Author: maurelio1234
Date: 2007-06-22 14:56:50-0700
New Revision: 12893
Modified:
branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/ui/FigStereotypesCompartment.java
Log:
Reordering stereotypes in order to solve the problem when some of them is hidden
Modified: branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/ui/FigStereotypesCompartment.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/ui/FigStereotypesCompartment.java?view=diff&rev=12893&p1=branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/ui/FigStereotypesCompartment.java&p2=branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/ui/FigStereotypesCompartment.java&r1=12892&r2=12893
==============================================================================
--- branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/ui/FigStereotypesCompartment.java (original)
+++ branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/ui/FigStereotypesCompartment.java 2007-06-22 14:56:50-0700
@@ -24,6 +24,7 @@
package org.argouml.uml.diagram.ui;
+import java.awt.Image;
import java.beans.PropertyChangeEvent;
import java.util.Collection;
import java.util.Iterator;
@@ -134,6 +135,7 @@
Model.getFacade().getName(stereotype));
stereotypeTextFig.setOwner(stereotype);
addFig(stereotypeTextFig);
+ reorderStereotypeFigs();
damage();
}
} else {
@@ -155,6 +157,40 @@
}
}
+ /**
+ * Keep the probaly invisible figs at the end of the list
+ */
+ private void reorderStereotypeFigs() {
+ List allFigs = getFigs();
+ List figsWithIcon = new Vector();
+ List figsWithOutIcon = new Vector();
+ List others = new Vector();
+
+ Iterator it = allFigs.iterator();
+
+ while(it.hasNext()) {
+ Fig f = (Fig) it.next();
+ if (f instanceof FigStereotype) {
+ FigStereotype s = (FigStereotype) f;
+ if (getIconForStereotype(s) != null) {
+ figsWithIcon.add(s);
+ } else {
+ figsWithOutIcon.add(s);
+ }
+ } else {
+ others.add(f);
+ }
+ }
+
+ Vector n = new Vector();
+
+ n.addAll(others);
+ n.addAll(figsWithOutIcon);
+ n.addAll(figsWithIcon);
+
+ setFigs(n);
+ }
+
private Fig findFig(Object stereotype) {
for (Iterator it = getFigs().iterator(); it.hasNext(); ) {
Fig f = (Fig) it.next();
@@ -218,7 +254,7 @@
stereotypeTextFig.setText(keyword);
acounter++;
}
-
+
Collection stereos = Model.getFacade().getStereotypes(modelElement);
if (stereos != null) {
Iterator iter = stereos.iterator();
@@ -254,6 +290,8 @@
removeFig((Fig) figs.get(i));
}
}
+
+ reorderStereotypeFigs();
// remove all stereotypes that have a graphical icon
updateHiddenStereotypes();
@@ -265,16 +303,20 @@
for (int i = 0; i < figs.size(); ++i) {
Fig f = (Fig) figs.get(i);
- if (f instanceof FigStereotype) {
- FigStereotype fs = (FigStereotype) f;
- fs.setVisible(ProjectManager.getManager().getCurrentProject()
- .getProfileConfiguration().getFigNodeStrategy()
- .getIconForStereotype(fs.getOwner()) == null
+ if (f instanceof FigStereotype) {
+ FigStereotype fs = (FigStereotype) f;
+ fs.setVisible(getIconForStereotype(fs) == null
|| !isHidingStereotypesWithIcon());
}
}
}
+ private Image getIconForStereotype(FigStereotype fs) {
+ return ProjectManager.getManager().getCurrentProject()
+ .getProfileConfiguration().getFigNodeStrategy()
+ .getIconForStereotype(fs.getOwner());
+ }
+
/*
* @see org.tigris.gef.presentation.Fig#setBoundsImpl(int, int, int,
* int)
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.