Author: linus
Date: 2010-01-27 11:50:58-0800
New Revision: 17924

Modified:
   trunk/src/argouml-app/src/org/argouml/ui/StylePanel.java
   
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/StylePanelFigAssociationClass.java

Log:
Changing the StylePanelFigAssociationClass so that it isn't a subclass of 
StylePanelFigClass. The assumptions on the type for getPanel no longer holds.

Modified: trunk/src/argouml-app/src/org/argouml/ui/StylePanel.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/StylePanel.java?view=diff&pathrev=17924&r1=17923&r2=17924
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/StylePanel.java    (original)
+++ trunk/src/argouml-app/src/org/argouml/ui/StylePanel.java    2010-01-27 
11:50:58-0800
@@ -217,7 +217,7 @@
     }
 
     /**
-     * @return Returns the _target.
+     * @return Returns the target of the Style Panel.
      */
     protected Fig getPanelTarget() {
         return panelTarget;

Modified: 
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/StylePanelFigAssociationClass.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/StylePanelFigAssociationClass.java?view=diff&pathrev=17924&r1=17923&r2=17924
==============================================================================
--- 
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/StylePanelFigAssociationClass.java
     (original)
+++ 
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/StylePanelFigAssociationClass.java
     2010-01-27 11:50:58-0800
@@ -40,25 +40,57 @@
 
 import java.awt.Rectangle;
 import java.awt.event.FocusListener;
+import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import java.awt.event.KeyListener;
+import java.beans.PropertyChangeEvent;
 
-import org.argouml.uml.diagram.static_structure.ui.StylePanelFigClass;
+import javax.swing.JCheckBox;
+
+import org.argouml.i18n.Translator;
+import org.argouml.model.Model;
+import org.argouml.ui.StylePanelFigNodeModelElement;
 import org.tigris.gef.presentation.Fig;
 
 /**
  * The style Panel for FigEdgeModelElement.
  *
  */
-public class StylePanelFigAssociationClass extends StylePanelFigClass 
implements
-        ItemListener, FocusListener, KeyListener {
+public class StylePanelFigAssociationClass
+    extends StylePanelFigNodeModelElement
+    implements ItemListener, FocusListener, KeyListener {
+
+    private JCheckBox attrCheckBox =
+        new JCheckBox(Translator.localize("checkbox.attributes"));
+
+    private JCheckBox operCheckBox =
+        new JCheckBox(Translator.localize("checkbox.operations"));
+
+    /**
+     * Flag to indicate that a refresh is going on.
+     */
+    private boolean refreshTransaction;
 
+    /**
+     * Constructor.
+     */
     public StylePanelFigAssociationClass() {
+        super();
+
+        addToDisplayPane(attrCheckBox);
+        addToDisplayPane(operCheckBox);
+
+        attrCheckBox.setSelected(false);
+        operCheckBox.setSelected(false);
+        attrCheckBox.addItemListener(this);
+        operCheckBox.addItemListener(this);
     }
 
     /**
      * Bounding box is editable (although this is style panel for an
      * FigEdgeModelElement).
+     * 
+     * @param value Ignored argument.
      */
     @Override
     protected void hasEditableBoundingBox(boolean value) {
@@ -100,17 +132,45 @@
     }
 
     /*
+     * Only refresh the tab if the bounds propertyChange event arrives.
+     *
+     * @see org.argouml.ui.StylePanel#refresh(java.beans.PropertyChangeEvent)
+     */
+    public void refresh(PropertyChangeEvent e) {
+        String propertyName = e.getPropertyName();
+        if (propertyName.equals("bounds")) {
+            refresh();
+        }
+    }
+    /*
      * @see org.argouml.ui.StylePanelFig#refresh()
      */
     @Override
     public void refresh() {
-        super.refresh();
-
-        // The boundary box as held in the target fig, and as listed in
-        // the
-        // boundary box style field (null if we don't have anything
-        // valid)
-        Fig target = getPanelTarget();
+        // StylePanelFigClass relies on getPanelTarget() to return a 
+        // FigCompartmentBox
+        refreshTransaction = true;
+        FigAssociationClass panelTarget =
+            (FigAssociationClass) getPanelTarget();
+        try {
+            super.refresh();
+            final FigCompartmentBox fcb = panelTarget.getAssociationClass();
+            if (fcb != null) {
+                FigCompartment compartment =
+                    fcb.getCompartment(Model.getMetaTypes().getAttribute());
+                attrCheckBox.setSelected(compartment.isVisible());
+                compartment =
+                    fcb.getCompartment(Model.getMetaTypes().getOperation());
+                operCheckBox.setSelected(compartment.isVisible());
+            }
+        } finally {
+            refreshTransaction = false;
+        }
+
+        // The boundary box as held in the target fig, and as listed
+        // in the boundary box style field (null if we don't have 
+        // anything valid)
+        Fig target = panelTarget;
 
         // Get class box, because we will set it's bounding box in text field
         if (((FigAssociationClass) target).getAssociationClass() != null) {
@@ -135,4 +195,28 @@
         }
     }
 
+    ////////////////////////////////////////////////////////////////
+    // event handling
+
+    /*
+     * @see 
java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
+     */
+    public void itemStateChanged(ItemEvent e) {
+        if (!refreshTransaction) {
+            Object src = e.getSource();
+
+            if (src == attrCheckBox) {
+                FigCompartmentBox fcb = (FigCompartmentBox) getPanelTarget();
+                fcb.showCompartment(Model.getMetaTypes().getAttribute(), 
+                        attrCheckBox.isSelected());
+            } else if (src == operCheckBox) {
+                FigCompartmentBox fcb = (FigCompartmentBox) getPanelTarget();
+                fcb.showCompartment(Model.getMetaTypes().getOperation(),
+                        operCheckBox.isSelected());
+            } else {
+                super.itemStateChanged(e);
+            }
+        }
+    }
+
 } /* end class StylePanelFigAssociationClass */

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

To unsubscribe from this discussion, e-mail: 
[commits-unsubscr...@argouml.tigris.org].

Reply via email to