diff options
author | Gabriel Pascual | 2014-11-13 14:45:35 +0000 |
---|---|---|
committer | Gabriel Pascual | 2014-12-08 16:04:09 +0000 |
commit | 3d412a3f84cd2ac61c3373c0cdc8f1be20f7b0f2 (patch) | |
tree | 9d440f95876b774c925f5d4eb306777d76c3eadc | |
parent | e2b80898f487aadb8b4c1b0894d39d787b78f842 (diff) | |
download | org.eclipse.papyrus-3d412a3f84cd2ac61c3373c0cdc8f1be20f7b0f2.tar.gz org.eclipse.papyrus-3d412a3f84cd2ac61c3373c0cdc8f1be20f7b0f2.tar.xz org.eclipse.papyrus-3d412a3f84cd2ac61c3373c0cdc8f1be20f7b0f2.zip |
418647: Location of package imported models should be shown
https://bugs.eclipse.org/bugs/show_bug.cgi?id=418647
- Create a constraint for Imported Package
- Add field in UML Tab to display location of Imported Package
Change-Id: I88687f7973e700976e521b1721d16b12f42e4782
Signed-off-by: Gabriel Pascual <gabriel.pascual@all4tec.net>
6 files changed, 238 insertions, 26 deletions
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/Environment.xmi b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/Environment.xmi index d45cbee8f68..ccbc376ed66 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/Environment.xmi +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/Environment.xmi @@ -42,6 +42,9 @@ <modelElementFactories name="Profile definitions" factoryClass="org.eclipse.papyrus.uml.properties.modelelement.ProfileDefinitionModelElementFactory"/> + <modelElementFactories + name="Imported Package Model Element Factory" + factoryClass="org.eclipse.papyrus.uml.properties.modelelement.ImportedPackageModelElementFactory"/> <propertyEditorTypes label="ExpressionEditor" widgetClass="ExpressionEditor" diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/UML.ctx b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/UML.ctx index b5ecd07ba1e..47cab776327 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/UML.ctx +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/UML.ctx @@ -5317,4 +5317,10 @@ </elements> <modelElementFactory href="ppe:/environment/org.eclipse.papyrus.views.properties/model/Environment.xmi#//@modelElementFactories.1"/> </dataContexts> + <dataContexts name="ImportedPackage" label="Imported Package"> + <elements name="Package"> + <properties name="location" label="Location" description="The location of imported package"/> + </elements> + <modelElementFactory href="ppe:/environment/org.eclipse.papyrus.uml.properties/Model/Environment.xmi#//@modelElementFactories.9"/> + </dataContexts> </contexts:Context> diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SinglePackage.xwt b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SinglePackage.xwt index 7284b4b36e2..aed2a6e5550 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SinglePackage.xwt +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SinglePackage.xwt @@ -1,27 +1,35 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<Composite xmlns:ppel="clr-namespace:org.eclipse.papyrus.views.properties.widgets.layout"
- xmlns="http://www.eclipse.org/xwt/presentation" xmlns:ppe="clr-namespace:org.eclipse.papyrus.views.properties.widgets"
- xmlns:x="http://www.eclipse.org/xwt" xmlns:j="clr-namespace:java.lang">
- <Composite.layout>
- <ppel:PropertiesLayout></ppel:PropertiesLayout>
- </Composite.layout>
- <Composite>
- <Composite.layout>
- <ppel:PropertiesLayout></ppel:PropertiesLayout>
- </Composite.layout>
- <ppe:StringEditor input="{Binding}" property="UML:NamedElement:name"></ppe:StringEditor>
- </Composite>
- <Composite>
- <Composite.layout>
- <ppel:PropertiesLayout></ppel:PropertiesLayout>
- </Composite.layout>
- <ppe:EnumCombo input="{Binding}" property="UML:NamedElement:visibility"></ppe:EnumCombo>
- </Composite>
- <Composite>
- <Composite.layout>
- <ppel:PropertiesLayout></ppel:PropertiesLayout>
- </Composite.layout>
- <ppe:MultiReference input="{Binding}"
- property="UML:Package:packageMerge"></ppe:MultiReference>
- </Composite>
+<?xml version="1.0" encoding="UTF-8"?> +<Composite xmlns:ppe="clr-namespace:org.eclipse.papyrus.views.properties.widgets" + xmlns="http://www.eclipse.org/xwt/presentation" xmlns:j="clr-namespace:java.lang" + xmlns:x="http://www.eclipse.org/xwt" + xmlns:ppel="clr-namespace:org.eclipse.papyrus.views.properties.widgets.layout"> + <Composite.layout> + <ppel:PropertiesLayout></ppel:PropertiesLayout> + </Composite.layout> + <Composite> + <Composite.layout> + <ppel:PropertiesLayout></ppel:PropertiesLayout> + </Composite.layout> + <ppe:StringEditor input="{Binding}" property="UML:NamedElement:name"></ppe:StringEditor> + </Composite> + <Composite> + <Composite.layout> + <ppel:PropertiesLayout></ppel:PropertiesLayout> + </Composite.layout> + <ppe:EnumCombo input="{Binding}" property="UML:NamedElement:visibility"></ppe:EnumCombo> + </Composite> + <Composite> + <Composite.layout> + <ppel:PropertiesLayout></ppel:PropertiesLayout> + </Composite.layout> + <ppe:MultiReference input="{Binding}" + property="UML:Package:packageMerge"></ppe:MultiReference> + </Composite> + <Composite> + <Composite.layout> + <ppel:PropertiesLayout></ppel:PropertiesLayout> + </Composite.layout> + <ppe:StringEditor input="{Binding}" + property="ImportedPackage:Package:location" readOnly="true"></ppe:StringEditor> + </Composite> </Composite>
\ No newline at end of file diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ImportedPackageLocationObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ImportedPackageLocationObservableValue.java new file mode 100644 index 00000000000..62590a52b2e --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ImportedPackageLocationObservableValue.java @@ -0,0 +1,75 @@ +/***************************************************************************** + * Copyright (c) 2014 CEA LIST. + * + * 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: + * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Initial API and implementation + *****************************************************************************/ + +package org.eclipse.papyrus.uml.properties.databinding; + +import org.eclipse.core.databinding.observable.value.AbstractObservableValue; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.uml2.uml.Package; + +/** + * Observable value of Imported Package's location. + * + * @author Gabriel Pascual + * + */ +public class ImportedPackageLocationObservableValue extends AbstractObservableValue { + + /** The Constant UNKNOWN_LOCATION. */ + private static final String UNKNOWN_LOCATION = "Unknown"; + + /** The imported package. */ + private Package importedPackage = null; + + + /** + * Instantiates a new imported package location. + * + * @param source + * the source + */ + public ImportedPackageLocationObservableValue(Package source) { + super(); + importedPackage = source; + } + + /** + * @see org.eclipse.core.databinding.observable.value.IObservableValue#getValueType() + * + * @return + */ + public Object getValueType() { + return String.class; + } + + /** + * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doGetValue() + * + * @return + */ + @Override + protected Object doGetValue() { + String location = UNKNOWN_LOCATION; + + if (importedPackage.eIsProxy()) { + location = EcoreUtil.getURI(importedPackage).trimFragment().toString(); + } else if (importedPackage.eResource() != null) { + URI uri = importedPackage.eResource().getURI(); + if (uri != null) { + location = uri.toString(); + } + } + return location; + } + +} diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ImportedPackageModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ImportedPackageModelElement.java new file mode 100644 index 00000000000..d44cbc005d3 --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ImportedPackageModelElement.java @@ -0,0 +1,63 @@ +/***************************************************************************** + * Copyright (c) 2014 CEA LIST. + * + * 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: + * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Initial API and implementation + *****************************************************************************/ + +package org.eclipse.papyrus.uml.properties.modelelement; + +import org.eclipse.core.databinding.observable.IObservable; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.uml.properties.databinding.ImportedPackageLocationObservableValue; +import org.eclipse.papyrus.views.properties.modelelement.EMFModelElement; +import org.eclipse.uml2.uml.Package; + +/** + * + * Model element of Imported Package. + * + * @author Gabriel Pascual + * + */ +public class ImportedPackageModelElement extends EMFModelElement { + + /** The Constant LOCATION_PROPERTY_PATH. */ + private final static String LOCATION_PROPERTY_PATH = "location"; //$NON-NLS-1$ + + /** + * Constructor. + * + * @param source + * the source + * @param domain + * the domain + */ + public ImportedPackageModelElement(EObject source, EditingDomain domain) { + super(source, domain); + } + + /** + * @see org.eclipse.papyrus.views.properties.modelelement.EMFModelElement#doGetObservable(java.lang.String) + * + * @param propertyPath + * @return + */ + @Override + protected IObservable doGetObservable(String propertyPath) { + + // Location of Imported Package + if (LOCATION_PROPERTY_PATH.equals(propertyPath)) { + return new ImportedPackageLocationObservableValue((Package) source); + } + + return super.doGetObservable(propertyPath); + } + +} diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ImportedPackageModelElementFactory.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ImportedPackageModelElementFactory.java new file mode 100644 index 00000000000..2777c5bc0ef --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ImportedPackageModelElementFactory.java @@ -0,0 +1,57 @@ +/***************************************************************************** + * Copyright (c) 2014 CEA LIST. + * + * 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: + * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Initial API and implementation + *****************************************************************************/ + +package org.eclipse.papyrus.uml.properties.modelelement; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.uml.tools.utils.UMLUtil; +import org.eclipse.papyrus.views.properties.Activator; +import org.eclipse.papyrus.views.properties.contexts.DataContextElement; +import org.eclipse.papyrus.views.properties.modelelement.EMFModelElementFactory; +import org.eclipse.uml2.uml.Element; + + +/** + * A factory for creating ImportedPackageModelElement objects. + * + * @author Gabriel Pascual + */ +public class ImportedPackageModelElementFactory extends EMFModelElementFactory { + + + /** The Constant RESOLUTION_WARNING_MESSAGE. */ + private static final String RESOLUTION_WARNING_MESSAGE = "Unable to resolve the selected element to a UML Element"; + + /** + * Do create from source. + * + * @param source + * the source + * @param context + * the context + * @return the imported package model element + * @see org.eclipse.papyrus.views.properties.modelelement.EMFModelElementFactory#doCreateFromSource(java.lang.Object, org.eclipse.papyrus.views.properties.contexts.DataContextElement) + */ + @Override + protected ImportedPackageModelElement doCreateFromSource(Object source, DataContextElement context) { + Element umlSource = UMLUtil.resolveUMLElement(source); + if (umlSource == null) { + Activator.log.warn(RESOLUTION_WARNING_MESSAGE); + return null; + } + + EditingDomain domain = EMFHelper.resolveEditingDomain(umlSource); + return new ImportedPackageModelElement(umlSource, domain); + } + +} |