Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEsteban Dugueperoux2016-03-22 10:26:01 +0000
committerEsteban Dugueperoux2016-04-08 07:16:04 +0000
commit2acb5761b8e4fffc836e0f21354438c3608f3bd6 (patch)
treebd8bf692190bb897a9e573187fbce4428cd4e63e
parentcada3deea0c8ae041bb3c268fe97c7c8cb68808d (diff)
downloadorg.eclipse.sirius-2acb5761b8e4fffc836e0f21354438c3608f3bd6.tar.gz
org.eclipse.sirius-2acb5761b8e4fffc836e0f21354438c3608f3bd6.tar.xz
org.eclipse.sirius-2acb5761b8e4fffc836e0f21354438c3608f3bd6.zip
[490164] Give better feedback on failing session opening
- Have exception cause of failing session opening displayed in ErrorDialog when session opening is done through OpenRepresentationsFileJob. - Now OpenRepresentationsFileJob manages only one session opening instead of a collection of session to open. - Now to avoid concurrent execution of OpenRepresentationsFileJob we use a specific ISchedulingRule defined in AbstractRepresentationsFileJob.DEFAULT_SCHEDULING_RULE, instead of using OpenRepresentationsFileJob.waitOtherJobs() which was provoking sometimes reentrant call exception on IProject TreeItem. - To have ProgressMonitorDialog displayed after an amount of time, we call PlatformUI.getWorkbench().getProgressService().showInDialog() just after OpenRepresentationsFileJob scheduling. In opposite to call of PlatformUI.getWorkbench().getProgressService().busyCursorWhile() done before in OpenRepresentationsFileJob.waitOtherJobs(), this allows to have ErrorDialog display the cause of failing session opening with ProgressMonitorDialog. - Now OpenSessionOnExpandListener hasn't need to call waitOtherJobs since OpenRepresentationsFileJob cannot be executed in concurrency and children of TreeItem appears then ExpandAgainJob is also useless. - Remove Messages.OpenRepresentationsFileJob_initModelingProjectsTask since OpenRepresentationsFileJob has no more need to compute main representations files since it get representationsFileURI directly by constructor, the case of ModelingProjects to manage is now done directly in DefaultModelingProjectResourceListener. - Catch always the RuntimeException only to create an error marker as before. - To avoid several OpenRepresentationsFileJob executed in sequence for a same representationsFileURI, we call ModelingProjectManager.loadAndOpenRepresentationsFile() which detects that a job for a specified representationsFileURI is in execution, instead of calling OpenRepresentationsFileJob.scheduleNewWhenPossible(). - A new method has been added in ModelingProjectManager, a variant of ModelingProjectManager.loadAndOpenRepresentationsFile(URI) with an additional parameter to specify if the session opening job must be a user job or not. - To avoid "The resource tree is locked for modifications." message in console and error log, due to markers deletion/addition not being done in a workspace operation, we add InvalidModelingProjectMarkerUpdaterJob WorkspaceModifyOperation. - ModelingProject.getMainRepresentationsFileURI() no more update workspace resource about markers as this must be done in a workspace aware operation. Bug: 490164 Change-Id: Iacbd8e06277bf70246976e84613d2d424edd9f28 Signed-off-by: Esteban Dugueperoux <esteban.dugueperoux@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/marker/SiriusMarkerNavigationProviderSpec.java22
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.html46
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile3
-rw-r--r--plugins/org.eclipse.sirius.ui/plugin.properties4
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/project/ModelingProjectManager.java13
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/views/modelexplorerview/resourcelistener/DefaultModelingProjectResourceListener.java28
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/session/OpenSessionAction.java7
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/InvalidModelingProjectMarkerUpdaterJob.java70
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/OpenRepresentationsFileJob.java319
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/manager/ModelingProjectManagerImpl.java47
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/model/ModelingModelProvider.java32
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/ManageSessionActionProvider.java12
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/OpenSessionOnExpandListener.java81
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/modelexplorer/ModelExplorerView.java19
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/viewpoint/provider/Messages.java7
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/modelingproject/AbstractRepresentationsFileJob.java30
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/modelingproject/ModelingProject.java25
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/modelingproject/manager/InitializeModelingProjectJob.java17
18 files changed, 385 insertions, 397 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/marker/SiriusMarkerNavigationProviderSpec.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/marker/SiriusMarkerNavigationProviderSpec.java
index 60869377ab..8148ab1ab3 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/marker/SiriusMarkerNavigationProviderSpec.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/marker/SiriusMarkerNavigationProviderSpec.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2009, 2016 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
@@ -17,11 +17,13 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.common.ui.URIEditorInput;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPart;
import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.sirius.business.api.modelingproject.AbstractRepresentationsFileJob;
import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.business.api.session.SessionManager;
import org.eclipse.sirius.diagram.DDiagram;
@@ -37,7 +39,7 @@ import org.eclipse.sirius.diagram.ui.tools.internal.resource.NavigationMarkerCon
import org.eclipse.sirius.ui.business.api.dialect.DialectEditor;
import org.eclipse.sirius.ui.business.api.dialect.DialectUIManager;
import org.eclipse.sirius.ui.business.api.session.SessionEditorInput;
-import org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.OpenRepresentationsFileJob;
+import org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager;
import org.eclipse.sirius.viewpoint.description.validation.ValidationRule;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.PartInitException;
@@ -48,15 +50,9 @@ import org.eclipse.ui.ide.IDE;
* Specification of SiriusMarkerNavigationProvider.
*
* @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a>
- *
*/
public class SiriusMarkerNavigationProviderSpec extends SiriusMarkerNavigationProvider {
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.sirius.diagram.internal.providers.SiriusMarkerNavigationProvider#doGotoMarker(org.eclipse.core.resources.IMarker)
- */
@Override
protected void doGotoMarker(final IMarker marker) {
final String diagramURI = marker.getAttribute(NavigationMarkerConstants.DIAGRAM_URI, null);
@@ -78,7 +74,7 @@ public class SiriusMarkerNavigationProviderSpec extends SiriusMarkerNavigationPr
final SiriusDiagramEditor targetEditor = switchToTargetEditor(defaultEditor, markedResource, markedDiagramURI, markedDiagram);
if (targetEditor != null) {
- final Map editPartRegistry = targetEditor.getDiagramGraphicalViewer().getEditPartRegistry();
+ final Map<?, ?> editPartRegistry = targetEditor.getDiagramGraphicalViewer().getEditPartRegistry();
final EObject targetView = targetEditor.getDiagram().eResource().getEObject(elementId);
if (targetView == null) {
return;
@@ -138,9 +134,13 @@ public class SiriusMarkerNavigationProviderSpec extends SiriusMarkerNavigationPr
Session session = SessionManager.INSTANCE.getExistingSession(sessionResourceUri);
if (session == null) {
// Try to open a session.
- OpenRepresentationsFileJob.scheduleNewWhenPossible(sessionResourceUri, true);
+ ModelingProjectManager.INSTANCE.loadAndOpenRepresentationsFile(sessionResourceUri, true);
// Wait the end of the loading of the representations file
- OpenRepresentationsFileJob.waitOtherJobs();
+ try {
+ Job.getJobManager().join(AbstractRepresentationsFileJob.FAMILY, new NullProgressMonitor());
+ } catch (InterruptedException e) {
+ // Do nothing;
+ }
session = SessionManager.INSTANCE.getExistingSession(sessionResourceUri);
}
return session;
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
index 52ea6141a0..6702e13a7e 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
@@ -106,7 +106,7 @@
<li><span class="label label-info">Modified</span> The
<code>BorderSizeComputationExpression</code> migration has been corrected to recursively handle the sub container mappings. VSM created or migrated with Sirius 3.1.0, 3.1.1 or 3.1.2 might require a manual modification for the style descriptions of sub container mappings with border size computation equals to 0 as we cannot determine if they were added (or updated) after or before the migration: starting with Sirius 3.1.0, no border will be displayed for a 0 pixel value whereas with older version container always had at least a 1 pixel border.
</li>
- <li><span class="label label-info">Modified</span> The variable under VariableFilter, previously named &#8220;Variable&#8221;, is renamed to &#8220;Select Model Element Variable&#8221;. It is functionally equivalent.</li>
+ <li><span class="label label-info">Modified</span> The variable under VariableFilter, previously named &#171;Variable&#187;, is renamed to &#171;Select Model Element Variable&#187;. It is functionally equivalent.</li>
</ul>
<h3 id="DeveloperVisibleChanges">Developer-Visible Changes</h3>
<ul>
@@ -157,6 +157,10 @@
<code>org.eclipse.sirius.ui.tools.api.command.AbstractSWTCallback</code> and
<code>org.eclipse.sirius.tools.api.command.ui.NoUICallback</code>.
</li>
+ <li><span class="label label-success">Added</span>
+ <code>org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager.loadAndOpenRepresentationsFile(URI, boolean)</code> has been added to specify if job used to open a session must be considered as launched by the user or not, because by default with
+ <code>ModelingProjectManager.loadAndOpenRepresentationsFile(URI)</code> the job was not considered as launched by the user.
+ </li>
<li><span class="label label-info">Modified</span>
<code>org.eclipse.sirius.viewpoint.description.tool.SelectModelElementVariable</code> now implements
<code>org.eclipse.sirius.viewpoint.description.InteractiveVariableDescription</code>.
@@ -169,6 +173,9 @@
<code>org.eclipse.sirius.viewpoint.description.tool.SubVariable</code> has been moved to
<code>org.eclipse.sirius.viewpoint.description.SubVariable</code>.
</li>
+ <li><span class="label label-info">Modified</span>
+ <code>org.eclipse.sirius.business.api.modelingproject.ModelingProject.getMainRepresentationsFileURI()</code> methods no more update workspace resource about markers, now this must be done in caller on IllegalArgumentException catch in a workspace aware operation.
+ </li>
<li><span class="label label-danger">Removed</span> The class
<code>org.eclipse.sirius.business.api.extender.MetamodelDescriptorProvider2</code> has been deleted and is now
<code>MetamodelDescriptorProvider</code>.
@@ -236,16 +243,19 @@
</li>
<li><span class="label label-info">Added</span> The new internationalizable label
<code>Messages_createRepresentationInputDialog_DefaultRepresentationDescName</code> has been added (available through
- <code>org.eclipse.sirius.ui.tools.api.Messages.createRepresentationInputDialog_DefaultRepresentationDescName</code>. Its value is &#8220;Representation&#8221;.
+ <code>org.eclipse.sirius.ui.tools.api.Messages.createRepresentationInputDialog_DefaultRepresentationDescName</code>. Its value is &#171;Representation&#187;.
</li>
<li><span class="label label-info">Modified</span> The internationalizable label
- <code>Messages_createRepresentationInputDialog_NewRepresentationNameLabel</code> has been replaced by &#8220;Name:&#8221; (previous value was &#8220;Representation name:&#8221;).
+ <code>Messages_createRepresentationInputDialog_NewRepresentationNameLabel</code> has been replaced by &#171;Name:&#187; (previous value was &#171;Representation name:&#187;).
</li>
<li><span class="label label-info">Modified</span> The internationalizable label
- <code>Messages_createRepresentationInputDialog_RepresentationDescriptionLabel</code> has been replaced by &#8220;Representation description: {0}&#8221; (previous value was &#8220;Representation description: &#8221;).
+ <code>Messages_createRepresentationInputDialog_RepresentationDescriptionLabel</code> has been replaced by &#171;Representation description: {0}&#187; (previous value was &#171;Representation description: &#187;).
</li>
<li><span class="label label-info">Modified</span> The internationalizable label
- <code>Messages_createRepresentationInputDialog_Title</code> has been replaced by &#8220;New {0}&#8221; (previous value was &#8220;New Representation&#8221;).
+ <code>Messages_createRepresentationInputDialog_Title</code> has been replaced by &#171;New {0}&#187; (previous value was &#171;New Representation&#187;).
+ </li>
+ <li><span class="label label-danger">Removed</span> The internationalizable label
+ <code>org.eclipse.sirius.viewpoint.provider.Messages.OpenRepresentationsFileJob_initModelingProjectsTask</code> has been removed as this message is no more used.
</li>
<li><span class="label label-danger">Removed</span> The class
<code>org.eclipse.sirius.ui.business.api.editor.SpecificSessionManager</code> has been removed.
@@ -465,7 +475,7 @@
</ul>
<h3 id="DeveloperVisibleChanges3">Developer-Visible Changes</h3>
<h4 id="Partialsupportforinternationalization">Partial support for internationalization</h4>
- <p>Sirius 3.1 introduces partial support for internationalization: all literal strings from the runtime part of Sirius are now externalized and can be localized by third parties by providing the appropriate &#8220;language packs&#8221; as OSGi fragments. Note that this does not concern the VSM editor&#8217;s UI, the VSMs themselves, or the parts of the UI inherited from Eclipse/EMF/GEF/GMF and other libraries and frameworks used by Sirius.</p>
+ <p>Sirius 3.1 introduces partial support for internationalization: all literal strings from the runtime part of Sirius are now externalized and can be localized by third parties by providing the appropriate &#171;language packs&#187; as OSGi fragments. Note that this does not concern the VSM editor&#8217;s UI, the VSMs themselves, or the parts of the UI inherited from Eclipse/EMF/GEF/GMF and other libraries and frameworks used by Sirius.</p>
<p>Some API changes were required to enable this. While technically breaking changes if interpreting strictly the OSGi versioning rules, the major version number of the impacted bundles was not incremented as the changes only concern classes that should not impact the vast majority of users. Most breaking changes concern the plug-in/activator classes from each bundle. They are:</p>
<ul>
<li><span class="label label-success">Added</span>
@@ -943,7 +953,7 @@
</li>
<li><span class="label label-success">Added</span> On diagrams, it is now possible to set a custom background image on list containers.</li>
<li><span class="label label-info">Modified</span> In the
- <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.
+ <em>Viewpoint Selection</em> dialog and wizard page, 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. 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>
@@ -966,12 +976,12 @@
<li><span class="label label-success">Added</span> Compressed SVG images (
<code>*.svgz</code>) are now supported everywhere normal SVG images were supported.
</li>
- <li><span class="label label-success">Added</span> When developing a modeler in &#8220;live mode&#8221;, with the VSM in the same workspace as the sample session(s) which use it, VSM expressions which use
+ <li><span class="label label-success">Added</span> When developing a modeler in &#171;live mode&#187;, with the VSM in the same workspace as the sample session(s) which use it, VSM expressions which use
<code>service:</code> or
<code>aql:</code> can now invoke Java services which are defined in the workspace (with no need to launch a separate runtime).
</li>
<li><span class="label label-success">Added</span> A quick outline is now accessible in the VSM editor by using the shortcut <kbd>Ctrl+o</kbd>. It supports filtering on both an element&#8217;s name and properties for quick, keyboard-only navigation in complex VSMs.</li>
- <li><span class="label label-success">Added</span> The &#8220;hide label by default capability&#8221; has been added to the container styles.</li>
+ <li><span class="label label-success">Added</span> The &#171;hide label by default capability&#187; has been added to the container styles.</li>
<li><span class="label label-success">Added</span> In addition to
<em>Bold</em> and
<em>Italic</em>,
@@ -1004,7 +1014,7 @@
</li>
<li><span class="label label-success">Improved</span> The precision of the VSM validation, especially regarding the typing of computed expressions, has been greatly improved. Other validation rules like static image paths have also been added or improved.</li>
<li><span class="label label-info">Modified</span> In the VSM editor, the context menu entries (categories and items) have been reorganized to put most common actions/items first.</li>
- <li><span class="label label-info">Modified</span> In diagrams, the style previously named &#8220;Lozenge&#8221; is now called &#8220;Diamond&#8221;.</li>
+ <li><span class="label label-info">Modified</span> In diagrams, the style previously named &#171;Lozenge&#187; is now called &#171;Diamond&#187;.</li>
<li><span class="label label-info">Modified</span> In the
<em>Open</em> menu on a representation, the menu is computed from the navigation tool&#8217;s label instead of its name/id.
</li>
@@ -1887,13 +1897,13 @@
<img border="0" src="images/containerResize-changedBehavior.gif"/>
</p>
<ul>
- <li>The &#8220;snap to shapes&#8221; is now enabled by default (see
+ <li>The &#171;snap to shapes&#187; 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 &#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:
+ <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:
<ul>
- <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>
+ <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>
</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>
@@ -1918,19 +1928,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 &#8220;Remove Bend-points&#8221; or by using the shortcut &#8220;Ctrl&#8221; + &#8220;Shift&#8221; + &#8220;-&#8221;.</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>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="SpecifierVisibleChanges5">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 &#8220;advance&#8221; 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 &#171;advance&#187; 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 &#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.
+ <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.
</li>
- <li>&#8220;Lozenge&#8221; is replaced by &#8220;Diamond&#8221; in diagram style.</li>
+ <li>&#171;Lozenge&#187; is replaced by &#171;Diamond&#187; in diagram style.</li>
</ul>
<h3 id="APIChanges">API Changes</h3>
<h4 id="Changesinorg.eclipse.sirius5">Changes in
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
index 471dfca9b9..2afc55fb09 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
@@ -38,9 +38,11 @@ h4. Changes in @org.eclipse.sirius@
* <span class="label label-success">Added</span> @org.eclipse.sirius.business.api.dialect.AbstractRepresentationDialectServices.getRequiredViewpoints(DRepresentation)@ has been added to have a default implementation of @DialectServices.getRequiredViewpoints(DRepresentation)@ method.
* <span class="label label-success">Added</span> @org.eclipse.sirius.business.api.dialect.AbstractRepresentationDialectServices.isRelatedViewpointSelected(Session, RepresentationDescription)@ protected method has been added to check if a @RepresentationDescription@ is usable in the context of the specified session.
* <span class="label label-success">Added</span> @org.eclipse.sirius.tools.api.command.ui.UICallBack.askForDetailName(String, String, String)@ method has been added to replace the deprecated @org.eclipse.sirius.tools.api.command.ui.UICallBack.askForDetailName(String, String)@. This method now uses the description name as title for the wizard. This new method has been implemented by @org.eclipse.sirius.ui.tools.api.command.AbstractSWTCallback@ and @org.eclipse.sirius.tools.api.command.ui.NoUICallback@.
+* <span class="label label-success">Added</span> @org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager.loadAndOpenRepresentationsFile(URI, boolean)@ has been added to specify if job used to open a session must be considered as launched by the user or not, because by default with @ModelingProjectManager.loadAndOpenRepresentationsFile(URI)@ the job was not considered as launched by the user.
* <span class="label label-info">Modified</span> @org.eclipse.sirius.viewpoint.description.tool.SelectModelElementVariable@ now implements @org.eclipse.sirius.viewpoint.description.InteractiveVariableDescription@.
* <span class="label label-info">Modified</span> @org.eclipse.sirius.viewpoint.description.tool.AbstractVariable@ has been moved to @org.eclipse.sirius.viewpoint.description.AbstractVariable@.
* <span class="label label-info">Modified</span> @org.eclipse.sirius.viewpoint.description.tool.SubVariable@ has been moved to @org.eclipse.sirius.viewpoint.description.SubVariable@.
+* <span class="label label-info">Modified</span> @org.eclipse.sirius.business.api.modelingproject.ModelingProject.getMainRepresentationsFileURI()@ methods no more update workspace resource about markers, now this must be done in caller on IllegalArgumentException catch in a workspace aware operation.
* <span class="label label-danger">Removed</span> The class @org.eclipse.sirius.business.api.extender.MetamodelDescriptorProvider2@ has been deleted and is now @MetamodelDescriptorProvider@.
h4. Changes in @org.eclipse.sirius.common@
@@ -67,6 +69,7 @@ h4. Changes in @org.eclipse.sirius.ui@
* <span class="label label-info">Modified</span> The internationalizable label @Messages_createRepresentationInputDialog_NewRepresentationNameLabel@ has been replaced by "Name:" (previous value was "Representation name:").
* <span class="label label-info">Modified</span> The internationalizable label @Messages_createRepresentationInputDialog_RepresentationDescriptionLabel@ has been replaced by "Representation description: {0}" (previous value was "Representation description: ").
* <span class="label label-info">Modified</span> The internationalizable label @Messages_createRepresentationInputDialog_Title@ has been replaced by "New {0}" (previous value was "New Representation").
+* <span class="label label-danger">Removed</span> The internationalizable label @org.eclipse.sirius.viewpoint.provider.Messages.OpenRepresentationsFileJob_initModelingProjectsTask@ has been removed as this message is no more used.
* <span class="label label-danger">Removed</span> The class @org.eclipse.sirius.ui.business.api.editor.SpecificSessionManager@ has been removed.
h4. Changes in @org.eclipse.sirius.diagram.ui@
diff --git a/plugins/org.eclipse.sirius.ui/plugin.properties b/plugins/org.eclipse.sirius.ui/plugin.properties
index 4ae10f7338..babf920ff1 100644
--- a/plugins/org.eclipse.sirius.ui/plugin.properties
+++ b/plugins/org.eclipse.sirius.ui/plugin.properties
@@ -1,5 +1,5 @@
# ====================================================================
-# Copyright (c) 2007, 2014, 2015 THALES GLOBAL SERVICES and others.
+# Copyright (c) 2007, 2016 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
@@ -199,7 +199,6 @@ OpenRepresentationsAction_name = Open
OpenRepresentationsAction_openRepresentationTask = Open representation...
OpenRepresentationsAction_openRepresentationsTask = Open representations...
OpenRepresentationsFileJob_errorInvalidInputList = This list must be a list of URI or a list of ModelingProject.
-OpenRepresentationsFileJob_initModelingProjectsTask = Initialize modeling projects
OpenRepresentationsFileJob_invalidModelingProjectsError = Several modeling projects are invalid or can not be opened.
OpenRepresentationsFileJob_label = Loading models
OpenRepresentationsFileJob_loadReferencedModelsTask = Loading referenced models of "{0}"
@@ -382,6 +381,7 @@ migrateODesignToODesignActionLabel=Migrate Description File
navigatorContent.siriusContent.name = Sirius Content Management
propertyTab.default.label = Default
repairActionLabel=Repair
+InvalidModelingProjectMarkerUpdaterJob_updateMarkers = Update Markers
_Pref_RefreshOnRepresentationOpening = true
_Pref_AutoRefresh = true
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/project/ModelingProjectManager.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/project/ModelingProjectManager.java
index 3b85f67370..19182a4c10 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/project/ModelingProjectManager.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/project/ModelingProjectManager.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
@@ -39,6 +39,17 @@ public interface ModelingProjectManager {
void loadAndOpenRepresentationsFile(URI representationsFileURI);
/**
+ * Load and open a representations file.
+ *
+ * @param representationsFileURI
+ * The URI of the representations file to open.
+ * @param user
+ * <code>true</code> if this job is a user-initiated job, and
+ * <code>false</code> otherwise.
+ */
+ void loadAndOpenRepresentationsFile(URI representationsFileURI, boolean user);
+
+ /**
* Load and open representations files.
*
* @param representationsFilesURIs
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/views/modelexplorerview/resourcelistener/DefaultModelingProjectResourceListener.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/views/modelexplorerview/resourcelistener/DefaultModelingProjectResourceListener.java
index 7b70b6ae77..f9df3d454e 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/views/modelexplorerview/resourcelistener/DefaultModelingProjectResourceListener.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/views/modelexplorerview/resourcelistener/DefaultModelingProjectResourceListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 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,7 +10,6 @@
*******************************************************************************/
package org.eclipse.sirius.ui.tools.api.views.modelexplorerview.resourcelistener;
-import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Set;
@@ -20,6 +19,7 @@ import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.ResourceSet;
@@ -30,8 +30,10 @@ import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.business.internal.modelingproject.manager.AttachSemanticResourcesJob;
import org.eclipse.sirius.business.internal.modelingproject.manager.InitializeModelingProjectJob;
import org.eclipse.sirius.common.tools.api.resource.ResourceSetFactory;
+import org.eclipse.sirius.ext.base.Option;
+import org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager;
+import org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.InvalidModelingProjectMarkerUpdaterJob;
import org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.ModelingProjectFileQuery;
-import org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.OpenRepresentationsFileJob;
import org.eclipse.sirius.viewpoint.provider.SiriusEditPlugin;
import com.google.common.collect.Lists;
@@ -68,11 +70,6 @@ public class DefaultModelingProjectResourceListener implements IModelingProjectR
workspace.removeResourceChangeListener(this);
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
- */
@Override
public void resourceChanged(IResourceChangeEvent event) {
IResourceDelta delta = event.getDelta();
@@ -100,8 +97,19 @@ public class DefaultModelingProjectResourceListener implements IModelingProjectR
// Launch the silently job to initialize the modeling
// projects and then open the main representations files of
// each projects.
- OpenRepresentationsFileJob.scheduleNewWhenPossible(new ArrayList<ModelingProject>(visitor.projectsToInitializeAndLoad), false);
-
+ for (ModelingProject modelingProject : visitor.projectsToInitializeAndLoad) {
+ try {
+ Option<URI> mainRepresentationsFileURIOption = modelingProject.getMainRepresentationsFileURI(new NullProgressMonitor(), true, true);
+ if (mainRepresentationsFileURIOption.some()) {
+ URI mainRepresentationsFileURI = mainRepresentationsFileURIOption.get();
+ ModelingProjectManager.INSTANCE.loadAndOpenRepresentationsFile(mainRepresentationsFileURI, true);
+ }
+ } catch (IllegalArgumentException e) {
+ IProject project = modelingProject.getProject();
+ Job invalidModelingProjectMarkerUpdaterJob = new InvalidModelingProjectMarkerUpdaterJob(project, e.getMessage());
+ invalidModelingProjectMarkerUpdaterJob.schedule();
+ }
+ }
}
if (!visitor.semanticResourcesURIsToAttachPerSession.isEmpty()) {
Job attachSemanticResourcesJob = new AttachSemanticResourcesJob(new LinkedHashMap<Session, Set<URI>>(visitor.semanticResourcesURIsToAttachPerSession));
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/session/OpenSessionAction.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/session/OpenSessionAction.java
index 346657de36..4485f06601 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/session/OpenSessionAction.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/session/OpenSessionAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 THALES GLOBAL SERVICES.
+ * Copyright (c) 2008, 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
@@ -18,7 +18,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.sirius.business.api.helper.SiriusUtil;
import org.eclipse.sirius.common.tools.DslCommonPlugin;
import org.eclipse.sirius.tools.api.profiler.SiriusTasksKey;
-import org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.OpenRepresentationsFileJob;
+import org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager;
import org.eclipse.ui.actions.SelectionListenerAction;
import com.google.common.collect.Iterables;
@@ -69,7 +69,8 @@ public class OpenSessionAction extends SelectionListenerAction {
DslCommonPlugin.PROFILER.startWork(SiriusTasksKey.OPEN_SESSION_ACTION_KEY);
for (IFile selectedFile : selectedFiles) {
if (SiriusUtil.SESSION_RESOURCE_EXTENSION.equals(selectedFile.getFileExtension())) {
- OpenRepresentationsFileJob.scheduleNewWhenPossible(URI.createPlatformResourceURI(selectedFile.getFullPath().toOSString(), true), true);
+ URI sessionResourceURI = URI.createPlatformResourceURI(selectedFile.getFullPath().toOSString(), true);
+ ModelingProjectManager.INSTANCE.loadAndOpenRepresentationsFile(sessionResourceURI, true);
}
}
} finally {
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/InvalidModelingProjectMarkerUpdaterJob.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/InvalidModelingProjectMarkerUpdaterJob.java
new file mode 100644
index 0000000000..f66f757c3f
--- /dev/null
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/InvalidModelingProjectMarkerUpdaterJob.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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
+ *******************************************************************************/
+package org.eclipse.sirius.ui.tools.internal.views.common.modelingproject;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.sirius.business.internal.modelingproject.marker.ModelingMarker;
+import org.eclipse.sirius.viewpoint.SiriusPlugin;
+import org.eclipse.sirius.viewpoint.provider.Messages;
+
+/**
+ * A {@link WorkspaceJob} to update markers for a invalid project.
+ *
+ * @author <a href="mailto:esteban.dugueperoux@obeo.fr">Esteban Dugueperoux</a>
+ */
+public class InvalidModelingProjectMarkerUpdaterJob extends WorkspaceJob {
+
+ private IProject project;
+
+ private String message;
+
+ /**
+ * Default constructor.
+ *
+ * @param project
+ * the project for which update markers to mark this project as
+ * invalid
+ * @param message
+ * the message to display in marker
+ */
+ public InvalidModelingProjectMarkerUpdaterJob(IProject project, String message) {
+ super(Messages.InvalidModelingProjectMarkerUpdaterJob_updateMarkers);
+ this.project = project;
+ this.message = message;
+ }
+
+ @Override
+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+ // Clean existing marker if exists
+ try {
+ project.deleteMarkers(ModelingMarker.MARKER_TYPE, false, IResource.DEPTH_ZERO);
+ } catch (final CoreException ce) {
+ SiriusPlugin.getDefault().getLog().log(ce.getStatus());
+ }
+ // Add a marker on this project
+ try {
+ final IMarker marker = project.createMarker(ModelingMarker.MARKER_TYPE);
+ marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
+ marker.setAttribute(IMarker.MESSAGE, message);
+ } catch (final CoreException ce) {
+ SiriusPlugin.getDefault().getLog().log(ce.getStatus());
+ }
+ return Status.OK_STATUS;
+ }
+
+}
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/OpenRepresentationsFileJob.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/OpenRepresentationsFileJob.java
index 949be091f4..8e765417f8 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/OpenRepresentationsFileJob.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/OpenRepresentationsFileJob.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2011, 2016 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
@@ -13,9 +13,6 @@ package org.eclipse.sirius.ui.tools.internal.views.common.modelingproject;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.MessageFormat;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
@@ -24,20 +21,16 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource.Diagnostic;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.sirius.business.api.helper.SiriusUtil;
import org.eclipse.sirius.business.api.modelingproject.AbstractRepresentationsFileJob;
import org.eclipse.sirius.business.api.modelingproject.ModelingProject;
import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.business.api.session.SessionManager;
-import org.eclipse.sirius.business.internal.modelingproject.manager.InitializeModelingProjectJob;
import org.eclipse.sirius.business.internal.modelingproject.marker.ModelingMarker;
import org.eclipse.sirius.common.tools.api.util.MarkerUtil;
import org.eclipse.sirius.ext.base.Option;
@@ -47,41 +40,24 @@ import org.eclipse.sirius.ui.business.api.session.SessionUIManager;
import org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager;
import org.eclipse.sirius.viewpoint.SiriusPlugin;
import org.eclipse.sirius.viewpoint.provider.Messages;
-import org.eclipse.sirius.viewpoint.provider.SiriusEditPlugin;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.statushandlers.StatusManager;
-
-import com.google.common.base.Predicates;
-import com.google.common.collect.Iterators;
-import com.google.common.collect.Lists;
/**
- * A job to load one or more representations files (load the aird file and all
- * the referenced resource). Warning before calling this job you must call
+ * A job to load one representations files (load the aird file and all the
+ * referenced resource). Warning before calling this job you must call
* waitOtherJobs methods to ensure that there is no job of this kind currently
* running.
*
* @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a>
*/
public class OpenRepresentationsFileJob extends AbstractRepresentationsFileJob {
- /**
- * The default label for the job that open a representations file.
- */
- public static final String JOB_LABEL = Messages.OpenRepresentationsFileJob_label;
- /**
- * The list of representations files to load. This list is exclusive with
- * the list of modeling projects.
- */
- List<URI> representationsFilesURIs = Lists.newArrayList();
+ /** The default label for the job that open a representations file. */
+ public static final String JOB_LABEL = Messages.OpenRepresentationsFileJob_label;
- /**
- * The list of modeling projects to initialize and for which to load the
- * main representations file. This list is exclusive with the list of
- * representations files.
- */
- List<ModelingProject> modelingProjects = Lists.newArrayList();
+ /** The {@link URI} of the representations file to open. */
+ private URI representationsFileURI;
/**
* Constructor to open only one representations file.
@@ -91,23 +67,7 @@ public class OpenRepresentationsFileJob extends AbstractRepresentationsFileJob {
*/
public OpenRepresentationsFileJob(final URI representationsFileURI) {
super(OpenRepresentationsFileJob.JOB_LABEL);
- this.representationsFilesURIs.add(representationsFileURI);
- }
-
- /**
- * Constructor to open several representations files.
- *
- * @param elements
- * A list of URIs of the representations files to open or a list
- * of the modeling projects to initialize and open.
- */
- public OpenRepresentationsFileJob(List<? extends Object> elements) {
- super(OpenRepresentationsFileJob.JOB_LABEL);
- if (!(Iterators.all(elements.iterator(), Predicates.instanceOf(URI.class)) || Iterators.all(elements.iterator(), Predicates.instanceOf(ModelingProject.class)))) {
- throw new IllegalArgumentException(Messages.OpenRepresentationsFileJob_errorInvalidInputList);
- }
- Iterators.addAll(this.representationsFilesURIs, Iterators.filter(elements.iterator(), URI.class));
- Iterators.addAll(this.modelingProjects, Iterators.filter(elements.iterator(), ModelingProject.class));
+ this.representationsFileURI = representationsFileURI;
}
/**
@@ -120,143 +80,107 @@ public class OpenRepresentationsFileJob extends AbstractRepresentationsFileJob {
* <code>false</code> otherwise.
*/
public static void scheduleNewWhenPossible(URI representationsFileURI, boolean user) {
- // Just wait other job if some are already in progress
- OpenRepresentationsFileJob.waitOtherJobs();
-
// Schedule a new job for this representations file.
Job job = new OpenRepresentationsFileJob(representationsFileURI);
job.setUser(user);
job.setPriority(Job.SHORT);
job.schedule();
- }
-
- /**
- * Launch this job when all other openRepresentationFile's job are finished.
- *
- * @param elements
- * A list of URIs of the representations files to open or a list
- * of the modeling projects to initialize and open.
- * @param user
- * <code>true</code> if this job is a user-initiated job, and
- * <code>false</code> otherwise.
- */
- public static void scheduleNewWhenPossible(List<? extends Object> elements, boolean user) {
- if (!(Iterators.all(elements.iterator(), Predicates.instanceOf(URI.class)) || Iterators.all(elements.iterator(), Predicates.instanceOf(ModelingProject.class)))) {
- throw new IllegalArgumentException(Messages.OpenRepresentationsFileJob_errorInvalidInputList);
+ IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (activeWorkbenchWindow != null) {
+ PlatformUI.getWorkbench().getProgressService().showInDialog(activeWorkbenchWindow.getShell(), job);
}
-
- // Just wait other job if some are already in progress
- OpenRepresentationsFileJob.waitOtherJobs();
-
- // Schedule a new job for this representations file.
- Job job = new OpenRepresentationsFileJob(elements);
- job.setUser(user);
- job.setPriority(Job.SHORT);
- job.schedule();
}
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) {
- IStatus initializationStatus = Status.OK_STATUS;
- List<IStatus> openingStatuses = Lists.newArrayList();
+ SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.OpenRepresentationsFileJob_loadingModelsTask, 100);
+ // Clean existing marker if exists
+ IProject project = null;
try {
- monitor.beginTask(Messages.OpenRepresentationsFileJob_loadingModelsTask, 11);
- monitor.subTask(Messages.OpenRepresentationsFileJob_initModelingProjectsTask);
- if (!modelingProjects.isEmpty()) {
- // Initialize the modeling projects before open the main
- // representations files.
- List<IProject> projects = Lists.newArrayList();
- for (ModelingProject modelingProject : modelingProjects) {
- projects.add(modelingProject.getProject());
+ if (representationsFileURI.isPlatform()) {
+ String projectName = URI.decode(representationsFileURI.segment(1));
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ }
+ try {
+ if (project != null) {
+ project.deleteMarkers(ModelingMarker.MARKER_TYPE, false, IResource.DEPTH_ZERO);
}
- initializationStatus = InitializeModelingProjectJob.initializeModelingProjects(projects, true, new SubProgressMonitor(monitor, 2));
+ } catch (final CoreException e) {
+ SiriusPlugin.getDefault().getLog().log(e.getStatus());
+ }
- SubProgressMonitor getRepresentationsFilesMonitor = new SubProgressMonitor(monitor, 1);
- try {
- getRepresentationsFilesMonitor.beginTask("", modelingProjects.size()); //$NON-NLS-1$
- for (ModelingProject modelingProject : modelingProjects) {
- Option<URI> optionalMainSessionFileURI = modelingProject.getMainRepresentationsFileURI(new SubProgressMonitor(getRepresentationsFilesMonitor, 1), false, false);
- if (optionalMainSessionFileURI.some()) {
- representationsFilesURIs.add(optionalMainSessionFileURI.get());
- }
- }
- } finally {
- getRepresentationsFilesMonitor.done();
- }
- } else {
- monitor.worked(3);
+ subMonitor.subTask(MessageFormat.format(Messages.OpenRepresentationsFileJob_loadingRepresentationFileTask, representationsFileURI.lastSegment()));
+ Session session = performOpenSession(subMonitor.newChild(90));
+ if (session != null) {
+ monitor.subTask(MessageFormat.format(Messages.OpenRepresentationsFileJob_openingStartRepresentationTask, representationsFileURI.lastSegment()));
+ // Open the startup representations of each session
+ SessionHelper.openStartupRepresentations(session, subMonitor.newChild(10));
}
- SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, 8);
- try {
- subMonitor.beginTask("", 100 * representationsFilesURIs.size()); //$NON-NLS-1$
- for (URI representationsFileURI : representationsFilesURIs) {
- // Clean existing marker if exists
- IProject project = null;
- if (representationsFileURI.isPlatform()) {
- String projectName = URI.decode(representationsFileURI.segment(1));
- project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- }
- try {
- if (project != null) {
- project.deleteMarkers(ModelingMarker.MARKER_TYPE, false, IResource.DEPTH_ZERO);
- }
- } catch (final CoreException e) {
- SiriusPlugin.getDefault().getLog().log(e.getStatus());
- }
+ // CHECKSTYLE:OFF to add a marker on this project
+ } catch (RuntimeException e) {
+ // CHECKSTYLE:ON
+ String message = markeModelingProjectAsInvalid(project, e);
+ throw new RuntimeException(message, e);
+ } finally {
+ monitor.done();
+ }
+ return Status.OK_STATUS;
+ }
- subMonitor.subTask(MessageFormat.format(Messages.OpenRepresentationsFileJob_loadingRepresentationFileTask, representationsFileURI.lastSegment()));
- final Set<Session> sessions = performOpenSession(representationsFileURI, new SubProgressMonitor(subMonitor, 90));
- if (sessions.isEmpty()) {
- subMonitor.worked(10);
- String errorMessage = logLoadingProblem(project, representationsFileURI, null);
- openingStatuses.add(new Status(IStatus.ERROR, SiriusEditPlugin.ID, IStatus.OK, errorMessage, null));
- } else {
- subMonitor.subTask(MessageFormat.format(Messages.OpenRepresentationsFileJob_openingStartRepresentationTask, representationsFileURI.lastSegment()));
- // Open the startup representations of each session
- for (final Session session : sessions) {
- SessionHelper.openStartupRepresentations(session, new SubProgressMonitor(subMonitor, 10 / sessions.size()));
- }
+ /**
+ * Open session.
+ *
+ * @param monitor
+ * the progress monitor.
+ * @return the opened session.
+ */
+ private Session performOpenSession(IProgressMonitor monitor) {
+ Session session = null;
+ try {
+ SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.OpenRepresentationsFileJob_loadRepresentationsTask, 16);
+ if (SiriusUtil.SESSION_RESOURCE_EXTENSION.equals(representationsFileURI.fileExtension())) {
+ subMonitor.worked(1);
+ session = SessionManager.INSTANCE.getSession(representationsFileURI, subMonitor.newChild(10));
+ // Open the session if needed (load the referenced models by
+ // a ResolveAll call)
+ subMonitor.subTask(MessageFormat.format(Messages.OpenRepresentationsFileJob_loadReferencedModelsTask, representationsFileURI.lastSegment()));
+ if (session != null) {
+ if (!session.isOpen()) {
+ session.open(subMonitor.newChild(4));
+ }
+ IEditingSession editingSession = SessionUIManager.INSTANCE.getOrCreateUISession(session);
+ if (!editingSession.isOpen()) {
+ editingSession.open();
}
}
- } finally {
- subMonitor.done();
+ subMonitor.worked(1);
}
} finally {
monitor.done();
}
- List<IStatus> allStatuses = Lists.newArrayList(openingStatuses);
- if (!initializationStatus.isOK()) {
- if (initializationStatus instanceof MultiStatus) {
- allStatuses.addAll(0, Lists.newArrayList(((MultiStatus) initializationStatus).getChildren()));
- } else {
- allStatuses.add(0, initializationStatus);
- }
- }
-
- IStatus result = Status.OK_STATUS;
- if (allStatuses.size() == 1) {
- result = allStatuses.get(0);
- } else if (allStatuses.size() > 1) {
- result = new MultiStatus(SiriusEditPlugin.ID, IStatus.ERROR, allStatuses.toArray(new IStatus[0]), Messages.OpenRepresentationsFileJob_invalidModelingProjectsError, null);
- }
-
- return result;
+ return session;
}
/**
- * Log loading problem (Add a marker on this project, change valid status of
- * this modeling project, clean the cache of the ModelingProjectManager).
+ * Marks the {@link ModelingProject} associated to the specified
+ * <code>project</code> as invalid :
+ *
+ * <ul>
+ * <li>add a error marker to the project</li>
+ * <li>mark the associated {@link IProject} as invalid</li>
+ * <li>clear the cache of {@link ModelingProjectManager} about this
+ * {@link ModelingProject}</li>
+ * </ul>
*
* @param project
- * The project concerned by this problem.
- * @param representationsFileURI
- * The URI of the representations file concerned by this problem.
+ * the project associated to the {@link ModelingProject}.
* @param exception
- * The thrown exception
- * @return The error message.
+ * the {@link RuntimeException} origin of the failing session
+ * opening
+ * @return the error message to dispatch.
*/
- protected String logLoadingProblem(IProject project, URI representationsFileURI, Exception exception) {
- String message = ""; //$NON-NLS-1$
+ private String markeModelingProjectAsInvalid(IProject project, RuntimeException exception) {
+ String message = null;
if (project != null) {
boolean isModelingProject = ModelingProject.hasModelingProjectNature(project);
final String errorDetail;
@@ -287,83 +211,6 @@ public class OpenRepresentationsFileJob extends AbstractRepresentationsFileJob {
}
/**
- * Open session.
- *
- * @param representationsFileURI
- * The URI of the representations file corresponding to the
- * session to opened.
- * @param monitor
- * the progress monitor.
- * @return Resource associated to session.
- */
- public Set<Session> performOpenSession(URI representationsFileURI, IProgressMonitor monitor) {
- Set<Session> openedSessions = new HashSet<Session>();
- try {
- monitor.beginTask(Messages.OpenRepresentationsFileJob_loadRepresentationsTask, 16);
- if (SiriusUtil.SESSION_RESOURCE_EXTENSION.equals(representationsFileURI.fileExtension())) {
- monitor.worked(1);
- Session session = SessionManager.INSTANCE.getSession(representationsFileURI, new SubProgressMonitor(monitor, 10));
- // Open the session if needed (load the referenced models by
- // a ResolveAll call)
- monitor.subTask(MessageFormat.format(Messages.OpenRepresentationsFileJob_loadReferencedModelsTask, representationsFileURI.lastSegment()));
- if (session != null) {
- if (!session.isOpen()) {
- session.open(new SubProgressMonitor(monitor, 4));
- }
- IEditingSession editingSession;
- // JGO : Do not create an editing session in case the
- // session is
- // null
- // the session could be null if the session is not a local
- // session (CDO for example) and
- // if the remote CDO server is unreachable
- editingSession = SessionUIManager.INSTANCE.getOrCreateUISession(session);
- if (!editingSession.isOpen()) {
- editingSession.open();
- }
- if (openedSessions != null) {
- openedSessions.add(session);
- }
- }
- monitor.worked(1);
- }
- // CHECKSTYLE:OFF
- } catch (RuntimeException e) {
- // CHECKSTYLE:ON
- SiriusEditPlugin.getPlugin().log(e);
- } finally {
- monitor.done();
- }
- return openedSessions;
- }
-
- /**
- * Waits until all jobs of this kind are finished. This method must be
- * called from UI Thread.
- */
- public static void waitOtherJobs() {
- if (OpenRepresentationsFileJob.shouldWaitOtherJobs()) {
- try {
- if (Display.getCurrent() != null) {
- PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InterruptedException {
- Job.getJobManager().join(AbstractRepresentationsFileJob.FAMILY, monitor);
- }
- });
- } else {
- Job.getJobManager().join(AbstractRepresentationsFileJob.FAMILY, new NullProgressMonitor());
- }
- } catch (InvocationTargetException e) {
- StatusManager.getManager()
- .handle(new Status(IStatus.ERROR, SiriusEditPlugin.ID, IStatus.OK, OpenRepresentationsFileJob.getLocalizedMessage(e), OpenRepresentationsFileJob.getCause(e)));
- } catch (InterruptedException e) {
- // Do nothing;
- }
- }
- }
-
- /**
* Check if other jobs of this kind are running. This method must be called
* from UI Thread.
*
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/manager/ModelingProjectManagerImpl.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/manager/ModelingProjectManagerImpl.java
index 80a5acf1b8..dd264ecd22 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/manager/ModelingProjectManagerImpl.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/manager/ModelingProjectManagerImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2011, 2016 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
@@ -18,6 +18,7 @@ import java.util.Set;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
@@ -27,6 +28,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
@@ -35,6 +37,7 @@ import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.sirius.business.api.modelingproject.AbstractRepresentationsFileJob;
import org.eclipse.sirius.business.api.modelingproject.ModelingProject;
import org.eclipse.sirius.business.api.query.ResourceQuery;
import org.eclipse.sirius.business.api.resource.LoadEMFResource;
@@ -51,6 +54,7 @@ import org.eclipse.sirius.tools.api.command.semantic.AddSemanticResourceCommand;
import org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager;
import org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.ModelingProjectFileQuery;
import org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.OpenRepresentationsFileJob;
+import org.eclipse.sirius.viewpoint.SiriusPlugin;
import org.eclipse.sirius.viewpoint.provider.Messages;
import org.eclipse.sirius.viewpoint.provider.SiriusEditPlugin;
@@ -75,7 +79,7 @@ public class ModelingProjectManagerImpl implements ModelingProjectManager {
public void notify(Session updated, int notification) {
if (notification == SessionListener.OPENING) {
// No need to at it again to the sessionFileLoading list because
- // we add it during the starting of the load
+ // we add it during the starting of the load
// ModelingProjectManager.loadAndOpenSession().
} else if (notification == SessionListener.OPENED) {
sessionFileLoading.remove(updated.getSessionResource().getURI());
@@ -114,11 +118,20 @@ public class ModelingProjectManagerImpl implements ModelingProjectManager {
@Override
public void loadAndOpenRepresentationsFile(final URI representationsFileURI) {
- loadAndOpenRepresentationsFiles(Lists.newArrayList(representationsFileURI));
+ loadAndOpenRepresentationsFiles(Lists.newArrayList(representationsFileURI), false);
+ }
+
+ @Override
+ public void loadAndOpenRepresentationsFile(final URI representationsFileURI, boolean user) {
+ loadAndOpenRepresentationsFiles(Lists.newArrayList(representationsFileURI), user);
}
@Override
public void loadAndOpenRepresentationsFiles(final List<URI> representationsFilesURIs) {
+ loadAndOpenRepresentationsFiles(representationsFilesURIs, false);
+ }
+
+ private void loadAndOpenRepresentationsFiles(final List<URI> representationsFilesURIs, boolean user) {
// Add the specific sessions listener (if not already added).
SessionManager.INSTANCE.addSessionsListener(sessionManagerListener);
@@ -137,7 +150,9 @@ public class ModelingProjectManagerImpl implements ModelingProjectManager {
List<URI> tempRepresentationsFilesURIs = Lists.newArrayList(representationsFilesURIsToLoadIterator);
sessionFileLoading.addAll(tempRepresentationsFilesURIs);
// Launch the silently job to open the representations files
- OpenRepresentationsFileJob.scheduleNewWhenPossible(tempRepresentationsFilesURIs, false);
+ for (URI representationsFilesURI : tempRepresentationsFilesURIs) {
+ OpenRepresentationsFileJob.scheduleNewWhenPossible(representationsFilesURI, user);
+ }
}
/**
@@ -244,7 +259,7 @@ public class ModelingProjectManagerImpl implements ModelingProjectManager {
};
ResourcesPlugin.getWorkspace().run(create, monitor);
}
-
+
@Override
public void createLocalRepresentationsFile(IProject project, IProgressMonitor monitor) throws CoreException {
URI representationsURI = URI.createPlatformResourceURI(project.getFullPath().append(ModelingProject.DEFAULT_REPRESENTATIONS_FILE_NAME).toString(), true);
@@ -296,9 +311,23 @@ public class ModelingProjectManagerImpl implements ModelingProjectManager {
Option<URI> mainRepresentationsFileURI = optionalModelingProject.get().getMainRepresentationsFileURI(new SubProgressMonitor(monitor, 1), false, true);
if (mainRepresentationsFileURI.some()) {
// Open the session.
- OpenRepresentationsFileJob.scheduleNewWhenPossible(mainRepresentationsFileURI.get(), true);
+ loadAndOpenRepresentationsFile(mainRepresentationsFileURI.get(), true);
}
} catch (IllegalArgumentException e) {
+ // Clean existing marker if exists
+ try {
+ project.deleteMarkers(ModelingMarker.MARKER_TYPE, false, IResource.DEPTH_ZERO);
+ } catch (final CoreException ce) {
+ SiriusPlugin.getDefault().getLog().log(ce.getStatus());
+ }
+ // Add a marker on this project
+ try {
+ final IMarker marker = project.createMarker(ModelingMarker.MARKER_TYPE);
+ marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
+ marker.setAttribute(IMarker.MESSAGE, e.getMessage());
+ } catch (final CoreException ce) {
+ SiriusPlugin.getDefault().getLog().log(ce.getStatus());
+ }
if (e.getCause() != null && ModelingProjectQuery.ZERO_REPRESENTATIONS_FILE_FOUND_IN.equals(e.getCause().getMessage())) {
// 0 files has been found : create a representation
ModelingProjectManager.INSTANCE.createLocalRepresentationsFile(project, new SubProgressMonitor(monitor, 1));
@@ -316,7 +345,11 @@ public class ModelingProjectManagerImpl implements ModelingProjectManager {
// open session
if (OpenRepresentationsFileJob.shouldWaitOtherJobs()) {
// We are loading session(s)
- OpenRepresentationsFileJob.waitOtherJobs();
+ try {
+ Job.getJobManager().join(AbstractRepresentationsFileJob.FAMILY, new NullProgressMonitor());
+ } catch (InterruptedException e) {
+ // Do nothing
+ }
}
if (optionalModelingProject.get().getSession() != null) {
// add semantic resources if already existing in the project
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/model/ModelingModelProvider.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/model/ModelingModelProvider.java
index e45e1d2b48..e4c5a3fd53 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/model/ModelingModelProvider.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/model/ModelingModelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2011, 2016 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
@@ -28,12 +28,14 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.sirius.business.api.helper.SiriusUtil;
import org.eclipse.sirius.business.api.modelingproject.ModelingProject;
import org.eclipse.sirius.business.api.query.FileQuery;
import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.business.api.session.SessionStatus;
import org.eclipse.sirius.ext.base.Option;
+import org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.InvalidModelingProjectMarkerUpdaterJob;
import org.eclipse.sirius.viewpoint.SiriusPlugin;
import org.eclipse.sirius.viewpoint.provider.Messages;
@@ -85,20 +87,20 @@ public class ModelingModelProvider extends ModelProvider {
if (visitor.getProjectContainingSessionToSaveToDelete().size() == 1) {
result = new ModelStatus(IStatus.ERROR, SiriusPlugin.ID, ModelingModelProvider.MODELING_MODEL_PROVIDER_ID, Messages.ModelingModelProvider_satusUnsavedDataWillBeLost);
} else if (visitor.getProjectContainingSessionToSaveToDelete().size() > 1) {
- result = new ModelStatus(IStatus.ERROR, SiriusPlugin.ID, ModelingModelProvider.MODELING_MODEL_PROVIDER_ID, MessageFormat.format(
- Messages.ModelingModelProvider_satusUnsaveDataWillBeLostWithProjectNames, getProjectsName(visitor.getProjectContainingSessionToSaveToDelete())));
+ result = new ModelStatus(IStatus.ERROR, SiriusPlugin.ID, ModelingModelProvider.MODELING_MODEL_PROVIDER_ID,
+ MessageFormat.format(Messages.ModelingModelProvider_satusUnsaveDataWillBeLostWithProjectNames, getProjectsName(visitor.getProjectContainingSessionToSaveToDelete())));
} else if (visitor.getMainRepresentationsFilesToDelete().size() == 1) {
- result = new ModelStatus(IStatus.ERROR, SiriusPlugin.ID, ModelingModelProvider.MODELING_MODEL_PROVIDER_ID, MessageFormat.format(
- Messages.ModelingModelProvider_mainRepresentationFileDeleted, visitor.getMainRepresentationsFilesToDelete().get(0).getProject().getName()));
+ result = new ModelStatus(IStatus.ERROR, SiriusPlugin.ID, ModelingModelProvider.MODELING_MODEL_PROVIDER_ID,
+ MessageFormat.format(Messages.ModelingModelProvider_mainRepresentationFileDeleted, visitor.getMainRepresentationsFilesToDelete().get(0).getProject().getName()));
} else if (visitor.getMainRepresentationsFilesToDelete().size() > 1) {
- result = new ModelStatus(IStatus.ERROR, SiriusPlugin.ID, ModelingModelProvider.MODELING_MODEL_PROVIDER_ID, MessageFormat.format(
- Messages.ModelingModelProvider_mainRepresentationFilesOfSomeProjectsDeleted, getFilesProjectName(visitor.getMainRepresentationsFilesToDelete())));
+ result = new ModelStatus(IStatus.ERROR, SiriusPlugin.ID, ModelingModelProvider.MODELING_MODEL_PROVIDER_ID,
+ MessageFormat.format(Messages.ModelingModelProvider_mainRepresentationFilesOfSomeProjectsDeleted, getFilesProjectName(visitor.getMainRepresentationsFilesToDelete())));
} else if (visitor.getRepresentationsFileToAddOnValidModelingProject().size() == 1) {
- result = new ModelStatus(IStatus.ERROR, SiriusPlugin.ID, ModelingModelProvider.MODELING_MODEL_PROVIDER_ID, MessageFormat.format(
- Messages.ModelingModelProvider_addAnotherRepresentationFile, visitor.getRepresentationsFileToAddOnValidModelingProject().get(0).getProject().getName()));
+ result = new ModelStatus(IStatus.ERROR, SiriusPlugin.ID, ModelingModelProvider.MODELING_MODEL_PROVIDER_ID, MessageFormat
+ .format(Messages.ModelingModelProvider_addAnotherRepresentationFile, visitor.getRepresentationsFileToAddOnValidModelingProject().get(0).getProject().getName()));
} else if (visitor.getRepresentationsFileToAddOnValidModelingProject().size() > 1) {
- result = new ModelStatus(IStatus.ERROR, SiriusPlugin.ID, ModelingModelProvider.MODELING_MODEL_PROVIDER_ID, MessageFormat.format(
- Messages.ModelingModelProvider_addAnotherRepresentationFileSeveralProjects, getFilesProjectName(visitor.getRepresentationsFileToAddOnValidModelingProject())));
+ result = new ModelStatus(IStatus.ERROR, SiriusPlugin.ID, ModelingModelProvider.MODELING_MODEL_PROVIDER_ID, MessageFormat
+ .format(Messages.ModelingModelProvider_addAnotherRepresentationFileSeveralProjects, getFilesProjectName(visitor.getRepresentationsFileToAddOnValidModelingProject())));
}
} catch (CoreException e) {
/* do nothing */
@@ -246,7 +248,13 @@ public class ModelingModelProvider extends ModelProvider {
} else if (new FileQuery(currentFile).isSessionResourceFile()) {
// If the project is not valid and the deleted file is a
// representations file, validate the project again.
- optionalModelingProject.get().getMainRepresentationsFileURI(new NullProgressMonitor(), true, false);
+ try {
+ optionalModelingProject.get().getMainRepresentationsFileURI(new NullProgressMonitor(), true, true);
+ } catch (IllegalArgumentException e) {
+ IProject project = optionalModelingProject.get().getProject();
+ Job invalidModelingProjectMarkerUpdaterJob = new InvalidModelingProjectMarkerUpdaterJob(project, e.getMessage());
+ invalidModelingProjectMarkerUpdaterJob.schedule();
+ }
}
} else if (IResourceDelta.ADDED == delta.getKind()) {
// Check that the corresponding project does not already
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/ManageSessionActionProvider.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/ManageSessionActionProvider.java
index 2780af4e6d..2c756b9e06 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/ManageSessionActionProvider.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/ManageSessionActionProvider.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,12 +10,14 @@
*******************************************************************************/
package org.eclipse.sirius.ui.tools.internal.views.common.navigator;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.sirius.business.api.modelingproject.AbstractRepresentationsFileJob;
import org.eclipse.sirius.ui.tools.api.views.ViewHelper;
import org.eclipse.sirius.ui.tools.internal.views.common.ContextMenuFiller;
import org.eclipse.sirius.ui.tools.internal.views.common.SessionLabelProvider;
-import org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.OpenRepresentationsFileJob;
import org.eclipse.ui.navigator.CommonActionProvider;
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
@@ -55,7 +57,11 @@ public class ManageSessionActionProvider extends CommonActionProvider {
}
// Wait the end of the loading of the representations file
- OpenRepresentationsFileJob.waitOtherJobs();
+ try {
+ Job.getJobManager().join(AbstractRepresentationsFileJob.FAMILY, new NullProgressMonitor());
+ } catch (InterruptedException e) {
+ // Do nothing
+ }
// Differents behavior between win and linux : windows will not
// display contextual menu if busy cursor while dialog is shown.
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/OpenSessionOnExpandListener.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/OpenSessionOnExpandListener.java
index 0ac53b0846..18edef81a8 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/OpenSessionOnExpandListener.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/OpenSessionOnExpandListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2011, 2016 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
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.sirius.ui.tools.internal.views.common.navigator;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.text.MessageFormat;
import org.eclipse.core.resources.IFile;
@@ -19,24 +17,27 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.ITreeViewerListener;
import org.eclipse.jface.viewers.TreeExpansionEvent;
import org.eclipse.sirius.business.api.helper.SiriusUtil;
+import org.eclipse.sirius.business.api.modelingproject.AbstractRepresentationsFileJob;
import org.eclipse.sirius.business.api.modelingproject.ModelingProject;
import org.eclipse.sirius.ext.base.Option;
+import org.eclipse.sirius.ext.base.Options;
import org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager;
+import org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.InvalidModelingProjectMarkerUpdaterJob;
import org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.OpenRepresentationsFileJob;
import org.eclipse.sirius.viewpoint.provider.Messages;
import org.eclipse.ui.progress.UIJob;
/**
- * This listener opens a representations file.<BR>
- * When user expands a modeling project, the representations file is opened
- * "silently". And when user expands the representations file, if the "silently"
- * opening is not finished, it become blocker.
+ * {@link ITreeViewerListener} to open {@link ModelingProject}'s session on
+ * project expansion.
*
* @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a>
*/
@@ -54,7 +55,13 @@ public class OpenSessionOnExpandListener implements ITreeViewerListener {
Option<ModelingProject> optionalModelingProject = ModelingProject.asModelingProject(projectExpanded);
if (optionalModelingProject.some()) {
- Option<URI> optionalMainSessionFileURI = optionalModelingProject.get().getMainRepresentationsFileURI(new NullProgressMonitor(), false, false);
+ Option<URI> optionalMainSessionFileURI = Options.newNone();
+ try {
+ optionalMainSessionFileURI = optionalModelingProject.get().getMainRepresentationsFileURI(new NullProgressMonitor(), false, true);
+ } catch (IllegalArgumentException e) {
+ Job invalidModelingProjectMarkerUpdaterJob = new InvalidModelingProjectMarkerUpdaterJob(optionalModelingProject.get().getProject(), e.getMessage());
+ invalidModelingProjectMarkerUpdaterJob.schedule();
+ }
if (optionalMainSessionFileURI.some()) {
// Load the main representations file of this modeling
// project if it's not already loaded or during loading.
@@ -72,8 +79,6 @@ public class OpenSessionOnExpandListener implements ITreeViewerListener {
if (OpenRepresentationsFileJob.shouldWaitOtherJobs()) {
// We are loading session(s), wait loading is finished and
// re-expand the tree
- OpenRepresentationsFileJob.waitOtherJobs();
-
// Session is now loaded, the expanded file could have
// children now, demand new expand.
UIJob expandAgain = new ExpandAgainJob(event.getTreeViewer(), expandedFile);
@@ -86,7 +91,6 @@ public class OpenSessionOnExpandListener implements ITreeViewerListener {
* {@link UIJob} to expand the loaded file
*
* @author mporhel
- *
*/
private class ExpandAgainJob extends UIJob {
@@ -95,11 +99,14 @@ public class OpenSessionOnExpandListener implements ITreeViewerListener {
private final Object itemToExpand;
/**
- *
+ * Default constructor.
+ *
* @param viewer
+ * the {@link AbstractTreeViewer} on which do expansion
* @param itemToExpand
+ * the item to expand
*/
- public ExpandAgainJob(AbstractTreeViewer viewer, IFile itemToExpand) {
+ ExpandAgainJob(AbstractTreeViewer viewer, IFile itemToExpand) {
super(MessageFormat.format(Messages.OpenSessionOnExpandListener_expandJob, itemToExpand.getName()));
this.viewer = viewer;
this.itemToExpand = itemToExpand;
@@ -108,51 +115,17 @@ public class OpenSessionOnExpandListener implements ITreeViewerListener {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
+ try {
+ Job.getJobManager().join(AbstractRepresentationsFileJob.FAMILY, new NullProgressMonitor());
+ } catch (OperationCanceledException | InterruptedException e) {
+ // Do nothing
+ }
if (viewer != null) {
- if (isViewerBusy()) {
- schedule();
- } else {
- viewer.expandToLevel(itemToExpand, 1);
- }
+ viewer.expandToLevel(itemToExpand, 1);
}
return Status.OK_STATUS;
}
- private boolean isViewerBusy() {
- boolean viewerIsBusy = false;
-
- // ColumnViewer.isBusy was not public before 3.4
- if (viewer != null) {
- Method method = null;
- try {
- method = viewer.getClass().getMethod("isBusy"); //$NON-NLS-1$
- } catch (SecurityException e) {
- // No method, no data
- } catch (NoSuchMethodException e) {
- // No method, no data
- }
-
- if (method != null) {
- if (!method.isAccessible()) {
- method.setAccessible(true);
- }
-
- try {
- Object data = method.invoke(viewer);
- if (data instanceof Boolean) {
- viewerIsBusy = ((Boolean) data).booleanValue();
- }
- } catch (IllegalArgumentException e) {
- // No access, no data
- } catch (IllegalAccessException e) {
- // No access, no data
- } catch (InvocationTargetException e) {
- // No access, no data
- }
- }
+ }
- }
- return viewerIsBusy;
- }
- };
}
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/modelexplorer/ModelExplorerView.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/modelexplorer/ModelExplorerView.java
index 7441494fab..25c66cefee 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/modelexplorer/ModelExplorerView.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/modelexplorer/ModelExplorerView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 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
@@ -15,6 +15,7 @@ import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
@@ -26,10 +27,12 @@ import org.eclipse.sirius.common.tools.api.util.StringUtil;
import org.eclipse.sirius.common.ui.tools.api.util.SWTUtil;
import org.eclipse.sirius.common.ui.tools.api.view.IExpandSelectionTarget;
import org.eclipse.sirius.ext.base.Option;
+import org.eclipse.sirius.ext.base.Options;
import org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager;
import org.eclipse.sirius.ui.tools.api.views.LockDecorationUpdater;
import org.eclipse.sirius.ui.tools.api.views.modelexplorerview.IModelExplorerTabExtension;
import org.eclipse.sirius.ui.tools.api.views.modelexplorerview.IModelExplorerView;
+import org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.InvalidModelingProjectMarkerUpdaterJob;
import org.eclipse.sirius.ui.tools.internal.views.common.navigator.filter.FilteredCommonTree;
import org.eclipse.sirius.ui.tools.internal.views.modelexplorer.extension.tab.CommonNavigatorTab;
import org.eclipse.sirius.ui.tools.internal.views.modelexplorer.extension.tab.ModelExplorerTabDescriptor;
@@ -107,6 +110,7 @@ public class ModelExplorerView extends CommonNavigator implements IModelExplorer
tabFolder.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
selection(e);
}
@@ -134,6 +138,7 @@ public class ModelExplorerView extends CommonNavigator implements IModelExplorer
/**
* {@inheritDoc}
*/
+ @Override
public Object getAdapter(Class type) {
Object result = null;
if (type == IPropertySheetPage.class) {
@@ -286,6 +291,7 @@ public class ModelExplorerView extends CommonNavigator implements IModelExplorer
*
* @see org.eclipse.sirius.common.ui.tools.api.view.IExpandSelectionTarget#expand(java.lang.Object)
*/
+ @Override
public void expand(Object elementOrTreePath) {
if (getCommonViewer() != null) {
getCommonViewer().expandToLevel(elementOrTreePath, 1);
@@ -343,7 +349,14 @@ public class ModelExplorerView extends CommonNavigator implements IModelExplorer
if (element instanceof IProject) {
Option<ModelingProject> optionalModelingProject = ModelingProject.asModelingProject((IProject) element);
if (optionalModelingProject.some()) {
- Option<URI> optionalMainSessionFileURI = optionalModelingProject.get().getMainRepresentationsFileURI(new NullProgressMonitor(), false, false);
+ Option<URI> optionalMainSessionFileURI = Options.newNone();
+ try {
+ optionalMainSessionFileURI = optionalModelingProject.get().getMainRepresentationsFileURI(new NullProgressMonitor(), false, true);
+ } catch (IllegalArgumentException e) {
+ IProject project = optionalModelingProject.get().getProject();
+ Job invalidModelingProjectMarkerUpdaterJob = new InvalidModelingProjectMarkerUpdaterJob(project, e.getMessage());
+ invalidModelingProjectMarkerUpdaterJob.schedule();
+ }
if (optionalMainSessionFileURI.some()) {
// Load the main representations file of this modeling
// project if it's not already loaded or during loading.
@@ -362,6 +375,7 @@ public class ModelExplorerView extends CommonNavigator implements IModelExplorer
bars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameActionHandler);
this.getCommonViewer().getControl().addKeyListener(new KeyAdapter() {
+ @Override
public void keyReleased(KeyEvent event) {
handleKeyReleased(event);
}
@@ -390,6 +404,7 @@ public class ModelExplorerView extends CommonNavigator implements IModelExplorer
/**
* {@inheritDoc}
*/
+ @Override
public String getContributorId() {
return ID;
}
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/viewpoint/provider/Messages.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/viewpoint/provider/Messages.java
index 4861998d9e..314ab2b198 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/viewpoint/provider/Messages.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/viewpoint/provider/Messages.java
@@ -19,6 +19,7 @@ import org.eclipse.sirius.ext.base.I18N.TranslatableMessage;
* @author <a href="mailto:esteban.dugueperoux@obeo.fr">Esteban Dugueperoux</a>
*/
public final class Messages {
+
static {
I18N.initializeMessages(Messages.class, SiriusEditPlugin.INSTANCE);
}
@@ -580,9 +581,6 @@ public final class Messages {
public static String OpenRepresentationsFileJob_errorInvalidInputList;
@TranslatableMessage
- public static String OpenRepresentationsFileJob_initModelingProjectsTask;
-
- @TranslatableMessage
public static String OpenRepresentationsFileJob_invalidModelingProjectsError;
@TranslatableMessage
@@ -1026,6 +1024,9 @@ public final class Messages {
@TranslatableMessage
public static String ViewpointsSelectionWizardPage_title;
+ @TranslatableMessage
+ public static String InvalidModelingProjectMarkerUpdaterJob_updateMarkers;
+
// CHECKSTYLE:ON
private Messages() {
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/modelingproject/AbstractRepresentationsFileJob.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/modelingproject/AbstractRepresentationsFileJob.java
index a25fc5feaf..aa55e79beb 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/modelingproject/AbstractRepresentationsFileJob.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/modelingproject/AbstractRepresentationsFileJob.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
@@ -11,6 +11,7 @@
package org.eclipse.sirius.business.api.modelingproject;
import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.sirius.viewpoint.SiriusPlugin;
/**
@@ -18,13 +19,28 @@ import org.eclipse.sirius.viewpoint.SiriusPlugin;
* family).
*
* @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a>
- *
*/
public abstract class AbstractRepresentationsFileJob extends WorkspaceJob {
+
+ /** The family id for this kind of job. */
+ public static final String FAMILY = SiriusPlugin.ID + ".representationsFile"; //$NON-NLS-1$
+
/**
- * The family id for this kind of job.
+ * A {@link ISchedulingRule} to avoid concurrent execution of
+ * {@link AbstractRepresentationsFileJob} .
*/
- public static final String FAMILY = SiriusPlugin.ID + ".representationsFile"; //$NON-NLS-1$
+ private static final ISchedulingRule DEFAULT_SCHEDULING_RULE = new ISchedulingRule() {
+
+ @Override
+ public boolean isConflicting(ISchedulingRule rule) {
+ return rule == this;
+ }
+
+ @Override
+ public boolean contains(ISchedulingRule rule) {
+ return rule == this;
+ }
+ };
/**
* Default constructor.
@@ -35,13 +51,9 @@ public abstract class AbstractRepresentationsFileJob extends WorkspaceJob {
*/
public AbstractRepresentationsFileJob(String name) {
super(name);
+ setRule(DEFAULT_SCHEDULING_RULE);
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.core.runtime.jobs.Job#belongsTo(java.lang.Object)
- */
@Override
public boolean belongsTo(Object family) {
return FAMILY.equals(family);
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/modelingproject/ModelingProject.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/modelingproject/ModelingProject.java
index 87c18e272d..c14080abfa 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/modelingproject/ModelingProject.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/modelingproject/ModelingProject.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 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
@@ -11,10 +11,8 @@
package org.eclipse.sirius.business.api.modelingproject;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectNature;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -22,12 +20,10 @@ import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.business.api.session.SessionManager;
-import org.eclipse.sirius.business.internal.modelingproject.marker.ModelingMarker;
import org.eclipse.sirius.business.internal.query.ModelingProjectQuery;
import org.eclipse.sirius.ext.base.Option;
import org.eclipse.sirius.ext.base.Options;
import org.eclipse.sirius.viewpoint.Messages;
-import org.eclipse.sirius.viewpoint.SiriusPlugin;
/**
* A modeling project nature is used to know which projects should be handled in
@@ -178,7 +174,7 @@ public class ModelingProject implements IProjectNature, IModelingElement {
*
* @param monitor
* the monitor to be used for reporting progress and responding
- * to cancelation. The monitor is never <code>null</code>
+ * to cancellation. The monitor is never <code>null</code>
* @return an optional URI corresponding to the main session file of this
* project.
* @throws IllegalArgumentException
@@ -193,8 +189,7 @@ public class ModelingProject implements IProjectNature, IModelingElement {
* this project. If the main representations file is not known, it will be
* computed by a specific SaxParser that analyzes representations files of
* this project to determine which is never referenced.<BR>
- * This method marks this project as invalid and adds a marker on it, if it
- * is considered as invalid.
+ * This method marks this project as invalid.
*
* @param monitor
* the monitor to be used for reporting progress and responding
@@ -225,20 +220,6 @@ public class ModelingProject implements IProjectNature, IModelingElement {
try {
mainRepresentationsFileURI = new ModelingProjectQuery(this).computeMainRepresentationsFileURI(new SubProgressMonitor(monitor, 1));
} catch (IllegalArgumentException e) {
- // Clean existing marker if exists
- try {
- getProject().deleteMarkers(ModelingMarker.MARKER_TYPE, false, IResource.DEPTH_ZERO);
- } catch (final CoreException ce) {
- SiriusPlugin.getDefault().getLog().log(ce.getStatus());
- }
- // Add a marker on this project
- try {
- final IMarker marker = getProject().createMarker(ModelingMarker.MARKER_TYPE);
- marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
- marker.setAttribute(IMarker.MESSAGE, e.getMessage());
- } catch (final CoreException ce) {
- SiriusPlugin.getDefault().getLog().log(ce.getStatus());
- }
// Set this project in invalid state
setValid(false);
// Throw exception if asked
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/modelingproject/manager/InitializeModelingProjectJob.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/modelingproject/manager/InitializeModelingProjectJob.java
index 4a5eb80742..4ddd0cc741 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/modelingproject/manager/InitializeModelingProjectJob.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/modelingproject/manager/InitializeModelingProjectJob.java
@@ -12,6 +12,7 @@ package org.eclipse.sirius.business.internal.modelingproject.manager;
import java.util.List;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -119,7 +120,7 @@ public class InitializeModelingProjectJob extends WorkspaceJob {
* if it is already known), false otherwise.
* @param monitor
* the monitor to be used for reporting progress and responding
- * to cancelation. The monitor is never <code>null</code>
+ * to cancellation. The monitor is never <code>null</code>
* @return resulting status of the initialization
*/
public static IStatus initializeModelingProjects(List<IProject> projects, boolean forceInit, IProgressMonitor monitor) {
@@ -127,13 +128,13 @@ public class InitializeModelingProjectJob extends WorkspaceJob {
try {
IProject[] projectsTable;
if (projects != null) {
- projectsTable = projects.toArray(new IProject[0]);
+ projectsTable = projects.toArray(new IProject[projects.size()]);
} else {
projectsTable = ResourcesPlugin.getWorkspace().getRoot().getProjects();
}
monitor.beginTask("", projectsTable.length); //$NON-NLS-1$
- for (int i = 0; i < projectsTable.length; i++) {
- Option<ModelingProject> optionalModelingProject = ModelingProject.asModelingProject(projectsTable[i]);
+ for (IProject project : projectsTable) {
+ Option<ModelingProject> optionalModelingProject = ModelingProject.asModelingProject(project);
if (optionalModelingProject.some()) {
// Clean existing marker if exists
try {
@@ -144,6 +145,14 @@ public class InitializeModelingProjectJob extends WorkspaceJob {
try {
optionalModelingProject.get().getMainRepresentationsFileURI(new SubProgressMonitor(monitor, 1), forceInit, true);
} catch (IllegalArgumentException e) {
+ // Add a marker on this project
+ try {
+ final IMarker marker = project.createMarker(ModelingMarker.MARKER_TYPE);
+ marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
+ marker.setAttribute(IMarker.MESSAGE, e.getMessage());
+ } catch (final CoreException ce) {
+ SiriusPlugin.getDefault().getLog().log(ce.getStatus());
+ }
// Add the problem to the result status of this job
errorStatus.add(new Status(IStatus.ERROR, SiriusPlugin.ID, IStatus.OK, e.getMessage(), null));
}

Back to the top