Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Noyrit2017-04-05 08:31:05 -0400
committerGerrit Code Review @ Eclipse.org2017-04-05 10:23:18 -0400
commit9fb71ec895a345ac6d56b8c8a29e4f302ece268d (patch)
tree33b09fc82ac881b90484d396dce96679dead08ad /plugins/developer
parent8b0a4951fec7b5587e39d43d046b55a472ea2309 (diff)
downloadorg.eclipse.papyrus-9fb71ec895a345ac6d56b8c8a29e4f302ece268d.tar.gz
org.eclipse.papyrus-9fb71ec895a345ac6d56b8c8a29e4f302ece268d.tar.xz
org.eclipse.papyrus-9fb71ec895a345ac6d56b8c8a29e4f302ece268d.zip
Bug 514766 - Implement a command in project management developer tools
to set selected bundles to singletons Change-Id: Ia2456046a3faa81a46463de744ad40744a76b7ec
Diffstat (limited to 'plugins/developer')
-rw-r--r--plugins/developer/org.eclipse.papyrus.dev.project.management/plugin.xml18
-rw-r--r--plugins/developer/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/handlers/plugins/SingletonBundleHandler.java22
-rw-r--r--plugins/developer/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/internal/operations/SingletonBundle.java74
3 files changed, 114 insertions, 0 deletions
diff --git a/plugins/developer/org.eclipse.papyrus.dev.project.management/plugin.xml b/plugins/developer/org.eclipse.papyrus.dev.project.management/plugin.xml
index 9c23d1c7c68..ecb870b08d5 100644
--- a/plugins/developer/org.eclipse.papyrus.dev.project.management/plugin.xml
+++ b/plugins/developer/org.eclipse.papyrus.dev.project.management/plugin.xml
@@ -39,6 +39,12 @@
name="Optimize Bundle Dependencies">
</command>
<command
+ defaultHandler="org.eclipse.papyrus.dev.project.management.handlers.plugins.SingletonBundleHandler"
+ description="Set bundles to be singleton"
+ id="org.eclipse.papyrus.dev.project.management.command.singletonbundle"
+ name="Set bundles to be singleton">
+ </command>
+ <command
defaultHandler="org.eclipse.papyrus.dev.project.management.handlers.SyncManifestAndPOMVersions"
description="Ensure that POM versions match their plug-in/feature manifest"
id="org.eclipse.papyrus.dev.project.management.command.syncPOMVersions"
@@ -136,6 +142,18 @@
</iterate>
</visibleWhen>
</command>
+ <command
+ commandId="org.eclipse.papyrus.dev.project.management.command.singletonbundle"
+ icon="icons/plugin_mf_obj.gif">
+ <visibleWhen
+ checkEnabled="false">
+ <iterate>
+ <reference
+ definitionId="org.eclipse.papyrus.dev.project.management.isPluginProjectOrManifest">
+ </reference>
+ </iterate>
+ </visibleWhen>
+ </command>
</menuContribution>
<menuContribution
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
diff --git a/plugins/developer/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/handlers/plugins/SingletonBundleHandler.java b/plugins/developer/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/handlers/plugins/SingletonBundleHandler.java
new file mode 100644
index 00000000000..296cd30c5dd
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/handlers/plugins/SingletonBundleHandler.java
@@ -0,0 +1,22 @@
+
+package org.eclipse.papyrus.dev.project.management.handlers.plugins;
+
+import java.util.Map;
+
+import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.papyrus.dev.project.management.internal.operations.SingletonBundle;
+import org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor;
+
+
+public class SingletonBundleHandler extends AbstractManifestUpdateHandler {
+
+ public SingletonBundleHandler() {
+ super();
+ }
+
+ @Override
+ protected IUndoableOperation createUpdateOperation(Map<? extends IFile, ? extends IManifestEditor> manifests) {
+ return new SingletonBundle(manifests);
+ }
+}
diff --git a/plugins/developer/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/internal/operations/SingletonBundle.java b/plugins/developer/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/internal/operations/SingletonBundle.java
new file mode 100644
index 00000000000..2d18781a002
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.dev.project.management/src/org/eclipse/papyrus/dev/project/management/internal/operations/SingletonBundle.java
@@ -0,0 +1,74 @@
+/*****************************************************************************
+ * Copyright (c) 2016 Christian W. Damus and others.
+ *
+ * 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:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.dev.project.management.internal.operations;
+
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.papyrus.dev.project.management.Activator;
+import org.eclipse.papyrus.dev.project.management.internal.operations.DependencyAnalysisContext.BundleAnalysis;
+import org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor;
+import org.eclipse.papyrus.infra.tools.util.Iterables2;
+
+/**
+ * Undoable "set singleton" operation
+ */
+public class SingletonBundle extends AbstractManifestUpdateOperation {
+
+ public SingletonBundle(Map<? extends IFile, ? extends IManifestEditor> manifests) {
+ super("Optimize Bundle Dependencies", manifests);
+ }
+
+ @Override
+ protected IStatus doExecute(IProgressMonitor monitor, Map<? extends IFile, ? extends IManifestEditor> manifests) throws ExecutionException {
+ SubMonitor sub = SubMonitor.convert(monitor, "Analyzing ...", manifests.size() + 1);
+
+ sub.split(1).beginTask("Initializing", IProgressMonitor.UNKNOWN);
+
+ DependencyAnalysisContext analysisContext = new DependencyAnalysisContext(manifests.keySet());
+
+ // This map is sorted from root to leaves of the dependency tree
+ List<BundleAnalysis> bundles = Iterables2.topoSort(
+ analysisContext.getAnalysisRoots(),
+ BundleAnalysis::partialCompare);
+
+ for (BundleAnalysis bundle : bundles) {
+ IManifestEditor editor = manifests.get(bundle.getManifest());
+
+ SubMonitor step = sub.split(1);
+
+ if (step.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+
+ if (editor != null) {
+ editor.init();
+
+ editor.setSingleton(true);
+ editor.save();
+ } else {
+ Activator.log.warn("Null editor: " + bundle.getBundleID());
+ }
+ }
+
+ return Status.OK_STATUS;
+ }
+}

Back to the top