Author: bobtarling
Date: 2008-06-07 11:18:56-0700
New Revision: 14883
Modified:
trunk/src/argouml-app/src/org/argouml/uml/reveng/ui/RESequenceDiagramDialog.java
trunk/src/argouml-app/src/org/argouml/uml/ui/ActionRESequenceDiagram.java
Log:
Pass project from action to dialog
Use final to help understand what changes when
Modified: trunk/src/argouml-app/src/org/argouml/uml/reveng/ui/RESequenceDiagramDialog.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/reveng/ui/RESequenceDiagramDialog.java?view=diff&rev=14883&p1=trunk/src/argouml-app/src/org/argouml/uml/reveng/ui/RESequenceDiagramDialog.java&p2=trunk/src/argouml-app/src/org/argouml/uml/reveng/ui/RESequenceDiagramDialog.java&r1=14882&r2=14883
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/reveng/ui/RESequenceDiagramDialog.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/reveng/ui/RESequenceDiagramDialog.java 2008-06-07 11:18:56-0700
@@ -56,7 +56,6 @@
import org.apache.log4j.Logger;
import org.argouml.i18n.Translator;
import org.argouml.kernel.Project;
-import org.argouml.kernel.ProjectManager;
import org.argouml.model.Model;
import org.argouml.ui.CheckboxTableModel;
import org.argouml.ui.explorer.ExplorerEventAdaptor;
@@ -111,6 +110,11 @@
private static final int X_OFFSET = 10;
+ /**
+ * The project this dialog is operating within
+ */
+ private final Project project;
+
private final Object model;
// TODO: Why is this not final?
@@ -147,8 +151,8 @@
*
* @param oper The operation that should be reverse engineered.
*/
- public RESequenceDiagramDialog(Object oper) {
- this(oper, null, null);
+ public RESequenceDiagramDialog(Project project, Object oper) {
+ this(project, oper, null, null);
}
/**
@@ -156,11 +160,13 @@
* the actual diagram is a sequence diagram, so no new one is created and
* the work happens in the actual sequence diagram.
*
+ * @param project The project this dialog is acting within
* @param oper The operation that should be reverse engineered.
* @param figMessage the message figure where the result will be drawn to
* @param diagram the diagram to draw to or null is a new diagram required
*/
public RESequenceDiagramDialog(
+ final Project project,
final Object oper,
final FigMessage figMessage,
final ArgoDiagram diagram) {
@@ -176,11 +182,9 @@
ArgoDialog.OK_CANCEL_OPTION,
true);
setResizable(false);
-
+ this.project = project;
+
operation = oper;
- // TODO: Remove reference to getCurrentProject. Project should be
- // as an argument.
- Project project = ProjectManager.getManager().getCurrentProject();
model = project.getModel();
try {
// TODO: must not depend on the Java modeller, but the needed one
@@ -258,21 +262,20 @@
} else if (e.getSource() == getCancelButton()
&& isNewSequenceDiagram) {
// remove SD and clean up everything
- Project p = ProjectManager.getManager().getCurrentProject();
Object newTarget = null;
if (ActionDeleteModelElements.sureRemove(diagram)) {
Object collaboration = diagram.getNamespace();
// remove from the model
newTarget = getNewTarget(diagram);
- p.moveToTrash(diagram);
- p.moveToTrash(collaboration);
+ project.moveToTrash(diagram);
+ project.moveToTrash(collaboration);
}
if (newTarget != null) {
TargetManager.getInstance().setTarget(newTarget);
}
}
}
-
+
/*
* @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
*/
@@ -296,7 +299,6 @@
* @return The object.
*/
private Object getNewTarget(Object target) {
- Project p = ProjectManager.getManager().getCurrentProject();
Object newTarget = null;
if (target instanceof Fig) {
// TODO: common method for getting the model element of a fig
@@ -306,18 +308,18 @@
&& Model.getFacade().getNamespace(target) != null) {
newTarget = Model.getFacade().getNamespace(target);
} else if (target instanceof Diagram) {
- Diagram firstDiagram = (Diagram) p.getDiagramList().get(0);
+ Diagram firstDiagram = (Diagram) project.getDiagramList().get(0);
if (target != firstDiagram) {
newTarget = firstDiagram;
} else {
- if (p.getDiagramList().size() > 1) {
- newTarget = p.getDiagramList().get(1);
+ if (project.getDiagramList().size() > 1) {
+ newTarget = project.getDiagramList().get(1);
} else {
- newTarget = p.getRoot();
+ newTarget = project.getRoot();
}
}
} else {
- newTarget = p.getRoot();
+ newTarget = project.getRoot();
}
return newTarget;
}
@@ -499,9 +501,6 @@
* TODO: find a better place for a similar method.
*/
private ArgoDiagram buildSequenceDiagram(Object theClassifier) {
- // TODO: Remove reference to ProjectManager
- Project p = ProjectManager.getManager().getCurrentProject();
-
Object collaboration =
Model.getCollaborationsFactory().buildCollaboration(
Model.getFacade().getNamespace(theClassifier),
@@ -511,7 +510,7 @@
DiagramType.Sequence,
collaboration,
null);
- p.addMember(newDiagram);
+ project.addMember(newDiagram);
TargetManager.getInstance().setTarget(newDiagram);
return newDiagram;
}
Modified: trunk/src/argouml-app/src/org/argouml/uml/ui/ActionRESequenceDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/ui/ActionRESequenceDiagram.java?view=diff&rev=14883&p1=trunk/src/argouml-app/src/org/argouml/uml/ui/ActionRESequenceDiagram.java&p2=trunk/src/argouml-app/src/org/argouml/uml/ui/ActionRESequenceDiagram.java&r1=14882&r2=14883
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/ui/ActionRESequenceDiagram.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/ui/ActionRESequenceDiagram.java 2008-06-07 11:18:56-0700
@@ -47,6 +47,11 @@
public class ActionRESequenceDiagram extends AbstractAction {
/**
+ * The UID.
+ */
+ private static final long serialVersionUID = 2915509413708666273L;
+
+ /**
* The constructor. If a figure is given, then it is invoked inside of a
* sequence diagram, so it will work with this diagram. If figure is null,
* then this causes the creation of a new sequence diagram.
@@ -69,21 +74,16 @@
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e) {
+ Project project = ProjectManager.getManager().getCurrentProject();
final Object target = TargetManager.getInstance().getTarget();
if (Model.getFacade().isAOperation(target)) {
RESequenceDiagramDialog dialog =
- new RESequenceDiagramDialog(target);
+ new RESequenceDiagramDialog(project, target);
dialog.setVisible(true);
} else if (Model.getFacade().isAMessage(target) && messageFig != null) {
final Object action = Model.getFacade().getAction(target);
- Object operation =
- Model.getFacade().isACallAction(action)
- ? Model.getFacade().getOperation(action)
- : null;
final SequenceDiagramGraphModel sequenceDiagramGraphModel =
(SequenceDiagramGraphModel) Globals.curEditor().getGraphModel();
- final Project project =
- ProjectManager.getManager().getCurrentProject();
ArgoDiagram diagram = null;
Iterator<ArgoDiagram> iter = project.getDiagramList().iterator();
while (iter.hasNext()) {
@@ -92,12 +92,14 @@
break;
}
}
- if (operation != null) {
+ if (Model.getFacade().isACallAction(action)) {
+ final Object operation = Model.getFacade().getOperation(action);
// it is highly desirable that the message action
// already knows it's operation
// TODO: There is a cyclic dependency between
// ActionRESequenceDiagram and FigMessage
RESequenceDiagramDialog dialog = new RESequenceDiagramDialog(
+ project,
operation,
(FigMessage) messageFig,
diagram);
@@ -105,14 +107,14 @@
} else {
// the hard way: try to determine the operation
// from the message name
- Object receiver = Model.getFacade().getReceiver(target);
+ final Object receiver = Model.getFacade().getReceiver(target);
// TODO: Do we really need to test for null here? I would
// expect an empty array which is safe.
- Collection c =
+ final Collection c =
receiver != null
? Model.getFacade().getBases(receiver)
: null;
- Object cls =
+ final Object cls =
c != null && !c.isEmpty() ? c.iterator().next() : null;
if (cls != null && Model.getFacade().isAClassifier(cls)) {
// too primitive (just gets the first method
@@ -128,16 +130,15 @@
}
pos2 = pos2 != -1 ? pos2 : opName.length();
opName = opName.substring(pos1, pos2);
- final Iterator it =
- Model.getCoreHelper().getOperationsInh(cls).iterator();
- while (it.hasNext()) {
- operation = it.next();
+
+ for (Object operation : Model.getCoreHelper().getOperationsInh(cls)) {
if (opName.equals(
Model.getFacade().getName(operation))) {
// TODO: There is a cyclic dependency between
// ActionRESequenceDiagram and FigMessage
RESequenceDiagramDialog dialog =
new RESequenceDiagramDialog(
+ project,
operation,
(FigMessage) messageFig,
diagram);
@@ -162,9 +163,4 @@
// TODO: We later cast this to FigMessage so why define as Object here?
private Object messageFig;
-
- /**
- * The UID.
- */
- private static final long serialVersionUID = 2915509413708666273L;
}
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.