diff options
Diffstat (limited to 'plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core')
41 files changed, 2776 insertions, 2776 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/CommandFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/CommandFactory.java index 947e315d0fe..1046cbb7727 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/CommandFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/CommandFactory.java @@ -1,59 +1,59 @@ -/**
- * Copyright (c) 2011 CEA LIST.
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 345730 - Deleting an element in the model breaks the table
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.command.SetResourceContentCommand;
-
-public final class CommandFactory {
-
- private CommandFactory() {
- // Must not be called
- }
-
- /**
- * This method creates a command to set a collection of element to a resource
- *
- * @param resource
- * the resource to set
- * @param content
- * a collection of EObject to set as the content of the resource.
- * @return an EMF Command
- */
- public static Command createSetResourceContentsCommand(final Resource resource,
- final Collection<EObject> content) {
- Command result = new SetResourceContentCommand(resource, content);
- return result;
- }
-
- /**
- * This method creates a command to set an EObject to a resource
- *
- * @param resource
- * the resource to set
- * @param eObject
- * an EObject to set as the content of the resource.
- * @return an EMF Command
- */
- public static Command createSetResourceContentsCommand(final Resource resource,
- final EObject eObject) {
- List<EObject> content = new ArrayList<EObject>();
- content.add(eObject);
- Command result = createSetResourceContentsCommand(resource, content);
- return result;
- }
-}
+/** + * Copyright (c) 2011 CEA LIST. + * 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: + * Gregoire Dupe (Mia-Software) - Bug 345730 - Deleting an element in the model breaks the table + */ +package org.eclipse.papyrus.emf.facet.util.emf.core; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.command.SetResourceContentCommand; + +public final class CommandFactory { + + private CommandFactory() { + // Must not be called + } + + /** + * This method creates a command to set a collection of element to a resource + * + * @param resource + * the resource to set + * @param content + * a collection of EObject to set as the content of the resource. + * @return an EMF Command + */ + public static Command createSetResourceContentsCommand(final Resource resource, + final Collection<EObject> content) { + Command result = new SetResourceContentCommand(resource, content); + return result; + } + + /** + * This method creates a command to set an EObject to a resource + * + * @param resource + * the resource to set + * @param eObject + * an EObject to set as the content of the resource. + * @return an EMF Command + */ + public static Command createSetResourceContentsCommand(final Resource resource, + final EObject eObject) { + List<EObject> content = new ArrayList<EObject>(); + content.add(eObject); + Command result = createSetResourceContentsCommand(resource, content); + return result; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/EmfDebugUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/EmfDebugUtils.java index 444de9809b5..818ccb269e8 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/EmfDebugUtils.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/EmfDebugUtils.java @@ -1,91 +1,91 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 366804 - [Restructuring] Table widget upgrade
- * Grégoire Dupé (Mia-Software) - Bug 365843 - [Unit Test Failure][0.2/3.8][0.2/4.2] org.eclipse.papyrus.emf.facet.widgets.nattable.tests.swtbot.Bug344925Test.testBug344925
- * Grégoire Dupé (Mia-Software) - Bug 367700 - [Unit Test Failure][0.2/3.8] org.eclipse.papyrus.emf.facet.widgets.table.tests.internal.v0_2.swtbot.NatTableUITests.testOpenLoadCustomizationDialog
- * Grégoire Dupé (Mia-Software) - Bug 373078 - API Cleaning
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.emf.core;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Collections;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.papyrus.emf.facet.util.core.DebugUtils;
-import org.eclipse.papyrus.emf.facet.util.emf.core.exception.DebugRuntimeException;
-
-/**
- * @since 0.2
- */
-public final class EmfDebugUtils {
-
- private EmfDebugUtils() {
- // Must not be used
- }
-
- public static String debugCommand(final Command command) {
- return debugCommand(command, 1);
- }
-
- private static String debugCommand(final Command command, final int indent) {
- StringBuffer result = new StringBuffer();
- result.append('\n');
- for (int i = 0; i < indent; i++) {
- result.append("--"); //$NON-NLS-1$
- }
- result.append(command.getClass().getSimpleName());
- result.append(" \""); //$NON-NLS-1$
- result.append(command.getLabel());
- result.append("\" "); //$NON-NLS-1$
- result.append(" canExecute="); //$NON-NLS-1$
- result.append(command.canExecute());
- result.append(" ("); //$NON-NLS-1$
- result.append(command.getClass().getName());
- result.append(')');
- if (command instanceof CompoundCommand) {
- CompoundCommand compoundCommand = (CompoundCommand) command;
- for (Command subCommand : compoundCommand.getCommandList()) {
- result.append(debugCommand(subCommand, indent + 1));
- }
- }
- return result.toString();
- }
-
- /**
- * This method can be used to easily dump a model into a file. This method has been written to be
- * used by unit tests.
- *
- * @param eObject
- * @param fileExtension
- * @return a string explaining where the file has been saved.
- */
- public static String getStateDumpMessage(final EObject eObject, final String fileExtension) {
- final File file = new File(DebugUtils.getCallerLocation(1) + '.' + fileExtension);
- URI uri = URI.createFileURI(file.getAbsolutePath());
- ResourceSet resourceSet = new ResourceSetImpl();
- Resource resource = resourceSet.createResource(uri);
- resource.getContents().add(EcoreUtil.copy(eObject));
- try {
- resource.save(Collections.EMPTY_MAP);
- } catch (IOException e) {
- throw new DebugRuntimeException(e);
- }
- return "A model containing the dumped EObject has been saved in " + file.getAbsolutePath(); //$NON-NLS-1$
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 366804 - [Restructuring] Table widget upgrade + * Grégoire Dupé (Mia-Software) - Bug 365843 - [Unit Test Failure][0.2/3.8][0.2/4.2] org.eclipse.papyrus.emf.facet.widgets.nattable.tests.swtbot.Bug344925Test.testBug344925 + * Grégoire Dupé (Mia-Software) - Bug 367700 - [Unit Test Failure][0.2/3.8] org.eclipse.papyrus.emf.facet.widgets.table.tests.internal.v0_2.swtbot.NatTableUITests.testOpenLoadCustomizationDialog + * Grégoire Dupé (Mia-Software) - Bug 373078 - API Cleaning + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.emf.core; + +import java.io.File; +import java.io.IOException; +import java.util.Collections; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.CompoundCommand; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.papyrus.emf.facet.util.core.DebugUtils; +import org.eclipse.papyrus.emf.facet.util.emf.core.exception.DebugRuntimeException; + +/** + * @since 0.2 + */ +public final class EmfDebugUtils { + + private EmfDebugUtils() { + // Must not be used + } + + public static String debugCommand(final Command command) { + return debugCommand(command, 1); + } + + private static String debugCommand(final Command command, final int indent) { + StringBuffer result = new StringBuffer(); + result.append('\n'); + for (int i = 0; i < indent; i++) { + result.append("--"); //$NON-NLS-1$ + } + result.append(command.getClass().getSimpleName()); + result.append(" \""); //$NON-NLS-1$ + result.append(command.getLabel()); + result.append("\" "); //$NON-NLS-1$ + result.append(" canExecute="); //$NON-NLS-1$ + result.append(command.canExecute()); + result.append(" ("); //$NON-NLS-1$ + result.append(command.getClass().getName()); + result.append(')'); + if (command instanceof CompoundCommand) { + CompoundCommand compoundCommand = (CompoundCommand) command; + for (Command subCommand : compoundCommand.getCommandList()) { + result.append(debugCommand(subCommand, indent + 1)); + } + } + return result.toString(); + } + + /** + * This method can be used to easily dump a model into a file. This method has been written to be + * used by unit tests. + * + * @param eObject + * @param fileExtension + * @return a string explaining where the file has been saved. + */ + public static String getStateDumpMessage(final EObject eObject, final String fileExtension) { + final File file = new File(DebugUtils.getCallerLocation(1) + '.' + fileExtension); + URI uri = URI.createFileURI(file.getAbsolutePath()); + ResourceSet resourceSet = new ResourceSetImpl(); + Resource resource = resourceSet.createResource(uri); + resource.getContents().add(EcoreUtil.copy(eObject)); + try { + resource.save(Collections.EMPTY_MAP); + } catch (IOException e) { + throw new DebugRuntimeException(e); + } + return "A model containing the dumped EObject has been saved in " + file.getAbsolutePath(); //$NON-NLS-1$ + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/IBrowserRegistry.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/IBrowserRegistry.java index 394a36b7f51..82550d6d162 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/IBrowserRegistry.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/IBrowserRegistry.java @@ -1,85 +1,85 @@ -/**********************************************************************************
- * Copyright (c) 2011 Mia-Software.
- * 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:
- * Nicolas Guyomar (Mia-Software) - Bug 333652 Extension point offering the possibility to declare an EPackage browser
- * Fabien Giquel (Mia-Software) -Bug 335218 - Extension point for registering EObject, EPackage, model editor
- * Nicolas Bros (Mia-Software) - Bug 335218 - Extension point for registering EObject, EPackage, model editor
- ***********************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.emf.core;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.registry.BrowserRegistry;
-
-/**
- * A registry for the {@link EObject}, {@link EPackage}, and {@link Resource} browser opener
- * extension point. It can be used to open a default model browser (chosen by the user) or get a
- * list of model browsers that can be opened on a model element, {@link EPackage} or {@link Resource}.
- */
-public interface IBrowserRegistry {
-
- public static IBrowserRegistry INSTANCE = new BrowserRegistry();
-
- /**
- * Browse the given package using the default EPackage browser opener
- *
- * @param ePackage
- * the element to browse
- */
- public void browseEPackage(EPackage ePackage);
-
- /**
- * Browse the given resource using the default Resource browser opener
- *
- * @param resource
- * the element to browse
- */
- public void browseResource(Resource resource);
-
- /**
- * Browse the given eObject using the default EObject browser opener
- *
- * @param eObject
- * the element to browse
- */
- public void browseEObject(EObject eObject);
-
- /**
- * @return the registered EPackage browser openers
- */
- public List<IEPackageBrowserOpener> getAllRegisteredEPackageBrowsers();
-
- /**
- * @return the registered EObject browser openers
- */
- public List<IEObjectBrowserOpener> getAllRegisteredEObjectBrowsers();
-
- /**
- * @return the registered Resource browser openers
- */
- public List<IResourceBrowserOpener> getAllRegisteredResourceBrowsers();
-
- /**
- * @return the default EPackage browser opener, can be <code>null</code>
- */
- public IEPackageBrowserOpener getDefaultEPackageBrowserOpener();
-
- /**
- * @return the default EObject browser opener, can be <code>null</code>
- */
- public IEObjectBrowserOpener getDefaultEObjectBrowserOpener();
-
- /**
- * @return the default Resource browser opener, can be <code>null</code>
- */
- public IResourceBrowserOpener getDefaultResourceBrowserOpener();
-
-}
+/********************************************************************************** + * Copyright (c) 2011 Mia-Software. + * 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: + * Nicolas Guyomar (Mia-Software) - Bug 333652 Extension point offering the possibility to declare an EPackage browser + * Fabien Giquel (Mia-Software) -Bug 335218 - Extension point for registering EObject, EPackage, model editor + * Nicolas Bros (Mia-Software) - Bug 335218 - Extension point for registering EObject, EPackage, model editor + ***********************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.emf.core; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.registry.BrowserRegistry; + +/** + * A registry for the {@link EObject}, {@link EPackage}, and {@link Resource} browser opener + * extension point. It can be used to open a default model browser (chosen by the user) or get a + * list of model browsers that can be opened on a model element, {@link EPackage} or {@link Resource}. + */ +public interface IBrowserRegistry { + + public static IBrowserRegistry INSTANCE = new BrowserRegistry(); + + /** + * Browse the given package using the default EPackage browser opener + * + * @param ePackage + * the element to browse + */ + public void browseEPackage(EPackage ePackage); + + /** + * Browse the given resource using the default Resource browser opener + * + * @param resource + * the element to browse + */ + public void browseResource(Resource resource); + + /** + * Browse the given eObject using the default EObject browser opener + * + * @param eObject + * the element to browse + */ + public void browseEObject(EObject eObject); + + /** + * @return the registered EPackage browser openers + */ + public List<IEPackageBrowserOpener> getAllRegisteredEPackageBrowsers(); + + /** + * @return the registered EObject browser openers + */ + public List<IEObjectBrowserOpener> getAllRegisteredEObjectBrowsers(); + + /** + * @return the registered Resource browser openers + */ + public List<IResourceBrowserOpener> getAllRegisteredResourceBrowsers(); + + /** + * @return the default EPackage browser opener, can be <code>null</code> + */ + public IEPackageBrowserOpener getDefaultEPackageBrowserOpener(); + + /** + * @return the default EObject browser opener, can be <code>null</code> + */ + public IEObjectBrowserOpener getDefaultEObjectBrowserOpener(); + + /** + * @return the default Resource browser opener, can be <code>null</code> + */ + public IResourceBrowserOpener getDefaultResourceBrowserOpener(); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ICatalogManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ICatalogManager.java index e8370bd5f22..4d007b6445d 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ICatalogManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ICatalogManager.java @@ -1,54 +1,54 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 334000 Simple catalog manager
- * Nicolas Guyomar (Mia-Software) - Bug 334000 Simple catalog manager
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.util.emf.catalog.CatalogSet;
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.catalog.CatalogSetManager;
-
-/**
- * Manager for catalogs containing registered elements defined in models.
- *
- * @since 0.2
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface ICatalogManager {
-
- /**
- * Return <code>true</code> if the eObject can be managed as a catalog entry.
- *
- * @param root
- * the root element of a catalog
- * @return whether the given element is of the right type to be a catalog root
- */
- public boolean canBeManaged(EObject root);
-
- /**
- * This method is called by {@link CatalogSetManager} when a model registration that can be
- * managed (according to {@link ICatalogManager#canBeManaged(EObject) canBeManaged}) is detected
- * while loading. This method adds the given root model element to the catalog.
- *
- * @param root
- * a root element of a model that should be added to the catalog
- */
- public void manage(EObject root);
-
- /**
- * This method is called by the {@link CatalogSetManager} after the instantiation of this {@link ICatalogManager}. This method must attach the catalog(s) managed by this {@link ICatalogManager} to the given <code>catalogSet</code>.
- *
- * @param catalogSet
- * the {@link CatalogSet} to which the catalog managed by this {@link ICatalogManager} should be attached
- */
- public void setCatalogSet(CatalogSet catalogSet);
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 334000 Simple catalog manager + * Nicolas Guyomar (Mia-Software) - Bug 334000 Simple catalog manager + */ +package org.eclipse.papyrus.emf.facet.util.emf.core; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.util.emf.catalog.CatalogSet; +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.catalog.CatalogSetManager; + +/** + * Manager for catalogs containing registered elements defined in models. + * + * @since 0.2 + * @noextend This interface is not intended to be extended by clients. + */ +public interface ICatalogManager { + + /** + * Return <code>true</code> if the eObject can be managed as a catalog entry. + * + * @param root + * the root element of a catalog + * @return whether the given element is of the right type to be a catalog root + */ + public boolean canBeManaged(EObject root); + + /** + * This method is called by {@link CatalogSetManager} when a model registration that can be + * managed (according to {@link ICatalogManager#canBeManaged(EObject) canBeManaged}) is detected + * while loading. This method adds the given root model element to the catalog. + * + * @param root + * a root element of a model that should be added to the catalog + */ + public void manage(EObject root); + + /** + * This method is called by the {@link CatalogSetManager} after the instantiation of this {@link ICatalogManager}. This method must attach the catalog(s) managed by this {@link ICatalogManager} to the given <code>catalogSet</code>. + * + * @param catalogSet + * the {@link CatalogSet} to which the catalog managed by this {@link ICatalogManager} should be attached + */ + public void setCatalogSet(CatalogSet catalogSet); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ICatalogSetManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ICatalogSetManager.java index c5c83e655ef..d64c4e9b5de 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ICatalogSetManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ICatalogSetManager.java @@ -1,64 +1,64 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 334000 Simple catalog manager
- * Nicolas Guyomar (Mia-Software) - Bug 334000 Simple catalog manager
- * Nicolas Guyomar (Mia-Software) - Bug 334529 ICatalogManager should be exposed in org.eclipse.papyrus.emf.facet.common.core
- * Nicolas Guyomar (Mia-Software) - Bug 338811 - A model registration method in the interface ICatalogSetManager
- * Gregoire Dupe (Mia-Software) - Bug 362084 - Get the instance of a catalog manager
- * Gregoire Dupe (Mia-Software) - Bug 362087 - [Deprecated] org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.papyrus.emf.facet.util.emf.catalog.Catalog;
-import org.eclipse.papyrus.emf.facet.util.emf.catalog.CatalogSet;
-import org.eclipse.papyrus.emf.facet.util.emf.core.exception.InvalidFacetSetException;
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.catalog.CatalogSetManager;
-import org.osgi.framework.Bundle;
-
-/**
- * @deprecated This interface has been replaced by {@link ICatalogSetManager2}
- */
-@Deprecated
-public interface ICatalogSetManager {
-
- /**
- * This method returns the {@link CatalogSet} object which contains all the registered catalogs.
- *
- * @return the set of registered {@link Catalog}s
- */
- public CatalogSet getCatalogSet();
-
- /**
- * The singleton instance of this {@link ICatalogSetManager}.
- */
- public static ICatalogSetManager INSTANCE = CatalogSetManager.INSTANCE;
-
- /**
- * Return the bundle containing the file from which we have created the given resource.
- *
- * @param eResource
- * @return the Bundle matching the given resource.
- * @author Nicolas Guyomar
- */
- public Bundle getBundleByResource(Resource eResource);
-
- /**
- * This method takes a file to register it as a "modelDeclaration" extension in its containing
- * plug-in.
- *
- * @param file
- * the file to be registered as a "modelDeclaration"
- * @throws InvalidFacetSetException
- */
- public void registerModelDeclaration(IFile file) throws InvalidFacetSetException;
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 334000 Simple catalog manager + * Nicolas Guyomar (Mia-Software) - Bug 334000 Simple catalog manager + * Nicolas Guyomar (Mia-Software) - Bug 334529 ICatalogManager should be exposed in org.eclipse.papyrus.emf.facet.common.core + * Nicolas Guyomar (Mia-Software) - Bug 338811 - A model registration method in the interface ICatalogSetManager + * Gregoire Dupe (Mia-Software) - Bug 362084 - Get the instance of a catalog manager + * Gregoire Dupe (Mia-Software) - Bug 362087 - [Deprecated] org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager + */ +package org.eclipse.papyrus.emf.facet.util.emf.core; + +import org.eclipse.core.resources.IFile; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.papyrus.emf.facet.util.emf.catalog.Catalog; +import org.eclipse.papyrus.emf.facet.util.emf.catalog.CatalogSet; +import org.eclipse.papyrus.emf.facet.util.emf.core.exception.InvalidFacetSetException; +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.catalog.CatalogSetManager; +import org.osgi.framework.Bundle; + +/** + * @deprecated This interface has been replaced by {@link ICatalogSetManager2} + */ +@Deprecated +public interface ICatalogSetManager { + + /** + * This method returns the {@link CatalogSet} object which contains all the registered catalogs. + * + * @return the set of registered {@link Catalog}s + */ + public CatalogSet getCatalogSet(); + + /** + * The singleton instance of this {@link ICatalogSetManager}. + */ + public static ICatalogSetManager INSTANCE = CatalogSetManager.INSTANCE; + + /** + * Return the bundle containing the file from which we have created the given resource. + * + * @param eResource + * @return the Bundle matching the given resource. + * @author Nicolas Guyomar + */ + public Bundle getBundleByResource(Resource eResource); + + /** + * This method takes a file to register it as a "modelDeclaration" extension in its containing + * plug-in. + * + * @param file + * the file to be registered as a "modelDeclaration" + * @throws InvalidFacetSetException + */ + public void registerModelDeclaration(IFile file) throws InvalidFacetSetException; + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ICatalogSetManager2.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ICatalogSetManager2.java index b3cfa5ea261..dede1027783 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ICatalogSetManager2.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ICatalogSetManager2.java @@ -1,83 +1,83 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 334000 Simple catalog manager
- * Nicolas Guyomar (Mia-Software) - Bug 334000 Simple catalog manager
- * Nicolas Guyomar (Mia-Software) - Bug 334529 ICatalogManager should be exposed in org.eclipse.papyrus.emf.facet.common.core
- * Nicolas Guyomar (Mia-Software) - Bug 338811 - A model registration method in the interface ICatalogSetManager
- * Gregoire Dupe (Mia-Software) - Bug 362084 - Get the instance of a catalog manager
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.papyrus.emf.facet.util.emf.catalog.Catalog;
-import org.eclipse.papyrus.emf.facet.util.emf.catalog.CatalogSet;
-import org.eclipse.papyrus.emf.facet.util.emf.core.exception.InvalidFacetSetException;
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.catalog.CatalogSetManager;
-import org.osgi.framework.Bundle;
-
-/**
- * @since 0.2
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ICatalogSetManager2 {
-
- /**
- * This method returns the {@link CatalogSet} object which contains all the registered catalogs.
- *
- * @return the set of registered {@link Catalog}s
- */
- public CatalogSet getCatalogSet();
-
- /**
- * The singleton instance of this {@link ICatalogSetManager2}.
- *
- * @deprecated has been replaced by
- * org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManagerFactory
- * .createICatalogSetManager(ResourceSet)
- */
- @Deprecated
- public static ICatalogSetManager2 INSTANCE = CatalogSetManager.INSTANCE;
-
- /**
- * Return the bundle containing the file from which we have created the given resource.
- *
- * @param eResource
- * the EMF Resource
- * @return the {@link Bundle} matching the given resource, or <code>null</code> if the resource
- * is not defined in a Bundle.
- * @throws IllegalArgumentException
- * if the resource is <code>null</code>
- *
- * @author Nicolas Guyomar
- */
- public Bundle getBundleByResource(Resource eResource);
-
- /**
- * This method takes a file to register it as a "modelDeclaration" extension in its containing
- * plug-in.
- *
- * @param file
- * the file to be registered as a "modelDeclaration"
- * @throws InvalidFacetSetException
- */
- public void registerModelDeclaration(IFile file) throws InvalidFacetSetException;
-
- /**
- * Return the registered catalogs conforming to the parameter class.
- *
- * @return a list of {@link ICatalogManager}
- */
- public <T> List<T> getCatalogManagerByType(Class<? extends T> catalogManagerClass);
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 334000 Simple catalog manager + * Nicolas Guyomar (Mia-Software) - Bug 334000 Simple catalog manager + * Nicolas Guyomar (Mia-Software) - Bug 334529 ICatalogManager should be exposed in org.eclipse.papyrus.emf.facet.common.core + * Nicolas Guyomar (Mia-Software) - Bug 338811 - A model registration method in the interface ICatalogSetManager + * Gregoire Dupe (Mia-Software) - Bug 362084 - Get the instance of a catalog manager + */ +package org.eclipse.papyrus.emf.facet.util.emf.core; + +import java.util.List; + +import org.eclipse.core.resources.IFile; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.papyrus.emf.facet.util.emf.catalog.Catalog; +import org.eclipse.papyrus.emf.facet.util.emf.catalog.CatalogSet; +import org.eclipse.papyrus.emf.facet.util.emf.core.exception.InvalidFacetSetException; +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.catalog.CatalogSetManager; +import org.osgi.framework.Bundle; + +/** + * @since 0.2 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ICatalogSetManager2 { + + /** + * This method returns the {@link CatalogSet} object which contains all the registered catalogs. + * + * @return the set of registered {@link Catalog}s + */ + public CatalogSet getCatalogSet(); + + /** + * The singleton instance of this {@link ICatalogSetManager2}. + * + * @deprecated has been replaced by + * org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManagerFactory + * .createICatalogSetManager(ResourceSet) + */ + @Deprecated + public static ICatalogSetManager2 INSTANCE = CatalogSetManager.INSTANCE; + + /** + * Return the bundle containing the file from which we have created the given resource. + * + * @param eResource + * the EMF Resource + * @return the {@link Bundle} matching the given resource, or <code>null</code> if the resource + * is not defined in a Bundle. + * @throws IllegalArgumentException + * if the resource is <code>null</code> + * + * @author Nicolas Guyomar + */ + public Bundle getBundleByResource(Resource eResource); + + /** + * This method takes a file to register it as a "modelDeclaration" extension in its containing + * plug-in. + * + * @param file + * the file to be registered as a "modelDeclaration" + * @throws InvalidFacetSetException + */ + public void registerModelDeclaration(IFile file) throws InvalidFacetSetException; + + /** + * Return the registered catalogs conforming to the parameter class. + * + * @return a list of {@link ICatalogManager} + */ + public <T> List<T> getCatalogManagerByType(Class<? extends T> catalogManagerClass); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ICatalogSetManagerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ICatalogSetManagerFactory.java index cf4e54d9c64..46ad0df465c 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ICatalogSetManagerFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ICatalogSetManagerFactory.java @@ -1,26 +1,26 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core;
-
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.catalog.CatalogSetManagerFactory;
-
-/**
- * @since 0.2
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ICatalogSetManagerFactory {
- ICatalogSetManagerFactory DEFAULT = new CatalogSetManagerFactory();
-
- ICatalogSetManager2 createICatalogSetManager(ResourceSet resourceSet);
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + */ +package org.eclipse.papyrus.emf.facet.util.emf.core; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.catalog.CatalogSetManagerFactory; + +/** + * @since 0.2 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ICatalogSetManagerFactory { + ICatalogSetManagerFactory DEFAULT = new CatalogSetManagerFactory(); + + ICatalogSetManager2 createICatalogSetManager(ResourceSet resourceSet); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/IEObjectBrowserOpener.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/IEObjectBrowserOpener.java index a09ec6a4cbc..5bcad9574b3 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/IEObjectBrowserOpener.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/IEObjectBrowserOpener.java @@ -1,39 +1,39 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Fabien Giquel (Mia-Software)
- * Nicolas Bros (Mia-Software) - Bug 335218 - Extension point for registering EObject, EPackage, model editor
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core;
-
-import org.eclipse.emf.ecore.EObject;
-
-/**
- * This class is used to register a Browser (typically an Eclipse editor or view), that can be
- * opened from a given EObject. The registration is done through the
- * "org.eclipse.papyrus.emf.facet.util.emf.core.modelViewer" extension point.
- */
-public interface IEObjectBrowserOpener {
-
- /**
- * This method opens the given {@link EObject} with the browser corresponding to this {@link IEObjectBrowserOpener}.
- *
- * @param eObject
- * the {@link EObject} to be opened
- */
- public void openEObject(final EObject eObject);
-
- /**
- * Return a human readable name for the {@link EObject} browser.
- *
- * @return a human readable name for the {@link EObject} browser
- */
- public String getBrowserName();
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Fabien Giquel (Mia-Software) + * Nicolas Bros (Mia-Software) - Bug 335218 - Extension point for registering EObject, EPackage, model editor + */ +package org.eclipse.papyrus.emf.facet.util.emf.core; + +import org.eclipse.emf.ecore.EObject; + +/** + * This class is used to register a Browser (typically an Eclipse editor or view), that can be + * opened from a given EObject. The registration is done through the + * "org.eclipse.papyrus.emf.facet.util.emf.core.modelViewer" extension point. + */ +public interface IEObjectBrowserOpener { + + /** + * This method opens the given {@link EObject} with the browser corresponding to this {@link IEObjectBrowserOpener}. + * + * @param eObject + * the {@link EObject} to be opened + */ + public void openEObject(final EObject eObject); + + /** + * Return a human readable name for the {@link EObject} browser. + * + * @return a human readable name for the {@link EObject} browser + */ + public String getBrowserName(); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/IEPackageBrowserOpener.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/IEPackageBrowserOpener.java index 4a489a1c94e..3bc4ae2b5b6 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/IEPackageBrowserOpener.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/IEPackageBrowserOpener.java @@ -1,39 +1,39 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Nicolas Guyomar (Mia-Software) - Bug 333652 Extension point offering the possibility to declare an EPackage browser
- * Nicolas Bros (Mia-Software) - Bug 335218 - Extension point for registering EObject, EPackage, model editor
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core;
-
-import org.eclipse.emf.ecore.EPackage;
-
-/**
- * This class is used to register a Browser (typically an Eclipse editor or view), that can be
- * opened from a given EPackage. The registration is done through the
- * "org.eclipse.papyrus.emf.facet.util.emf.core.modelViewer" extension point.
- */
-public interface IEPackageBrowserOpener {
-
- /**
- * This method opens the given {@link EPackage} with the browser corresponding to this {@link IEPackageBrowserOpener}.
- *
- * @param ePackage
- * the {@link EPackage} to be opened
- */
- public void openEPackage(final EPackage ePackage);
-
- /**
- * Return a human readable name for the {@link EPackage} browser.
- *
- * @return a human readable name for the {@link EPackage} browser
- */
- public String getBrowserName();
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Nicolas Guyomar (Mia-Software) - Bug 333652 Extension point offering the possibility to declare an EPackage browser + * Nicolas Bros (Mia-Software) - Bug 335218 - Extension point for registering EObject, EPackage, model editor + */ +package org.eclipse.papyrus.emf.facet.util.emf.core; + +import org.eclipse.emf.ecore.EPackage; + +/** + * This class is used to register a Browser (typically an Eclipse editor or view), that can be + * opened from a given EPackage. The registration is done through the + * "org.eclipse.papyrus.emf.facet.util.emf.core.modelViewer" extension point. + */ +public interface IEPackageBrowserOpener { + + /** + * This method opens the given {@link EPackage} with the browser corresponding to this {@link IEPackageBrowserOpener}. + * + * @param ePackage + * the {@link EPackage} to be opened + */ + public void openEPackage(final EPackage ePackage); + + /** + * Return a human readable name for the {@link EPackage} browser. + * + * @return a human readable name for the {@link EPackage} browser + */ + public String getBrowserName(); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/IResourceBrowserOpener.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/IResourceBrowserOpener.java index c2ebd32829e..58e38f7a630 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/IResourceBrowserOpener.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/IResourceBrowserOpener.java @@ -1,39 +1,39 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Fabien Giquel (Mia-Software)
- * Nicolas Bros (Mia-Software) - Bug 335218 - Extension point for registering EObject, EPackage, model editor
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core;
-
-import org.eclipse.emf.ecore.resource.Resource;
-
-/**
- * This class is used to register a Browser (typically an Eclipse editor or view), that can be
- * opened from a given EMF Resource. The registration is done through the
- * "org.eclipse.papyrus.emf.facet.util.emf.core.modelViewer" extension point.
- */
-public interface IResourceBrowserOpener {
-
- /**
- * This method opens the given {@link Resource} with the browser corresponding to this {@link IResourceBrowserOpener}.
- *
- * @param resource
- * the {@link Resource} to be opened
- */
- public void openResource(final Resource resource);
-
- /**
- * Return a human readable name for the {@link Resource} browser.
- *
- * @return a human readable name for the {@link Resource} browser
- */
- public String getBrowserName();
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Fabien Giquel (Mia-Software) + * Nicolas Bros (Mia-Software) - Bug 335218 - Extension point for registering EObject, EPackage, model editor + */ +package org.eclipse.papyrus.emf.facet.util.emf.core; + +import org.eclipse.emf.ecore.resource.Resource; + +/** + * This class is used to register a Browser (typically an Eclipse editor or view), that can be + * opened from a given EMF Resource. The registration is done through the + * "org.eclipse.papyrus.emf.facet.util.emf.core.modelViewer" extension point. + */ +public interface IResourceBrowserOpener { + + /** + * This method opens the given {@link Resource} with the browser corresponding to this {@link IResourceBrowserOpener}. + * + * @param resource + * the {@link Resource} to be opened + */ + public void openResource(final Resource resource); + + /** + * Return a human readable name for the {@link Resource} browser. + * + * @return a human readable name for the {@link Resource} browser + */ + public String getBrowserName(); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ModelUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ModelUtils.java index 47ab8ddddd1..41cd7b06003 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ModelUtils.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ModelUtils.java @@ -1,261 +1,261 @@ -/*******************************************************************************
- * Copyright (c) 2009, 2014 Mia-Software, CEA, 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:
- * Nicolas Bros (Mia-Software) - Bug 366367 - To be able to change the "CanBePresentedInTheTable" query
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Laurent Pichierri (Soft-Maint) - Bug 371204 - Compatibility with Helios
- * Gregoire Dupe (Mia-Software) - Bug 371367 - Hierarchical FacetSets
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
- * Christian W. Damus (CEA) - bug 410346
- *
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.emf.core;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.util.FeatureMap;
-import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
-import org.eclipse.emf.edit.provider.IItemLabelProvider;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.papyrus.emf.facet.util.core.internal.exported.StringUtils;
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.Activator;
-
-/**
- * Utility class for models.
- *
- * @since 0.2
- */
-public final class ModelUtils {
-
- /**
- * Meta-model qualified name separator
- */
- private static final String MM_QNAME_SEPARATOR = "::"; //$NON-NLS-1$
-
- /**
- * Utility classes don't need to (and shouldn't) be instantiated.
- */
- private ModelUtils() {
- // prevents instantiation
- }
-
- /**
- * Computes a list of {@link EObject}s from the same {@link ResourceSet} as <code>source</code> that can be assigned to the given feature.
- */
- // Copied from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils.computeAssignableElements(EStructuralFeature, EObject)
- public static List<EObject> computeAssignableElements(final EStructuralFeature feature,
- final EObject source) {
- EClassifier eType = feature.getEType();
-
- // build a list of EObjects assignable to the EReference
- List<EObject> list = new ArrayList<EObject>();
- Resource eResource = source.eResource();
- ResourceSet resourceSet = eResource.getResourceSet();
- TreeIterator<Notifier> allContents = resourceSet.getAllContents();
- while (allContents.hasNext()) {
- Notifier notifier = allContents.next();
- if (notifier instanceof EObject) {
- EObject eObject = (EObject) notifier;
- if (eType.isInstance(eObject)) {
- list.add(eObject);
- }
- }
- }
- return list;
- }
-
- public static boolean isBooleanDataType(final EClassifier classifier) {
- if (classifier instanceof EDataType) {
- EDataType dataType = (EDataType) classifier;
- Class<?> instanceClass = dataType.getInstanceClass();
- return instanceClass == Boolean.class || instanceClass == boolean.class;
- }
- return false;
- }
-
- /**
- * Find all subclasses of the given metaclass in the package registry
- *
- * @param context
- * the metaclass whose subclasses must be found
- * @return all the subclasses
- */
- // Copied from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils.allSubClasses(final EClass context)
- public static List<EClass> allSubClasses(final EClass context) {
- List<EClass> result = new ArrayList<EClass>();
- // Set<Resource> resources = new HashSet<Resource>();
- Collection<String> uris = new ArrayList<String>(EPackage.Registry.INSTANCE.keySet());
- for (String ePackageURI : uris) {
- try {
- EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(ePackageURI);
- EList<EClassifier> eClassifiers = ePackage.getEClassifiers();
- for (EClassifier eClassifier : eClassifiers) {
- if (eClassifier instanceof EClass) {
- EClass eClass = (EClass) eClassifier;
- if (isSuperTypeOf(context, eClass)) {
- result.add(eClass);
- }
- }
- }
- } catch (Exception e) {
- Logger.logError(e, Activator.getDefault());
- }
- }
- return result;
- }
-
- // Copied from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils.isSuperTypeOf(final EClass self, final EClass typeDeclaration)
- public static boolean isSuperTypeOf(final EClass self, final EClass typeDeclaration) {
- return typeDeclaration.getEAllSuperTypes().contains(self);
- }
-
- /** @return the qualified name of the given metaclass */
- // Copied from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils.getMetaclassQualifiedName(final EClassifier eClass)
- public static String getMetaclassQualifiedName(final EClassifier eClass) {
- final ArrayList<String> qualifiedNameParts = new ArrayList<String>();
- final StringBuilder builder = new StringBuilder();
-
- EPackage ePackage = eClass.getEPackage();
- while (ePackage != null) {
- qualifiedNameParts.add(ePackage.getName());
- ePackage = ePackage.getESuperPackage();
- }
-
- for (int i = qualifiedNameParts.size() - 1; i >= 0; i--) {
- builder.append(qualifiedNameParts.get(i) + "."); //$NON-NLS-1$
- }
-
- builder.append(eClass.getName());
-
- return builder.toString();
- }
-
- /**
- * Returns a name for the given model element from the EMF global registry,
- * or use a default name taken from a String attribute.
- *
- * @return a name for the given element
- */
- // Copied from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils.getName(EObject)
- public static String getName(final EObject eObject) {
- ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
-
- try {
- IItemLabelProvider itemLabelProvider = (IItemLabelProvider) adapterFactory.adapt(eObject, IItemLabelProvider.class);
- if (itemLabelProvider != null) {
- return itemLabelProvider.getText(eObject);
- }
- } finally {
- // Dispose the adapter factory because it added an adapter that would leak, as it will never be reused
- adapterFactory.dispose();
- }
-
- return ModelUtils.getDefaultName(eObject);
- }
-
- /**
- * @return a default name based on a string feature of the given {@link EObject}
- */
- // Copied from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils.getDefaultName(EObject)
- public static String getDefaultName(final EObject eObject) {
- // find a feature that can be used as a name
- final EStructuralFeature feature = ModelUtils.getLabelFeature(eObject.eClass());
- if (feature != null) {
- final Object value = eObject.eGet(feature);
- if (value != null) {
- return StringUtils.truncateBeforeNewline(value.toString());
- }
- }
- return ""; //$NON-NLS-1$
- }
-
- // Copied from ReflectiveItemProvider class
- // Copied from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils.getLabelFeature(EClass)
- private static EStructuralFeature getLabelFeature(final EClass eClass) {
- EAttribute result = null;
- for (final EAttribute eAttribute : eClass.getEAllAttributes()) {
- if (!eAttribute.isMany()
- && eAttribute.getEType().getInstanceClass() != FeatureMap.Entry.class) {
- if ("name".equalsIgnoreCase(eAttribute.getName())) { //$NON-NLS-1$
- result = eAttribute;
- break;
- } else if (result == null) {
- result = eAttribute;
- } else if (eAttribute.getEAttributeType().getInstanceClass() == String.class
- && result.getEAttributeType().getInstanceClass() != String.class) {
- result = eAttribute;
- }
- }
- }
- return result;
- }
-
- /**
- * @author Gregoire Dupe (Mia-Software)
- * @param namedElement
- * @return
- */
- public static String getQualifiedName(final ENamedElement namedElement) {
- String parentQName = ""; //$NON-NLS-1$
- if (namedElement.eContainer() instanceof ENamedElement) {
- ENamedElement parent = (ENamedElement) namedElement.eContainer();
- parentQName = getQualifiedName(parent) + ModelUtils.MM_QNAME_SEPARATOR;
- }
- return parentQName + namedElement.getName();
- }
-
- /**
- * @since 0.3
- */
- public static ResourceSet getOrCreateResourceSet(final EObject eObject) {
- ResourceSet resourceSet = null;
- if (eObject.eResource() == null) {
- resourceSet = new ResourceSetImpl();
- } else {
- resourceSet = eObject.eResource().getResourceSet();
- }
- return resourceSet;
- }
-
- /**
- * @since 0.3
- */
- public static IProject getProject(final EObject eObject) {
- IProject result = null;
- final Resource resource = eObject.eResource();
- final URI uri = resource.getURI();
- if (uri.isPlatformResource()) {
- final String projectName = uri.segment(1);
- final IWorkspace workspace = ResourcesPlugin.getWorkspace();
- result = workspace.getRoot()
- .getProject(projectName);
- }
- return result;
- }
-}
+/******************************************************************************* + * Copyright (c) 2009, 2014 Mia-Software, CEA, 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: + * Nicolas Bros (Mia-Software) - Bug 366367 - To be able to change the "CanBePresentedInTheTable" query + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Laurent Pichierri (Soft-Maint) - Bug 371204 - Compatibility with Helios + * Gregoire Dupe (Mia-Software) - Bug 371367 - Hierarchical FacetSets + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors + * Christian W. Damus (CEA) - bug 410346 + * + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.emf.core; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.ENamedElement; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.papyrus.emf.facet.util.core.internal.exported.StringUtils; +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.Activator; + +/** + * Utility class for models. + * + * @since 0.2 + */ +public final class ModelUtils { + + /** + * Meta-model qualified name separator + */ + private static final String MM_QNAME_SEPARATOR = "::"; //$NON-NLS-1$ + + /** + * Utility classes don't need to (and shouldn't) be instantiated. + */ + private ModelUtils() { + // prevents instantiation + } + + /** + * Computes a list of {@link EObject}s from the same {@link ResourceSet} as <code>source</code> that can be assigned to the given feature. + */ + // Copied from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils.computeAssignableElements(EStructuralFeature, EObject) + public static List<EObject> computeAssignableElements(final EStructuralFeature feature, + final EObject source) { + EClassifier eType = feature.getEType(); + + // build a list of EObjects assignable to the EReference + List<EObject> list = new ArrayList<EObject>(); + Resource eResource = source.eResource(); + ResourceSet resourceSet = eResource.getResourceSet(); + TreeIterator<Notifier> allContents = resourceSet.getAllContents(); + while (allContents.hasNext()) { + Notifier notifier = allContents.next(); + if (notifier instanceof EObject) { + EObject eObject = (EObject) notifier; + if (eType.isInstance(eObject)) { + list.add(eObject); + } + } + } + return list; + } + + public static boolean isBooleanDataType(final EClassifier classifier) { + if (classifier instanceof EDataType) { + EDataType dataType = (EDataType) classifier; + Class<?> instanceClass = dataType.getInstanceClass(); + return instanceClass == Boolean.class || instanceClass == boolean.class; + } + return false; + } + + /** + * Find all subclasses of the given metaclass in the package registry + * + * @param context + * the metaclass whose subclasses must be found + * @return all the subclasses + */ + // Copied from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils.allSubClasses(final EClass context) + public static List<EClass> allSubClasses(final EClass context) { + List<EClass> result = new ArrayList<EClass>(); + // Set<Resource> resources = new HashSet<Resource>(); + Collection<String> uris = new ArrayList<String>(EPackage.Registry.INSTANCE.keySet()); + for (String ePackageURI : uris) { + try { + EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(ePackageURI); + EList<EClassifier> eClassifiers = ePackage.getEClassifiers(); + for (EClassifier eClassifier : eClassifiers) { + if (eClassifier instanceof EClass) { + EClass eClass = (EClass) eClassifier; + if (isSuperTypeOf(context, eClass)) { + result.add(eClass); + } + } + } + } catch (Exception e) { + Logger.logError(e, Activator.getDefault()); + } + } + return result; + } + + // Copied from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils.isSuperTypeOf(final EClass self, final EClass typeDeclaration) + public static boolean isSuperTypeOf(final EClass self, final EClass typeDeclaration) { + return typeDeclaration.getEAllSuperTypes().contains(self); + } + + /** @return the qualified name of the given metaclass */ + // Copied from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils.getMetaclassQualifiedName(final EClassifier eClass) + public static String getMetaclassQualifiedName(final EClassifier eClass) { + final ArrayList<String> qualifiedNameParts = new ArrayList<String>(); + final StringBuilder builder = new StringBuilder(); + + EPackage ePackage = eClass.getEPackage(); + while (ePackage != null) { + qualifiedNameParts.add(ePackage.getName()); + ePackage = ePackage.getESuperPackage(); + } + + for (int i = qualifiedNameParts.size() - 1; i >= 0; i--) { + builder.append(qualifiedNameParts.get(i) + "."); //$NON-NLS-1$ + } + + builder.append(eClass.getName()); + + return builder.toString(); + } + + /** + * Returns a name for the given model element from the EMF global registry, + * or use a default name taken from a String attribute. + * + * @return a name for the given element + */ + // Copied from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils.getName(EObject) + public static String getName(final EObject eObject) { + ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); + + try { + IItemLabelProvider itemLabelProvider = (IItemLabelProvider) adapterFactory.adapt(eObject, IItemLabelProvider.class); + if (itemLabelProvider != null) { + return itemLabelProvider.getText(eObject); + } + } finally { + // Dispose the adapter factory because it added an adapter that would leak, as it will never be reused + adapterFactory.dispose(); + } + + return ModelUtils.getDefaultName(eObject); + } + + /** + * @return a default name based on a string feature of the given {@link EObject} + */ + // Copied from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils.getDefaultName(EObject) + public static String getDefaultName(final EObject eObject) { + // find a feature that can be used as a name + final EStructuralFeature feature = ModelUtils.getLabelFeature(eObject.eClass()); + if (feature != null) { + final Object value = eObject.eGet(feature); + if (value != null) { + return StringUtils.truncateBeforeNewline(value.toString()); + } + } + return ""; //$NON-NLS-1$ + } + + // Copied from ReflectiveItemProvider class + // Copied from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils.getLabelFeature(EClass) + private static EStructuralFeature getLabelFeature(final EClass eClass) { + EAttribute result = null; + for (final EAttribute eAttribute : eClass.getEAllAttributes()) { + if (!eAttribute.isMany() + && eAttribute.getEType().getInstanceClass() != FeatureMap.Entry.class) { + if ("name".equalsIgnoreCase(eAttribute.getName())) { //$NON-NLS-1$ + result = eAttribute; + break; + } else if (result == null) { + result = eAttribute; + } else if (eAttribute.getEAttributeType().getInstanceClass() == String.class + && result.getEAttributeType().getInstanceClass() != String.class) { + result = eAttribute; + } + } + } + return result; + } + + /** + * @author Gregoire Dupe (Mia-Software) + * @param namedElement + * @return + */ + public static String getQualifiedName(final ENamedElement namedElement) { + String parentQName = ""; //$NON-NLS-1$ + if (namedElement.eContainer() instanceof ENamedElement) { + ENamedElement parent = (ENamedElement) namedElement.eContainer(); + parentQName = getQualifiedName(parent) + ModelUtils.MM_QNAME_SEPARATOR; + } + return parentQName + namedElement.getName(); + } + + /** + * @since 0.3 + */ + public static ResourceSet getOrCreateResourceSet(final EObject eObject) { + ResourceSet resourceSet = null; + if (eObject.eResource() == null) { + resourceSet = new ResourceSetImpl(); + } else { + resourceSet = eObject.eResource().getResourceSet(); + } + return resourceSet; + } + + /** + * @since 0.3 + */ + public static IProject getProject(final EObject eObject) { + IProject result = null; + final Resource resource = eObject.eResource(); + final URI uri = resource.getURI(); + if (uri.isPlatformResource()) { + final String projectName = uri.segment(1); + final IWorkspace workspace = ResourcesPlugin.getWorkspace(); + result = workspace.getRoot() + .getProject(projectName); + } + return result; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/command/EmfCommandUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/command/EmfCommandUtils.java index a9a4bdaec0d..05cacafc647 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/command/EmfCommandUtils.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/command/EmfCommandUtils.java @@ -1,41 +1,41 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
- * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core.command;
-
-import java.util.List;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-
-/**
- * @since 0.3
- */
-public final class EmfCommandUtils {
-
- private EmfCommandUtils() {
- // Must not be used
- }
-
- public static final Command createResult(final List<Command> commandList,
- final String label) {
- Command result = null;
- while (commandList.contains(null)) {
- commandList.remove(null);
- }
- if (!commandList.isEmpty()) {
- result = new CompoundCommand(label, commandList);
- }
- return result;
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors + * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors + */ +package org.eclipse.papyrus.emf.facet.util.emf.core.command; + +import java.util.List; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.CompoundCommand; + +/** + * @since 0.3 + */ +public final class EmfCommandUtils { + + private EmfCommandUtils() { + // Must not be used + } + + public static final Command createResult(final List<Command> commandList, + final String label) { + Command result = null; + while (commandList.contains(null)) { + commandList.remove(null); + } + if (!commandList.isEmpty()) { + result = new CompoundCommand(label, commandList); + } + return result; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/command/ICommandFactoryResult.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/command/ICommandFactoryResult.java index 1f764976439..e67f6001825 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/command/ICommandFactoryResult.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/command/ICommandFactoryResult.java @@ -1,25 +1,25 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core.command;
-
-import org.eclipse.emf.common.command.Command;
-
-/**
- * @since 0.2
- */
-public interface ICommandFactoryResult<T> {
- Command getCommand();
-
- T getResult();
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.util.emf.core.command; + +import org.eclipse.emf.common.command.Command; + +/** + * @since 0.2 + */ +public interface ICommandFactoryResult<T> { + Command getCommand(); + + T getResult(); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/command/ICommandFactoryResultFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/command/ICommandFactoryResultFactory.java index 617a3d4b129..3228241ce96 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/command/ICommandFactoryResultFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/command/ICommandFactoryResultFactory.java @@ -1,26 +1,26 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core.command;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.command.CommandFactoryResultFactory;
-
-/**
- * @since 0.2
- */
-public interface ICommandFactoryResultFactory {
-
- ICommandFactoryResultFactory DEFAULT = new CommandFactoryResultFactory();
-
- <T> ICommandFactoryResult<T> createCommandFactoryResult(Command command, T result);
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.util.emf.core.command; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.command.CommandFactoryResultFactory; + +/** + * @since 0.2 + */ +public interface ICommandFactoryResultFactory { + + ICommandFactoryResultFactory DEFAULT = new CommandFactoryResultFactory(); + + <T> ICommandFactoryResult<T> createCommandFactoryResult(Command command, T result); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/command/ILockableUndoCommand.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/command/ILockableUndoCommand.java index b5dfb4a2424..9c7589fc4f6 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/command/ILockableUndoCommand.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/command/ILockableUndoCommand.java @@ -1,25 +1,25 @@ -/**
- * Copyright (c) 2011 CEA LIST.
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 345730 - Deleting an element in the model breaks the table
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core.command;
-
-/**
- * This interface is used to force an EMF command to not be "undo-able"
- *
- * @since 0.1.1
- */
-public interface ILockableUndoCommand {
-
- /**
- * @param enableUndo
- * false to lock the command in an not "undo-able" mode
- */
- public void enableCanUndo(boolean enableUndo);
-}
+/** + * Copyright (c) 2011 CEA LIST. + * 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: + * Gregoire Dupe (Mia-Software) - Bug 345730 - Deleting an element in the model breaks the table + */ +package org.eclipse.papyrus.emf.facet.util.emf.core.command; + +/** + * This interface is used to force an EMF command to not be "undo-able" + * + * @since 0.1.1 + */ +public interface ILockableUndoCommand { + + /** + * @param enableUndo + * false to lock the command in an not "undo-able" mode + */ + public void enableCanUndo(boolean enableUndo); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/exception/DebugRuntimeException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/exception/DebugRuntimeException.java index bff617f3adb..7339462c213 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/exception/DebugRuntimeException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/exception/DebugRuntimeException.java @@ -1,25 +1,25 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia Software.
- * 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:
- * Grégoire Dupé - Bug 365843 - [Unit Test Failure][0.2/3.8][0.2/4.2]org.eclipse.papyrus.emf.facet.widgets.nattable.tests.swtbot.Bug344925Test.testBug344925
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.emf.core.exception;
-
-/**
- * @since 0.2
- */
-public final class DebugRuntimeException extends RuntimeException {
-
- private static final long serialVersionUID = -2130942266962627760L;
-
- public DebugRuntimeException(final Throwable throwable) {
- super(throwable);
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia Software. + * 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: + * Grégoire Dupé - Bug 365843 - [Unit Test Failure][0.2/3.8][0.2/4.2]org.eclipse.papyrus.emf.facet.widgets.nattable.tests.swtbot.Bug344925Test.testBug344925 + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.emf.core.exception; + +/** + * @since 0.2 + */ +public final class DebugRuntimeException extends RuntimeException { + + private static final long serialVersionUID = -2130942266962627760L; + + public DebugRuntimeException(final Throwable throwable) { + super(throwable); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/exception/InvalidFacetSetException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/exception/InvalidFacetSetException.java index 35482c3dccf..e36846b3c0c 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/exception/InvalidFacetSetException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/exception/InvalidFacetSetException.java @@ -1,36 +1,36 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Nicolas Guyomar (Mia-Software) - Bug 338811 - A model registration method in the interface ICatalogSetManager
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core.exception;
-
-/**
- * This exception is raised when an invalid FacetSet is found
- *
- * @since 0.2
- */
-public final class InvalidFacetSetException extends Exception {
-
- private static final long serialVersionUID = -7684948344074635385L;
-
- public InvalidFacetSetException(final String message) {
- super(message);
- }
-
- public InvalidFacetSetException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- public InvalidFacetSetException(final Throwable cause) {
- super(cause);
- }
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Nicolas Guyomar (Mia-Software) - Bug 338811 - A model registration method in the interface ICatalogSetManager + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.util.emf.core.exception; + +/** + * This exception is raised when an invalid FacetSet is found + * + * @since 0.2 + */ +public final class InvalidFacetSetException extends Exception { + + private static final long serialVersionUID = -7684948344074635385L; + + public InvalidFacetSetException(final String message) { + super(message); + } + + public InvalidFacetSetException(final String message, final Throwable cause) { + super(message, cause); + } + + public InvalidFacetSetException(final Throwable cause) { + super(cause); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/Activator.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/Activator.java index 58361f05da1..e43104556a3 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/Activator.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/Activator.java @@ -1,47 +1,47 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 334000 - Simple catalog manager
- * Nicolas Bros (Mia-Software) - Bug 335218 - Extension point for registering EObject, EPackage, model editor
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core.internal;
-
-import org.eclipse.core.runtime.Plugin;
-import org.osgi.framework.BundleContext;
-
-public class Activator extends Plugin {
-
- public static final String PLUGIN_ID = "org.eclipse.papyrus.emf.facet.util.emf.core"; //$NON-NLS-1$
-
- private static BundleContext context;
- private static Activator plugin;
-
- public static Plugin getDefault() {
- return Activator.plugin;
- }
-
- static BundleContext getContext() {
- return Activator.context;
- }
-
- @Override
- public void start(final BundleContext bundleContext) throws Exception {
- super.start(bundleContext);
- Activator.plugin = this;
- Activator.context = bundleContext;
- }
-
- @Override
- public void stop(final BundleContext bundleContext) throws Exception {
- Activator.context = null;
- Activator.plugin = null;
- super.stop(bundleContext);
- }
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 334000 - Simple catalog manager + * Nicolas Bros (Mia-Software) - Bug 335218 - Extension point for registering EObject, EPackage, model editor + */ +package org.eclipse.papyrus.emf.facet.util.emf.core.internal; + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; + +public class Activator extends Plugin { + + public static final String PLUGIN_ID = "org.eclipse.papyrus.emf.facet.util.emf.core"; //$NON-NLS-1$ + + private static BundleContext context; + private static Activator plugin; + + public static Plugin getDefault() { + return Activator.plugin; + } + + static BundleContext getContext() { + return Activator.context; + } + + @Override + public void start(final BundleContext bundleContext) throws Exception { + super.start(bundleContext); + Activator.plugin = this; + Activator.context = bundleContext; + } + + @Override + public void stop(final BundleContext bundleContext) throws Exception { + Activator.context = null; + Activator.plugin = null; + super.stop(bundleContext); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/catalog/CatalogSetManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/catalog/CatalogSetManager.java index 0f489eb4d92..4bc1e0a8ce5 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/catalog/CatalogSetManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/catalog/CatalogSetManager.java @@ -1,187 +1,187 @@ -/**
- * Copyright (c) 2011, 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 334000 Simple catalog manager
- * Nicolas Guyomar (Mia-Software) - Bug 334000 Simple catalog manager
- * Nicolas Guyomar (Mia-Software) - Bug 334529 - ICatalogManager should be exposed in org.eclipse.papyrus.emf.facet.common.core
- * Nicolas Guyomar (Mia-Software) - Bug 338811 - A model registration method in the interface ICatalogSetManager
- * Gregoire Dupe (Mia-Software) - Bug 338811 - A model registration method in the interface ICatalogSetManager
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- * Gregoire Dupe (Mia-Software) - Bug 362084 - Get the instance of a catalog manager
- * Gregoire Dupe (Mia-Software) - Bug 362087 - [Deprecated] org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core.internal.catalog;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.papyrus.emf.facet.util.emf.catalog.CatalogFactory;
-import org.eclipse.papyrus.emf.facet.util.emf.catalog.CatalogSet;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogManager;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager2;
-import org.eclipse.papyrus.emf.facet.util.emf.core.exception.InvalidFacetSetException;
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.Activator;
-import org.eclipse.papyrus.emf.facet.util.pde.core.internal.exported.PluginUtils;
-import org.osgi.framework.Bundle;
-
-@SuppressWarnings("deprecation")
-// TODO Bug 362087 - [Deprecated] org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager
-public class CatalogSetManager implements ICatalogSetManager, ICatalogSetManager2, Adapter {
-
- private static final String CATALOG_MGR_EXTENSION_POINT_ID = "org.eclipse.papyrus.emf.facet.util.emf.core.catalogmanager"; //$NON-NLS-1$
- private static final String MODEL_DECLARATION_EXTENSION_POINT_ID = "org.eclipse.papyrus.emf.facet.util.emf.core.modeldeclaration"; //$NON-NLS-1$
- private static final String CLASS = "class"; //$NON-NLS-1$
- private static final String FILE = "file"; //$NON-NLS-1$
-
- /**
- * The singleton instance of this {@link CatalogSetManager}.
- */
- public static final CatalogSetManager INSTANCE = new CatalogSetManager();
-
- private final Map<Resource, Bundle> resourceToBundleMap = new HashMap<Resource, Bundle>();
- private final ResourceSet resourceSet;
-
- private final List<ICatalogManager> catalogManagers = new ArrayList<ICatalogManager>();
- private final CatalogSet catalogSet;
-
- public CatalogSetManager() {
- this.resourceSet = new ResourceSetImpl();
- this.catalogSet = CatalogFactory.eINSTANCE.createCatalogSet();
- initRegisteredEntries();
- }
-
- public CatalogSetManager(final ResourceSet resourceSet) {
- this.resourceSet = resourceSet;
- this.catalogSet = CatalogFactory.eINSTANCE.createCatalogSet();
- initRegisteredEntries();
- }
-
- private void initRegisteredEntries() {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extPointCatalogMgr = registry
- .getExtensionPoint(CatalogSetManager.CATALOG_MGR_EXTENSION_POINT_ID);
- if (extPointCatalogMgr != null) {
- for (IExtension ext : extPointCatalogMgr.getExtensions()) {
- for (IConfigurationElement configElt : ext
- .getConfigurationElements()) {
- ICatalogManager catalogMgr;
- try {
- catalogMgr = (ICatalogManager) configElt
- .createExecutableExtension(CatalogSetManager.CLASS);
- this.catalogManagers.add(catalogMgr);
- catalogMgr.setCatalogSet(this.catalogSet);
- } catch (CoreException e) {
- Logger.logError(e, Activator.getDefault());
- }
- }
- }
- }
- IExtensionPoint modelDeclarationExtPoint = registry
- .getExtensionPoint(CatalogSetManager.MODEL_DECLARATION_EXTENSION_POINT_ID);
- if (modelDeclarationExtPoint != null) {
- for (IExtension ext : modelDeclarationExtPoint.getExtensions()) {
- for (IConfigurationElement configElt : ext
- .getConfigurationElements()) {
- String filePath = configElt
- .getAttribute(CatalogSetManager.FILE);
- if (filePath != null) {
- String pluginName = ext.getNamespaceIdentifier();
- Bundle bundle = Platform.getBundle(pluginName);
- URI uri = URI.createPlatformPluginURI(pluginName + "/" //$NON-NLS-1$
- + filePath, false);
- try {
- Resource resource = this.resourceSet.getResource(
- uri, true);
- this.resourceToBundleMap.put(resource, bundle);
- for (EObject root : resource.getContents()) {
- for (ICatalogManager catalogMgr : this.catalogManagers) {
- if (catalogMgr.canBeManaged(root)) {
- catalogMgr.manage(root);
- }
- }
- }
- } catch (Exception e) {
- Logger.logError(e, Activator.getDefault());
- }
- }
- }
- }
- }
- }
-
- public CatalogSet getCatalogSet() {
- return this.catalogSet;
- }
-
- /**
- * @author Nicolas Guyomar
- * Modified by Emmanuelle Rouillé
- */
- public Bundle getBundleByResource(final Resource eResource) {
- if (eResource == null) {
- throw new IllegalArgumentException("The resource cannot be null"); //$NON-NLS-1$
- }
- if (eResource.getURI().scheme().equals("platform") && eResource.getURI().segment(0).equals("plugin")) { //$NON-NLS-1$//$NON-NLS-2$
- return Platform.getBundle(eResource.getURI().segment(1));
- }
- return this.resourceToBundleMap.get(eResource);
- }
-
- public void registerModelDeclaration(final IFile file) throws InvalidFacetSetException {
- PluginUtils.register(file, CatalogSetManager.MODEL_DECLARATION_EXTENSION_POINT_ID, "modeldeclaration"); //$NON-NLS-1$
- }
-
- public <T> List<T> getCatalogManagerByType(final Class<? extends T> catalogManagerClass) {
- List<T> result = new ArrayList<T>();
- for (ICatalogManager catalogManager : this.catalogManagers) {
- if (catalogManagerClass.isInstance(catalogManager)) {
- result.add((T) catalogManager);
- }
- }
- return result;
- }
-
- public void notifyChanged(final Notification notification) {
- // Nothing to do
- }
-
- public Notifier getTarget() {
- return this.resourceSet;
- }
-
- public void setTarget(final Notifier newTarget) {
- // Nothing to do
- }
-
- public boolean isAdapterForType(final Object type) {
- return type == ICatalogSetManager2.class;
- }
-
-
-
-}
+/** + * Copyright (c) 2011, 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 334000 Simple catalog manager + * Nicolas Guyomar (Mia-Software) - Bug 334000 Simple catalog manager + * Nicolas Guyomar (Mia-Software) - Bug 334529 - ICatalogManager should be exposed in org.eclipse.papyrus.emf.facet.common.core + * Nicolas Guyomar (Mia-Software) - Bug 338811 - A model registration method in the interface ICatalogSetManager + * Gregoire Dupe (Mia-Software) - Bug 338811 - A model registration method in the interface ICatalogSetManager + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + * Gregoire Dupe (Mia-Software) - Bug 362084 - Get the instance of a catalog manager + * Gregoire Dupe (Mia-Software) - Bug 362087 - [Deprecated] org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager + */ +package org.eclipse.papyrus.emf.facet.util.emf.core.internal.catalog; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.papyrus.emf.facet.util.emf.catalog.CatalogFactory; +import org.eclipse.papyrus.emf.facet.util.emf.catalog.CatalogSet; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogManager; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager2; +import org.eclipse.papyrus.emf.facet.util.emf.core.exception.InvalidFacetSetException; +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.Activator; +import org.eclipse.papyrus.emf.facet.util.pde.core.internal.exported.PluginUtils; +import org.osgi.framework.Bundle; + +@SuppressWarnings("deprecation") +// TODO Bug 362087 - [Deprecated] org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager +public class CatalogSetManager implements ICatalogSetManager, ICatalogSetManager2, Adapter { + + private static final String CATALOG_MGR_EXTENSION_POINT_ID = "org.eclipse.papyrus.emf.facet.util.emf.core.catalogmanager"; //$NON-NLS-1$ + private static final String MODEL_DECLARATION_EXTENSION_POINT_ID = "org.eclipse.papyrus.emf.facet.util.emf.core.modeldeclaration"; //$NON-NLS-1$ + private static final String CLASS = "class"; //$NON-NLS-1$ + private static final String FILE = "file"; //$NON-NLS-1$ + + /** + * The singleton instance of this {@link CatalogSetManager}. + */ + public static final CatalogSetManager INSTANCE = new CatalogSetManager(); + + private final Map<Resource, Bundle> resourceToBundleMap = new HashMap<Resource, Bundle>(); + private final ResourceSet resourceSet; + + private final List<ICatalogManager> catalogManagers = new ArrayList<ICatalogManager>(); + private final CatalogSet catalogSet; + + public CatalogSetManager() { + this.resourceSet = new ResourceSetImpl(); + this.catalogSet = CatalogFactory.eINSTANCE.createCatalogSet(); + initRegisteredEntries(); + } + + public CatalogSetManager(final ResourceSet resourceSet) { + this.resourceSet = resourceSet; + this.catalogSet = CatalogFactory.eINSTANCE.createCatalogSet(); + initRegisteredEntries(); + } + + private void initRegisteredEntries() { + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint extPointCatalogMgr = registry + .getExtensionPoint(CatalogSetManager.CATALOG_MGR_EXTENSION_POINT_ID); + if (extPointCatalogMgr != null) { + for (IExtension ext : extPointCatalogMgr.getExtensions()) { + for (IConfigurationElement configElt : ext + .getConfigurationElements()) { + ICatalogManager catalogMgr; + try { + catalogMgr = (ICatalogManager) configElt + .createExecutableExtension(CatalogSetManager.CLASS); + this.catalogManagers.add(catalogMgr); + catalogMgr.setCatalogSet(this.catalogSet); + } catch (CoreException e) { + Logger.logError(e, Activator.getDefault()); + } + } + } + } + IExtensionPoint modelDeclarationExtPoint = registry + .getExtensionPoint(CatalogSetManager.MODEL_DECLARATION_EXTENSION_POINT_ID); + if (modelDeclarationExtPoint != null) { + for (IExtension ext : modelDeclarationExtPoint.getExtensions()) { + for (IConfigurationElement configElt : ext + .getConfigurationElements()) { + String filePath = configElt + .getAttribute(CatalogSetManager.FILE); + if (filePath != null) { + String pluginName = ext.getNamespaceIdentifier(); + Bundle bundle = Platform.getBundle(pluginName); + URI uri = URI.createPlatformPluginURI(pluginName + "/" //$NON-NLS-1$ + + filePath, false); + try { + Resource resource = this.resourceSet.getResource( + uri, true); + this.resourceToBundleMap.put(resource, bundle); + for (EObject root : resource.getContents()) { + for (ICatalogManager catalogMgr : this.catalogManagers) { + if (catalogMgr.canBeManaged(root)) { + catalogMgr.manage(root); + } + } + } + } catch (Exception e) { + Logger.logError(e, Activator.getDefault()); + } + } + } + } + } + } + + public CatalogSet getCatalogSet() { + return this.catalogSet; + } + + /** + * @author Nicolas Guyomar + * Modified by Emmanuelle Rouillé + */ + public Bundle getBundleByResource(final Resource eResource) { + if (eResource == null) { + throw new IllegalArgumentException("The resource cannot be null"); //$NON-NLS-1$ + } + if (eResource.getURI().scheme().equals("platform") && eResource.getURI().segment(0).equals("plugin")) { //$NON-NLS-1$//$NON-NLS-2$ + return Platform.getBundle(eResource.getURI().segment(1)); + } + return this.resourceToBundleMap.get(eResource); + } + + public void registerModelDeclaration(final IFile file) throws InvalidFacetSetException { + PluginUtils.register(file, CatalogSetManager.MODEL_DECLARATION_EXTENSION_POINT_ID, "modeldeclaration"); //$NON-NLS-1$ + } + + public <T> List<T> getCatalogManagerByType(final Class<? extends T> catalogManagerClass) { + List<T> result = new ArrayList<T>(); + for (ICatalogManager catalogManager : this.catalogManagers) { + if (catalogManagerClass.isInstance(catalogManager)) { + result.add((T) catalogManager); + } + } + return result; + } + + public void notifyChanged(final Notification notification) { + // Nothing to do + } + + public Notifier getTarget() { + return this.resourceSet; + } + + public void setTarget(final Notifier newTarget) { + // Nothing to do + } + + public boolean isAdapterForType(final Object type) { + return type == ICatalogSetManager2.class; + } + + + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/catalog/CatalogSetManagerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/catalog/CatalogSetManagerFactory.java index 0ccbc435af1..2e2a39968e3 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/catalog/CatalogSetManagerFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/catalog/CatalogSetManagerFactory.java @@ -1,36 +1,36 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core.internal.catalog;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager2;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManagerFactory;
-
-public class CatalogSetManagerFactory implements ICatalogSetManagerFactory {
-
- public ICatalogSetManager2 createICatalogSetManager(final ResourceSet resourceSet) {
- CatalogSetManager result = null;
- for (Adapter adapter : resourceSet.eAdapters()) {
- if (adapter instanceof CatalogSetManager) {
- result = (CatalogSetManager) adapter;
-
- }
- }
- if (result == null) {
- result = new CatalogSetManager(resourceSet);
- resourceSet.eAdapters().add(result);
- }
- return result;
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + */ +package org.eclipse.papyrus.emf.facet.util.emf.core.internal.catalog; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager2; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManagerFactory; + +public class CatalogSetManagerFactory implements ICatalogSetManagerFactory { + + public ICatalogSetManager2 createICatalogSetManager(final ResourceSet resourceSet) { + CatalogSetManager result = null; + for (Adapter adapter : resourceSet.eAdapters()) { + if (adapter instanceof CatalogSetManager) { + result = (CatalogSetManager) adapter; + + } + } + if (result == null) { + result = new CatalogSetManager(resourceSet); + resourceSet.eAdapters().add(result); + } + return result; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/command/CommandFactoryResult.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/command/CommandFactoryResult.java index f30c87ba64a..ea8f1cbd9fe 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/command/CommandFactoryResult.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/command/CommandFactoryResult.java @@ -1,35 +1,35 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core.internal.command;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.papyrus.emf.facet.util.emf.core.command.ICommandFactoryResult;
-
-public class CommandFactoryResult<T> implements ICommandFactoryResult<T> {
-
- private final Command cmd;
- private final T result;
-
- public CommandFactoryResult(final Command cmd, final T result) {
- this.cmd = cmd;
- this.result = result;
- }
-
- public Command getCommand() {
- return this.cmd;
- }
-
- public T getResult() {
- return this.result;
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + */ +package org.eclipse.papyrus.emf.facet.util.emf.core.internal.command; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.papyrus.emf.facet.util.emf.core.command.ICommandFactoryResult; + +public class CommandFactoryResult<T> implements ICommandFactoryResult<T> { + + private final Command cmd; + private final T result; + + public CommandFactoryResult(final Command cmd, final T result) { + this.cmd = cmd; + this.result = result; + } + + public Command getCommand() { + return this.cmd; + } + + public T getResult() { + return this.result; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/command/CommandFactoryResultFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/command/CommandFactoryResultFactory.java index 1ceb5756d38..d2ef3203f41 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/command/CommandFactoryResultFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/command/CommandFactoryResultFactory.java @@ -1,23 +1,23 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core.internal.command;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.papyrus.emf.facet.util.emf.core.command.ICommandFactoryResult;
-import org.eclipse.papyrus.emf.facet.util.emf.core.command.ICommandFactoryResultFactory;
-
-public class CommandFactoryResultFactory implements ICommandFactoryResultFactory {
-
- public <T> ICommandFactoryResult<T> createCommandFactoryResult(final Command command, final T result) {
- return new CommandFactoryResult<T>(command, result);
- }
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + */ +package org.eclipse.papyrus.emf.facet.util.emf.core.internal.command; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.papyrus.emf.facet.util.emf.core.command.ICommandFactoryResult; +import org.eclipse.papyrus.emf.facet.util.emf.core.command.ICommandFactoryResultFactory; + +public class CommandFactoryResultFactory implements ICommandFactoryResultFactory { + + public <T> ICommandFactoryResult<T> createCommandFactoryResult(final Command command, final T result) { + return new CommandFactoryResult<T>(command, result); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/command/SetResourceContentCommand.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/command/SetResourceContentCommand.java index 0cd629c58ec..870e51497b9 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/command/SetResourceContentCommand.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/command/SetResourceContentCommand.java @@ -1,107 +1,107 @@ -/**
- * Copyright (c) 2011 CEA LIST.
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 345730 - Deleting an element in the model breaks the table
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core.internal.command;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.papyrus.emf.facet.util.emf.core.command.ILockableUndoCommand;
-
-/**
- * This command has to be used to set the content of a resource
- */
-public class SetResourceContentCommand implements Command, ILockableUndoCommand {
- private EList<EObject> oldContent = null;
- private Collection<EObject> newContent = null;
- private Resource resource;
- private boolean enableUndo = true;
-
- /**
- * @param resource
- * the resource of which we want to set the content.
- * @param content
- * a list of EObject to set as the content of the resource
- */
- public SetResourceContentCommand(final Resource resource, final Collection<EObject> content) {
- this.resource = resource;
- this.newContent = content;
- }
-
- public boolean canExecute() {
- return true;
- }
-
- public void execute() {
- this.oldContent = this.resource.getContents();
- this.resource.getContents().clear();
- this.resource.getContents().addAll(this.newContent);
-
- }
-
- public boolean canUndo() {
- boolean canUndo = (this.enableUndo && (this.oldContent != null));
- return canUndo;
- }
-
- public void undo() {
- this.resource.getContents().clear();
- this.resource.getContents().addAll(this.oldContent);
-
- }
-
- public void redo() {
- this.resource.getContents().clear();
- this.resource.getContents().addAll(this.newContent);
- }
-
- public Collection<?> getResult() {
- Collection<Resource> result = new ArrayList<Resource>();
- result.add(this.resource);
- return result;
- }
-
- public Collection<?> getAffectedObjects() {
- Collection<Object> affectedObjects = new ArrayList<Object>();
- affectedObjects.add(this.resource);
- affectedObjects.addAll(this.newContent);
- affectedObjects.addAll(this.oldContent);
- return affectedObjects;
- }
-
- public String getLabel() {
- // TODO: Must be externalized
- return "Set Resource Content"; //$NON-NLS-1$
- }
-
- public String getDescription() {
- // TODO: Must be externalized
- return "This command changes the content of an EMF resource"; //$NON-NLS-1$
- }
-
- public void dispose() {
- this.oldContent = null;
- this.newContent = null;
- this.resource = null;
- }
-
- public Command chain(final Command command) {
- return null;
- }
-
- public void enableCanUndo(final boolean enable) {
- this.enableUndo = enable;
- }
-
-}
+/** + * Copyright (c) 2011 CEA LIST. + * 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: + * Gregoire Dupe (Mia-Software) - Bug 345730 - Deleting an element in the model breaks the table + */ +package org.eclipse.papyrus.emf.facet.util.emf.core.internal.command; + +import java.util.ArrayList; +import java.util.Collection; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.papyrus.emf.facet.util.emf.core.command.ILockableUndoCommand; + +/** + * This command has to be used to set the content of a resource + */ +public class SetResourceContentCommand implements Command, ILockableUndoCommand { + private EList<EObject> oldContent = null; + private Collection<EObject> newContent = null; + private Resource resource; + private boolean enableUndo = true; + + /** + * @param resource + * the resource of which we want to set the content. + * @param content + * a list of EObject to set as the content of the resource + */ + public SetResourceContentCommand(final Resource resource, final Collection<EObject> content) { + this.resource = resource; + this.newContent = content; + } + + public boolean canExecute() { + return true; + } + + public void execute() { + this.oldContent = this.resource.getContents(); + this.resource.getContents().clear(); + this.resource.getContents().addAll(this.newContent); + + } + + public boolean canUndo() { + boolean canUndo = (this.enableUndo && (this.oldContent != null)); + return canUndo; + } + + public void undo() { + this.resource.getContents().clear(); + this.resource.getContents().addAll(this.oldContent); + + } + + public void redo() { + this.resource.getContents().clear(); + this.resource.getContents().addAll(this.newContent); + } + + public Collection<?> getResult() { + Collection<Resource> result = new ArrayList<Resource>(); + result.add(this.resource); + return result; + } + + public Collection<?> getAffectedObjects() { + Collection<Object> affectedObjects = new ArrayList<Object>(); + affectedObjects.add(this.resource); + affectedObjects.addAll(this.newContent); + affectedObjects.addAll(this.oldContent); + return affectedObjects; + } + + public String getLabel() { + // TODO: Must be externalized + return "Set Resource Content"; //$NON-NLS-1$ + } + + public String getDescription() { + // TODO: Must be externalized + return "This command changes the content of an EMF resource"; //$NON-NLS-1$ + } + + public void dispose() { + this.oldContent = null; + this.newContent = null; + this.resource = null; + } + + public Command chain(final Command command) { + return null; + } + + public void enableCanUndo(final boolean enable) { + this.enableUndo = enable; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/exported/ICommandFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/exported/ICommandFactory.java index 590ee7cc188..0d458e13063 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/exported/ICommandFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/exported/ICommandFactory.java @@ -1,71 +1,71 @@ -/*******************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.emf.core.internal.exported;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.edit.command.AddCommand;
-import org.eclipse.emf.edit.command.MoveCommand;
-import org.eclipse.emf.edit.command.RemoveCommand;
-import org.eclipse.emf.edit.command.SetCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
-
-/**
- * Creates {@link Command}s for a specific {@link EditingDomain}.
- * <p>
- * See also {@link ICommandFactoriesRegistry}
- *
- * @since 0.2
- */
-// Copied from org.eclipse.papyrus.emf.facet.widgets.celleditors.ICommandFactory
-public interface ICommandFactory {
- /**
- * Whether this command factory should be used for the given {@link EditingDomain}
- */
- boolean handles(EditingDomain editingDomain);
-
- /**
- * This creates a {@link SetCommand} to set the owner's feature to the specified value.
- */
- Command createSetCommand(EditingDomain domain, Object owner, Object feature, Object value);
-
- /**
- * This creates a {@link SetCommand} to set the owner's feature to the specified value at the
- * specified index.
- */
- Command createSetCommand(EditingDomain domain, Object owner, Object feature,
- Object value, int index);
-
- /**
- * This creates a {@link MoveCommand} to move a particular value to a particular index in the
- * specified feature of the owner. The feature will often be <code>null</code> because the
- * domain will deduce it.
- */
- Command createMoveCommand(EditingDomain domain, Object owner, Object feature, Object value,
- int index);
-
- /**
- * This creates an {@link AddCommand} to add a particular value to the specified feature of the
- * owner. The feature will often be <code>null</code> because the domain will deduce it.
- */
- Command createAddCommand(EditingDomain domain, Object owner, Object feature, Object value);
-
- /**
- * This creates a {@link RemoveCommand} to remove a particular value from the specified feature
- * of the owner.
- */
- Command createRemoveCommand(EditingDomain domain, Object owner, Object feature, Object value);
-
- /** This creates a command that deletes the given object. */
- Command createDeleteCommand(EditingDomain domain, Object object);
-
-}
+/******************************************************************************* + * Copyright (c) 2010 CEA LIST. + * + * 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: + * Nicolas Bros (Mia-Software) - initial API and implementation + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.emf.core.internal.exported; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.edit.command.AddCommand; +import org.eclipse.emf.edit.command.MoveCommand; +import org.eclipse.emf.edit.command.RemoveCommand; +import org.eclipse.emf.edit.command.SetCommand; +import org.eclipse.emf.edit.domain.EditingDomain; + +/** + * Creates {@link Command}s for a specific {@link EditingDomain}. + * <p> + * See also {@link ICommandFactoriesRegistry} + * + * @since 0.2 + */ +// Copied from org.eclipse.papyrus.emf.facet.widgets.celleditors.ICommandFactory +public interface ICommandFactory { + /** + * Whether this command factory should be used for the given {@link EditingDomain} + */ + boolean handles(EditingDomain editingDomain); + + /** + * This creates a {@link SetCommand} to set the owner's feature to the specified value. + */ + Command createSetCommand(EditingDomain domain, Object owner, Object feature, Object value); + + /** + * This creates a {@link SetCommand} to set the owner's feature to the specified value at the + * specified index. + */ + Command createSetCommand(EditingDomain domain, Object owner, Object feature, + Object value, int index); + + /** + * This creates a {@link MoveCommand} to move a particular value to a particular index in the + * specified feature of the owner. The feature will often be <code>null</code> because the + * domain will deduce it. + */ + Command createMoveCommand(EditingDomain domain, Object owner, Object feature, Object value, + int index); + + /** + * This creates an {@link AddCommand} to add a particular value to the specified feature of the + * owner. The feature will often be <code>null</code> because the domain will deduce it. + */ + Command createAddCommand(EditingDomain domain, Object owner, Object feature, Object value); + + /** + * This creates a {@link RemoveCommand} to remove a particular value from the specified feature + * of the owner. + */ + Command createRemoveCommand(EditingDomain domain, Object owner, Object feature, Object value); + + /** This creates a command that deletes the given object. */ + Command createDeleteCommand(EditingDomain domain, Object object); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/preferences/PreferenceConstants.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/preferences/PreferenceConstants.java index 6a0d383ad59..7d7aef10384 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/preferences/PreferenceConstants.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/preferences/PreferenceConstants.java @@ -1,26 +1,26 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Nicolas Guyomar (Mia-Software) - Bug 333652 Extension point offering the possibility to declare an EPackage browser
- * Fabien Giquel (Mia-Software)
- * Nicolas Bros (Mia-Software) - Bug 335218 - Extension point for registering EObject, EPackage, model editor
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core.internal.preferences;
-
-public final class PreferenceConstants {
-
- private PreferenceConstants() {
- // constants class: no need to instantiate
- }
-
- public static final String P_DEFAULT_EPACKAGE_VIEWER = "emf_facet_default_epackage_viewer"; //$NON-NLS-1$
- public static final String P_DEFAULT_EOBJECT_VIEWER = "emf_facet_default_eobject_viewer"; //$NON-NLS-1$
- public static final String P_DEFAULT_RESOURCE_VIEWER = "emf_facet_default_resource_viewer"; //$NON-NLS-1$
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Nicolas Guyomar (Mia-Software) - Bug 333652 Extension point offering the possibility to declare an EPackage browser + * Fabien Giquel (Mia-Software) + * Nicolas Bros (Mia-Software) - Bug 335218 - Extension point for registering EObject, EPackage, model editor + */ +package org.eclipse.papyrus.emf.facet.util.emf.core.internal.preferences; + +public final class PreferenceConstants { + + private PreferenceConstants() { + // constants class: no need to instantiate + } + + public static final String P_DEFAULT_EPACKAGE_VIEWER = "emf_facet_default_epackage_viewer"; //$NON-NLS-1$ + public static final String P_DEFAULT_EOBJECT_VIEWER = "emf_facet_default_eobject_viewer"; //$NON-NLS-1$ + public static final String P_DEFAULT_RESOURCE_VIEWER = "emf_facet_default_resource_viewer"; //$NON-NLS-1$ + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/preferences/PreferenceInitializer.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/preferences/PreferenceInitializer.java index 3c5007de7aa..8f1e4f42d9b 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/preferences/PreferenceInitializer.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/preferences/PreferenceInitializer.java @@ -1,54 +1,54 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Nicolas Guyomar (Mia-Software) - Bug 333652 Extension point offering the possibility to declare an EPackage browser
- * Nicolas Bros (Mia-Software) - Bug 335218 - Extension point for registering EObject, EPackage, model editor
- * Laurent Pichierri (Soft-Maint) - Bug 371204 - Compatibility with Helios
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core.internal.preferences;
-
-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.papyrus.emf.facet.util.emf.core.IBrowserRegistry;
-import org.eclipse.papyrus.emf.facet.util.emf.core.IEObjectBrowserOpener;
-import org.eclipse.papyrus.emf.facet.util.emf.core.IEPackageBrowserOpener;
-import org.eclipse.papyrus.emf.facet.util.emf.core.IResourceBrowserOpener;
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.Activator;
-
-public class PreferenceInitializer extends AbstractPreferenceInitializer {
-
- @Override
- public void initializeDefaultPreferences() {
- IEclipsePreferences preferenceNode = new DefaultScope().getNode(Activator.PLUGIN_ID);
- // general rule is to keep the same behavior as EMF by default
- IEObjectBrowserOpener defaultEObjectBrowserOpener = IBrowserRegistry.INSTANCE
- .getDefaultEObjectBrowserOpener();
- if (defaultEObjectBrowserOpener != null) {
- preferenceNode.put(PreferenceConstants.P_DEFAULT_EOBJECT_VIEWER,
- defaultEObjectBrowserOpener.getClass().getName());
- }
-
- IEPackageBrowserOpener defaultEPackageBrowserOpener = IBrowserRegistry.INSTANCE
- .getDefaultEPackageBrowserOpener();
- if (defaultEPackageBrowserOpener != null) {
- preferenceNode.put(PreferenceConstants.P_DEFAULT_EPACKAGE_VIEWER,
- defaultEPackageBrowserOpener.getClass().getName());
- }
-
- IResourceBrowserOpener defaultResourceBrowserOpener = IBrowserRegistry.INSTANCE
- .getDefaultResourceBrowserOpener();
- if (defaultResourceBrowserOpener != null) {
- preferenceNode.put(PreferenceConstants.P_DEFAULT_RESOURCE_VIEWER,
- defaultResourceBrowserOpener.getClass().getName());
- }
-
- }
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Nicolas Guyomar (Mia-Software) - Bug 333652 Extension point offering the possibility to declare an EPackage browser + * Nicolas Bros (Mia-Software) - Bug 335218 - Extension point for registering EObject, EPackage, model editor + * Laurent Pichierri (Soft-Maint) - Bug 371204 - Compatibility with Helios + */ +package org.eclipse.papyrus.emf.facet.util.emf.core.internal.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.core.runtime.preferences.DefaultScope; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.papyrus.emf.facet.util.emf.core.IBrowserRegistry; +import org.eclipse.papyrus.emf.facet.util.emf.core.IEObjectBrowserOpener; +import org.eclipse.papyrus.emf.facet.util.emf.core.IEPackageBrowserOpener; +import org.eclipse.papyrus.emf.facet.util.emf.core.IResourceBrowserOpener; +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.Activator; + +public class PreferenceInitializer extends AbstractPreferenceInitializer { + + @Override + public void initializeDefaultPreferences() { + IEclipsePreferences preferenceNode = new DefaultScope().getNode(Activator.PLUGIN_ID); + // general rule is to keep the same behavior as EMF by default + IEObjectBrowserOpener defaultEObjectBrowserOpener = IBrowserRegistry.INSTANCE + .getDefaultEObjectBrowserOpener(); + if (defaultEObjectBrowserOpener != null) { + preferenceNode.put(PreferenceConstants.P_DEFAULT_EOBJECT_VIEWER, + defaultEObjectBrowserOpener.getClass().getName()); + } + + IEPackageBrowserOpener defaultEPackageBrowserOpener = IBrowserRegistry.INSTANCE + .getDefaultEPackageBrowserOpener(); + if (defaultEPackageBrowserOpener != null) { + preferenceNode.put(PreferenceConstants.P_DEFAULT_EPACKAGE_VIEWER, + defaultEPackageBrowserOpener.getClass().getName()); + } + + IResourceBrowserOpener defaultResourceBrowserOpener = IBrowserRegistry.INSTANCE + .getDefaultResourceBrowserOpener(); + if (defaultResourceBrowserOpener != null) { + preferenceNode.put(PreferenceConstants.P_DEFAULT_RESOURCE_VIEWER, + defaultResourceBrowserOpener.getClass().getName()); + } + + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/registry/BrowserRegistry.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/registry/BrowserRegistry.java index 13846574b74..f951b7903f5 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/registry/BrowserRegistry.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/registry/BrowserRegistry.java @@ -1,212 +1,212 @@ -/**********************************************************************************
- * Copyright (c) 2011 Mia-Software.
- * 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:
- * Nicolas Guyomar (Mia-Software) - Bug 333652 Extension point offering the possibility to declare an EPackage browser
- * Nicolas Bros (Mia-Software) - Bug 335218 - Extension point for registering EObject, EPackage, model editor
- * Laurent Pichierri (Soft-Maint) - Bug 371204 - Compatibility with Helios
- ***********************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.emf.core.internal.registry;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.papyrus.emf.facet.util.emf.core.IBrowserRegistry;
-import org.eclipse.papyrus.emf.facet.util.emf.core.IEObjectBrowserOpener;
-import org.eclipse.papyrus.emf.facet.util.emf.core.IEPackageBrowserOpener;
-import org.eclipse.papyrus.emf.facet.util.emf.core.IResourceBrowserOpener;
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.Activator;
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.preferences.PreferenceConstants;
-
-/** A registry for the EObject, EPackage, and Resource browser opener extension point. */
-public class BrowserRegistry implements IBrowserRegistry {
-
- private static final String EXTENSION_POINT_RESOURCE_VIEWER_ELT = "resourceViewer"; //$NON-NLS-1$
- private static final String EXTENSION_POINT_EOBJECT_VIEWER_ELT = "eObjectViewer"; //$NON-NLS-1$
- private static final String EXTENSION_POINT_EPACKAGE_VIEWER_ELT = "ePackageViewer"; //$NON-NLS-1$
- private final List<IEPackageBrowserOpener> epackageBrowserOpeners;
- private final List<IEObjectBrowserOpener> eobjectBrowserOpeners;
- private final List<IResourceBrowserOpener> resourceBrowserOpeners;
-
- public static final String EXTENSION_POINT_MODEL_VIEWER_ID = "org.eclipse.papyrus.emf.facet.util.emf.core.modelViewer"; //$NON-NLS-1$
-
- public static final String CLASS = "class"; //$NON-NLS-1$
-
- public BrowserRegistry() {
- this.epackageBrowserOpeners = new ArrayList<IEPackageBrowserOpener>();
- this.eobjectBrowserOpeners = new ArrayList<IEObjectBrowserOpener>();
- this.resourceBrowserOpeners = new ArrayList<IResourceBrowserOpener>();
-
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = registry
- .getExtensionPoint(BrowserRegistry.EXTENSION_POINT_MODEL_VIEWER_ID);
- if (extensionPoint != null) {
- for (IExtension ext : extensionPoint.getExtensions()) {
- for (IConfigurationElement configElt : ext.getConfigurationElements()) {
-
- String kind = configElt.getName();
- String classID = configElt.getAttribute(BrowserRegistry.CLASS);
- try {
- if (classID != null) {
- if (kind.equals(BrowserRegistry.EXTENSION_POINT_EPACKAGE_VIEWER_ELT)) {
- this.epackageBrowserOpeners.add((IEPackageBrowserOpener) configElt
- .createExecutableExtension(BrowserRegistry.CLASS));
- } else if (kind
- .equals(BrowserRegistry.EXTENSION_POINT_EOBJECT_VIEWER_ELT)) {
- this.eobjectBrowserOpeners.add((IEObjectBrowserOpener) configElt
- .createExecutableExtension(BrowserRegistry.CLASS));
- } else if (kind
- .equals(BrowserRegistry.EXTENSION_POINT_RESOURCE_VIEWER_ELT)) {
- this.resourceBrowserOpeners.add((IResourceBrowserOpener) configElt
- .createExecutableExtension(BrowserRegistry.CLASS));
- }
- }
- } catch (CoreException e) {
- Logger.logError(e, Activator.getDefault());
- }
- }
- }
- } else {
- Logger.logError(
- "Extension point not found: " + BrowserRegistry.EXTENSION_POINT_MODEL_VIEWER_ID, //$NON-NLS-1$
- Activator.getDefault());
- }
- }
-
- public void browseEPackage(final EPackage ePackage) {
- if (ePackage == null) {
- throw new IllegalArgumentException();
- }
- IEPackageBrowserOpener opener = getDefaultEPackageBrowserOpener();
- if (opener != null) {
- opener.openEPackage(ePackage);
- } else {
- Logger.logWarning(
- "No epackage browser opener is registered to open ePackage " + ePackage.getNsURI(), Activator.getDefault()); //$NON-NLS-1$
- }
- }
-
- public void browseResource(final Resource resource) {
- if (resource == null) {
- throw new IllegalArgumentException();
- }
- IResourceBrowserOpener opener = getDefaultResourceBrowserOpener();
- if (opener != null) {
- opener.openResource(resource);
- } else {
- Logger.logWarning(
- "No resource browser opener is registered to open " + resource.getURI(), Activator.getDefault()); //$NON-NLS-1$
- }
- }
-
- public void browseEObject(final EObject eObject) {
- if (eObject == null) {
- throw new IllegalArgumentException();
- }
- IEObjectBrowserOpener opener = getDefaultEObjectBrowserOpener();
- if (opener != null) {
- opener.openEObject(eObject);
- } else {
- Logger.logWarning(
- "No eobject browser opener is registered to open " + eObject.toString(), Activator.getDefault()); //$NON-NLS-1$
- }
- }
-
- public List<IEPackageBrowserOpener> getAllRegisteredEPackageBrowsers() {
- return Collections.unmodifiableList(this.epackageBrowserOpeners);
- }
-
- public List<IEObjectBrowserOpener> getAllRegisteredEObjectBrowsers() {
- return Collections.unmodifiableList(this.eobjectBrowserOpeners);
- }
-
- public List<IResourceBrowserOpener> getAllRegisteredResourceBrowsers() {
- return Collections.unmodifiableList(this.resourceBrowserOpeners);
- }
-
- /**
- * @return the default EPackage browser opener, can be null
- */
- public IEPackageBrowserOpener getDefaultEPackageBrowserOpener() {
- IEclipsePreferences preferenceNode = new InstanceScope().getNode(Activator.PLUGIN_ID);
- String className = preferenceNode.get(PreferenceConstants.P_DEFAULT_EPACKAGE_VIEWER, null);
- if (className != null) {
- for (IEPackageBrowserOpener ePackageBrowserFactory : this.epackageBrowserOpeners) {
- if (ePackageBrowserFactory.getClass().getName().equals(className)) {
- return ePackageBrowserFactory;
- }
- }
- }
- // By default return the first editor registered through the extension
- // point org.eclipse.papyrus.emf.facet.util.emf.core.modelViewer
- if (!this.epackageBrowserOpeners.isEmpty()) {
- return this.epackageBrowserOpeners.get(0);
- }
-
- return null;
-
- }
-
- /**
- * @return the default EObject browser opener, can be null
- */
- public IEObjectBrowserOpener getDefaultEObjectBrowserOpener() {
- IEclipsePreferences preferenceNode = new InstanceScope().getNode(Activator.PLUGIN_ID);
- String className = preferenceNode.get(PreferenceConstants.P_DEFAULT_EOBJECT_VIEWER, null);
- if (className != null) {
- for (IEObjectBrowserOpener eObjectBrowserFactory : this.eobjectBrowserOpeners) {
- if (eObjectBrowserFactory.getClass().getName().equals(className)) {
- return eObjectBrowserFactory;
- }
- }
- }
- // By default return the first editor registered through the extension
- // point org.eclipse.papyrus.emf.facet.util.emf.core.modelViewer
- if (!this.eobjectBrowserOpeners.isEmpty()) {
- return this.eobjectBrowserOpeners.get(0);
- }
-
- return null;
-
- }
-
- /**
- * @return the default Resource browser opener, can be <code>null</code>
- */
- public IResourceBrowserOpener getDefaultResourceBrowserOpener() {
- IEclipsePreferences preferenceNode = new InstanceScope().getNode(Activator.PLUGIN_ID);
- String className = preferenceNode.get(PreferenceConstants.P_DEFAULT_RESOURCE_VIEWER, null);
- if (className != null) {
- for (IResourceBrowserOpener resourceBrowserOpener : this.resourceBrowserOpeners) {
- if (resourceBrowserOpener.getClass().getName().equals(className)) {
- return resourceBrowserOpener;
- }
- }
- }
- // By default return the first editor registered through the extension
- // point org.eclipse.papyrus.emf.facet.util.emf.core.modelViewer
- if (!this.resourceBrowserOpeners.isEmpty()) {
- return this.resourceBrowserOpeners.get(0);
- }
-
- return null;
- }
-
-}
+/********************************************************************************** + * Copyright (c) 2011 Mia-Software. + * 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: + * Nicolas Guyomar (Mia-Software) - Bug 333652 Extension point offering the possibility to declare an EPackage browser + * Nicolas Bros (Mia-Software) - Bug 335218 - Extension point for registering EObject, EPackage, model editor + * Laurent Pichierri (Soft-Maint) - Bug 371204 - Compatibility with Helios + ***********************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.emf.core.internal.registry; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.papyrus.emf.facet.util.emf.core.IBrowserRegistry; +import org.eclipse.papyrus.emf.facet.util.emf.core.IEObjectBrowserOpener; +import org.eclipse.papyrus.emf.facet.util.emf.core.IEPackageBrowserOpener; +import org.eclipse.papyrus.emf.facet.util.emf.core.IResourceBrowserOpener; +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.Activator; +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.preferences.PreferenceConstants; + +/** A registry for the EObject, EPackage, and Resource browser opener extension point. */ +public class BrowserRegistry implements IBrowserRegistry { + + private static final String EXTENSION_POINT_RESOURCE_VIEWER_ELT = "resourceViewer"; //$NON-NLS-1$ + private static final String EXTENSION_POINT_EOBJECT_VIEWER_ELT = "eObjectViewer"; //$NON-NLS-1$ + private static final String EXTENSION_POINT_EPACKAGE_VIEWER_ELT = "ePackageViewer"; //$NON-NLS-1$ + private final List<IEPackageBrowserOpener> epackageBrowserOpeners; + private final List<IEObjectBrowserOpener> eobjectBrowserOpeners; + private final List<IResourceBrowserOpener> resourceBrowserOpeners; + + public static final String EXTENSION_POINT_MODEL_VIEWER_ID = "org.eclipse.papyrus.emf.facet.util.emf.core.modelViewer"; //$NON-NLS-1$ + + public static final String CLASS = "class"; //$NON-NLS-1$ + + public BrowserRegistry() { + this.epackageBrowserOpeners = new ArrayList<IEPackageBrowserOpener>(); + this.eobjectBrowserOpeners = new ArrayList<IEObjectBrowserOpener>(); + this.resourceBrowserOpeners = new ArrayList<IResourceBrowserOpener>(); + + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint extensionPoint = registry + .getExtensionPoint(BrowserRegistry.EXTENSION_POINT_MODEL_VIEWER_ID); + if (extensionPoint != null) { + for (IExtension ext : extensionPoint.getExtensions()) { + for (IConfigurationElement configElt : ext.getConfigurationElements()) { + + String kind = configElt.getName(); + String classID = configElt.getAttribute(BrowserRegistry.CLASS); + try { + if (classID != null) { + if (kind.equals(BrowserRegistry.EXTENSION_POINT_EPACKAGE_VIEWER_ELT)) { + this.epackageBrowserOpeners.add((IEPackageBrowserOpener) configElt + .createExecutableExtension(BrowserRegistry.CLASS)); + } else if (kind + .equals(BrowserRegistry.EXTENSION_POINT_EOBJECT_VIEWER_ELT)) { + this.eobjectBrowserOpeners.add((IEObjectBrowserOpener) configElt + .createExecutableExtension(BrowserRegistry.CLASS)); + } else if (kind + .equals(BrowserRegistry.EXTENSION_POINT_RESOURCE_VIEWER_ELT)) { + this.resourceBrowserOpeners.add((IResourceBrowserOpener) configElt + .createExecutableExtension(BrowserRegistry.CLASS)); + } + } + } catch (CoreException e) { + Logger.logError(e, Activator.getDefault()); + } + } + } + } else { + Logger.logError( + "Extension point not found: " + BrowserRegistry.EXTENSION_POINT_MODEL_VIEWER_ID, //$NON-NLS-1$ + Activator.getDefault()); + } + } + + public void browseEPackage(final EPackage ePackage) { + if (ePackage == null) { + throw new IllegalArgumentException(); + } + IEPackageBrowserOpener opener = getDefaultEPackageBrowserOpener(); + if (opener != null) { + opener.openEPackage(ePackage); + } else { + Logger.logWarning( + "No epackage browser opener is registered to open ePackage " + ePackage.getNsURI(), Activator.getDefault()); //$NON-NLS-1$ + } + } + + public void browseResource(final Resource resource) { + if (resource == null) { + throw new IllegalArgumentException(); + } + IResourceBrowserOpener opener = getDefaultResourceBrowserOpener(); + if (opener != null) { + opener.openResource(resource); + } else { + Logger.logWarning( + "No resource browser opener is registered to open " + resource.getURI(), Activator.getDefault()); //$NON-NLS-1$ + } + } + + public void browseEObject(final EObject eObject) { + if (eObject == null) { + throw new IllegalArgumentException(); + } + IEObjectBrowserOpener opener = getDefaultEObjectBrowserOpener(); + if (opener != null) { + opener.openEObject(eObject); + } else { + Logger.logWarning( + "No eobject browser opener is registered to open " + eObject.toString(), Activator.getDefault()); //$NON-NLS-1$ + } + } + + public List<IEPackageBrowserOpener> getAllRegisteredEPackageBrowsers() { + return Collections.unmodifiableList(this.epackageBrowserOpeners); + } + + public List<IEObjectBrowserOpener> getAllRegisteredEObjectBrowsers() { + return Collections.unmodifiableList(this.eobjectBrowserOpeners); + } + + public List<IResourceBrowserOpener> getAllRegisteredResourceBrowsers() { + return Collections.unmodifiableList(this.resourceBrowserOpeners); + } + + /** + * @return the default EPackage browser opener, can be null + */ + public IEPackageBrowserOpener getDefaultEPackageBrowserOpener() { + IEclipsePreferences preferenceNode = new InstanceScope().getNode(Activator.PLUGIN_ID); + String className = preferenceNode.get(PreferenceConstants.P_DEFAULT_EPACKAGE_VIEWER, null); + if (className != null) { + for (IEPackageBrowserOpener ePackageBrowserFactory : this.epackageBrowserOpeners) { + if (ePackageBrowserFactory.getClass().getName().equals(className)) { + return ePackageBrowserFactory; + } + } + } + // By default return the first editor registered through the extension + // point org.eclipse.papyrus.emf.facet.util.emf.core.modelViewer + if (!this.epackageBrowserOpeners.isEmpty()) { + return this.epackageBrowserOpeners.get(0); + } + + return null; + + } + + /** + * @return the default EObject browser opener, can be null + */ + public IEObjectBrowserOpener getDefaultEObjectBrowserOpener() { + IEclipsePreferences preferenceNode = new InstanceScope().getNode(Activator.PLUGIN_ID); + String className = preferenceNode.get(PreferenceConstants.P_DEFAULT_EOBJECT_VIEWER, null); + if (className != null) { + for (IEObjectBrowserOpener eObjectBrowserFactory : this.eobjectBrowserOpeners) { + if (eObjectBrowserFactory.getClass().getName().equals(className)) { + return eObjectBrowserFactory; + } + } + } + // By default return the first editor registered through the extension + // point org.eclipse.papyrus.emf.facet.util.emf.core.modelViewer + if (!this.eobjectBrowserOpeners.isEmpty()) { + return this.eobjectBrowserOpeners.get(0); + } + + return null; + + } + + /** + * @return the default Resource browser opener, can be <code>null</code> + */ + public IResourceBrowserOpener getDefaultResourceBrowserOpener() { + IEclipsePreferences preferenceNode = new InstanceScope().getNode(Activator.PLUGIN_ID); + String className = preferenceNode.get(PreferenceConstants.P_DEFAULT_RESOURCE_VIEWER, null); + if (className != null) { + for (IResourceBrowserOpener resourceBrowserOpener : this.resourceBrowserOpeners) { + if (resourceBrowserOpener.getClass().getName().equals(className)) { + return resourceBrowserOpener; + } + } + } + // By default return the first editor registered through the extension + // point org.eclipse.papyrus.emf.facet.util.emf.core.modelViewer + if (!this.resourceBrowserOpeners.isEmpty()) { + return this.resourceBrowserOpeners.get(0); + } + + return null; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/SerializationRegistry.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/SerializationRegistry.java index b6c0ae0aa31..80df0a12c56 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/SerializationRegistry.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/SerializationRegistry.java @@ -1,133 +1,133 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- * Laurent Pichierri (Soft-Maint) - Bug 371204 - Compatibility with Helios
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.emf.core.internal.serialization;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-//import org.eclipse.papyrus.emf.facet.infra.common.core.internal.extensions.AbstractRegistry;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.papyrus.emf.facet.util.core.internal.exported.AbstractRegistry;
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.Activator;
-import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializationRegistry;
-import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializer;
-
-/** Registry for the "serialization" extension point */
-public class SerializationRegistry extends AbstractRegistry implements ISerializationRegistry {
-
- private static final String EXTENSION_POINT_NAMESPACE = "org.eclipse.papyrus.emf.facet.util.emf.core"; //$NON-NLS-1$
- private static final String EXTENSION_POINT_NAME = "serialization"; //$NON-NLS-1$
-
- private static final String SERIALIZER_ELEMENT = "serializer"; //$NON-NLS-1$
- private static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$
-
- private static SerializationRegistry instance = null;
-
- private final List<ISerializer<?>> serializers = new ArrayList<ISerializer<?>>();
-
- public static SerializationRegistry getInstance() {
- if (SerializationRegistry.instance == null) {
- SerializationRegistry.instance = new SerializationRegistry();
- }
- return SerializationRegistry.instance;
- }
-
- public SerializationRegistry() {
- initialize();
- }
-
- public List<ISerializer<?>> getSerializers() {
- return Collections.unmodifiableList(this.serializers);
- }
-
- public ISerializer<?> getSerializerFor(final Class<?> type) {
- for (ISerializer<?> serializer : this.serializers) {
- if (serializer.getType().isAssignableFrom(type)) {
- return serializer;
- }
- }
- return null;
- }
-
- public ISerializer<?> getSerializerFor(final String type) {
- for (ISerializer<?> serializer : this.serializers) {
- if (serializer.getType().getName().equals(type)) {
- return serializer;
- }
- }
- return null;
- }
-
- @Override
- protected String getExtensionPointName() {
- return SerializationRegistry.EXTENSION_POINT_NAME;
- }
-
- @Override
- protected String getExtensionPointNamespace() {
- return SerializationRegistry.EXTENSION_POINT_NAMESPACE;
- }
-
- @Override
- protected void handleRootElement(final IConfigurationElement configurationElement) {
- final String name = configurationElement.getName();
- if (name.equalsIgnoreCase(SerializationRegistry.SERIALIZER_ELEMENT)) {
- readSerializerElement(configurationElement);
- } else {
- logUnknownElement(configurationElement);
- }
- }
-
- /** Read a 'serializer' element */
- private void readSerializerElement(final IConfigurationElement configurationElement) {
- Object object;
- try {
- object = configurationElement
- .createExecutableExtension(SerializationRegistry.CLASS_ATTRIBUTE);
- } catch (CoreException e) {
- Logger.logError(e, Activator.getDefault());
- return;
- }
- if (object == null) {
- logMissingAttribute(configurationElement, SerializationRegistry.CLASS_ATTRIBUTE);
- return;
- }
-
- if (object instanceof ISerializer<?>) {
- ISerializer<?> serializer = (ISerializer<?>) object;
- ISerializer<?> existingSerializer = getSerializerFor(serializer.getType());
- if (existingSerializer != null) {
- logError(
- configurationElement,
- "Several serializers are provided for the type: " + serializer.getType().getName() + ". Only the first one will be used."); //$NON-NLS-1$ //$NON-NLS-2$
-
- // always take the first one in the alphabetical order => determinism to avoid
- // trying to serialize with one implementation and deserialize with an incompatible
- // implementation
- if (serializer.getClass().getName()
- .compareTo(existingSerializer.getClass().getName()) < 0) {
- // replace the already registered serializer by this one
- this.serializers.remove(existingSerializer);
- } else {
- return;
- }
- }
- this.serializers.add(serializer);
- } else {
- logError(configurationElement,
- "class must implement " + ISerializer.class.getSimpleName()); //$NON-NLS-1$
- }
- }
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - initial API and implementation + * Laurent Pichierri (Soft-Maint) - Bug 371204 - Compatibility with Helios + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.emf.core.internal.serialization; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +//import org.eclipse.papyrus.emf.facet.infra.common.core.internal.extensions.AbstractRegistry; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.papyrus.emf.facet.util.core.internal.exported.AbstractRegistry; +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.Activator; +import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializationRegistry; +import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializer; + +/** Registry for the "serialization" extension point */ +public class SerializationRegistry extends AbstractRegistry implements ISerializationRegistry { + + private static final String EXTENSION_POINT_NAMESPACE = "org.eclipse.papyrus.emf.facet.util.emf.core"; //$NON-NLS-1$ + private static final String EXTENSION_POINT_NAME = "serialization"; //$NON-NLS-1$ + + private static final String SERIALIZER_ELEMENT = "serializer"; //$NON-NLS-1$ + private static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$ + + private static SerializationRegistry instance = null; + + private final List<ISerializer<?>> serializers = new ArrayList<ISerializer<?>>(); + + public static SerializationRegistry getInstance() { + if (SerializationRegistry.instance == null) { + SerializationRegistry.instance = new SerializationRegistry(); + } + return SerializationRegistry.instance; + } + + public SerializationRegistry() { + initialize(); + } + + public List<ISerializer<?>> getSerializers() { + return Collections.unmodifiableList(this.serializers); + } + + public ISerializer<?> getSerializerFor(final Class<?> type) { + for (ISerializer<?> serializer : this.serializers) { + if (serializer.getType().isAssignableFrom(type)) { + return serializer; + } + } + return null; + } + + public ISerializer<?> getSerializerFor(final String type) { + for (ISerializer<?> serializer : this.serializers) { + if (serializer.getType().getName().equals(type)) { + return serializer; + } + } + return null; + } + + @Override + protected String getExtensionPointName() { + return SerializationRegistry.EXTENSION_POINT_NAME; + } + + @Override + protected String getExtensionPointNamespace() { + return SerializationRegistry.EXTENSION_POINT_NAMESPACE; + } + + @Override + protected void handleRootElement(final IConfigurationElement configurationElement) { + final String name = configurationElement.getName(); + if (name.equalsIgnoreCase(SerializationRegistry.SERIALIZER_ELEMENT)) { + readSerializerElement(configurationElement); + } else { + logUnknownElement(configurationElement); + } + } + + /** Read a 'serializer' element */ + private void readSerializerElement(final IConfigurationElement configurationElement) { + Object object; + try { + object = configurationElement + .createExecutableExtension(SerializationRegistry.CLASS_ATTRIBUTE); + } catch (CoreException e) { + Logger.logError(e, Activator.getDefault()); + return; + } + if (object == null) { + logMissingAttribute(configurationElement, SerializationRegistry.CLASS_ATTRIBUTE); + return; + } + + if (object instanceof ISerializer<?>) { + ISerializer<?> serializer = (ISerializer<?>) object; + ISerializer<?> existingSerializer = getSerializerFor(serializer.getType()); + if (existingSerializer != null) { + logError( + configurationElement, + "Several serializers are provided for the type: " + serializer.getType().getName() + ". Only the first one will be used."); //$NON-NLS-1$ //$NON-NLS-2$ + + // always take the first one in the alphabetical order => determinism to avoid + // trying to serialize with one implementation and deserialize with an incompatible + // implementation + if (serializer.getClass().getName() + .compareTo(existingSerializer.getClass().getName()) < 0) { + // replace the already registered serializer by this one + this.serializers.remove(existingSerializer); + } else { + return; + } + } + this.serializers.add(serializer); + } else { + logError(configurationElement, + "class must implement " + ISerializer.class.getSimpleName()); //$NON-NLS-1$ + } + } }
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/SerializationService.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/SerializationService.java index e8c21b702a1..d14893c8be9 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/SerializationService.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/SerializationService.java @@ -1,66 +1,66 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- * Nicolas Bros (Mia-Software) - Bug 338907 - expose serialization services from SerializationFactoryImpl
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.emf.core.internal.serialization;
-
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.Activator;
-import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializationRegistry;
-import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializationService;
-import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializer;
-
-public class SerializationService implements ISerializationService {
-
- public String serialize(final Object instanceValue) {
- if (instanceValue == null) {
- return "null"; //$NON-NLS-1$
- }
-
- ISerializer<Object> serializer = (ISerializer<Object>) ISerializationRegistry.INSTANCE
- .getSerializerFor(instanceValue.getClass());
- if (serializer != null) {
- return serializer.getType().getName() + ":" //$NON-NLS-1$
- + serializer.serialize(instanceValue);
- }
-
- Logger.logError("serialization of type " + instanceValue.getClass().getName() //$NON-NLS-1$
- + " is not implemented.", Activator.getDefault()); //$NON-NLS-1$
- return "null"; //$NON-NLS-1$
- }
-
- public Object deserialize(final String serializedValue) {
- try {
- if ("null".equals(serializedValue)) { //$NON-NLS-1$
- return null;
- }
-
- int colonPos = serializedValue.indexOf(':');
- if (colonPos == -1) {
- throw new IllegalArgumentException("invalid serialization format"); //$NON-NLS-1$
- }
- String type = serializedValue.substring(0, colonPos);
- String strValue = serializedValue.substring(colonPos + 1);
-
- ISerializer<?> serializer = ISerializationRegistry.INSTANCE.getSerializerFor(type);
- if (serializer != null) {
- Object value = serializer.deserialize(strValue);
- return value;
- }
-
- Logger.logError("deserialization of type " + type //$NON-NLS-1$
- + " is not implemented.", Activator.getDefault()); //$NON-NLS-1$
- } catch (Exception e) {
- Logger.logError(e, "Error deserializing: " + serializedValue, //$NON-NLS-1$
- Activator.getDefault());
- }
- return null;
- }
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - initial API and implementation + * Nicolas Bros (Mia-Software) - Bug 338907 - expose serialization services from SerializationFactoryImpl + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.emf.core.internal.serialization; + +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.Activator; +import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializationRegistry; +import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializationService; +import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializer; + +public class SerializationService implements ISerializationService { + + public String serialize(final Object instanceValue) { + if (instanceValue == null) { + return "null"; //$NON-NLS-1$ + } + + ISerializer<Object> serializer = (ISerializer<Object>) ISerializationRegistry.INSTANCE + .getSerializerFor(instanceValue.getClass()); + if (serializer != null) { + return serializer.getType().getName() + ":" //$NON-NLS-1$ + + serializer.serialize(instanceValue); + } + + Logger.logError("serialization of type " + instanceValue.getClass().getName() //$NON-NLS-1$ + + " is not implemented.", Activator.getDefault()); //$NON-NLS-1$ + return "null"; //$NON-NLS-1$ + } + + public Object deserialize(final String serializedValue) { + try { + if ("null".equals(serializedValue)) { //$NON-NLS-1$ + return null; + } + + int colonPos = serializedValue.indexOf(':'); + if (colonPos == -1) { + throw new IllegalArgumentException("invalid serialization format"); //$NON-NLS-1$ + } + String type = serializedValue.substring(0, colonPos); + String strValue = serializedValue.substring(colonPos + 1); + + ISerializer<?> serializer = ISerializationRegistry.INSTANCE.getSerializerFor(type); + if (serializer != null) { + Object value = serializer.deserialize(strValue); + return value; + } + + Logger.logError("deserialization of type " + type //$NON-NLS-1$ + + " is not implemented.", Activator.getDefault()); //$NON-NLS-1$ + } catch (Exception e) { + Logger.logError(e, "Error deserializing: " + serializedValue, //$NON-NLS-1$ + Activator.getDefault()); + } + return null; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/BooleanSerializer.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/BooleanSerializer.java index 4eabaac1cf4..21b0e6e973e 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/BooleanSerializer.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/BooleanSerializer.java @@ -1,32 +1,32 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.emf.core.internal.serialization.serializers;
-
-import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializer;
-
-public class BooleanSerializer implements ISerializer<Boolean> {
-
- public BooleanSerializer() {
- //
- }
-
- public Class<Boolean> getType() {
- return Boolean.class;
- }
-
- public String serialize(final Boolean value) {
- return value.toString();
- }
-
- public Boolean deserialize(final String serializedValue) {
- return Boolean.valueOf(serializedValue);
- }
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.emf.core.internal.serialization.serializers; + +import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializer; + +public class BooleanSerializer implements ISerializer<Boolean> { + + public BooleanSerializer() { + // + } + + public Class<Boolean> getType() { + return Boolean.class; + } + + public String serialize(final Boolean value) { + return value.toString(); + } + + public Boolean deserialize(final String serializedValue) { + return Boolean.valueOf(serializedValue); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/EMFURISerializer.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/EMFURISerializer.java index 008fe7f745a..bd72491e649 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/EMFURISerializer.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/EMFURISerializer.java @@ -1,33 +1,33 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.emf.core.internal.serialization.serializers;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializer;
-
-public class EMFURISerializer implements ISerializer<URI> {
-
- public EMFURISerializer() {
- //
- }
-
- public Class<URI> getType() {
- return URI.class;
- }
-
- public String serialize(final URI value) {
- return value.toString();
- }
-
- public URI deserialize(final String serializedValue) {
- return URI.createURI(serializedValue);
- }
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.emf.core.internal.serialization.serializers; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializer; + +public class EMFURISerializer implements ISerializer<URI> { + + public EMFURISerializer() { + // + } + + public Class<URI> getType() { + return URI.class; + } + + public String serialize(final URI value) { + return value.toString(); + } + + public URI deserialize(final String serializedValue) { + return URI.createURI(serializedValue); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/IResourceSerializer.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/IResourceSerializer.java index 2ef2012dc19..45708f4f6f1 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/IResourceSerializer.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/IResourceSerializer.java @@ -1,34 +1,34 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.emf.core.internal.serialization.serializers;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializer;
-
-public class IResourceSerializer implements ISerializer<IResource> {
-
- public IResourceSerializer() {
- //
- }
-
- public Class<IResource> getType() {
- return IResource.class;
- }
-
- public String serialize(final IResource value) {
- return value.getFullPath().toPortableString();
- }
-
- public IResource deserialize(final String serializedValue) {
- return ResourcesPlugin.getWorkspace().getRoot().findMember(serializedValue);
- }
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.emf.core.internal.serialization.serializers; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializer; + +public class IResourceSerializer implements ISerializer<IResource> { + + public IResourceSerializer() { + // + } + + public Class<IResource> getType() { + return IResource.class; + } + + public String serialize(final IResource value) { + return value.getFullPath().toPortableString(); + } + + public IResource deserialize(final String serializedValue) { + return ResourcesPlugin.getWorkspace().getRoot().findMember(serializedValue); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/IntegerSerializer.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/IntegerSerializer.java index f2921bb159c..0efa5cec116 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/IntegerSerializer.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/IntegerSerializer.java @@ -1,32 +1,32 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.emf.core.internal.serialization.serializers;
-
-import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializer;
-
-public class IntegerSerializer implements ISerializer<Integer> {
-
- public IntegerSerializer() {
- //
- }
-
- public Class<Integer> getType() {
- return Integer.class;
- }
-
- public String serialize(final Integer value) {
- return value.toString();
- }
-
- public Integer deserialize(final String serializedValue) {
- return Integer.valueOf(serializedValue);
- }
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.emf.core.internal.serialization.serializers; + +import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializer; + +public class IntegerSerializer implements ISerializer<Integer> { + + public IntegerSerializer() { + // + } + + public Class<Integer> getType() { + return Integer.class; + } + + public String serialize(final Integer value) { + return value.toString(); + } + + public Integer deserialize(final String serializedValue) { + return Integer.valueOf(serializedValue); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/StringSerializer.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/StringSerializer.java index fc98b7bd6b1..a9e3dbde4cb 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/StringSerializer.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/internal/serialization/serializers/StringSerializer.java @@ -1,32 +1,32 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.emf.core.internal.serialization.serializers;
-
-import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializer;
-
-public class StringSerializer implements ISerializer<String> {
-
- public StringSerializer() {
- //
- }
-
- public Class<String> getType() {
- return String.class;
- }
-
- public String serialize(final String value) {
- return value;
- }
-
- public String deserialize(final String serializedValue) {
- return serializedValue;
- }
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.emf.core.internal.serialization.serializers; + +import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializer; + +public class StringSerializer implements ISerializer<String> { + + public StringSerializer() { + // + } + + public Class<String> getType() { + return String.class; + } + + public String serialize(final String value) { + return value; + } + + public String deserialize(final String serializedValue) { + return serializedValue; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/ISerializationRegistry.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/ISerializationRegistry.java index 6a1a5e9f7f0..34017550351 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/ISerializationRegistry.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/ISerializationRegistry.java @@ -1,35 +1,35 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.emf.core.serialization;
-
-import java.util.List;
-
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.serialization.SerializationRegistry;
-
-/** The registry of {@link ISerializer}s per type. */
-public interface ISerializationRegistry {
- public static ISerializationRegistry INSTANCE = new SerializationRegistry();
-
- /** Get all the serializers . */
- List<ISerializer<?>> getSerializers();
-
- /**
- * @return the serializer for the given type, or <code>null</code> if none has been registered.
- * Also returns serializers for super-types of <code>type</code>.
- */
- ISerializer<?> getSerializerFor(Class<?> type);
-
- /**
- * @return the serializer for the given type qualified name, or <code>null</code> if none has
- * been registered. Does not return serializers for super-types of <code>type</code>.
- */
- ISerializer<?> getSerializerFor(String type);
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.emf.core.serialization; + +import java.util.List; + +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.serialization.SerializationRegistry; + +/** The registry of {@link ISerializer}s per type. */ +public interface ISerializationRegistry { + public static ISerializationRegistry INSTANCE = new SerializationRegistry(); + + /** Get all the serializers . */ + List<ISerializer<?>> getSerializers(); + + /** + * @return the serializer for the given type, or <code>null</code> if none has been registered. + * Also returns serializers for super-types of <code>type</code>. + */ + ISerializer<?> getSerializerFor(Class<?> type); + + /** + * @return the serializer for the given type qualified name, or <code>null</code> if none has + * been registered. Does not return serializers for super-types of <code>type</code>. + */ + ISerializer<?> getSerializerFor(String type); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/ISerializationService.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/ISerializationService.java index 30ae9fc83b1..88c63272ba0 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/ISerializationService.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/ISerializationService.java @@ -1,29 +1,29 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- * Nicolas Bros (Mia-Software) - Bug 338907 - expose serialization services from SerializationFactoryImpl
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.emf.core.serialization;
-
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.serialization.SerializationService;
-
-/**
- * Provides a serialization service so that the following is true:<br/>
- * <code>deserialize(serialize(object)) == object</code>
- */
-public interface ISerializationService {
-
- public ISerializationService INSTANCE = new SerializationService();
-
- /** Serialize the given value. */
- String serialize(Object instanceValue);
-
- /** Deserialize the given string back into the value. */
- Object deserialize(String serializedValue);
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - initial API and implementation + * Nicolas Bros (Mia-Software) - Bug 338907 - expose serialization services from SerializationFactoryImpl + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.emf.core.serialization; + +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.serialization.SerializationService; + +/** + * Provides a serialization service so that the following is true:<br/> + * <code>deserialize(serialize(object)) == object</code> + */ +public interface ISerializationService { + + public ISerializationService INSTANCE = new SerializationService(); + + /** Serialize the given value. */ + String serialize(Object instanceValue); + + /** Deserialize the given string back into the value. */ + Object deserialize(String serializedValue); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/ISerializer.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/ISerializer.java index 77ca23c1771..c87a5528299 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/ISerializer.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/ISerializer.java @@ -1,33 +1,33 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.emf.core.serialization;
-
-/**
- * The interface that must be implemented when adding an extension to the "serializer" extension
- * point.
- *
- * @see ISerializationRegistry
- */
-// note: the serializer has to return the {@link Class} object instead of a qualified name
-// because that's the one that has it on its bundle classpath.
-public interface ISerializer<T> {
-
- /** @return the type handled by this serializer. */
- Class<T> getType();
-
- /** Serialize the given value into a String */
- String serialize(T value);
-
- /**
- * Deserialize the given String back into the original value that was serialized with {@link ISerializer#serialize(Object)}
- */
- T deserialize(String serializedValue);
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.emf.core.serialization; + +/** + * The interface that must be implemented when adding an extension to the "serializer" extension + * point. + * + * @see ISerializationRegistry + */ +// note: the serializer has to return the {@link Class} object instead of a qualified name +// because that's the one that has it on its bundle classpath. +public interface ISerializer<T> { + + /** @return the type handled by this serializer. */ + Class<T> getType(); + + /** Serialize the given value into a String */ + String serialize(T value); + + /** + * Deserialize the given String back into the original value that was serialized with {@link ISerializer#serialize(Object)} + */ + T deserialize(String serializedValue); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/model/serialization/SerializationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/model/serialization/SerializationFactory.java index bf3d2c2b600..9142e6bdaad 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/model/serialization/SerializationFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/model/serialization/SerializationFactory.java @@ -1,44 +1,44 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization;
-
-import org.eclipse.emf.ecore.EFactory;
-
-/**
- * <!-- begin-user-doc -->
- * The <b>Factory</b> for the model.
- * It provides a create method for each non-abstract class of the model.
- * <!-- end-user-doc -->
- *
- * @see org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.SerializationPackage
- * @generated
- */
-public interface SerializationFactory extends EFactory {
- /**
- * The singleton instance of the factory.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @generated
- */
- SerializationFactory eINSTANCE = org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.impl.SerializationFactoryImpl.init();
-
- /**
- * Returns the package supported by this factory.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @return the package supported by this factory.
- * @generated
- */
- SerializationPackage getSerializationPackage();
-
-} // SerializationFactory
+/** + * Copyright (c) 2011 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - initial API and implementation + */ +package org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization; + +import org.eclipse.emf.ecore.EFactory; + +/** + * <!-- begin-user-doc --> + * The <b>Factory</b> for the model. + * It provides a create method for each non-abstract class of the model. + * <!-- end-user-doc --> + * + * @see org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.SerializationPackage + * @generated + */ +public interface SerializationFactory extends EFactory { + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @generated + */ + SerializationFactory eINSTANCE = org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.impl.SerializationFactoryImpl.init(); + + /** + * Returns the package supported by this factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @return the package supported by this factory. + * @generated + */ + SerializationPackage getSerializationPackage(); + +} // SerializationFactory diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/model/serialization/SerializationPackage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/model/serialization/SerializationPackage.java index 1cfe69734f7..da724de0390 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/model/serialization/SerializationPackage.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/model/serialization/SerializationPackage.java @@ -1,131 +1,131 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization;
-
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EPackage;
-
-/**
- * <!-- begin-user-doc -->
- * The <b>Package</b> for the model.
- * It contains accessors for the meta objects to represent
- * <ul>
- * <li>each class,</li>
- * <li>each feature of each class,</li>
- * <li>each enum,</li>
- * <li>and each data type</li>
- * </ul>
- * <!-- end-user-doc -->
- *
- * @see org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.SerializationFactory
- * @model kind="package"
- * @generated
- */
-@SuppressWarnings("all")
-public interface SerializationPackage extends EPackage {
- /**
- * The package name.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @generated
- */
- String eNAME = "serialization"; //$NON-NLS-1$
-
- /**
- * The package namespace URI.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @generated
- */
- String eNS_URI = "http://www.eclipse.org/papyrus/emf/facet/serialization/0.1.incubation"; //$NON-NLS-1$
-
- /**
- * The package namespace name.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @generated
- */
- String eNS_PREFIX = "serialization"; //$NON-NLS-1$
-
- /**
- * The singleton instance of the package.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @generated
- */
- SerializationPackage eINSTANCE = org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.impl.SerializationPackageImpl.init();
-
- /**
- * The meta object id for the '<em>Extensible Serializable Java Object</em>' data type.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @see java.lang.Object
- * @see org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.impl.SerializationPackageImpl#getExtensibleSerializableJavaObject()
- * @generated
- */
- int EXTENSIBLE_SERIALIZABLE_JAVA_OBJECT = 0;
-
-
- /**
- * Returns the meta object for data type '{@link java.lang.Object <em>Extensible Serializable Java Object</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @return the meta object for data type '<em>Extensible Serializable Java Object</em>'.
- * @see java.lang.Object
- * @model instanceClass="java.lang.Object"
- * @generated
- */
- EDataType getExtensibleSerializableJavaObject();
-
- /**
- * Returns the factory that creates the instances of the model.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @return the factory that creates the instances of the model.
- * @generated
- */
- SerializationFactory getSerializationFactory();
-
- /**
- * <!-- begin-user-doc -->
- * Defines literals for the meta objects that represent
- * <ul>
- * <li>each class,</li>
- * <li>each feature of each class,</li>
- * <li>each enum,</li>
- * <li>and each data type</li>
- * </ul>
- * <!-- end-user-doc -->
- *
- * @generated
- */
- interface Literals {
- /**
- * The meta object literal for the '<em>Extensible Serializable Java Object</em>' data type.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @see java.lang.Object
- * @see org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.impl.SerializationPackageImpl#getExtensibleSerializableJavaObject()
- * @generated
- */
- EDataType EXTENSIBLE_SERIALIZABLE_JAVA_OBJECT = SerializationPackage.eINSTANCE.getExtensibleSerializableJavaObject();
-
- }
-
-} // SerializationPackage
+/** + * Copyright (c) 2011 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - initial API and implementation + */ +package org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization; + +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EPackage; + +/** + * <!-- begin-user-doc --> + * The <b>Package</b> for the model. + * It contains accessors for the meta objects to represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * + * @see org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.SerializationFactory + * @model kind="package" + * @generated + */ +@SuppressWarnings("all") +public interface SerializationPackage extends EPackage { + /** + * The package name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @generated + */ + String eNAME = "serialization"; //$NON-NLS-1$ + + /** + * The package namespace URI. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @generated + */ + String eNS_URI = "http://www.eclipse.org/papyrus/emf/facet/serialization/0.1.incubation"; //$NON-NLS-1$ + + /** + * The package namespace name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @generated + */ + String eNS_PREFIX = "serialization"; //$NON-NLS-1$ + + /** + * The singleton instance of the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @generated + */ + SerializationPackage eINSTANCE = org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.impl.SerializationPackageImpl.init(); + + /** + * The meta object id for the '<em>Extensible Serializable Java Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @see java.lang.Object + * @see org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.impl.SerializationPackageImpl#getExtensibleSerializableJavaObject() + * @generated + */ + int EXTENSIBLE_SERIALIZABLE_JAVA_OBJECT = 0; + + + /** + * Returns the meta object for data type '{@link java.lang.Object <em>Extensible Serializable Java Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @return the meta object for data type '<em>Extensible Serializable Java Object</em>'. + * @see java.lang.Object + * @model instanceClass="java.lang.Object" + * @generated + */ + EDataType getExtensibleSerializableJavaObject(); + + /** + * Returns the factory that creates the instances of the model. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @return the factory that creates the instances of the model. + * @generated + */ + SerializationFactory getSerializationFactory(); + + /** + * <!-- begin-user-doc --> + * Defines literals for the meta objects that represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * + * @generated + */ + interface Literals { + /** + * The meta object literal for the '<em>Extensible Serializable Java Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @see java.lang.Object + * @see org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.impl.SerializationPackageImpl#getExtensibleSerializableJavaObject() + * @generated + */ + EDataType EXTENSIBLE_SERIALIZABLE_JAVA_OBJECT = SerializationPackage.eINSTANCE.getExtensibleSerializableJavaObject(); + + } + +} // SerializationPackage diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/model/serialization/impl/SerializationFactoryImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/model/serialization/impl/SerializationFactoryImpl.java index 5a13f5f102b..419d6d2558c 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/model/serialization/impl/SerializationFactoryImpl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/model/serialization/impl/SerializationFactoryImpl.java @@ -1,151 +1,151 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- * Nicolas Bros (Mia-Software) - Bug 338907 - expose serialization services from SerializationFactoryImpl
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.impl;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.impl.EFactoryImpl;
-import org.eclipse.emf.ecore.plugin.EcorePlugin;
-import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializationService;
-import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.SerializationFactory;
-import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.SerializationPackage;
-
-/**
- * <!-- begin-user-doc --> An implementation of the model <b>Factory</b>. <!-- end-user-doc -->
- *
- * @generated
- */
-public class SerializationFactoryImpl extends EFactoryImpl implements SerializationFactory {
- /**
- * Creates the default factory implementation. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public static SerializationFactory init() {
- try {
- SerializationFactory theSerializationFactory = (SerializationFactory) EPackage.Registry.INSTANCE
- .getEFactory("http://www.eclipse.org/papyrus/emf/facet/serialization/0.1.incubation"); //$NON-NLS-1$
- if (theSerializationFactory != null) {
- return theSerializationFactory;
- }
- } catch (Exception exception) {
- EcorePlugin.INSTANCE.log(exception);
- }
- return new SerializationFactoryImpl();
- }
-
- /**
- * Creates an instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public SerializationFactoryImpl() {
- super();
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- @Override
- public EObject create(final EClass eClass) {
- switch (eClass.getClassifierID()) {
- default:
- throw new IllegalArgumentException(
- "The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- @Override
- public Object createFromString(final EDataType eDataType, final String initialValue) {
- switch (eDataType.getClassifierID()) {
- case SerializationPackage.EXTENSIBLE_SERIALIZABLE_JAVA_OBJECT:
- return createExtensibleSerializableJavaObjectFromString(eDataType, initialValue);
- default:
- throw new IllegalArgumentException(
- "The datatype '" + eDataType.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- @Override
- public String convertToString(final EDataType eDataType, final Object instanceValue) {
- switch (eDataType.getClassifierID()) {
- case SerializationPackage.EXTENSIBLE_SERIALIZABLE_JAVA_OBJECT:
- return convertExtensibleSerializableJavaObjectToString(eDataType, instanceValue);
- default:
- throw new IllegalArgumentException(
- "The datatype '" + eDataType.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /**
- * <!-- begin-user-doc --> Deserializes a value.
- *
- * @param eDataType
- * the datatype
- * @param initialValue
- * the serialized value to deserialize <!-- end-user-doc -->
- * @generated NOT
- */
- public static Object createExtensibleSerializableJavaObjectFromString(
- final EDataType eDataType, final String initialValue) {
- return ISerializationService.INSTANCE.deserialize(initialValue);
- }
-
- /**
- * <!-- begin-user-doc --> Serializes a value.
- *
- * @param eDataType
- * the datatype
- * @param instanceValue
- * the value to serialize <!-- end-user-doc -->
- * @generated NOT
- */
- public static String convertExtensibleSerializableJavaObjectToString(final EDataType eDataType,
- final Object instanceValue) {
- return ISerializationService.INSTANCE.serialize(instanceValue);
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public SerializationPackage getSerializationPackage() {
- return (SerializationPackage) getEPackage();
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @deprecated
- * @generated
- */
- @Deprecated
- public static SerializationPackage getPackage() {
- return SerializationPackage.eINSTANCE;
- }
-
-} // SerializationFactoryImpl
+/** + * Copyright (c) 2011 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - initial API and implementation + * Nicolas Bros (Mia-Software) - Bug 338907 - expose serialization services from SerializationFactoryImpl + */ +package org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.impl; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.impl.EFactoryImpl; +import org.eclipse.emf.ecore.plugin.EcorePlugin; +import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.ISerializationService; +import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.SerializationFactory; +import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.SerializationPackage; + +/** + * <!-- begin-user-doc --> An implementation of the model <b>Factory</b>. <!-- end-user-doc --> + * + * @generated + */ +public class SerializationFactoryImpl extends EFactoryImpl implements SerializationFactory { + /** + * Creates the default factory implementation. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public static SerializationFactory init() { + try { + SerializationFactory theSerializationFactory = (SerializationFactory) EPackage.Registry.INSTANCE + .getEFactory("http://www.eclipse.org/papyrus/emf/facet/serialization/0.1.incubation"); //$NON-NLS-1$ + if (theSerializationFactory != null) { + return theSerializationFactory; + } + } catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new SerializationFactoryImpl(); + } + + /** + * Creates an instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public SerializationFactoryImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + @Override + public EObject create(final EClass eClass) { + switch (eClass.getClassifierID()) { + default: + throw new IllegalArgumentException( + "The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + @Override + public Object createFromString(final EDataType eDataType, final String initialValue) { + switch (eDataType.getClassifierID()) { + case SerializationPackage.EXTENSIBLE_SERIALIZABLE_JAVA_OBJECT: + return createExtensibleSerializableJavaObjectFromString(eDataType, initialValue); + default: + throw new IllegalArgumentException( + "The datatype '" + eDataType.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + @Override + public String convertToString(final EDataType eDataType, final Object instanceValue) { + switch (eDataType.getClassifierID()) { + case SerializationPackage.EXTENSIBLE_SERIALIZABLE_JAVA_OBJECT: + return convertExtensibleSerializableJavaObjectToString(eDataType, instanceValue); + default: + throw new IllegalArgumentException( + "The datatype '" + eDataType.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + + /** + * <!-- begin-user-doc --> Deserializes a value. + * + * @param eDataType + * the datatype + * @param initialValue + * the serialized value to deserialize <!-- end-user-doc --> + * @generated NOT + */ + public static Object createExtensibleSerializableJavaObjectFromString( + final EDataType eDataType, final String initialValue) { + return ISerializationService.INSTANCE.deserialize(initialValue); + } + + /** + * <!-- begin-user-doc --> Serializes a value. + * + * @param eDataType + * the datatype + * @param instanceValue + * the value to serialize <!-- end-user-doc --> + * @generated NOT + */ + public static String convertExtensibleSerializableJavaObjectToString(final EDataType eDataType, + final Object instanceValue) { + return ISerializationService.INSTANCE.serialize(instanceValue); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public SerializationPackage getSerializationPackage() { + return (SerializationPackage) getEPackage(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @deprecated + * @generated + */ + @Deprecated + public static SerializationPackage getPackage() { + return SerializationPackage.eINSTANCE; + } + +} // SerializationFactoryImpl diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/model/serialization/impl/SerializationPackageImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/model/serialization/impl/SerializationPackageImpl.java index 7886f66dadc..b002954c422 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/model/serialization/impl/SerializationPackageImpl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/serialization/model/serialization/impl/SerializationPackageImpl.java @@ -1,176 +1,176 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- */
-package org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.impl;
-
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.impl.EPackageImpl;
-import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.SerializationFactory;
-import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.SerializationPackage;
-
-/**
- * <!-- begin-user-doc -->
- * An implementation of the model <b>Package</b>.
- * <!-- end-user-doc -->
- *
- * @generated
- */
-public class SerializationPackageImpl extends EPackageImpl implements SerializationPackage {
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @generated
- */
- private EDataType extensibleSerializableJavaObjectEDataType = null;
-
- /**
- * Creates an instance of the model <b>Package</b>, registered with {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
- * package URI value.
- * <p>
- * Note: the correct way to create the package is via the static factory method {@link #init init()}, which also performs initialization of the package, or returns the registered package, if one already exists. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @see org.eclipse.emf.ecore.EPackage.Registry
- * @see org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.SerializationPackage#eNS_URI
- * @see #init()
- * @generated
- */
- private SerializationPackageImpl() {
- super(SerializationPackage.eNS_URI, SerializationFactory.eINSTANCE);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @generated
- */
- private static boolean isInited = false;
-
- /**
- * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
- *
- * <p>
- * This method is used to initialize {@link SerializationPackage#eINSTANCE} when that field is accessed. Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. <!-- begin-user-doc --> <!-- end-user-doc
- * -->
- *
- * @see #eNS_URI
- * @see #createPackageContents()
- * @see #initializePackageContents()
- * @generated
- */
- public static SerializationPackage init() {
- if (SerializationPackageImpl.isInited) {
- return (SerializationPackage) EPackage.Registry.INSTANCE.getEPackage(SerializationPackage.eNS_URI);
- }
-
- // Obtain or create and register package
- SerializationPackageImpl theSerializationPackage = (SerializationPackageImpl) (EPackage.Registry.INSTANCE.get(SerializationPackage.eNS_URI) instanceof SerializationPackageImpl ? EPackage.Registry.INSTANCE.get(SerializationPackage.eNS_URI)
- : new SerializationPackageImpl());
-
- SerializationPackageImpl.isInited = true;
-
- // Create package meta-data objects
- theSerializationPackage.createPackageContents();
-
- // Initialize created meta-data
- theSerializationPackage.initializePackageContents();
-
- // Mark meta-data to indicate it can't be changed
- theSerializationPackage.freeze();
-
-
- // Update the registry and return the package
- EPackage.Registry.INSTANCE.put(SerializationPackage.eNS_URI, theSerializationPackage);
- return theSerializationPackage;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @generated
- */
- public EDataType getExtensibleSerializableJavaObject() {
- return this.extensibleSerializableJavaObjectEDataType;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @generated
- */
- public SerializationFactory getSerializationFactory() {
- return (SerializationFactory) getEFactoryInstance();
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @generated
- */
- private boolean isCreated = false;
-
- /**
- * Creates the meta-model objects for the package. This method is
- * guarded to have no affect on any invocation but its first.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @generated
- */
- public void createPackageContents() {
- if (this.isCreated) {
- return;
- }
- this.isCreated = true;
-
- // Create data types
- this.extensibleSerializableJavaObjectEDataType = createEDataType(SerializationPackage.EXTENSIBLE_SERIALIZABLE_JAVA_OBJECT);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @generated
- */
- private boolean isInitialized = false;
-
- /**
- * Complete the initialization of the package and its meta-model. This
- * method is guarded to have no affect on any invocation but its first.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @generated
- */
- public void initializePackageContents() {
- if (this.isInitialized) {
- return;
- }
- this.isInitialized = true;
-
- // Initialize package
- setName(SerializationPackage.eNAME);
- setNsPrefix(SerializationPackage.eNS_PREFIX);
- setNsURI(SerializationPackage.eNS_URI);
-
- // Initialize data types
- initEDataType(this.extensibleSerializableJavaObjectEDataType, Object.class, "ExtensibleSerializableJavaObject", EPackageImpl.IS_SERIALIZABLE, !EPackageImpl.IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
-
- // Create resource
- createResource(SerializationPackage.eNS_URI);
- }
-
-} // SerializationPackageImpl
+/** + * Copyright (c) 2011 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - initial API and implementation + */ +package org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.impl; + +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.impl.EPackageImpl; +import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.SerializationFactory; +import org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.SerializationPackage; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Package</b>. + * <!-- end-user-doc --> + * + * @generated + */ +public class SerializationPackageImpl extends EPackageImpl implements SerializationPackage { + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @generated + */ + private EDataType extensibleSerializableJavaObjectEDataType = null; + + /** + * Creates an instance of the model <b>Package</b>, registered with {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + * <p> + * Note: the correct way to create the package is via the static factory method {@link #init init()}, which also performs initialization of the package, or returns the registered package, if one already exists. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.eclipse.papyrus.emf.facet.util.emf.core.serialization.model.serialization.SerializationPackage#eNS_URI + * @see #init() + * @generated + */ + private SerializationPackageImpl() { + super(SerializationPackage.eNS_URI, SerializationFactory.eINSTANCE); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. + * + * <p> + * This method is used to initialize {@link SerializationPackage#eINSTANCE} when that field is accessed. Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. <!-- begin-user-doc --> <!-- end-user-doc + * --> + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static SerializationPackage init() { + if (SerializationPackageImpl.isInited) { + return (SerializationPackage) EPackage.Registry.INSTANCE.getEPackage(SerializationPackage.eNS_URI); + } + + // Obtain or create and register package + SerializationPackageImpl theSerializationPackage = (SerializationPackageImpl) (EPackage.Registry.INSTANCE.get(SerializationPackage.eNS_URI) instanceof SerializationPackageImpl ? EPackage.Registry.INSTANCE.get(SerializationPackage.eNS_URI) + : new SerializationPackageImpl()); + + SerializationPackageImpl.isInited = true; + + // Create package meta-data objects + theSerializationPackage.createPackageContents(); + + // Initialize created meta-data + theSerializationPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theSerializationPackage.freeze(); + + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(SerializationPackage.eNS_URI, theSerializationPackage); + return theSerializationPackage; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @generated + */ + public EDataType getExtensibleSerializableJavaObject() { + return this.extensibleSerializableJavaObjectEDataType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @generated + */ + public SerializationFactory getSerializationFactory() { + return (SerializationFactory) getEFactoryInstance(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @generated + */ + public void createPackageContents() { + if (this.isCreated) { + return; + } + this.isCreated = true; + + // Create data types + this.extensibleSerializableJavaObjectEDataType = createEDataType(SerializationPackage.EXTENSIBLE_SERIALIZABLE_JAVA_OBJECT); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @generated + */ + public void initializePackageContents() { + if (this.isInitialized) { + return; + } + this.isInitialized = true; + + // Initialize package + setName(SerializationPackage.eNAME); + setNsPrefix(SerializationPackage.eNS_PREFIX); + setNsURI(SerializationPackage.eNS_URI); + + // Initialize data types + initEDataType(this.extensibleSerializableJavaObjectEDataType, Object.class, "ExtensibleSerializableJavaObject", EPackageImpl.IS_SERIALIZABLE, !EPackageImpl.IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ + + // Create resource + createResource(SerializationPackage.eNS_URI); + } + +} // SerializationPackageImpl |