import java.util.Collection;\r
import java.util.Collections;\r
import java.util.HashMap;\r
+import java.util.List;\r
import java.util.Map;\r
import java.util.Set;\r
\r
import org.simantics.db.Session;\r
import org.simantics.db.WriteGraph;\r
import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.request.PossibleObjectWithType;\r
import org.simantics.db.common.request.WriteRequest;\r
import org.simantics.db.common.request.WriteResultRequest;\r
+import org.simantics.db.common.utils.ListUtils;\r
import org.simantics.db.common.utils.NameUtils;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.exception.ResourceNotFoundException;\r
import org.simantics.db.layer0.migration.MigrationUtils;\r
import org.simantics.db.layer0.util.RemoverUtil;\r
import org.simantics.db.request.Read;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
import org.simantics.issues.common.AllBatchIssueSources;\r
import org.simantics.issues.common.BatchIssueSource;\r
import org.simantics.issues.ontology.IssueResource;\r
final Resource project = SimanticsUI.getProject().get();\r
if(project == null) return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model: project not found", null);\r
\r
- beginTask(monitor, "Import model", 7);\r
+ beginTask(monitor, "Import model", 8);\r
\r
Activator.getDefault().getPreferenceStore().setValue(IMPORTMODELTPATH, (new File(path)).getParent());\r
\r
subTask(monitor, "Add enumeration issue source");\r
addEnumerationIssueSource(graph, ModelRoot);\r
worked(monitor, 1);\r
+ subTask(monitor, "Add shadow profile");\r
+ addShadowProfile(graph, ModelRoot);\r
+ worked(monitor, 1); \r
subTask(monitor, "Activate model");\r
activateModel(graph, ModelRoot);\r
worked(monitor, 1);\r
L0X.IsActivatedBy, modelRoot,\r
L0.PartOf, modelRoot\r
); \r
- } }\r
+ } \r
+ }\r
+ \r
+ private static void addShadowProfile(WriteGraph graph, Resource modelRoot) throws DatabaseException {\r
+ DiagramResource DIA = DiagramResource.getInstance(graph);\r
+ SysdynResource SR = SysdynResource.getInstance(graph);\r
+ Resource defaultProfile = graph.syncRequest(new PossibleObjectWithType(modelRoot, Layer0.getInstance(graph).ConsistsOf, SR.DefaultProfile));\r
+ if(defaultProfile != null) {\r
+ Resource entryList = graph.getPossibleObject(defaultProfile, DIA.HasEntries);\r
+ if(entryList != null) {\r
+ List<Resource> entries = ListUtils.toList(graph, entryList);\r
+ if(entries != null && !entries.contains(SR.Profiles_ShadowVisualizations)) {\r
+ ListUtils.insertBack(graph, entryList, Collections.singletonList(SR.Profiles_ShadowVisualizations));\r
+ }\r
+ }\r
+ \r
+ }\r
+ }\r
\r
private static Collection<Resource> findAllConfigurations(ReadGraph graph, Resource modelRoot) throws DatabaseException {\r
SysdynResource sr = SysdynResource.getInstance(graph);\r