svn commit: r17393 - trunk/src/argouml-app/src/org/argouml: Images Images/plaf/javax/swing/plaf/metal/MetalLookAndFeel/toolbarButtonGraphics/general application/helpers i18n kernel ui/cmd uml
Thomas Neustupny <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: thn
Date: 2009-10-10 14:09:46-0700
New Revision: 17393
Added:
trunk/src/argouml-app/src/org/argouml/Images/Profile.gif (contents, props changed)
trunk/src/argouml-app/src/org/argouml/Images/plaf/javax/swing/plaf/metal/MetalLookAndFeel/toolbarButtonGraphics/general/NewProfile.gif (contents, props changed)
trunk/src/argouml-app/src/org/argouml/ui/cmd/ActionNewProfile.java (contents, props changed)
Modified:
trunk/src/argouml-app/src/org/argouml/application/helpers/ResourceLoaderWrapper.java
trunk/src/argouml-app/src/org/argouml/i18n/action.properties
trunk/src/argouml-app/src/org/argouml/i18n/misc.properties
trunk/src/argouml-app/src/org/argouml/kernel/Project.java
trunk/src/argouml-app/src/org/argouml/kernel/ProjectFactory.java
trunk/src/argouml-app/src/org/argouml/kernel/ProjectImpl.java
trunk/src/argouml-app/src/org/argouml/kernel/ProjectManager.java
trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java
trunk/src/argouml-app/src/org/argouml/uml/ProjectMemberModel.java
Log:
add feature: create new profile project
Added: trunk/src/argouml-app/src/org/argouml/Images/Profile.gif
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/Images/Profile.gif?view=markup&pathrev=17393
==============================================================================
Binary file. No diff available.
Added: trunk/src/argouml-app/src/org/argouml/Images/plaf/javax/swing/plaf/metal/MetalLookAndFeel/toolbarButtonGraphics/general/NewProfile.gif
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/Images/plaf/javax/swing/plaf/metal/MetalLookAndFeel/toolbarButtonGraphics/general/NewProfile.gif?view=markup&pathrev=17393
==============================================================================
Binary file. No diff available.
Modified: trunk/src/argouml-app/src/org/argouml/application/helpers/ResourceLoaderWrapper.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/application/helpers/ResourceLoaderWrapper.java?view=diff&pathrev=17393&r1=17392&r2=17393
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/application/helpers/ResourceLoaderWrapper.java (original)
+++ trunk/src/argouml-app/src/org/argouml/application/helpers/ResourceLoaderWrapper.java 2009-10-10 14:09:46-0700
@@ -337,6 +337,7 @@
images.put("action.navigate-back", "Navigate Back");
images.put("action.navigate-forward", "Navigate Forward");
images.put("action.new", "New");
+ images.put("action.new-profile", "NewProfile");
images.put("action.new-todo-item", "New To Do Item...");
images.put("action.open-project", "Open Project...");
images.put("action.page-setup", "Page Setup...");
Modified: trunk/src/argouml-app/src/org/argouml/i18n/action.properties
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/i18n/action.properties?view=diff&pathrev=17393&r1=17392&r2=17393
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/i18n/action.properties (original)
+++ trunk/src/argouml-app/src/org/argouml/i18n/action.properties 2009-10-10 14:09:46-0700
@@ -135,6 +135,7 @@
action.navigation.bidirectional = Bidirectional
action.navigation.from-to = {0} to {1}
action.new = New
+action.new-profile = New Profile
action.new-comment = New Comment
action.new-todo-item = New To Do Item...
action.next-details-tab = Next Details Tab
Modified: trunk/src/argouml-app/src/org/argouml/i18n/misc.properties
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/i18n/misc.properties?view=diff&pathrev=17393&r1=17392&r2=17393
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/i18n/misc.properties (original)
+++ trunk/src/argouml-app/src/org/argouml/i18n/misc.properties 2009-10-10 14:09:46-0700
@@ -224,5 +224,6 @@
misc.type = Type
misc.unnamed = (Unnamed {0})
misc.untitled-model = untitledModel
+misc.untitled-profile = untitledProfile
misc.use-case = Use Case
misc.use-case.extension-point = Use Case->Extension Point
Modified: trunk/src/argouml-app/src/org/argouml/kernel/Project.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/kernel/Project.java?view=diff&pathrev=17393&r1=17392&r2=17393
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/kernel/Project.java (original)
+++ trunk/src/argouml-app/src/org/argouml/kernel/Project.java 2009-10-10 14:09:46-0700
@@ -44,11 +44,20 @@
* eliminating methods which should be part of the public API and splitting the
* interface into smaller function specific (e.g. TrashCan) interfaces.
*
- * @author Tom Morris <[email protected]>
+ * @author Tom Morris <[email protected]>, Thomas Neustupny
* @since 0.25.4 when it replaced the concrete class of the same name
*/
public interface Project {
+ /**
+ * Project type: an UML project
+ */
+ public static final int UML_PROJECT = 0;
+
+ /**
+ * Project type: a profile project
+ */
+ public static final int PROFILE_PROJECT = 0;
/**
* Get the project name. This is just the name part of the full filename.
@@ -56,6 +65,11 @@
*/
public String getName();
+ /**
+ * Get the project type. (Currently needed for profile project; probably
+ * no longer needed when ArgoUML supports multimodel projects.)
+ */
+ public int getProjectType();
/**
* Get the URI for this project.
Modified: trunk/src/argouml-app/src/org/argouml/kernel/ProjectFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/kernel/ProjectFactory.java?view=diff&pathrev=17393&r1=17392&r2=17393
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/kernel/ProjectFactory.java (original)
+++ trunk/src/argouml-app/src/org/argouml/kernel/ProjectFactory.java 2009-10-10 14:09:46-0700
@@ -61,7 +61,7 @@
* @return a newly created project
*/
public Project createProject(URI uri) {
- return new ProjectImpl(uri);
+ return new ProjectImpl(Project.UML_PROJECT, uri);
}
public static ProjectFactory getInstance() {
Modified: trunk/src/argouml-app/src/org/argouml/kernel/ProjectImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/kernel/ProjectImpl.java?view=diff&pathrev=17393&r1=17392&r2=17393
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/kernel/ProjectImpl.java (original)
+++ trunk/src/argouml-app/src/org/argouml/kernel/ProjectImpl.java 2009-10-10 14:09:46-0700
@@ -76,6 +76,11 @@
Translator.localize("label.projectbrowser-title");
/**
+ * The project type
+ */
+ private int projectType = UML_PROJECT;
+
+ /**
* The UID.
*/
static final long serialVersionUID = 1399111233978692444L;
@@ -153,8 +158,8 @@
*
* @param theProjectUri Uri to read the project from.
*/
- public ProjectImpl(URI theProjectUri) {
- this();
+ public ProjectImpl(int type, URI theProjectUri) {
+ this(UML_PROJECT);
/* TODO: Why was this next line in the code so long? */
// uri = PersistenceManager.getInstance().fixUriExtension(theProjectUri);
uri = theProjectUri;
@@ -164,6 +169,14 @@
* Constructor.
*/
public ProjectImpl() {
+ this(UML_PROJECT);
+ }
+
+ /**
+ * Constructor.
+ */
+ public ProjectImpl(int type) {
+ projectType = type;
setProfileConfiguration(new ProfileConfiguration(this));
projectSettings = new ProjectSettings();
@@ -192,6 +205,9 @@
return new File(uri).getName();
}
+ public int getProjectType() {
+ return projectType;
+ }
public URI getUri() {
return uri;
@@ -288,6 +304,9 @@
} else if (Model.getFacade().isAModel(m)) {
LOG.info("Adding model member");
addModelMember(m);
+ } else if (Model.getFacade().isAProfile(m)) {
+ LOG.info("Adding profile model member");
+ addModelMember(m);
} else {
throw new IllegalArgumentException(
"The member must be a UML model todo member or diagram."
@@ -330,7 +349,8 @@
public void addModel(final Object model) {
- if (!Model.getFacade().isAModel(model)) {
+ if (!Model.getFacade().isAModel(model)
+ && !Model.getFacade().isAProfile(model)) {
throw new IllegalArgumentException();
}
if (!models.contains(model)) {
@@ -823,6 +843,9 @@
if (Model.getFacade().isAModel(obj)) {
return; //Can not delete the model
}
+ if (Model.getFacade().isAProfile(obj)) {
+ return; //Can not delete the profile
+ }
if (obj != null) {
trashcan.add(obj);
@@ -832,9 +855,9 @@
Model.getUmlFactory().delete(obj);
// TODO: Presumably this is only relevant if
- // obj is actually a Model.
- // An added test of Model.getFacade.isAModel(obj) would clarify what
- // is going on here.
+ // obj is actually a Model or Profile.
+ // An added test of isAModel(obj) or isAProfile(obj) would clarify
+ // what is going on here.
if (models.contains(obj)) {
models.remove(obj);
}
@@ -897,7 +920,8 @@
throw new IllegalArgumentException(
"A root model element is required");
}
- if (!Model.getFacade().isAModel(theRoot)) {
+ if (!Model.getFacade().isAModel(theRoot)
+ && !Model.getFacade().isAProfile(theRoot)) {
throw new IllegalArgumentException(
"The root model element must be a model - got "
+ theRoot.getClass().getName());
@@ -930,7 +954,8 @@
LOG.warn("Top level element other than package found - "
+ Model.getFacade().getName(element));
}
- if (Model.getFacade().isAModel(element)) {
+ if (Model.getFacade().isAModel(element)
+ || Model.getFacade().isAProfile(element) ) {
addModel(element);
if (!modelFound) {
setRoot(element);
Modified: trunk/src/argouml-app/src/org/argouml/kernel/ProjectManager.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/kernel/ProjectManager.java?view=diff&pathrev=17393&r1=17392&r2=17393
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/kernel/ProjectManager.java (original)
+++ trunk/src/argouml-app/src/org/argouml/kernel/ProjectManager.java 2009-10-10 14:09:46-0700
@@ -314,7 +314,55 @@
}
/**
- * Create the default diagrams for the project. Currently a Class Diagram
+ * Makes an empty profile project.
+ * @return Project the empty profile project
+ */
+ public Project makeEmptyProfileProject() {
+ return makeEmptyProfileProject(true);
+ }
+
+ /**
+ * Make a new empty profile project optionally including default diagrams.
+ * <p>
+ * Historically new projects have been created with two default diagrams
+ * (Class and Use Case). NOTE: ArgoUML currently requires at least one
+ * diagram for proper operation.
+ *
+ * @param addDefaultDiagrams
+ * if true the project will be be created with the standard
+ * default diagram (Class)
+ * @return Project the newly created profile project
+ */
+ public Project makeEmptyProfileProject(final boolean addDefaultDiagrams) {
+ final Command cmd = new NonUndoableCommand() {
+
+ @Override
+ public Object execute() {
+ Model.getPump().stopPumpingEvents();
+
+ creatingCurrentProject = true;
+ LOG.info("making empty profile project");
+ Project newProject = new ProjectImpl(Project.PROFILE_PROJECT);
+ createDefaultProfile(newProject);
+ if (addDefaultDiagrams) {
+ ArgoDiagram d = createClassDiagram(newProject);
+ createTodoList(newProject);
+ newProject.setActiveDiagram(d);
+ }
+ creatingCurrentProject = false;
+ setCurrentProject(newProject);
+ Model.getPump().startPumpingEvents();
+ return null;
+ }
+ };
+ cmd.execute();
+ currentProject.getUndoManager().addCommand(cmd);
+ setSaveEnabled(false);
+ return currentProject;
+ }
+
+ /**
+ * Create the default diagrams for the project. Currently a Class Diagram
* and a UseCase diagram.
*
* @param project the project to create the diagrams in.
@@ -323,19 +371,46 @@
LOG.debug("Creating default diagrams");
Object model = project.getRoots().iterator().next();
DiagramFactory df = DiagramFactory.getInstance();
- ArgoDiagram d = df.create(DiagramFactory.DiagramType.Class,
- model,
- project.getProjectSettings().getDefaultDiagramSettings());
- project.addMember(d);
+ ArgoDiagram d = createClassDiagram(project);
+ LOG.debug("Creating use case diagram");
project.addMember(df.create(
DiagramFactory.DiagramType.UseCase, model,
project.getProjectSettings().getDefaultDiagramSettings()));
project.addMember(new ProjectMemberTodoList("",
project));
+ createTodoList(project);
project.setActiveDiagram(d);
}
/**
+ * Create a class diagrams for the project.
+ *
+ * @param project the project to create the diagram in.
+ * @return the created class diagram
+ */
+ private ArgoDiagram createClassDiagram(Project project) {
+ LOG.debug("Creating class diagram");
+ Object model = project.getRoots().iterator().next();
+ DiagramFactory df = DiagramFactory.getInstance();
+ ArgoDiagram d = df.create(DiagramFactory.DiagramType.Class,
+ model,
+ project.getProjectSettings().getDefaultDiagramSettings());
+ project.addMember(d);
+ return d;
+ }
+
+ /**
+ * Create a todo list for the project.
+ *
+ * @param project the project to create the todo list in.
+ */
+ private void createTodoList(Project project) {
+ LOG.debug("Creating todo list");
+ project.addMember(new ProjectMemberTodoList("",
+ project));
+ }
+
+ /**
* Create the top level model for the project and set it as a root and the
* current namespace.
*
@@ -351,6 +426,23 @@
project.setCurrentNamespace(model);
project.addMember(model);
}
+
+ /**
+ * Create the top level profile for the project and set it as a root and the
+ * current namespace.
+ *
+ * @param project the project to create the model in.
+ */
+ private void createDefaultProfile(Project project) {
+ Object model = Model.getModelManagementFactory().createProfile();
+ Model.getCoreHelper().setName(model,
+ Translator.localize("misc.untitled-profile"));
+ Collection roots = new ArrayList();
+ roots.add(model);
+ project.setRoots(roots);
+ project.setCurrentNamespace(model);
+ project.addMember(model);
+ }
/**
* Set the save action.
Added: trunk/src/argouml-app/src/org/argouml/ui/cmd/ActionNewProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/cmd/ActionNewProfile.java?view=markup&pathrev=17393
==============================================================================
--- (empty file)
+++ trunk/src/argouml-app/src/org/argouml/ui/cmd/ActionNewProfile.java 2009-10-10 14:09:46-0700
@@ -0,0 +1,87 @@
+// $Id$
+// Copyright (c) 2009 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.ui.cmd;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+
+import org.argouml.application.helpers.ResourceLoaderWrapper;
+import org.argouml.cognitive.Designer;
+import org.argouml.i18n.Translator;
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+import org.argouml.ui.ProjectBrowser;
+import org.argouml.ui.targetmanager.TargetManager;
+
+/**
+ * Action to trigger creation of a new profile project.
+ */
+public class ActionNewProfile extends AbstractAction {
+
+ /**
+ * The constructor.
+ */
+ public ActionNewProfile() {
+ // Set the name and icon:
+ super(Translator.localize("action.new-profile"),
+ ResourceLoaderWrapper.lookupIcon("action.new-profile"));
+ // Set the tooltip string:
+ putValue(Action.SHORT_DESCRIPTION,
+ Translator.localize("action.new-profile"));
+ }
+
+ ////////////////////////////////////////////////////////////////
+ // main methods
+
+ /*
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent e) {
+ Model.getPump().flushModelEvents();
+ Model.getPump().stopPumpingEvents();
+ Model.getPump().flushModelEvents();
+ Project p = ProjectManager.getManager().getCurrentProject();
+
+ if (getValue("non-interactive") == null) {
+ if (!ProjectBrowser.getInstance().askConfirmationAndSave()) {
+ return;
+ }
+ }
+
+ ProjectBrowser.getInstance().clearDialogs();
+ Designer.disableCritiquing();
+ Designer.clearCritiquing();
+ // clean the history
+ TargetManager.getInstance().cleanHistory();
+ p.remove();
+ p = ProjectManager.getManager().makeEmptyProfileProject();
+ TargetManager.getInstance().setTarget(p.getDiagramList().get(0));
+ Designer.enableCritiquing();
+ Model.getPump().startPumpingEvents();
+ }
+}
Modified: trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java?view=diff&pathrev=17393&r1=17392&r2=17393
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java (original)
+++ trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java 2009-10-10 14:09:46-0700
@@ -311,6 +311,10 @@
setMnemonic(newItem, "New");
ShortcutMgr.assignAccelerator(newItem, ShortcutMgr.ACTION_NEW_PROJECT);
toolbarTools.add((new ActionNew()));
+ JMenuItem newProfileItem = file.add(new ActionNewProfile());
+ setMnemonic(newProfileItem, "New Profile");
+ ShortcutMgr.assignAccelerator(newProfileItem, null);
+ toolbarTools.add((new ActionNewProfile()));
openAction = new ActionOpenProject();
JMenuItem openProjectItem = file.add(openAction);
setMnemonic(openProjectItem, "Open");
Modified: trunk/src/argouml-app/src/org/argouml/uml/ProjectMemberModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/ProjectMemberModel.java?view=diff&pathrev=17393&r1=17392&r2=17393
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/ProjectMemberModel.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/ProjectMemberModel.java 2009-10-10 14:09:46-0700
@@ -42,7 +42,7 @@
/**
* The constructor.
*
- * @param m the model
+ * @param m the model or profile
* @param p the project
*/
public ProjectMemberModel(Object m, Project p) {
@@ -50,7 +50,8 @@
super(PersistenceManager.getInstance().getProjectBaseName(p)
+ FILE_EXT, p);
- if (!Model.getFacade().isAModel(m))
+ if (!Model.getFacade().isAModel(m)
+ && !Model.getFacade().isAProfile(m))
throw new IllegalArgumentException();
setModel(m);
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2406231
To unsubscribe from this discussion, e-mail: [[email protected]].