Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStéphane Bégaudeau2016-12-16 13:43:31 +0000
committerStéphane Bégaudeau2017-02-03 14:03:12 +0000
commitc192881b5e7654971d196debce016842c9306e55 (patch)
tree157595a3f2609cc1938c11843f26d68c19c50016
parentea65ce00ed1511232566732be12e526596b8cd8b (diff)
downloadorg.eclipse.sirius-c192881b5e7654971d196debce016842c9306e55.tar.gz
org.eclipse.sirius-c192881b5e7654971d196debce016842c9306e55.tar.xz
org.eclipse.sirius-c192881b5e7654971d196debce016842c9306e55.zip
[505766] Improve the edition of the EPackages of the Properties View
1) I have refactored the existing code to edit the metamodels of the various representations in order to use it for the Properties view 2) The edition of the metamodels of the Properties view will now be realized in the "Metamodels" tab just like for the representations. Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=505766 Change-Id: Ic4d5518ee0ff3e6563583c18fdeb66aaf552c6aa Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.html36
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile8
-rw-r--r--plugins/org.eclipse.sirius.editor.properties/plugin.xml4
-rw-r--r--plugins/org.eclipse.sirius.editor.properties/src/org/eclipse/sirius/properties/editor/properties/sections/properties/viewextensiondescription/ViewExtensionDescriptionMetamodelsPropertySectionSpec.java29
-rw-r--r--plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AbstractMetamodelPropertySectionSpec.java311
-rw-r--r--plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AddFromFilesystemButtonListener.java34
-rw-r--r--plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AddFromRegistryButtonListener.java34
-rw-r--r--plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AddFromWorkspaceButtonListener.java34
-rw-r--r--plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/DescriptionMetamodelsUpdater.java (renamed from plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/RepresentationDescriptionMetamodelsUpdater.java)58
-rw-r--r--plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/RemoveMetamodelsSelectionButtonListener.java36
-rw-r--r--plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/RepresentationDescriptionMetamodelPropertySectionSpec.java294
-rw-r--r--plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationextensiondescription/RepresentationExtensionDescriptionMetamodelPropertySectionSpec.java15
-rw-r--r--plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationextensiondescription/RepresentationExtensionDescriptionMetamodelsUpdater.java15
13 files changed, 493 insertions, 415 deletions
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
index c2a6bcd65c..648cde2419 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
@@ -16,6 +16,9 @@
<a href="#sirius5.0.0">Changes in Sirius 5.0.0</a>
<ol style="list-style: disc;">
<li>
+ <a href="#SpecifierVisibleChanges">Specifier-Visible Changes</a>
+ </li>
+ <li>
<a href="#DeveloperVisibleChanges">Developer-Visible Changes</a>
</li>
</ol>
@@ -49,7 +52,7 @@
<a href="#UserVisibleChanges3">User-Visible Changes</a>
</li>
<li>
- <a href="#SpecifierVisibleChanges">Specifier-Visible Changes</a>
+ <a href="#SpecifierVisibleChanges2">Specifier-Visible Changes</a>
</li>
<li>
<a href="#DeveloperVisibleChanges4">Developer-Visible Changes</a>
@@ -63,7 +66,7 @@
<a href="#UserVisibleChanges4">User-Visible Changes</a>
</li>
<li>
- <a href="#SpecifierVisibleChanges2">Specifier-Visible Changes</a>
+ <a href="#SpecifierVisibleChanges3">Specifier-Visible Changes</a>
</li>
<li>
<a href="#DeveloperVisibleChanges5">Developer-Visible Changes</a>
@@ -77,7 +80,7 @@
<a href="#UserVisibleChanges5">User-Visible Changes</a>
</li>
<li>
- <a href="#SpecifierVisibleChanges3">Specifier-Visible Changes</a>
+ <a href="#SpecifierVisibleChanges4">Specifier-Visible Changes</a>
</li>
<li>
<a href="#DeveloperVisibleChanges6">Developer-Visible Changes</a>
@@ -91,7 +94,7 @@
<a href="#UserVisibleChanges6">User-Visible Changes</a>
</li>
<li>
- <a href="#SpecifierVisibleChanges4">Specifier-Visible Changes</a>
+ <a href="#SpecifierVisibleChanges5">Specifier-Visible Changes</a>
</li>
<li>
<a href="#DeveloperVisibleChanges7">Developer-Visible Changes</a>
@@ -105,6 +108,10 @@
<a href="Release_Notes_Previous.html">the release notes from previous versions</a> for details about older releases.
</p>
<h2 id="sirius5.0.0">Changes in Sirius 5.0.0</h2>
+ <h3 id="SpecifierVisibleChanges">Specifier-Visible Changes</h3>
+ <ul>
+ <li><span class="label label-info">Modified</span> The tab used to configure the metamodels used by the Properties view description is now using the same interface as the metamodels tab used to configure the representations.</li>
+ </ul>
<h3 id="DeveloperVisibleChanges">Developer-Visible Changes</h3>
<h4 id="Changesinorg.eclipse.sirius.tests.junit.support">Changes in
<code>org.eclipse.sirius.tests.junit.support</code>
@@ -152,6 +159,19 @@ bot.waitUntil(new ICondition() {
SWTBotUtils.waitAllUiEvents();
</pre>
+ <h4 id="Changesinorg.eclipse.sirius.editor.properties">Changes in
+ <code>org.eclipse.sirius.editor.properties</code>
+ </h4>
+ <ul>
+ <li><span class="label label-info">Modified</span> In the package
+ <code>org.eclipse.sirius.editor.properties.sections.description.representationdescription</code> the class
+ <code>RepresentationDescriptionMetamodelsUpdater</code> has been replaced by
+ <code>DescriptionMetamodelsUpdater</code> which can now be used with any EObject with a many-valued EReference to EPackages. The behavior of the class
+ <code>RepresentationDescriptionMetamodelPropertySectionSpec</code> has been transfered to an abstract class independent of
+ <code>RepresentationDescription</code> named
+ <code>AbstractMetamodelPropertySectionSpec</code>. Those classes are now used for the edition of the metamodels of both the Properties view description and the various representations.
+ </li>
+ </ul>
<h2 id="sirius4.1.2">Changes in Sirius 4.1.2</h2>
<h3 id="UserVisibleChanges">User-Visible Changes</h3>
<ul>
@@ -268,7 +288,7 @@ SWTBotUtils.waitAllUiEvents();
<em>Ctrl+HOME</em>.
</li>
</ul>
- <h3 id="SpecifierVisibleChanges">Specifier-Visible Changes</h3>
+ <h3 id="SpecifierVisibleChanges2">Specifier-Visible Changes</h3>
<ul>
<li><span class="label label-success">Added</span> It is now possible to inline a copy of the default Properties Views model inside the VSM. This is a copy of the model Sirius would use if no
<em>Properties View Description</em> was specified. It can be used as a starting point for manual customization, or as a complement for elements for which you do not provide any custom rules.
@@ -742,7 +762,7 @@ SWTBotUtils.waitAllUiEvents();
<code>Apply Appearance Properties</code> action has been modified to use the last selected element as base style instead of the first one.
</li>
</ul>
- <h3 id="SpecifierVisibleChanges2">Specifier-Visible Changes</h3>
+ <h3 id="SpecifierVisibleChanges3">Specifier-Visible Changes</h3>
<ul>
<li><span class="label label-success">Added</span> Sirius 4.0 introduces
<strong>experimental</strong> support for specifying the properties views of your modelers directly from inside the VSM. This feature uses the same dynamic approach as for specifying diagrams, tables and trees, with a very flexible configuration language and no code generation involved (including live preview of any change). As of Sirius 4.0, this feature should be considered in an experimental state with details subject to changes until Sirius 4.1, and is not installed by default. To install it, make sure either
@@ -1243,7 +1263,7 @@ SWTBotUtils.waitAllUiEvents();
<em>Arrange Linked Border Nodes</em> as it is border nodes which are layouted and not bordered nodes.
</li>
</ul>
- <h3 id="SpecifierVisibleChanges3">Specifier-Visible Changes</h3>
+ <h3 id="SpecifierVisibleChanges4">Specifier-Visible Changes</h3>
<ul>
<li><span class="label label-info">Modified</span> The
<em>Acceleo Query Language</em> (AQL) interpreter has been improved. AQL, and its support in Sirius, is no longer considered experimental, and instead is now the recommended query language to use for new VSMs. Improvements mostly concern better completion and validation, and more precise error reporting. In particular AQL expressions will now be able to display warnings and errors in the Interpreter view. The message displayed in the Interpreter view after an evaluation has also been improved to display the qualified name of the type of the value computed (
@@ -1773,7 +1793,7 @@ SWTBotUtils.waitAllUiEvents();
<em>Viewpoint Selection</em> dialog and wizard page, the &#8220;plug-in&#8221; decorator for viewpoints loaded from plug-ins is removed, and a &#8220;Folder&#8221; decorator for viewpoints loaded from the current workspace has been added. This makes the icons more visible in the most common where viewpoints come from installed plug-ins.
</li>
</ul>
- <h3 id="SpecifierVisibleChanges4">Specifier-Visible Changes</h3>
+ <h3 id="SpecifierVisibleChanges5">Specifier-Visible Changes</h3>
<ul>
<li><span class="label label-success">Added</span> <span class="label label-info">Experimental</span> Optional support for the experimental
<em>Acceleo Query Language</em> (AQL) has been added to write interpreted expressions. It is provided by the
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
index 2a88c248c3..37e8ea79e5 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
@@ -6,6 +6,10 @@ This document contains the release notes for recent major releases of Sirius. Se
h2(#sirius5.0.0). Changes in Sirius 5.0.0
+h3. Specifier-Visible Changes
+
+* <span class="label label-info">Modified</span> The tab used to configure the metamodels used by the Properties view description is now using the same interface as the metamodels tab used to configure the representations.
+
h3. Developer-Visible Changes
h4. Changes in @org.eclipse.sirius.tests.junit.support@
@@ -39,6 +43,10 @@ bot.waitUntil(new ICondition() {
// are not really redrawn and the rest of the test is not reliable.
SWTBotUtils.waitAllUiEvents();
+h4. Changes in @org.eclipse.sirius.editor.properties@
+
+* <span class="label label-info">Modified</span> In the package @org.eclipse.sirius.editor.properties.sections.description.representationdescription@ the class @RepresentationDescriptionMetamodelsUpdater@ has been replaced by @DescriptionMetamodelsUpdater@ which can now be used with any EObject with a many-valued EReference to EPackages. The behavior of the class @RepresentationDescriptionMetamodelPropertySectionSpec@ has been transfered to an abstract class independent of @RepresentationDescription@ named @AbstractMetamodelPropertySectionSpec@. Those classes are now used for the edition of the metamodels of both the Properties view description and the various representations.
+
h2(#sirius4.1.2). Changes in Sirius 4.1.2
h3. User-Visible Changes
diff --git a/plugins/org.eclipse.sirius.editor.properties/plugin.xml b/plugins/org.eclipse.sirius.editor.properties/plugin.xml
index 0c618f7ad2..0625058aa6 100644
--- a/plugins/org.eclipse.sirius.editor.properties/plugin.xml
+++ b/plugins/org.eclipse.sirius.editor.properties/plugin.xml
@@ -550,11 +550,11 @@
<input type="org.eclipse.sirius.properties.PageDescription"/>
</propertySection>
<propertySection
- class="org.eclipse.sirius.properties.editor.properties.sections.properties.viewextensiondescription.ViewExtensionDescriptionMetamodelsPropertySection"
+ class="org.eclipse.sirius.properties.editor.properties.sections.properties.viewextensiondescription.ViewExtensionDescriptionMetamodelsPropertySectionSpec"
id="properties.section.viewExtensionDescription.Metamodels"
filter="org.eclipse.sirius.properties.editor.properties.filters.properties.viewextensiondescription.ViewExtensionDescriptionMetamodelsFilter"
afterSection="properties.section.viewExtensionDescription.Identifier"
- tab="viewpoint.tab.general">
+ tab="viewpoint.tab.metamodels">
<input type="org.eclipse.sirius.properties.ViewExtensionDescription"/>
</propertySection>
<propertySection
diff --git a/plugins/org.eclipse.sirius.editor.properties/src/org/eclipse/sirius/properties/editor/properties/sections/properties/viewextensiondescription/ViewExtensionDescriptionMetamodelsPropertySectionSpec.java b/plugins/org.eclipse.sirius.editor.properties/src/org/eclipse/sirius/properties/editor/properties/sections/properties/viewextensiondescription/ViewExtensionDescriptionMetamodelsPropertySectionSpec.java
new file mode 100644
index 0000000000..619d7ee83e
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.properties/src/org/eclipse/sirius/properties/editor/properties/sections/properties/viewextensiondescription/ViewExtensionDescriptionMetamodelsPropertySectionSpec.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.properties.editor.properties.sections.properties.viewextensiondescription;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.sirius.editor.properties.sections.description.representationdescription.AbstractMetamodelPropertySectionSpec;
+import org.eclipse.sirius.properties.PropertiesPackage;
+
+/**
+ * An {@link AbstractMetamodelPropertySectionSpec} for the metamodels tab of the
+ * properties view description.
+ *
+ * @author sbegaudeau
+ */
+public class ViewExtensionDescriptionMetamodelsPropertySectionSpec extends AbstractMetamodelPropertySectionSpec {
+
+ @Override
+ protected EStructuralFeature getFeature() {
+ return PropertiesPackage.eINSTANCE.getViewExtensionDescription_Metamodels();
+ }
+
+}
diff --git a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AbstractMetamodelPropertySectionSpec.java b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AbstractMetamodelPropertySectionSpec.java
new file mode 100644
index 0000000000..4e34a42327
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AbstractMetamodelPropertySectionSpec.java
@@ -0,0 +1,311 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.editor.properties.sections.description.representationdescription;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.sirius.editor.editorPlugin.SiriusEditorPlugin;
+import org.eclipse.sirius.editor.properties.ViewpointPropertySheetPage;
+import org.eclipse.sirius.editor.properties.sections.common.AbstractViewpointPropertySection;
+import org.eclipse.sirius.viewpoint.description.RepresentationDescription;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+
+/**
+ * Common superclass of all the metamodel property sections.
+ *
+ * @author sbegaudeau
+ */
+public abstract class AbstractMetamodelPropertySectionSpec extends AbstractViewpointPropertySection {
+
+ private CLabel help;
+
+ /** Main composite **/
+ protected Composite composite;
+
+ protected Label listHeader;
+
+ protected Table metamodelsTable;
+
+ protected Button addFromRegistryButton;
+
+ protected Button addFromWorkspaceButton;
+
+ protected Button addFromFilesystemButton;
+
+ protected Button removeMetamodelsSelectionButton;
+
+ protected DescriptionMetamodelsUpdater descriptionMetamodelsUpdater;
+
+ @Override
+ protected void makeReadonly() {
+ metamodelsTable.setEnabled(false);
+ addFromRegistryButton.setEnabled(false);
+ addFromWorkspaceButton.setEnabled(false);
+ addFromFilesystemButton.setEnabled(false);
+ removeMetamodelsSelectionButton.setEnabled(false);
+ }
+
+ @Override
+ protected void makeWrittable() {
+ metamodelsTable.setEnabled(true);
+ addFromRegistryButton.setEnabled(true);
+ addFromWorkspaceButton.setEnabled(true);
+ addFromFilesystemButton.setEnabled(true);
+ }
+
+ @Override
+ public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ super.createControls(parent, aTabbedPropertySheetPage);
+
+ if (aTabbedPropertySheetPage instanceof ViewpointPropertySheetPage)
+ super.createControls(parent, (ViewpointPropertySheetPage) aTabbedPropertySheetPage);
+ else
+ super.createControls(parent, aTabbedPropertySheetPage);
+ composite = getWidgetFactory().createFlatFormComposite(parent);
+
+ help = getWidgetFactory().createCLabel(composite, "");
+ help.setImage(getHelpIcon());
+ help.setToolTipText("Select the Metamodels (EPackage) which must be used in the current description");
+
+ listHeader = getWidgetFactory().createLabel(composite, "Selected Metamodels : ");
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 25);
+ data.right = new FormAttachment(100, 0);
+ data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
+ listHeader.setLayoutData(data);
+
+ // CHECKSTYLE:OFF
+ int style = SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL;
+ // CHECKSTYLE:ON
+ metamodelsTable = getWidgetFactory().createTable(composite, style);
+ metamodelsTable.setLinesVisible(true);
+ metamodelsTable.setHeaderVisible(true);
+ TableColumn ePackageNameColumn = new TableColumn(metamodelsTable, SWT.NONE);
+ ePackageNameColumn.setText("Name");
+ TableColumn ePackageNSURIColumn = new TableColumn(metamodelsTable, SWT.NONE);
+ ePackageNSURIColumn.setText("nsURI");
+ TableColumn ecoreResourceURIColumn = new TableColumn(metamodelsTable, SWT.NONE);
+ ecoreResourceURIColumn.setText("metamodel URI");
+ data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(80, 0);
+ data.top = new FormAttachment(listHeader, 0, ITabbedPropertyConstants.VSPACE);
+ data.height = 120;
+ data.width = 200;
+ metamodelsTable.setLayoutData(data);
+
+ addButtons();
+ }
+
+ protected void addButtons() {
+ EStructuralFeature eStructuralFeature = this.getFeature();
+ if (eStructuralFeature instanceof EReference) {
+ this.descriptionMetamodelsUpdater = new DescriptionMetamodelsUpdater(eObject, (EReference) eStructuralFeature);
+ }
+
+ addFromRegistryButton = getWidgetFactory().createButton(composite, "Add from registry", SWT.PUSH);
+ addFromRegistryButton.addSelectionListener(new AddFromRegistryButtonListener(this, descriptionMetamodelsUpdater));
+ FormData data = new FormData();
+ data.top = new FormAttachment(listHeader, 0, SWT.RIGHT);
+ data.left = new FormAttachment(metamodelsTable, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
+ data.right = new FormAttachment(100);
+ data.width = 60;
+ addFromRegistryButton.setLayoutData(data);
+
+ addFromWorkspaceButton = getWidgetFactory().createButton(composite, "Add from workspace", SWT.PUSH);
+ addFromWorkspaceButton.addSelectionListener(new AddFromWorkspaceButtonListener(this, descriptionMetamodelsUpdater));
+ data = new FormData();
+ data.top = new FormAttachment(addFromRegistryButton, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
+ data.left = new FormAttachment(metamodelsTable, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
+ data.right = new FormAttachment(100);
+ data.width = 60;
+ addFromWorkspaceButton.setLayoutData(data);
+
+ addFromFilesystemButton = getWidgetFactory().createButton(composite, "Add from filesystem", SWT.PUSH);
+ addFromFilesystemButton.addSelectionListener(new AddFromFilesystemButtonListener(this, descriptionMetamodelsUpdater));
+ data = new FormData();
+ data.top = new FormAttachment(addFromWorkspaceButton, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
+ data.left = new FormAttachment(metamodelsTable, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
+ data.right = new FormAttachment(100);
+ data.width = 60;
+ addFromFilesystemButton.setLayoutData(data);
+
+ removeMetamodelsSelectionButton = getWidgetFactory().createButton(composite, "Remove", SWT.PUSH);
+ removeMetamodelsSelectionButton.addSelectionListener(new RemoveMetamodelsSelectionButtonListener(this, removeMetamodelsSelectionButton, metamodelsTable, descriptionMetamodelsUpdater));
+ removeMetamodelsSelectionButton.setEnabled(false);
+ data = new FormData();
+ data.top = new FormAttachment(addFromFilesystemButton, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
+ data.left = new FormAttachment(metamodelsTable, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
+ data.right = new FormAttachment(100);
+ data.width = 60;
+ removeMetamodelsSelectionButton.setLayoutData(data);
+ }
+
+ @Override
+ public void refresh() {
+ descriptionMetamodelsUpdater.setDescription(eObject);
+ List<EPackage> ePackages = getValue();
+ if (ePackages != null) {
+ List<EPackage> previousEPackages = getEPackages(metamodelsTable.getItems());
+ int previousSelectionIndex = metamodelsTable.getSelectionIndex();
+ metamodelsTable.removeAll();
+ List<TableItem> newItems = new ArrayList<TableItem>();
+ for (EPackage ePackage : ePackages) {
+ TableItem item = new TableItem(metamodelsTable, 0);
+ item.setData(ePackage);
+ if (ePackage.eResource() != null) {
+ String ePackageName = ePackage.getName();
+ if (ePackageName == null) {
+ ePackageName = "null";
+ }
+ item.setText(0, ePackageName);
+ String ePackageNSURI = ePackage.getNsURI();
+ if (ePackageNSURI == null) {
+ ePackageNSURI = "null";
+ }
+ item.setText(1, ePackageNSURI);
+ String ePackageURI = null;
+ URI completeURIToEPackage = descriptionMetamodelsUpdater.getCompleteURIToEPackage(ePackage);
+ if (completeURIToEPackage != null) {
+ ePackageURI = URI.decode(completeURIToEPackage.toString());
+ } else {
+ URI genModelResourceURI = EcorePlugin.getEPackageNsURIToGenModelLocationMap().get(ePackage.getNsURI());
+ if (genModelResourceURI != null) {
+ ePackageURI = genModelResourceURI.trimFileExtension().appendFileExtension("ecore").toString();
+ }
+ }
+ if (ePackageURI == null) {
+ ePackageURI = "unknow metamodel resource URI";
+ }
+ item.setText(2, ePackageURI);
+ if (!previousEPackages.contains(ePackage)) {
+ newItems.add(item);
+ }
+ } else {
+ URI proxyURI = ((InternalEObject) ePackage).eProxyURI();
+ String ePackageName = proxyURI.lastSegment().substring(0, proxyURI.lastSegment().indexOf('.'));
+ item.setText(0, ePackageName);
+ item.setText(1, "null");
+ String ePackageURI = proxyURI.trimFragment().toString();
+ item.setText(2, ePackageURI);
+ // Adding decorator
+ FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
+ Image img = fieldDecoration.getImage();
+ item.setImage(img);
+ // Log an error in the "Error log" view.
+ SiriusEditorPlugin.getPlugin().getLog().log(new Status(IStatus.ERROR, SiriusEditorPlugin.PLUGIN_ID, "Invalid ressource access for the metamodel " + ePackageURI));
+ }
+ }
+ if (!newItems.isEmpty()) {
+ metamodelsTable.setSelection(newItems.toArray(new TableItem[0]));
+ removeMetamodelsSelectionButton.setEnabled(true);
+ } else {
+ metamodelsTable.select(previousSelectionIndex - 1);
+ }
+ }
+ if (metamodelsTable.getSelectionCount() == 0) {
+ removeMetamodelsSelectionButton.setEnabled(false);
+ }
+ metamodelsTable.getColumn(0).pack();
+ metamodelsTable.getColumn(1).pack();
+ metamodelsTable.getColumn(2).pack();
+ }
+
+ /**
+ * Get the current {@link EditingDomain}.
+ *
+ * @return the current {@link EditingDomain}
+ */
+ public EditingDomain getEditingDomain() {
+ EditingDomain editingDomain = null;
+ if (getPart() instanceof IEditingDomainProvider) {
+ editingDomain = ((IEditingDomainProvider) getPart()).getEditingDomain();
+ }
+ return editingDomain;
+ }
+
+ /**
+ * Get the list a {@link EPackage}s associated to the specified array of
+ * {@link TableItem}.
+ *
+ * @param selection
+ * array of {@link TableItem}
+ * @return list a {@link EPackage}s associated
+ */
+ public List<EPackage> getEPackages(TableItem[] selection) {
+ List<EPackage> ePackages = new ArrayList<EPackage>();
+ for (TableItem item : selection) {
+ if (item.getData() instanceof EPackage) {
+ ePackages.add((EPackage) item.getData());
+ }
+ }
+ return ePackages;
+ }
+
+ /**
+ * Get the {@link RepresentationDescription#getMetamodel()} value.
+ *
+ * @return the {@link RepresentationDescription#getMetamodel()} value
+ */
+ @SuppressWarnings("unchecked")
+ protected List<EPackage> getValue() {
+ List<EPackage> ePackages = new ArrayList<EPackage>();
+ Object object = eObject.eGet(getFeature());
+ if (object instanceof List<?>) {
+ java.util.List<?> values = (java.util.List<?>) object;
+ if (!values.isEmpty() && values.get(0) instanceof EPackage) {
+ ePackages = (List<EPackage>) values;
+ }
+ }
+ return ePackages;
+ }
+
+ @Override
+ public void dispose() {
+ if (descriptionMetamodelsUpdater != null) {
+ descriptionMetamodelsUpdater.dispose();
+ descriptionMetamodelsUpdater = null;
+ }
+ removeMetamodelsSelectionButton = null;
+ addFromFilesystemButton = null;
+ addFromWorkspaceButton = null;
+ addFromRegistryButton = null;
+ metamodelsTable = null;
+ listHeader = null;
+ composite = null;
+ help = null;
+ super.dispose();
+ }
+}
diff --git a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AddFromFilesystemButtonListener.java b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AddFromFilesystemButtonListener.java
index b942099c48..016136d6d8 100644
--- a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AddFromFilesystemButtonListener.java
+++ b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AddFromFilesystemButtonListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 THALES GLOBAL SERVICES.
+ * Copyright (c) 2011, 2016 THALES GLOBAL SERVICES.
* 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
@@ -27,25 +27,24 @@ import org.eclipse.swt.widgets.Shell;
*/
public class AddFromFilesystemButtonListener extends SelectionAdapter {
- private RepresentationDescriptionMetamodelPropertySectionSpec representationDescriptionMetamodelsPropertySection;
+ private AbstractMetamodelPropertySectionSpec abstractMetamodelsPropertySection;
- private RepresentationDescriptionMetamodelsUpdater representationDescriptionMetamodelsUpdater;
+ private DescriptionMetamodelsUpdater descriptionMetamodelsUpdater;
/**
* Default constructor.
*
- * @param representationDescriptionMetamodelsPropertySection
- * {@link RepresentationDescriptionMetamodelPropertySectionSpec}
- * which use this listener
+ * @param abstractMetamodelsPropertySection
+ * {@link AbstractMetamodelPropertySectionSpec} which use this
+ * listener
*
- * @param representationDescriptionMetamodelsUpdater
- * the {@link RepresentationDescriptionMetamodelsUpdater} used to
- * update the model
+ * @param descriptionMetamodelsUpdater
+ * the {@link DescriptionMetamodelsUpdater} used to update the
+ * model
*/
- public AddFromFilesystemButtonListener(RepresentationDescriptionMetamodelPropertySectionSpec representationDescriptionMetamodelsPropertySection,
- RepresentationDescriptionMetamodelsUpdater representationDescriptionMetamodelsUpdater) {
- this.representationDescriptionMetamodelsPropertySection = representationDescriptionMetamodelsPropertySection;
- this.representationDescriptionMetamodelsUpdater = representationDescriptionMetamodelsUpdater;
+ public AddFromFilesystemButtonListener(AbstractMetamodelPropertySectionSpec abstractMetamodelsPropertySection, DescriptionMetamodelsUpdater descriptionMetamodelsUpdater) {
+ this.abstractMetamodelsPropertySection = abstractMetamodelsPropertySection;
+ this.descriptionMetamodelsUpdater = descriptionMetamodelsUpdater;
}
/**
@@ -54,8 +53,9 @@ public class AddFromFilesystemButtonListener extends SelectionAdapter {
*
* {@inheritDoc}
*/
+ @Override
public void widgetSelected(SelectionEvent e) {
- Shell shell = representationDescriptionMetamodelsPropertySection.getPart().getSite().getShell();
+ Shell shell = abstractMetamodelsPropertySection.getPart().getSite().getShell();
FileDialog fileDialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
fileDialog.setText("Metamodel resource selection");
@@ -65,9 +65,9 @@ public class AddFromFilesystemButtonListener extends SelectionAdapter {
String filterPath = fileDialog.getFilterPath();
String[] fileNames = fileDialog.getFileNames();
- representationDescriptionMetamodelsUpdater.setEditingDomain(representationDescriptionMetamodelsPropertySection.getEditingDomain());
- List<URI> filesystemEcoreResourceURIs = representationDescriptionMetamodelsUpdater.getURIs(filterPath, fileNames);
- representationDescriptionMetamodelsUpdater.addEPackagesFromEcoreResource(filesystemEcoreResourceURIs);
+ descriptionMetamodelsUpdater.setEditingDomain(abstractMetamodelsPropertySection.getEditingDomain());
+ List<URI> filesystemEcoreResourceURIs = descriptionMetamodelsUpdater.getURIs(filterPath, fileNames);
+ descriptionMetamodelsUpdater.addEPackagesFromEcoreResource(filesystemEcoreResourceURIs);
}
}
diff --git a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AddFromRegistryButtonListener.java b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AddFromRegistryButtonListener.java
index 623929ffd6..7027f3ddb5 100644
--- a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AddFromRegistryButtonListener.java
+++ b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AddFromRegistryButtonListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 THALES GLOBAL SERVICES.
+ * Copyright (c) 2011, 2016 THALES GLOBAL SERVICES.
* 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
@@ -35,25 +35,23 @@ import org.eclipse.ui.PlatformUI;
*/
public class AddFromRegistryButtonListener extends SelectionAdapter {
- private RepresentationDescriptionMetamodelPropertySectionSpec representationDescriptionMetamodelsPropertySection;
+ private AbstractMetamodelPropertySectionSpec abstractMetamodelsPropertySection;
- private RepresentationDescriptionMetamodelsUpdater representationDescriptionMetamodelsUpdater;
+ private DescriptionMetamodelsUpdater descriptionMetamodelsUpdater;
/**
* Default constructor.
*
- * @param representationDescriptionMetamodelsPropertySection
- * {@link RepresentationDescriptionMetamodelPropertySectionSpec}
- * which use this listener
+ * @param abstractMetamodelsPropertySection
+ * {@link AbstractMetamodelPropertySectionSpec} which use this
+ * listener
*
- * @param representationDescriptionMetamodelsUpdater
- * the {@link RepresentationDescriptionMetamodelsUpdater} to
- * update the model
+ * @param descriptionMetamodelsUpdater
+ * the {@link DescriptionMetamodelsUpdater} to update the model
*/
- public AddFromRegistryButtonListener(RepresentationDescriptionMetamodelPropertySectionSpec representationDescriptionMetamodelsPropertySection,
- RepresentationDescriptionMetamodelsUpdater representationDescriptionMetamodelsUpdater) {
- this.representationDescriptionMetamodelsPropertySection = representationDescriptionMetamodelsPropertySection;
- this.representationDescriptionMetamodelsUpdater = representationDescriptionMetamodelsUpdater;
+ public AddFromRegistryButtonListener(AbstractMetamodelPropertySectionSpec abstractMetamodelsPropertySection, DescriptionMetamodelsUpdater descriptionMetamodelsUpdater) {
+ this.abstractMetamodelsPropertySection = abstractMetamodelsPropertySection;
+ this.descriptionMetamodelsUpdater = descriptionMetamodelsUpdater;
}
/**
@@ -62,8 +60,9 @@ public class AddFromRegistryButtonListener extends SelectionAdapter {
*
* {@inheritDoc}
*/
+ @Override
public void widgetSelected(SelectionEvent e) {
- Shell shell = representationDescriptionMetamodelsPropertySection.getPart().getSite().getShell();
+ Shell shell = abstractMetamodelsPropertySection.getPart().getSite().getShell();
RegisteredPackageDialog registeredPackageDialog = new RegisteredPackageDialog(shell);
registeredPackageDialog.setTitle("Metamodel selection");
@@ -75,12 +74,13 @@ public class AddFromRegistryButtonListener extends SelectionAdapter {
IRunnableContext context = new ProgressMonitorDialog(shell);
PlatformUI.getWorkbench().getProgressService().runInUI(context, new IRunnableWithProgress() {
+ @Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Import metamodels from registry", IProgressMonitor.UNKNOWN);
- representationDescriptionMetamodelsUpdater.setEditingDomain(representationDescriptionMetamodelsPropertySection.getEditingDomain());
- List<EPackage> ePackagesFromNsURI = representationDescriptionMetamodelsUpdater.getEPackagesFromNsURI(result);
+ descriptionMetamodelsUpdater.setEditingDomain(abstractMetamodelsPropertySection.getEditingDomain());
+ List<EPackage> ePackagesFromNsURI = descriptionMetamodelsUpdater.getEPackagesFromNsURI(result);
monitor.worked(1);
- representationDescriptionMetamodelsUpdater.addEPackages(ePackagesFromNsURI);
+ descriptionMetamodelsUpdater.addEPackages(ePackagesFromNsURI);
monitor.done();
}
}, null);
diff --git a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AddFromWorkspaceButtonListener.java b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AddFromWorkspaceButtonListener.java
index 5edbf4c499..338ae8528d 100644
--- a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AddFromWorkspaceButtonListener.java
+++ b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/AddFromWorkspaceButtonListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 THALES GLOBAL SERVICES.
+ * Copyright (c) 2011, 2016 THALES GLOBAL SERVICES.
* 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
@@ -29,25 +29,24 @@ import org.eclipse.swt.widgets.Shell;
*/
public class AddFromWorkspaceButtonListener extends SelectionAdapter {
- private RepresentationDescriptionMetamodelPropertySectionSpec representationDescriptionMetamodelsPropertySection;
+ private AbstractMetamodelPropertySectionSpec abstractMetamodelsPropertySection;
- private RepresentationDescriptionMetamodelsUpdater representationDescriptionMetamodelsUpdater;
+ private DescriptionMetamodelsUpdater descriptionMetamodelsUpdater;
/**
* Default constructor.
*
- * @param representationDescriptionMetamodelsPropertySection
- * {@link RepresentationDescriptionMetamodelPropertySectionSpec}
- * which use this listener
+ * @param abstractMetamodelsPropertySection
+ * {@link AbstractMetamodelPropertySectionSpec} which use this
+ * listener
*
- * @param representationDescriptionMetamodelsUpdater
- * the {@link RepresentationDescriptionMetamodelsUpdater} used to
- * update the model
+ * @param descriptionMetamodelsUpdater
+ * the {@link DescriptionMetamodelsUpdater} used to update the
+ * model
*/
- public AddFromWorkspaceButtonListener(RepresentationDescriptionMetamodelPropertySectionSpec representationDescriptionMetamodelsPropertySection,
- RepresentationDescriptionMetamodelsUpdater representationDescriptionMetamodelsUpdater) {
- this.representationDescriptionMetamodelsPropertySection = representationDescriptionMetamodelsPropertySection;
- this.representationDescriptionMetamodelsUpdater = representationDescriptionMetamodelsUpdater;
+ public AddFromWorkspaceButtonListener(AbstractMetamodelPropertySectionSpec abstractMetamodelsPropertySection, DescriptionMetamodelsUpdater descriptionMetamodelsUpdater) {
+ this.abstractMetamodelsPropertySection = abstractMetamodelsPropertySection;
+ this.descriptionMetamodelsUpdater = descriptionMetamodelsUpdater;
}
/**
@@ -56,17 +55,18 @@ public class AddFromWorkspaceButtonListener extends SelectionAdapter {
*
* {@inheritDoc}
*/
+ @Override
public void widgetSelected(SelectionEvent e) {
- Shell shell = representationDescriptionMetamodelsPropertySection.getPart().getSite().getShell();
+ Shell shell = abstractMetamodelsPropertySection.getPart().getSite().getShell();
WorkspaceResourceDialog workspaceResourceDialog = new WorkspaceResourceDialog(shell, SWT.MULTI, "Ecore resource selection", Collections.singletonList("ecore"));
workspaceResourceDialog.open();
List<IResource> selectedEcoreResources = workspaceResourceDialog.getSelectedResources();
if (selectedEcoreResources != null) {
- representationDescriptionMetamodelsUpdater.setEditingDomain(representationDescriptionMetamodelsPropertySection.getEditingDomain());
- List<URI> workspaceEcoreResourceURIs = representationDescriptionMetamodelsUpdater.getURIs(selectedEcoreResources);
- representationDescriptionMetamodelsUpdater.addEPackagesFromEcoreResource(workspaceEcoreResourceURIs);
+ descriptionMetamodelsUpdater.setEditingDomain(abstractMetamodelsPropertySection.getEditingDomain());
+ List<URI> workspaceEcoreResourceURIs = descriptionMetamodelsUpdater.getURIs(selectedEcoreResources);
+ descriptionMetamodelsUpdater.addEPackagesFromEcoreResource(workspaceEcoreResourceURIs);
}
}
diff --git a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/RepresentationDescriptionMetamodelsUpdater.java b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/DescriptionMetamodelsUpdater.java
index 8b753e7ca6..a742714447 100644
--- a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/RepresentationDescriptionMetamodelsUpdater.java
+++ b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/DescriptionMetamodelsUpdater.java
@@ -1,10 +1,9 @@
/*******************************************************************************
- * Copyright (c) 2011 THALES GLOBAL SERVICES.
+ * Copyright (c) 2016 Obeo.
* 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:
* Obeo - initial API and implementation
*******************************************************************************/
@@ -12,6 +11,7 @@ package org.eclipse.sirius.editor.properties.sections.description.representation
import java.io.File;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -29,6 +29,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EPackage.Descriptor;
import org.eclipse.emf.ecore.EPackage.Registry;
+import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.plugin.EcorePlugin;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
@@ -38,31 +39,26 @@ import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.sirius.editor.editorPlugin.SiriusEditorPlugin;
-import org.eclipse.sirius.viewpoint.description.DescriptionPackage;
import org.eclipse.sirius.viewpoint.description.RepresentationDescription;
-/**
- * A class to update the {@link RepresentationDescription#getMetamodel()}
- * feature of a contextual {@link RepresentationDescription}.
- *
- * @author <a href="mailto:esteban.dugueperoux@obeo.fr">Esteban Dugueperoux</a>
- */
-public class RepresentationDescriptionMetamodelsUpdater {
-
+public class DescriptionMetamodelsUpdater {
private static ResourceSet resourceSetCache;
- private RepresentationDescription representationDescription;
+ private EObject description;
+
+ private EReference metamodelEReference;
protected EditingDomain editingDomain;
/**
* Default constructor.
*
- * @param representationDescription
- * the {@link RepresentationDescription} to update
+ * @param description
+ * the description to update
*/
- public RepresentationDescriptionMetamodelsUpdater(RepresentationDescription representationDescription) {
- this.representationDescription = representationDescription;
+ public DescriptionMetamodelsUpdater(EObject description, EReference metamodelEReference) {
+ this.description = description;
+ this.metamodelEReference = metamodelEReference;
}
public void setEditingDomain(EditingDomain editingDomain) {
@@ -71,9 +67,8 @@ public class RepresentationDescriptionMetamodelsUpdater {
/**
* Add all {@link EPackage}s contained in the specified ecore
- * {@link Resource}'s {@link URI}s to the contextual
- * {@link RepresentationDescription} on the
- * {@link RepresentationDescription#getMetamodel()} feature.
+ * {@link Resource}'s {@link URI}s to the contextual description on the
+ * metamodel feature.
*
* @param ecoreResourceURIs
* the specified ecore {@link Resource}'s {@link URI}s containing
@@ -86,8 +81,7 @@ public class RepresentationDescriptionMetamodelsUpdater {
/**
* Add the {@link EPackage}s specified by <code>ePackageURIs</code> to the
- * contextual {@link RepresentationDescription} on the
- * {@link RepresentationDescription#getMetamodel()} feature.
+ * contextual description on the metamodel feature.
*
* @param ePackageURIs
* the specified {@link EPackage}s {@link URI}
@@ -99,15 +93,14 @@ public class RepresentationDescriptionMetamodelsUpdater {
/**
* Add the {@link EPackage}s specified by <code>ePackageURIs</code> to the
- * contextual {@link RepresentationDescription} on the
- * {@link RepresentationDescription#getMetamodel()} feature.
+ * contextual description on the metamodel feature.
*
* @param ePackageURIs
* the specified {@link EPackage}s {@link URI}
*/
public void addEPackages(List<EPackage> ePackages) {
if (!ePackages.isEmpty()) {
- Command addEPackagesCmd = AddCommand.create(editingDomain, representationDescription, DescriptionPackage.Literals.REPRESENTATION_DESCRIPTION__METAMODEL, ePackages);
+ Command addEPackagesCmd = AddCommand.create(editingDomain, description, metamodelEReference, ePackages);
editingDomain.getCommandStack().execute(addEPackagesCmd);
}
}
@@ -129,8 +122,8 @@ public class RepresentationDescriptionMetamodelsUpdater {
return ecoreResourceEPackages;
}
- public void setRepresentationDescription(RepresentationDescription representationDescription) {
- this.representationDescription = representationDescription;
+ public void setDescription(EObject description) {
+ this.description = description;
}
protected List<EPackage> getEPackages(Resource ecoreResource) {
@@ -169,8 +162,11 @@ public class RepresentationDescriptionMetamodelsUpdater {
for (Resource ePackageToRemoveResource : getRelatedResources(ePackagesToRemove)) {
if (ePackageToRemoveResource != null) {
List<EPackage> ePackagesOfResourceToRemove = getEPackages(ePackageToRemoveResource);
- if (Collections.disjoint(ePackagesOfResourceToRemove, representationDescription.getMetamodel())) {
- relatedResourcesToRemove.add(ePackageToRemoveResource);
+ Object metamodels = this.description.eGet(this.metamodelEReference);
+ if (metamodels instanceof Collection<?>) {
+ if (Collections.disjoint(ePackagesOfResourceToRemove, (Collection<?>) metamodels)) {
+ relatedResourcesToRemove.add(ePackageToRemoveResource);
+ }
}
}
}
@@ -219,7 +215,7 @@ public class RepresentationDescriptionMetamodelsUpdater {
*/
public void removeEPackages(List<EPackage> ePackages) {
if (!ePackages.isEmpty()) {
- Command removeEPackagesCmd = RemoveCommand.create(editingDomain, representationDescription, DescriptionPackage.Literals.REPRESENTATION_DESCRIPTION__METAMODEL, ePackages);
+ Command removeEPackagesCmd = RemoveCommand.create(editingDomain, description, metamodelEReference, ePackages);
editingDomain.getCommandStack().execute(removeEPackagesCmd);
Set<Resource> relatedResourcesToRemove = getRelatedResourcesToRemove(ePackages);
for (Resource relatedResourceToRemove : relatedResourcesToRemove) {
@@ -371,8 +367,8 @@ public class RepresentationDescriptionMetamodelsUpdater {
}
public void dispose() {
- representationDescription = null;
+ description = null;
+ metamodelEReference = null;
editingDomain = null;
}
-
}
diff --git a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/RemoveMetamodelsSelectionButtonListener.java b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/RemoveMetamodelsSelectionButtonListener.java
index 7ba194eff6..470839806a 100644
--- a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/RemoveMetamodelsSelectionButtonListener.java
+++ b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/RemoveMetamodelsSelectionButtonListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 THALES GLOBAL SERVICES.
+ * Copyright (c) 2011, 2016 THALES GLOBAL SERVICES.
* 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
@@ -13,7 +13,6 @@ package org.eclipse.sirius.editor.properties.sections.description.representation
import java.util.List;
import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.sirius.viewpoint.description.RepresentationDescription;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
@@ -27,35 +26,35 @@ import org.eclipse.swt.widgets.TableItem;
*/
public class RemoveMetamodelsSelectionButtonListener extends SelectionAdapter {
- private RepresentationDescriptionMetamodelPropertySectionSpec representationDescriptionMetamodelsPropertySection;
+ private AbstractMetamodelPropertySectionSpec abstractMetamodelsPropertySection;
private Button removeButton;
private Table metamodelsTable;
- private RepresentationDescriptionMetamodelsUpdater representationDescriptionMetamodelsUpdater;
+ private DescriptionMetamodelsUpdater descriptionMetamodelsUpdater;
/**
* Default constructor.
*
- * @param representationDescriptionMetamodelsPropertySection
- * {@link RepresentationDescriptionMetamodelPropertySectionSpec}
- * which use this listener
+ * @param abstractMetamodelsPropertySection
+ * {@link AbstractMetamodelPropertySectionSpec} which use this
+ * listener
* @param removeButton
* the {@link Button} to remove referenced {@link EPackage}
* @param metamodelsTable
* the {@link Table} representing the metamodels associated to
- * the {@link RepresentationDescription}
- * @param representationDescriptionMetamodelsUpdater
- * the {@link RepresentationDescriptionMetamodelsUpdater} used to
- * update the model
+ * the description
+ * @param descriptionMetamodelsUpdater
+ * the {@link DescriptionMetamodelsUpdater} used to update the
+ * model
*/
- public RemoveMetamodelsSelectionButtonListener(RepresentationDescriptionMetamodelPropertySectionSpec representationDescriptionMetamodelsPropertySection, Button removeButton,
- Table metamodelsTable, RepresentationDescriptionMetamodelsUpdater representationDescriptionMetamodelsUpdater) {
- this.representationDescriptionMetamodelsPropertySection = representationDescriptionMetamodelsPropertySection;
+ public RemoveMetamodelsSelectionButtonListener(AbstractMetamodelPropertySectionSpec abstractMetamodelsPropertySection, Button removeButton, Table metamodelsTable,
+ DescriptionMetamodelsUpdater descriptionMetamodelsUpdater) {
+ this.abstractMetamodelsPropertySection = abstractMetamodelsPropertySection;
this.removeButton = removeButton;
this.metamodelsTable = metamodelsTable;
- this.representationDescriptionMetamodelsUpdater = representationDescriptionMetamodelsUpdater;
+ this.descriptionMetamodelsUpdater = descriptionMetamodelsUpdater;
metamodelsTable.addSelectionListener(this);
}
@@ -64,15 +63,16 @@ public class RemoveMetamodelsSelectionButtonListener extends SelectionAdapter {
*
* {@inheritDoc}
*/
+ @Override
public void widgetSelected(SelectionEvent e) {
Object source = e.getSource();
TableItem[] selection = metamodelsTable.getSelection();
if (source == removeButton) {
if (selection != null && selection.length > 0) {
- representationDescriptionMetamodelsUpdater.setEditingDomain(representationDescriptionMetamodelsPropertySection.getEditingDomain());
- List<EPackage> ePackages = representationDescriptionMetamodelsPropertySection.getEPackages(selection);
- representationDescriptionMetamodelsUpdater.removeEPackages(ePackages);
+ descriptionMetamodelsUpdater.setEditingDomain(abstractMetamodelsPropertySection.getEditingDomain());
+ List<EPackage> ePackages = abstractMetamodelsPropertySection.getEPackages(selection);
+ descriptionMetamodelsUpdater.removeEPackages(ePackages);
}
} else if (source == metamodelsTable) {
boolean enable = selection != null && selection.length > 0;
diff --git a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/RepresentationDescriptionMetamodelPropertySectionSpec.java b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/RepresentationDescriptionMetamodelPropertySectionSpec.java
index ba588d1bdf..be2c593b62 100644
--- a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/RepresentationDescriptionMetamodelPropertySectionSpec.java
+++ b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationdescription/RepresentationDescriptionMetamodelPropertySectionSpec.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 THALES GLOBAL SERVICES.
+ * Copyright (c) 2011, 2016 THALES GLOBAL SERVICES.
* 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
@@ -10,309 +10,19 @@
*******************************************************************************/
package org.eclipse.sirius.editor.properties.sections.description.representationdescription;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.plugin.EcorePlugin;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.jface.fieldassist.FieldDecoration;
-import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
-import org.eclipse.sirius.editor.editorPlugin.SiriusEditorPlugin;
-import org.eclipse.sirius.editor.properties.ViewpointPropertySheetPage;
-import org.eclipse.sirius.editor.properties.sections.common.AbstractViewpointPropertySection;
import org.eclipse.sirius.viewpoint.description.DescriptionPackage;
-import org.eclipse.sirius.viewpoint.description.RepresentationDescription;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
/**
* A {@link AbstractSiriusPropertySection} for the metamodels tab.
*
* @author <a href="mailto:esteban.dugueperoux@obeo.fr">Esteban Dugueperoux</a>
*/
-public class RepresentationDescriptionMetamodelPropertySectionSpec extends AbstractViewpointPropertySection {
-
- private CLabel help;
-
- /** Main composite **/
- protected Composite composite;
-
- protected Label listHeader;
-
- protected Table metamodelsTable;
-
- protected Button addFromRegistryButton;
-
- protected Button addFromWorkspaceButton;
-
- protected Button addFromFilesystemButton;
-
- protected Button removeMetamodelsSelectionButton;
-
- protected RepresentationDescriptionMetamodelsUpdater representationDescriptionMetamodelsUpdater;
-
- @Override
- protected void makeReadonly() {
- metamodelsTable.setEnabled(false);
- addFromRegistryButton.setEnabled(false);
- addFromWorkspaceButton.setEnabled(false);
- addFromFilesystemButton.setEnabled(false);
- removeMetamodelsSelectionButton.setEnabled(false);
- }
-
- @Override
- protected void makeWrittable() {
- metamodelsTable.setEnabled(true);
- addFromRegistryButton.setEnabled(true);
- addFromWorkspaceButton.setEnabled(true);
- addFromFilesystemButton.setEnabled(true);
- }
+public class RepresentationDescriptionMetamodelPropertySectionSpec extends AbstractMetamodelPropertySectionSpec {
@Override
protected EStructuralFeature getFeature() {
return DescriptionPackage.eINSTANCE.getRepresentationDescription_Metamodel();
}
- @Override
- public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
- super.createControls(parent, aTabbedPropertySheetPage);
-
- if (aTabbedPropertySheetPage instanceof ViewpointPropertySheetPage)
- super.createControls(parent, (ViewpointPropertySheetPage) aTabbedPropertySheetPage);
- else
- super.createControls(parent, aTabbedPropertySheetPage);
- composite = getWidgetFactory().createFlatFormComposite(parent);
-
- help = getWidgetFactory().createCLabel(composite, "");
- help.setImage(getHelpIcon());
- help.setToolTipText("Select the Metamodels (EPackage) which must be used in the current representation description");
-
- listHeader = getWidgetFactory().createLabel(composite, "Selected Metamodels : ");
- FormData data = new FormData();
- data.left = new FormAttachment(0, 25);
- data.right = new FormAttachment(100, 0);
- data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
- listHeader.setLayoutData(data);
-
- // CHECKSTYLE:OFF
- int style = SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL;
- // CHECKSTYLE:ON
- metamodelsTable = getWidgetFactory().createTable(composite, style);
- metamodelsTable.setLinesVisible(true);
- metamodelsTable.setHeaderVisible(true);
- TableColumn ePackageNameColumn = new TableColumn(metamodelsTable, SWT.NONE);
- ePackageNameColumn.setText("Name");
- TableColumn ePackageNSURIColumn = new TableColumn(metamodelsTable, SWT.NONE);
- ePackageNSURIColumn.setText("nsURI");
- TableColumn ecoreResourceURIColumn = new TableColumn(metamodelsTable, SWT.NONE);
- ecoreResourceURIColumn.setText("metamodel URI");
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(80, 0);
- data.top = new FormAttachment(listHeader, 0, ITabbedPropertyConstants.VSPACE);
- data.height = 120;
- data.width = 200;
- metamodelsTable.setLayoutData(data);
-
- addButtons();
- }
-
- protected void addButtons() {
- RepresentationDescription representationDescription = (RepresentationDescription) eObject;
- this.representationDescriptionMetamodelsUpdater = new RepresentationDescriptionMetamodelsUpdater(representationDescription);
-
- addFromRegistryButton = getWidgetFactory().createButton(composite, "Add from registry", SWT.PUSH);
- addFromRegistryButton.addSelectionListener(new AddFromRegistryButtonListener(this, representationDescriptionMetamodelsUpdater));
- FormData data = new FormData();
- data.top = new FormAttachment(listHeader, 0, SWT.RIGHT);
- data.left = new FormAttachment(metamodelsTable, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
- data.right = new FormAttachment(100);
- data.width = 60;
- addFromRegistryButton.setLayoutData(data);
-
- addFromWorkspaceButton = getWidgetFactory().createButton(composite, "Add from workspace", SWT.PUSH);
- addFromWorkspaceButton.addSelectionListener(new AddFromWorkspaceButtonListener(this, representationDescriptionMetamodelsUpdater));
- data = new FormData();
- data.top = new FormAttachment(addFromRegistryButton, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
- data.left = new FormAttachment(metamodelsTable, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
- data.right = new FormAttachment(100);
- data.width = 60;
- addFromWorkspaceButton.setLayoutData(data);
-
- addFromFilesystemButton = getWidgetFactory().createButton(composite, "Add from filesystem", SWT.PUSH);
- addFromFilesystemButton.addSelectionListener(new AddFromFilesystemButtonListener(this, representationDescriptionMetamodelsUpdater));
- data = new FormData();
- data.top = new FormAttachment(addFromWorkspaceButton, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
- data.left = new FormAttachment(metamodelsTable, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
- data.right = new FormAttachment(100);
- data.width = 60;
- addFromFilesystemButton.setLayoutData(data);
-
- removeMetamodelsSelectionButton = getWidgetFactory().createButton(composite, "Remove", SWT.PUSH);
- removeMetamodelsSelectionButton.addSelectionListener(new RemoveMetamodelsSelectionButtonListener(this, removeMetamodelsSelectionButton, metamodelsTable,
- representationDescriptionMetamodelsUpdater));
- removeMetamodelsSelectionButton.setEnabled(false);
- data = new FormData();
- data.top = new FormAttachment(addFromFilesystemButton, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
- data.left = new FormAttachment(metamodelsTable, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
- data.right = new FormAttachment(100);
- data.width = 60;
- removeMetamodelsSelectionButton.setLayoutData(data);
- }
-
- @Override
- public void refresh() {
- if (eObject instanceof RepresentationDescription) {
- representationDescriptionMetamodelsUpdater.setRepresentationDescription((RepresentationDescription) eObject);
- }
- List<EPackage> ePackages = getValue();
- if (ePackages != null) {
- List<EPackage> previousEPackages = getEPackages(metamodelsTable.getItems());
- int previousSelectionIndex = metamodelsTable.getSelectionIndex();
- metamodelsTable.removeAll();
- List<TableItem> newItems = new ArrayList<TableItem>();
- for (EPackage ePackage : ePackages) {
- TableItem item = new TableItem(metamodelsTable, 0);
- item.setData(ePackage);
- if (ePackage.eResource() != null) {
- String ePackageName = ePackage.getName();
- if (ePackageName == null) {
- ePackageName = "null";
- }
- item.setText(0, ePackageName);
- String ePackageNSURI = ePackage.getNsURI();
- if (ePackageNSURI == null) {
- ePackageNSURI = "null";
- }
- item.setText(1, ePackageNSURI);
- String ePackageURI = null;
- URI completeURIToEPackage = representationDescriptionMetamodelsUpdater.getCompleteURIToEPackage(ePackage);
- if (completeURIToEPackage != null) {
- ePackageURI = URI.decode(completeURIToEPackage.toString());
- } else {
- URI genModelResourceURI = EcorePlugin.getEPackageNsURIToGenModelLocationMap().get(ePackage.getNsURI());
- if (genModelResourceURI != null) {
- ePackageURI = genModelResourceURI.trimFileExtension().appendFileExtension("ecore").toString();
- }
- }
- if (ePackageURI == null) {
- ePackageURI = "unknow metamodel resource URI";
- }
- item.setText(2, ePackageURI);
- if (!previousEPackages.contains(ePackage)) {
- newItems.add(item);
- }
- } else {
- URI proxyURI = ((InternalEObject) ePackage).eProxyURI();
- String ePackageName = proxyURI.lastSegment().substring(0, proxyURI.lastSegment().indexOf('.'));
- item.setText(0, ePackageName);
- item.setText(1, "null");
- String ePackageURI = proxyURI.trimFragment().toString();
- item.setText(2, ePackageURI);
- // Adding decorator
- FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
- Image img = fieldDecoration.getImage();
- item.setImage(img);
- // Log an error in the "Error log" view.
- SiriusEditorPlugin.getPlugin().getLog().log(new Status(IStatus.ERROR, SiriusEditorPlugin.PLUGIN_ID, "Invalid ressource access for the metamodel " + ePackageURI));
- }
- }
- if (!newItems.isEmpty()) {
- metamodelsTable.setSelection(newItems.toArray(new TableItem[0]));
- removeMetamodelsSelectionButton.setEnabled(true);
- } else {
- metamodelsTable.select(previousSelectionIndex - 1);
- }
- }
- if (metamodelsTable.getSelectionCount() == 0) {
- removeMetamodelsSelectionButton.setEnabled(false);
- }
- metamodelsTable.getColumn(0).pack();
- metamodelsTable.getColumn(1).pack();
- metamodelsTable.getColumn(2).pack();
- }
-
- /**
- * Get the current {@link EditingDomain}.
- *
- * @return the current {@link EditingDomain}
- */
- public EditingDomain getEditingDomain() {
- EditingDomain editingDomain = null;
- if (getPart() instanceof IEditingDomainProvider) {
- editingDomain = ((IEditingDomainProvider) getPart()).getEditingDomain();
- }
- return editingDomain;
- }
-
- /**
- * Get the list a {@link EPackage}s associated to the specified array of
- * {@link TableItem}.
- *
- * @param selection
- * array of {@link TableItem}
- * @return list a {@link EPackage}s associated
- */
- public List<EPackage> getEPackages(TableItem[] selection) {
- List<EPackage> ePackages = new ArrayList<EPackage>();
- for (TableItem item : selection) {
- if (item.getData() instanceof EPackage) {
- ePackages.add((EPackage) item.getData());
- }
- }
- return ePackages;
- }
-
- /**
- * Get the {@link RepresentationDescription#getMetamodel()} value.
- *
- * @return the {@link RepresentationDescription#getMetamodel()} value
- */
- @SuppressWarnings("unchecked")
- protected List<EPackage> getValue() {
- List<EPackage> ePackages = new ArrayList<EPackage>();
- Object object = eObject.eGet(getFeature());
- if (object instanceof List<?>) {
- java.util.List<?> values = (java.util.List<?>) object;
- if (!values.isEmpty() && values.get(0) instanceof EPackage) {
- ePackages = (List<EPackage>) values;
- }
- }
- return ePackages;
- }
-
- @Override
- public void dispose() {
- if (representationDescriptionMetamodelsUpdater != null) {
- representationDescriptionMetamodelsUpdater.dispose();
- representationDescriptionMetamodelsUpdater = null;
- }
- removeMetamodelsSelectionButton = null;
- addFromFilesystemButton = null;
- addFromWorkspaceButton = null;
- addFromRegistryButton = null;
- metamodelsTable = null;
- listHeader = null;
- composite = null;
- help = null;
- super.dispose();
- }
}
diff --git a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationextensiondescription/RepresentationExtensionDescriptionMetamodelPropertySectionSpec.java b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationextensiondescription/RepresentationExtensionDescriptionMetamodelPropertySectionSpec.java
index b3c4932cf4..22efd005ee 100644
--- a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationextensiondescription/RepresentationExtensionDescriptionMetamodelPropertySectionSpec.java
+++ b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationextensiondescription/RepresentationExtensionDescriptionMetamodelPropertySectionSpec.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 THALES GLOBAL SERVICES.
+ * Copyright (c) 2011, 2016 THALES GLOBAL SERVICES.
* 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
@@ -14,6 +14,7 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.sirius.editor.properties.sections.description.representationdescription.AddFromFilesystemButtonListener;
import org.eclipse.sirius.editor.properties.sections.description.representationdescription.AddFromRegistryButtonListener;
import org.eclipse.sirius.editor.properties.sections.description.representationdescription.AddFromWorkspaceButtonListener;
+import org.eclipse.sirius.editor.properties.sections.description.representationdescription.DescriptionMetamodelsUpdater;
import org.eclipse.sirius.editor.properties.sections.description.representationdescription.RemoveMetamodelsSelectionButtonListener;
import org.eclipse.sirius.editor.properties.sections.description.representationdescription.RepresentationDescriptionMetamodelPropertySectionSpec;
import org.eclipse.sirius.viewpoint.description.DescriptionPackage;
@@ -30,11 +31,12 @@ import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
*/
public class RepresentationExtensionDescriptionMetamodelPropertySectionSpec extends RepresentationDescriptionMetamodelPropertySectionSpec {
+ @Override
protected void addButtons() {
RepresentationExtensionDescription representationExtensionDescription = (RepresentationExtensionDescription) eObject;
- this.representationDescriptionMetamodelsUpdater = new RepresentationExtensionDescriptionMetamodelsUpdater(representationExtensionDescription);
+ this.descriptionMetamodelsUpdater = new DescriptionMetamodelsUpdater(representationExtensionDescription, DescriptionPackage.eINSTANCE.getRepresentationExtensionDescription_Metamodel());
addFromRegistryButton = getWidgetFactory().createButton(composite, "Add from registry", SWT.PUSH);
- addFromRegistryButton.addSelectionListener(new AddFromRegistryButtonListener(this, representationDescriptionMetamodelsUpdater));
+ addFromRegistryButton.addSelectionListener(new AddFromRegistryButtonListener(this, descriptionMetamodelsUpdater));
FormData data = new FormData();
data.top = new FormAttachment(listHeader, 0, SWT.RIGHT);
data.left = new FormAttachment(metamodelsTable, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
@@ -42,7 +44,7 @@ public class RepresentationExtensionDescriptionMetamodelPropertySectionSpec exte
addFromRegistryButton.setLayoutData(data);
addFromWorkspaceButton = getWidgetFactory().createButton(composite, "Add from workspace", SWT.PUSH);
- addFromWorkspaceButton.addSelectionListener(new AddFromWorkspaceButtonListener(this, representationDescriptionMetamodelsUpdater));
+ addFromWorkspaceButton.addSelectionListener(new AddFromWorkspaceButtonListener(this, descriptionMetamodelsUpdater));
data = new FormData();
data.top = new FormAttachment(addFromRegistryButton, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
data.left = new FormAttachment(metamodelsTable, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
@@ -50,7 +52,7 @@ public class RepresentationExtensionDescriptionMetamodelPropertySectionSpec exte
addFromWorkspaceButton.setLayoutData(data);
addFromFilesystemButton = getWidgetFactory().createButton(composite, "Add from filesystem", SWT.PUSH);
- addFromFilesystemButton.addSelectionListener(new AddFromFilesystemButtonListener(this, representationDescriptionMetamodelsUpdater));
+ addFromFilesystemButton.addSelectionListener(new AddFromFilesystemButtonListener(this, descriptionMetamodelsUpdater));
data = new FormData();
data.top = new FormAttachment(addFromWorkspaceButton, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
data.left = new FormAttachment(metamodelsTable, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
@@ -58,8 +60,7 @@ public class RepresentationExtensionDescriptionMetamodelPropertySectionSpec exte
addFromFilesystemButton.setLayoutData(data);
removeMetamodelsSelectionButton = getWidgetFactory().createButton(composite, "Remove", SWT.PUSH);
- removeMetamodelsSelectionButton.addSelectionListener(new RemoveMetamodelsSelectionButtonListener(this, removeMetamodelsSelectionButton, metamodelsTable,
- representationDescriptionMetamodelsUpdater));
+ removeMetamodelsSelectionButton.addSelectionListener(new RemoveMetamodelsSelectionButtonListener(this, removeMetamodelsSelectionButton, metamodelsTable, descriptionMetamodelsUpdater));
removeMetamodelsSelectionButton.setEnabled(false);
data = new FormData();
data.top = new FormAttachment(addFromFilesystemButton, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
diff --git a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationextensiondescription/RepresentationExtensionDescriptionMetamodelsUpdater.java b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationextensiondescription/RepresentationExtensionDescriptionMetamodelsUpdater.java
index 8105e13865..dfdad9bd42 100644
--- a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationextensiondescription/RepresentationExtensionDescriptionMetamodelsUpdater.java
+++ b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/description/representationextensiondescription/RepresentationExtensionDescriptionMetamodelsUpdater.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 THALES GLOBAL SERVICES.
+ * Copyright (c) 2011, 2016 THALES GLOBAL SERVICES.
* 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
@@ -22,7 +22,7 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
-import org.eclipse.sirius.editor.properties.sections.description.representationdescription.RepresentationDescriptionMetamodelsUpdater;
+import org.eclipse.sirius.editor.properties.sections.description.representationdescription.DescriptionMetamodelsUpdater;
import org.eclipse.sirius.viewpoint.description.DescriptionPackage;
import org.eclipse.sirius.viewpoint.description.RepresentationDescription;
import org.eclipse.sirius.viewpoint.description.RepresentationExtensionDescription;
@@ -34,7 +34,7 @@ import org.eclipse.sirius.viewpoint.description.RepresentationExtensionDescripti
*
* @author <a href="mailto:esteban.dugueperoux@obeo.fr">Esteban Dugueperoux</a>
*/
-public class RepresentationExtensionDescriptionMetamodelsUpdater extends RepresentationDescriptionMetamodelsUpdater {
+public class RepresentationExtensionDescriptionMetamodelsUpdater extends DescriptionMetamodelsUpdater {
private RepresentationExtensionDescription representationExtensionDescription;
@@ -45,7 +45,7 @@ public class RepresentationExtensionDescriptionMetamodelsUpdater extends Represe
* the {@link RepresentationDescription} to update
*/
public RepresentationExtensionDescriptionMetamodelsUpdater(RepresentationExtensionDescription representationDescription) {
- super(null);
+ super(null, DescriptionPackage.eINSTANCE.getRepresentationDescription_Metamodel());
this.representationExtensionDescription = representationDescription;
}
@@ -57,6 +57,7 @@ public class RepresentationExtensionDescriptionMetamodelsUpdater extends Represe
* @param ePackageURIs
* the specified {@link EPackage}s {@link URI}
*/
+ @Override
public void addEPackages(List<EPackage> ePackages) {
if (!ePackages.isEmpty()) {
Command addEPackagesCmd = AddCommand.create(editingDomain, representationExtensionDescription, DescriptionPackage.Literals.REPRESENTATION_EXTENSION_DESCRIPTION__METAMODEL, ePackages);
@@ -72,10 +73,11 @@ public class RepresentationExtensionDescriptionMetamodelsUpdater extends Represe
* @param ePackages
* the list of {@link EPackage} to remove
*/
+ @Override
public void removeEPackages(List<EPackage> ePackages) {
if (!ePackages.isEmpty()) {
- Command removeEPackagesCmd = RemoveCommand
- .create(editingDomain, representationExtensionDescription, DescriptionPackage.Literals.REPRESENTATION_EXTENSION_DESCRIPTION__METAMODEL, ePackages);
+ Command removeEPackagesCmd = RemoveCommand.create(editingDomain, representationExtensionDescription, DescriptionPackage.Literals.REPRESENTATION_EXTENSION_DESCRIPTION__METAMODEL,
+ ePackages);
editingDomain.getCommandStack().execute(removeEPackagesCmd);
Set<Resource> relatedResourcesToRemove = getRelatedResourcesToRemove(ePackages);
for (Resource relatedResourceToRemove : relatedResourcesToRemove) {
@@ -94,6 +96,7 @@ public class RepresentationExtensionDescriptionMetamodelsUpdater extends Represe
* @return the related {@link Resource} to remove from the
* {@link ResourceSet}
*/
+ @Override
protected Set<Resource> getRelatedResourcesToRemove(List<EPackage> ePackagesToRemove) {
Set<Resource> relatedResourcesToRemove = new LinkedHashSet<Resource>();
for (Resource ePackageToRemoveResource : getRelatedResources(ePackagesToRemove)) {

Back to the top