Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael LANOE2015-02-25 09:35:55 +0000
committerMickael LANOE2015-03-18 16:51:45 +0000
commit8d00943c05349a4825ba6f76a15803964cd5e515 (patch)
tree7e5cb596002bab9d241b8d30722823e595073211
parent798d97d52eca4f06c216b442028f797ed0a6c5b6 (diff)
downloadorg.eclipse.sirius-8d00943c05349a4825ba6f76a15803964cd5e515.tar.gz
org.eclipse.sirius-8d00943c05349a4825ba6f76a15803964cd5e515.tar.xz
org.eclipse.sirius-8d00943c05349a4825ba6f76a15803964cd5e515.zip
[453437] Disable some actions when a DRepresentationContainer is locked
When a DRepresentationContainer is locked by using a permission authority, these following actions are now disabled: - Delete a representation from the DRepresentationContainer - Copy a representation from the DRepresentationContainer - Extract a representation from the DReprentationContainer - Move a representation from or to the DrepresentationContainer Add a test to check the fix. Bug: 453437 Change-Id: I689c6e852d920280677e676d34776b17be347bd8 Signed-off-by: Mickael LANOE <mickael.lanoe@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release Notes.html72
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release Notes.textile3
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java43
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/LockedRepresentationContainerTest.java282
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java3
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/copy/CopyRepresentationAction.java44
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/ContextMenuFiller.java53
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/action/DeleteRepresentationAction.java45
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/action/ExtractRepresentationAction.java104
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/action/MoveRepresentationAction.java127
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/wizards/pages/RepresentationsSelectionWizardPage.java96
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/session/danalysis/DAnalysisSessionHelper.java18
12 files changed, 720 insertions, 170 deletions
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html
index d6788a2796..32e5dac0ec 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html
@@ -43,7 +43,7 @@
<h2 id="sirius3.0.0">Changes in Sirius 3.0.0 (from Sirius 2.0.0)</h2>
<h3 id="UserVisibleChanges">User-Visible Changes</h3>
<ul>
- <li>In the Viewpoint Selection Dialog and ViewpointsSelectionWizardPage, the &#171;plug-in&#187; decorator for viewpoints loaded from plug-ins is removed, and a &#171;Folder&#187; decorator for viewpoints loaded from the current workspace has been added on the top of the default viewpoint icon.</li>
+ <li>In the Viewpoint Selection Dialog and ViewpointsSelectionWizardPage, 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 on the top of the default viewpoint icon.</li>
<li>The ability to print table representations has been re-introduced.</li>
</ul>
<h3 id="SpecifierVisibleChanges">Specifier-Visible Changes</h3>
@@ -53,7 +53,7 @@
<code>[eContents()-&gt;size()/]</code>) in the VSM, that was implicit before. Customers who want to completely remove this dependency must remove the A3 expressions from there VSM after the migration.
</li>
<li>The default icons paths of Selection Wizard and Pane Based Selection Wizard used to reference invalid icons, so the corresponding tools had no icon per default in the palette. The default icons paths have been corrected to reference the icons displayed for those elements in the VSM editor.</li>
- <li>&#171;*&#187; can now be used as feature name of a FeatureColumn to skip the feature name validation during the cell creation. This allow to compute the label of cells for lines whose semantic element types have no common EStructuralFeatures (inherited or with same name).</li>
+ <li>&#8220;*&#8221; can now be used as feature name of a FeatureColumn to skip the feature name validation during the cell creation. This allow to compute the label of cells for lines whose semantic element types have no common EStructuralFeatures (inherited or with same name).</li>
</ul>
<h3 id="APIChanges">API Changes</h3>
<h4 id="Changesinorg.eclipse.sirius.ext.emf.tx">Changes in
@@ -71,6 +71,12 @@
</h4>
<ul>
<li>The method
+ <code>org.eclipse.sirius.business.api.session.danalysis.DAnalysisSessionHelper.findContainerForAddedRepresentation(DAnalysis, DRepresentation)</code> has been added to return a
+ <code>DRepresentationContainer</code> from the
+ <code>DAnalysis</code> parameter and the added
+ <code>DRepresentation</code>.
+ </li>
+ <li>The method
<code>org.eclipse.sirius.business.api.migration.IMigrationParticipant.updateCreatedObject(EObject newObject, String loadedVersion)</code> has been added to update object values in VSM before loading this objects from XML file.
</li>
<li>The method
@@ -80,7 +86,7 @@
<code>org.eclipse.sirius.business.api.helper.SiriusUtil.ENVIRONMENT_URI_SCHEME</code> declares environment URI scheme.
</li>
<li>Constant
- <code>org.eclipse.sirius.business.api.helper.SiriusUtil.VIEWPOINT_ENVIRONMENT_RESOURCE_URI</code> declares &#171;environment:/viewpoint&#187; resource uri.
+ <code>org.eclipse.sirius.business.api.helper.SiriusUtil.VIEWPOINT_ENVIRONMENT_RESOURCE_URI</code> declares &#8220;environment:/viewpoint&#8221; resource uri.
</li>
<li>Constant
<code>org.eclipse.sirius.viewpoint.description.util.DescriptionResourceImpl.OPTION_SIRIUS_USE_URI_FRAGMENT_AS_ID</code> added to define a option to enable the use of a id map for odesign resource, id being uri&#8217;s fragment.
@@ -325,7 +331,7 @@
<code>org.eclipse.sirius.diagram.tools.api.command.ChangeLayerActivationCommand</code> has been added. This command was previously internal.
</li>
<li>Constant
- <code>org.eclipse.sirius.diagram.business.api.helper.SiriusDiagramUtil.DIAGRAM_ENVIRONMENT_RESOURCE_URI</code> declares &#171;environment:/diagram&#187; resource uri.
+ <code>org.eclipse.sirius.diagram.business.api.helper.SiriusDiagramUtil.DIAGRAM_ENVIRONMENT_RESOURCE_URI</code> declares &#8220;environment:/diagram&#8221; resource uri.
</li>
<li>The method
<code>org.eclipse.sirius.diagram.business.api.diagramtype.IDiagramDescriptionProvider.completeToolTipText(String, EObject, EStructuralFeature)</code> has been added to customize the tooltip displayed in the VSM editor by using the feature of the current object. The old method
@@ -481,6 +487,12 @@
<code>org.eclipse.sirius.common</code> plugin).
</li>
</ul>
+ <ul>
+ <li>The method
+ <code>org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor.getDRepresentation()</code> has been added to return the
+ <code>org.eclipse.sirius.viewpoint.DRepresentation</code> instance available in the diagram editor.
+ </li>
+ </ul>
<h2 id="sirius2.0.0">Changes in Sirius 2.0.0 (from Sirius 1.0.0)</h2>
<h3 id="UserVisibleChanges2">User-Visible Changes</h3>
<ul>
@@ -498,13 +510,13 @@
<img border="0" src="images/containerResize-changedBehavior.gif"/>
</p>
<ul>
- <li>The &#171;snap to shapes&#187; is now enabled by default (see
+ <li>The &#8220;snap to shapes&#8221; is now enabled by default (see
<em>Sirius &gt; Sirius Diagram &gt; Rulers and Grid</em> preference page). This is true only for new diagrams. The existing diagrams are not impacted.
</li>
- <li>The &#171;Navigate&#187; top-level contextual menu entry with mixed actions for creating new representations and opening existing ones has been changed by two top-level menus:
+ <li>The &#8220;Navigate&#8221; top-level contextual menu entry with mixed actions for creating new representations and opening existing ones has been changed by two top-level menus:
<ul>
- <li>One named &#171;New&#187;, which lists only the available actions to create new representations on the selected element.</li>
- <li>One named &#171;Open&#187;, which lists only the existing representations on the selected element. </li>
+ <li>One named &#8220;New&#8221;, which lists only the available actions to create new representations on the selected element.</li>
+ <li>One named &#8220;Open&#8221;, which lists only the existing representations on the selected element. </li>
</ul>
</li>
<li>When a shape is resized (no matter the direction), the edge(s) connection location (toward or from this one) is kept. Before that, edges connections moved according to the ratio of the resizing.</li>
@@ -529,19 +541,19 @@
<li>Distribute centers vertically</li>
</ul>
</li>
- <li>The end user can now remove all bend-points between the two edge ends. This action is available on edge context menu &#171;Remove Bend-points&#187; or by using the shortcut &#171;Ctrl&#187; + &#171;Shift&#187; + &#171;-&#187;.</li>
+ <li>The end user can now remove all bend-points between the two edge ends. This action is available on edge context menu &#8220;Remove Bend-points&#8221; or by using the shortcut &#8220;Ctrl&#8221; + &#8220;Shift&#8221; + &#8220;-&#8221;.</li>
<li>Reconnection of an edge will only now move the minimum necessary bendpoints instead of reseting it to default.</li>
<li>A new action has been added to reset the diagram (or container) origin: the diagram (or container) bounds (the rectangle formed by the highest, the leftmost, the lowest and the rightmost children elements) can have a negative origin or can be shifted toward the bottom-right with a blank zone at the top-left. This action aims to move all diagram (or container) elements so that the it retrieves its origin while keeping elements layout.</li>
</ul>
<h3 id="SpecifierVisibleChanges2">Specifier-Visible Changes</h3>
<ul>
- <li>The specifier can now choose to hold the edge ends toward the center of the source, target or both. New fields within the &#171;advance&#187; tab of EdgeStyle description have been added to choose for which source or target mappings an edge should be centered. See
+ <li>The specifier can now choose to hold the edge ends toward the center of the source, target or both. New fields within the &#8220;advance&#8221; tab of EdgeStyle description have been added to choose for which source or target mappings an edge should be centered. See
<a href="specifier/diagrams/Diagrams.html#edges_styles">Edges Styles &gt; Edge Centering</a> in the specifier manual for more details.
</li>
<li>When creating a new Viewpoint Specification Project using the supplied wizard:
- <em>New &gt; Viewpoint Specification Project</em>, the VSM name is now given according to the project name. If the project name is suffixed with &#171;design&#187;, the VSM name is provided by the last word before this suffix. Otherwise, the VSM name is given by the last word of the project name.
+ <em>New &gt; Viewpoint Specification Project</em>, the VSM name is now given according to the project name. If the project name is suffixed with &#8220;design&#8221;, the VSM name is provided by the last word before this suffix. Otherwise, the VSM name is given by the last word of the project name.
</li>
- <li>&#171;Lozenge&#187; is replaced by &#171;Diamond&#187; in diagram style.</li>
+ <li>&#8220;Lozenge&#8221; is replaced by &#8220;Diamond&#8221; in diagram style.</li>
</ul>
<h3 id="APIChanges2">API Changes</h3>
<h4 id="Changesinorg.eclipse.sirius2">Changes in
@@ -974,7 +986,7 @@
<h3 id="SpecifierVisibleChanges4">Specifier-Visible Changes</h3>
<ul>
<li>The default value of the
- <em>Semantic Candidates Expression</em> for Tree Items has changed from an empty string (meaning &#171;any compatible element in the session&#187;) to
+ <em>Semantic Candidates Expression</em> for Tree Items has changed from an empty string (meaning &#8220;any compatible element in the session&#8221;) to
<code>feature:eAllContents</code> which only looks for compatible candidates inside the current element (recursively). The new behavior is more efficient on large models and consistent with what happens for diagrams. The change does not affect existing VSMs which continue to work as before whatever was the expression they used. Users who want the old behavior on specific mappings can simply remove the expression in the properties view.
</li>
<li>In the
@@ -1007,7 +1019,7 @@
<code>org.eclipse.diagram</code> again.
</p>
<p>Unlike, the
- <a href="#separationOfDiagramSpecificConcept-step1">Step1</a>, a simple &#171;Organize Imports&#187; operation is not enough. First, you will probably need to add dependencies to
+ <a href="#separationOfDiagramSpecificConcept-step1">Step1</a>, a simple &#8220;Organize Imports&#8221; operation is not enough. First, you will probably need to add dependencies to
<code>org.eclipse.sirius.diagram</code>,
<code>org.eclipse.sirius.diagram.ui</code> or
<code>org.eclipse.sirius.editor.diagram</code> in the MANIFEST.MF of your projects that depend on Sirius diagram classes. The dependencies to add depend on what you really use.
@@ -1434,7 +1446,7 @@
<code>Multimap</code>.
</li>
<li>
- <code>org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager.initializeAfterLoad()</code> method has been removed. There is no replacement for this method documented as &#171;Not intended to be used by client&#187;.
+ <code>org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager.initializeAfterLoad()</code> method has been removed. There is no replacement for this method documented as &#8220;Not intended to be used by client&#8221;.
</li>
</ul>
<h4 id="Changesinorg.eclipse.sirius.ecore.extender3">Changes in
@@ -1678,27 +1690,27 @@ if (rootPackage != null &amp;&amp; rootPackage.getNsURI().equals(DiagramPackage.
<h2 id="sirius1.0M5">Changes in Sirius 1.0.0M5 (from Sirius 1.0M4)</h2>
<h3 id="UserVisibleChanges4">User-Visible Changes</h3>
<ul>
- <li>The table csv export has been improved to handle cropped label. In some specific cases, the cell label is automatically cropped and &#8249;...&#8250; is concatenated to the resulting value. This cropped displayed label was previously exported, now the complete semantic value is exported.</li>
+ <li>The table csv export has been improved to handle cropped label. In some specific cases, the cell label is automatically cropped and &#8216;...&#8217; is concatenated to the resulting value. This cropped displayed label was previously exported, now the complete semantic value is exported.</li>
</ul>
<h3 id="APIChanges6">API Changes</h3>
<h4 id="LibraryExtensions">Library Extensions</h4>
- <p>This milestone (Sirius 1.0M5) introduces several new plug-ins, collectively called &#171;library extensions&#187;. They are all named
+ <p>This milestone (Sirius 1.0M5) introduces several new plug-ins, collectively called &#8220;library extensions&#8221;. They are all named
<code>org.eclipse.sirius.ext.LIB</code>, where
- <code>LIB</code> is the name of a library or component Sirius depends on. These plug-ins are used to isolate generic code which extends existing libraries with features and helpers needed for Sirius, but which do not depend on Sirius themselves. A relatively large part of the code in Sirius is of this kind: things that could/should be in EMF, GMF, Eclipse itself, etc. and which are not Sirius-specific but which make it easier to build Sirius itself. Sirius 1.0M5 introduces several of these library extensions and starts to fill them with existing classes which were &#171;hidden&#187; inside Sirius and are now exposed in library extensions. Most of the time, existing code which used the Sirius API will only need to:
+ <code>LIB</code> is the name of a library or component Sirius depends on. These plug-ins are used to isolate generic code which extends existing libraries with features and helpers needed for Sirius, but which do not depend on Sirius themselves. A relatively large part of the code in Sirius is of this kind: things that could/should be in EMF, GMF, Eclipse itself, etc. and which are not Sirius-specific but which make it easier to build Sirius itself. Sirius 1.0M5 introduces several of these library extensions and starts to fill them with existing classes which were &#8220;hidden&#8221; inside Sirius and are now exposed in library extensions. Most of the time, existing code which used the Sirius API will only need to:
</p>
<ol>
<li>Add the necessary
<code>Import-Package</code> (recommended) or
<code>Require-Bundle</code> to depend on the library extension(s) where the code they use now lives;
</li>
- <li>Perform a simple &#171;Organize Imports&#187; operation, which should find the classes and interfaces in their new locations.</li>
+ <li>Perform a simple &#8220;Organize Imports&#8221; operation, which should find the classes and interfaces in their new locations.</li>
</ol>
<h4 id="separationOfDiagramSpecificConcept-step1">Move diagram-specific EClasses into a separate EPackage</h4>
<p>For historical reasons, the core Sirius metamodels defined in viewpoint.ecore contain both generic (dialect-independant like Viewpoint, RepresentationDescription, DAnalysis...) concepts and diagram-specific ones (e.g. DNode, EdgeStyle, ContainerCreationDescription...). The table and tree metamodels are more cleanly separated.
<br/>This milestone (Sirius 1.0M5) includes the first step towards a full separation of the diagram-specific stuff out of the core of Sirius. So many EClasses have been moved.
</p>
- <p>Most of the time, existing code which used these Sirius EClasses will only need to perform a simple &#171;Organize Imports&#187; operation, which should find the classes and interfaces in their new locations.
- <br/>The &#171;Organize imports&#187; is not sufficient in case of imported classes existing several time in different packages (
+ <p>Most of the time, existing code which used these Sirius EClasses will only need to perform a simple &#8220;Organize Imports&#8221; operation, which should find the classes and interfaces in their new locations.
+ <br/>The &#8220;Organize imports&#8221; is not sufficient in case of imported classes existing several time in different packages (
<code>EFactory</code> classes for example with
<code>DescriptionFactory</code>, or
<code>EPackage</code> classes for example with
@@ -2113,7 +2125,7 @@ if (rootPackage != null &amp;&amp; rootPackage.getNsURI().equals(DiagramPackage.
</li>
</ul>
<h2 id="sirius0.9">Changes in Sirius 0.9.0</h2>
- <p>Version 0.9.0 is the first release under the Sirius name and under the Eclipse Foundation umbrella. Except for the few cases mentioned below (in the &#171;Other API Changes&#187;, &#171;Specifier-Visible Changes&#187; and &#171;User-Visible Changes&#187; sections), Sirius 0.9.0 is functionally equivalent to the latest version of Viewpoint (version 6.10), which was the name of the project before it was open sourced at Eclipse. See the rest of the documentation for the complete list of feature of the Sirius platform.</p>
+ <p>Version 0.9.0 is the first release under the Sirius name and under the Eclipse Foundation umbrella. Except for the few cases mentioned below (in the &#8220;Other API Changes&#8221;, &#8220;Specifier-Visible Changes&#8221; and &#8220;User-Visible Changes&#8221; sections), Sirius 0.9.0 is functionally equivalent to the latest version of Viewpoint (version 6.10), which was the name of the project before it was open sourced at Eclipse. See the rest of the documentation for the complete list of feature of the Sirius platform.</p>
<h3 id="MigratingfromObeoDesignerorViewpointtoSirius">Migrating from Obeo Designer or Viewpoint to Sirius</h3>
<p>If you have existing projects which used this technology before it became Eclipse Sirius and want to migrate to Sirius, you must:</p>
<ol>
@@ -2137,9 +2149,9 @@ if (rootPackage != null &amp;&amp; rootPackage.getNsURI().equals(DiagramPackage.
<code>org.eclipse.sirius.componentization</code> extension point id. The identifier changes for the other extension points follow the same rules as the name changes of the plug-ins they are defined in.
</li>
<li>The migration of your VSMs (
- <code>*.odesign</code> files) is automatic: simply open your files once in the VSM editor, perform some no-op change to make the editor &#171;dirty&#187; and save it. The saved version will have been migrated to Sirius.
+ <code>*.odesign</code> files) is automatic: simply open your files once in the VSM editor, perform some no-op change to make the editor &#8220;dirty&#8221; and save it. The saved version will have been migrated to Sirius.
</li>
- <li>If you had Java code which used the Viewpoint APIs, you will need to update it to use the Sirius APIs. A simple &#171;Source &gt; Organize Imports&#187; on your source folders should find most classes you used in their new namespace. The Viewpoint code base and APIs used the term &#171;Viewpoint&#187; both for the name of the product and for the name of the concept. When it refered to the name of the product, the names were changed to use &#171;Sirius&#187; instead, so you may need to adjust some names in your code beyond just updating the imports (for example,
+ <li>If you had Java code which used the Viewpoint APIs, you will need to update it to use the Sirius APIs. A simple &#8220;Source &gt; Organize Imports&#8221; on your source folders should find most classes you used in their new namespace. The Viewpoint code base and APIs used the term &#8220;Viewpoint&#8221; both for the name of the product and for the name of the concept. When it refered to the name of the product, the names were changed to use &#8220;Sirius&#8221; instead, so you may need to adjust some names in your code beyond just updating the imports (for example,
<code>ViewpointControlCommand</code> is now
<code>SiriusControlCommand</code>).
</li>
@@ -2154,7 +2166,7 @@ if (rootPackage != null &amp;&amp; rootPackage.getNsURI().equals(DiagramPackage.
<h4 id="MigratingModelingProjectsandRepresentationFiles">Migrating Modeling Projects and Representation Files</h4>
<ul>
<li>First migrate any modeler definitions used by your modeling projects and representation files (see the section above).</li>
- <li>Modeling projects created using Viewpoint will not be recognized directly by Sirius, because the nature identfier has changed. You must use the &#171;Configure/Convert to Modeling Project&#187; action in the project&#8217;s context menu to make it a Sirius-compatible modeling project (see the section below for the technical details of the change).</li>
+ <li>Modeling projects created using Viewpoint will not be recognized directly by Sirius, because the nature identfier has changed. You must use the &#8220;Configure/Convert to Modeling Project&#8221; action in the project&#8217;s context menu to make it a Sirius-compatible modeling project (see the section below for the technical details of the change).</li>
<li>The migration of you representation files (
<code>*.aird</code>) is performed automatically when they are loaded in memory. It will become permanent the first time you save it (you can force this by opening a representation, making some arbitrary change and saving the session).
</li>
@@ -2330,20 +2342,20 @@ if (rootPackage != null &amp;&amp; rootPackage.getNsURI().equals(DiagramPackage.
</tr>
</table>
<h4 id="JavaPackagesandClassesNames">Java Packages and Classes Names</h4>
- <p>The Java package names have changed to start with the identifier of the plug-in they are defined in (which has changed). A simple &#171;Source &gt; Organize Imports&#187; on your source folders should find most classes you used in their new namespace.</p>
- <p>The Viewpoint code base and APIs used the term &#171;Viewpoint&#187; both for the name of the product and for the name of the concept. When it refered to the name of the product, the names where changed to use &#171;Sirius&#187; instead (for example,
+ <p>The Java package names have changed to start with the identifier of the plug-in they are defined in (which has changed). A simple &#8220;Source &gt; Organize Imports&#8221; on your source folders should find most classes you used in their new namespace.</p>
+ <p>The Viewpoint code base and APIs used the term &#8220;Viewpoint&#8221; both for the name of the product and for the name of the concept. When it refered to the name of the product, the names where changed to use &#8220;Sirius&#8221; instead (for example,
<code>ViewpointControlCommand</code> is now
<code>SiriusControlCommand</code>).
</p>
<h4 id="ModelsnamespaceURIs">Models namespace URIs</h4>
- <p>All namespace URIs have also been changed from &#171;http://www.obeo.fr/dsl/viewpoint*&#187; to &#171;http://www.eclipse.org/sirius/&#187;.</p>
+ <p>All namespace URIs have also been changed from &#8220;http://www.obeo.fr/dsl/viewpoint*&#8221; to &#8220;http://www.eclipse.org/sirius/&#8221;.</p>
<p>If you have created VSM file (.odesign) or representations file (.aird) with Viewpoint, the changes of the namespace URIs will be automatically migrated during the loading of your VSM or your representations file. These new nsURIs will be stored physically in the file during the first save. If the file is not saved, the automatic migration will be replayed at the next opening.</p>
<h3 id="NatureID">Nature ID</h3>
<p>The modeling project has a specific nature (
<code>org.eclipse.sirius.nature.modelingproject</code>).
- <br/>If you have modeling project created with Viewpoint, you must launch the action &#171;Configure/Convert to Modeling Project&#187; to replace old nature id (
+ <br/>If you have modeling project created with Viewpoint, you must launch the action &#8220;Configure/Convert to Modeling Project&#8221; to replace old nature id (
<code>fr.obeo.dsl.viewpoint.nature.modelingproject</code>) by the new one.
- <br/>If you have many modeling projects to &#171;migrate&#187;, you can easily make a script to replace
+ <br/>If you have many modeling projects to &#8220;migrate&#8221;, you can easily make a script to replace
<code>fr.obeo.dsl.viewpoint.nature.modelingproject</code> by
<code>org.eclipse.sirius.nature.modelingproject</code> in all
<code>.project</code> file of each modeling projects.
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile
index 661d1cd961..469416c449 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile
@@ -26,6 +26,7 @@ h4. Changes in @org.eclipse.sirius.ext.emf.tx@
h4. Changes in @org.eclipse.sirius@
+* The method @org.eclipse.sirius.business.api.session.danalysis.DAnalysisSessionHelper.findContainerForAddedRepresentation(DAnalysis, DRepresentation)@ has been added to return a @DRepresentationContainer@ from the @DAnalysis@ parameter and the added @DRepresentation@.
* The method @org.eclipse.sirius.business.api.migration.IMigrationParticipant.updateCreatedObject(EObject newObject, String loadedVersion)@ has been added to update object values in VSM before loading this objects from XML file.
* The method @org.eclipse.sirius.tools.api.ui.RefreshEditorsPrecommitListener.disable()@ has been added to disable the next refresh attempt in the current precommit loop iteration.
* Constant @org.eclipse.sirius.business.api.helper.SiriusUtil.ENVIRONMENT_URI_SCHEME@ declares environment URI scheme.
@@ -138,6 +139,8 @@ h4. Changes in @org.eclipse.sirius.ext.swt@
* The @org.eclipse.sirius.ext.swt.ImageFileFormat@ class has been moved in @org.eclipse.sirius.common.tools.api.resource@ (in the @org.eclipse.sirius.common@ plugin).
+* The method @org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor.getDRepresentation()@ has been added to return the @org.eclipse.sirius.viewpoint.DRepresentation@ instance available in the diagram editor.
+
h2(#sirius2.0.0). Changes in Sirius 2.0.0 (from Sirius 1.0.0)
h3. User-Visible Changes
diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java
index eb2e11f786..9f14edb2a9 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java
@@ -1,13 +1,13 @@
-/**
- * Copyright (c) 2009, 2014 THALES GLOBAL SERVICES and others.
- * All rights reserved. This program and the accompanying materials
+/*******************************************************************************
+ * Copyright (c) 2009, 2015 THALES GLOBAL SERVICES and others.
+ * 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
- */
+ * Obeo - initial API and implementation
+ *******************************************************************************/
package org.eclipse.sirius.tests.swtbot.support.api.editor;
import java.util.ArrayList;
@@ -313,12 +313,6 @@ public class SWTBotSiriusDiagramEditor extends SWTBotGefEditor {
return bounds;
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor#drag(java.lang.String,
- * int, int)
- */
@Override
public void drag(final String label, final int toXPosition, final int toYPosition) {
final SWTBotGefEditPart selectedEP = getEditPart(label);
@@ -406,9 +400,6 @@ public class SWTBotSiriusDiagramEditor extends SWTBotGefEditor {
return result;
}
- /**
- * {@inheritDoc}
- */
@Override
public SWTBotGefEditPart getEditPart(final String label) {
final SWTBotGefEditPart selectedEP = super.getEditPart(label);
@@ -830,11 +821,6 @@ public class SWTBotSiriusDiagramEditor extends SWTBotGefEditor {
return swtbotGefEditPartList;
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor#clickContextMenu(java.lang.String)
- */
@Override
public SWTBotGefEditor clickContextMenu(String text) throws WidgetNotFoundException {
SWTBotGefEditor swtBotGefEditor = super.clickContextMenu(text);
@@ -1686,9 +1672,11 @@ public class SWTBotSiriusDiagramEditor extends SWTBotGefEditor {
public DiagramEditPart getDiagramEditPart() {
final List<SWTBotGefEditPart> parts = editParts(new BaseMatcher<EditPart>() {
+ @Override
public void describeTo(final Description description) {
}
+ @Override
public boolean matches(final Object item) {
return item instanceof DiagramEditPart;
}
@@ -1733,4 +1721,19 @@ public class SWTBotSiriusDiagramEditor extends SWTBotGefEditor {
outlineView.activateLayer(layerName);
}
}
+
+ /**
+ * Get the {@link DRepresentation} instance available in the diagram editor.
+ *
+ * @return the {@link DRepresentation} instance
+ */
+ public DRepresentation getDRepresentation() {
+ DRepresentation dRepresentation = null;
+ IEditorPart editorPart = getReference().getEditor(false);
+ if (editorPart instanceof DialectEditor) {
+ DialectEditor dialectEditor = (DialectEditor) editorPart;
+ dRepresentation = dialectEditor.getRepresentation();
+ }
+ return dRepresentation;
+ }
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/LockedRepresentationContainerTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/LockedRepresentationContainerTest.java
new file mode 100644
index 0000000000..d604b8f9bc
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/LockedRepresentationContainerTest.java
@@ -0,0 +1,282 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.tests.swtbot;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.sirius.business.api.session.Session;
+import org.eclipse.sirius.diagram.DDiagram;
+import org.eclipse.sirius.ecore.extender.business.api.permission.PermissionAuthorityRegistry;
+import org.eclipse.sirius.ecore.extender.business.internal.permission.ReadOnlyPermissionAuthority;
+import org.eclipse.sirius.tests.swtbot.support.api.AbstractSiriusSwtBotGefTestCase;
+import org.eclipse.sirius.tests.swtbot.support.api.business.UIResource;
+import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor;
+import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils;
+import org.eclipse.sirius.tools.internal.command.PrepareNewAnalysisCommand;
+import org.eclipse.sirius.viewpoint.DAnalysis;
+import org.eclipse.sirius.viewpoint.DRepresentationContainer;
+import org.eclipse.sirius.viewpoint.ViewpointFactory;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+
+import com.google.common.collect.Sets;
+
+/**
+ * Ensure that some actions on representation are disabled when the
+ * {@link DRepresentationContainer} is locked by using the permission authority
+ * {@link ReadOnlyPermissionAuthority}
+ *
+ * @author <a href="mailto:mickael.lanoe@obeo.fr">Mickael LANOE</a>
+ */
+public class LockedRepresentationContainerTest extends AbstractSiriusSwtBotGefTestCase {
+ private static final String MODEL = "tc2216.ecore";
+
+ private static final String MODEL_URI = "platform:/resource/DesignerTestProject/tc2216.ecore";
+
+ private static final String SESSION_FILE = "tc2216.aird";
+
+ private static final String DATA_UNIT_DIR = "data/unit/portPositionStability/tc-2216/";
+
+ private static final String FILE_DIR = "/";
+
+ private static final String VIEWPOINT_NAME = "Design";
+
+ private static final String REPRESENTATION_DESCRIPTION_NAME = "Entities";
+
+ private static final String REPRESENTATION_NAME = "aaaa package entities";
+
+ private static final String NEXT = "Next >";
+
+ private static final String CANCEL = "Cancel";
+
+ private static final String OK = "OK";
+
+ private static final String FINISH = "Finish";
+
+ private static final String EXTRACT_TO_AIRD_FILE = "Extract to .aird file ...";
+
+ private static final String CREATE_REPRESENTATION = "Create Representation";
+
+ private static final String CREATE_REPRESENTATION_WIZARD = "Create Representation Wizard";
+
+ private static final String NEW_REPRESENTATION = "New Representation";
+
+ private static final String DELETE_ACTION = "Delete";
+
+ private static final String COPY_ACTION = "Copy";
+
+ private static final String MOVE_ACTION = "Move";
+
+ private static final String PACKAGE_NAME = "aaaa";
+
+ private static final String PACKAGE_SUB_NAME = "0";
+
+ private static final String CONTROL_ACTION = "Control...";
+
+ private static final String CONTROL_DIALOG = "Control";
+
+ private static final String CONTROL_WIZARD = "Wizard of representations selection";
+
+ private UIResource semanticModel;
+
+ private EObject representationContainer;
+
+ @Override
+ protected void onSetUpBeforeClosingWelcomePage() throws Exception {
+ copyFileToTestProject(Activator.PLUGIN_ID, DATA_UNIT_DIR, MODEL, SESSION_FILE);
+ }
+
+ @Override
+ protected void onSetUpAfterOpeningDesignerPerspective() throws Exception {
+ sessionAirdResource = new UIResource(designerProject, FILE_DIR, SESSION_FILE);
+ localSession = designerPerspective.openSessionFromFile(sessionAirdResource);
+
+ // Activate Design viewpoint
+ localSession.changeViewpointSelection(Sets.newHashSet(VIEWPOINT_NAME), Sets.<String> newHashSet());
+
+ // Open the entity diagram & retrieve the representation container
+ editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), REPRESENTATION_DESCRIPTION_NAME, REPRESENTATION_NAME, DDiagram.class);
+
+ representationContainer = editor.getDRepresentation().eContainer();
+
+ // Get the semantic model
+ semanticModel = new UIResource(designerProject, FILE_DIR, MODEL);
+ }
+
+ /**
+ * Ensure that the creation of a new representation from the session is
+ * forbidden when the representation container is locked by using permission
+ * authority.
+ */
+ public void testControlSemanticModel() {
+ SWTBotTreeItem semanticPackageNode = getSelectedSemanticSubPackageNode();
+
+ // Call the control action
+ clickContextMenu(semanticPackageNode, CONTROL_ACTION);
+
+ // Click "Ok" on the first dialog
+ SWTBotShell shell = bot.shell(CONTROL_DIALOG);
+ shell.activate();
+ bot.button(OK).click();
+
+ // Activate the selection wizard
+ shell = bot.shell(CONTROL_WIZARD);
+ shell.activate();
+
+ // Select the representation description
+ SWTBotTreeItem item = bot.tree().expandNode(MODEL_URI, PACKAGE_NAME, REPRESENTATION_NAME).select();
+ item.check();
+
+ assertTrue("The representation extraction should be allowed", bot.button(FINISH).isEnabled());
+
+ // Lock the representation container
+ lockRepresentationContainer();
+
+ // After locking the representation container, the node must be selected
+ // again to update the button status
+ item = bot.tree().expandNode(MODEL_URI, PACKAGE_NAME, REPRESENTATION_NAME).select();
+ item.check();
+
+ assertFalse("The representation extraction should be forbidden when the representation container is locked", bot.button(FINISH).isEnabled());
+
+ // Close the wizard
+ bot.button(CANCEL).click();
+ }
+
+ /**
+ * Ensure that the deletion of a representation is forbidden when the
+ * representation container is locked by using permission authority.
+ */
+ public void testDeleteRepresentation() {
+ doTestRepresentationAction(DELETE_ACTION);
+ }
+
+ /**
+ * Ensure that the copy of a representation is forbidden when the
+ * representation container is locked by using permission authority.
+ */
+ public void testCopyRepresentation() {
+ doTestRepresentationAction(COPY_ACTION);
+ }
+
+ /**
+ * Ensure that the extract of a representation is forbidden when the
+ * representation container is locked by using permission authority.
+ */
+ public void testExtractRepresentation() {
+ doTestRepresentationAction(EXTRACT_TO_AIRD_FILE);
+ }
+
+ /**
+ * Ensure that the move of a representation is forbidden when the
+ * representation container is locked by using permission authority.
+ */
+ public void testMoveRepresentation() {
+ // First create a new ".aird" file to have the "Move" action
+ Session session = localSession.getOpenedSession();
+ TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
+ ResourceSet resourceSet = domain.getResourceSet();
+ URI airdUri = URI.createPlatformResourceURI("/" + getProjectName() + "/move.aird", true);
+ Resource airdResource = resourceSet.createResource(airdUri);
+ DAnalysis slaveAnalysis = ViewpointFactory.eINSTANCE.createDAnalysis();
+ domain.getCommandStack().execute(new PrepareNewAnalysisCommand(domain, airdResource, slaveAnalysis, session));
+
+ final String moveAction = "move to " + airdUri.toString();
+
+ // Before locking the representation container
+ assertTrue("The action '" + moveAction + "' should be enabled", getSelectedDiagramNode().contextMenu(MOVE_ACTION).menu(moveAction).isEnabled());
+
+ // Lock the representation container
+ lockRepresentationContainer();
+
+ // After locking the representation container
+ assertFalse("The action '" + moveAction + "' should be disabled when the representation container is locked", getSelectedDiagramNode().contextMenu(MOVE_ACTION).menu(moveAction).isEnabled());
+ }
+
+ /**
+ * Ensure that an action on a representation is forbidden when the
+ * representation container is locked by using permission authority.
+ *
+ * @param action
+ * the action to check
+ */
+ private void doTestRepresentationAction(String action) {
+ SWTBotTreeItem diagramNode = getSelectedDiagramNode();
+
+ // Before locking the representation container
+ assertTrue("The action '" + action + "' should be enabled", diagramNode.contextMenu(action).isEnabled());
+
+ // Lock the representation container
+ lockRepresentationContainer();
+
+ // After locking the representation container
+ assertFalse("The action '" + action + "' should be disabled when the representation container is locked", diagramNode.contextMenu(action).isEnabled());
+ }
+
+ /**
+ * Get and select the semantic package node from the tree item.
+ *
+ * @return semantic package node
+ */
+ private SWTBotTreeItem getSelectedSemanticPackageNode() {
+ SWTBotTreeItem semanticResourceNode = localSession.getSemanticResourceNode(semanticModel);
+ return semanticResourceNode.expandNode(PACKAGE_NAME).select();
+ }
+
+ /**
+ * Get and select the semantic package node from the tree item.
+ *
+ * @return semantic package node
+ */
+ private SWTBotTreeItem getSelectedSemanticSubPackageNode() {
+ SWTBotTreeItem semanticResourceNode = localSession.getSemanticResourceNode(semanticModel);
+ return semanticResourceNode.expandNode(PACKAGE_NAME, PACKAGE_SUB_NAME).select();
+ }
+
+ /**
+ * Get and select the diagram node from the tree item
+ *
+ * @return diagram node
+ */
+ private SWTBotTreeItem getSelectedDiagramNode() {
+ SWTBotTreeItem semanticPackageNode = getSelectedSemanticPackageNode();
+ return semanticPackageNode.expandNode(REPRESENTATION_NAME).select();
+ }
+
+ /**
+ * Lock the representation container.
+ */
+ private void lockRepresentationContainer() {
+ // Activate the ReadOnlyPermission Authority on the representation
+ // container to lock it
+ ((ReadOnlyPermissionAuthority) PermissionAuthorityRegistry.getDefault().getPermissionAuthority(representationContainer)).activate();
+ }
+
+ /**
+ * Click on a context menu action.
+ *
+ * @param treeItem
+ * selection tree item
+ * @param action
+ * action to call
+ */
+ private void clickContextMenu(SWTBotTreeItem treeItem, String action) {
+ try {
+ treeItem.contextMenu(action).click();
+ } catch (WidgetNotFoundException e) {
+ SWTBotUtils.clickContextMenu(treeItem, CREATE_REPRESENTATION);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java
index eca0783f4a..3ccf3dd6bd 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010-2015 THALES GLOBAL SERVICES.
+ * Copyright (c) 2010, 2015 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
@@ -298,6 +298,7 @@ public class AllTestSuite extends TestCase {
suite.addTestSuite(TabBarTest.class);
suite.addTestSuite(NotInvisibleTabBarTest.class);
suite.addTestSuite(LockedTabBarTest.class);
+ suite.addTestSuite(LockedRepresentationContainerTest.class);
suite.addTestSuite(ArrangeSelectionOnBreakdownDiagramTest.class);
suite.addTestSuite(RemovedDefaultColorMenuTest.class);
suite.addTestSuite(DuplicationCausedBySelectionTest.class);
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/copy/CopyRepresentationAction.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/copy/CopyRepresentationAction.java
index 981993f0a7..2e0eafe44b 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/copy/CopyRepresentationAction.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/copy/CopyRepresentationAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2014 THALES GLOBAL SERVICES.
+ * Copyright (c) 2009, 2015 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
@@ -12,6 +12,7 @@ package org.eclipse.sirius.ui.tools.internal.actions.copy;
import java.util.Collection;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.jface.action.Action;
@@ -20,11 +21,17 @@ import org.eclipse.sirius.business.api.dialect.command.CopyRepresentationCommand
import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.common.tools.api.util.StringUtil;
import org.eclipse.sirius.common.ui.tools.api.dialog.RenameDialog;
+import org.eclipse.sirius.ecore.extender.business.api.permission.IPermissionAuthority;
+import org.eclipse.sirius.ecore.extender.business.api.permission.PermissionAuthorityRegistry;
import org.eclipse.sirius.viewpoint.DRepresentation;
+import org.eclipse.sirius.viewpoint.DRepresentationContainer;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
/**
* An action to copy selected representations.
*
@@ -52,13 +59,13 @@ public class CopyRepresentationAction extends Action {
final ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
this.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
this.setDisabledImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
+
+ // Disable the action if the selection is not valid
+ if (!isValidSelection()) {
+ this.setEnabled(false);
+ }
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.action.Action#run()
- */
@Override
public void run() {
@@ -95,4 +102,29 @@ public class CopyRepresentationAction extends Action {
private String getPrefix() {
return StringUtil.EMPTY_STRING;
}
+
+ /**
+ * Test if the selection is valid.
+ *
+ * @return true if the selection is valid
+ */
+ private boolean isValidSelection() {
+
+ boolean anyInvalidCopy = Iterables.any(representations, new Predicate<DRepresentation>() {
+
+ @Override
+ public boolean apply(DRepresentation input) {
+ EObject container = input.eContainer();
+ if (container instanceof DRepresentationContainer) {
+ IPermissionAuthority permissionAuthority = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(container);
+ if (permissionAuthority != null && !permissionAuthority.canCreateIn(container)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ });
+
+ return !anyInvalidCopy;
+ }
}
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/ContextMenuFiller.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/ContextMenuFiller.java
index 8fd5952507..2d4946195f 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/ContextMenuFiller.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/ContextMenuFiller.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 THALES GLOBAL SERVICES.
+ * Copyright (c) 2011, 2015 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,7 +27,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.GroupMarker;
@@ -45,10 +44,7 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.sirius.business.api.dialect.DialectManager;
-import org.eclipse.sirius.business.api.dialect.command.MoveRepresentationCommand;
-import org.eclipse.sirius.business.api.helper.SiriusUtil;
import org.eclipse.sirius.business.api.modelingproject.ModelingProject;
import org.eclipse.sirius.business.api.query.URIQuery;
import org.eclipse.sirius.business.api.session.Session;
@@ -74,19 +70,18 @@ import org.eclipse.sirius.ui.tools.internal.actions.session.OpenRepresentationsA
import org.eclipse.sirius.ui.tools.internal.actions.session.OpenViewpointSelectionAction;
import org.eclipse.sirius.ui.tools.internal.views.ViewHelperImpl;
import org.eclipse.sirius.ui.tools.internal.views.common.action.DeleteRepresentationAction;
+import org.eclipse.sirius.ui.tools.internal.views.common.action.ExtractRepresentationAction;
+import org.eclipse.sirius.ui.tools.internal.views.common.action.MoveRepresentationAction;
import org.eclipse.sirius.ui.tools.internal.views.common.action.RenameRepresentationAction;
import org.eclipse.sirius.ui.tools.internal.views.common.item.ControlledRoot;
import org.eclipse.sirius.ui.tools.internal.views.common.item.RepresentationItemImpl;
import org.eclipse.sirius.ui.tools.internal.views.common.navigator.SiriusCommonLabelProvider;
import org.eclipse.sirius.ui.tools.internal.views.modelexplorer.extension.IContextMenuActionProvider;
-import org.eclipse.sirius.ui.tools.internal.wizards.ExtractRepresentationsWizard;
import org.eclipse.sirius.viewpoint.DAnalysis;
import org.eclipse.sirius.viewpoint.DRepresentation;
import org.eclipse.sirius.viewpoint.DSemanticDecorator;
import org.eclipse.sirius.viewpoint.description.RepresentationDescription;
import org.eclipse.sirius.viewpoint.provider.SiriusEditPlugin;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ISaveablesSource;
import org.eclipse.ui.IWorkbenchCommandConstants;
import org.eclipse.ui.PlatformUI;
@@ -526,40 +521,11 @@ public class ContextMenuFiller implements IMenuListener, IMenuListener2 {
}
private IAction buildExtractRepresentationsAction(final Session session, final Collection<DRepresentation> movableRepresentations) {
- final ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(SiriusEditPlugin.ID, "/icons/full/others/export.gif");
- return new Action("Extract to ." + SiriusUtil.SESSION_RESOURCE_EXTENSION + " file ...", descriptor) {
-
- @Override
- public void run() {
- final TransactionalEditingDomain transDomain = session.getTransactionalEditingDomain();
- final ExtractRepresentationsWizard wizard = new ExtractRepresentationsWizard(session, transDomain, movableRepresentations);
- final Shell defaultShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- final WizardDialog dialog = new WizardDialog(defaultShell, wizard);
- dialog.create();
- dialog.open();
- }
- };
+ return new ExtractRepresentationAction(session, movableRepresentations);
}
private Action buildMoveRepresentationsActions(final Session session, final Collection<DRepresentation> movableRepresentations, final DAnalysis targetAnalysis) {
- final ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(SiriusEditPlugin.ID, "/icons/full/others/forward.gif");
- final String uri = targetAnalysis.eResource().getURI().toString();
- return new Action("move to " + uri, descriptor) {
-
- @Override
- public void run() {
- final IEditingSession uiSession = SessionUIManager.INSTANCE.getUISession(session);
- if (uiSession != null) {
- for (final DRepresentation representation : movableRepresentations) {
- final IEditorPart editor = uiSession.getEditor(representation);
- if (editor != null) {
- editor.getEditorSite().getPage().closeEditor(editor, false);
- }
- }
- }
- session.getTransactionalEditingDomain().getCommandStack().execute(new MoveRepresentationCommand(session, targetAnalysis, movableRepresentations));
- }
- };
+ return new MoveRepresentationAction(session, targetAnalysis, movableRepresentations);
}
private Action buildViewpointsSelectionDialogAction(final Session session) {
@@ -723,17 +689,12 @@ public class ContextMenuFiller implements IMenuListener, IMenuListener2 {
return semRes;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public void menuAboutToShow(IMenuManager manager) {
// Nothing to do
-
}
- /**
- * {@inheritDoc}
- */
+ @Override
public void menuAboutToHide(IMenuManager manager) {
// As the menu is about to be hidden, and because all actions filled by
// this menu filler will be re-calculated,
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/action/DeleteRepresentationAction.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/action/DeleteRepresentationAction.java
index f208884c50..e368c3944d 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/action/DeleteRepresentationAction.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/action/DeleteRepresentationAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 THALES GLOBAL SERVICES.
+ * Copyright (c) 2011, 2015 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,6 +22,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
@@ -37,11 +38,15 @@ import org.eclipse.sirius.ui.business.api.dialect.DialectUIManager;
import org.eclipse.sirius.ui.business.api.session.IEditingSession;
import org.eclipse.sirius.ui.business.api.session.SessionUIManager;
import org.eclipse.sirius.viewpoint.DRepresentation;
+import org.eclipse.sirius.viewpoint.DRepresentationContainer;
import org.eclipse.sirius.viewpoint.provider.SiriusEditPlugin;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
/**
* Action to delete on or more Sirius representations.
*
@@ -60,13 +65,13 @@ public class DeleteRepresentationAction extends Action {
public DeleteRepresentationAction(Collection<DRepresentation> representations) {
super("Delete", AbstractUIPlugin.imageDescriptorFromPlugin(SiriusEditPlugin.ID, "/icons/full/others/delete.gif"));
this.selectedRepresentations = representations;
+
+ // Disable the action if the selection is not valid
+ if (!isValidSelection()) {
+ this.setEnabled(false);
+ }
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.action.Action#run()
- */
@Override
public void run() {
Map<DRepresentation, Session> dRepresentation2Session = getRepresentations();
@@ -83,6 +88,7 @@ public class DeleteRepresentationAction extends Action {
if (deletionConfirmation) {
IRunnableContext context = new ProgressMonitorDialog(shell);
IRunnableWithProgress editorClosingRunnable = new IRunnableWithProgress() {
+ @Override
public void run(final IProgressMonitor monitor) {
try {
monitor.beginTask("Associated editor closing", 1);
@@ -114,6 +120,7 @@ public class DeleteRepresentationAction extends Action {
IRunnableWithProgress representationsDeletionRunnable = new IRunnableWithProgress() {
+ @Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
monitor.beginTask("Representation" + (session2DRepresentations.size() > 1 ? "s" : "") + " deletion", session2DRepresentations.size());
@@ -187,4 +194,30 @@ public class DeleteRepresentationAction extends Action {
}
return isEnabled;
}
+
+ /**
+ * Test if the selection is valid.
+ *
+ * @return true if the selection is valid
+ */
+ private boolean isValidSelection() {
+
+ boolean anyInvalidDelete = Iterables.any(selectedRepresentations, new Predicate<DRepresentation>() {
+
+ @Override
+ public boolean apply(DRepresentation input) {
+ EObject container = input.eContainer();
+ if (container instanceof DRepresentationContainer) {
+ IPermissionAuthority permissionAuthority = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(container);
+ if (permissionAuthority != null && !permissionAuthority.canDeleteInstance(input)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ });
+
+ return !anyInvalidDelete;
+ }
+
}
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/action/ExtractRepresentationAction.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/action/ExtractRepresentationAction.java
new file mode 100644
index 0000000000..157692dbf3
--- /dev/null
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/action/ExtractRepresentationAction.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.ui.tools.internal.views.common.action;
+
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.sirius.business.api.helper.SiriusUtil;
+import org.eclipse.sirius.business.api.session.Session;
+import org.eclipse.sirius.ecore.extender.business.api.permission.IPermissionAuthority;
+import org.eclipse.sirius.ecore.extender.business.api.permission.PermissionAuthorityRegistry;
+import org.eclipse.sirius.ui.tools.internal.wizards.ExtractRepresentationsWizard;
+import org.eclipse.sirius.viewpoint.DRepresentation;
+import org.eclipse.sirius.viewpoint.DRepresentationContainer;
+import org.eclipse.sirius.viewpoint.provider.SiriusEditPlugin;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+/**
+ * An action to extract selected representations.
+ *
+ * @author <a href="mailto:mickael.lanoe@obeo.fr">Mickael LANOE</a>
+ */
+public class ExtractRepresentationAction extends Action {
+ private final Session session;
+
+ private final Collection<DRepresentation> representations;
+
+ /**
+ * Construct a new instance.
+ *
+ * @param session
+ * the current session
+ * @param selection
+ * the selected representations to extract
+ */
+ public ExtractRepresentationAction(Session session, Collection<DRepresentation> selection) {
+ super();
+ this.session = session;
+ this.representations = selection;
+
+ final ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(SiriusEditPlugin.ID, "/icons/full/others/export.gif");
+ this.setImageDescriptor(descriptor);
+
+ this.setText("Extract to ." + SiriusUtil.SESSION_RESOURCE_EXTENSION + " file ...");
+
+ // Disable the action if the selection is not valid
+ if (!isValidSelection()) {
+ this.setEnabled(false);
+ }
+ }
+
+ @Override
+ public void run() {
+ final TransactionalEditingDomain transDomain = session.getTransactionalEditingDomain();
+ final ExtractRepresentationsWizard wizard = new ExtractRepresentationsWizard(session, transDomain, representations);
+ final Shell defaultShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ final WizardDialog dialog = new WizardDialog(defaultShell, wizard);
+ dialog.create();
+ dialog.getShell().setText("Extract Representation Wizard");
+ dialog.open();
+ }
+
+ /**
+ * Test if the selection is valid.
+ *
+ * @return true if the selection is valid
+ */
+ private boolean isValidSelection() {
+
+ boolean anyInvalidExtract = Iterables.any(representations, new Predicate<DRepresentation>() {
+
+ @Override
+ public boolean apply(DRepresentation input) {
+ EObject container = input.eContainer();
+ if (container instanceof DRepresentationContainer) {
+ IPermissionAuthority permissionAuthority = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(container);
+ if (permissionAuthority != null && !permissionAuthority.canDeleteInstance(input)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ });
+
+ return !anyInvalidExtract;
+ }
+}
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/action/MoveRepresentationAction.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/action/MoveRepresentationAction.java
new file mode 100644
index 0000000000..99b212b403
--- /dev/null
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/action/MoveRepresentationAction.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.ui.tools.internal.views.common.action;
+
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.sirius.business.api.dialect.command.MoveRepresentationCommand;
+import org.eclipse.sirius.business.api.session.Session;
+import org.eclipse.sirius.business.api.session.danalysis.DAnalysisSessionHelper;
+import org.eclipse.sirius.ecore.extender.business.api.permission.IPermissionAuthority;
+import org.eclipse.sirius.ecore.extender.business.api.permission.PermissionAuthorityRegistry;
+import org.eclipse.sirius.ui.business.api.session.IEditingSession;
+import org.eclipse.sirius.ui.business.api.session.SessionUIManager;
+import org.eclipse.sirius.viewpoint.DAnalysis;
+import org.eclipse.sirius.viewpoint.DRepresentation;
+import org.eclipse.sirius.viewpoint.DRepresentationContainer;
+import org.eclipse.sirius.viewpoint.provider.SiriusEditPlugin;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+/**
+ * An action to move selected representations.
+ *
+ * @author <a href="mailto:mickael.lanoe@obeo.fr">Mickael LANOE</a>
+ */
+public class MoveRepresentationAction extends Action {
+ private final Collection<DRepresentation> representations;
+
+ private final DAnalysis targetAnalysis;
+
+ private final Session session;
+
+ /**
+ * Construct a new instance.
+ *
+ * @param session
+ * the current session
+ * @param targetAnalysis
+ * target analysis for the selection
+ * @param selection
+ * the selected representations to move
+ */
+ public MoveRepresentationAction(Session session, final DAnalysis targetAnalysis, Collection<DRepresentation> selection) {
+ super();
+ this.targetAnalysis = targetAnalysis;
+ this.session = session;
+ this.representations = selection;
+
+ final ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(SiriusEditPlugin.ID, "/icons/full/others/forward.gif");
+ this.setImageDescriptor(descriptor);
+
+ this.setText("move to " + targetAnalysis.eResource().getURI().toString());
+
+ // Disable the action if the selection is not valid
+ if (!isValidSelection()) {
+ this.setEnabled(false);
+ }
+ }
+
+ @Override
+ public void run() {
+ final IEditingSession uiSession = SessionUIManager.INSTANCE.getUISession(session);
+ if (uiSession != null) {
+ for (final DRepresentation representation : representations) {
+ final IEditorPart editor = uiSession.getEditor(representation);
+ if (editor != null) {
+ editor.getEditorSite().getPage().closeEditor(editor, false);
+ }
+ }
+ }
+ session.getTransactionalEditingDomain().getCommandStack().execute(new MoveRepresentationCommand(session, targetAnalysis, representations));
+ }
+
+ /**
+ * Test if the selection is valid.
+ *
+ * @return true if the selection is valid
+ */
+ private boolean isValidSelection() {
+
+ boolean anyInvalidMove = Iterables.any(representations, new Predicate<DRepresentation>() {
+
+ @Override
+ public boolean apply(DRepresentation input) {
+ boolean invalid = false; // false is the default value
+
+ // Step 1: Check source representation container
+ EObject container = input.eContainer();
+ if (container instanceof DRepresentationContainer) {
+ IPermissionAuthority permissionAuthority = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(container);
+ if (permissionAuthority != null && !permissionAuthority.canDeleteInstance(input)) {
+ invalid = true;
+ }
+ }
+
+ // Step 2: Check target representation container
+ if (!invalid) {
+ DRepresentationContainer targetContainer = DAnalysisSessionHelper.findContainerForAddedRepresentation(targetAnalysis, input);
+ if (targetContainer != null) {
+ IPermissionAuthority permissionAuthority = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(targetContainer);
+ if (permissionAuthority != null && !permissionAuthority.canCreateIn(targetContainer)) {
+ invalid = true;
+ }
+ }
+ }
+
+ return invalid;
+ }
+ });
+
+ return !anyInvalidMove;
+ }
+}
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/wizards/pages/RepresentationsSelectionWizardPage.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/wizards/pages/RepresentationsSelectionWizardPage.java
index 37584706f9..49cbc22bc9 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/wizards/pages/RepresentationsSelectionWizardPage.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/wizards/pages/RepresentationsSelectionWizardPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 THALES GLOBAL SERVICES.
+ * Copyright (c) 2008, 2015 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
@@ -32,8 +32,11 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.sirius.business.api.dialect.DialectManager;
import org.eclipse.sirius.business.api.session.Session;
+import org.eclipse.sirius.ecore.extender.business.api.permission.IPermissionAuthority;
+import org.eclipse.sirius.ecore.extender.business.api.permission.PermissionAuthorityRegistry;
import org.eclipse.sirius.ui.tools.api.views.ViewHelper;
import org.eclipse.sirius.viewpoint.DRepresentation;
+import org.eclipse.sirius.viewpoint.DRepresentationContainer;
import org.eclipse.sirius.viewpoint.DSemanticDecorator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
@@ -54,6 +57,8 @@ public class RepresentationsSelectionWizardPage extends WizardPage {
private static final String SELECT_REPRESENTATIONS_TO_EXPORT = "Select Representations to export";
+ private static final String READ_ONLY_REPRESENTATION_CONTAINER = "The representation container is read only.\r\n Please select another representation.";
+
/** The title of the page. */
private static final String PAGE_TITLE = "Selection of representations to export";
@@ -63,8 +68,8 @@ public class RepresentationsSelectionWizardPage extends WizardPage {
/** The user has not selected one or more diagrams. */
private static final int CODE_NO_SEL = 1;
- /** The user has selected an object that is not a diagram. */
- private static final int CODE_ERROR = 2;
+ /** A representation cannot be extracted because the container is read only */
+ private static final int CODE_ERROR_READONLY = 2;
/** The composite control of the page. */
private Composite pageComposite;
@@ -97,11 +102,7 @@ public class RepresentationsSelectionWizardPage extends WizardPage {
setMessage(SELECT_REPRESENTATIONS_TO_EXPORT, IMessageProvider.INFORMATION);
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
+ @Override
public void createControl(final Composite parent) {
initializeDialogUnits(parent);
@@ -149,12 +150,7 @@ public class RepresentationsSelectionWizardPage extends WizardPage {
* @author cbrun
*/
private class SiriusDiagramSelectionCheckStateListener implements ICheckStateListener {
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
- */
+ @Override
public void checkStateChanged(final CheckStateChangedEvent event) {
final int result = checkSelection(getSelectedElements());
switch (result) {
@@ -163,7 +159,9 @@ public class RepresentationsSelectionWizardPage extends WizardPage {
setMessage(SELECT_REPRESENTATIONS_TO_EXPORT, IMessageProvider.INFORMATION);
setPageComplete(true);
break;
- case CODE_ERROR:
+ case CODE_ERROR_READONLY:
+ setMessage(READ_ONLY_REPRESENTATION_CONTAINER, IMessageProvider.ERROR);
+ setPageComplete(false);
break;
default:
setMessage("Unknown code result", IMessageProvider.ERROR);
@@ -171,21 +169,25 @@ public class RepresentationsSelectionWizardPage extends WizardPage {
break;
}
}
-
}
- private int checkSelection(final Collection<?> selectedItems) {
+ private int checkSelection(final Collection<DRepresentation> selectedRepresentations) {
int result = CODE_OK;
- if (selectedItems.isEmpty()) {
+ if (selectedRepresentations.isEmpty()) {
result = CODE_NO_SEL;
} else {
- final Iterator<?> iterItems = selectedItems.iterator();
- while (iterItems.hasNext()) {
- final Object next = iterItems.next();
- if (!(next instanceof DRepresentation)) {
- result = CODE_ERROR;
+ for (DRepresentation item : selectedRepresentations) {
+ // check permission authority
+ EObject container = item.eContainer();
+ if (container instanceof DRepresentationContainer) {
+ IPermissionAuthority permissionAuthority = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(container);
+ if (permissionAuthority != null && !permissionAuthority.canDeleteInstance(item)) {
+ // Cannot remove representation from the container
+ result = CODE_ERROR_READONLY;
+ break; // quit the while
+ }
}
- }
+ } // while
}
return result;
}
@@ -229,11 +231,6 @@ public class RepresentationsSelectionWizardPage extends WizardPage {
super(tree);
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.dialogs.ContainerCheckedTreeViewer#doCheckStateChanged(java.lang.Object)
- */
@Override
protected void doCheckStateChanged(final Object element) {
//
@@ -310,6 +307,7 @@ public class RepresentationsSelectionWizardPage extends WizardPage {
*
* @return all selected elements.
*/
+ @SuppressWarnings("unchecked")
public Collection<DRepresentation> getSelectedElements() {
final Collection<DRepresentation> result = new HashSet<DRepresentation>();
result.addAll((Collection<? extends DRepresentation>) Arrays.asList(treeViewer.getCheckedElements()));
@@ -317,6 +315,9 @@ public class RepresentationsSelectionWizardPage extends WizardPage {
return result;
}
+ /**
+ * Session content provider.
+ */
private static final class SessionContentProvider implements ITreeContentProvider {
private static Object[] empty = new Object[0];
@@ -339,11 +340,7 @@ public class RepresentationsSelectionWizardPage extends WizardPage {
this.semanticProvider = new AdapterFactoryContentProvider(adapterFactory);
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- */
+ @Override
public Object[] getChildren(final Object parentElement) {
Object[] children = empty;
if (parentElement instanceof Session) {
@@ -386,11 +383,7 @@ public class RepresentationsSelectionWizardPage extends WizardPage {
return filtered.toArray();
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- */
+ @Override
public Object getParent(final Object element) {
if (element instanceof EObject) {
final EObject current = (EObject) element;
@@ -400,39 +393,22 @@ public class RepresentationsSelectionWizardPage extends WizardPage {
return null;
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- */
+ @Override
public boolean hasChildren(final Object element) {
return getChildren(element).length > 0;
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
+ @Override
public Object[] getElements(final Object inputElement) {
return getChildren(inputElement);
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
+ @Override
public void dispose() {
this.semanticProvider.dispose();
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
- * java.lang.Object, java.lang.Object)
- */
+ @Override
public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
// empty
}
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/session/danalysis/DAnalysisSessionHelper.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/session/danalysis/DAnalysisSessionHelper.java
index 05d3a32eaf..389d7e6954 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/session/danalysis/DAnalysisSessionHelper.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/session/danalysis/DAnalysisSessionHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2015 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
@@ -20,8 +20,10 @@ import java.util.Set;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.sirius.business.api.dialect.DialectManager;
import org.eclipse.sirius.business.api.query.DAnalysisQuery;
import org.eclipse.sirius.business.api.query.EObjectQuery;
+import org.eclipse.sirius.business.api.query.RepresentationDescriptionQuery;
import org.eclipse.sirius.business.api.query.URIQuery;
import org.eclipse.sirius.business.api.query.ViewpointQuery;
import org.eclipse.sirius.business.internal.movida.ViewpointSelection;
@@ -210,6 +212,20 @@ public final class DAnalysisSessionHelper {
}
/**
+ * Find an existing container.
+ *
+ * @param analysis
+ * selected analysis
+ * @param representation
+ * the added representation.
+ * @return the free container if found or <code>null</code> otherwise.
+ */
+ public static DRepresentationContainer findContainerForAddedRepresentation(DAnalysis analysis, final DRepresentation representation) {
+ final Viewpoint viewpoint = new RepresentationDescriptionQuery(DialectManager.INSTANCE.getDescription(representation)).getParentViewpoint();
+ return getContainer(analysis, viewpoint);
+ }
+
+ /**
* Find a free container.
*
* @param viewpoint

Back to the top