org.simantics.issues;bundle-version="1.1.0",
org.simantics.document;bundle-version="1.0.0",
org.simantics.graph.db;bundle-version="1.1.9",
- org.bouncycastle.bcprov-jdk14;bundle-version="1.38.0",
+ org.bouncycastle;bundle-version="1.47.0",
org.simantics.image2.ontology;bundle-version="1.1.0",
org.simantics.scl.compiler;bundle-version="0.4.0",
org.simantics.scl.compiler.dummy;bundle-version="1.0.0",
import org.simantics.scl.compiler.errors.CompilationError;\r
import org.simantics.scl.compiler.errors.Locations;\r
import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.structural2.utils.StructuralUtils;\r
import org.simantics.ui.workbench.ResourceEditorInput;\r
import org.simantics.utils.logging.TimeLogger;\r
\r
\r
protected Resource resource;\r
protected String currentText;\r
+ protected boolean immutable;\r
protected boolean errorHappened;\r
\r
protected AnnotationModel annotationModel = new AnnotationModel();\r
public Document perform(ReadGraph graph) throws DatabaseException {\r
StructuralResource2 STR = StructuralResource2.getInstance(graph);\r
currentText = graph.getRelatedValue(resource, STR.ComponentTypeScript_code, Bindings.STRING);\r
+ Resource owner = graph.getPossibleObject(resource, STR.ComponentType_hasScript_Inverse);\r
+ immutable = owner != null && StructuralUtils.isImmutable(graph, owner);\r
errorHappened = false;\r
return new Document(currentText != null ? currentText : "");\r
}\r
\r
@Override\r
public boolean isModifiable(Object element) {\r
- return !errorHappened;\r
+ return !errorHappened && !immutable;\r
}\r
\r
@Override\r
public boolean isReadOnly(Object element) {\r
- return errorHappened;\r
+ return errorHappened || immutable;\r
}\r
\r
- @Override\r
- public boolean canSaveDocument(Object element) {\r
- return !errorHappened && !getDocument(element).get().equals(currentText);\r
- }\r
- \r
}\r
import org.simantics.db.common.request.UniqueRead;\r
import org.simantics.db.common.utils.NameUtils;\r
import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
import org.simantics.db.procedure.Listener;\r
import org.simantics.db.request.Read;\r
-import org.simantics.db.service.XSupport;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.modeling.ui.Activator;\r
import org.simantics.operation.Layer0X;\r
Layer0 L0 = Layer0.getInstance(graph);\r
Layer0X L0X = Layer0X.getInstance(graph);\r
StructuralResource2 STR = StructuralResource2.getInstance(graph);\r
+\r
+ boolean typeIsImmutable = graph.isImmutable(data.componentType)\r
+ || graph.hasStatement(data.componentType, STR.ComponentType_Locked)\r
+ || Layer0Utils.isPublished(graph, data.componentType)\r
+ || Layer0Utils.isContainerPublished(graph, data.componentType);\r
+\r
for(Resource relation : graph.getObjects(data.componentType, L0.DomainOf)) {\r
if(graph.isSubrelationOf(relation, L0.HasProperty)) {\r
String name = graph.getRelatedValue(relation, L0.HasName);\r
\r
String valid = expression != null ? DerivedPropertiesSection.validateMonitorExpression(graph, data.componentType, relation, expression) : null; \r
\r
- boolean immutable = graph.isImmutable(relation);\r
+ boolean immutable = typeIsImmutable || graph.isImmutable(relation);\r
ComponentTypeViewerPropertyInfo info =\r
new ComponentTypeViewerPropertyInfo(relation, name, type, defaultValue, numberType, unit, label, description, expression, valid, immutable);\r
\r
}\r
}\r
Collections.sort(result);\r
- XSupport xs = graph.peekService(XSupport.class);\r
- boolean immutable = xs != null ? xs.getImmutable(data.componentType) : false;\r
- return new ComponentTypePropertiesResult(result, connectionPoints, immutable);\r
+ return new ComponentTypePropertiesResult(result, connectionPoints, typeIsImmutable);\r
}\r
}, new Listener<ComponentTypePropertiesResult>() {\r
@Override\r
\r
import java.io.PrintWriter;\r
import java.io.StringWriter;\r
-import java.util.Arrays;\r
import java.util.Collections;\r
import java.util.List;\r
\r
import org.simantics.db.layer0.util.Layer0Utils;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.scl.compiler.errors.CompilationError;\r
-import org.simantics.scl.compiler.errors.Failable;\r
-import org.simantics.scl.compiler.errors.Failure;\r
import org.simantics.scl.compiler.errors.Locations;\r
-import org.simantics.scl.compiler.module.Module;\r
-import org.simantics.scl.compiler.module.repository.UpdateListener;\r
-import org.simantics.scl.osgi.SCLOsgi;\r
-import org.simantics.scl.runtime.SCLContext;\r
import org.simantics.ui.workbench.ResourceEditorInput;\r
import org.simantics.utils.logging.TimeLogger;\r
\r
}\r
}\r
\r
- // While this editor is active we do not want that this listener gets collected\r
- private UpdateListener listener = new UpdateListener() {\r
- @Override\r
- public void notifyAboutUpdate() {\r
- updateAnnotations();\r
- }\r
- };\r
-\r
protected void updateAnnotations() {\r
Simantics.getSession().asyncRequest(new ReadRequest() {\r
@Override\r
public void run(ReadGraph graph) throws DatabaseException {\r
-// String moduleName = graph.getURI(resource);\r
-// SCLContext context = SCLContext.getCurrent();\r
-// context.put("graph", graph);\r
-// Failable<Module> result = SCLOsgi.MODULE_REPOSITORY.getModule(moduleName, listener);\r
-// \r
-// if(result instanceof Failure) {\r
-// Failure failure = (Failure)result;\r
-// setAnnotations(Arrays.asList(failure.errors));\r
-// }\r
-// else {\r
-// setAnnotations(Collections.<CompilationError>emptyList());\r
-// }\r
- setAnnotations(Collections.<CompilationError>emptyList());\r
+ setAnnotations(Collections.emptyList());\r
}\r
});\r
}\r
return errorHappened;\r
}\r
\r
- @Override\r
- public boolean canSaveDocument(Object element) {\r
- return !errorHappened && !getDocument(element).get().equals(currentText);\r
- }\r
-\r
}\r
import org.simantics.scl.osgi.SCLOsgi;\r
import org.simantics.scl.runtime.SCLContext;\r
import org.simantics.scl.ui.editor.SCLSourceViewerConfigurationNew;\r
+import org.simantics.structural2.utils.StructuralUtils;\r
import org.simantics.ui.workbench.ResourceEditorInput;\r
import org.simantics.utils.logging.TimeLogger;\r
\r
\r
protected Resource resource;\r
protected String currentText;\r
+ protected boolean immutable;\r
protected boolean errorHappened;\r
\r
protected AnnotationModel annotationModel = new AnnotationModel();\r
public Document perform(ReadGraph graph) throws DatabaseException {\r
Layer0 L0 = Layer0.getInstance(graph);\r
currentText = graph.getRelatedValue(resource, L0.SCLModule_definition, Bindings.STRING);\r
+ immutable = StructuralUtils.isImmutable(graph, resource);\r
errorHappened = false;\r
return new Document(currentText != null ? currentText : "");\r
}\r
\r
@Override\r
public boolean isModifiable(Object element) {\r
- return !errorHappened;\r
+ return !errorHappened && !immutable;\r
}\r
\r
@Override\r
public boolean isReadOnly(Object element) {\r
- return errorHappened;\r
- }\r
-\r
- @Override\r
- public boolean canSaveDocument(Object element) {\r
- return !errorHappened && !getDocument(element).get().equals(currentText);\r
+ return errorHappened || immutable;\r
}\r
\r
}\r
return errorHappened;\r
}\r
\r
- @Override\r
- public boolean canSaveDocument(Object element) {\r
- return !errorHappened && !getDocument(element).get().equals(currentText);\r
- }\r
-\r
}\r
public Variable perform(ReadGraph graph) throws DatabaseException {\r
\r
DiagramResource DIA = DiagramResource.getInstance(graph);\r
+ ModelingResources MOD = ModelingResources.getInstance(graph);\r
\r
String uri = graph.getPossibleRelatedValue(resource, DIA.RuntimeDiagram_HasVariable);\r
if (uri == null)\r
if (var == null)\r
return null;\r
\r
- Resource config = graph.getPossibleObject(resource2, ModelingResources.getInstance(graph).ElementToComponent);\r
- if (config == null)\r
+ Resource config = graph.getPossibleObject(resource2, MOD.ElementToComponent);\r
+ if (config == null) {\r
+ // Apros #9646: if resource2 is the diagram\r
+ // itself, return the diagram composite variable\r
+ // since it is generally more useful than the\r
+ // variable to the diagram.\r
+ Resource composite = graph.getPossibleObject(resource2, MOD.DiagramToComposite);\r
+ if (composite != null && composite.equals(var.getPossibleRepresents(graph))) {\r
+ //return Variables.getPossibleVariable(graph, resource2);\r
+ return var;\r
+ }\r
+\r
return null;\r
+ }\r
\r
return var.browsePossible(graph, config);\r
\r
import org.simantics.scl.compiler.source.StringModuleSource;\r
import org.simantics.scl.compiler.source.repository.ModuleSourceRepository;\r
import org.simantics.scl.runtime.SCLContext;\r
+import org.simantics.structural2.utils.StructuralUtils;\r
import org.simantics.scl.runtime.tuple.Tuple0;\r
\r
import gnu.trove.procedure.TObjectProcedure;\r
\r
public static class GraphModuleSource extends StringModuleSource {\r
\r
- public GraphModuleSource(String moduleName, ClassLoader classLoader, String moduleText) {\r
+ private final boolean immutable;\r
+\r
+ public GraphModuleSource(String moduleName, ClassLoader classLoader, String moduleText, boolean immutable) {\r
super(moduleName, classLoader, moduleText);\r
+ this.immutable = immutable;\r
}\r
\r
@Override\r
public boolean isUpdateable() {\r
- return true;\r
+ return !immutable;\r
}\r
\r
@Override\r
if(!graph.isInstanceOf(moduleResource, L0.SCLModule))\r
return null;\r
String text = graph.getRelatedValue(moduleResource, L0.SCLModule_definition);\r
- return new GraphModuleSource(parameter, getClass().getClassLoader(), text);\r
+ boolean immutable = StructuralUtils.isImmutable(graph, moduleResource);\r
+ return new GraphModuleSource(parameter, getClass().getClassLoader(), text, immutable);\r
}\r
}\r
\r
import org.simantics.db.WriteGraph;\r
import org.simantics.db.common.CommentMetadata;\r
import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.request.PossibleTypedParent;\r
import org.simantics.db.common.utils.NameUtils;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.layer0.exception.MissingVariableException;\r
}\r
return null;\r
}\r
- \r
+\r
+ public static boolean isImmutable(ReadGraph graph, Resource r) throws DatabaseException {\r
+ StructuralResource2 STR = StructuralResource2.getInstance(graph);\r
+ Resource uc = graph.syncRequest(new PossibleTypedParent(r, STR.ComponentType));\r
+ return graph.isImmutable(r)\r
+ // Anything under a published or locked user component is published as well\r
+ || (uc != null && (Layer0Utils.isPublished(graph, uc)\r
+ || graph.hasStatement(uc, STR.ComponentType_Locked)))\r
+ // Anything under a published container (shared library) is published as well\r
+ || Layer0Utils.isContainerPublished(graph, r)\r
+ ;\r
+ }\r
+\r
}\r