Introduced new IExtendedPlatformConstants.FAMILY_MODEL_SAVING job family
and made sure that all new model resource creation and model saving jobs
in EcorePlatformUtil belong to appropriate job families
diff --git a/plugins/org.eclipse.sphinx.emf/src/org/eclipse/sphinx/emf/util/EcorePlatformUtil.java b/plugins/org.eclipse.sphinx.emf/src/org/eclipse/sphinx/emf/util/EcorePlatformUtil.java
index faca3ee..a3a5977 100644
--- a/plugins/org.eclipse.sphinx.emf/src/org/eclipse/sphinx/emf/util/EcorePlatformUtil.java
+++ b/plugins/org.eclipse.sphinx.emf/src/org/eclipse/sphinx/emf/util/EcorePlatformUtil.java
@@ -1,7 +1,7 @@
/**
* <copyright>
*
- * Copyright (c) 2008-2014 itemis, See4sys and others.
+ * Copyright (c) 2008-2019 itemis, See4sys 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
@@ -86,6 +86,7 @@
import org.eclipse.sphinx.emf.resource.ModelResourceDescriptor;
import org.eclipse.sphinx.emf.saving.SaveIndicatorUtil;
import org.eclipse.sphinx.emf.scoping.IResourceScope;
+import org.eclipse.sphinx.platform.IExtendedPlatformConstants;
import org.eclipse.sphinx.platform.util.ExtendedPlatform;
import org.eclipse.sphinx.platform.util.PlatformLogUtil;
import org.eclipse.sphinx.platform.util.StatusUtil;
@@ -1605,10 +1606,17 @@
try {
runAddNewModelResources(editingDomain, modelResourceDescriptors, monitor);
return Status.OK_STATUS;
- } catch (CoreException ex) {
- return ex.getStatus();
+ } catch (OperationCanceledException ex) {
+ return Status.CANCEL_STATUS;
+ } catch (Exception ex) {
+ return StatusUtil.createErrorStatus(Activator.getPlugin(), ex);
}
}
+
+ @Override
+ public boolean belongsTo(Object family) {
+ return IExtendedPlatformConstants.FAMILY_MODEL_LOADING.equals(family);
+ }
};
job.setRule(rule);
job.setPriority(Job.BUILD);
@@ -1632,7 +1640,7 @@
private static void runAddNewModelResources(final TransactionalEditingDomain editingDomain,
final Collection<ModelResourceDescriptor> modelResourceDescriptors, IProgressMonitor monitor)
- throws CoreException, OperationCanceledException {
+ throws CoreException, OperationCanceledException {
Assert.isNotNull(editingDomain);
Assert.isNotNull(modelResourceDescriptors);
SubMonitor progress = SubMonitor.convert(monitor,
@@ -1714,10 +1722,17 @@
try {
runSaveNewModelResources(editingDomain, modelResourceDescriptors, options, monitor);
return Status.OK_STATUS;
- } catch (CoreException ex) {
- return ex.getStatus();
+ } catch (OperationCanceledException ex) {
+ return Status.CANCEL_STATUS;
+ } catch (Exception ex) {
+ return StatusUtil.createErrorStatus(Activator.getPlugin(), ex);
}
}
+
+ @Override
+ public boolean belongsTo(Object family) {
+ return IExtendedPlatformConstants.FAMILY_MODEL_SAVING.equals(family);
+ }
};
job.setRule(rule);
job.setPriority(Job.BUILD);
@@ -1754,7 +1769,7 @@
*/
private static void runSaveNewModelResources(final TransactionalEditingDomain editingDomain,
final Collection<ModelResourceDescriptor> modelResourceDescriptors, final Map<?, ?> options, IProgressMonitor monitor)
- throws CoreException, OperationCanceledException {
+ throws CoreException, OperationCanceledException {
Assert.isNotNull(editingDomain);
Assert.isNotNull(modelResourceDescriptors);
SubMonitor progress = SubMonitor.convert(monitor,
@@ -1916,10 +1931,17 @@
try {
runSaveModelResources(resourcesToSave, options, monitor);
return Status.OK_STATUS;
- } catch (CoreException ex) {
- return ex.getStatus();
+ } catch (OperationCanceledException ex) {
+ return Status.CANCEL_STATUS;
+ } catch (Exception ex) {
+ return StatusUtil.createErrorStatus(Activator.getPlugin(), ex);
}
}
+
+ @Override
+ public boolean belongsTo(Object family) {
+ return IExtendedPlatformConstants.FAMILY_MODEL_SAVING.equals(family);
+ }
};
job.setRule(rule);
@@ -1987,10 +2009,17 @@
try {
runSaveModelResources(resourcesToSave, options, monitor);
return Status.OK_STATUS;
- } catch (CoreException ex) {
- return ex.getStatus();
+ } catch (OperationCanceledException ex) {
+ return Status.CANCEL_STATUS;
+ } catch (Exception ex) {
+ return StatusUtil.createErrorStatus(Activator.getPlugin(), ex);
}
}
+
+ @Override
+ public boolean belongsTo(Object family) {
+ return IExtendedPlatformConstants.FAMILY_MODEL_SAVING.equals(family);
+ }
};
job.setRule(rule);
job.setPriority(Job.BUILD);
diff --git a/plugins/org.eclipse.sphinx.platform/src/org/eclipse/sphinx/platform/IExtendedPlatformConstants.java b/plugins/org.eclipse.sphinx.platform/src/org/eclipse/sphinx/platform/IExtendedPlatformConstants.java
index be387df..cd86879 100644
--- a/plugins/org.eclipse.sphinx.platform/src/org/eclipse/sphinx/platform/IExtendedPlatformConstants.java
+++ b/plugins/org.eclipse.sphinx.platform/src/org/eclipse/sphinx/platform/IExtendedPlatformConstants.java
@@ -1,15 +1,15 @@
/**
* <copyright>
- *
- * Copyright (c) 2008-2010 See4sys and others.
+ *
+ * Copyright (c) 2008-2019 See4sys 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:
+ *
+ * Contributors:
* See4sys - Initial API and implementation
- *
+ *
* </copyright>
*/
package org.eclipse.sphinx.platform;
@@ -29,28 +29,35 @@
/**
* Identifier of job family for long running jobs. All jobs which belong to this family will be automatically
* canceled upon workbench shutdown.
- *
+ *
* @see IJobManager#join(Object, IProgressMonitor)
*/
public static final Object FAMILY_LONG_RUNNING = "LONG_RUNNING"; //$NON-NLS-1$
/**
* Identifier of job family for model loading jobs.
- *
+ *
* @see IJobManager#join(Object, IProgressMonitor)
*/
public static final Object FAMILY_MODEL_LOADING = "MODEL_LOADING"; //$NON-NLS-1$
/**
+ * Identifier of job family for model saving jobs.
+ *
+ * @see IJobManager#join(Object, IProgressMonitor)
+ */
+ public static final Object FAMILY_MODEL_SAVING = "MODEL_SAVING"; //$NON-NLS-1$
+
+ /**
* Identifier of job family for automatic validation jobs.
- *
+ *
* @see IJobManager#join(Object, IProgressMonitor)
*/
public static final Object FAMILY_AUTOMATIC_VALIDATION = "AUTOMATIC_VALIDATION"; //$NON-NLS-1$
/**
* Identifier of job family for label decoration jobs.
- *
+ *
* @see IJobManager#join(Object, IProgressMonitor)
*/
public static final Object FAMILY_LABEL_DECORATION = "LABEL_DECORATION"; //$NON-NLS-1$
@@ -74,8 +81,8 @@
/**
* A constant used to indicate that a {@link org.eclipse.emf.ecore.resource.Resource resource} or {@link IFile file}
* is non-model XML document.
- *
+ *
* @see ExtendedPlatform#getContentTypeId(IFile)
*/
- public static final String CONTENT_TYPE_ID_NON_MODEL_XML_FILE = "org.eclipse.sphinx.platform.nonModelXMLFile"; //$NON-NLS-1$;
+ public static final String CONTENT_TYPE_ID_NON_MODEL_XML_FILE = "org.eclipse.sphinx.platform.nonModelXMLFile"; //$NON-NLS-1$ ;
}