summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Wouters2014-04-04 10:12:46 (EDT)
committerLaurent Wouters2014-04-04 10:12:46 (EDT)
commit533d626e28b57981a5714f87ef03d7a1a2ae2f8a (patch)
tree4ef6b90689177c15a8d202ba7e61976cbe2c8560
parent2c24d306413a02046b77da924656456de6e0ed5d (diff)
downloadorg.eclipse.papyrus-533d626e28b57981a5714f87ef03d7a1a2ae2f8a.zip
org.eclipse.papyrus-533d626e28b57981a5714f87ef03d7a1a2ae2f8a.tar.gz
org.eclipse.papyrus-533d626e28b57981a5714f87ef03d7a1a2ae2f8a.tar.bz2
[clean] Retiring org.eclipse.papyrus.resource.migrationlast/org.eclipse.papyrus.resource.migration
Signed-off-by: Laurent Wouters <laurent.wouters@cea.fr>
-rw-r--r--deprecated/org.eclipse.papyrus.resource.migration/.classpath7
-rw-r--r--deprecated/org.eclipse.papyrus.resource.migration/.project28
-rw-r--r--deprecated/org.eclipse.papyrus.resource.migration/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--deprecated/org.eclipse.papyrus.resource.migration/META-INF/MANIFEST.MF18
-rw-r--r--deprecated/org.eclipse.papyrus.resource.migration/about.html28
-rw-r--r--deprecated/org.eclipse.papyrus.resource.migration/build.properties7
-rw-r--r--deprecated/org.eclipse.papyrus.resource.migration/plugin.properties15
-rw-r--r--deprecated/org.eclipse.papyrus.resource.migration/plugin.xml19
-rw-r--r--deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/Activator.java65
-rw-r--r--deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/controller/GenModelUpdater.java227
-rw-r--r--deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/controller/exceptions/URINotValidException.java32
-rw-r--r--deprecated/org.eclipse.papyrus.resource.migration/src/org/eclipse/papyrus/resource/migration/popup/actions/UpdateGenModelAction.java118
12 files changed, 0 insertions, 572 deletions
diff --git a/deprecated/org.eclipse.papyrus.resource.migration/.classpath b/deprecated/org.eclipse.papyrus.resource.migration/.classpath
deleted file mode 100644
index 2d1a430..0000000
--- a/deprecated/org.eclipse.papyrus.resource.migration/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/deprecated/org.eclipse.papyrus.resource.migration/.project b/deprecated/org.eclipse.papyrus.resource.migration/.project
deleted file mode 100644
index 74665d4..0000000
--- a/deprecated/org.eclipse.papyrus.resource.migration/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.papyrus.resource.migration</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
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 7bd4b87..0000000
--- 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 4aa5384..0000000
--- 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 35b45e0..0000000
--- a/deprecated/org.eclipse.papyrus.resource.migration/about.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>September 30, 2009</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party (&quot;Redistributor&quot;) 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 <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
-
-</body>
-</html> \ 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 751d7ad..0000000
--- 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 4fadc0a..0000000
--- 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 765bb6f..0000000
--- a/deprecated/org.eclipse.papyrus.resource.migration/plugin.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <extension
- point="org.eclipse.ui.popupMenus">
- <objectContribution
- id="org.eclipse.papyrus.resource.migration.contribution1"
- nameFilter="*.genmodel"
- objectClass="org.eclipse.core.resources.IFile">
- <action
- class="org.eclipse.papyrus.resource.migration.popup.actions.UpdateGenModelAction"
- enablesFor="+"
- id="org.eclipse.papyrus.resource.migration.newAction"
- label="configure genmodel with Papyrus profile approach">
- </action>
- </objectContribution>
- </extension>
-
-</plugin>
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 91474a3..0000000
--- 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 410c8c9..0000000
--- 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<GenPackage> 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 b94b9a5..0000000
--- 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 312ad46..0000000
--- 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) {
- }
-
-}