Author: bszanto
Date: 2008-07-13 04:17:11-0700
New Revision: 15251
Modified:
branches/gsoc2008/feature3_5140_bszanto/ (props changed)
branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigAttribute.java
branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/ui/FigCompartmentBox.java
Log:
Clicking (roughly) the +/-/~/# signs or the public/package/private words now cycles through the visibilities of the attribute.
Modified: branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigAttribute.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigAttribute.java?view=diff&rev=15251&p1=branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigAttribute.java&p2=branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigAttribute.java&r1=15250&r2=15251
==============================================================================
--- branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigAttribute.java (original)
+++ branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigAttribute.java 2008-07-13 04:17:11-0700
@@ -24,23 +24,82 @@
package org.argouml.uml.diagram.static_structure.ui;
+import java.awt.Rectangle;
+
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
import org.argouml.notation.NotationProvider;
import org.tigris.gef.presentation.Fig;
/**
- * Fig with specific knowledge of Attribute display. <p>
+ * Fig with specific knowledge of Attribute display.
+ * <p>
+ *
+ * This class does not contain any Attribute specific functionality. But since
+ * the Feature is an abstract class in the UML metamodel, it seems more logical
+ * to follow this structure here, and keep FigFeature abstract, too.
*
- * This class does not contain any Attribute specific functionality.
- * But since the Feature is an abstract class in the UML metamodel,
- * it seems more logical to follow this structure here,
- * and keep FigFeature abstract, too.
- *
* @author Michiel
*/
public class FigAttribute extends FigFeature {
- public FigAttribute(int x, int y, int w, int h, Fig aFig,
+ /**
+ * Constructor.
+ * @param x x
+ * @param y x
+ * @param w width
+ * @param h height
+ * @param aFig the fig
+ * @param np the notation provider for the text
+ */
+ public FigAttribute(int x, int y, int w, int h, Fig aFig,
NotationProvider np) {
super(x, y, w, h, aFig, np);
}
+
+ /**
+ * Cyclies the visibility of an attribute when clicking in the beggining
+ * part of the FigAttribute.
+ * @param r Hit rectangle.
+ * @author bszanto
+ */
+ public void changeVisibility(Rectangle r) {
+ if (super.hit(r)) {
+ String notation = ProjectManager.getManager().getCurrentProject()
+ .getProjectSettings().getNotationLanguage();
+
+ // The hit zone is different for the different notations.
+ // Java uses words (public, protected, private) while UML 1.4 uses
+ // signs (+, -, ~, #).
+ int offset = 0;
+ if (notation.equals("Java")) {
+ offset = 50;
+ } else if (notation.equals("UML 1.4")) {
+ offset = 10;
+ }
+
+ if (r.x < (_x + offset)) {
+ Object atttribute = getOwner();
+ Object visibity = Model.getFacade().getVisibility(atttribute);
+
+ // visibility is chandes according to prop panel order which is:
+ // public, package, protected, private
+ if (Model.getVisibilityKind().getPrivate().equals(visibity)) {
+ Model.getCoreHelper().setVisibility(atttribute,
+ Model.getVisibilityKind().getPublic());
+ } else if (Model.getVisibilityKind().getPublic().equals(
+ visibity)) {
+ Model.getCoreHelper().setVisibility(atttribute,
+ Model.getVisibilityKind().getPackage());
+ } else if (Model.getVisibilityKind().getPackage().equals(
+ visibity)) {
+ Model.getCoreHelper().setVisibility(atttribute,
+ Model.getVisibilityKind().getProtected());
+ } else {
+ Model.getCoreHelper().setVisibility(atttribute,
+ Model.getVisibilityKind().getPrivate());
+ }
+ }
+ }
+ }
}
Modified: branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/ui/FigCompartmentBox.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/ui/FigCompartmentBox.java?view=diff&rev=15251&p1=branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/ui/FigCompartmentBox.java&p2=branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/ui/FigCompartmentBox.java&r1=15250&r2=15251
==============================================================================
--- branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/ui/FigCompartmentBox.java (original)
+++ branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/ui/FigCompartmentBox.java 2008-07-13 04:17:11-0700
@@ -31,6 +31,7 @@
import java.util.List;
import org.argouml.ui.targetmanager.TargetManager;
+import org.argouml.uml.diagram.static_structure.ui.FigAttribute;
import org.argouml.uml.diagram.static_structure.ui.SelectionClass;
import org.tigris.gef.base.Editor;
import org.tigris.gef.base.Globals;
@@ -107,14 +108,20 @@
if (sel instanceof SelectionClass) {
((SelectionClass) sel).hideButtons();
}
- unhighlight();
-
+
Rectangle r =
new Rectangle(
mouseEvent.getX() - 1,
mouseEvent.getY() - 1,
2,
2);
+
+ if (highlightedFigText instanceof FigAttribute) {
+ // try to change visibility
+ ((FigAttribute) highlightedFigText).changeVisibility(r);
+ }
+
+ unhighlight();
Fig f = hitFig(r);
if (f instanceof FigEditableCompartment) {
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.