Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2014-09-04 05:09:48 -0400
committerCamille Letavernier2014-09-04 05:09:48 -0400
commitb3456fc23464aa86762b2346a5166a60b48b9641 (patch)
tree842ece9399bbb0c4165d3e6bd5d1a2b4c6f23ae6 /plugins/developer/org.eclipse.papyrus.releng.tools
parent1748df91bbfca87ab2fbc90c66e4726e18619cab (diff)
downloadorg.eclipse.papyrus-b3456fc23464aa86762b2346a5166a60b48b9641.tar.gz
org.eclipse.papyrus-b3456fc23464aa86762b2346a5166a60b48b9641.tar.xz
org.eclipse.papyrus-b3456fc23464aa86762b2346a5166a60b48b9641.zip
[Releng - Dev Plug-in] New plug-in to update RMaps/POM dependencies from
B3 Aggregation model
Diffstat (limited to 'plugins/developer/org.eclipse.papyrus.releng.tools')
-rw-r--r--plugins/developer/org.eclipse.papyrus.releng.tools/.classpath7
-rw-r--r--plugins/developer/org.eclipse.papyrus.releng.tools/.project34
-rw-r--r--plugins/developer/org.eclipse.papyrus.releng.tools/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--plugins/developer/org.eclipse.papyrus.releng.tools/META-INF/MANIFEST.MF15
-rw-r--r--plugins/developer/org.eclipse.papyrus.releng.tools/OSGI-INF/l10n/bundle.properties14
-rw-r--r--plugins/developer/org.eclipse.papyrus.releng.tools/README.TXT18
-rw-r--r--plugins/developer/org.eclipse.papyrus.releng.tools/about.html28
-rw-r--r--plugins/developer/org.eclipse.papyrus.releng.tools/build.properties19
-rw-r--r--plugins/developer/org.eclipse.papyrus.releng.tools/plugin.xml74
-rw-r--r--plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/Activator.java45
-rw-r--r--plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/Messages.java31
-rw-r--r--plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/handler/AbstractDependencyHandler.java109
-rw-r--r--plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/handler/UpdateMapHandler.java77
-rw-r--r--plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/handler/UpdatePOMHandler.java76
-rw-r--r--plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/messages.properties17
-rw-r--r--plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/popup/actions/DependencyUpdater.java147
-rw-r--r--plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/popup/actions/MapUpdater.java58
-rw-r--r--plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/popup/actions/PomUpdater.java36
18 files changed, 812 insertions, 0 deletions
diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/.classpath b/plugins/developer/org.eclipse.papyrus.releng.tools/.classpath
new file mode 100644
index 00000000000..8a8f1668cdc
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.releng.tools/.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/JavaSE-1.6"/>
+ <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.releng.tools/.project b/plugins/developer/org.eclipse.papyrus.releng.tools/.project
new file mode 100644
index 00000000000..b85bc70e191
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.releng.tools/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.releng.tools</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>
+ <buildCommand>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/.settings/org.eclipse.jdt.core.prefs b/plugins/developer/org.eclipse.papyrus.releng.tools/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..f287d53cf45
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.releng.tools/.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.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/META-INF/MANIFEST.MF b/plugins/developer/org.eclipse.papyrus.releng.tools/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..e42c882c671
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.releng.tools/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.eclipse.papyrus.releng.tools;singleton:=true
+Bundle-Version: 1.0.1.qualifier
+Bundle-Activator: org.eclipse.papyrus.releng.tools.internal.Activator
+Bundle-Vendor: %Bundle-Vendor
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.emf.ecore;bundle-version="2.6.0",
+ org.eclipse.ui,
+ org.eclipse.core.resources,
+ org.eclipse.b3.aggregator;bundle-version="0.2.0",
+ org.eclipse.b3.aggregator.legacy;bundle-version="0.2.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/OSGI-INF/l10n/bundle.properties b/plugins/developer/org.eclipse.papyrus.releng.tools/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 00000000000..c1cf5900b73
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.releng.tools/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,14 @@
+###############################################################################
+# Copyright (c) 2011 Mia-Software.
+# 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:
+# Nicolas Bros (Mia-Software) - Bug 366567 - [Releng] Tool to update rmaps
+###############################################################################
+#Properties file for org.eclipse.papyrus.releng.tools
+Bundle-Vendor = Eclipse Modeling Project
+Bundle-Name = Papyrus Releng Tools
+action.label = Update RMap From Aggregation Build Model \ No newline at end of file
diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/README.TXT b/plugins/developer/org.eclipse.papyrus.releng.tools/README.TXT
new file mode 100644
index 00000000000..502229bb09f
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.releng.tools/README.TXT
@@ -0,0 +1,18 @@
+This plug-in contains a tool to update a Buckminster rmap (XML file) from a B3 build model.
+The rmap is updated using comments in the XML that reference the model elements from which
+the update sites must be copied.
+These comments must appear before each "rm:uri" element which must be updated automatically, like this:
+ <!-- updateFrom("Eclipse", 0) -->
+ <rm:uri format="http://download.eclipse.org/eclipse/updates/4.2milestones/S-4.2M3-201110281100"/>
+
+The first parameter in updateFrom is the label of a contribution, which you can find in the b3aggrcon files:
+ <aggregator:Contribution ... label="xxx">
+
+The second parameter is the index of the "repositories" element that must be used
+(in case there are several update sites defined on one contribution).
+
+To update the map once these comments are written, right-click on an rmap file
+and choose "Update RMap From Aggregation Build Model".
+Then choose from which b3aggr file (aggregation build model) the map must be updated.
+The b3aggr file must be at the root of a project in your workspace :
+checkout one of the "org.eclipse.<releaseName>.build" projects from CVS "dev.eclipse.org:/cvsroot/callisto". \ No newline at end of file
diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/about.html b/plugins/developer/org.eclipse.papyrus.releng.tools/about.html
new file mode 100644
index 00000000000..3019b95b9cf
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.releng.tools/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 22, 2008</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/developer/org.eclipse.papyrus.releng.tools/build.properties b/plugins/developer/org.eclipse.papyrus.releng.tools/build.properties
new file mode 100644
index 00000000000..7e749beeb33
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.releng.tools/build.properties
@@ -0,0 +1,19 @@
+###############################################################################
+# Copyright (c) 2011 Mia-Software.
+# 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:
+# Nicolas Bros (Mia-Software) - initial API and implementation
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ about.html,\
+ OSGI-INF/,\
+ plugin.xml,\
+ OSGI-INF/l10n/bundle.properties
+src.includes = about.html
diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/plugin.xml b/plugins/developer/org.eclipse.papyrus.releng.tools/plugin.xml
new file mode 100644
index 00000000000..e33d623e45e
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.releng.tools/plugin.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?> <!--
+ Copyright (c) 2011-2014 Mia-Software, 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:
+ Nicolas Bros (Mia-Software) - initial API and implementation
+ Camille Letavernier (CEA LIST) - Reimplement with Eclipse Menu/Handlers
+ -->
+
+<plugin>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.ui.popup.any?after=additions">
+ <command
+ commandId="org.eclipse.papyrus.releng.tools.updateRmap"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <iterate
+ operator="or">
+ <adapt
+ type="org.eclipse.core.resources.IFile">
+ <or>
+ <test
+ property="org.eclipse.core.resources.extension"
+ value="rmap">
+ </test>
+ </or>
+ </adapt>
+ </iterate>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.releng.tools.updatePom"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <iterate
+ operator="or">
+ <adapt
+ type="org.eclipse.core.resources.IFile">
+ <or>
+ <test
+ property="org.eclipse.core.resources.name"
+ value="*pom*.xml">
+ </test>
+ </or>
+ </adapt>
+ </iterate>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ defaultHandler="org.eclipse.papyrus.releng.tools.internal.handler.UpdateMapHandler"
+ id="org.eclipse.papyrus.releng.tools.updateRmap"
+ name="Update RMap from Aggregation Build Model">
+ </command>
+ <command
+ defaultHandler="org.eclipse.papyrus.releng.tools.internal.handler.UpdatePOMHandler"
+ id="org.eclipse.papyrus.releng.tools.updatePom"
+ name="Update POM from Aggregation Build Model">
+ </command>
+ </extension>
+
+</plugin>
diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/Activator.java b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/Activator.java
new file mode 100644
index 00000000000..bf428bee8e7
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/Activator.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software.
+ * 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:
+ * Nicolas Bros (Mia-Software) - Bug 366567 - [Releng] Tool to update rmaps
+ *******************************************************************************/
+package org.eclipse.papyrus.releng.tools.internal;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/** The activator class controls the plug-in life cycle */
+public class Activator extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.releng.tools"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ @Override
+ public void start(final BundleContext context) throws Exception {
+ super.start(context);
+ Activator.plugin = this;
+ }
+
+ @Override
+ public void stop(final BundleContext context) throws Exception {
+ Activator.plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return Activator.plugin;
+ }
+}
diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/Messages.java b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/Messages.java
new file mode 100644
index 00000000000..9f61873c45e
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/Messages.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mia-Software.
+ * 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:
+ * Nicolas Bros (Mia-Software) - Bug 366567 - [Releng] Tool to update rmaps
+ *******************************************************************************/
+package org.eclipse.papyrus.releng.tools.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.releng.tools.internal.messages"; //$NON-NLS-1$
+ public static String UpdateRMapAction_mapWasUpdatedTitle;
+ public static String UpdateRMapAction_chooseBuildModel;
+ public static String UpdateRMapAction_chooseBuildModelLong;
+ public static String UpdateRMapAction_error;
+ public static String UpdateRMapAction_mapWasUpdated;
+ public static String UpdateRMapAction_noBuildModelFound;
+ public static String UpdateRMapAction_noBuildModelFoundLong;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/handler/AbstractDependencyHandler.java b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/handler/AbstractDependencyHandler.java
new file mode 100644
index 00000000000..d1bb4153756
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/handler/AbstractDependencyHandler.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 Mia-Software, 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:
+ * Nicolas Bros (Mia-Software) - Bug 366567 - [Releng] Tool to update rmaps
+ * Camille Letavernier (CEA LIST) - camille.letavernier@cea.fr - Generalize to handle POMs
+ *******************************************************************************/
+package org.eclipse.papyrus.releng.tools.internal.handler;
+
+import java.util.ArrayList;
+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.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.papyrus.releng.tools.internal.Activator;
+import org.eclipse.papyrus.releng.tools.internal.Messages;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+
+public abstract class AbstractDependencyHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ Shell activeShell = HandlerUtil.getActiveShell(event);
+ try {
+ if(selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection)selection;
+ Object selected = structuredSelection.getFirstElement();
+ if(selected instanceof IFile) {
+ IFile file = (IFile)selected;
+ List<IFile> aggregationBuildFiles = findAggregationBuildFiles();
+ IFile aggregationBuildFile = chooseAggregationBuildFile(aggregationBuildFiles, activeShell);
+ if(aggregationBuildFile != null) {
+ updateFile(file, aggregationBuildFile, activeShell);
+ }
+ }
+ }
+ } catch (Exception e) {
+ Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error", e)); //$NON-NLS-1$
+ MessageDialog.openError(activeShell, Messages.UpdateRMapAction_error, e.getLocalizedMessage());
+ }
+
+ return null;
+ }
+
+ protected List<IFile> findAggregationBuildFiles() throws CoreException {
+ List<IFile> aggregationBuildFiles = new ArrayList<IFile>();
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for(IProject project : projects) {
+ if(!project.isOpen()) {
+ continue;
+ }
+ IResource[] members = project.members();
+ for(IResource resource : members) {
+ if(resource.getType() == IResource.FILE && resource.getName().endsWith(".b3aggr")) { //$NON-NLS-1$
+ aggregationBuildFiles.add((IFile)resource);
+ }
+ }
+ }
+ return aggregationBuildFiles;
+ }
+
+ protected IFile chooseAggregationBuildFile(final List<IFile> aggregationBuildFiles, Shell activeShell) {
+ if(aggregationBuildFiles.size() == 0) {
+ MessageDialog.openWarning(activeShell, Messages.UpdateRMapAction_noBuildModelFound, Messages.UpdateRMapAction_noBuildModelFoundLong);
+ return null;
+ }
+ LabelProvider labelProvider = new LabelProvider() {
+
+ @Override
+ public String getText(final Object element) {
+ if(element instanceof IFile) {
+ IFile file = (IFile)element;
+ return file.getProject().getName() + "/" + file.getName(); //$NON-NLS-1$
+ }
+ return super.getText(element);
+ }
+ };
+
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(activeShell, labelProvider);
+ dialog.setTitle(Messages.UpdateRMapAction_chooseBuildModel);
+ dialog.setMessage(Messages.UpdateRMapAction_chooseBuildModelLong);
+ dialog.setElements(aggregationBuildFiles.toArray());
+ dialog.open();
+ return (IFile)dialog.getFirstResult();
+ }
+
+ protected abstract void updateFile(IFile selectedFile, IFile aggregationBuildFile, Shell activeShell) throws CoreException;
+
+}
diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/handler/UpdateMapHandler.java b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/handler/UpdateMapHandler.java
new file mode 100644
index 00000000000..3b3f437f73e
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/handler/UpdateMapHandler.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2014 Mia-Software, 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:
+ * Nicolas Bros (Mia-Software) - Bug 366567 - [Releng] Tool to update rmaps
+ * Camille Letavernier (CEA LIST) - camille.letavernier@cea.fr - Reimplement as a Handler
+ *******************************************************************************/
+package org.eclipse.papyrus.releng.tools.internal.handler;
+
+import org.eclipse.b3.aggregator.Aggregation;
+import org.eclipse.b3.aggregator.AggregatorPackage;
+import org.eclipse.b3.aggregator.Contribution;
+import org.eclipse.b3.aggregator.transformer.TransformationManager;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.releng.tools.internal.Activator;
+import org.eclipse.papyrus.releng.tools.internal.Messages;
+import org.eclipse.papyrus.releng.tools.internal.popup.actions.MapUpdater;
+import org.eclipse.swt.widgets.Shell;
+
+
+/* Reimplemented from org.eclipse.papyrus.releng.tools.internal.popup.actions.UpdateRMapAction */
+public class UpdateMapHandler extends AbstractDependencyHandler {
+
+ @Override
+ protected void updateFile(final IFile mapFile, final IFile aggregationBuildFile, Shell activeShell) throws CoreException {
+
+ // make sure the EPackage is initialized
+ AggregatorPackage.eINSTANCE.getEFactoryInstance();
+ URI uri = URI.createPlatformResourceURI(aggregationBuildFile.getFullPath().toString(), true);
+
+ final ResourceSet resourceSet = new ResourceSetImpl();
+ Resource resource = null;
+ try {
+ // with the latest version of the metamodel
+ resource = resourceSet.getResource(uri, true);
+ resource.load(null);
+ } catch (Exception e) {
+ // with an older version of the metamodel
+ try {
+ TransformationManager transformationManager = new TransformationManager(uri);
+ resource = transformationManager.transformResource(true);
+ } catch (Exception e1) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error loading b3aggr. Make sure you have the latest version of B3 installed. : " + e.getLocalizedMessage(), e1)); //$NON-NLS-1$
+ }
+ }
+
+ if(resource.getContents().size() == 0) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "The b3aggr resource is empty")); //$NON-NLS-1$
+ }
+
+ EObject root = resource.getContents().get(0);
+ if(root instanceof Aggregation) {
+ Aggregation aggregation = (Aggregation)root;
+ EList<Contribution> allContributions = aggregation.getAllContributions(true);
+ MapUpdater mapUpdater = new MapUpdater(mapFile, allContributions);
+ mapUpdater.updateDocument();
+ }
+
+ MessageDialog.openInformation(activeShell, Messages.UpdateRMapAction_mapWasUpdatedTitle, NLS.bind(Messages.UpdateRMapAction_mapWasUpdated, mapFile.getFullPath().toString(), aggregationBuildFile.getFullPath().toString()));
+ }
+
+}
diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/handler/UpdatePOMHandler.java b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/handler/UpdatePOMHandler.java
new file mode 100644
index 00000000000..1906482eb52
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/handler/UpdatePOMHandler.java
@@ -0,0 +1,76 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.releng.tools.internal.handler;
+
+import org.eclipse.b3.aggregator.Aggregation;
+import org.eclipse.b3.aggregator.AggregatorPackage;
+import org.eclipse.b3.aggregator.Contribution;
+import org.eclipse.b3.aggregator.transformer.TransformationManager;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.releng.tools.internal.Activator;
+import org.eclipse.papyrus.releng.tools.internal.Messages;
+import org.eclipse.papyrus.releng.tools.internal.popup.actions.PomUpdater;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class UpdatePOMHandler extends AbstractDependencyHandler {
+
+ @Override
+ protected void updateFile(IFile pomFile, IFile aggregationBuildFile, Shell activeShell) throws CoreException {
+
+ // make sure the EPackage is initialized
+ AggregatorPackage.eINSTANCE.getEFactoryInstance();
+ URI uri = URI.createPlatformResourceURI(aggregationBuildFile.getFullPath().toString(), true);
+
+ final ResourceSet resourceSet = new ResourceSetImpl();
+ Resource resource = null;
+ try {
+ // with the latest version of the metamodel
+ resource = resourceSet.getResource(uri, true);
+ resource.load(null);
+ } catch (Exception e) {
+ // with an older version of the metamodel
+ try {
+ TransformationManager transformationManager = new TransformationManager(uri);
+ resource = transformationManager.transformResource(true);
+ } catch (Exception e1) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error loading b3aggr. Make sure you have the latest version of B3 installed. : " + e.getLocalizedMessage(), e1)); //$NON-NLS-1$
+ }
+ }
+
+ if(resource.getContents().size() == 0) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "The b3aggr resource is empty")); //$NON-NLS-1$
+ }
+
+ EObject root = resource.getContents().get(0);
+ if(root instanceof Aggregation) {
+ Aggregation aggregation = (Aggregation)root;
+ EList<Contribution> allContributions = aggregation.getAllContributions(true);
+ PomUpdater pomUpdater = new PomUpdater(pomFile, allContributions);
+ pomUpdater.updateDocument();
+ }
+
+ MessageDialog.openInformation(activeShell, Messages.UpdateRMapAction_mapWasUpdatedTitle, NLS.bind(Messages.UpdateRMapAction_mapWasUpdated, pomFile.getFullPath().toString(), aggregationBuildFile.getFullPath().toString()));
+ }
+
+}
diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/messages.properties b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/messages.properties
new file mode 100644
index 00000000000..c6ddaf9a805
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/messages.properties
@@ -0,0 +1,17 @@
+###############################################################################
+# Copyright (c) 2011 Mia-Software.
+# 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:
+# Nicolas Bros (Mia-Software) - Bug 366567 - [Releng] Tool to update rmaps
+###############################################################################
+UpdateRMapAction_mapWasUpdatedTitle=Papyrus Releng Tools
+UpdateRMapAction_chooseBuildModel=Choose build model
+UpdateRMapAction_chooseBuildModelLong=Select the build model with which to update the map:
+UpdateRMapAction_error=Error
+UpdateRMapAction_mapWasUpdated=The dependencies in {0}\nwere updated from {1}.
+UpdateRMapAction_noBuildModelFound=No build model found
+UpdateRMapAction_noBuildModelFoundLong=No build model was found in your workspace.\nPlease checkout a build project from git://git.eclipse.org/gitroot/simrel/org.eclipse.simrel.build.git
diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/popup/actions/DependencyUpdater.java b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/popup/actions/DependencyUpdater.java
new file mode 100644
index 00000000000..8eb83b6da09
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/popup/actions/DependencyUpdater.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2011 - 2014 Mia-Software, 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:
+ * Nicolas Bros (Mia-Software) - Bug 366567 - [Releng] Tool to update rmaps
+ * Camille Letavernier (CEA LIST) - Generalize to support POMs
+ *******************************************************************************/
+package org.eclipse.papyrus.releng.tools.internal.popup.actions;
+
+import java.io.File;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
+
+import org.eclipse.b3.aggregator.Contribution;
+import org.eclipse.b3.aggregator.MappedRepository;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.papyrus.releng.tools.internal.Activator;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+
+public abstract class DependencyUpdater {
+
+ protected final IFile fMapFile;
+
+ protected final EList<Contribution> contributions;
+
+ public DependencyUpdater(final IFile mapFile, final EList<Contribution> contributions) {
+ this.fMapFile = mapFile;
+ this.contributions = contributions;
+ }
+
+ protected static final String PREFIX = "http://download.eclipse.org/"; //$NON-NLS-1$
+
+ public void updateDocument() throws CoreException {
+ try {
+ File mapFile = this.fMapFile.getLocation().toFile();
+
+ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+ Document doc = docBuilder.parse(mapFile);
+ doc.normalize();
+ Element documentElement = doc.getDocumentElement();
+
+ XPath xpath = XPathFactory.newInstance().newXPath();
+ NodeList uris = (NodeList)xpath.evaluate(getXpath(), documentElement, XPathConstants.NODESET);
+
+ for(int i = 0; i < uris.getLength(); i++) {
+ Node uri = uris.item(i);
+ Comment precedingComment = getPrecedingComment(uri);
+ if(precedingComment != null) {
+ String comment = precedingComment.getTextContent();
+ Pattern pattern = Pattern.compile("updateFrom\\s*\\(\\s*\"(.*?)\"\\s*,\\s*(\\d+)\\s*\\)"); //$NON-NLS-1$
+ Matcher matcher = pattern.matcher(comment);
+ if(matcher.find()) {
+ String contributionName = matcher.group(1);
+ int repositoryIndex = Integer.parseInt(matcher.group(2));
+ updateWithContribution(uri, contributionName, repositoryIndex);
+ } else if(comment.contains("updateFrom")) { //$NON-NLS-1$
+ throw new Exception("Wrong syntax for 'updateFrom' : should be updateFrom(\"<contributionName>\",<index>)"); //$NON-NLS-1$
+ }
+ }
+ }
+
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+
+ StreamResult result = new StreamResult(mapFile);
+ DOMSource source = new DOMSource(doc);
+ transformer.transform(source, result);
+
+ this.fMapFile.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
+
+ } catch (Exception e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error updating map: " + e.getLocalizedMessage(), e)); //$NON-NLS-1$
+ }
+ }
+
+ protected void updateWithContribution(final Node uri, final String contributionName, final int repositoryIndex) {
+ Contribution contribution = findContribution(contributionName);
+ if(contribution == null) {
+ throw new RuntimeException("'updateFrom' failed: cannot find contribution with label \"" + contributionName + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ EList<MappedRepository> repositories = contribution.getRepositories();
+ if(repositoryIndex >= repositories.size()) {
+ throw new RuntimeException("wrong index in updateFrom(\"" + contributionName + "\"" + repositoryIndex //$NON-NLS-1$ //$NON-NLS-2$
+ + ") : there are " + repositories.size() + " contributions"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ String location = repositories.get(repositoryIndex).getLocation();
+
+ updateUri(uri, location);
+ }
+
+ protected abstract void updateUri(Node uri, String location);
+
+ protected Contribution findContribution(final String contributionName) {
+ Contribution matchingContribution = null;
+ for(Contribution contribution : this.contributions) {
+ if(contributionName.equalsIgnoreCase(contribution.getLabel())) {
+ matchingContribution = contribution;
+ }
+ }
+ return matchingContribution;
+ }
+
+ protected Comment getPrecedingComment(final Node node) {
+ Comment comment = null;
+ Node previous = node.getPreviousSibling();
+ while(previous != null) {
+ if(previous.getNodeType() == Node.COMMENT_NODE) {
+ comment = (Comment)previous;
+ break;
+ } else if(previous.getNodeType() != Node.TEXT_NODE) {
+ break;
+ }
+ previous = previous.getPreviousSibling();
+ }
+ return comment;
+ }
+
+ protected abstract String getXpath();
+
+}
diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/popup/actions/MapUpdater.java b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/popup/actions/MapUpdater.java
new file mode 100644
index 00000000000..f43b3f2bee2
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/popup/actions/MapUpdater.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2011 - 2014 Mia-Software, 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:
+ * Nicolas Bros (Mia-Software) - Bug 366567 - [Releng] Tool to update rmaps
+ * Camille Letavernier (CEA LIST) - Generalize to support POMs
+ *******************************************************************************/
+package org.eclipse.papyrus.releng.tools.internal.popup.actions;
+
+import org.eclipse.b3.aggregator.Contribution;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.util.EList;
+import org.w3c.dom.Node;
+
+/**
+ * Updates a Buckminster rmap (XML file) from a B3 build model. The rmap is updated using
+ * comments in the XML that reference the model elements from which the update sites must be copied.
+ * <p>
+ * These comments must appear before each "rm:uri" element which must be updated automatically, like this:
+ *
+ * <pre>
+ * &lt;!-- updateFrom("Eclipse", 0) --&gt;
+ * &lt;rm:uri format="http://download.eclipse.org/eclipse/updates/4.2milestones/S-4.2M3-201110281100"/&gt;
+ * </pre>
+ *
+ * The first parameter in updateFrom is the label of a contribution, which you can find in the b3aggrcon files:
+ *
+ * <pre>
+ * &lt;aggregator:Contribution ... label="xxx"&gt;
+ * </pre>
+ *
+ * The second parameter is the index of the "repositories" element that must be used (in case there are several update sites defined on one
+ * contribution).
+ */
+public class MapUpdater extends DependencyUpdater {
+
+ public MapUpdater(final IFile mapFile, final EList<Contribution> contributions) {
+ super(mapFile, contributions);
+ }
+
+ @Override
+ protected String getXpath() {
+ return "/rmap/searchPath/provider[@readerType='p2']/uri";
+ }
+
+ @Override
+ protected void updateUri(Node uri, String location) {
+ if(location.startsWith(PREFIX)) {
+ location = "{0}/" + location.substring(PREFIX.length()); //$NON-NLS-1$
+ }
+ uri.getAttributes().getNamedItem("format").setTextContent(location); //$NON-NLS-1$
+ }
+
+}
diff --git a/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/popup/actions/PomUpdater.java b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/popup/actions/PomUpdater.java
new file mode 100644
index 00000000000..0b3fc7d0105
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.releng.tools/src/org/eclipse/papyrus/releng/tools/internal/popup/actions/PomUpdater.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.releng.tools.internal.popup.actions;
+
+import org.eclipse.b3.aggregator.Contribution;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.util.EList;
+import org.w3c.dom.Node;
+
+
+public class PomUpdater extends DependencyUpdater {
+
+ public PomUpdater(final IFile mapFile, final EList<Contribution> contributions) {
+ super(mapFile, contributions);
+ }
+
+ @Override
+ protected String getXpath() {
+ return "/project/repositories/repository/url";
+ }
+
+ @Override
+ protected void updateUri(Node uri, String location) {
+ uri.setTextContent(location);
+ }
+
+}

Back to the top