Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2012-09-03 10:43:56 -0400
committervlorenzo2012-09-03 10:43:56 -0400
commitf7e892074b1a34a1ce1eb562f50ac1d61711d480 (patch)
treed005d3ae99a5046a39fd6fbf4a5a23677fc8ae92
parent9f81d96165e90a69d1e31c43fa718d690a0d10f9 (diff)
downloadorg.eclipse.papyrus-f7e892074b1a34a1ce1eb562f50ac1d61711d480.tar.gz
org.eclipse.papyrus-f7e892074b1a34a1ce1eb562f50ac1d61711d480.tar.xz
org.eclipse.papyrus-f7e892074b1a34a1ce1eb562f50ac1d61711d480.zip
A save of my work on oep.dev.project.management
-rw-r--r--sandbox/org.eclipse.papyrus.dev.project.management/META-INF/MANIFEST.MF3
-rw-r--r--sandbox/org.eclipse.papyrus.dev.project.management/icons/copyright_icon.pngbin0 -> 281 bytes
-rw-r--r--sandbox/org.eclipse.papyrus.dev.project.management/plugin.xml22
-rw-r--r--sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/handlers/features/SetCopyrightNoticeHandler.java94
-rw-r--r--sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/utils/Utils.java58
5 files changed, 176 insertions, 1 deletions
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
index 26200032ac9..b707d2b2496 100644
--- a/sandbox/org.eclipse.papyrus.dev.project.management/META-INF/MANIFEST.MF
+++ b/sandbox/org.eclipse.papyrus.dev.project.management/META-INF/MANIFEST.MF
@@ -10,6 +10,7 @@ Require-Bundle: org.eclipse.ui,
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"
+ org.eclipse.papyrus.infra.core.log;bundle-version="0.9.0",
+ org.eclipse.pde.ui
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
diff --git a/sandbox/org.eclipse.papyrus.dev.project.management/icons/copyright_icon.png b/sandbox/org.eclipse.papyrus.dev.project.management/icons/copyright_icon.png
new file mode 100644
index 00000000000..df9393d4f01
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.dev.project.management/icons/copyright_icon.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
index 2f16d850b36..f87c3828012 100644
--- a/sandbox/org.eclipse.papyrus.dev.project.management/plugin.xml
+++ b/sandbox/org.eclipse.papyrus.dev.project.management/plugin.xml
@@ -38,6 +38,17 @@
id="org.eclipse.papyrus.dev.project.management.command.feature.add.epl"
name="Add EPL file">
</command>
+ <command
+ defaultHandler="org.eclipse.papyrus.dev.project.management.handlers.features.SetCopyrightNoticeHandler"
+ description="Set Feature Copyright"
+ id="org.eclipse.papyrus.dev.project.management.command.feature.set.copyright"
+ name="Set Feature Copyright">
+ </command>
+ <command
+ defaultHandler="org.eclipse.papyrus.dev.project.management.handlers.features.ExternalizeFeatureStringHandler"
+ id="org.eclipse.papyrus.dev.project.management.command.feature.externalize"
+ name="Externalize String for Feature">
+ </command>
</extension>
<extension
point="org.eclipse.ui.menus">
@@ -68,6 +79,17 @@
label="Change Feature Version (no undo)"
style="push">
</command>
+ <command
+ commandId="org.eclipse.papyrus.dev.project.management.command.feature.set.copyright"
+ icon="icons/copyright_icon.png"
+ label="Set Copyright (doesn&apos;t erase existing value)"
+ style="push">
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.dev.project.management.command.feature.externalize"
+ label="Externalize String"
+ style="push">
+ </command>
</menu>
<menu
icon="icons/plugin_obj.gif"
diff --git a/sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/handlers/features/SetCopyrightNoticeHandler.java b/sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/handlers/features/SetCopyrightNoticeHandler.java
new file mode 100644
index 00000000000..830cd9924b5
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/handlers/features/SetCopyrightNoticeHandler.java
@@ -0,0 +1,94 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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.project.management.handlers.features;
+
+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.resources.IProject;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.dev.project.management.Activator;
+import org.eclipse.papyrus.dev.project.management.dialog.TwoInputDialog;
+import org.eclipse.papyrus.dev.project.management.utils.Utils;
+import org.eclipse.papyrus.eclipse.project.editors.interfaces.IFeatureProjectEditor;
+import org.eclipse.papyrus.eclipse.project.editors.project.FeatureProjectEditor;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ *
+ * set the Copyright and the URL only if it not yet set.
+ *
+ */
+public class SetCopyrightNoticeHandler extends AbstractHandler {
+
+ final static String OPTIONAL_URL = "url";
+
+ final static String TEXT = "text";
+
+ public Object execute(final ExecutionEvent event) throws ExecutionException {
+ Utils.getSelectedOpenProject();
+ final TwoInputDialog dialog = new TwoInputDialog(Display.getDefault().getActiveShell(), "Set Copyright Notice", "Licence url", "text", OPTIONAL_URL, TEXT, null);
+ if(dialog.open() == Window.OK) {
+ final String newVersion = dialog.getValue();
+ final List<IProject> featureProjects = Utils.getOpenedFeatureProject();
+ for(final IProject current : featureProjects) {
+ try {
+ setCopyrightNotice(current, dialog.getValue(), dialog.getValue_2());
+ } catch (final Throwable e) {
+ Activator.log.error(e);
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param featureProject
+ * @param url
+ * @param text
+ * @throws Throwable
+ *
+ * TODO : doesn't erase existing value!
+ * TODO : add a checkbox in the dialog to erase existing value
+ */
+ protected void setCopyrightNotice(final IProject featureProject, final String url, final String text) throws Throwable {
+ final IFeatureProjectEditor editor = new FeatureProjectEditor(featureProject);
+ editor.init();
+ final String copyrirghtText = editor.getCopyrightText();
+ final String copyrightURL = editor.getCopyrightURL();
+ String settedURL = null;
+ String settedText = null;
+ //TODO improve these tests
+ if((copyrightURL == null) || copyrightURL.equals("")) {
+ settedURL = url;
+ } else {
+ settedURL = copyrightURL;
+ }
+
+ if((copyrirghtText == null) || copyrirghtText.equals("")) {
+ settedText = text;
+ }
+ if(settedText.equals(copyrirghtText) && settedURL.equals(copyrightURL)) {
+ //do nothing
+ } else {
+ editor.setCopyright(settedURL, settedText);
+ editor.save();
+ }
+
+ }
+
+}
diff --git a/sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/utils/Utils.java b/sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/utils/Utils.java
index 7fdb01d0b16..4d97dc41a23 100644
--- a/sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/utils/Utils.java
+++ b/sandbox/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/utils/Utils.java
@@ -1,5 +1,23 @@
package org.eclipse.papyrus.dev.project.management.utils;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.dev.project.management.Activator;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.WorkingSet;
+
public class Utils {
@@ -10,4 +28,44 @@ public class Utils {
public static final String FEATURE_NATURE = "org.eclipse.pde.FeatureNature";
public static final String PLUGIN_NATURE = "org.eclipse.pde.PluginNature";
+
+ /**
+ *
+ * @return
+ * the list of opened feature project
+ */
+ public static List<IProject> getOpenedFeatureProject() {
+ final List<IProject> featureProject = new ArrayList<IProject>();
+ final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for(final IProject current : projects) {
+ try {
+ if(current.isOpen() && current.hasNature(FEATURE_NATURE)) {
+ featureProject.add(current);
+ }
+ } catch (final CoreException e) {
+ Activator.log.error(e);
+ }
+ }
+ return featureProject;
+ }
+
+ public static Collection<IProject> getSelectedOpenProject() {
+ final Set<IProject> selectedProject = new HashSet<IProject>();
+ final ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
+ Assert.isTrue(selection instanceof IStructuredSelection);
+ final Iterator<?> iter = ((IStructuredSelection)selection).iterator();
+ while(iter.hasNext()) {
+ final Object current = iter.next();
+ if((current instanceof IProject) && ((IProject)current).isOpen()) {
+ selectedProject.add((IProject)current);
+ } else if(current instanceof WorkingSet) {
+ for(final IAdaptable curr : ((WorkingSet)current).getElements()) {
+ if((curr instanceof IProject) && ((IProject)curr).isOpen()) {
+ selectedProject.add((IProject)curr);
+ }
+ }
+ }
+ }
+ return selectedProject;
+ }
}

Back to the top