From 88c526225da8a5742d19207f870ce037a39ff734 Mon Sep 17 00:00:00 2001 From: Christian W. Damus Date: Fri, 7 Mar 2014 13:18:29 -0500 Subject: 323802: [General] Papyrus shall provide a read only mode https://bugs.eclipse.org/bugs/show_bug.cgi?id=323802 Don't prompt multiple times to make a resource read-only if the user already answered in the negative and we are therefore rolling back. --- .../emf/readonly/PapyrusROTransactionalEditingDomain.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'plugins/infra') diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomain.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomain.java index de7b67ec2eb..0d178b8c6be 100644 --- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomain.java +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomain.java @@ -22,6 +22,7 @@ import java.util.Set; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.emf.common.notify.AdapterFactory; import org.eclipse.emf.common.notify.Notification; @@ -92,8 +93,11 @@ public class PapyrusROTransactionalEditingDomain extends TransactionalEditingDom InternalTransaction tx = getActiveTransaction(); // If there's no transaction, then there will be nothing to roll back. And if it's unprotected, let the client do whatever. - // And, of course, don't interfere with rollback! - if((tx != null) && !tx.isRollingBack() && !Boolean.TRUE.equals(tx.getOptions().get(Transaction.OPTION_UNPROTECTED))) { + // And, of course, don't interfere with rollback! Finally, if we're already going to roll back, don't bother + if((tx != null) && !tx.isRollingBack() // + && !Boolean.TRUE.equals(tx.getOptions().get(Transaction.OPTION_UNPROTECTED)) // + && !willRollBack(tx)) { + boolean readOnly; // Check for Resource first because CDO resources *are* EObjects @@ -119,6 +123,11 @@ public class PapyrusROTransactionalEditingDomain extends TransactionalEditingDom } } } + + private boolean willRollBack(Transaction tx) { + IStatus status = tx.getStatus(); + return (status != null) && (status.getSeverity() >= IStatus.ERROR); + } protected boolean makeWritable(Resource resource) { URI[] uris = getCompositeModelURIs(resource.getURI()); -- cgit v1.2.3 From 652138c6e4eb4d37cd6646b9afcf3da859a27169 Mon Sep 17 00:00:00 2001 From: Camille Letavernier Date: Mon, 10 Mar 2014 14:32:10 +0100 Subject: [Trivial] Update oep.infra.core BREE to Java 1.6, to be consistent with actual implementation [Trivial] Add deprecated tags and documentation in SashModelUtils--- .../core/org.eclipse.papyrus.infra.core/.classpath | 3 +- .../.settings/org.eclipse.jdt.core.prefs | 7 +++++ .../META-INF/MANIFEST.MF | 2 +- .../core/resource/sasheditor/SashModelUtils.java | 32 ++++++++++++---------- 4 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/.settings/org.eclipse.jdt.core.prefs (limited to 'plugins/infra') diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/.classpath b/plugins/infra/core/org.eclipse.papyrus.infra.core/.classpath index 024fd574b42..8a8f1668cdc 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/.classpath +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/.classpath @@ -1,8 +1,7 @@ - + - diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/core/org.eclipse.papyrus.infra.core/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..f287d53cf45 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF b/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF index 9fea77c193b..3d4475746e8 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF @@ -40,5 +40,5 @@ Bundle-Name: %pluginName Bundle-ManifestVersion: 2 Bundle-Activator: org.eclipse.papyrus.infra.core.Activator Bundle-SymbolicName: org.eclipse.papyrus.infra.core;singleton:=true -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/SashModelUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/SashModelUtils.java index b35cb8e02c5..23bb97b79d0 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/SashModelUtils.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/SashModelUtils.java @@ -1,5 +1,5 @@ /** - * + * */ package org.eclipse.papyrus.infra.core.resource.sasheditor; @@ -12,9 +12,9 @@ import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers; /** * Set of utility methods linked to Trace for ControlMode - * + * * @author cedric dumoulin - * + * */ public class SashModelUtils { @@ -23,12 +23,14 @@ public class SashModelUtils { * Warning: This method is designed to be call from ui.handlers. It is not * designed to be call from Editors. This method can return null if called * during the MultiEditor initialization. - * + * * @see ServiceUtilsForActionHandlers.getInstance().getModelSet() - * + * * @return The {@link SashModel} of the current editor, or null if not * found. + * @deprecated Use {@link #getSashModel(ModelSet)} or {@link #getSashModel(ServicesRegistry)} instead */ + @Deprecated public static SashModel getSashModel() { try { @@ -43,14 +45,16 @@ public class SashModelUtils { * Warning: This method is designed to be call from ui.handlers. It is not * designed to be call from Editors. This method can return null if called * during the MultiEditor initialization. - * + * * @see ServiceUtilsForActionHandlers.getInstance().getModelSet() - * + * * @return The {@link SashModel} of the current editor, or null if not * found. * @throws ServiceException * If an error occurs while getting or starting the service. + * @deprecated Use {@link #getSashModelChecked(ServicesRegistry)} instead */ + @Deprecated public static SashModel getSashModelChecked() throws ServiceException { return (SashModel)ServiceUtilsForActionHandlers.getInstance().getModelSet().getModel(SashModel.MODEL_ID); @@ -58,10 +62,10 @@ public class SashModelUtils { /** * Gets the SashModel from the {@link ModelSet}.
- * + * * @param modelsManager * The modelManager containing the requested model. - * + * * @return The {@link SashModel} registered in modelManager, or null if not * found. */ @@ -72,10 +76,10 @@ public class SashModelUtils { /** * Gets the SashModel from the {@link ModelSet}.
- * + * * @param ServicesRegistry * The servie registry under which the ModelSet is registered. - * + * * @return The {@link SashModel} registered in modelManager, or null if not * found. */ @@ -90,10 +94,10 @@ public class SashModelUtils { /** * Gets the SashModel from the {@link ModelSet}.
- * + * * @param ServicesRegistry * The servie registry under which the ModelSet is registered. - * + * * @return The {@link SashModel} registered in modelManager, or null if not * found. * @throws ServiceException @@ -106,7 +110,7 @@ public class SashModelUtils { /** * Retrieve the uri of the initial di opened - * + * * @param modelSet * @return */ -- cgit v1.2.3 From e9eb2ae9d1d16b7119826e6bbce5da2955533d99 Mon Sep 17 00:00:00 2001 From: Camille Letavernier Date: Mon, 10 Mar 2014 14:37:11 +0100 Subject: 429239: [Resource Management] Refactoring of the 3-files model and PageManager https://bugs.eclipse.org/bugs/show_bug.cgi?id=429239 - Improve the exception catching in ModelSet#save(IModel) - Improve the implementation of ModelUtils#resourceFailedOnLoad(Resource), to be more accurate--- .../infra/core/resource/EMFLogicalModel.java | 9 +- .../papyrus/infra/core/resource/ModelSet.java | 116 +++++++++++---------- .../papyrus/infra/core/resource/ModelUtils.java | 56 +++++----- 3 files changed, 97 insertions(+), 84 deletions(-) (limited to 'plugins/infra') diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/EMFLogicalModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/EMFLogicalModel.java index 749da273e49..cb18390bbad 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/EMFLogicalModel.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/EMFLogicalModel.java @@ -18,6 +18,7 @@ import java.util.Set; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.papyrus.infra.core.Activator; /** * An IModel which is an abstraction for a set of consistent EMF Resources @@ -53,7 +54,13 @@ public abstract class EMFLogicalModel extends AbstractBaseModel implements IEMFM public void saveModel() throws IOException { for(Resource resource : getResources()) { if(!getModelManager().getTransactionalEditingDomain().isReadOnly(resource) && !ModelUtils.resourceFailedOnLoad(resource)) { - resource.save(null); + try { + resource.save(null); + } catch (IOException ex) { + //If an exception occurs, we should not prevent other resources from being saved. + //This would probably make things even worse. Catch and log. + Activator.log.error(ex); + } } } } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java index 48475d9458e..96f02ae8f5d 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java @@ -62,7 +62,7 @@ import com.google.common.base.Optional; /** * This class is used to manage a set of {@link IModel}. - * + * *

>Usage

* - * + * * Please note that indirectly referenced models are loaded on demand. If a * model contains a cross reference towards another model (e.g. an import in * case of UML) the referenced resource does not appear initially in the set. * However, it is added once the referenced model is resolved. - * + * * TODO Modify ModelSetSnippet in order to inform them of model addition. - * + * * @author cedric dumoulin - * + * */ public class ModelSet extends ResourceSetImpl { @@ -125,9 +125,9 @@ public class ModelSet extends ResourceSetImpl { /** - * + * * Constructor. - * + * */ public ModelSet() { registerModel(additional); @@ -146,7 +146,7 @@ public class ModelSet extends ResourceSetImpl { * Register the specified model under its associated key. The key is defined * in the model itself. It is usually the model type from * (ModelPackage.eCONTENT_TYPE). - * + * * @param model * the model */ @@ -166,7 +166,7 @@ public class ModelSet extends ResourceSetImpl { /** * Get a model by its key. TODO throw an exception if not found. - * + * * @param key * the key * @return the model @@ -177,7 +177,7 @@ public class ModelSet extends ResourceSetImpl { /** * Get a model by its key. TODO throw an exception if not found. - * + * * @param key * the key * @return the model @@ -249,7 +249,7 @@ public class ModelSet extends ResourceSetImpl { /** * @deprecated please use {@link #getAssociatedResource(EObject, String, boolean)} instead - * + * * @param modelElement * @param associatedResourceExtension * @return @@ -261,7 +261,7 @@ public class ModelSet extends ResourceSetImpl { /** * @deprecated please use {@link #getAssociatedResource(Resource, String, boolean)} instead - * + * * @param modelResource * @param associatedResourceExtension * @return @@ -273,7 +273,7 @@ public class ModelSet extends ResourceSetImpl { /** * Retrieve and load the associated resource which have the given extension. - * + * * @param modelElement * @param associatedResourceExtension * @param loadOnDemand @@ -289,7 +289,7 @@ public class ModelSet extends ResourceSetImpl { /** * Retrieve and load the associated resource which have the given extension. - * + * * @param modelResource * @param associatedResourceExtension * @param loadOnDemand @@ -308,7 +308,7 @@ public class ModelSet extends ResourceSetImpl { /** * This method is called by getResource, createResource and demandLoad before returning * the resource to the caller so we can set options on the resource. - * + * * @param r * , can be null * @return the same resource for convenience @@ -336,7 +336,7 @@ public class ModelSet extends ResourceSetImpl { /** * Create the transactional editing domain. - * + * * @return the transactional editing domain */ public synchronized TransactionalEditingDomain getTransactionalEditingDomain() { @@ -352,7 +352,7 @@ public class ModelSet extends ResourceSetImpl { /** * @return the filenameWithoutExtension - * + * * @deprecated Use the {@link #getURIWithoutExtension()} API, instead. */ @Deprecated @@ -397,11 +397,11 @@ public class ModelSet extends ResourceSetImpl { /** * Create all the associated models. This creates the models, regardless if * they already exist. - * + * * @param newFile * The file from which path is extracted to create the new * resources - * + * * @deprecated Use the {@link #createModels(URI)} API, instead. */ @Deprecated @@ -412,7 +412,7 @@ public class ModelSet extends ResourceSetImpl { /** * Create all the associated models. This creates the models, regardless if * they already exist. - * + * * @param newFile * The file from which path is extracted to create the new * resources @@ -434,9 +434,9 @@ public class ModelSet extends ResourceSetImpl { /** * Create the model specified by the identifiers. Other models are * untouched, unless they are sharing something with specified models. - * + * * This creates the models, regardless if they already exist. - * + * * @param newFile * The file from which path is extracted to create the new * resources @@ -458,7 +458,7 @@ public class ModelSet extends ResourceSetImpl { /** * Load only the specified model. ModelSetSnippets are not called. Model is * loaded using the ModelSet Path. - * + * * @param modelIdentifier * the model identifier * @param file @@ -478,7 +478,7 @@ public class ModelSet extends ResourceSetImpl { /** * Import only the specified model. ModelSetSnippets are not called. - * + * * @param modelIdentifier * the model identifier * @param file @@ -499,7 +499,7 @@ public class ModelSet extends ResourceSetImpl { /** * Load all the associated models from a handle on one of the associated * file. - * + * * @param file * The file to load (no matter the extension) * @deprecated Use the {@link #loadModels(URI)} API, instead. @@ -516,7 +516,7 @@ public class ModelSet extends ResourceSetImpl { /** * Load all the associated models from a URI identifying one of the associated * files. - * + * * @param uri * The URI to load (no matter the extension) */ @@ -566,14 +566,14 @@ public class ModelSet extends ResourceSetImpl { * Import specified models into the ModelSet. The models are imported using * the specified IFile. After import, the models are associated with the * ModelSet Path. - * + * * @param modelIdentifiers * The model to import from the specified IFile. * @param file * The IFile used to import the model. * @throws ModelException * If an error occur during import. - * + * * @deprecated Use the {@link #importModels(ModelIdentifiers, URI)} API, instead */ @Deprecated @@ -586,7 +586,7 @@ public class ModelSet extends ResourceSetImpl { * Import specified models into the ModelSet. The models are imported using * the specified IFile. After import, the models are associated with the * ModelSet Path. - * + * * @param modelIdentifiers * The model to import from the specified IFile. * @param file @@ -613,14 +613,14 @@ public class ModelSet extends ResourceSetImpl { * Import only the specified model. ModelSetSnippets are not called. An * import can be performed after model are loaded. Normally, it should not * be done before a model is loaded. - * + * * @param modelIdentifier * the model identifier * @param file * the file * @throws ModelException * @returns The loaded model. - * + * * @deprecated Use the {@link #importModel(String, URI)} API, instead. */ @Deprecated @@ -633,7 +633,7 @@ public class ModelSet extends ResourceSetImpl { * Import only the specified model. ModelSetSnippets are not called. An * import can be performed after model are loaded. Normally, it should not * be done before a model is loaded. - * + * * @param modelIdentifier * the model identifier * @param file @@ -666,7 +666,7 @@ public class ModelSet extends ResourceSetImpl { /** * Save the resources. - * + * * @param monitor * The monitor. * @throws IOException @@ -712,12 +712,22 @@ public class ModelSet extends ResourceSetImpl { try { // Walk all registered models for(IModel model : modelList) { - if(!(model instanceof AdditionalResourcesModel)) { - model.saveModel(); - monitor.worked(1); + try { + if(!(model instanceof AdditionalResourcesModel)) { + model.saveModel(); + monitor.worked(1); + } + } catch (Exception ex) { + //If an exception occurs, we should not prevent other models from being saved. + //This would probably make things even worse. Catch and log. + Activator.log.error(ex); } } - additional.saveModel(); + try { + additional.saveModel(); + } catch (Exception ex) { + Activator.log.error(ex); + } //Delete resource back end to delete on save handleResourcesToDelete(); @@ -790,12 +800,12 @@ public class ModelSet extends ResourceSetImpl { /** * Finds the file corresponding to the specified URI, using a URI converter * if necessary (and provided) to normalize it. - * + * * @param uri * a URI * @param converter * an optional URI converter (may be null) - * + * * @return the file, if available in the workspace */ protected IFile getFile(URI uri) { @@ -849,12 +859,12 @@ public class ModelSet extends ResourceSetImpl { /** * The resources are already loaded, but we want to save them under another * name. - * + * * @param path * the path * @throws IOException * Signals that an I/O exception has occurred. - * + * * @deprecated Use the {@link #saveAs(URI)} API, instead. */ @Deprecated @@ -865,7 +875,7 @@ public class ModelSet extends ResourceSetImpl { /** * The resources are already loaded, but we want to save them under another * name. - * + * * @param path * the path * @throws IOException @@ -941,7 +951,7 @@ public class ModelSet extends ResourceSetImpl { /** * Obtains my internal API adapter. - * + * * @return my internal API adapter */ public Internal getInternal() { @@ -966,7 +976,7 @@ public class ModelSet extends ResourceSetImpl { /** * Add a {@link IModelSetSnippet}. A snippet allows to add code that will * perform additional operations on the ModelSet. - * + * * @param snippet * The snippet to add. */ @@ -976,11 +986,11 @@ public class ModelSet extends ResourceSetImpl { /** * A list of {@link IModelSetSnippet}. - * + * * Used by Models to maintain their list of Snippets. - * + * * @author cedric dumoulin - * + * */ public class ModelSetSnippetList extends ArrayList { @@ -989,7 +999,7 @@ public class ModelSet extends ResourceSetImpl { /** * Call the start method on all registered snippets. - * + * * @param modelsManager * The model that is starting */ @@ -1001,7 +1011,7 @@ public class ModelSet extends ResourceSetImpl { /** * Call the start method on all registered snippets. - * + * * @param modelsManager * The model that is stopping */ @@ -1020,10 +1030,10 @@ public class ModelSet extends ResourceSetImpl { /** * Sets the {@link ModelSet}'s primary resource URI. - * + * * @param uri * the URI - * + * * @see ModelSet#createModels(URI) * @see ModelSet#saveAs(URI) */ @@ -1032,7 +1042,7 @@ public class ModelSet extends ResourceSetImpl { /** * Register a model with the option to force it (in case a more specific * implementation of the model is already registered). - * + * * @param model * a model to register * @param force @@ -1042,7 +1052,7 @@ public class ModelSet extends ResourceSetImpl { } /** - * + * * @param target */ public void saveCopy(IPath targetPathWithoutExtension) { diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelUtils.java index 76db49aa909..e745574077c 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelUtils.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelUtils.java @@ -1,5 +1,5 @@ /** - * + * */ package org.eclipse.papyrus.infra.core.resource; @@ -9,11 +9,8 @@ import java.util.Collection; import java.util.List; import java.util.Map; -import org.eclipse.core.internal.resources.ResourceException; import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.common.util.WrappedException; import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.Resource.Diagnostic; import org.eclipse.emf.ecore.xmi.IllegalValueException; import org.eclipse.papyrus.infra.core.Activator; import org.eclipse.papyrus.infra.core.services.ServiceException; @@ -107,17 +104,9 @@ public class ModelUtils { } public static boolean resourceFailedOnLoad(Resource r) { - if(r.getErrors() != null) { - for(Diagnostic d : r.getErrors()) { - if(d instanceof WrappedException) { - WrappedException wrapped = (WrappedException)d; - if(wrapped.getCause() instanceof ResourceException && r.getContents().isEmpty()) { - return true; - } - } - } - } - return false; + //If the resource failed on load, but the contents is not empty, then we may try to save it + //(e.g. the resource didn't exist, but we'll create it during save, if possible) + return !r.getErrors().isEmpty() && r.getContents().isEmpty(); } /** @@ -129,7 +118,7 @@ public class ModelUtils { // L <= Empty list that will contain the sorted nodes // while there are unmarked nodes do // select an unmarked node n - // visit(n) + // visit(n) // function visit(node n) // if n has a temporary mark then stop (not a DAG) // if n is not marked (i.e. has not been visited yet) then @@ -143,7 +132,7 @@ public class ModelUtils { do { List skippedModels = new ArrayList(); for(IModel model : modelsToLoad) { - + List dependencies = model.getAfterLoadModelIdentifiers(); // no dependency => start if(dependencies == null) { @@ -152,6 +141,7 @@ public class ModelUtils { // model has dependencies. Check if the dependencies are already inserted in the ordered list Collection startedModels = Collections2.transform(dependencies, new Function() { + @Override public IModel apply(String arg0) { return models.get(arg0); } @@ -163,25 +153,31 @@ public class ModelUtils { } } } - + // implement here a safeguard in case no models has been added to orderedModels if(!skippedModels.isEmpty() && skippedModels.size() == modelsToLoad.size()) { - Activator.log.error("Impossible to load models. Cycles in dependency graph for the following set of models: "+modelsToLoad, null); + Activator.log.error("Impossible to load models. Cycles in dependency graph for the following set of models: " + modelsToLoad, null); break; } else { modelsToLoad = skippedModels; } - } while(!modelsToLoad.isEmpty()); - + } while(!modelsToLoad.isEmpty()); + return orderedModels; } - + /** - * Returns the resource from the model set. If the resource is not yet in the resource set, it will create it. Once it is created, if asked, it will load it. If it is already present, it will not load it. - * @param modelSet model set in which the resource should be - * @param loadAfterCreation true if the resource should be load if it has been created - * @param resourceURI the uri of the resource - * @param contentType the content type identifier of the resource if it has to be created. + * Returns the resource from the model set. If the resource is not yet in the resource set, it will create it. Once it is created, if asked, it + * will load it. If it is already present, it will not load it. + * + * @param modelSet + * model set in which the resource should be + * @param loadAfterCreation + * true if the resource should be load if it has been created + * @param resourceURI + * the uri of the resource + * @param contentType + * the content type identifier of the resource if it has to be created. * @return the resource found or created */ public static Resource getOrCreateResource(ModelSet modelSet, boolean loadAfterCreation, URI resourceURI, String contentType) { @@ -191,10 +187,10 @@ public class ModelUtils { if(loadAfterCreation) { try { resource.load(modelSet.getLoadOptions()); - } catch(IOException e) { - // physical resource does not exists, but EMF resource itself is build. + } catch (IOException e) { + // physical resource does not exists, but EMF resource itself is build. Activator.log.debug(e.getMessage()); - } + } } } return resource; -- cgit v1.2.3