]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ConfigurationPropertiesSection.java
Externalize strings
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / componentTypeEditor / ConfigurationPropertiesSection.java
index 9a2a713df0fa8807ddd55ac48935343ad824bb5f..34d26e4915e387ca0d04266be246ede57d1081cd 100644 (file)
@@ -68,9 +68,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 +90,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 +111,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);
@@ -228,18 +235,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 +294,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 +362,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<String, ImageDescriptor>(name, null));
                                         
                                     }
@@ -370,7 +377,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 +436,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 +454,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 +477,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) {
@@ -530,8 +537,8 @@ public class ConfigurationPropertiesSection implements ComponentTypeViewerSectio
             item.setText(0, info.name);
             item.setText(1, info.type);
             item.setText(2, info.defaultValue);
-            item.setText(3, unitStr(info));
-            item.setText(4, rangeStr(info));
+            item.setText(3, info.unitString());
+            item.setText(4, info.rangeString());
             item.setText(5, info.label);
             item.setText(6, info.description);
 
@@ -569,23 +576,11 @@ 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();
         }
     }
 
-    private String unitStr(ComponentTypeViewerPropertyInfo info) {
-        String unit = info.numberType == null ? null : info.numberType.getUnit();
-        if (unit == null)
-            unit = info.unit;
-        return unit != null ? unit : "";
-    }
-
-    private String rangeStr(ComponentTypeViewerPropertyInfo info) {
-        String range = info.numberType == null ? null : info.numberType.getRangeStr();
-        return range != null ? range : "";
-    }
-    
     @Override
     public void setReadOnly(boolean readOnly) {
         boolean e = !readOnly;