diff options
Diffstat (limited to 'plugins/infra')
4 files changed, 82 insertions, 44 deletions
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF index 6df6221986a..c3162af7f52 100644 --- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF @@ -24,7 +24,7 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.6.0,4.0.0)", org.eclipse.pde.core;bundle-version="[3.14.100,4.0.0)";resolution:=optional Bundle-Vendor: Eclipse Modeling Project Bundle-ActivationPolicy: lazy -Bundle-Version: 4.3.0.qualifier +Bundle-Version: 4.4.0.qualifier Bundle-Name: EMF Tools Bundle-Activator: org.eclipse.papyrus.infra.emf.Activator Bundle-ManifestVersion: 2 diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/pom.xml b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/pom.xml index ebd53f9ab15..0001062f524 100644 --- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/pom.xml +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/pom.xml @@ -9,6 +9,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.infra.emf</artifactId> - <version>4.3.0-SNAPSHOT</version> + <version>4.4.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/api/IModelSetService.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/api/IModelSetService.java index 62451b839f6..5f6d369c0b1 100644 --- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/api/IModelSetService.java +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/api/IModelSetService.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2023 CEA LIST and others.s + * Copyright (c) 2023 CEA LIST and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * Pauline DEVILLE (CEA LIST) pauline.deville@cea.fr - Bug 582415 * *****************************************************************************/ @@ -21,7 +22,7 @@ import org.eclipse.papyrus.infra.core.resource.ModelSet; import org.eclipse.papyrus.infra.core.services.ServicesRegistry; /** - * this class has all methods that implements use cases around model set. + * This class has all methods that implements use cases around model set. * * @since 4.3 * @@ -29,27 +30,43 @@ import org.eclipse.papyrus.infra.core.services.ServicesRegistry; public interface IModelSetService { /** - * get the current modelSet from a services registry + * Get the current modelSet from a services registry * * @param servicesRegistry - * the services registry see papyrus core + * the services registry see Papyrus core + * @return the ModelSet associated to the servicesRegistry if any, null otherwise **/ public ModelSet getModelSet(ServicesRegistry servicesRegistry); /** - * create a modelSet, a command is executed in the command stack, for info + * Create a modelSet, a command is executed in the command stack, for info * * @param project * the project where we want to create a modelSet + * @return the newly created ModelSet of null if cannot **/ public ModelSet createModelSet(IProject project); /** - * load a model set from a given uri and given services registry + * Create a modelSet, a command is executed in the command stack, for info * * @param uri + * the uri of the project where we want to create a modelSet + * @param modelName + * the model name + * @return the newly created ModelSet of null if cannot + */ + ModelSet createModelSet(URI uri, String modelName); + + /** + * Load a model set from a given uri and given services registry + * + * @param uri + * the uri of the model to load * @param servicesRegistry - * @return the model set associate to the uri and services registry. + * the service registry associated + * @return the model set associated to the uri and services registry. */ public ModelSet loadModelSet(URI uri, ServicesRegistry servicesRegistry); + } diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/internal/ModelSetService.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/internal/ModelSetService.java index 6c21a83e5fc..c95678e4293 100644 --- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/internal/ModelSetService.java +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/internal/ModelSetService.java @@ -10,6 +10,7 @@ * * Contributors: * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * Pauline DEVILLE (CEA LIST) pauline.deville@cea.fr - Bug 582415 * *****************************************************************************/ @@ -46,9 +47,12 @@ import com.google.common.collect.Iterables; public class ModelSetService implements IModelSetService { /** - * @see org.org.eclipse.papyrus.infra.emf.api.IModelSetService#getModelSet() * - * @return + * @see org.eclipse.papyrus.infra.emf.api.IModelSetService#getModelSet(org.eclipse.papyrus.infra.core.services.ServicesRegistry) + * + * @param servicesRegistry + * the services registry see Papyrus core + * @return the ModelSet associated to the servicesRegistry if any, null otherwise */ @Override public ModelSet getModelSet(ServicesRegistry servicesRegistry) { @@ -65,60 +69,77 @@ public class ModelSetService implements IModelSetService { * @see org.eclipse.papyrus.infra.emf.api.IModelSetService#createModelSet(org.eclipse.core.resources.IProject) * * @param project - * @return + * the project where we want to create a modelSet + * @return the newly created ModelSet of null if cannot */ @Override public ModelSet createModelSet(IProject project) { + URI diURI = URI.createPlatformResourceURI(project.getName(), false);// the name of the project + return createModelSet(diURI, project.getName()); + } + + /** + * + * @see org.eclipse.papyrus.infra.emf.api.IModelSetService#createModelSet(org.eclipse.emf.common.util.URI, java.lang.String) + * + * @param uri + * the uri of the project where we want to create a modelSet + * @param modelName + * the model name + * @return the newly created ModelSet of null if cannot + */ + @Override + public ModelSet createModelSet(final URI uri, final String modelName) { ModelSet modelSet = null; - if (project != null) { - ServicesRegistry registry = null; + ServicesRegistry registry = null; + try { + registry = new ExtensionServicesRegistry(org.eclipse.papyrus.infra.core.Activator.PLUGIN_ID); + } catch (ServiceException e) { + // Silently catch exception + } + if (registry != null) { + try { + registry.startServicesByClassKeys(ModelSet.class); + } catch (ServiceException ex) { + // Silently catch exception + } try { - registry = new ExtensionServicesRegistry(org.eclipse.papyrus.infra.core.Activator.PLUGIN_ID); - } catch (ServiceException e) { + modelSet = registry.getService(ModelSet.class); + } catch (ServiceException e1) { // Silently catch exception } - if (registry != null) { + if (modelSet != null) { + CommandStack stack = modelSet.getTransactionalEditingDomain().getCommandStack(); + URI diURI = uri.appendSegment(modelName).appendFileExtension(DiModel.DI_FILE_EXTENSION); + Command command = new CreateModelInModelSetCommand(modelSet, diURI); + + if (stack != null && command.canExecute()) { + stack.execute(command); + } try { - registry.startServicesByClassKeys(ModelSet.class); - } catch (ServiceException ex) { + registry.startRegistry(); + } catch (ServiceMultiException e) { // Silently catch exception } try { - modelSet = registry.getService(ModelSet.class); - } catch (ServiceException e1) { + registry.getService(IPageManager.class); + } catch (ServiceException e) { // Silently catch exception } - if (modelSet != null) { - CommandStack stack = modelSet.getTransactionalEditingDomain().getCommandStack(); - URI diURI = URI.createPlatformResourceURI(project.getName(), false);// the name of the project - diURI = diURI.appendSegment(project.getName());// the name of the model - diURI = diURI.appendFileExtension(DiModel.DI_FILE_EXTENSION); - Command command = new CreateModelInModelSetCommand(modelSet, diURI); - - if (stack != null && command.canExecute()) { - stack.execute(command); - } - try { - registry.startRegistry(); - } catch (ServiceMultiException e) { - // Silently catch exception - } - try { - registry.getService(IPageManager.class); - } catch (ServiceException e) { - // Silently catch exception - } - } } } return modelSet; } /** - * @see org.org.eclipse.papyrus.infra.emf.api.IModelSetService#loadModelSet(org.eclipse.emf.common.util.URI) + * + * @see org.eclipse.papyrus.infra.emf.api.IModelSetService#loadModelSet(org.eclipse.emf.common.util.URI, org.eclipse.papyrus.infra.core.services.ServicesRegistry) * * @param uri - * @return + * the uri of the model to load + * @param servicesRegistry + * the service registry associated + * @return the model set associated to the uri and services registry. */ @Override public ModelSet loadModelSet(URI uri, ServicesRegistry registry) { |