Author: tfmorris
Date: 2007-12-18 09:28:02-0800
New Revision: 13945
Added:
trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigUtil.java (contents, props changed)
Modified:
trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigGroup.java
trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigText.java
trunk/src_new/org/argouml/uml/diagram/ui/FigEdgeModelElement.java
trunk/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java
Log:
Consolidate getProject() implementations for 4 Argo Fig superclasses
Modified: 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=diff&rev=13945&p1=trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigGroup.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigGroup.java&r1=13944&r2=13945
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigGroup.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigGroup.java 2007-12-18 09:28:02-0800
@@ -33,6 +33,7 @@
import org.tigris.gef.base.Globals;
import org.tigris.gef.base.Layer;
import org.tigris.gef.base.LayerPerspective;
+import org.tigris.gef.graph.GraphModel;
import org.tigris.gef.presentation.FigGroup;
/**
@@ -68,29 +69,7 @@
* @see org.argouml.uml.diagram.ui.ArgoFig#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 (layer == null) {
- return null;
- }
- UMLMutableGraphSupport gm =
- (UMLMutableGraphSupport) layer.getGraphModel();
- return gm.getProject();
+ return ArgoFigUtil.getProject(this);
}
+
}
Modified: trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigText.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigText.java?view=diff&rev=13945&p1=trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigText.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigText.java&r1=13944&r2=13945
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigText.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigText.java 2007-12-18 09:28:02-0800
@@ -122,34 +122,7 @@
}
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 (layer == null) {
- return null;
- }
- GraphModel gm = layer.getGraphModel();
- if (gm instanceof UMLMutableGraphSupport) {
- return ((UMLMutableGraphSupport) gm).getProject();
- } else {
- return ProjectManager.getManager().getCurrentProject();
- }
+ return ArgoFigUtil.getProject(this);
}
/**
Added: trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigUtil.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigUtil.java?view=auto&rev=13945
==============================================================================
--- (empty file)
+++ trunk/src_new/org/argouml/uml/diagram/ui/ArgoFigUtil.java 2007-12-18 09:28:02-0800
@@ -0,0 +1,79 @@
+// $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;
+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.graph.GraphModel;
+import org.tigris.gef.presentation.Fig;
+
+/**
+ * Static utility methods for use with ArgoFigs.
+ *
+ * @author Tom Morris <[email protected]>
+ */
+public class ArgoFigUtil {
+
+ public static Project getProject(ArgoFig fig) {
+ if (fig instanceof Fig) {
+ Fig f = (Fig) fig;
+ LayerPerspective layer = (LayerPerspective) f.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 (layer == null) {
+ return ProjectManager.getManager().getCurrentProject();
+ }
+ GraphModel gm = layer.getGraphModel();
+ if (gm instanceof UMLMutableGraphSupport) {
+ return ((UMLMutableGraphSupport) gm).getProject();
+ } else {
+ return ProjectManager.getManager().getCurrentProject();
+ }
+ }
+ return null;
+ }
+
+
+}
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=13945&p1=trunk/src_new/org/argouml/uml/diagram/ui/FigEdgeModelElement.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/FigEdgeModelElement.java&r1=13944&r2=13945
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/FigEdgeModelElement.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/FigEdgeModelElement.java 2007-12-18 09:28:02-0800
@@ -66,7 +66,6 @@
import org.argouml.kernel.DelayedChangeNotify;
import org.argouml.kernel.DelayedVChangeListener;
import org.argouml.kernel.Project;
-import org.argouml.kernel.ProjectManager;
import org.argouml.model.AddAssociationEvent;
import org.argouml.model.AssociationChangeEvent;
import org.argouml.model.AttributeChangeEvent;
@@ -83,12 +82,9 @@
import org.argouml.ui.targetmanager.TargetManager;
import org.argouml.uml.StereotypeUtility;
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;
import org.tigris.gef.base.PathConvPercent;
import org.tigris.gef.base.Selection;
import org.tigris.gef.presentation.Fig;
@@ -1369,26 +1365,7 @@
}
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();
+ return ArgoFigUtil.getProject(this);
}
/**
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=13945&p1=trunk/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java&r1=13944&r2=13945
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java 2007-12-18 09:28:02-0800
@@ -88,15 +88,12 @@
import org.argouml.uml.diagram.ArgoDiagram;
import org.argouml.uml.diagram.IItemUID;
import org.argouml.uml.diagram.PathContainer;
-import org.argouml.uml.diagram.UMLMutableGraphSupport;
import org.argouml.uml.ui.ActionDeleteModelElements;
import org.tigris.gef.base.Diagram;
-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.base.Selection;
-import org.tigris.gef.graph.GraphModel;
import org.tigris.gef.graph.MutableGraphSupport;
import org.tigris.gef.presentation.Fig;
import org.tigris.gef.presentation.FigGroup;
@@ -2019,34 +2016,7 @@
* @see org.argouml.uml.diagram.ui.ArgoFig#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 (layer == null) {
- return null;
- }
-
- GraphModel gm = layer.getGraphModel();
- if (gm instanceof UMLMutableGraphSupport) {
- return ((UMLMutableGraphSupport) gm).getProject();
- } else {
- return ProjectManager.getManager().getCurrentProject();
- }
+ return ArgoFigUtil.getProject(this);
}
/**
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.