X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2FcomponentTypeEditor%2FDerivedPropertiesSection.java;h=869d5e32aada675fb56981116fd2eb8ac0961c56;hb=3260b37ec9ce61bc8a1383a5fc9ab8d8ab9d1fae;hp=1fa503515b4e840c8bd5c55a7b1ae8729fa2626b;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/DerivedPropertiesSection.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/DerivedPropertiesSection.java index 1fa503515..869d5e32a 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/DerivedPropertiesSection.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/DerivedPropertiesSection.java @@ -42,12 +42,18 @@ import org.simantics.scl.runtime.function.Function4; import org.simantics.structural.stubs.StructuralResource2; public class DerivedPropertiesSection implements ComponentTypeViewerSection { - private static final String[] COLUMN_NAMES = - new String[] {"Name", "Type", "Expression", "Label", "Description"}; + private static final String[] COLUMN_NAMES = { + Messages.DerivedPropertiesSection_Name, + Messages.DerivedPropertiesSection_Type, + Messages.DerivedPropertiesSection_Expression, + Messages.DerivedPropertiesSection_Unit, + Messages.DerivedPropertiesSection_Label, + Messages.DerivedPropertiesSection_Description + }; private static final int[] COLUMN_LENGTHS = - new int[] { 120, 100, 100, 100, 100 }; + new int[] { 120, 100, 100, 70, 100, 100 }; private static final int[] COLUMN_WEIGHTS = - new int[] { 0, 0, 100, 0, 0 }; + new int[] { 0, 0, 100, 0, 0, 0 }; private static Function4 VALIDATE_MONITOR_EXPRESSION = new Function4() { @Override @@ -71,7 +77,7 @@ public class DerivedPropertiesSection implements ComponentTypeViewerSection { Form form = data.form; section = tk.createSection(form.getBody(), Section.TITLE_BAR | Section.EXPANDED); section.setLayout(new FillLayout()); - section.setText("Derived properties"); + section.setText(Messages.DerivedPropertiesSection_DerivedProperties); Composite sectionBody = tk.createComposite(section); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(sectionBody); @@ -155,11 +161,11 @@ public class DerivedPropertiesSection implements ComponentTypeViewerSection { }, VALIDATE_MONITOR_EXPRESSION); break; -// case 3: -// editUnit(table2, editor2, propertyInfo, selectedItem, column); -// break; - case 3: + data.editUnit(table, editor, propertyInfo, selectedItem, column); + break; + + case 4: data.editValue(table, editor, propertyInfo, selectedItem, column, propertyInfo.immutable ? null : new StringWriter() { @Override public void perform(WriteGraph graph, String newValue) throws DatabaseException { @@ -170,7 +176,7 @@ public class DerivedPropertiesSection implements ComponentTypeViewerSection { }, null); break; - case 4: + case 5: data.editMultilineText(table, editor, propertyInfo, selectedItem, selectedItemBounds, column, new StringWriter() { @Override public void perform(WriteGraph graph, String newValue) throws DatabaseException { @@ -191,9 +197,9 @@ public class DerivedPropertiesSection implements ComponentTypeViewerSection { GridDataFactory.fillDefaults().applyTo(buttons); GridLayoutFactory.fillDefaults().applyTo(buttons); - newProperty = tk.createButton(buttons, "New property", SWT.PUSH); + newProperty = tk.createButton(buttons, Messages.DerivedPropertiesSection_NewProperty, SWT.PUSH); GridDataFactory.fillDefaults().applyTo(newProperty); - removeProperty = tk.createButton(buttons, "Remove property", SWT.PUSH); + removeProperty = tk.createButton(buttons, Messages.DerivedPropertiesSection_RemoveProperty, SWT.PUSH); GridDataFactory.fillDefaults().applyTo(removeProperty); // Actions @@ -247,11 +253,11 @@ public class DerivedPropertiesSection implements ComponentTypeViewerSection { public static String validateMonitorExpression(final RequestProcessor processor, final Resource componentType, final Resource relation, final String expression) { if (expression.trim().isEmpty()) { - return "Expression is empty."; + return Messages.DerivedPropertiesSection_ExpressionIsEmpty; } if (expression.trim().isEmpty()) { - return "Expression is empty."; + return Messages.DerivedPropertiesSection_ExpressionIsEmpty; } try { return processor.sync(new UniqueRead() { @@ -282,7 +288,7 @@ public class DerivedPropertiesSection implements ComponentTypeViewerSection { } catch (Exception e) { String msg = e.getMessage(); - int index = msg.indexOf(":"); + int index = msg.indexOf(":"); //$NON-NLS-1$ if(index > 0) msg = msg.substring(index); return msg; } @@ -327,12 +333,12 @@ public class DerivedPropertiesSection implements ComponentTypeViewerSection { TableItem item = new TableItem(table, SWT.NONE); - item.setText(0, info.valid != null ? info.name + " (!)" : info.name); + item.setText(0, info.valid != null ? info.name + " (!)" : info.name); //$NON-NLS-1$ item.setText(1, info.type); item.setText(2, info.expression); - //item.setText(3, unitStr(info)); - item.setText(3, info.label); - item.setText(4, info.description); + item.setText(3, info.unitString()); + item.setText(4, info.label); + item.setText(5, info.description); item.setForeground(fg); @@ -376,4 +382,4 @@ public class DerivedPropertiesSection implements ComponentTypeViewerSection { return 100.0; } -} +} \ No newline at end of file