Author: bobtarling Date: 2011-03-30 09:16:40-0700 New Revision: 19146 Modified: trunk/src/argouml-app/src/org/argouml/kernel/Project.java trunk/src/argouml-app/src/org/argouml/kernel/ProjectImpl.java trunk/src/argouml-app/src/org/argouml/ui/ActionCreateContainedModelElement.java
Log: Pass the defaults tp the UML factory when creating model elements from the property panels 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=19146&r1=19145&r2=19146 ============================================================================== --- trunk/src/argouml-app/src/org/argouml/kernel/Project.java (original) +++ trunk/src/argouml-app/src/org/argouml/kernel/Project.java 2011-03-30 09:16:40-0700 @@ -45,6 +45,7 @@ import java.util.List; import java.util.Map; +import org.argouml.model.UmlFactoryDefaults; import org.argouml.uml.diagram.ArgoDiagram; import org.tigris.gef.presentation.Fig; @@ -284,6 +285,7 @@ @Deprecated public Object getModel(); + public UmlFactoryDefaults getUmlFactoryDefaults(); /** * Return the default type for an attribute. 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=19146&r1=19145&r2=19146 ============================================================================== --- trunk/src/argouml-app/src/org/argouml/kernel/ProjectImpl.java (original) +++ trunk/src/argouml-app/src/org/argouml/kernel/ProjectImpl.java 2011-03-30 09:16:40-0700 @@ -64,6 +64,7 @@ import org.argouml.i18n.Translator; import org.argouml.model.InvalidElementException; import org.argouml.model.Model; +import org.argouml.model.UmlFactoryDefaults; import org.argouml.profile.Profile; import org.argouml.profile.ProfileFacade; import org.argouml.ui.targetmanager.TargetManager; @@ -575,6 +576,29 @@ return null; } + public UmlFactoryDefaults getUmlFactoryDefaults() { + return new UmlFactoryDefaults() { + public Object getDefaultType(Object metaType) { + if (Model.getMetaTypes().getOperation() == metaType) { + if (profileConfiguration.getDefaultTypeStrategy() != null) { + return profileConfiguration.getDefaultTypeStrategy() + .getDefaultReturnType(); + } + } else if (Model.getMetaTypes().getAttribute() == metaType) { + if (profileConfiguration.getDefaultTypeStrategy() != null) { + return profileConfiguration.getDefaultTypeStrategy() + .getDefaultAttributeType(); + } + } else if (Model.getMetaTypes().getParameter() == metaType) { + if (profileConfiguration.getDefaultTypeStrategy() != null) { + return profileConfiguration.getDefaultTypeStrategy() + .getDefaultParameterType(); + } + } + return null; + } + }; + } public Object getDefaultParameterType() { if (profileConfiguration.getDefaultTypeStrategy() != null) { Modified: trunk/src/argouml-app/src/org/argouml/ui/ActionCreateContainedModelElement.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/ActionCreateContainedModelElement.java?view=diff&pathrev=19146&r1=19145&r2=19146 ============================================================================== --- trunk/src/argouml-app/src/org/argouml/ui/ActionCreateContainedModelElement.java (original) +++ trunk/src/argouml-app/src/org/argouml/ui/ActionCreateContainedModelElement.java 2011-03-30 09:16:40-0700 @@ -40,8 +40,11 @@ import java.awt.event.ActionEvent; +import org.argouml.kernel.Project; +import org.argouml.kernel.ProjectManager; import org.argouml.model.Model; import org.argouml.ui.targetmanager.TargetManager; +import org.argouml.uml.diagram.ui.FigCompartment; import org.argouml.uml.ui.AbstractActionNewModelElement; /** @@ -64,8 +67,8 @@ */ public ActionCreateContainedModelElement( Object theMetaType, - Object target) { - this(theMetaType, target, + Object container) { + this(theMetaType, container, "button.new-" + Model.getMetaTypes().getName(theMetaType).toLowerCase()); } @@ -75,31 +78,33 @@ * Construct the action. * * @param theMetaType the element to be created - * @param target the container that will own the new element + * @param container the container that will own the new element * @param menuDescr the description for the menu item label. */ public ActionCreateContainedModelElement( Object theMetaType, - Object target, + Object container, String menuDescr) { super(menuDescr); metaType = theMetaType; property = null; - setTarget(target); + setTarget(container); } /** * Construct the action. * * @param theMetaType the element to be created - * @param target the container that will own the new element + * @param container the container that will own the new element + * @param property the property name that represents the new element with + * the container * @param menuDescr the description for the menu item label. */ public ActionCreateContainedModelElement( Object theMetaType, - Object target, + Object container, String property, String menuDescr) { super(menuDescr); @@ -107,12 +112,19 @@ metaType = theMetaType; this.property = property; - setTarget(target); + setTarget(container); } - public void actionPerformed(ActionEvent e) { + public void actionPerformed(ActionEvent e) { + // TODO - lets pass in Project as a constructor argument + Project project = ProjectManager.getManager().getCurrentProject(); + Object newElement = - Model.getUmlFactory().buildNode(metaType, getTarget(), property); + Model.getUmlFactory().buildNode( + metaType, + getTarget(), + property, + project.getUmlFactoryDefaults()); TargetManager.getInstance().setTarget(newElement); } ------------------------------------------------------ http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2715345 To unsubscribe from this discussion, e-mail: [[email protected]].
