Author: tfmorris
Date: 2007-07-10 13:30:14-0700
New Revision: 13047
Modified:
trunk/src_new/org/argouml/gefext/ArgoFigText.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
Modified: trunk/src_new/org/argouml/gefext/ArgoFigText.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/gefext/ArgoFigText.java?view=diff&rev=13047&p1=trunk/src_new/org/argouml/gefext/ArgoFigText.java&p2=trunk/src_new/org/argouml/gefext/ArgoFigText.java&r1=13046&r2=13047
==============================================================================
--- trunk/src_new/org/argouml/gefext/ArgoFigText.java (original)
+++ trunk/src_new/org/argouml/gefext/ArgoFigText.java 2007-07-10 13:30:14-0700
@@ -32,6 +32,14 @@
import javax.management.NotificationFilter;
import javax.management.NotificationListener;
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.uml.diagram.UMLMutableGraphSupport;
+import org.argouml.uml.diagram.ui.ArgoFig;
+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.FigText;
/**
@@ -39,7 +47,7 @@
*
* @author Michiel
*/
-public class ArgoFigText extends FigText implements NotificationEmitter {
+public class ArgoFigText extends FigText implements NotificationEmitter, ArgoFig {
private NotificationBroadcasterSupport notifier =
new NotificationBroadcasterSupport();
@@ -48,7 +56,10 @@
super(x, y, w, h);
}
-
+ public ArgoFigText(int x, int y, int w, int h, boolean expandOnly) {
+ super(x, y, w, h, expandOnly);
+ }
+
/*
* @see org.tigris.gef.presentation.Fig#deleteFromModel()
*/
@@ -91,5 +102,37 @@
throws ListenerNotFoundException {
notifier.removeNotificationListener(listener);
}
+
+ /**
+ * 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();
+ }
}
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.