Author: bobtarling
Date: 2009-12-20 03:55:27-0800
New Revision: 17688

Modified:
   
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/CheckBox.java
   
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java

Log:
Use i18n to set checkbox label

Modified: 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/CheckBox.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/CheckBox.java?view=diff&pathrev=17688&r1=17687&r2=17688
==============================================================================
--- 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/CheckBox.java
       (original)
+++ 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/CheckBox.java
       2009-12-20 03:55:27-0800
@@ -14,6 +14,11 @@
 import org.argouml.ui.LookAndFeelMgr;
 import org.argouml.ui.UndoableAction;
 
+/**
+ * A check box representing a boolean property in the UML model
+ * @author Bob Tarling
+ * @since 0.29.2 19th Dec 2009
+ */
 class CheckBox extends JCheckBox 
     implements PropertyChangeListener {
 
@@ -22,44 +27,60 @@
      */
     private static final long serialVersionUID = 2654856740168885592L;
 
-    private Object target;
-    private String propertyName;
+    private final Object modelElement;
+    
+    private final String propertyName;
     
     /**
      * The action that will be called when the checkbox changes
      */
-    private Action action;
+    private final Action action;
 
     private final GetterSetter getterSetter;
     
     /**
      * Constructor for UMLCheckBox.
      * @param text the text of the check box
-     * @param a the action we're going to listen to
-     * @param name the property set name
-     */
-    public CheckBox(final String propertyName, final Object target, 
GetterSetter getterSetter) {
-        super(Translator.localize("label." + propertyName));
+     * @param modelElement the model element the check box represents, updates 
and
+     * is listening for changes to
+     * @param propertyName the property of the target that the checkbox is 
listening
+     * @param getterSetter the facade used to get and set properties on the 
model
+     * for and updating
+     */
+    public CheckBox(
+            final String text,
+            final Object modelElement,
+            final String propertyName, 
+            final GetterSetter getterSetter) {
+        super(text);
         
         this.getterSetter = getterSetter;
         this.propertyName = propertyName;
-        this.target = target;
+        this.modelElement = modelElement;
         
         setFont(LookAndFeelMgr.getInstance().getStandardFont());
         
         build();
         
-        action = new SetAction(getterSetter, target, propertyName);
+        action = new SetAction(getterSetter, modelElement, propertyName);
         setActionCommand((String) action.getValue(Action.ACTION_COMMAND_KEY));
     }
     
+    private String propertyToLabel(String propertyName) {
+        if (propertyName.startsWith("is")) {
+            return "checkbox." + propertyName.substring(2).toLowerCase();
+        } else {
+            return "checkbox." + propertyName.toLowerCase();
+        }
+    }
+    
     /**
      * Add listeners when the component is placed on its parent
      */
     public void addNotify() {
         addActionListener(action);
         Model.getPump().addModelEventListener(
-                this, target, propertyName);
+                this, modelElement, propertyName);
     }
     
     /**
@@ -68,7 +89,7 @@
     public void removeNotify() {
         removeActionListener(action);
         Model.getPump().removeModelEventListener(
-                this, target, propertyName);
+                this, modelElement, propertyName);
     }
     
     /*
@@ -84,7 +105,7 @@
      */
     private void build() {
         if (getterSetter != null) {
-            setSelected((Boolean) getterSetter.get(target, propertyName));
+            setSelected((Boolean) getterSetter.get(modelElement, 
propertyName));
         }
     }
     
@@ -97,17 +118,17 @@
         
         private final GetterSetter getterSetter;
         private final String propertyName;
-        private Object target;
+        private Object modelElement;
         
         /**
          * Constructor for ActionSetElementOwnershipSpecification.
          */
         protected SetAction(
                 final GetterSetter getterSetter, 
-                final Object target,
+                final Object modelElement,
                 final String propertyName) {
             super(Translator.localize("Set"), null);
-            this.target = target;
+            this.modelElement = modelElement;
             this.getterSetter = getterSetter;
             this.propertyName = propertyName;
             // Set the tooltip string:
@@ -121,7 +142,7 @@
         public void actionPerformed(ActionEvent e) {
             super.actionPerformed(e);
             CheckBox source = (CheckBox) e.getSource();
-            this.getterSetter.set(target, source.isSelected(), propertyName);
+            this.getterSetter.set(modelElement, source.isSelected(), 
propertyName);
         }
     }
 }

