X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2FcomponentTypeEditor%2FConfigurationPropertiesSection.java;h=ef44ddf12adf4aa1c8d81fe379606eb5497e8fb8;hb=bb61be97905f72c01fd99e21c263546c88edc5f7;hp=e919aa71f00d01a8fa27b926a022aef077609e38;hpb=b825d7a7aff95002f355878ec2767352411b5a43;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ConfigurationPropertiesSection.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ConfigurationPropertiesSection.java index e919aa71f..ef44ddf12 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ConfigurationPropertiesSection.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ConfigurationPropertiesSection.java @@ -59,6 +59,8 @@ import org.simantics.layer0.Layer0; import org.simantics.modeling.ui.Activator; import org.simantics.modeling.ui.componentTypeEditor.LiftPropertiesDialog.LiftedProperty; import org.simantics.modeling.userComponent.ComponentTypeCommands; +import org.simantics.modeling.utils.ComponentTypePropertiesResult; +import org.simantics.modeling.utils.ComponentTypeViewerPropertyInfo; import org.simantics.selectionview.SelectionViewResources; import org.simantics.structural.stubs.StructuralResource2; import org.simantics.utils.datastructures.Pair; @@ -68,9 +70,16 @@ import org.slf4j.LoggerFactory; public class ConfigurationPropertiesSection implements ComponentTypeViewerSection { private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationPropertiesSection.class); - - private static final String[] COLUMN_NAMES = - new String[] {"Name", "Type", "Default Value", "Unit", "Range", "Label", "Description"}; + + private static final String[] COLUMN_NAMES = { + Messages.ConfigurationPropertiesSection_Name, + Messages.ConfigurationPropertiesSection_Type, + Messages.ConfigurationPropertiesSection_DefaultValue, + Messages.ConfigurationPropertiesSection_Unit, + Messages.ConfigurationPropertiesSection_Range, + Messages.ConfigurationPropertiesSection_Label, + Messages.ConfigurationPropertiesSection_Description + }; private static final int[] COLUMN_LENGTHS = new int[] { 120, 100, 100, 50, 100, 100, 100 }; private static final int[] COLUMN_WEIGHTS = @@ -83,8 +92,8 @@ public class ConfigurationPropertiesSection implements ComponentTypeViewerSectio */ private static final int[] IMMUTABLE_COLUMNS_WITH_IMMUTABLE_RELATION = { 0, 1, 3, 4, 5, 6 }; - ComponentTypeViewerData data; + Table table; TableColumn[] columns; TableEditor editor; @@ -104,7 +113,7 @@ public class ConfigurationPropertiesSection implements ComponentTypeViewerSectio section = tk.createSection(form.getBody(), Section.TITLE_BAR | Section.EXPANDED); section.setLayout(new FillLayout()); - section.setText("Configuration properties"); + section.setText(Messages.ConfigurationPropertiesSection_ConfigurationProperties); Composite sectionBody = tk.createComposite(section); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(sectionBody); @@ -176,7 +185,7 @@ public class ConfigurationPropertiesSection implements ComponentTypeViewerSectio break; case 1: - data.editType(table, editor, propertyInfo, selectedItem, column, true); + data.editType(table, editor, propertyInfo, selectedItem, column, selectedItem.getText(4), true); break; case 2: { @@ -228,18 +237,18 @@ public class ConfigurationPropertiesSection implements ComponentTypeViewerSectio GridDataFactory.fillDefaults().applyTo(buttons); GridLayoutFactory.fillDefaults().applyTo(buttons); - newProperty = tk.createButton(buttons, "New property", SWT.PUSH); + newProperty = tk.createButton(buttons, Messages.ConfigurationPropertiesSection_NewProperty, SWT.PUSH); GridDataFactory.fillDefaults().applyTo(newProperty); - removeProperty = tk.createButton(buttons, "Remove property", SWT.PUSH); + removeProperty = tk.createButton(buttons, Messages.ConfigurationPropertiesSection_RemoveProperty, SWT.PUSH); GridDataFactory.fillDefaults().applyTo(removeProperty); - liftProperties = tk.createButton(buttons, "Lift Properties", SWT.PUSH); + liftProperties = tk.createButton(buttons, Messages.ConfigurationPropertiesSection_LiftProperties, SWT.PUSH); GridDataFactory.fillDefaults().applyTo(liftProperties); hasTypes = !getTypes().isEmpty(); if(hasTypes) { - setTypes = tk.createButton(buttons, "Assign Types", SWT.PUSH); + setTypes = tk.createButton(buttons, Messages.ConfigurationPropertiesSection_AssignTypes, SWT.PUSH); GridDataFactory.fillDefaults().applyTo(setTypes); } @@ -287,7 +296,7 @@ public class ConfigurationPropertiesSection implements ComponentTypeViewerSectio if (!info.immutable) propertiesToBeRemoved.add(info.resource); } - System.out.println("remove " + propertiesToBeRemoved.size() + " resources"); + //System.out.println("remove " + propertiesToBeRemoved.size() + " resources"); //$NON-NLS-1$ //$NON-NLS-2$ if(!propertiesToBeRemoved.isEmpty()) Simantics.getSession().async(new WriteRequest() { @Override @@ -355,7 +364,7 @@ public class ConfigurationPropertiesSection implements ComponentTypeViewerSectio String predicateName = NameUtils.getSafeName(graph, predicate); if(existing.contains(predicateName)) continue; - String name = componentName + " " + predicateName; + String name = componentName + " " + predicateName; //$NON-NLS-1$ map.put(new LiftedProperty(component, type, predicate), new Pair(name, null)); } @@ -370,7 +379,7 @@ public class ConfigurationPropertiesSection implements ComponentTypeViewerSectio }); Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - LiftPropertiesDialog dialog = new LiftPropertiesDialog(shell, map, "Select properties to lift") { + LiftPropertiesDialog dialog = new LiftPropertiesDialog(shell, map, Messages.ConfigurationPropertiesSection_SelectPropertiesToLift) { @Override protected IDialogSettings getBaseDialogSettings() { return Activator.getDefault().getDialogSettings(); @@ -429,13 +438,13 @@ public class ConfigurationPropertiesSection implements ComponentTypeViewerSectio graph.claim(data.componentType, L0.DomainOf, copy); Layer0Utils.assert_(graph, data.componentType, copy, copyAss.iterator().next()); CommentMetadata cm = graph.getMetadata(CommentMetadata.class); - graph.addMetadata(cm.add("Lifted property " + NameUtils.getSafeName(graph, copy) + " into "+ NameUtils.getSafeName(graph, data.componentType))); + graph.addMetadata(cm.add("Lifted property " + NameUtils.getSafeName(graph, copy) + " into "+ NameUtils.getSafeName(graph, data.componentType))); //$NON-NLS-1$ //$NON-NLS-2$ } if(mapProperties) { Variable v = Variables.getVariable(graph, p.getComponent()); Variable property = v.getProperty(graph, p.getPredicate()); Variable displayValue = property.getProperty(graph, Variables.DISPLAY_VALUE); - displayValue.setValue(graph, "=" + NameUtils.getSafeName(graph, p.getPredicate()), Bindings.STRING); + displayValue.setValue(graph, "=" + NameUtils.getSafeName(graph, p.getPredicate()), Bindings.STRING); //$NON-NLS-1$ } index++; } @@ -447,7 +456,7 @@ public class ConfigurationPropertiesSection implements ComponentTypeViewerSectio } catch (DatabaseException e1) { - LOGGER.error("Lifting properties failed", e1); + LOGGER.error("Lifting properties failed", e1); //$NON-NLS-1$ return; } @@ -470,7 +479,7 @@ public class ConfigurationPropertiesSection implements ComponentTypeViewerSectio if(propertiesToSet.size() != 1) return; Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - SetTypesDialog page = new SetTypesDialog(shell, getTypes(), "Select user types for property"); + SetTypesDialog page = new SetTypesDialog(shell, getTypes(), Messages.ConfigurationPropertiesSection_SelectUserTypesForProp); if (page.open() == Window.OK) { final Object[] result = page.getResult(); if (result != null && result.length > 0) { @@ -569,7 +578,7 @@ public class ConfigurationPropertiesSection implements ComponentTypeViewerSectio } }); } catch (DatabaseException e) { - LOGGER.error("Finding UserDefinedProperties failed.", e); + LOGGER.error("Finding UserDefinedProperties failed.", e); //$NON-NLS-1$ return Collections.emptyMap(); } }