svn commit: r17038 - trunk/src: argouml-app/src/org/argouml/uml/ui/foundation/core argouml-core-model-mdr/src/org/argouml/model/mdr

Alexander Lepekhine <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: lepekhine
Date: 2009-04-05 02:02:29-0700
New Revision: 17038

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/PropPanelTemplateParameter.java
   trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UmlFactoryMDRImpl.java

Log:
Rewrote without MDR dependancy

Modified: trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/PropPanelTemplateParameter.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/PropPanelTemplateParameter.java?view=diff&pathrev=17038&r1=17037&r2=17038
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/PropPanelTemplateParameter.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/core/PropPanelTemplateParameter.java	2009-04-05 02:02:29-0700
@@ -1,54 +1,78 @@
+// $Id$
+// Copyright (c) 1996-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.ui.foundation.core;
 
 import javax.swing.JTextField;
 
+import org.argouml.i18n.Translator;
+import org.argouml.model.Model;
+import org.argouml.uml.ui.PropPanel;
 import org.argouml.uml.ui.UMLPlainTextDocument;
 import org.argouml.uml.ui.UMLTextField2;
-//import org.omg.uml.foundation.core.ModelElement;
-//import org.omg.uml.foundation.core.TemplateParameter;
-
-public class PropPanelTemplateParameter extends PropPanelStructuralFeature {
 
-	private static final long serialVersionUID = 8466952187322427678L;
-	
-	public PropPanelTemplateParameter() {
-		super("label.template-parameter", null);
-		addField("Name",  new UMLTextField2(new UMLTemplateParameterDocument("TemplateParameter")));
-		// TODO: we don't need Type and DefaultValue for Java but they should be implemented to comply with UML 
-		addField("Type", new JTextField(""));
-		addField("Default Value", new JTextField(""));
-	}
-	
-	public static class UMLTemplateParameterDocument extends UMLPlainTextDocument {
-
-		private static final long serialVersionUID = -2597673735297949111L;
-
-		public UMLTemplateParameterDocument(String name) {
-			super(name);
-		}
-//		
-//		private ModelElement getParameter() {
-//			Object target = getTarget();
-//			if (target instanceof TemplateParameter) {
-//				Object parameter =  ( (TemplateParameter)target).getParameter();
-//				if (parameter instanceof ModelElement) {
-//					return (ModelElement)parameter;
-//				}
-//				throw new IllegalArgumentException(parameter.getClass().getName() +" is not a ModelElement");
-//			}
-//			throw new IllegalArgumentException(target.getClass().getName() +" is not a TemplateParameter");
-//		}
-		
-		@Override
-		protected void setProperty(String text) {
-//			getParameter().setName(text);
-		}
-
-		@Override
-		protected String getProperty() {
-		    return "";
-//			return getParameter().getName();
-		}
-	}
+/**
+ * PropPanel for a TemplateParameter.
+ * @author alepekhin
+ *
+ */
+public class PropPanelTemplateParameter extends PropPanelModelElement {
+
+    private static final long serialVersionUID = 8466952187322427678L;
+
+    public PropPanelTemplateParameter() {
+        super("label.template-parameter", null);
+        addField(Translator.localize("label.name"), new UMLTextField2(new UMLTemplateParameterDocument(
+                "TemplateParameter")));
+        // TODO: not implemented yet
+        addField("Type", new JTextField(""));
+        addField("Default Value", new JTextField(""));
+    }
+
+    public static class UMLTemplateParameterDocument extends
+            UMLPlainTextDocument {
+
+        private static final long serialVersionUID = -2597673735297949111L;
+
+        public UMLTemplateParameterDocument(String name) {
+            super(name);
+        }
+
+        private Object getParameter() {
+            return Model.getFacade().getParameter(getTarget());
+        }
+
+        @Override
+        protected void setProperty(String name) {
+            Model.getCoreHelper().setName(getParameter(), name);
+        }
+
+        @Override
+        protected String getProperty() {
+            String name = Model.getFacade().getName(getParameter());
+            return name;
+        }
+    }
 
 }

Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UmlFactoryMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UmlFactoryMDRImpl.java?view=diff&pathrev=17038&r1=17037&r2=17038
==============================================================================
--- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UmlFactoryMDRImpl.java	(original)
+++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UmlFactoryMDRImpl.java	2009-04-05 02:02:29-0700
@@ -30,12 +30,15 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import javax.jmi.reflect.InvalidObjectException;
 import javax.jmi.reflect.RefObject;
 
 import org.apache.log4j.Logger;
 import org.argouml.model.DummyModelCommand;
+import org.argouml.model.ExtensionMechanismsFactory;
 import org.argouml.model.IllegalModelElementConnectionException;
 import org.argouml.model.InvalidElementException;
 import org.argouml.model.MetaTypes;
@@ -588,15 +591,23 @@
             element = this.modelImpl.getUseCasesFactory().
                 buildExtensionPoint(container);            
         } else if (elementType == this.metaTypes.getTemplateParameter()) {
-			TemplateParameter t = (TemplateParameter) Model.getCoreFactory().createTemplateParameter();
-			DataType d = getCore().createDataType();
-			d.setName("T");
-			t.setParameter(d);
-			if (container instanceof ModelElement) {
-				t.setTemplate((ModelElement)container);
-				((ModelElement) container).getTemplateParameter().add(t);
-			}
-            return t;            
+            TemplateParameter templateParam = getCore().createTemplateParameter();
+            Parameter param = getCore().createParameter();
+            param.setName("T");
+            templateParam.setParameter(param);
+            // bounds are defined as param tagged values
+            if (container instanceof ModelElement) {
+                for (String tagName : new String[]{"extends","super"}) {
+                    TaggedValue bound = (TaggedValue)getExtensionMechanisms().buildTaggedValue(
+                            getExtensionMechanisms().buildTagDefinition(tagName, null, 
+                                    ((ModelElement)container).getNamespace()),
+                            new String[]{""});
+                    param.getTaggedValue().add(bound);
+                }
+                templateParam.setTemplate((ModelElement)container);
+                ((ModelElement) container).getTemplateParameter().add(templateParam);
+            }
+            return templateParam;            
         } else {
             // build all other elements using existing buildNode
             element = buildNode(elementType);

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

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.