svn commit: r17461 - trunk/src/argouml-app/src/org/argouml/uml/diagram: static_structure/ui ui
Bob Tarling <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: bobtarling
Date: 2009-11-08 10:08:03-0800
New Revision: 17461
Modified:
trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClass.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClassifierBox.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClassifierBoxWithAttributes.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigInterface.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigSignal.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartment.java
Log:
Start to remove the lazy initialization of compartments. Comment what to do with some attribute specific methods in FigCompartmentBox.
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClass.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClass.java?view=diff&pathrev=17461&r1=17460&r2=17461
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClass.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClass.java 2009-11-08 10:08:03-0800
@@ -31,6 +31,7 @@
import org.argouml.model.Model;
import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.ui.FigAttributesCompartment;
import org.tigris.gef.base.Selection;
import org.tigris.gef.presentation.Fig;
import org.tigris.gef.presentation.FigGroup;
@@ -77,7 +78,10 @@
/* Stereotype covers NameFig: */
addFig(getStereotypeFig());
/* Compartments from top to bottom: */
- addFig(getAttributesCompartment());
+ addFig(new FigAttributesCompartment(
+ getOwner(),
+ DEFAULT_COMPARTMENT_BOUNDS,
+ getSettings()));
addFig(getOperationsFig());
addFig(getBorderFig());
@@ -140,10 +144,10 @@
do {
i--;
while (i < 1) {
- if (fgVec == getAttributesCompartment()) {
+ if (fgVec == getAttributesFig()) {
fgVec = getOperationsFig();
} else {
- fgVec = getAttributesCompartment();
+ fgVec = getAttributesFig();
}
figs = fgVec.getFigs();
i = figs.size() - 1;
@@ -174,10 +178,10 @@
do {
i++;
while (i >= v.size()) {
- if (fgVec == getAttributesCompartment()) {
+ if (fgVec == getAttributesFig()) {
fgVec = getOperationsFig();
} else {
- fgVec = getAttributesCompartment();
+ fgVec = getAttributesFig();
}
v = new ArrayList(fgVec.getFigs());
i = 1;
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClassifierBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClassifierBox.java?view=diff&pathrev=17461&r1=17460&r2=17461
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClassifierBox.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClassifierBox.java 2009-11-08 10:08:03-0800
@@ -44,6 +44,7 @@
import org.argouml.uml.diagram.ui.ActionCompartmentDisplay;
import org.argouml.uml.diagram.ui.ActionEdgesDisplay;
import org.argouml.uml.diagram.ui.FigAttributesCompartment;
+import org.argouml.uml.diagram.ui.FigCompartment;
import org.argouml.uml.diagram.ui.FigCompartmentBox;
import org.argouml.uml.diagram.ui.FigOperationsCompartment;
import org.argouml.uml.ui.foundation.core.ActionAddOperation;
@@ -66,11 +67,6 @@
private FigOperationsCompartment operationsFigCompartment;
/**
- * The Fig for the attributes compartment (if any).
- */
- private FigAttributesCompartment attributesFigCompartment;
-
- /**
* Initialization shared by all constructors.
*/
private void constructFigs() {
@@ -224,64 +220,49 @@
/**
* @return The graphics for the UML attributes (if any).
- * @deprecated in 0.29.1 use getAttributesCompartment
+ * @deprecated in 0.29.1 use
+ * getCompartment(Model.getUmlFactory(Model.getMetaTypes(),getAttribute()))
+ * to determine if an attribute compartment exists and return it.
+ * The attributesCompartment should be created by the concrete class
*/
protected FigAttributesCompartment getAttributesFig() {
- return getAttributesCompartment();
+ FigCompartment fc = getCompartment(Model.getMetaTypes().getAttribute());
+ return (FigAttributesCompartment) fc;
}
+ /**
+ * @deprecated by Bob Tarling in 0.29.2 use
+ * getCompartment(Model.getMetaTypes().getAttribute()).getBounds()
+ * @return the bounds
+ */
+ @Deprecated
public Rectangle getAttributesBounds() {
- return getAttributesCompartment().getBounds();
+ return getAttributesFig().getBounds();
}
- public boolean isAttributesVisible() {
- return attributesFigCompartment != null
- && attributesFigCompartment.isVisible();
- }
-
/**
- * Updates the attributes in the fig. Called from modelchanged if there is
- * a modelEvent effecting the attributes and from renderingChanged in all
- * cases.
- * TODO: Looks like this should be private - Bob.
+ * @deprecated by Bob Tarling in 0.29.2 use
+ * getCompartment(Model.getMetaTypes().getAttribute()).isVisible()
+ * @return the visibility
*/
- protected void updateAttributes() {
- if (!isAttributesVisible()) {
- return;
- }
- attributesFigCompartment.populate();
-
- // TODO: make setBounds, calcBounds and updateBounds consistent
- setBounds(getBounds());
+ @Deprecated
+ public boolean isAttributesVisible() {
+ FigCompartment fc = getCompartment(Model.getMetaTypes().getAttribute());
+ return fc != null && fc.isVisible();
}
/**
+ * TODO: Should not be on this class as we don't know if we'll have
+ * attributes
* @param isVisible true if the attribute compartment is visible
- *
- * @see org.argouml.uml.diagram.AttributesCompartmentContainer#setAttributesVisible(boolean)
+ * @deprecated by Bob Tarling in 0.29.2 use setCompartmentVisible
*/
public void setAttributesVisible(boolean isVisible) {
- setCompartmentVisible(attributesFigCompartment, isVisible);
- }
-
- /**
- * @return the Fig for the Attribute compartment
- */
- public FigAttributesCompartment getAttributesCompartment() {
- // Set bounds will be called from our superclass constructor before
- // our constructor has run, so make sure this gets set up if needed.
- if (attributesFigCompartment == null) {
- attributesFigCompartment = new FigAttributesCompartment(
- getOwner(),
- DEFAULT_COMPARTMENT_BOUNDS,
- getSettings());
- }
- return attributesFigCompartment;
+ final FigCompartment afc =
+ getCompartment(Model.getMetaTypes().getAttribute());
+ setCompartmentVisible(afc, isVisible);
}
-
-
-
/*
* @see org.tigris.gef.presentation.Fig#translate(int, int)
*/
@@ -350,12 +331,20 @@
/**
* USED BY PGML.tee.
+ * TODO We should loop round the compartments to build this string. That
+ * way we have no attribute/operation knowledge at this level.
* @return the class name and bounds together with compartment
* visibility.
*/
public String classNameAndBounds() {
- return super.classNameAndBounds()
+ String classNameAndBounds = super.classNameAndBounds()
+ "operationsVisible=" + isOperationsVisible() + ";";
+ FigCompartment fc = getCompartment(Model.getMetaTypes().getAttribute());
+ if (fc != null) {
+ classNameAndBounds +=
+ "attributesVisible=" + fc.isVisible() + ";";
+ }
+ return classNameAndBounds;
}
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClassifierBoxWithAttributes.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClassifierBoxWithAttributes.java?view=diff&pathrev=17461&r1=17460&r2=17461
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClassifierBoxWithAttributes.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClassifierBoxWithAttributes.java 2009-11-08 10:08:03-0800
@@ -40,6 +40,7 @@
import org.argouml.uml.diagram.AttributesCompartmentContainer;
import org.argouml.uml.diagram.DiagramSettings;
import org.argouml.uml.diagram.ui.FigAttributesCompartment;
+import org.argouml.uml.diagram.ui.FigCompartment;
import org.argouml.uml.ui.foundation.core.ActionAddAttribute;
/**
@@ -60,7 +61,6 @@
public FigClassifierBoxWithAttributes(Object owner, Rectangle bounds,
DiagramSettings settings) {
super(owner, bounds, settings);
- getAttributesCompartment(); // this creates the compartment fig
}
/*
@@ -177,5 +177,15 @@
}
}
}
+
+ protected void updateAttributes() {
+ FigCompartment fc = getCompartment(Model.getMetaTypes().getAttribute());
+ if (!fc.isVisible()) {
+ return;
+ }
+ fc.populate();
+ // TODO: make setBounds, calcBounds and updateBounds consistent
+ setBounds(getBounds());
+ }
}
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigInterface.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigInterface.java?view=diff&pathrev=17461&r1=17460&r2=17461
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigInterface.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigInterface.java 2009-11-08 10:08:03-0800
@@ -33,6 +33,7 @@
import org.argouml.ui.targetmanager.TargetManager;
import org.argouml.uml.diagram.ArgoDiagram;
import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.ui.FigAttributesCompartment;
import org.tigris.gef.base.Selection;
import org.tigris.gef.presentation.Fig;
@@ -67,7 +68,16 @@
addFig(getNameFig());
// stereotype fig covers the name fig:
addFig(getStereotypeFig());
- /* Only one compartment: */
+ // Only add an attribute compartment if its valid for this
+ // container
+ if (Model.getUmlFactory().isContainmentValid(
+ Model.getMetaTypes().getAttribute(),
+ getOwner())) {
+ addFig(new FigAttributesCompartment(
+ getOwner(),
+ DEFAULT_COMPARTMENT_BOUNDS,
+ getSettings()));
+ }
addFig(getOperationsFig());
addFig(getBorderFig());
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigSignal.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigSignal.java?view=diff&pathrev=17461&r1=17460&r2=17461
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigSignal.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigSignal.java 2009-11-08 10:08:03-0800
@@ -29,6 +29,7 @@
import java.util.Vector;
import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.ui.FigAttributesCompartment;
import org.tigris.gef.base.Selection;
/**
@@ -72,7 +73,10 @@
/* Stereotype covers NameFig: */
addFig(getStereotypeFig());
/* Compartments from top to bottom: */
- addFig(getAttributesCompartment());
+ addFig(new FigAttributesCompartment(
+ getOwner(),
+ DEFAULT_COMPARTMENT_BOUNDS,
+ getSettings()));
addFig(getOperationsFig());
addFig(getBorderFig());
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartment.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartment.java?view=diff&pathrev=17461&r1=17460&r2=17461
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartment.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartment.java 2009-11-08 10:08:03-0800
@@ -194,4 +194,9 @@
* @return a model element type
*/
public abstract Object getCompartmentType();
+
+ /**
+ * The concrete Fig implements this to build all the child Figs
+ */
+ public abstract void populate();
}
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2415589
To unsubscribe from this discussion, e-mail: [[email protected]].