svn commit: r17127 - trunk/src/argouml-app/src/org/argouml/uml/ui: . foundation/core

Thomas Neustupny <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: thn
Date: 2009-04-24 03:46:38-0700
New Revision: 17127

Added:
   trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/UMLOperationRaisedExceptionsListModel.java   (contents, props changed)
Modified:
   trunk/src/argouml-app/src/org/argouml/uml/ui/InitUmlUI.java
   trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/PropPanelOperation.java

Log:
UML2: enable working with operations in diagram and property panel
(obtained from arueckert, modified to make prop panel work for UML1 again)

Modified: trunk/src/argouml-app/src/org/argouml/uml/ui/InitUmlUI.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/ui/InitUmlUI.java?view=diff&pathrev=17127&r1=17126&r2=17127
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/ui/InitUmlUI.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/ui/InitUmlUI.java	2009-04-24 03:46:38-0700
@@ -31,6 +31,7 @@
 import org.argouml.application.api.AbstractArgoJPanel;
 import org.argouml.application.api.GUISettingsTabInterface;
 import org.argouml.application.api.InitSubsystem;
+import org.argouml.model.Model;
 
 /**
  * Initialise this subsystem.
@@ -58,7 +59,10 @@
         result.add(new TabSrc());
         result.add(new TabConstraints());
         result.add(new TabStereotype());
-        result.add(new TabTaggedValues());
+        // Add the tagged values for UML 1.x
+        if( Model.getFacade().getUmlVersion().charAt(0) == '1') {
+            result.add(new TabTaggedValues());
+        }
         return result;
     }
 

Modified: trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/PropPanelOperation.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/PropPanelOperation.java?view=diff&pathrev=17127&r1=17126&r2=17127
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/PropPanelOperation.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/PropPanelOperation.java	2009-04-24 03:46:38-0700
@@ -86,9 +86,16 @@
 
         addSeparator();
 
-        addField(Translator.localize("label.raisedsignals"),
-               new JScrollPane(new UMLLinkedList(
-                       new UMLOperationRaisedSignalsListModel())));
+        if (Model.getFacade().getUmlVersion().charAt(0) == '1') {
+            addField(Translator.localize("label.raisedsignals"),
+                    new JScrollPane(new UMLLinkedList(
+                            new UMLOperationRaisedSignalsListModel())));
+        } else {
+            // UML2
+            addField(Translator.localize("label.raisedexceptions"),
+                    new JScrollPane(new UMLLinkedList(
+                            new UMLOperationRaisedExceptionsListModel())));
+        }
 
         addField(Translator.localize("label.methods"),
                new JScrollPane(new UMLLinkedList(
@@ -121,7 +128,12 @@
         });
         addAction(new ActionAddOperation());
         addAction(new ActionNewParameter());
-        addAction(new ActionNewRaisedSignal());
+        if (Model.getFacade().getUmlVersion().charAt(0) == '1') {
+            addAction(new ActionNewRaisedSignal());
+        } else {
+            // UML2
+            addAction(new ActionNewRaisedException());
+        }
         addAction(new ActionNewMethod());
         addAction(new ActionAddDataType());
         addAction(new ActionAddEnumeration());
@@ -129,11 +141,13 @@
         addAction(getDeleteAction());
     }
 
-
     /**
      * Add a new RaisedSignal to the current target.
      */
     public void addRaisedSignal() {
+        if (Model.getFacade().getUmlVersion().charAt(0) != '1') {
+            return;
+        }
         Object target = getTarget();
         if (Model.getFacade().isAOperation(target)) {
             Object oper = target;
@@ -150,6 +164,28 @@
     }
 
     /**
+     * Add a new RaisedException to the current target.
+     */
+    public void addRaisedException() {
+        if (Model.getFacade().getUmlVersion().charAt(0) != '2') {
+            return;
+        }
+        Object target = getTarget();
+        if (Model.getFacade().isAOperation(target)) {
+            Object oper = target;
+            Object newException = Model.getCommonBehaviorFactory()
+                    .createException();
+
+            Model.getCoreHelper().addOwnedElement(
+                    Model.getFacade().getNamespace(
+                            Model.getFacade().getOwner(oper)),
+                    newException);
+            Model.getCoreHelper().addRaisedException(oper, newException);
+            TargetManager.getInstance().setTarget(newException);
+        }
+    }
+
+    /**
      * Add a Method to the current target.
      */
     public void addMethod() {
@@ -173,7 +209,7 @@
         private static final long serialVersionUID = -2380798799656866520L;
 
         /**
-         * Construct an action to create a new RaisedSignal.
+         * Construct an action to create a new RaisedException.
          */
         public ActionNewRaisedSignal() {
             super("button.new-raised-signal");
@@ -196,6 +232,32 @@
         }
     }
 
+    private class ActionNewRaisedException extends AbstractActionNewModelElement {
+
+        /**
+         * Construct an action to create a new RaisedException.
+         */
+        public ActionNewRaisedException() {
+            super("button.new-raised-exception");
+            putValue(Action.NAME,
+                    Translator.localize("button.new-raised-exception"));
+            Icon icon = ResourceLoaderWrapper.lookupIcon("SignalSending");
+            putValue(Action.SMALL_ICON, icon);
+        }
+
+        /*
+         * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+         */
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            Object target = TargetManager.getInstance().getModelTarget();
+            if (Model.getFacade().isAOperation(target)) {
+                addRaisedException();
+                super.actionPerformed(e);
+            }
+        }
+    }
+
 
     private class ActionNewMethod extends AbstractActionNewModelElement {
 

Added: trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/UMLOperationRaisedExceptionsListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/UMLOperationRaisedExceptionsListModel.java?view=markup&pathrev=17127
==============================================================================
--- (empty file)
+++ trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/UMLOperationRaisedExceptionsListModel.java	2009-04-24 03:46:38-0700
@@ -0,0 +1,73 @@
+// $Id$
+// Copyright (c) 2004-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.uml.ui.foundation.core;
+
+import java.util.Collection;
+
+import org.argouml.model.Model;
+import org.argouml.uml.ui.UMLModelElementListModel2;
+
+
+/**
+ * The model for the list of raised exceptions of an operation.
+ *
+ * @author Michiel
+ */
+public class UMLOperationRaisedExceptionsListModel
+    extends UMLModelElementListModel2 {
+
+    /**
+     * The constructor.
+     */
+    public UMLOperationRaisedExceptionsListModel() {
+        super("exception");
+    }
+
+    /*
+     * @see org.argouml.uml.ui.UMLModelElementListModel2#buildModelList()
+     */
+    protected void buildModelList() {
+        if (getTarget() != null) {
+            Collection exceptions = null;
+            Object target = getTarget();
+            if (Model.getFacade().isAOperation(target)) {
+                exceptions = Model.getFacade().getRaisedExceptions(target);
+            }
+            setAllElements(exceptions);
+        }
+    }
+
+    /*
+     * @see org.argouml.uml.ui.UMLModelElementListModel2#isValidElement(java.lang.Object)
+     */
+    protected boolean isValidElement(Object element) {
+        Collection exceptions = null;
+        Object target = getTarget();
+        if (Model.getFacade().isAOperation(target)) {
+            exceptions = Model.getFacade().getRaisedExceptions(target);
+        }
+        return (exceptions != null) && exceptions.contains(element);
+    }
+}

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=1889762

To unsubscribe from this discussion, e-mail: [[email protected]].
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.