Author: bobtarling
Date: 2010-07-21 05:02:15-0700
New Revision: 18540
Added:
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComponentInstanceClassifierComboBoxModel.java
Modified:
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/metamodel.xml
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCollaborationRepresentedClassifierComboBoxModel.java
Log:
Enforce WFR 4.9.3.6[1] in this regard
[1] A ComponentInstance originates from exactly one Component.
self.classifier->size = 1
and
self.classifier.oclIsKindOf (Component)
Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/metamodel.xml
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/metamodel.xml?view=diff&pathrev=18540&r1=18539&r2=18540
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/metamodel.xml (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/metamodel.xml 2010-07-21 05:02:15-0700
@@ -2427,7 +2427,7 @@
<list name="clientDependency" type="Dependency" label="label.client-dependencies" />
<list name="supplierDependency" type="ModelElement" label="label.supplier-dependencies" />
<separator />
- <list name="classifier" type="Classifier" />
+ <combo name="classifier" type="Classifier" />
<!--
<list name="targetFlow" type="Flow" label="label.target-flows" />
<list name="sourceFlow" type="Flow" label="label.source-flows" />
Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java?view=diff&pathrev=18540&r1=18539&r2=18540
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java 2010-07-21 05:02:15-0700
@@ -430,6 +430,13 @@
"label.operation.navigate.tooltip"),
combo);
}
+ } else if ("classifier".equals(prop.getName())) {
+ final UMLComboBoxModel model =
+ new UMLComponentInstanceClassifierComboBoxModel(propertyName, target);
+ UMLComboBox combo = new UMLComboBox(model);
+ comp = new UMLComboBoxNavigator(Translator.localize(
+ "label.component-instance.navigate.tooltip"),
+ combo);
} else if ("representedClassifier".equals(prop.getName())) {
final UMLComboBoxModel model =
new UMLCollaborationRepresentedClassifierComboBoxModel(propertyName, target);
Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCollaborationRepresentedClassifierComboBoxModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCollaborationRepresentedClassifierComboBoxModel.java?view=diff&pathrev=18540&r1=18539&r2=18540
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCollaborationRepresentedClassifierComboBoxModel.java (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCollaborationRepresentedClassifierComboBoxModel.java 2010-07-21 05:02:15-0700
@@ -67,7 +67,7 @@
final String propertyName,
final Object target) {
super(propertyName, true);
- setTarget(propertyName);
+ setTarget(target);
}
/*
Added: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComponentInstanceClassifierComboBoxModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComponentInstanceClassifierComboBoxModel.java?view=markup&pathrev=18540
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComponentInstanceClassifierComboBoxModel.java 2010-07-21 05:02:15-0700
@@ -0,0 +1,122 @@
+/* $Id: $
+ *****************************************************************************
+ * Copyright (c) 2009 Contributors - see below
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bob Tarling
+ *****************************************************************************
+ */
+
+package org.argouml.core.propertypanels.ui;
+
+import java.awt.event.ActionEvent;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.swing.Action;
+
+import org.apache.log4j.Logger;
+import org.argouml.application.helpers.ResourceLoaderWrapper;
+import org.argouml.i18n.Translator;
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
+import org.argouml.profile.Profile;
+import org.argouml.profile.ProfileException;
+import org.argouml.ui.UndoableAction;
+
+class UMLComponentInstanceClassifierComboBoxModel
+ extends UMLComboBoxModel {
+
+ private static final Logger LOG =
+ Logger.getLogger("UMLComponentInstanceClassifierComboBoxModel");
+
+ public UMLComponentInstanceClassifierComboBoxModel(
+ final String propertyName,
+ final Object target) {
+ super(propertyName, true);
+ setTarget(target);
+ }
+
+ /*
+ * @see org.argouml.uml.ui.UMLModelElementListModel#buildModelList()
+ */
+ protected void buildModelList() {
+ List list = new ArrayList();
+
+ // Get all classifiers in our model
+ // TODO: We need the property panels to have some reference to the
+ // project they belong to instead of using deprecated functionality
+ Project p = ProjectManager.getManager().getCurrentProject();
+ Object model = p.getRoot();
+ list.addAll(Model.getModelManagementHelper()
+ .getAllModelElementsOfKindWithModel(model, Model.getMetaTypes().getComponent()));
+
+ // Get all classifiers in all top level packages of all profiles
+ for (Profile profile : p.getProfileConfiguration().getProfiles()) {
+ try {
+ for (Object topPackage : profile.getProfilePackages()) {
+ list.addAll(Model.getModelManagementHelper()
+ .getAllModelElementsOfKindWithModel(topPackage,
+ Model.getMetaTypes().getComponent()));
+ }
+ } catch (ProfileException e) {
+ // TODO: We need to rethrow this as some other exception
+ // type but that is too much change for the moment.
+ LOG.error("Exception", e);
+ }
+ }
+ setElements(list);
+ }
+
+ /*
+ * @see org.argouml.uml.ui.UMLComboBoxModel#isValidElement(Object)
+ */
+ protected boolean isValidElement(Object element) {
+ return Model.getFacade().isAClassifier(element)
+ && Model.getFacade().getRepresentedClassifier(getTarget())
+ == element;
+ }
+
+ /*
+ * @see org.argouml.uml.ui.UMLComboBoxModel#getSelectedModelElement()
+ */
+ protected Object getSelectedModelElement() {
+ Collection list = Model.getFacade().getClassifiers(getTarget());
+ if (list.size() == 0) {
+ return null;
+ }
+ return list.iterator().next();
+ }
+
+ public Action getAction() {
+ return new ActionSet();
+ }
+
+ private class ActionSet extends UndoableAction {
+
+ ActionSet() {
+ super(Translator.localize("action.set"),
+ ResourceLoaderWrapper.lookupIcon("action.set"));
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ super.actionPerformed(e);
+ UMLComboBox source = (UMLComboBox) e.getSource();
+ Object target = source.getTarget();
+ Object newValue = source.getSelectedItem();
+ List classifiers = new ArrayList(1);
+ if (Model.getFacade().isAClassifier(newValue)) {
+ classifiers.add(newValue);
+ }
+ Model.getCommonBehaviorHelper().setClassifiers(getTarget(), classifiers);
+ }
+
+ }
+}
+
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2636339
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.