diff options
author | vlorenzo | 2011-07-11 11:28:25 +0000 |
---|---|---|
committer | vlorenzo | 2011-07-11 11:28:25 +0000 |
commit | 9a4a399dbd91a85076e3e7ed0cb26b2aa74672b2 (patch) | |
tree | 9ca30da19145e26463acfa79c584bb6e85dbe6d2 /plugins/developer/org.eclipse.papyrus.dev.java.utils | |
parent | d29f2e77ee05162abe5bf4ca8c5efa07f0cc801e (diff) | |
download | org.eclipse.papyrus-9a4a399dbd91a85076e3e7ed0cb26b2aa74672b2.tar.gz org.eclipse.papyrus-9a4a399dbd91a85076e3e7ed0cb26b2aa74672b2.tar.xz org.eclipse.papyrus-9a4a399dbd91a85076e3e7ed0cb26b2aa74672b2.zip |
Move this plugin from /incoming to plugins/developper.
This plugin provides tools to facilitate the Papyrus Developpement.
Currently its main feature is an action called "Empty Package" which allows to empty selected Java package. (useful before a re-generation of diagrams)
Diffstat (limited to 'plugins/developer/org.eclipse.papyrus.dev.java.utils')
11 files changed, 325 insertions, 0 deletions
diff --git a/plugins/developer/org.eclipse.papyrus.dev.java.utils/.classpath b/plugins/developer/org.eclipse.papyrus.dev.java.utils/.classpath new file mode 100644 index 00000000000..2d1a4302f04 --- /dev/null +++ b/plugins/developer/org.eclipse.papyrus.dev.java.utils/.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/developer/org.eclipse.papyrus.dev.java.utils/.project b/plugins/developer/org.eclipse.papyrus.dev.java.utils/.project new file mode 100644 index 00000000000..e679584ea65 --- /dev/null +++ b/plugins/developer/org.eclipse.papyrus.dev.java.utils/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.dev.java.utils</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/developer/org.eclipse.papyrus.dev.java.utils/.settings/org.eclipse.jdt.core.prefs b/plugins/developer/org.eclipse.papyrus.dev.java.utils/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..ff2fb3f467c --- /dev/null +++ b/plugins/developer/org.eclipse.papyrus.dev.java.utils/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Fri Apr 15 09:54:50 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/developer/org.eclipse.papyrus.dev.java.utils/META-INF/MANIFEST.MF b/plugins/developer/org.eclipse.papyrus.dev.java.utils/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..d58ea38b59f --- /dev/null +++ b/plugins/developer/org.eclipse.papyrus.dev.java.utils/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-SymbolicName: org.eclipse.papyrus.dev.java.utils;singleton:=true +Bundle-Version: 0.9.0.qualifier +Bundle-Activator: org.eclipse.papyrus.dev.java.utils.Activator +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.jdt.core +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-Vendor: %providerName +Bundle-Name: %pluginName +Bundle-Localization: plugin diff --git a/plugins/developer/org.eclipse.papyrus.dev.java.utils/about.html b/plugins/developer/org.eclipse.papyrus.dev.java.utils/about.html new file mode 100644 index 00000000000..82d49bf5f81 --- /dev/null +++ b/plugins/developer/org.eclipse.papyrus.dev.java.utils/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>June 5, 2007</p>
+<h3>License</h3>
+
+<p>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 <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" 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 ("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 <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/plugins/developer/org.eclipse.papyrus.dev.java.utils/build.properties b/plugins/developer/org.eclipse.papyrus.dev.java.utils/build.properties new file mode 100644 index 00000000000..8665ac2ffec --- /dev/null +++ b/plugins/developer/org.eclipse.papyrus.dev.java.utils/build.properties @@ -0,0 +1,6 @@ +source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties
diff --git a/plugins/developer/org.eclipse.papyrus.dev.java.utils/icons/16977.empty_pack_obj.png b/plugins/developer/org.eclipse.papyrus.dev.java.utils/icons/16977.empty_pack_obj.png Binary files differnew file mode 100644 index 00000000000..a2d43103f01 --- /dev/null +++ b/plugins/developer/org.eclipse.papyrus.dev.java.utils/icons/16977.empty_pack_obj.png diff --git a/plugins/developer/org.eclipse.papyrus.dev.java.utils/plugin.properties b/plugins/developer/org.eclipse.papyrus.dev.java.utils/plugin.properties new file mode 100644 index 00000000000..f25f7900b40 --- /dev/null +++ b/plugins/developer/org.eclipse.papyrus.dev.java.utils/plugin.properties @@ -0,0 +1,16 @@ +#################################################################################
+# 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:
+# Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - initial API and implementation
+##################################################################################
+#Properties file for org.eclipse.papyrus.dev.java.utils
+providerName = Eclipse Modeling Project
+pluginName = Java Utils for Papyrus Developper
+command.name = Empty Packages Command
+command.label = Empty Packages (No Undo)
+command.mnemonic = E
\ No newline at end of file diff --git a/plugins/developer/org.eclipse.papyrus.dev.java.utils/plugin.xml b/plugins/developer/org.eclipse.papyrus.dev.java.utils/plugin.xml new file mode 100644 index 00000000000..17eae342554 --- /dev/null +++ b/plugins/developer/org.eclipse.papyrus.dev.java.utils/plugin.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ categoryId="org.eclipse.ui.category.project"
+ defaultHandler="org.eclipse.papyrus.dev.java.utils.EmptyPackagesHandler"
+ id="org.eclipse.papyrus.dev.java.utils.EmptyPackagesCommand"
+ name="%command.name">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.ui.popup.any">
+ <command
+ commandId="org.eclipse.papyrus.dev.java.utils.EmptyPackagesCommand"
+ icon="icons/16977.empty_pack_obj.png"
+ label="%command.label"
+ mnemonic="%command.mnemonic"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+
+</plugin>
diff --git a/plugins/developer/org.eclipse.papyrus.dev.java.utils/src/org/eclipse/papyrus/dev/java/utils/Activator.java b/plugins/developer/org.eclipse.papyrus.dev.java.utils/src/org/eclipse/papyrus/dev/java/utils/Activator.java new file mode 100644 index 00000000000..146d7d3a8d6 --- /dev/null +++ b/plugins/developer/org.eclipse.papyrus.dev.java.utils/src/org/eclipse/papyrus/dev/java/utils/Activator.java @@ -0,0 +1,65 @@ +/*****************************************************************************
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.dev.java.utils;
+
+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.eclipse.utils"; //$NON-NLS-1$
+
+ // 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/plugins/developer/org.eclipse.papyrus.dev.java.utils/src/org/eclipse/papyrus/dev/java/utils/EmptyPackagesHandler.java b/plugins/developer/org.eclipse.papyrus.dev.java.utils/src/org/eclipse/papyrus/dev/java/utils/EmptyPackagesHandler.java new file mode 100644 index 00000000000..7cdb5ef4192 --- /dev/null +++ b/plugins/developer/org.eclipse.papyrus.dev.java.utils/src/org/eclipse/papyrus/dev/java/utils/EmptyPackagesHandler.java @@ -0,0 +1,123 @@ +/*****************************************************************************
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.dev.java.utils;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * This action allows to empty the selected packages or the package included in a IPackageFragmentRoot (i.e : a Source Folder)
+ *
+ *
+ *
+ */
+public class EmptyPackagesHandler extends AbstractHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ for(IPackageFragment current : getSelectedElements()) {
+ IJavaElement children[] = null;
+ try {
+ children = current.getChildren();
+ } catch (JavaModelException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ if(children != null) {
+ for(IJavaElement currentElement : children) {
+ if(currentElement instanceof ICompilationUnit) {
+ try {
+ ((ICompilationUnit)currentElement).delete(true, new NullProgressMonitor());
+ } catch (JavaModelException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+ MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(), "Empty Package", null, "All the package are now empty!", MessageDialog.INFORMATION, new String[]{ "OK" }, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ dialog.open();
+ return null;
+ }
+
+ /**
+ * Iterate over current selection and build a list of the {@link IGraphicalEditPart} contained in
+ * the selection.
+ *
+ * @return the currently selected {@link IGraphicalEditPart}
+ */
+ protected List<IPackageFragment> getSelectedElements() {
+ List<IPackageFragment> packages = new ArrayList<IPackageFragment>();
+ ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
+ if(selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection)selection;
+ Iterator<?> it = structuredSelection.iterator();
+ while(it.hasNext()) {
+ Object object = it.next();
+ if(object instanceof IPackageFragment) {
+ packages.add((IPackageFragment)object);
+ } else if(object instanceof IPackageFragmentRoot) {
+ try {
+ IJavaElement[] children = ((IPackageFragmentRoot)object).getChildren();
+ for(IJavaElement current : children) {
+ if(current instanceof IPackageFragment) {
+ packages.add((IPackageFragment)current);
+ }
+ }
+
+ } catch (JavaModelException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ }
+ }
+ }
+ return packages;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ *
+ * @return
+ */
+ @Override
+ public boolean isEnabled() {
+ return getSelectedElements().size() != 0;
+ }
+}
|