From 533d626e28b57981a5714f87ef03d7a1a2ae2f8a Mon Sep 17 00:00:00 2001 From: Laurent Wouters Date: Fri, 4 Apr 2014 16:12:46 +0200 Subject: [clean] Retiring org.eclipse.papyrus.resource.migration Signed-off-by: Laurent Wouters --- .../.classpath | 7 - .../.project | 28 --- .../.settings/org.eclipse.jdt.core.prefs | 8 - .../META-INF/MANIFEST.MF | 18 -- .../about.html | 28 --- .../build.properties | 7 - .../plugin.properties | 15 -- .../plugin.xml | 19 -- .../papyrus/resource/migration/Activator.java | 65 ------ .../migration/controller/GenModelUpdater.java | 227 --------------------- .../exceptions/URINotValidException.java | 32 --- .../popup/actions/UpdateGenModelAction.java | 118 ----------- 12 files changed, 572 deletions(-) delete mode 100644 deprecated/org.eclipse.papyrus.resource.migration/.classpath delete mode 100644 deprecated/org.eclipse.papyrus.resource.migration/.project delete mode 100644 deprecated/org.eclipse.papyrus.resource.migration/.settings/org.eclipse.jdt.core.prefs delete mode 100644 deprecated/org.eclipse.papyrus.resource.migration/META-INF/MANIFEST.MF delete mode 100644 deprecated/org.eclipse.papyrus.resource.migration/about.html delete mode 100644 deprecated/org.eclipse.papyrus.resource.migration/build.properties delete mode 100644 deprecated/org.eclipse.papyrus.resource.migration/plugin.properties delete mode 100644 deprecated/org.eclipse.papyrus.resource.migration/plugin.xml delete mode 100644 deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/Activator.java delete mode 100644 deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/controller/GenModelUpdater.java delete mode 100644 deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/controller/exceptions/URINotValidException.java delete mode 100644 deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/popup/actions/UpdateGenModelAction.java diff --git a/deprecated/org.eclipse.papyrus.resource.migration/.classpath b/deprecated/org.eclipse.papyrus.resource.migration/.classpath deleted file mode 100644 index 2d1a4302f04..00000000000 --- a/deprecated/org.eclipse.papyrus.resource.migration/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/deprecated/org.eclipse.papyrus.resource.migration/.project b/deprecated/org.eclipse.papyrus.resource.migration/.project deleted file mode 100644 index 74665d4cff6..00000000000 --- a/deprecated/org.eclipse.papyrus.resource.migration/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.papyrus.resource.migration - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/deprecated/org.eclipse.papyrus.resource.migration/.settings/org.eclipse.jdt.core.prefs b/deprecated/org.eclipse.papyrus.resource.migration/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7bd4b87357c..00000000000 --- a/deprecated/org.eclipse.papyrus.resource.migration/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Wed Dec 02 09:11:51 CET 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 diff --git a/deprecated/org.eclipse.papyrus.resource.migration/META-INF/MANIFEST.MF b/deprecated/org.eclipse.papyrus.resource.migration/META-INF/MANIFEST.MF deleted file mode 100644 index 4aa5384dfda..00000000000 --- a/deprecated/org.eclipse.papyrus.resource.migration/META-INF/MANIFEST.MF +++ /dev/null @@ -1,18 +0,0 @@ -Manifest-Version: 1.0 -Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime, - org.eclipse.core.resources, - org.eclipse.emf.ecore, - org.eclipse.papyrus.resource;bundle-version="0.9.0", - org.eclipse.emf.codegen.ecore -Bundle-Vendor: %providerName -Bundle-ActivationPolicy: lazy -Bundle-Version: 0.9.0.qualifier -Bundle-Name: %pluginName -Bundle-Localization: plugin -Bundle-ManifestVersion: 2 -Bundle-Activator: org.eclipse.papyrus.resource.migration.Activator -Bundle-SymbolicName: org.eclipse.papyrus.resource.migration;singleton: - =true -Bundle-RequiredExecutionEnvironment: J2SE-1.5 - diff --git a/deprecated/org.eclipse.papyrus.resource.migration/about.html b/deprecated/org.eclipse.papyrus.resource.migration/about.html deleted file mode 100644 index 35b45e096ae..00000000000 --- a/deprecated/org.eclipse.papyrus.resource.migration/about.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - -About - - -

