Author: mvw
Date: 2007-07-31 11:22:49-0700
New Revision: 13193
Modified:
trunk/src_new/org/argouml/i18n/menu.properties
trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigClassifierBox.java
trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigPackage.java
trunk/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java
trunk/src_new/org/argouml/uml/diagram/use_case/ui/FigUseCase.java
Log:
Fix for issues 3422 and 3479: Fig popup menu for Show/Hide Path in Name.
Also show the path by default for figNodeModelelements created on an "alien" diagram.
Modified: trunk/src_new/org/argouml/i18n/menu.properties
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/i18n/menu.properties?view=diff&rev=13193&p1=trunk/src_new/org/argouml/i18n/menu.properties&p2=trunk/src_new/org/argouml/i18n/menu.properties&r1=13192&r2=13193
==============================================================================
--- trunk/src_new/org/argouml/i18n/menu.properties (original)
+++ trunk/src_new/org/argouml/i18n/menu.properties 2007-07-31 11:22:49-0700
@@ -248,6 +248,7 @@
menu.popup.extends = {0} Extends {1}
menu.popup.generalizes = {0} Generalizes {1}
menu.popup.has-permission-on = {0} Has Permission On {1}
+menu.popup.hide.path = Hide Path in Name
menu.popup.includes = {0} Includes {1}
menu.popup.modifiers = Modifiers
menu.popup.modifiers.mnemonic = M
@@ -266,6 +267,7 @@
menu.popup.show.mnemonic = S
menu.popup.show.show-stereotype = Show Stereotype
menu.popup.show.hide-stereotype = Hide Stereotype
+menu.popup.show.path = Show Path in Name
menu.popup.show.show-visibility = Show Visibility
menu.popup.show.hide-visibility = Hide Visibility
menu.popup.trigger = New Trigger
Modified: trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigClassifierBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigClassifierBox.java?view=diff&rev=13193&p1=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigClassifierBox.java&p2=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigClassifierBox.java&r1=13192&r2=13193
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigClassifierBox.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigClassifierBox.java 2007-07-31 11:22:49-0700
@@ -286,16 +286,7 @@
ArgoJMenu addMenu = buildAddMenu();
popUpActions.insertElementAt(addMenu,
popUpActions.size() - getPopupAddOffset());
-
- // Show ...
- ArgoJMenu showMenu = new ArgoJMenu("menu.popup.show");
- Iterator i = ActionCompartmentDisplay.getActions().iterator();
- while (i.hasNext()) {
- showMenu.add((Action) i.next());
- }
- popUpActions.insertElementAt(showMenu,
- popUpActions.size() - getPopupAddOffset());
-
+
// Modifier ...
popUpActions.insertElementAt(buildModifierPopUp(),
popUpActions.size() - getPopupAddOffset());
@@ -307,6 +298,16 @@
return popUpActions;
}
+ protected ArgoJMenu buildShowPopUp() {
+ ArgoJMenu showMenu = super.buildShowPopUp();
+
+ Iterator i = ActionCompartmentDisplay.getActions().iterator();
+ while (i.hasNext()) {
+ showMenu.add((Action) i.next());
+ }
+ return showMenu;
+ }
+
protected ArgoJMenu buildAddMenu() {
ArgoJMenu addMenu = new ArgoJMenu("menu.popup.add");
Action addOperation = new ActionAddOperation();
Modified: trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigPackage.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigPackage.java?view=diff&rev=13193&p1=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigPackage.java&p2=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigPackage.java&r1=13192&r2=13193
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigPackage.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/static_structure/ui/FigPackage.java 2007-07-31 11:22:49-0700
@@ -503,8 +503,19 @@
public Vector getPopUpActions(MouseEvent me) {
Vector popUpActions = super.getPopUpActions(me);
- // Show ...
- ArgoJMenu showMenu = new ArgoJMenu("menu.popup.show");
+ // Modifier ...
+ popUpActions.insertElementAt(buildModifierPopUp(ABSTRACT | LEAF | ROOT),
+ popUpActions.size() - getPopupAddOffset());
+
+ // Visibility ...
+ popUpActions.insertElementAt(buildVisibilityPopUp(),
+ popUpActions.size() - getPopupAddOffset());
+
+ return popUpActions;
+ }
+
+ protected ArgoJMenu buildShowPopUp() {
+ ArgoJMenu showMenu = super.buildShowPopUp();
/* Only show the menuitems if they make sense: */
Editor ce = Globals.curEditor();
Vector figs = ce.getSelectionManager().getFigs();
@@ -547,18 +558,7 @@
showMenu.add(new ShowVisibilityAction());
}
- popUpActions.insertElementAt(showMenu,
- popUpActions.size() - getPopupAddOffset());
-
- // Modifier ...
- popUpActions.insertElementAt(buildModifierPopUp(ABSTRACT | LEAF | ROOT),
- popUpActions.size() - getPopupAddOffset());
-
- // Visibility ...
- popUpActions.insertElementAt(buildVisibilityPopUp(),
- popUpActions.size() - getPopupAddOffset());
-
- return popUpActions;
+ return showMenu;
}
/**
Modified: trunk/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java?view=diff&rev=13193&p1=trunk/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java&r1=13192&r2=13193
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java 2007-07-31 11:22:49-0700
@@ -29,6 +29,7 @@
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
@@ -98,6 +99,7 @@
import org.tigris.gef.presentation.FigNode;
import org.tigris.gef.presentation.FigRect;
import org.tigris.gef.presentation.FigText;
+import org.tigris.gef.undo.UndoableAction;
/**
* Abstract class to display diagram icons for UML ModelElements that
@@ -269,8 +271,10 @@
private Collection<Object[]> listeners = new ArrayList<Object[]>();
/**
- * The main constructor.
- *
+ * The main constructor. <p>
+ *
+ * The owner nor the Layer (which has a 1..1 relation to the Diagram)
+ * are set in this stage of the creation of the Fig.
*/
protected FigNodeModelElement() {
// this rectangle marks the whole modelelement figure; everything
@@ -307,7 +311,10 @@
}
/**
- * Construct a figure at a specific position for a given model element.
+ * Construct a figure at a specific position for a given model element. <p>
+ *
+ * The Layer (which has a 1..1 relation to the Diagram)
+ * is not yet set in this stage of the creation of the Fig.
*
* @param element ModelElement associated with figure
* @param x horizontal location
@@ -321,6 +328,19 @@
setLocation(x, y);
}
+ /**
+ * This is the final call at creation time of the Fig, i.e. here
+ * it is put on a Diagram.
+ *
+ * @param lay the Layer (which has a 1..1 relation to the Diagram)
+ * @see org.tigris.gef.presentation.Fig#setLayer(org.tigris.gef.base.Layer)
+ */
+ @Override
+ public void setLayer(Layer lay) {
+ super.setLayer(lay);
+ determineDefaultPathVisible();
+ }
+
/*
* @see java.lang.Object#finalize()
*/
@@ -456,6 +476,12 @@
public Vector getPopUpActions(MouseEvent me) {
Vector popUpActions = super.getPopUpActions(me);
+ // Show ...
+ ArgoJMenu show = buildShowPopUp();
+ if (show.getMenuComponentCount() > 0) {
+ popUpActions.addElement(show);
+ }
+
// popupAddOffset should be equal to the number of items added here:
popUpActions.addElement(new JSeparator());
popupAddOffset = 1;
@@ -507,6 +533,20 @@
return popUpActions;
}
+ protected ArgoJMenu buildShowPopUp() {
+ ArgoJMenu showMenu = new ArgoJMenu("menu.popup.show");
+
+ Object owner = getOwner();
+ if (Model.getFacade().isAModelElement(owner)) {
+ Object ns = Model.getFacade().getNamespace(owner);
+ if (ns != null) {
+ /* Only show the path item when there is an owning namespace. */
+ showMenu.add(new ActionSetPath(isPathVisible(), this));
+ }
+ }
+ return showMenu;
+ }
+
/**
* @return the pop-up menu item for Visibility
*/
@@ -1305,6 +1345,9 @@
return;
}
MutableGraphSupport.enableSaveAction();
+ // TODO: Use this event mechanism to update
+ // the checkmark on the Presentation Tab:
+ firePropChange("pathVisible", !visible, visible);
pathVisible = visible;
if (notationProviderName != null) {
npArguments.put("pathVisible", Boolean.valueOf(visible));
@@ -1314,6 +1357,41 @@
damage();
}
}
+
+ /**
+ * At creation time of the Fig, we determine
+ * if the path should be visible by default. <p>
+ *
+ * The path is a concatenation of the names of all packages by which
+ * this modelelement is contained,
+ * seperated by "::" (for UML at least). <p>
+ *
+ * If the default namespace of the diagram corresponds
+ * to the namespace of the modelelement,
+ * then we do NOT show the path. Otherwise, we do. <p>
+ *
+ * RRose uses the same heuristic algorithm,
+ * but shows "(from <path>)" below the name,
+ * while we follow the UML syntax.
+ */
+ protected void determineDefaultPathVisible() {
+ Object modelElement = getOwner();
+ LayerPerspective layer = (LayerPerspective) getLayer();
+ if ((layer != null)
+ && Model.getFacade().isAModelElement(modelElement)) {
+ ArgoDiagram diagram = (ArgoDiagram) layer.getDiagram();
+ Object elementNs = Model.getFacade().getNamespace(modelElement);
+ Object diagramNs = diagram.getNamespace();
+ if (elementNs != null) {
+ boolean visible = elementNs != diagramNs;
+ npArguments.put("pathVisible", Boolean.valueOf(visible));
+ renderingChanged();
+ damage();
+ }
+ // it is done
+ }
+ // either layer or owner was null
+ }
/*
* @see org.tigris.gef.presentation.Fig#classNameAndBounds()
@@ -1806,3 +1884,34 @@
}
}
+
+/**
+ * This action shows or hides the path in the name.
+ *
+ * @author Michiel
+ */
+class ActionSetPath extends UndoableAction {
+
+ private boolean isPathVisible;
+ private PathContainer myFig;
+
+ public ActionSetPath(boolean isVisible, PathContainer fig) {
+ super();
+ isPathVisible = isVisible;
+ String name = Translator.localize(isVisible ? "menu.popup.hide.path"
+ : "menu.popup.show.path");
+ putValue(Action.NAME, name);
+ this.myFig = fig;
+ }
+
+ /**
+ * @param e
+ * @see org.tigris.gef.undo.UndoableAction#actionPerformed(java.awt.event.ActionEvent)
+ */
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ super.actionPerformed(e);
+ myFig.setPathVisible(!isPathVisible);
+ }
+
+}
\ No newline at end of file
Modified: trunk/src_new/org/argouml/uml/diagram/use_case/ui/FigUseCase.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/use_case/ui/FigUseCase.java?view=diff&rev=13193&p1=trunk/src_new/org/argouml/uml/diagram/use_case/ui/FigUseCase.java&p2=trunk/src_new/org/argouml/uml/diagram/use_case/ui/FigUseCase.java&r1=13192&r2=13193
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/use_case/ui/FigUseCase.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/use_case/ui/FigUseCase.java 2007-07-31 11:22:49-0700
@@ -398,15 +398,6 @@
popUpActions.insertElementAt(addMenu,
popUpActions.size() - getPopupAddOffset());
- // Show menu to display/hide the extension point compartment.
- ArgoJMenu showMenu = new ArgoJMenu("menu.popup.show");
- Iterator i = ActionCompartmentDisplay.getActions().iterator();
- while (i.hasNext()) {
- showMenu.add((Action) i.next());
- }
- popUpActions.insertElementAt(showMenu,
- popUpActions.size() - getPopupAddOffset());
-
// Modifier menu. Placed one before last, so the "Properties" entry is
// always last.
popUpActions.insertElementAt(
@@ -417,6 +408,21 @@
}
/**
+ * Show menu to display/hide the extension point compartment.
+ * @return the menu
+ * @see org.argouml.uml.diagram.ui.FigNodeModelElement#buildShowPopUp()
+ */
+ @Override
+ protected ArgoJMenu buildShowPopUp() {
+ ArgoJMenu showMenu = super.buildShowPopUp();
+ Iterator i = ActionCompartmentDisplay.getActions().iterator();
+ while (i.hasNext()) {
+ showMenu.add((Action) i.next());
+ }
+ return showMenu;
+ }
+
+ /**
* USED BY PGML.tee.
* @return the class name and bounds together with compartment
* visibility.
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.