Author: tfmorris
Date: 2007-07-10 13:18:28-0700
New Revision: 13046
Added:
trunk/src_new/org/argouml/uml/diagram/ui/ArgoFig.java (contents, props changed)
trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigGroup.java (contents, props changed)
Removed:
trunk/src_new/org/argouml/uml/diagram/ui/FigGraphEdge.java
Modified:
trunk/src_new/org/argouml/uml/diagram/ui/FigCompartment.java
trunk/src_new/org/argouml/uml/diagram/ui/FigEdgeModelElement.java
trunk/src_new/org/argouml/uml/diagram/ui/FigMultiLineText.java
trunk/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java
trunk/src_new/org/argouml/uml/diagram/ui/FigSingleLineText.java
trunk/src_new/org/argouml/uml/diagram/ui/FigTextGroup.java
Log:
Introduce ArgoFig interface which all our Figs must implement.
Reorganize Fig hierarchy to better isolate from GEF and improve reuse.
Centralize knowledge about Project
Added: trunk/src_new/org/argouml/uml/diagram/ui/ArgoFig.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/ArgoFig.java?view=auto&rev=13046
==============================================================================
--- (empty file)
+++ trunk/src_new/org/argouml/uml/diagram/ui/ArgoFig.java 2007-07-10 13:18:28-0700
@@ -0,0 +1,54 @@
+// $Id$
+// Copyright (c) 2007 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.uml.diagram.ui;
+
+import org.argouml.kernel.Project;
+
+/**
+ * An interface that all ArgoUML Figs are required to interface. It provides a
+ * single place to specify behaviors that we want all Figs to have since with
+ * don't have access to the GEF class hiearchy (and it's made up of concrete
+ * classes instead of interfaces.
+ *
+ * @author Tom Morris <[email protected]>
+ * @since 0.25.4
+ */
+public interface ArgoFig {
+
+ /**
+ * Set the owning project for this Fig.
+ *
+ * @param p the project
+ */
+ public void setProject(Project p);
+
+ /**
+ * Get the owning project for this fig.
+ *
+ * @return the project
+ */
+ public Project getProject();
+
+}
Added: trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigGroup.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigGroup.java?view=auto&rev=13046
==============================================================================
--- (empty file)
+++ trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigGroup.java 2007-07-10 13:18:28-0700
@@ -0,0 +1,84 @@
+// $Id$
+// Copyright (c) 2007 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.uml.diagram.ui;
+
+import java.util.List;
+
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.uml.diagram.UMLMutableGraphSupport;
+import org.tigris.gef.base.Editor;
+import org.tigris.gef.base.Globals;
+import org.tigris.gef.base.Layer;
+import org.tigris.gef.base.LayerPerspective;
+import org.tigris.gef.presentation.FigGroup;
+
+/**
+ * A fig which contains other figs. ArgoUMLs version of GEF's FigGroup.
+ *
+ * @author Tom Morris <[email protected]>
+ */
+public abstract class ArgoFigGroup extends FigGroup implements ArgoFig {
+
+ public ArgoFigGroup() {
+ super();
+ }
+
+ public ArgoFigGroup(List arg0) {
+ super(arg0);
+ }
+
+ /**
+ * This optional method is not implemented. It will throw an
+ * {@link UnsupportedOperationException} if used. Figs are
+ * added to a GraphModel which is, in turn, owned by a project.
+ */
+ public void setProject(Project project) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Project getProject() {
+ LayerPerspective layer = (LayerPerspective) getLayer();
+ if (layer == null) {
+ /* TODO: Without this, we fail to draw e.g. a Class.
+ * But is this a good solution?
+ * Why is the Layer not set in the constructor? */
+ Editor editor = Globals.curEditor();
+ if (editor == null) {
+ // TODO: The above doesn't work reliably in a constructor. We
+ // need a better way of getting default fig settings for the owning
+ // project rather than using the project manager singleton. - tfm
+ return ProjectManager.getManager().getCurrentProject();
+ }
+ Layer lay = editor.getLayerManager().getActiveLayer();
+ if (lay instanceof LayerPerspective) {
+ layer = (LayerPerspective) lay;
+ }
+ }
+ UMLMutableGraphSupport gm =
+ (UMLMutableGraphSupport) layer.getGraphModel();
+ return gm.getProject();
+ }
+}
Modified: trunk/src_new/org/argouml/uml/diagram/ui/FigCompartment.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/FigCompartment.java?view=diff&rev=13046&p1=trunk/src_new/org/argouml/uml/diagram/ui/FigCompartment.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/FigCompartment.java&r1=13045&r2=13046
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/FigCompartment.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/FigCompartment.java 2007-07-10 13:18:28-0700
@@ -35,7 +35,7 @@
/**
* @author Bob Tarling
*/
-public abstract class FigCompartment extends FigGroup {
+public abstract class FigCompartment extends ArgoFigGroup {
private Fig bigPort;
Modified: trunk/src_new/org/argouml/uml/diagram/ui/FigEdgeModelElement.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/FigEdgeModelElement.java?view=diff&rev=13046&p1=trunk/src_new/org/argouml/uml/diagram/ui/FigEdgeModelElement.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/FigEdgeModelElement.java&r1=13045&r2=13046
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/FigEdgeModelElement.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/FigEdgeModelElement.java 2007-07-10 13:18:28-0700
@@ -77,11 +77,13 @@
import org.argouml.notation.NotationProviderFactory2;
import org.argouml.ui.ArgoJMenu;
import org.argouml.ui.Clarifier;
-import org.argouml.ui.ProjectBrowser;
+import org.argouml.ui.ProjectActions;
import org.argouml.ui.targetmanager.TargetManager;
import org.argouml.uml.diagram.ArgoDiagram;
+import org.argouml.uml.diagram.IItemUID;
import org.argouml.uml.diagram.UMLMutableGraphSupport;
import org.argouml.uml.ui.ActionDeleteModelElements;
+import org.tigris.gef.base.Editor;
import org.tigris.gef.base.Globals;
import org.tigris.gef.base.Layer;
import org.tigris.gef.base.LayerPerspective;
@@ -108,7 +110,9 @@
KeyListener,
PropertyChangeListener,
ArgoNotationEventListener,
- Highlightable {
+ Highlightable,
+ IItemUID,
+ ArgoFig {
private static final Logger LOG =
Logger.getLogger(FigEdgeModelElement.class);
@@ -250,6 +254,7 @@
/*
* @see org.tigris.gef.presentation.Fig#getTipString(java.awt.event.MouseEvent)
*/
+ @Override
public String getTipString(MouseEvent me) {
ToDoItem item = hitClarifier(me.getX(), me.getY());
String tip = "";
@@ -286,7 +291,7 @@
popupAddOffset = 1;
if (removeFromDiagram) {
popUpActions.addElement(
- ProjectBrowser.getInstance().getRemoveFromDiagramAction());
+ ProjectActions.getInstance().getRemoveFromDiagramAction());
popupAddOffset++;
}
popUpActions.addElement(new ActionDeleteModelElements());
@@ -960,7 +965,7 @@
public void deleteFromModel() {
Object own = getOwner();
if (own != null) {
- ProjectManager.getManager().getCurrentProject().moveToTrash(own);
+ getProject().moveToTrash(own);
}
/* TODO: MVW: Why is this not done in GEF? */
@@ -1072,10 +1077,7 @@
// GEF does not take into account the multiple diagrams we have
// therefore we loop through our diagrams and delete each and every
// occurence on our own
- it = ProjectManager.getManager().getCurrentProject().getDiagrams()
- .iterator();
- while (it.hasNext()) {
- ArgoDiagram diagram = (ArgoDiagram) it.next();
+ for (ArgoDiagram diagram : getProject().getDiagramList()) {
diagram.damage();
}
@@ -1368,15 +1370,37 @@
listeners.clear();
}
+
/**
- * Get the Project that the Fig belongs to
- * @return the project
+ * This optional method is not implemented. It will throw an
+ * {@link UnsupportedOperationException} if used. Figs are
+ * added to a GraphModel which is, in turn, owned by a project.
*/
- protected Project getProject() {
- LayerPerspective layer = (LayerPerspective) getLayer();
- UMLMutableGraphSupport gm =
- (UMLMutableGraphSupport) layer.getGraphModel();
- return gm.getProject();
+ public void setProject(Project project) {
+ throw new UnsupportedOperationException();
}
-
-} /* end class FigEdgeModelElement */
+
+ public Project getProject() {
+ LayerPerspective layer = (LayerPerspective) getLayer();
+ if (layer == null) {
+ /* TODO: Without this, we fail to draw e.g. a Class.
+ * But is this a good solution?
+ * Why is the Layer not set in the constructor? */
+ Editor editor = Globals.curEditor();
+ if (editor == null) {
+ // TODO: The above doesn't work reliably in a constructor. We
+ // need a better way of getting default fig settings for the owning
+ // project rather than using the project manager singleton. - tfm
+ return ProjectManager.getManager().getCurrentProject();
+ }
+ Layer lay = editor.getLayerManager().getActiveLayer();
+ if (lay instanceof LayerPerspective) {
+ layer = (LayerPerspective) lay;
+ }
+ }
+ UMLMutableGraphSupport gm =
+ (UMLMutableGraphSupport) layer.getGraphModel();
+ return gm.getProject();
+ }
+
+}
Removed: trunk/src_new/org/argouml/uml/diagram/ui/FigGraphEdge.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/FigGraphEdge.java?view=auto&rev=13045
Modified: trunk/src_new/org/argouml/uml/diagram/ui/FigMultiLineText.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/FigMultiLineText.java?view=diff&rev=13046&p1=trunk/src_new/org/argouml/uml/diagram/ui/FigMultiLineText.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/FigMultiLineText.java&r1=13045&r2=13046
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/FigMultiLineText.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/FigMultiLineText.java 2007-07-10 13:18:28-0700
@@ -26,6 +26,7 @@
import java.awt.Color;
+import org.argouml.gefext.ArgoFigText;
import org.tigris.gef.presentation.FigText;
/**
@@ -41,7 +42,7 @@
*
* @author Bob Tarling
*/
-public class FigMultiLineText extends FigText {
+public class FigMultiLineText extends ArgoFigText {
/*
* @see org.tigris.gef.presentation.FigText#FigText(
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=13046&p1=trunk/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java&r1=13045&r2=13046
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java 2007-07-10 13:18:28-0700
@@ -78,9 +78,10 @@
import org.argouml.notation.NotationProviderFactory2;
import org.argouml.ui.ArgoJMenu;
import org.argouml.ui.Clarifier;
-import org.argouml.ui.ProjectBrowser;
+import org.argouml.ui.ProjectActions;
import org.argouml.ui.targetmanager.TargetManager;
import org.argouml.uml.diagram.ArgoDiagram;
+import org.argouml.uml.diagram.IItemUID;
import org.argouml.uml.diagram.UMLMutableGraphSupport;
import org.argouml.uml.ui.ActionDeleteModelElements;
import org.tigris.gef.base.Diagram;
@@ -113,7 +114,10 @@
PropertyChangeListener,
PathContainer,
ArgoNotationEventListener,
- Highlightable {
+ Highlightable,
+ IItemUID,
+ Clarifiable,
+ ArgoFig {
/**
* Logger.
@@ -132,7 +136,7 @@
private static final Font BOLD_ITALIC_LABEL_FONT;
private NotationProvider notationProviderName;
- private HashMap npArguments = new HashMap();
+ private HashMap<String, Object> npArguments = new HashMap<String, Object>();
/**
* True if an instance is allowed to be
@@ -259,7 +263,9 @@
*/
private boolean editable = true;
- private Collection listeners = new ArrayList();
+ // TODO: A more strongly typed data structure could be used here.
+ private Collection<Object[]> listeners = new ArrayList<Object[]>();
+
/**
* The main constructor.
*
@@ -282,8 +288,9 @@
readyToEdit = false;
ArgoEventPump.addListener(ArgoEventTypes.ANY_NOTATION_EVENT, this);
- Project p = ProjectManager.getManager().getCurrentProject();
- ProjectSettings ps = p.getProjectSettings();
+
+ Project project = getProject();
+ ProjectSettings ps = project.getProjectSettings();
showBoldName = ps.getShowBoldNamesValue();
if ((nameFig.getFont().getStyle() & Font.ITALIC) != 0) {
@@ -452,7 +459,7 @@
popupAddOffset = 1;
if (removeFromDiagram) {
popUpActions.addElement(
- ProjectBrowser.getInstance().getRemoveFromDiagramAction());
+ ProjectActions.getInstance().getRemoveFromDiagramAction());
popupAddOffset++;
}
popUpActions.addElement(new ActionDeleteModelElements());
@@ -922,13 +929,13 @@
}
/**
- * Utility function to localize the given string with help text,
- * and show it in the status bar of the ArgoUML window.
- * This function is used in favour of the inline call
- * to enable later improvements; e.g. it would be possible to
- * show a help-balloon. TODO: Work this out.
- * One matter to possibly improve: show multiple lines.
- *
+ * Utility function to localize the given string with help text, and show it
+ * in the status bar of the ArgoUML window. This function is used in favour
+ * of the inline call to enable later improvements; e.g. it would be
+ * possible to show a help-balloon.
+ * <p>
+ * TODO: Work this out. One matter to possibly improve: show multiple lines.
+ *
* @param s the given string to be localized and shown
*/
protected void showHelp(String s) {
@@ -1157,10 +1164,11 @@
/*
* @see org.tigris.gef.presentation.Fig#deleteFromModel()
*/
+ @Override
public void deleteFromModel() {
Object own = getOwner();
if (own != null) {
- ProjectManager.getManager().getCurrentProject().moveToTrash(own);
+ getProject().moveToTrash(own);
}
Iterator it = getFigs().iterator();
while (it.hasNext()) {
@@ -1177,6 +1185,7 @@
* by use of the empty constructor.
* The assigned model element (owner) must not change during the lifetime
* of the Fig.
+ * <p>
* TODO: It is planned to refactor so that there is only one Fig
* constructor. When this is achieved this method can refactored out.
*
@@ -1261,7 +1270,7 @@
if (notationProviderName != null) {
nameFig.setText(notationProviderName.toString(
getOwner(), npArguments));
- Project p = ProjectManager.getManager().getCurrentProject();
+ Project p = getProject();
ProjectSettings ps = p.getProjectSettings();
showBoldName = ps.getShowBoldNamesValue();
if ((nameFig.getFont().getStyle() & Font.ITALIC) != 0) {
@@ -1499,6 +1508,7 @@
/**
* Get the Fig containing the stereotype.
+ * <p>
* TODO: Should return FigStereotypesCompartment or at the very least
* a FigGroup
*
@@ -1748,16 +1758,33 @@
npArguments.put(key, value);
}
}
+
+ /**
+ * This optional method is not implemented. It will throw an
+ * {@link UnsupportedOperationException} if used. Figs are
+ * added to a GraphModel which is, in turn, owned by a project.
+ */
+ public void setProject(Project project) {
+ throw new UnsupportedOperationException();
+ }
- protected Project getProject() {
+ public Project getProject() {
LayerPerspective layer = (LayerPerspective) getLayer();
if (layer == null) {
/* TODO: Without this, we fail to draw e.g. a Class.
* But is this a good solution?
* Why is the Layer not set in the constructor? */
Editor editor = Globals.curEditor();
+ if (editor == null) {
+ // TODO: The above doesn't work reliably in a constructor. We
+ // need a better way of getting default fig settings for the owning
+ // project rather than using the project manager singleton. - tfm
+ return ProjectManager.getManager().getCurrentProject();
+ }
Layer lay = editor.getLayerManager().getActiveLayer();
- if (lay instanceof LayerPerspective) layer = (LayerPerspective) lay;
+ if (lay instanceof LayerPerspective) {
+ layer = (LayerPerspective) lay;
+ }
}
UMLMutableGraphSupport gm =
(UMLMutableGraphSupport) layer.getGraphModel();
@@ -1774,4 +1801,4 @@
== getOwner();
}
-} /* end class FigNodeModelElement */
+}
Modified: trunk/src_new/org/argouml/uml/diagram/ui/FigSingleLineText.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/FigSingleLineText.java?view=diff&rev=13046&p1=trunk/src_new/org/argouml/uml/diagram/ui/FigSingleLineText.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/FigSingleLineText.java&r1=13045&r2=13046
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/FigSingleLineText.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/FigSingleLineText.java 2007-07-10 13:18:28-0700
@@ -31,6 +31,7 @@
import java.beans.PropertyChangeEvent;
import java.util.Arrays;
+import org.argouml.gefext.ArgoFigText;
import org.argouml.model.AttributeChangeEvent;
import org.argouml.model.Model;
import org.argouml.notation.NotationProvider;
@@ -48,7 +49,7 @@
*
* @author Bob Tarling
*/
-public class FigSingleLineText extends FigText {
+public class FigSingleLineText extends ArgoFigText {
/**
* The UID.
Modified: trunk/src_new/org/argouml/uml/diagram/ui/FigTextGroup.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/FigTextGroup.java?view=diff&rev=13046&p1=trunk/src_new/org/argouml/uml/diagram/ui/FigTextGroup.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/FigTextGroup.java&r1=13045&r2=13046
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/FigTextGroup.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/FigTextGroup.java 2007-07-10 13:18:28-0700
@@ -30,7 +30,6 @@
import java.util.Iterator;
import org.tigris.gef.presentation.Fig;
-import org.tigris.gef.presentation.FigGroup;
/**
* Custom class to group FigTexts in such a way that they don't
@@ -39,7 +38,7 @@
*
* @author [email protected]
*/
-public class FigTextGroup extends FigGroup implements MouseListener {
+public class FigTextGroup extends ArgoFigGroup implements MouseListener {
private boolean supressCalcBounds = false;
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.