Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2012-06-04 09:06:57 +0000
committervlorenzo2012-06-04 09:06:57 +0000
commit5cc39abd7152c63da60ad7e9329296dc498b4be0 (patch)
treefc1f18814b79ef8311b1d1a7ac1ccd5344708910 /sandbox
parent288997da4a34e72d4ddd35b3c7dd4e020e95432c (diff)
downloadorg.eclipse.papyrus-5cc39abd7152c63da60ad7e9329296dc498b4be0.tar.gz
org.eclipse.papyrus-5cc39abd7152c63da60ad7e9329296dc498b4be0.tar.xz
org.eclipse.papyrus-5cc39abd7152c63da60ad7e9329296dc498b4be0.zip
Share the project org.eclipse.papyrus.dev.project.management.
this plugin provides methods to manipulate easily the papyrus project. Currently, it provides only an handler to change the version number.
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/org.eclipse.papyrus.dev.project.management/.classpath7
-rw-r--r--sandbox/org.eclipse.papyrus.dev.project.management/.project28
-rw-r--r--sandbox/org.eclipse.papyrus.dev.project.management/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--sandbox/org.eclipse.papyrus.dev.project.management/META-INF/MANIFEST.MF15
-rw-r--r--sandbox/org.eclipse.papyrus.dev.project.management/OSGI-INF/l10n/bundle.properties7
-rw-r--r--sandbox/org.eclipse.papyrus.dev.project.management/build.properties7
-rw-r--r--sandbox/org.eclipse.papyrus.dev.project.management/icons/papyrus.pngbin0 -> 602 bytes
-rw-r--r--sandbox/org.eclipse.papyrus.dev.project.management/plugin.xml30
-rw-r--r--sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/Activator.java57
-rw-r--r--sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/dialog/InputDialogWithCheckBox.java93
-rw-r--r--sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/handlers/ChangeVersionNumberHandler.java147
11 files changed, 398 insertions, 0 deletions
diff --git a/sandbox/org.eclipse.papyrus.dev.project.management/.classpath b/sandbox/org.eclipse.papyrus.dev.project.management/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.dev.project.management/.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/sandbox/org.eclipse.papyrus.dev.project.management/.project b/sandbox/org.eclipse.papyrus.dev.project.management/.project
new file mode 100644
index 00000000000..87953a6014f
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.dev.project.management/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.dev.project.management</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/sandbox/org.eclipse.papyrus.dev.project.management/.settings/org.eclipse.jdt.core.prefs b/sandbox/org.eclipse.papyrus.dev.project.management/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..44217f8c068
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.dev.project.management/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+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/sandbox/org.eclipse.papyrus.dev.project.management/META-INF/MANIFEST.MF b/sandbox/org.eclipse.papyrus.dev.project.management/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..26200032ac9
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.dev.project.management/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.eclipse.papyrus.dev.project.management;singleton:=true
+Bundle-Version: 0.9.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.dev.project.management.Activator
+Bundle-Vendor: %Bundle-Vendor
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.commands,
+ org.eclipse.core.resources;bundle-version="3.8.0",
+ org.eclipse.papyrus.eclipse.project.editors;bundle-version="0.9.0",
+ org.eclipse.papyrus.infra.core.log;bundle-version="0.9.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
diff --git a/sandbox/org.eclipse.papyrus.dev.project.management/OSGI-INF/l10n/bundle.properties b/sandbox/org.eclipse.papyrus.dev.project.management/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 00000000000..e35f78420bf
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.dev.project.management/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,7 @@
+#Properties file for org.eclipse.papyrus.dev.project.managment
+Bundle-Vendor = Eclispe Modeling Project
+Bundle-Name = Papyrus Project Management (Incubation)
+command.description = This plugin allow to change easily the version number
+command.name = Change Version Number
+menu.label = Papyrus Managment
+command.label = Change version number \ No newline at end of file
diff --git a/sandbox/org.eclipse.papyrus.dev.project.management/build.properties b/sandbox/org.eclipse.papyrus.dev.project.management/build.properties
new file mode 100644
index 00000000000..418bf938f20
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.dev.project.management/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ OSGI-INF/,\
+ icons/
diff --git a/sandbox/org.eclipse.papyrus.dev.project.management/icons/papyrus.png b/sandbox/org.eclipse.papyrus.dev.project.management/icons/papyrus.png
new file mode 100644
index 00000000000..0f74e27b483
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.dev.project.management/icons/papyrus.png
Binary files differ
diff --git a/sandbox/org.eclipse.papyrus.dev.project.management/plugin.xml b/sandbox/org.eclipse.papyrus.dev.project.management/plugin.xml
new file mode 100644
index 00000000000..7b8abe264c2
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.dev.project.management/plugin.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ defaultHandler="org.eclipse.papyrus.dev.project.management.handlers.ChangeVersionNumberHandler"
+ description="%command.description"
+ id="org.eclipse.papyrus.dev.project.management.command.update.version"
+ name="%command.name">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="menu:org.eclipse.ui.main.menu?after=edit">
+ <menu
+ icon="icons/papyrus.png"
+ label="%menu.label">
+ <command
+ commandId="org.eclipse.papyrus.dev.project.management.command.update.version"
+ label="%command.label"
+ style="push">
+ </command>
+ </menu>
+ </menuContribution>
+ </extension>
+
+</plugin>
diff --git a/sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/Activator.java b/sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/Activator.java
new file mode 100644
index 00000000000..f091b3783ac
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/Activator.java
@@ -0,0 +1,57 @@
+package org.eclipse.papyrus.dev.project.management;
+
+import org.eclipse.papyrus.infra.core.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 {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclispe.papyrus.dev.project.managment"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * the log helper for this plugin
+ */
+ public static LogHelper log;
+
+ /**
+ * 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);
+ log = new LogHelper(this);
+ 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/sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/dialog/InputDialogWithCheckBox.java b/sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/dialog/InputDialogWithCheckBox.java
new file mode 100644
index 00000000000..b19ebf7628e
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/dialog/InputDialogWithCheckBox.java
@@ -0,0 +1,93 @@
+package org.eclipse.papyrus.dev.project.management.dialog;
+
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ *
+ * This input dialog provides a field to edit and a checkbox
+ *
+ */
+//TODO move this class in an upper project
+public class InputDialogWithCheckBox extends InputDialog {
+
+ /**
+ * the checkbox
+ */
+ private Button checkbox;
+
+ /**
+ * the message for the checkbox
+ */
+ final private String checkboxMessage;
+
+ /**
+ * the initial state of the checkbox
+ */
+ final private boolean checkboxStatus;
+
+ /**
+ * the state of the checkbox when the dialog is closed
+ */
+ private boolean finalState;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parentShell
+ * @param dialogTitle
+ * @param dialogMessage
+ * @param initialValue
+ * @param checkboxMessage
+ * @param checkboxStatus
+ * @param validator
+ */
+ public InputDialogWithCheckBox(Shell parentShell, String dialogTitle, String dialogMessage, String initialValue, final String checkboxMessage, final boolean checkboxStatus, final IInputValidator validator) {
+ super(parentShell, dialogTitle, dialogMessage, initialValue, validator);
+ this.checkboxMessage = checkboxMessage;
+ this.checkboxStatus = checkboxStatus;
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite)
+ *
+ * @param parent
+ * @return
+ */
+ @Override
+ protected Control createContents(Composite parent) {
+ Control ctrl = super.createContents(parent);
+ checkbox = new Button((Composite)((Composite)ctrl).getChildren()[0], SWT.CHECK);
+ checkbox.setText(checkboxMessage);
+ checkbox.setSelection(checkboxStatus);
+ return ctrl;
+ }
+
+
+ /**
+ *
+ * @return
+ * <code>true</code> if the checkbox is checked
+ */
+ public boolean isChecked() {
+ return this.finalState;
+ }
+
+ /**
+ * save the state of the checkbox
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ *
+ */
+ @Override
+ protected void okPressed() {
+ finalState = this.checkbox.getSelection();
+ super.okPressed();
+ }
+}
diff --git a/sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/handlers/ChangeVersionNumberHandler.java b/sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/handlers/ChangeVersionNumberHandler.java
new file mode 100644
index 00000000000..18850494d96
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/handlers/ChangeVersionNumberHandler.java
@@ -0,0 +1,147 @@
+package org.eclipse.papyrus.dev.project.management.handlers;
+
+import java.io.IOException;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.dev.project.management.Activator;
+import org.eclipse.papyrus.dev.project.management.dialog.InputDialogWithCheckBox;
+import org.eclipse.papyrus.eclipse.project.editors.file.ManifestEditor;
+import org.eclipse.papyrus.eclipse.project.editors.interfaces.IFeatureProjectEditor;
+import org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor;
+import org.eclipse.papyrus.eclipse.project.editors.project.FeatureProjectEditor;
+import org.eclipse.swt.widgets.Display;
+import org.xml.sax.SAXException;
+
+public class ChangeVersionNumberHandler extends AbstractHandler {
+
+ private static final String TITLE = "Enter the new version number for Papyrus plugin.";
+
+ private static final String MESSAGE = "Enter the new version number. This action works for : \n - plugin\n - fragment";
+
+ private static final String INITIAL_VALUE = "0.0.0.qualifier";
+
+ private static final String CHECKBOX_MESSAGE = "Only projects beginning with 'org.eclipse.papyrus.*'";
+
+ private static final String WARNING_DIALOG_TITLE = "Change Version Name Report";
+
+ private static final String WARNING_DIALOG_MESSAGE = "The following project were NOT managed : ";
+
+ private static final String WARNING_DIALOG_MESSAGE2 = "Done.";
+
+ private static final String PAPYRUS_NAME = "org.eclipse.papyrus";
+
+ private static final String FEATURE_NATURE = "org.eclipse.pde.FeatureNature";
+
+ private static final String PLUGIN_NATURE = "org.eclipse.pde.PluginNature";
+
+ //TODO : the same thing for the feature
+ //TODO : tests the projects name
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ IInputValidator validator = new IInputValidator() {
+
+ public String isValid(String newText) {
+ boolean match = newText.matches("[0-9]+\\.[0-9]+\\.[0-9]+\\.qualifier");
+ if(!match) {
+ return NLS.bind("The version number should be : something like this : {0}.", INITIAL_VALUE);
+ }
+ return null;
+ }
+ };
+
+
+ InputDialogWithCheckBox dialog = new InputDialogWithCheckBox(Display.getCurrent().getActiveShell(), TITLE, MESSAGE, INITIAL_VALUE, CHECKBOX_MESSAGE, true, validator);
+ if(dialog.open() == Window.OK) {
+ String notManagedProjectNames = "";
+ final String newVersion = dialog.getValue();
+ final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for(IProject current : projects) {
+ final String name = current.getName();
+ if(dialog.isChecked()) {
+ if(name.startsWith(PAPYRUS_NAME)) {//we test the project name
+ setVersionNumber(current, newVersion, notManagedProjectNames);
+ } else {
+ notManagedProjectNames += NLS.bind("- {0} \n", current.getName());
+ }
+ } else {
+ setVersionNumber(current, newVersion, notManagedProjectNames);
+ }
+ }
+ if(notManagedProjectNames.equals("")) {
+ MessageDialog informationDialog = new MessageDialog(Display.getCurrent().getActiveShell(), WARNING_DIALOG_TITLE, null, WARNING_DIALOG_MESSAGE2, MessageDialog.INFORMATION, new String[]{ "OK" }, 0);
+ informationDialog.open();
+ } else {
+ MessageDialog informationDialog = new MessageDialog(Display.getCurrent().getActiveShell(), WARNING_DIALOG_TITLE, null, WARNING_DIALOG_MESSAGE + "\n" + notManagedProjectNames, MessageDialog.INFORMATION, new String[]{ "OK" }, 0);
+ informationDialog.open();
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param project
+ * the project to manage
+ * @param newVersion
+ * the new version for the project
+ * @param notManagedProjectNames
+ * a String used to build the message with the not managed projects
+ */
+ private void setVersionNumber(final IProject project, final String newVersion, String notManagedProjectNames) {
+ if(project.isOpen()) {
+ try {
+ boolean pluginnature = project.hasNature(PLUGIN_NATURE);
+ if(pluginnature) {
+ try {
+ IManifestEditor editor = new ManifestEditor(project);
+ editor.init();
+ editor.setBundleVersion(newVersion);
+ editor.save();
+ } catch (IOException e) {
+ Activator.log.error(e);
+ notManagedProjectNames += NLS.bind("- {0} \n", project.getName());
+ } catch (Throwable e) {
+ Activator.log.error(e);
+ notManagedProjectNames += NLS.bind("- {0} \n", project.getName());
+ }
+
+ } else if(project.hasNature(FEATURE_NATURE)) {//for features
+ try {
+ IFeatureProjectEditor editor = new FeatureProjectEditor(project);
+ editor.init();
+ editor.setVersion(newVersion);
+ editor.save();
+ } catch (ParserConfigurationException e) {
+ Activator.log.error(e);
+ notManagedProjectNames += NLS.bind("- {0} \n", project.getName());
+ } catch (SAXException e) {
+ Activator.log.error(e);
+ notManagedProjectNames += NLS.bind("- {0} \n", project.getName());
+ } catch (IOException e) {
+ Activator.log.error(e);
+ notManagedProjectNames += NLS.bind("- {0} \n", project.getName());
+ } catch (Throwable e) {
+ Activator.log.error(e);
+ notManagedProjectNames += NLS.bind("- {0} \n", project.getName());
+ }
+
+ }
+ } catch (CoreException e) {
+ Activator.log.error(e);
+ }
+ } else {
+ notManagedProjectNames += NLS.bind("- {0} \n", project.getName());
+ }
+ }
+}

Back to the top