Modified: 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java?view=diff&pathrev=17688&r1=17687&r2=17688
==============================================================================
--- 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java
 (original)
+++ 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java
 2009-12-20 03:55:27-0800
@@ -278,37 +278,45 @@
         
         final String propertyName = prop.getName();
         
-        GetterSetter getterSetter = GetterSetter.getGetterSetter();
+        final GetterSetter getterSetter = GetterSetter.getGetterSetter();
+
+        String label;
+        if (propertyName.startsWith("is")) {
+            label = "label." + propertyName.substring(2).toLowerCase();
+        } else {
+            label = "label." + propertyName.toLowerCase();
+        }
+        label = Translator.localize(label);        
         
         CheckBox checkbox = null;
         if ("derived".equals(propertyName)) {
-            checkbox = new CheckBox(propertyName, target, getterSetter);
+            checkbox = new CheckBox(label, target, propertyName, getterSetter);
         } else if ("isAbstract".equals(propertyName)) {
-            checkbox = new CheckBox(propertyName, target, getterSetter);
+            checkbox = new CheckBox(label, target, propertyName, getterSetter);
         } else if ("isLeaf".equals(propertyName)) {
-            checkbox = new CheckBox(propertyName, target, getterSetter);
+            checkbox = new CheckBox(label, target, propertyName, getterSetter);
         } else if ("isRoot".equals(propertyName)) {
-            checkbox = new CheckBox(propertyName, target, getterSetter);
+            checkbox = new CheckBox(label, target, propertyName, getterSetter);
         } else if ("isActive".equals(propertyName)) {
-            checkbox = new CheckBox(propertyName, target, getterSetter);
+            checkbox = new CheckBox(label, target, propertyName, getterSetter);
         } else if ("ownerScope".equals(propertyName)) {   
-            checkbox = new CheckBox(propertyName, target, getterSetter);
+            checkbox = new CheckBox(label, target, propertyName, getterSetter);
         } else if ("targetScope".equals(propertyName)) {
             // TODO: An alternative property name will need to be inserted for
             // UML 2.x
-            checkbox = new CheckBox(propertyName, target, getterSetter);
+            checkbox = new CheckBox(label, target, propertyName, getterSetter);
         } else if ("isQuery".equals(propertyName)) {
-            checkbox = new CheckBox(propertyName, target, getterSetter);
+            checkbox = new CheckBox(label, target, propertyName, getterSetter);
         } else if ("isNavigable".equals(propertyName)) {
-            checkbox = new CheckBox(propertyName, target, getterSetter);
+            checkbox = new CheckBox(label, target, propertyName, getterSetter);
         } else if ("ordering".equals(propertyName)) {
-            checkbox = new CheckBox(propertyName, target, getterSetter);
+            checkbox = new CheckBox(label, target, propertyName, getterSetter);
         } else if ("isAsynchronous".equals(propertyName)) {
-            checkbox = new CheckBox(propertyName, target, getterSetter);
+            checkbox = new CheckBox(label, target, propertyName, getterSetter);
         } else if ("isSynch".equals(propertyName)) {
-            checkbox = new CheckBox(propertyName, target, getterSetter);
+            checkbox = new CheckBox(label, target, propertyName, getterSetter);
         } else if ("derived".equals(propertyName)) {
-            checkbox = new CheckBox(propertyName, target, getterSetter);
+            checkbox = new CheckBox(label, target, propertyName, getterSetter);
         }
         
         if (checkbox != null) {

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2431789

To unsubscribe from this discussion, e-mail: 
[[email protected]].

Reply via email to