import org.eclipse.swt.widgets.Tree;\r
import org.eclipse.ui.IWorkbenchSite;\r
import org.simantics.browsing.ui.swt.AdaptableHintContext;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
import org.simantics.browsing.ui.swt.SingleSelectionInputSource;\r
import org.simantics.browsing.ui.swt.widgets.Button;\r
import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
import org.simantics.sysdyn.ui.properties.widgets.ColumnKeys;\r
import org.simantics.utils.datastructures.ArrayMap;\r
\r
-public class ArrayIndexesTab extends PropertyTabContributorImpl implements Widget{\r
+public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widget{\r
\r
GraphExplorerComposite availableEnumerationsExplorer;\r
GraphExplorerComposite usedEnumerationsExplorer;\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.swt.widgets.Label;\r
import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\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.TrackedCombo;\r
import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListenerImpl;\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.WriteGraph;\r
+import org.simantics.db.common.utils.NameUtils;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.management.ISessionContext;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
import org.simantics.sysdyn.ui.utils.VariableNameUtils;\r
\r
-public class ConfigurationTab extends PropertyTabContributorImpl {\r
-\r
+public class ConfigurationTab extends LabelPropertyTabContributor {\r
+\r
+ private class ModelLabelModifier extends TextModifyListenerImpl<Resource> {\r
+\r
+ public ModelLabelModifier(ISessionContext context, String propertyURI) {\r
+ }\r
+ \r
+ @Override\r
+ public void applyText(WriteGraph graph, Resource issue, String text) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ graph.claimLiteral(issue, l0.HasLabel, text);\r
+ String safeName = NameUtils.findFreshName(graph, text, graph.getSingleObject(issue, l0.PartOf), l0.ConsistsOf, "%s%d");\r
+ graph.claimLiteral(issue, l0.HasName, safeName);\r
+ }\r
+ \r
+ }\r
\r
\r
@Override\r
\r
TrackedText name = new TrackedText(composite, support, SWT.BORDER);\r
name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel));\r
- name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
+ name.addModifyListener(new ModelLabelModifier(context, Layer0.URIs.HasLabel));\r
name.setInputValidator(new IInputValidator() {\r
\r
@Override\r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\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.db.management.ISessionContext;\r
import org.simantics.layer0.Layer0;\r
\r
-public class DependencyTab extends PropertyTabContributorImpl {\r
+public class DependencyTab extends LabelPropertyTabContributor {\r
\r
@Override\r
public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
import org.eclipse.swt.widgets.TreeItem;\r
import org.eclipse.ui.IWorkbenchSite;\r
import org.simantics.browsing.ui.NodeContext;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
import org.simantics.browsing.ui.swt.SingleSelectionInputSource;\r
import org.simantics.browsing.ui.swt.widgets.Button;\r
import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
import org.simantics.ui.utils.AdaptionUtils;\r
import org.simantics.utils.datastructures.ArrayMap;\r
\r
-public class EnumerationTab extends PropertyTabContributorImpl implements Widget {\r
+public class EnumerationTab extends LabelPropertyTabContributor implements Widget {\r
\r
GraphExplorerComposite indexExplorer;\r
\r
import org.eclipse.ui.IWorkbenchPartReference;\r
import org.eclipse.ui.IWorkbenchSite;\r
import org.simantics.browsing.ui.platform.PropertyPageView;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
import org.simantics.browsing.ui.swt.widgets.Button;\r
import org.simantics.browsing.ui.swt.widgets.TrackedCombo;\r
import org.simantics.browsing.ui.swt.widgets.impl.ComboModifyListenerImpl;\r
import org.simantics.ui.utils.AdaptionUtils;\r
import org.simantics.utils.datastructures.Pair;\r
\r
-public class EquationTab extends PropertyTabContributorImpl implements Widget {\r
+public class EquationTab extends LabelPropertyTabContributor implements Widget {\r
\r
TrackedCombo expressionTypeCombo, unitCombo, arrayEquationCombo;\r
ShortcutTabWidget shortcutTabWidget;\r
\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
import org.simantics.db.management.ISessionContext;\r
\r
-public class ExperimentTab extends PropertyTabContributorImpl {\r
+public class ExperimentTab extends LabelPropertyTabContributor {\r
\r
@Override\r
public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
import org.eclipse.swt.widgets.Shell;\r
import org.eclipse.swt.widgets.Tree;\r
import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
import org.simantics.browsing.ui.swt.SingleSelectionInputSource;\r
import org.simantics.browsing.ui.swt.widgets.Button;\r
import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
import org.simantics.utils.datastructures.ArrayMap;\r
import org.simantics.utils.datastructures.Pair;\r
\r
-public class ExternalFilesTab extends PropertyTabContributorImpl implements Widget {\r
+public class ExternalFilesTab extends LabelPropertyTabContributor implements Widget {\r
\r
GraphExplorerComposite externalFilesExplorer;\r
Button importButton; \r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\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.db.management.ISessionContext;\r
import org.simantics.layer0.Layer0;\r
\r
-public class FunctionLibraryTab extends PropertyTabContributorImpl {\r
+public class FunctionLibraryTab extends LabelPropertyTabContributor {\r
\r
@Override\r
public void createControls(Composite body, IWorkbenchSite site,\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.swt.widgets.Group;\r
import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\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.sysdyn.manager.FunctionUtils;\r
import org.simantics.sysdyn.ui.properties.widgets.FunctionLabelFactory;\r
\r
-public class FunctionTab extends PropertyTabContributorImpl {\r
+public class FunctionTab extends LabelPropertyTabContributor {\r
\r
@Override\r
public void createControls(Composite body, IWorkbenchSite site,\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.swt.widgets.Label;\r
import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNamePropertyModifier;\r
import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNameValidator;\r
\r
-public class InputVariableTab extends PropertyTabContributorImpl {\r
+public class InputVariableTab extends LabelPropertyTabContributor {\r
\r
\r
@Override\r
--- /dev/null
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
+import org.simantics.db.AsyncReadGraph;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.procedure.AsyncListener;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.datastructures.Callback;\r
+\r
+public abstract class LabelPropertyTabContributor extends PropertyTabContributorImpl {\r
+\r
+ \r
+ public void updatePartName(ISelection forSelection, final Callback<String> updateCallback) {\r
+ final Resource r = AdaptionUtils.adaptToSingle(forSelection, Resource.class);\r
+ if(r == null) {\r
+ updateCallback.run("Selection properties");\r
+ return;\r
+ }\r
+ \r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new Read<String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ String label = graph.getPossibleRelatedValue(r, l0.HasLabel);\r
+ if(label != null)\r
+ return label;\r
+ label = graph.getPossibleRelatedValue(r, l0.HasName);\r
+ if(label != null)\r
+ return label;\r
+ return "No name for selection";\r
+ }\r
+ }, new AsyncListener<String>() {\r
+\r
+ @Override\r
+ public void execute(AsyncReadGraph graph, String result) {\r
+ updateCallback.run(result);\r
+ }\r
+\r
+ @Override\r
+ public void exception(AsyncReadGraph graph, Throwable throwable) {\r
+ \r
+ }\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ return false;\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ updateCallback.run("Selection error in LabelPropertyTabContributor");\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ }\r
+}\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.swt.widgets.Label;\r
import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
import org.simantics.db.management.ISessionContext;\r
import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
\r
-public class LookupTableTab extends PropertyTabContributorImpl {\r
+public class LookupTableTab extends LabelPropertyTabContributor {\r
\r
@Override\r
public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
import org.simantics.db.management.ISessionContext;\r
\r
-public class ModelTab extends PropertyTabContributorImpl {\r
+public class ModelTab extends LabelPropertyTabContributor {\r
\r
@Override\r
public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\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.structural.stubs.StructuralResource2;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.ui.properties.widgets.ModuleInputEditingSupport;\r
-import org.simantics.sysdyn.ui.properties.widgets.ReferenceTable;\r
import org.simantics.sysdyn.ui.properties.widgets.ReferenceRow;\r
-import org.simantics.sysdyn.ui.properties.widgets.RowProvider;\r
import org.simantics.sysdyn.ui.properties.widgets.ReferenceRowLabelProvider;\r
+import org.simantics.sysdyn.ui.properties.widgets.ReferenceTable;\r
+import org.simantics.sysdyn.ui.properties.widgets.RowProvider;\r
\r
-public class ModuleInputTab extends PropertyTabContributorImpl {\r
+public class ModuleInputTab extends LabelPropertyTabContributor {\r
\r
public static final String FIRSTCOLUMN = "Input in Module";\r
public static final String SECONDCOLUMN = "Refers to output";\r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\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.sysdyn.ui.properties.widgets.ReferenceTable;\r
import org.simantics.sysdyn.ui.properties.widgets.RowProvider;\r
\r
-public class ModuleOutputTab extends PropertyTabContributorImpl {\r
+public class ModuleOutputTab extends LabelPropertyTabContributor {\r
\r
public static final String FIRSTCOLUMN = "Output in module";\r
public static final String SECONDCOLUMN = "Referes to input";\r
import org.eclipse.swt.widgets.Label;\r
import org.eclipse.swt.widgets.Tree;\r
import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
import org.simantics.browsing.ui.swt.SingleSelectionInputSource;\r
import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
import org.simantics.sysdyn.ui.properties.widgets.ColumnKeys;\r
import org.simantics.utils.datastructures.ArrayMap;\r
\r
-public class ModuleTab extends PropertyTabContributorImpl implements Widget {\r
+public class ModuleTab extends LabelPropertyTabContributor implements Widget {\r
\r
GraphExplorerComposite enumerationRedeclarationExplorer;\r
\r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\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.db.management.ISessionContext;\r
import org.simantics.layer0.Layer0;\r
\r
-public class ModuleTypeTab extends PropertyTabContributorImpl {\r
+public class ModuleTypeTab extends LabelPropertyTabContributor {\r
\r
@Override\r
public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
import org.simantics.db.management.ISessionContext;\r
\r
-public class ReferenceDependencyTab extends PropertyTabContributorImpl {\r
+public class ReferenceDependencyTab extends LabelPropertyTabContributor {\r
\r
@Override\r
public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
import org.simantics.db.management.ISessionContext;\r
\r
-public class ResultTab extends PropertyTabContributorImpl {\r
+public class ResultTab extends LabelPropertyTabContributor {\r
\r
@Override\r
public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
import org.eclipse.ui.IWorkbenchSite;\r
import org.simantics.browsing.ui.NodeContext;\r
import org.simantics.browsing.ui.swt.AdaptableHintContext;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
import org.simantics.browsing.ui.swt.SingleSelectionInputSource;\r
import org.simantics.browsing.ui.swt.widgets.Button;\r
import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
import org.simantics.ui.utils.AdaptionUtils;\r
import org.simantics.utils.datastructures.ArrayMap;\r
\r
-public class SharedFunctionLibrariesTab extends PropertyTabContributorImpl implements Widget {\r
+public class SharedFunctionLibrariesTab extends LabelPropertyTabContributor implements Widget {\r
\r
GraphExplorerComposite availableSharedFunctionLibraries;\r
GraphExplorerComposite usedSharedFunctionLibraries;\r
\r
import java.util.Set;\r
\r
-import org.eclipse.jface.viewers.ISelection;\r
import org.eclipse.ui.IWorkbenchPartSite;\r
import org.simantics.browsing.ui.swt.StandardPropertyPage;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.modeling.ModelingUtils;\r
\r
public class SysdynPropertyPage extends StandardPropertyPage {\r
\r
public SysdynPropertyPage(IWorkbenchPartSite site, Set<String> set) {\r
super(site, set);\r
}\r
-\r
- @Override\r
- protected String computeTitle(ReadGraph graph, ISelection selection) throws DatabaseException {\r
- return ModelingUtils.computeTitle(graph, selection, MAX_SELECTION_LENGTH_TO_SHOW, true);\r
- }\r
-\r
}\r
import org.eclipse.swt.widgets.Group;\r
import org.eclipse.swt.widgets.Label;\r
import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\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.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
\r
-public class VariableInformationTab extends PropertyTabContributorImpl {\r
+public class VariableInformationTab extends LabelPropertyTabContributor {\r
\r
@Override\r
public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r