Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2011-10-25 12:12:34 +0000
committercletavernie2011-10-25 12:12:34 +0000
commit2a7ac0c8c25b0cdb7397c619086efd60df7e94d8 (patch)
tree7d2d1f497f21a31c9ceb37967698016edd34694f /plugins/views/modelexplorer
parent0461ccd2972651807ebb691be5734f2509160da4 (diff)
downloadorg.eclipse.papyrus-2a7ac0c8c25b0cdb7397c619086efd60df7e94d8.tar.gz
org.eclipse.papyrus-2a7ac0c8c25b0cdb7397c619086efd60df7e94d8.tar.xz
org.eclipse.papyrus-2a7ac0c8c25b0cdb7397c619086efd60df7e94d8.zip
Diffstat (limited to 'plugins/views/modelexplorer')
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/.classpath7
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/.project28
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/META-INF/MANIFEST.MF22
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/about.html28
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/build.properties7
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/icons/LoadResource.gifbin0 -> 231 bytes
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/icons/UnloadResource.gifbin0 -> 211 bytes
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/plugin.properties15
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/plugin.xml108
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/src/org/eclipse/papyrus/modelexplorer/resourceloading/Activator.java107
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/src/org/eclipse/papyrus/modelexplorer/resourceloading/handler/LoadResourceHandler.java83
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/src/org/eclipse/papyrus/modelexplorer/resourceloading/handler/UnloadResourceHandler.java117
13 files changed, 530 insertions, 0 deletions
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/.classpath b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/.classpath
@@ -0,0 +1,7 @@
+<?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/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/.project b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/.project
new file mode 100644
index 00000000000..64436edba9f
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.modelexplorer.resourceloading</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/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/.settings/org.eclipse.jdt.core.prefs b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..3223f25b542
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Wed Aug 24 17:43:54 CEST 2011
+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/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/META-INF/MANIFEST.MF b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..5f060ea41fe
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/META-INF/MANIFEST.MF
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-Localization: plugin
+Bundle-SymbolicName: org.eclipse.papyrus.modelexplorer.resourceloading;singleton:=true
+Bundle-Version: 0.9.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.modelexplorer.resourceloading.Activator
+Require-Bundle: org.eclipse.emf.converter;bundle-version="2.5.0",
+ org.eclipse.emf.ecore.editor;bundle-version="2.6.0",
+ org.eclipse.emf.workspace.ui;bundle-version="1.3.0",
+ org.eclipse.papyrus.service.edit;bundle-version="0.8.0",
+ org.eclipse.emf.facet.infra.browser;bundle-version="0.1.0",
+ org.eclipse.emf.facet.infra.browser.custom;bundle-version="0.1.0",
+ org.eclipse.emf.facet.infra.common.core;bundle-version="0.1.0",
+ org.eclipse.emf.facet.infra.facet;bundle-version="0.1.0",
+ org.eclipse.papyrus.modelexplorer;bundle-version="0.8.0",
+ org.eclipse.papyrus.controlmode.history;bundle-version="0.8.0",
+ org.eclipse.papyrus.core.resourceloading
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-Vendor: %providerName
+Export-Package: org.eclipse.papyrus.modelexplorer.resourceloading.handler
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/about.html b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/about.html
new file mode 100644
index 00000000000..dd02e0be168
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/about.html
@@ -0,0 +1,28 @@
+<!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>December 2, 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/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/build.properties b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/build.properties
new file mode 100644
index 00000000000..9fdb11c9431
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/build.properties
@@ -0,0 +1,7 @@
+#
+#Mon Sep 12 09:29:55 CEST 2011
+bin.includes=META-INF/,.,plugin.xml,icons/,plugin.properties,about.html
+output..=bin/
+src.includes=icons/,META-INF/,.,plugin.xml,plugin.properties,about.html
+source..=src/
+bin..=bin/
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/icons/LoadResource.gif b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/icons/LoadResource.gif
new file mode 100644
index 00000000000..f2c989e6579
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/icons/LoadResource.gif
Binary files differ
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/icons/UnloadResource.gif b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/icons/UnloadResource.gif
new file mode 100644
index 00000000000..c1c07a7456b
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/icons/UnloadResource.gif
Binary files differ
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/plugin.properties b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/plugin.properties
new file mode 100644
index 00000000000..07faecd80d1
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/plugin.properties
@@ -0,0 +1,15 @@
+##########################################################################################
+# Copyright (c) 2011 Atos.
+#
+#
+# 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:
+# Vincent Hemery (Atos) vincent.hemery@atos.net - Initial API and implementation
+#
+########################################################################################
+pluginName=Papyrus Resource Loading for Model Explorer (Incubation)
+providerName=Eclipse Modeling Project
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/plugin.xml b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/plugin.xml
new file mode 100644
index 00000000000..25bb0270121
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/plugin.xml
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+<extension point="org.eclipse.ui.menus">
+ <!-- ModelExplorer Contextual menu -->
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.papyrus.modelexplorer.modelexplorer.popup?after=org.eclipse.papyrus.modelexplorer.modelexplorer.popup.paste">
+ <separator
+ name="popup:org.eclipse.papyrus.modelexplorer.modelexplorer.popup.loadSeparator"
+ visible="true">
+ <!--visibleWhen
+ checkEnabled="true">
+ <with
+ variable="selection">
+ <or>
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.core.resourceloading.tester.isAllLoaded"
+ value="true" />
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.core.resourceloading.tester.isAllNotLoaded"
+ value="true" />
+ </or>
+ </with>
+ </visibleWhen-->
+ </separator>
+ <command
+ commandId="org.eclipse.papyrus.modelexplorer.resourceloading.LoadResource"
+ icon="icons/LoadResource.gif"
+ label="Load"
+ style="push"
+ tooltip="Load Resource containing this object">
+ <visibleWhen
+ checkEnabled="true">
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.core.resourceloading.tester.isAllNotLoaded"
+ value="true" />
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.modelexplorer.resourceloading.UnloadResource"
+ icon="icons/UnloadResource.gif"
+ label="Unload"
+ style="push"
+ tooltip="Unload Resource containing this object">
+ <visibleWhen
+ checkEnabled="true">
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.core.resourceloading.tester.isAllLoaded"
+ value="true" />
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+</extension>
+
+<!-- Command declarations (for model explorer toolbar and contextual menu -->
+<extension point="org.eclipse.ui.commands">
+ <!-- Command declaration : Load resource command -->
+ <command id="org.eclipse.papyrus.modelexplorer.resourceloading.LoadResource"
+ name="Load" description="Load Resource containing this object"
+ categoryId="org.eclipse.papyrus.editor.category"
+ defaultHandler="org.eclipse.papyrus.modelexplorer.resourceloading.handler.LoadResourceHandler">
+ </command>
+ <command id="org.eclipse.papyrus.modelexplorer.resourceloading.UnloadResource"
+ name="Unload" description="Unload Resource containing this object"
+ categoryId="org.eclipse.papyrus.editor.category"
+ defaultHandler="org.eclipse.papyrus.modelexplorer.resourceloading.handler.UnloadResourceHandler">
+ </command>
+</extension>
+
+<!-- This handler is activated when deleteInModelExplorer variable is valid.
+ -->
+<extension point="org.eclipse.ui.handlers">
+ <handler commandId="org.eclipse.papyrus.modelexplorer.resourceloading.LoadResource" class="org.eclipse.papyrus.modelexplorer.resourceloading.handler.LoadResourceHandler">
+ <activeWhen>
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.core.resourceloading.tester.isAllNotLoaded"
+ value="true" />
+ </with>
+ </activeWhen>
+ </handler>
+ <handler commandId="org.eclipse.papyrus.modelexplorer.resourceloading.UnloadResource" class="org.eclipse.papyrus.modelexplorer.resourceloading.handler.UnloadResourceHandler">
+ <activeWhen>
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.core.resourceloading.tester.isAllLoaded"
+ value="true" />
+ </with>
+ </activeWhen>
+ </handler>
+</extension>
+
+</plugin>
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/src/org/eclipse/papyrus/modelexplorer/resourceloading/Activator.java b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/src/org/eclipse/papyrus/modelexplorer/resourceloading/Activator.java
new file mode 100644
index 00000000000..6df9d300480
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/src/org/eclipse/papyrus/modelexplorer/resourceloading/Activator.java
@@ -0,0 +1,107 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos.
+ *
+ *
+ * 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:
+ * Vincent Hemery (Atos) vincent.hemery@atos.net - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.modelexplorer.resourceloading;
+
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.edit.EMFEditPlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.papyrus.log.LogHelper;
+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 implements org.eclipse.ui.IStartup {
+
+ /** The plug-in ID */
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.modelexplorer.resourceLoading"; //$NON-NLS-1$
+
+ /** The plug-in shared instance */
+ private static Activator plugin;
+
+ /** The log service */
+ public static LogHelper log;
+
+ /** Default 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;
+ log = new LogHelper(plugin);
+ EMFEditPlugin.getComposedAdapterFactoryDescriptorRegistry();
+
+ }
+
+ /**
+ * get the image descriptor from a string path
+ *
+ * @param pathString
+ * path of the image
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String pathString) {
+
+ IPath path = new Path(pathString);
+ URL uri = FileLocator.find(Activator.plugin.getBundle(), path, null);
+ if(uri == null) {
+ return null;
+ }
+ return ImageDescriptor.createFromURL(uri);
+ }
+
+ /*
+ * (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;
+ }
+
+ /**
+ *
+ * @see org.eclipse.ui.IStartup#earlyStartup()
+ *
+ */
+ public void earlyStartup() {
+
+ }
+
+}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/src/org/eclipse/papyrus/modelexplorer/resourceloading/handler/LoadResourceHandler.java b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/src/org/eclipse/papyrus/modelexplorer/resourceloading/handler/LoadResourceHandler.java
new file mode 100644
index 00000000000..c53835975df
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/src/org/eclipse/papyrus/modelexplorer/resourceloading/handler/LoadResourceHandler.java
@@ -0,0 +1,83 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos.
+ *
+ *
+ * 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:
+ * Vincent Hemery (Atos) vincent.hemery@atos.net - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.modelexplorer.resourceloading.handler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.command.AbstractCommand;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.command.UnexecutableCommand;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.core.resourceloading.util.LoadingUtils;
+import org.eclipse.papyrus.modelexplorer.handler.AbstractCommandHandler;
+import org.eclipse.papyrus.resource.ModelSet;
+
+/**
+ * Handler for the load resource action.
+ * This actions load a resource in the model set, which is not yet loaded (due to resource loading strategy).
+ */
+public class LoadResourceHandler extends AbstractCommandHandler {
+
+
+ /**
+ * Get the command to load resource of selected model object
+ *
+ * @see org.eclipse.papyrus.modelexplorer.handler.AbstractCommandHandler#getCommand()
+ * @return the command
+ */
+ @Override
+ protected Command getCommand() {
+ TransactionalEditingDomain editingDomain = getEditingDomain();
+ List<EObject> selection = getSelectedElements();
+ if(editingDomain != null && editingDomain.getResourceSet() instanceof ModelSet && selection.size() > 0) {
+ final ModelSet set = (ModelSet)editingDomain.getResourceSet();
+ CompoundCommand command = new CompoundCommand();
+ List<URI> handledURI = new ArrayList<URI>();
+ for(EObject sel : selection) {
+ if(sel.eIsProxy()) {
+ InternalEObject internal = (InternalEObject)sel;
+ URI uriProxy = internal.eProxyURI();
+ final URI uriTrim = uriProxy.trimFragment().trimFileExtension();
+ if(!handledURI.contains(uriTrim)) {
+ handledURI.add(uriTrim);
+ Command cmd = new AbstractCommand() {
+
+ public void redo() {
+ LoadingUtils.loadResourcesInModelSet(set, uriTrim);
+ }
+
+ public void execute() {
+ redo();
+ }
+
+ @Override
+ public boolean canExecute() {
+ return true;
+ }
+ };
+ command.append(cmd);
+ }
+ }
+ }
+ return command;
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+
+}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/src/org/eclipse/papyrus/modelexplorer/resourceloading/handler/UnloadResourceHandler.java b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/src/org/eclipse/papyrus/modelexplorer/resourceloading/handler/UnloadResourceHandler.java
new file mode 100644
index 00000000000..b35e0f16e89
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.modelexplorer.resourceloading/src/org/eclipse/papyrus/modelexplorer/resourceloading/handler/UnloadResourceHandler.java
@@ -0,0 +1,117 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos.
+ *
+ *
+ * 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:
+ * Vincent Hemery (Atos) vincent.hemery@atos.net - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.modelexplorer.resourceloading.handler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.command.AbstractCommand;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.command.UnexecutableCommand;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.core.resourceloading.util.LoadingUtils;
+import org.eclipse.papyrus.modelexplorer.handler.AbstractCommandHandler;
+import org.eclipse.papyrus.resource.ModelSet;
+import org.eclipse.papyrus.resource.notation.NotationUtils;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Handler for the load resource action.
+ * This actions load a resource in the model set, which is not yet loaded (due to resource loading strategy).
+ */
+public class UnloadResourceHandler extends AbstractCommandHandler {
+
+
+ /**
+ * @see org.eclipse.papyrus.modelexplorer.handler.AbstractCommandHandler#getCommand()
+ * @return the command
+ */
+ @Override
+ protected Command getCommand() {
+ TransactionalEditingDomain editingDomain = getEditingDomain();
+ List<EObject> selection = getSelectedElements();
+ if(editingDomain != null && editingDomain.getResourceSet() instanceof ModelSet && selection.size() > 0) {
+ final ModelSet set = (ModelSet)editingDomain.getResourceSet();
+ CompoundCommand command = new CompoundCommand();
+ List<URI> handledURI = new ArrayList<URI>();
+ // ensure main URI is never unloaded
+ URI mainURI = NotationUtils.getNotationModel(set).getResourceURI().trimFileExtension();
+ handledURI.add(mainURI);
+ for(EObject sel : selection) {
+ if(!sel.eIsProxy()) {
+ final URI uriTrim = sel.eResource().getURI().trimFileExtension();
+ if(!handledURI.contains(uriTrim)) {
+ handledURI.add(uriTrim);
+ Command cmd = new AbstractCommand() {
+
+ public void redo() {
+ LoadingUtils.unloadResourcesFromModelSet(set, uriTrim);
+ }
+
+ public void execute() {
+ redo();
+ }
+
+ @Override
+ public boolean canExecute() {
+ return true;
+ }
+ };
+ command.append(cmd);
+ }
+ }
+ }
+ return command;
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ /**
+ * Get currently opened editor
+ *
+ * @return editor
+ */
+ protected IEditorPart getEditor() {
+ IEditorPart editor = null;
+ IWorkbenchWindow activeWorkbenchWindow = getActiveWorkbenchWindow();
+ if(activeWorkbenchWindow != null) {
+ IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
+ if(activePage != null) {
+ editor = activePage.getActiveEditor();
+ }
+ }
+ return editor;
+ }
+
+ /**
+ * Get the active workbench window
+ *
+ * @return window
+ */
+ protected IWorkbenchWindow getActiveWorkbenchWindow() {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ if(workbench != null) {
+ return workbench.getActiveWorkbenchWindow();
+ }
+ return null;
+ }
+
+}

Back to the top