import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.swt.widgets.Group;\r
import org.eclipse.ui.IWorkbenchSite;\r
+import org.lobobrowser.util.ID;\r
import org.simantics.browsing.ui.swt.widgets.Label;\r
import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.IsParent;\r
+import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.management.ISessionContext;\r
+import org.simantics.db.request.Read;\r
import org.simantics.jfreechart.chart.properties.AdjustableTab;\r
import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.ui.properties.widgets.FunctionLabelFactory;\r
import org.simantics.sysdyn.ui.properties.widgets.expressions.ExpressionField;\r
import org.simantics.sysdyn.ui.properties.widgets.factories.FunctionNameInputValidator;\r
information = new TrackedText(documentationGroup, support, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);\r
information.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasDescription));\r
information.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasDescription));\r
+ \r
+ if (id instanceof Resource) {\r
+ final Resource r = (Resource) id;\r
+ try {\r
+ boolean editable = context.getSession().syncRequest(new Read<Boolean>() {\r
+\r
+ @Override\r
+ public Boolean perform(ReadGraph graph) throws DatabaseException {\r
+ boolean editable = new IsParent(SysdynResource.getInstance(graph).Built$in_Functions, r).perform(graph);\r
+ return !editable;\r
+ }\r
+ });\r
+ information.setEditable(editable);\r
+ nameText.setEditable(editable);\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
}\r
\r
@Override\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.IsParent;\r
import org.simantics.db.common.request.WriteRequest;\r
import org.simantics.db.common.utils.ListUtils;\r
import org.simantics.db.exception.DatabaseException;\r
});\r
if(code != null) {\r
modelicaCode.setExpression(code);\r
+ \r
+ boolean editable = context.getSession().syncRequest(new Read<Boolean>() {\r
+\r
+ @Override\r
+ public Boolean perform(ReadGraph graph) throws DatabaseException {\r
+ boolean asd = new IsParent(SysdynResource.getInstance(graph).Built$in_Functions, function).perform(graph);\r
+ return !asd;\r
+ }\r
+ });\r
+ modelicaCode.getSourceViewer().setEditable(editable);\r
validate();\r
}\r
} catch (DatabaseException e) {\r
}\r
\r
private void save() {\r
+ \r
+ if (!modelicaCode.getSourceViewer().isEditable())\r
+ return;\r
+ \r
final String code = modelicaCode.getExpression();\r
\r
// Update input and output lists.\r