About This Content

- -

September 30, 2009

-

License

- -

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

- -

If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at http://www.eclipse.org.

- - - \ No newline at end of file diff --git a/deprecated/org.eclipse.papyrus.resource.migration/build.properties b/deprecated/org.eclipse.papyrus.resource.migration/build.properties deleted file mode 100644 index 751d7adaec6..00000000000 --- a/deprecated/org.eclipse.papyrus.resource.migration/build.properties +++ /dev/null @@ -1,7 +0,0 @@ -# -#Mon Sep 12 09:30:11 CEST 2011 -bin.includes=META-INF/,.,plugin.xml,about.html,plugin.properties -output..=bin/ -src.includes=META-INF/,.,plugin.xml,about.html,plugin.properties -source..=src/ -bin..=bin/ diff --git a/deprecated/org.eclipse.papyrus.resource.migration/plugin.properties b/deprecated/org.eclipse.papyrus.resource.migration/plugin.properties deleted file mode 100644 index 4fadc0a8236..00000000000 --- a/deprecated/org.eclipse.papyrus.resource.migration/plugin.properties +++ /dev/null @@ -1,15 +0,0 @@ -#################################################################################### -# Copyright (c) 2008 Atos Origin. -# -# -# 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: -# Tristan Faure (Atos Origin) tristan.faure@atosorigin.com - Initial API and implementation -# -################################################################################## -pluginName = Papyrus Resource Migration (Incubation) -providerName=Eclipse Modeling Project diff --git a/deprecated/org.eclipse.papyrus.resource.migration/plugin.xml b/deprecated/org.eclipse.papyrus.resource.migration/plugin.xml deleted file mode 100644 index 765bb6fd926..00000000000 --- a/deprecated/org.eclipse.papyrus.resource.migration/plugin.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - diff --git a/deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/Activator.java b/deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/Activator.java deleted file mode 100644 index 91474a3ff88..00000000000 --- a/deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/Activator.java +++ /dev/null @@ -1,65 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 Atos Origin. - * - * - * 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: - * Tristan Faure (Atos Origin) tristan.faure@atosorigin.com - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.resource.migration; - -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "org.eclipse.papyrus.resource.migration"; - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - -} diff --git a/deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/controller/GenModelUpdater.java b/deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/controller/GenModelUpdater.java deleted file mode 100644 index 410c8c93d55..00000000000 --- a/deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/controller/GenModelUpdater.java +++ /dev/null @@ -1,227 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 Atos Origin. - * - * - * 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: - * Tristan Faure (Atos Origin) tristan.faure@atosorigin.com - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.resource.migration.controller; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; - -import org.eclipse.emf.codegen.ecore.genmodel.GenModel; -import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; -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.resource.ResourcePackage; -import org.eclipse.papyrus.resource.migration.controller.exceptions.URINotValidException; - -/** - * This class makes comaptible a genmodel with Resource meta model - * - * @author tristan.faure@atosorigin.com - * - */ -public class GenModelUpdater { - - /** - * The URI for Resource Genmodel - */ - private static final URI uriForResourceGenModel = URI - .createURI("platform:/plugin/org.eclipse.papyrus.resource/model/resource.genmodel"); - - /** - * The URI for Resource Ecore meta model - */ - private static final URI uriForEclassResourceEObject = URI - .createURI("platform:/plugin/org.eclipse.papyrus.resource/model/resource.ecore#//ResourceEObject"); - - /** - * instance of resource package used to reference usedGenpackage in the original genmodel - */ - private ResourcePackage resourcePackage = ResourcePackage.eINSTANCE; - - /** - * Eclass for resource Eobject - */ - private EClass resourceEObjectEClass = null; - - /** - * current Epackage for the meta model corresponding to the current genmodel - */ - private EPackage currentEPackage = null; - - /** - * Transform the genmodel sotred at the given URI to link it with Resource Meta model - * - * @param uri - * @throws URINotValidException - * @throws IOException - */ - public void transform(URI uri) throws URINotValidException, IOException { - if(uri == null) { - throw new URINotValidException("uri is null"); - } - ResourceSet set = new ResourceSetImpl(); - try { - Resource resource = set.getResource(uri, true); - if(resource != null) { - EObject e = resource.getContents().get(0); - if(e instanceof GenModel) { - GenModel genmodel = (GenModel)e; - Resource toSave = update(genmodel); - if(toSave != null) { - resource.save(Collections.EMPTY_MAP); - toSave.save(Collections.EMPTY_MAP); - } - } else { - throw new URINotValidException("uri " + uri.toString() + "doesn't reference a genmodel"); - } - } - // we have to unload the resource to free the memory - for(Resource r : set.getResources()) { - if(r.isLoaded()) { - try { - r.unload(); - } catch (Exception e) { - // to prevent unload exception - } - } - } - } catch (RuntimeException e) { - throw new URINotValidException("uri " + uri.toString() + "not valid"); - } - } - - /** - * update the genmodel to reference Resource Meta model - * - * @param genmodel - * @return true if the resource has to be saved - */ - private Resource update(GenModel genmodel) { - // does the genmodel already contain the resource ? - Resource result = null; - boolean found = false; - for(GenPackage p : genmodel.getUsedGenPackages()) { - found |= resourcePackage.equals(p.getEcorePackage()); - } - if(!found) { - // we load the Resource GenModel - Resource resourceForResourceGenmodel = genmodel.eResource().getResourceSet().getResource( - uriForResourceGenModel, true); - if(resourceForResourceGenmodel != null) { - EObject root = resourceForResourceGenmodel.getContents().get(0); - if(root instanceof GenModel) { - GenModel model = (GenModel)root; - // Resource Genmodel is a used gen package for the current genmodel - genmodel.getUsedGenPackages().add(model.getGenPackages().get(0)); - // load the eclass resource eobject - Resource resourceResource = genmodel.eResource().getResourceSet().getResource( - uriForEclassResourceEObject.trimFragment(), true); - if(resourceResource != null) { - // we get the ResourceEObject EClass - EObject resourceEObjectEobject = resourceResource.getEObject(uriForEclassResourceEObject - .fragment()); - if(resourceEObjectEobject instanceof EClass) { - resourceEObjectEClass = (EClass)resourceEObjectEobject; - result = addResourceEobjectInheritance(genmodel); - } - } - } - } - } - // if not found we have to save - return result; - } - - /** - * add the inheritance to each EObject - * - * @param genmodel - */ - private Resource addResourceEobjectInheritance(GenModel genmodel) { - // we resolve to have access to all the eobjects - EcoreUtil.resolveAll(genmodel.eResource().getResourceSet()); - Resource result = null; - List packages = genmodel.getGenPackages(); - if(packages.size() > 0) { - GenPackage genPackage = packages.get(0); - currentEPackage = genPackage.getEcorePackage(); - result = currentEPackage.eResource(); - manageEPackage(currentEPackage); - } - return result; - } - - /** - * Recursive method to browse EPackages - * - * @param currentEPackage2 - */ - private void manageEPackage(EPackage currentEPackage2) { - for(EClassifier eclassifier : currentEPackage2.getEClassifiers()) { - if(eclassifier instanceof EClass) { - EClass eClass = (EClass)eclassifier; - manageEClass(eClass); - } - } - for(EPackage ePackage : currentEPackage2.getESubpackages()) { - manageEPackage(ePackage); - } - - } - - /** - * Recursive method to manage hierarchy tree - * - * @param eClass - */ - private void manageEClass(EClass eClass) { - if(eClass != resourceEObjectEClass) { - if(eClass.getESuperTypes().size() == 0) { - if(isACorrectEPackage(eClass.getEPackage())) { - eClass.getESuperTypes().add(resourceEObjectEClass); - } - } else { - boolean toAdd = true; - for(EClass eClass2 : eClass.getESuperTypes()) { - toAdd &= !isACorrectEPackage(eClass2.getEPackage()); - manageEClass(eClass2); - } - if(toAdd) { - eClass.getESuperTypes().add(resourceEObjectEClass); - } - } - } - } - - /** - * determine if the ePackage given in parameter is a children of the current Epackage - * - * @param ePackage - * @return - */ - private boolean isACorrectEPackage(EPackage ePackage) { - EPackage current = ePackage; - while(current != null && current != currentEPackage) { - current = current.getESuperPackage(); - } - return current == currentEPackage; - } -} diff --git a/deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/controller/exceptions/URINotValidException.java b/deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/controller/exceptions/URINotValidException.java deleted file mode 100644 index b94b9a5c2e6..00000000000 --- a/deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/controller/exceptions/URINotValidException.java +++ /dev/null @@ -1,32 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 Atos Origin. - * - * - * 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: - * Tristan Faure (Atos Origin) tristan.faure@atosorigin.com - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.resource.migration.controller.exceptions; - -/** - * This exception is thrown when the uri is not valid - * - * @author tristan.faure@atosorigin.com - * - */ -public class URINotValidException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public URINotValidException(String string) { - super(string); - } -} diff --git a/deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/popup/actions/UpdateGenModelAction.java b/deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/popup/actions/UpdateGenModelAction.java deleted file mode 100644 index 312ad4652bd..00000000000 --- a/deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/popup/actions/UpdateGenModelAction.java +++ /dev/null @@ -1,118 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 Atos Origin. - * - * - * 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: - * Tristan Faure (Atos Origin) tristan.faure@atosorigin.com - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.resource.migration.popup.actions; - -import java.io.IOException; -import java.util.Iterator; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.emf.common.util.URI; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.papyrus.resource.migration.controller.GenModelUpdater; -import org.eclipse.papyrus.resource.migration.controller.exceptions.URINotValidException; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IActionDelegate; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.ISelectionService; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -public class UpdateGenModelAction implements IObjectActionDelegate { - - private Shell shell; - - /** - * Constructor for Action1. - */ - public UpdateGenModelAction() { - super(); - } - - /** - * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) - */ - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - shell = targetPart.getSite().getShell(); - } - - /** - * @see IActionDelegate#run(IAction) - */ - public void run(IAction action) { - if(PlatformUI.getWorkbench() != null) { - IWorkbench workbench = PlatformUI.getWorkbench(); - if(workbench.getActiveWorkbenchWindow() != null) { - IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); - if(window.getSelectionService() != null) { - ISelectionService service = window.getSelectionService(); - ISelection selection = service.getSelection(); - if(selection instanceof IStructuredSelection) { - final IStructuredSelection structuredSelection = (IStructuredSelection)selection; - BusyIndicator.showWhile(shell.getDisplay(), new Runnable() { - - public void run() { - runProcess(structuredSelection); - } - }); - } - } - } - } - } - - /** - * perform the process - * - * @param structuredSelection - */ - private void runProcess(final IStructuredSelection structuredSelection) { - try { - Iterator iterator = structuredSelection.iterator(); - GenModelUpdater updater = new GenModelUpdater(); - while(iterator.hasNext()) { - Object next = iterator.next(); - if(next instanceof IFile) { - IFile ifile = (IFile)next; - updater.transform(URI.createURI(ifile.getLocationURI().toString())); - ifile.getParent().refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor()); - } - } - MessageDialog.openInformation(shell, "Finish", "The genmodel has been updated"); - } catch (URINotValidException e) { - MessageDialog.openError(shell, "Error", e.getMessage()); - e.printStackTrace(); - } catch (IOException e) { - MessageDialog.openError(shell, "Error", "An error occurs during save process"); - e.printStackTrace(); - } catch (CoreException e) { - e.printStackTrace(); - } - } - - /** - * @see IActionDelegate#selectionChanged(IAction, ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - } - -} -- cgit v1.2.3