Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-09-27 11:47:17 +0000
committercletavernie2012-09-27 11:47:17 +0000
commit551c56199724c15f6fbec79304532821b01d767f (patch)
tree0272d5f2eb4e6fd1eb8a0493af31acf7e495bd52 /extraplugins/uml/org.eclipse.papyrus.uml.export
parentf959b932dfb5d5e86e1496d72b84b964ccd11d66 (diff)
downloadorg.eclipse.papyrus-551c56199724c15f6fbec79304532821b01d767f.tar.gz
org.eclipse.papyrus-551c56199724c15f6fbec79304532821b01d767f.tar.xz
org.eclipse.papyrus-551c56199724c15f6fbec79304532821b01d767f.zip
370817: [Profile - Packaging] When exporting a Model, we should also package the local profiles
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370817 Initial contribution
Diffstat (limited to 'extraplugins/uml/org.eclipse.papyrus.uml.export')
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/.classpath7
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/.project28
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/META-INF/MANIFEST.MF29
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/about.html28
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/build.properties9
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/icons/export_wiz_16x16-papyrusColor.gifbin0 -> 561 bytes
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/icons/import_wiz_16x16-papyrusColor.gifbin0 -> 541 bytes
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/plugin.properties5
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/plugin.xml153
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/Activator.java91
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/dialog/ExportProfilesIconsDialog.java121
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/dialog/ExportProfilesParametersDialog.java260
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/dialog/Messages.java46
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/dialog/ProfilesToExportSelectionDialog.java215
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/handlers/EditProfileApplicationAction.java323
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/handlers/ExportAppliedProfileHandler.java68
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/handlers/ExportProfilesCommand.java538
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/messages/Messages.java70
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/messages/messages.properties24
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/AreThereAppliedProfilesFromWS.java89
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/BuildProperties.java184
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ChangeProfileApplicationTester.java38
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ExportProfilesUserParameters.java135
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ImportedLibrary.java147
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/InstalledProfileURI.java84
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/PluginExportUtil.java535
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ProfileUtil.java89
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ProfilesLabelProvider.java51
-rw-r--r--extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/WSFileUtil.java182
29 files changed, 3549 insertions, 0 deletions
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/.classpath b/extraplugins/uml/org.eclipse.papyrus.uml.export/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/.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/extraplugins/uml/org.eclipse.papyrus.uml.export/.project b/extraplugins/uml/org.eclipse.papyrus.uml.export/.project
new file mode 100644
index 00000000000..d3966dc4461
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.uml.export</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/extraplugins/uml/org.eclipse.papyrus.uml.export/META-INF/MANIFEST.MF b/extraplugins/uml/org.eclipse.papyrus.uml.export/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..08fce810907
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/META-INF/MANIFEST.MF
@@ -0,0 +1,29 @@
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.papyrus.views.modelexplorer;bundle-version="0.9.0",
+ org.eclipse.uml2.uml;bundle-version="3.2.0",
+ org.eclipse.uml2.common.edit,
+ org.eclipse.papyrus.uml.extensionpoints;bundle-version="0.9.0",
+ org.eclipse.core.expressions,
+ org.eclipse.pde.ui;bundle-version="3.7.0",
+ org.eclipse.papyrus.infra.emf;bundle-version="0.9.0",
+ org.eclipse.gmf.runtime.emf.commands.core;bundle-version="1.4.0",
+ org.eclipse.papyrus.infra.widgets,
+ org.eclipse.core.filebuffers,
+ org.eclipse.gmf.runtime.common.ui,
+ org.eclipse.papyrus.eclipse.project.editors,
+ org.eclipse.papyrus.editor,
+ org.eclipse.pde.build,
+ com.ibm.icu,
+ org.eclipse.ui.ide;bundle-version="3.8.0",
+ org.eclipse.papyrus.infra.core;bundle-version="0.9.0",
+ org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="0.9.0"
+Bundle-Vendor: %Plugin-Vendor
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 0.9.0.qualifier
+Bundle-Name: %Plugin-Name
+Bundle-Localization: plugin
+Bundle-ManifestVersion: 2
+Bundle-Activator: org.eclipse.papyrus.uml.export.Activator
+Bundle-SymbolicName: org.eclipse.papyrus.uml.export;singleton:=true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/about.html b/extraplugins/uml/org.eclipse.papyrus.uml.export/about.html
new file mode 100644
index 00000000000..209103075a7
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/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>November 14, 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/extraplugins/uml/org.eclipse.papyrus.uml.export/build.properties b/extraplugins/uml/org.eclipse.papyrus.uml.export/build.properties
new file mode 100644
index 00000000000..b4a0106d4db
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/build.properties
@@ -0,0 +1,9 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ about.html,\
+ plugin.properties,\
+ icons/
+src.includes = about.html
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/icons/export_wiz_16x16-papyrusColor.gif b/extraplugins/uml/org.eclipse.papyrus.uml.export/icons/export_wiz_16x16-papyrusColor.gif
new file mode 100644
index 00000000000..be0e5397a35
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/icons/export_wiz_16x16-papyrusColor.gif
Binary files differ
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/icons/import_wiz_16x16-papyrusColor.gif b/extraplugins/uml/org.eclipse.papyrus.uml.export/icons/import_wiz_16x16-papyrusColor.gif
new file mode 100644
index 00000000000..c7be463bcd2
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/icons/import_wiz_16x16-papyrusColor.gif
Binary files differ
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/plugin.properties b/extraplugins/uml/org.eclipse.papyrus.uml.export/plugin.properties
new file mode 100644
index 00000000000..75e8a90d227
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/plugin.properties
@@ -0,0 +1,5 @@
+#Properties file for org.eclipse.papyrus.import
+providerName = Eclipse Modeling Project
+pluginName = Papyrus Export Profiles plugin (Incubation)
+Plugin-Vendor = CEA LIST
+Plugin-Name = org.eclipse.papyrus.uml.export \ No newline at end of file
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/plugin.xml b/extraplugins/uml/org.eclipse.papyrus.uml.export/plugin.xml
new file mode 100644
index 00000000000..48c77878fb1
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/plugin.xml
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup?before=org.eclipse.papyrus.views.modelexplorer.popupmenu.createchild">
+ <menu
+ icon="icons/export_wiz_16x16-papyrusColor.gif"
+ id="org.eclipse.papyrus.uml.export.menu"
+ label="&amp;Export"
+ tooltip="Papyrus Export Profile Menu">
+ <command
+ commandId="org.eclipse.papyrus.export.applied.profile"
+ icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Profile.gif"
+ label="Export &amp;Applied Profiles from Workspace"
+ style="push">
+ </command>
+ </menu>
+ </menuContribution>
+ <!--menuContribution
+ allPopups="true"
+ locationURI="popup:org.eclipse.ui.popup.any?after=additions">
+ <menu
+ icon="platform:/plugin/org.eclipse.papyrus.infra.widgets/icons/PapyrusLogo16x16.gif"
+ id="org.eclipse.papyrus.uml.export.refactorModel"
+ label="Refactor Model">
+ <command
+ commandId="org.eclipse.papyrus.uml.export.refactorModel.changeProfileAplication"
+ icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Profile.gif"
+ id="org.eclipse.papyrus.uml.export.refactorModel.changeProfileAplication"
+ label="ChangeProfileApplication"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <and>
+ <count value="1"/>
+ <adapt
+ type="org.eclipse.core.resources.IFile">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.ChangeProfileApplication.ChangeProfileApplication">
+ </test>
+ </adapt>
+ </and>
+
+ </visibleWhen>
+ </command>
+ </menu>
+ </menuContribution-->
+
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ categoryId="org.eclipse.papyrus.editor.category"
+ description="Export Applied Profile"
+ id="org.eclipse.papyrus.export.applied.profile"
+ name="Export Applied Profile">
+ </command>
+ <!--command
+ description="Change Profile Application"
+ id="org.eclipse.papyrus.uml.export.refactorModel.changeProfileAplication"
+ name="Change Profile Application">
+ </command-->
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.papyrus.uml.export.handlers.ExportAppliedProfileHandler"
+ commandId="org.eclipse.papyrus.export.applied.profile">
+ <activeWhen>
+ <and>
+
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.AreThereAppliedProfiles.AreThereAppliedProfiles"
+ value="true">
+ </test>
+ </with>
+ </and>
+ </activeWhen>
+
+ </handler>
+ <!--handler
+ class="org.eclipse.papyrus.uml.export.handlers.EditProfileApplicationAction"
+ commandId="org.eclipse.papyrus.uml.export.refactorModel.changeProfileAplication">
+ </handler-->
+
+ </extension>
+
+
+ <extension point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ adaptable="true"
+ objectClass="org.eclipse.core.resources.IFile"
+ nameFilter="*.uml"
+ id="org.eclipse.papyrus.uml.export.popupMenus.contribution.IFile">
+
+ <menu
+ icon="platform:/plugin/org.eclipse.papyrus.infra.widgets/icons/PapyrusLogo16x16.gif"
+ id="org.eclipse.papyrus.uml.export.menu"
+ label="Refactor Model"
+ path="additionsAcceleo">
+ <groupMarker name="refactor model"/>
+ </menu>
+ <action
+ class="org.eclipse.papyrus.uml.export.handlers.EditProfileApplicationAction"
+ enablesFor="+"
+ icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Profile.gif"
+ id="org.eclipse.papyrus.uml.export.popupMenus.EditProfileApplicationAction"
+ label="Edit Profile Application"
+ menubarPath="org.eclipse.papyrus.uml.export.menu/edit model">
+ <!--enablement>
+
+ <and>
+ <count value="1"/>
+ <adapt
+ type="org.eclipse.core.resources.IFile">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.uml.export.changeProfileApplicationTester.ChangeProfileApplication">
+ </test>
+ </adapt>
+ </and>
+
+
+ </enablement-->
+ </action>
+
+ </objectContribution>
+ </extension>
+<extension
+ point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.papyrus.uml.export.util.AreThereAppliedProfilesFromWS"
+ id="org.eclipse.papyrus.AreThereAppliedProfiles"
+ namespace="org.eclipse.papyrus.AreThereAppliedProfiles"
+ properties="AreThereAppliedProfiles"
+ type="org.eclipse.jface.viewers.ISelection">
+ </propertyTester>
+ <propertyTester
+ class="org.eclipse.papyrus.uml.export.util.ChangeProfileApplicationTester"
+ id="org.eclipse.papyrus.ChangeProfileApplication"
+ namespace="org.eclipse.papyrus.uml.export"
+ properties="ChangeProfileApplication"
+ type="org.eclipse.core.resources.IFile">
+ </propertyTester>
+ </extension>
+</plugin>
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/Activator.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/Activator.java
new file mode 100644
index 00000000000..e119ac45ba9
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/Activator.java
@@ -0,0 +1,91 @@
+/*****************************************************************************
+ * 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:
+ * Saadia DHOUIB (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.export;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The activator class controls the plug-in life cycle.
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ /** The Constant PLUGIN_ID. */
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.uml.export"; //$NON-NLS-1$
+
+ // The shared instance
+ /** The plugin. */
+ private static Activator plugin;
+
+ /**
+ * The constructor.
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ /**
+ * Start.
+ *
+ * @param context
+ * the context
+ * @throws Exception
+ * the exception
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+
+ @Override
+ 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)
+ */
+ /**
+ * Stop.
+ *
+ * @param context
+ * the context
+ * @throws Exception
+ * the exception
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+
+ @Override
+ 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/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/dialog/ExportProfilesIconsDialog.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/dialog/ExportProfilesIconsDialog.java
new file mode 100644
index 00000000000..f0d1427d7af
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/dialog/ExportProfilesIconsDialog.java
@@ -0,0 +1,121 @@
+/*****************************************************************************
+ * 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:
+ * Saadia DHOUIB (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.export.dialog;
+
+
+
+import org.eclipse.jface.dialogs.TrayDialog;
+import org.eclipse.papyrus.infra.widgets.editors.StringFileSelector;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.uml2.uml.Profile;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ExportProfilesIconsDialog.
+ */
+public class ExportProfilesIconsDialog extends TrayDialog {
+
+ /** The profiles. */
+ private Object[] profiles;
+
+ /** The profiles icons. */
+ private String[] profilesIcons = new String[10];
+
+
+
+
+ /** The table icon editor. */
+ private StringFileSelector[] profileIconEditors = new StringFileSelector[10];
+
+ /**
+ * Instantiates a new export profiles icons dialog.
+ *
+ * @param shell the shell
+ * @param profiles the profiles
+ */
+ public ExportProfilesIconsDialog(Shell shell, Object[] profiles) {
+ super(shell);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ this.profiles = profiles;
+
+ }
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#create()
+ *
+ */
+
+ @Override
+ public void create() {
+ // TODO Auto-generated method stub
+ super.create();
+ this.createEditors();
+ }
+
+ /**
+ * Creates the editors.
+ */
+ protected void createEditors() {
+ GridData data = new GridData();
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 2;
+
+ Composite parent = (Composite)getDialogArea();
+ for(int i = 0; i < this.profiles.length; i++) {
+ this.profileIconEditors[i] = new StringFileSelector(parent, SWT.BORDER);
+ this.profileIconEditors[i].setLayoutData(data);
+ this.profileIconEditors[i].setLabel("Icon for " + ((Profile)this.profiles[i]).getName());
+ this.profileIconEditors[i].setToolTipText("Enter the profile icon");
+ }
+
+ // Configure the shell
+ getShell().setSize(800, 250);
+ getShell().setText("Choose icons for the profiles to export");
+ getShell().layout();
+
+ }
+
+ /**
+ * Gets the profiles icons.
+ *
+ * @return the profiles icons
+ */
+ public String[] getProfilesIcons() {
+ return profilesIcons;
+ }
+
+ /**
+ * Ok pressed.
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+
+ @Override
+ protected void okPressed() {
+
+ loop: for(int i = 0; i < this.profileIconEditors.length; i++) {
+ if(this.profileIconEditors[i] != null)
+ this.profilesIcons[i] = (String)this.profileIconEditors[i].getValue();
+ else
+ break loop;
+ }
+
+ super.okPressed();
+ }
+
+}
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/dialog/ExportProfilesParametersDialog.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/dialog/ExportProfilesParametersDialog.java
new file mode 100644
index 00000000000..8f8218f5318
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/dialog/ExportProfilesParametersDialog.java
@@ -0,0 +1,260 @@
+/*****************************************************************************
+ * 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:
+ * Saadia DHOUIB (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.export.dialog;
+
+import org.eclipse.jface.dialogs.TrayDialog;
+import org.eclipse.papyrus.infra.widgets.editors.StringEditor;
+import org.eclipse.papyrus.infra.widgets.editors.StringFileSelector;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.uml2.uml.Profile;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ExportProfilesParametersDialog.
+ */
+public class ExportProfilesParametersDialog extends TrayDialog {
+
+ /** The plugin name. */
+ private String pluginName;
+
+ /** The plugin provider. */
+ private String pluginProvider;
+
+ /** The plugin version. */
+ private String pluginVersion;
+
+ /** The plugin exec environment. */
+ private String pluginExecEnvironment;
+
+ /** The plugin name editor. */
+ private StringEditor pluginNameEditor;
+
+ /** The plugin provider editor. */
+ private StringEditor pluginProviderEditor;
+
+ /** The plugin version editor. */
+ private StringEditor pluginVersionEditor;
+
+ /** The plugin exec environment editor. */
+ private StringEditor pluginExecEnvironmentEditor;
+
+ private Object[] profiles;
+
+ private String[] profilesIcons = new String[10];
+
+ private StringFileSelector[] profileIconEditors = new StringFileSelector[10];
+
+ /**
+ * Instantiates a new export profiles parameters dialog.
+ *
+ * @param shell
+ * the shell
+ * @param pluginName
+ * the plugin name
+ * @param pluginProvider
+ * the plugin provider
+ * @param pluginVersion
+ * the plugin version
+ * @param execEnvironment
+ * the exec environment
+ */
+ public ExportProfilesParametersDialog(Shell shell, String pluginName, String pluginProvider, String pluginVersion, String execEnvironment, Object[] profiles) {
+ super(shell);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ this.setPluginName(pluginName == null ? "" : pluginName); //$NON-NLS-1$
+ this.setPluginProvider(pluginProvider == null ? "" : pluginProvider); //$NON-NLS-1$
+ this.setPluginVersion(pluginVersion == null ? "" : pluginVersion); //$NON-NLS-1$
+ this.setPluginExecEnvironment(execEnvironment == null ? "" : execEnvironment); //$NON-NLS-1$
+ this.profiles = profiles;
+
+ }
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#create()
+ *
+ */
+
+ @Override
+ public void create() {
+ // TODO Auto-generated method stub
+ super.create();
+ this.createEditors();
+ }
+
+ /**
+ * Creates the editors.
+ */
+ protected void createEditors() {
+
+
+ GridData data = new GridData();
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 2;
+
+
+ Composite parent = (Composite)getDialogArea();
+
+
+ this.pluginNameEditor = new StringEditor(parent, SWT.NONE, Messages.ExportProfilesParametersDialog_0);
+ this.pluginNameEditor.setValue(getPluginName());
+ this.pluginNameEditor.setLayoutData(data);
+ this.pluginNameEditor.setToolTipText(Messages.ExportProfilesParametersDialog_1);
+
+
+ this.pluginProviderEditor = new StringEditor(parent, SWT.BORDER, Messages.ExportProfilesParametersDialog_2);
+ this.pluginProviderEditor.setValue(getPluginProvider());
+ this.pluginProviderEditor.setLayoutData(data);
+ this.pluginProviderEditor.setToolTipText(Messages.ExportProfilesParametersDialog_7);
+
+ this.pluginVersionEditor = new StringEditor(parent, SWT.BORDER, Messages.ExportProfilesParametersDialog_8);
+ this.pluginVersionEditor.setValue(getPluginVersion());
+ this.pluginVersionEditor.setLayoutData(data);
+ this.pluginVersionEditor.setToolTipText(Messages.ExportProfilesParametersDialog_9);
+
+
+ this.pluginExecEnvironmentEditor = new StringEditor(parent, SWT.BORDER, Messages.ExportProfilesParametersDialog_10);
+ this.pluginExecEnvironmentEditor.setValue(getPluginExecEnvironment());
+ this.pluginExecEnvironmentEditor.setLayoutData(data);
+ this.pluginExecEnvironmentEditor.setToolTipText(Messages.ExportProfilesParametersDialog_11);
+
+ for(int i = 0; i < this.profiles.length; i++) {
+ this.profileIconEditors[i] = new StringFileSelector(parent, SWT.BORDER);
+ this.profileIconEditors[i].setLayoutData(data);
+ this.profileIconEditors[i].setLabel("Icon for " + ((Profile)this.profiles[i]).getName());
+ this.profileIconEditors[i].setToolTipText("Enter the profile icon");
+ }
+
+
+ //Configure the shell
+ getShell().setSize(800, 350);
+
+ getShell().setText(Messages.ExportProfilesParametersDialog_12);
+
+
+ getShell().layout();
+
+
+ }
+
+ /**
+ * Ok pressed.
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+
+ @Override
+ protected void okPressed() {
+
+ loop: for(int i = 0; i < this.profileIconEditors.length; i++) {
+ if(this.profileIconEditors[i] != null) {
+ this.profilesIcons[i] = (String)this.profileIconEditors[i].getValue();
+ } else {
+ break loop;
+ }
+ }
+ this.pluginExecEnvironment = (String)this.pluginExecEnvironmentEditor.getValue();
+ this.pluginName = (String)this.pluginNameEditor.getValue();
+ this.pluginProvider = (String)this.pluginProviderEditor.getValue();
+ this.pluginVersion = (String)this.pluginVersionEditor.getValue();
+
+
+ super.okPressed();
+ }
+
+ /**
+ * Gets the plugin name.
+ *
+ * @return the plugin name
+ */
+ public String getPluginName() {
+ return pluginName;
+ }
+
+ /**
+ * Sets the plugin name.
+ *
+ * @param pluginName
+ * the new plugin name
+ */
+ private void setPluginName(String pluginName) {
+ this.pluginName = pluginName;
+ }
+
+ /**
+ * Gets the plugin provider.
+ *
+ * @return the plugin provider
+ */
+ public String getPluginProvider() {
+ return pluginProvider;
+ }
+
+ /**
+ * Sets the plugin provider.
+ *
+ * @param pluginProvider
+ * the new plugin provider
+ */
+ private void setPluginProvider(String pluginProvider) {
+ this.pluginProvider = pluginProvider;
+ }
+
+ /**
+ * Gets the plugin version.
+ *
+ * @return the plugin version
+ */
+ public String getPluginVersion() {
+ return pluginVersion;
+ }
+
+ /**
+ * Sets the plugin version.
+ *
+ * @param pluginVersion
+ * the new plugin version
+ */
+ private void setPluginVersion(String pluginVersion) {
+ this.pluginVersion = pluginVersion;
+ }
+
+ /**
+ * Gets the plugin exec environment.
+ *
+ * @return the plugin exec environment
+ */
+ public String getPluginExecEnvironment() {
+ return pluginExecEnvironment;
+ }
+
+ /**
+ * Sets the plugin exec environment.
+ *
+ * @param execEnvironment
+ * the new plugin exec environment
+ */
+ private void setPluginExecEnvironment(String execEnvironment) {
+ this.pluginExecEnvironment = execEnvironment;
+ }
+
+
+ public String[] getProfilesIcons() {
+ return profilesIcons;
+ }
+
+}
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/dialog/Messages.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/dialog/Messages.java
new file mode 100644
index 00000000000..44137df73df
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/dialog/Messages.java
@@ -0,0 +1,46 @@
+/*****************************************************************************
+ * 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:
+ * Saadia DHOUIB (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.export.dialog;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.uml.export.messages.messages"; //$NON-NLS-1$
+
+ public static String ExportProfilesParametersDialog_0;
+
+ public static String ExportProfilesParametersDialog_1;
+
+ public static String ExportProfilesParametersDialog_10;
+
+ public static String ExportProfilesParametersDialog_11;
+
+ public static String ExportProfilesParametersDialog_12;
+
+ public static String ExportProfilesParametersDialog_2;
+
+ public static String ExportProfilesParametersDialog_7;
+
+ public static String ExportProfilesParametersDialog_8;
+
+ public static String ExportProfilesParametersDialog_9;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/dialog/ProfilesToExportSelectionDialog.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/dialog/ProfilesToExportSelectionDialog.java
new file mode 100644
index 00000000000..608f3330bb2
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/dialog/ProfilesToExportSelectionDialog.java
@@ -0,0 +1,215 @@
+/*****************************************************************************
+ * 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:
+ * Saadia DHOUIB (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.export.dialog;
+
+import java.util.Comparator;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.papyrus.uml.export.messages.Messages;
+import org.eclipse.papyrus.uml.export.util.ProfilesLabelProvider;
+import org.eclipse.papyrus.uml.extensionpoints.Activator;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
+import org.eclipse.uml2.uml.Profile;
+
+
+
+/**
+ * The Class ProfilesToExportSelectionDialog.
+ */
+public class ProfilesToExportSelectionDialog extends FilteredItemsSelectionDialog {
+
+ /** all elements that can be selected by the dialog. */
+ Object[] totalInput;
+
+ /** The imported profiles label provider. */
+ private ProfilesLabelProvider importedProfilesLabelProvider;
+
+ /** ID for this dialog preferences section. */
+ protected static final String DIALOG_SETTINGS = Activator.PLUGIN_ID + "dialogs.exportedprofiles"; //$NON-NLS-1$
+
+
+
+ /**
+ * Instantiates a new profiles to export selection dialog.
+ *
+ * @param shell
+ * the shell
+ * @param multi
+ * the multi
+ * @param input
+ * the input
+ * @param title
+ * the title
+ */
+ public ProfilesToExportSelectionDialog(Shell shell, boolean multi, Object[] input, String title) {
+ super(shell, multi);
+ importedProfilesLabelProvider = new ProfilesLabelProvider();
+ setTitle(title);
+ setInitialPattern("**"); //$NON-NLS-1$
+ setListLabelProvider(importedProfilesLabelProvider);
+ this.totalInput = input;
+
+ }
+
+ /**
+ * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#getElementName(java.lang.Object)
+ *
+ * @param item
+ * @return
+ */
+
+ @Override
+ public String getElementName(Object item) {
+ if(!(item instanceof Profile)) {
+ return null;
+ }
+ //System.err.println(((Profile)item).getName());
+
+ return ((Profile)item).getName();
+ }
+
+
+
+ /**
+ * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea(org.eclipse.swt.widgets.Composite)
+ *
+ * @param parent
+ * @return
+ */
+
+ @Override
+ protected Control createExtendedContentArea(Composite parent) {
+ //nothing
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createFilter()
+ */
+ /**
+ * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createFilter()
+ *
+ * @return
+ */
+
+ @Override
+ protected ItemsFilter createFilter() {
+ return new ProfileFilter() {
+ };
+ }
+
+ /**
+ * Filter for extension points.
+ */
+ private class ProfileFilter extends ItemsFilter {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isConsistentItem(Object item) {
+ if(item instanceof Profile) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter#matchItem(java.lang.Object)
+ *
+ * @param item
+ * @return
+ */
+
+ @Override
+ public boolean matchItem(Object item) {
+ if((item instanceof Profile)) {
+ return true;
+ }
+ return false;
+ }
+
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Comparator<Profile> getItemsComparator() {
+ Comparator<Profile> comp = new Comparator<Profile>() {
+
+ public int compare(Profile o1, Profile o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ };
+ return comp;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected IDialogSettings getDialogSettings() {
+ IDialogSettings settings = Activator.getDefault().getDialogSettings().getSection(DIALOG_SETTINGS);
+ if(settings == null) {
+ settings = Activator.getDefault().getDialogSettings().addNewSection(DIALOG_SETTINGS);
+ }
+ return settings;
+ }
+
+ /**
+ * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#validateItem(java.lang.Object)
+ *
+ * @param item
+ * @return
+ */
+
+ @Override
+ protected IStatus validateItem(Object item) {
+ // TODO Auto-generated method stub
+ return new Status(IStatus.OK, Activator.PLUGIN_ID, ""); //$NON-NLS-1$
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void fillContentProvider(AbstractContentProvider contentProvider, ItemsFilter itemsFilter, IProgressMonitor progressMonitor) throws CoreException {
+ if(progressMonitor != null) {
+ progressMonitor.beginTask(Messages.ProfilesToExportSelectionDialog_3, totalInput.length);
+ }
+ for(int i = 0; i < totalInput.length; i++) {
+ contentProvider.add(totalInput[i], itemsFilter);
+ progressMonitor.worked(1);
+ }
+ if(progressMonitor != null) {
+ progressMonitor.done();
+ }
+
+ }
+
+
+}
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/handlers/EditProfileApplicationAction.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/handlers/EditProfileApplicationAction.java
new file mode 100644
index 00000000000..376ff1db5c4
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/handlers/EditProfileApplicationAction.java
@@ -0,0 +1,323 @@
+/*****************************************************************************
+ * 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:
+ * Saadia DHOUIB (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.export.handlers;
+
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.ITextFileBuffer;
+import org.eclipse.core.filebuffers.ITextFileBufferManager;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.common.util.WrappedException;
+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.action.IAction;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.FindReplaceDocumentAdapter;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.core.resource.NotFoundException;
+import org.eclipse.papyrus.uml.export.Activator;
+import org.eclipse.papyrus.uml.export.dialog.ProfilesToExportSelectionDialog;
+import org.eclipse.papyrus.uml.export.messages.Messages;
+import org.eclipse.papyrus.uml.export.util.ProfileUtil;
+import org.eclipse.papyrus.uml.export.util.WSFileUtil;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.text.edits.MalformedTreeException;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionDelegate;
+import org.eclipse.uml2.uml.Profile;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class EditProfileApplicationAction.
+ */
+public class EditProfileApplicationAction extends ActionDelegate implements IActionDelegate {
+
+
+ /**
+ * Selected model files.
+ */
+ protected List<IFile> files;
+
+ /**
+ * Gets the i file.
+ *
+ * @param selectedObj
+ * the selected obj
+ * @return the i file
+ */
+ public static IFile getIFile(Object selectedObj) {
+ IFile result = null;
+ if(selectedObj instanceof IFile) {
+ result = (IFile)selectedObj;
+ }
+ // Try to adapt
+ if(result == null && selectedObj instanceof IAdaptable) {
+ result = (IFile)((IAdaptable)selectedObj).getAdapter(IFile.class);
+ }
+ // adapt in ifile
+ if(result == null) {
+ result = (IFile)Platform.getAdapterManager().getAdapter(selectedObj, IFile.class);
+ }
+ if(result == null) {
+ // try to check if it is a collection
+ Collection<?> collec = (Collection<?>)Platform.getAdapterManager().getAdapter(selectedObj, Collection.class);
+ if(collec != null) {
+ for(Object o : collec) {
+ if(o instanceof IFile) {
+ IFile f = (IFile)o;
+ if("uml".equals(f.getFileExtension())) {
+ result = f;
+ break;
+ }
+ }
+ }
+ }
+ }
+ return result != null && "uml".equals(result.getFileExtension()) ? result : null;
+ }
+
+ /**
+ * Checks if is profile application is editable.
+ *
+ * @param selectedObj
+ * the selected obj
+ * @return true, if is profile application editable
+ */
+ public static boolean isProfileApplicationEditable(Object selectedObj) {
+ IFile file = getIFile(selectedObj);
+ if(file != null) {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Resource umlResource = WSFileUtil.loadResource(file.getFullPath().toString(), resourceSet);
+ if(umlResource.getContents().isEmpty()) {
+ // The root doesn't exist.
+ return false;
+ }
+ EObject root = umlResource.getContents().get(0);
+ Object[] appliedProfiles = ProfileUtil.getAppliedProfilesFromWS(root);
+ if(appliedProfiles != null) {
+ for(int i = 0; i < appliedProfiles.length; i++) {
+ String installedProfileURI = findCorrespondingInstalledProfile((Profile)appliedProfiles[i]);
+ if(installedProfileURI != null) {
+ return true;
+ }
+
+ }
+ }
+ }
+ return false;
+
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.actions.ActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ * @generated
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public void selectionChanged(IAction action, ISelection selection) {
+ if(selection instanceof IStructuredSelection) {
+ files = ((IStructuredSelection)selection).toList();
+ }
+ }
+
+ /**
+ * Run.
+ *
+ * @param action
+ * the action
+ * @see org.eclipse.ui.actions.ActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+
+ @Override
+ public void run(IAction action) {
+ if(files != null) {
+ Iterator<IFile> filesIt = files.iterator();
+ IFile file = filesIt.next();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
+ try {
+ manager.connect(file.getFullPath(), null);
+ } catch (CoreException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ final ITextFileBuffer buffer = manager.getTextFileBuffer(file.getFullPath());
+ final IDocument doc = buffer.getDocument();
+ final FindReplaceDocumentAdapter adapter = new FindReplaceDocumentAdapter(doc);
+ final MultiTextEdit multiEdit = new MultiTextEdit();
+ Resource umlResource = WSFileUtil.loadResource(file.getFullPath().toString(), resourceSet);
+ if(umlResource.getContents().isEmpty()) {
+ // The root doesn't exist.
+ try {
+ throw new NotFoundException(Messages.EditProfileApplicationAction_0);
+ } catch (NotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ EObject root = umlResource.getContents().get(0);
+ Object[] appliedProfiles = ProfileUtil.getAppliedProfilesFromWS(root);
+ ArrayList<Object> appliedLocalProfiles = new ArrayList<Object>();
+ for(int i = 0; i < appliedProfiles.length; i++) {
+ String installedProfileURI = findCorrespondingInstalledProfile((Profile)appliedProfiles[i]);
+ if(installedProfileURI != null) {
+ appliedLocalProfiles.add(appliedProfiles[i]);
+ }
+
+ }
+ if(appliedLocalProfiles != null && !appliedLocalProfiles.isEmpty()) {
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ final ProfilesToExportSelectionDialog dialog = new ProfilesToExportSelectionDialog(shell, true, appliedLocalProfiles.toArray(), "Change profile application from local to installed");
+
+ dialog.open();
+ if(Dialog.OK == dialog.getReturnCode()) {
+
+ IRunnableWithProgress operation = new IRunnableWithProgress() {
+
+
+ public void run(IProgressMonitor monitor) {
+ Object[] profiles = dialog.getResult();
+ for(int i = 0; i < profiles.length; i++) {
+ if(profiles[i] instanceof Profile) {
+ // TODO Auto-generated method stub
+
+ String localProfileURI = ((Profile)profiles[i]).eResource().getURI().toString();
+
+
+ //the applied local profile in the xmi file has an uri that is relative to the workspace,
+ //so adapt the uri that is in the preferences to fit in this format
+ localProfileURI = localProfileURI.replace("platform:/resource/", "../"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ String installedProfileURI = findCorrespondingInstalledProfile((Profile)profiles[i]);
+ if(installedProfileURI != null) {
+
+ try {
+ WSFileUtil.replaceString(localProfileURI, installedProfileURI, adapter, doc, 0, multiEdit);
+ } catch (BadLocationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+
+ }
+ if(multiEdit.hasChildren()) {
+ try {
+ multiEdit.apply(doc);
+ } catch (MalformedTreeException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (BadLocationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ try {
+ buffer.commit(null, true);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+ }
+ }
+ };
+ try {
+ PlatformUI.getWorkbench().getProgressService().run(true, true, operation);
+ } catch (InvocationTargetException e) {
+ IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
+ org.eclipse.papyrus.uml.export.Activator.getDefault().getLog().log(status);
+ } catch (InterruptedException e) {
+ IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
+ org.eclipse.papyrus.uml.export.Activator.getDefault().getLog().log(status);
+ }
+ }
+ } else {
+ //launch an error message
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ MessageDialog.openError(shell, "Error", "No profile application to edit");
+ }
+ }
+
+
+ }
+
+
+
+
+
+ /**
+ * Find corresponding installed profile.
+ *
+ * @param profile
+ * the profile
+ * @return the corresponding installed profile uri
+ */
+ public static String findCorrespondingInstalledProfile(Profile profile) {
+ // TODO Auto-generated method stub
+ IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode("org.eclipse.papyrus.uml.export"); //$NON-NLS-1$
+ org.osgi.service.prefs.Preferences node = preferences.node("installedProfilesUriCorrespondance");
+ String installedProfileURI = node.get(profile.eResource().getURI().toString(), "default"); //$NON-NLS-1$
+ if((!installedProfileURI.equals("default"))) {
+ URI uri = URI.createURI(installedProfileURI);
+ try {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Resource resource = resourceSet.getResource(uri, true);
+ //verify that the profile is indeed installed in the platform before replacing the uri
+ if((resource.isLoaded()) && (!(resource.getContents().isEmpty()))) {
+ //System.err.println(installedProfileURI);
+ return installedProfileURI;
+ }
+ } catch (WrappedException ex) {
+ ex.printStackTrace();
+ }
+ } else {
+ return null;
+ }
+ return null;
+
+ }
+
+
+
+}
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/handlers/ExportAppliedProfileHandler.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/handlers/ExportAppliedProfileHandler.java
new file mode 100644
index 00000000000..50e96a861ef
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/handlers/ExportAppliedProfileHandler.java
@@ -0,0 +1,68 @@
+/*****************************************************************************
+ * 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.uml.export.handlers;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.UnexecutableCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.papyrus.uml.export.messages.Messages;
+import org.eclipse.papyrus.views.modelexplorer.handler.AbstractCommandHandler;
+import org.eclipse.uml2.uml.Package;
+
+
+
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ExportAppliedProfileHandler.
+ */
+public class ExportAppliedProfileHandler extends AbstractCommandHandler {
+
+
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ protected Command getCommand() {
+
+ if(canExecute()) {
+
+ AbstractTransactionalCommand cmd = new ExportProfilesCommand(getEditingDomain(), Messages.ExportAppliedProfileHandler_0, null);
+ return new org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper(cmd);
+ }
+
+ else
+ return UnexecutableCommand.INSTANCE;
+ }
+
+
+
+
+
+ /**
+ * Can execute.
+ *
+ * @return true, if successful
+ */
+ public boolean canExecute() {
+ if(getSelectedElements().size() == 1) {
+ return (getSelectedElement() instanceof Package);
+ }
+ return false;
+ }
+
+
+
+}
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/handlers/ExportProfilesCommand.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/handlers/ExportProfilesCommand.java
new file mode 100644
index 00000000000..b856264c048
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/handlers/ExportProfilesCommand.java
@@ -0,0 +1,538 @@
+/*****************************************************************************
+ * 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:
+ * Saadia DHOUIB (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.export.handlers;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+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.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.ui.util.DisplayUtils;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.papyrus.eclipse.project.editors.file.ManifestEditor;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.resource.NotFoundException;
+import org.eclipse.papyrus.infra.core.resource.uml.UmlModel;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResource;
+import org.eclipse.papyrus.infra.widgets.util.FileUtil;
+
+import org.eclipse.papyrus.uml.export.dialog.ExportProfilesIconsDialog;
+import org.eclipse.papyrus.uml.export.dialog.ExportProfilesParametersDialog;
+import org.eclipse.papyrus.uml.export.dialog.ProfilesToExportSelectionDialog;
+import org.eclipse.papyrus.uml.export.messages.Messages;
+import org.eclipse.papyrus.uml.export.util.BuildProperties;
+import org.eclipse.papyrus.uml.export.util.ExportProfilesUserParameters;
+import org.eclipse.papyrus.uml.export.util.ImportedLibrary;
+import org.eclipse.papyrus.uml.export.util.InstalledProfileURI;
+import org.eclipse.papyrus.uml.export.util.PluginExportUtil;
+import org.eclipse.papyrus.uml.export.util.ProfileUtil;
+import org.eclipse.papyrus.uml.export.util.WSFileUtil;
+import org.eclipse.pde.core.plugin.IPluginBase;
+import org.eclipse.pde.core.plugin.IPluginElement;
+import org.eclipse.pde.core.plugin.IPluginExtension;
+import org.eclipse.pde.core.plugin.IPluginModel;
+import org.eclipse.pde.internal.core.plugin.WorkspacePluginModel;
+import org.eclipse.pde.internal.core.plugin.WorkspacePluginModelBase;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+import org.xml.sax.SAXException;
+
+
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ExportProfilesCommand.
+ */
+@SuppressWarnings("restriction")
+public class ExportProfilesCommand extends AbstractTransactionalCommand {
+
+ /**
+ * Instantiates a new export profiles command.
+ *
+ * @param domain
+ * the domain
+ * @param label
+ * the label
+ * @param affectedFiles
+ * the affected files
+ */
+ public ExportProfilesCommand(TransactionalEditingDomain domain, String label, @SuppressWarnings("rawtypes") List affectedFiles) {
+ super(domain, label, affectedFiles);
+ // TODO Auto-generated constructor stub
+ }
+
+ /** The resources folder name. */
+ private String resourcesFolderName = Messages.ExportProfilesCommand_0;
+
+ /** The plugin provider. */
+ String pluginProvider = Messages.ExportProfilesCommand_1;
+
+ /** The plugin to install name. */
+ String pluginToInstallName = Messages.ExportProfilesCommand_2;
+
+ /** The plugin version. */
+ String pluginVersion = Messages.ExportProfilesCommand_3;
+
+ /** The exec environment. */
+ String execEnvironment = Messages.ExportProfilesCommand_4;
+
+
+
+ /**
+ * Do execute with result.
+ *
+ * @param monitor
+ * the monitor
+ * @param info
+ * the info
+ * @return the command result
+ * @throws ExecutionException
+ * the execution exception
+ * @see org.eclipse.core.commands.operations.AbstractOperation#canExecute()
+ */
+
+
+
+ /**
+ * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor,
+ * org.eclipse.core.runtime.IAdaptable)
+ *
+ * @param monitor
+ * @param info
+ * @return
+ * @throws org.eclipse.core.commands.ExecutionException
+ */
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
+
+
+ ServiceUtilsForActionHandlers serviceUtils = new ServiceUtilsForActionHandlers();
+ UmlModel openedModel;
+
+ try {
+ openedModel = (UmlModel)serviceUtils.getModelSet().getModel(UmlModel.MODEL_ID);
+ if(openedModel != null) {
+
+ EObject root = openedModel.lookupRoot();
+
+
+
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+
+
+ ProfilesToExportSelectionDialog dialog = new ProfilesToExportSelectionDialog(shell, true, ProfileUtil.getAppliedProfilesFromWS(root), Messages.ExportProfilesCommand_6);
+
+ dialog.open();
+ if(Dialog.OK == dialog.getReturnCode()) {
+ // get the result, which is the set of libraries to export
+ //then export the result
+ //launch a window to set the user specified export parameters:
+ // * name of the plugin that will contain the exported profiles and will be installed in the environement
+ // * version of the plugin
+ // * Provider of the plugin
+ // * Execution Environment
+
+
+ Object[] profiles = dialog.getResult();
+ for(int i = 0; i < profiles.length; i++) {
+ pluginToInstallName += ((Profile)profiles[i]).getName();
+
+ }
+ ExportProfilesParametersDialog paramDialog = new ExportProfilesParametersDialog(DisplayUtils.getDefaultShell(), pluginToInstallName, pluginProvider, pluginVersion, execEnvironment, dialog.getResult());
+
+ if(paramDialog.open() == Dialog.OK) {
+ ExportProfilesUserParameters param = new ExportProfilesUserParameters(paramDialog.getPluginName(), paramDialog.getPluginProvider(), paramDialog.getPluginVersion(), paramDialog.getPluginExecEnvironment());
+
+ exportProfiles(shell, dialog.getResult(), param, paramDialog.getProfilesIcons());
+ return CommandResult.newOKCommandResult();
+
+
+ }
+
+
+
+ }
+ } else {
+ return CommandResult.newErrorCommandResult(Messages.ExportProfilesCommand_7);
+ }
+ } catch (ServiceException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ParserConfigurationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (SAXException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+ return CommandResult.newErrorCommandResult(Messages.ExportProfilesCommand_8);
+
+
+
+
+
+ }
+
+ /**
+ * Export profiles.
+ *
+ * @param shell
+ * the shell
+ * @param appliedProfilesFromWS
+ * the applied profiles from ws
+ * @param param
+ * User defined paprameters for the generation
+ * @param profilesIcons
+ * @throws ParserConfigurationException
+ * the parser configuration exception
+ * @throws SAXException
+ * the sAX exception
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ * @throws CoreException
+ * the core exception
+ */
+ protected void exportProfiles(final Shell shell, final Object[] appliedProfilesFromWS, final ExportProfilesUserParameters param, final String[] profilesIcons) throws ParserConfigurationException, SAXException, IOException, CoreException {
+
+
+ final ProgressMonitorDialog monitordialog = new ProgressMonitorDialog(shell);
+ try {
+ monitordialog.run(true, true, new IRunnableWithProgress() {
+
+
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+
+ //Construct the profile
+ String profilesConcatName = ""; //$NON-NLS-1$
+
+ for(int i = 0; i < appliedProfilesFromWS.length; i++) {
+
+ profilesConcatName += ((Profile)appliedProfilesFromWS[i]).getName();
+ }
+
+ String localPluginName = param.getPluginName();
+
+ //this variable will store the imported libraries from WS, it will be used for the extensions generation in the manifest
+ ArrayList<ImportedLibrary> importedLibrariesFromWS = new ArrayList<ImportedLibrary>();
+
+ IProject project = null;
+ final PluginExportUtil pluginCreator = new PluginExportUtil();
+ monitor.beginTask(Messages.ExportProfilesCommand_10, 100);
+
+ //****************************************************************
+ //1. Generating a Plugin in the WS that encapsulated the applied profiles
+ //****************************************************************
+ monitor.subTask(Messages.ExportProfilesCommand_11);
+ project = pluginCreator.createPlugin(monitor, param.getPluginName(), param.getPluginExecEnvironment(), param.getPluginVersion(), param.getPluginProvider());
+ monitor.worked(1);
+ try {
+ monitor.subTask(Messages.ExportProfilesCommand_12);
+ //****************************************************************
+ //1.0 Plugin customization: adding dependencies to Manifest
+ //****************************************************************
+ ManifestEditor editor = new ManifestEditor(project);
+ editor.init();
+ editor.setSingleton(true);//we are going to add extensions to manifest, singleton must be set to true
+ editor.save();
+
+
+
+
+ //***********************************************************************************
+ // 1.1 Plugin customization: adding model directory and copying the profiles resources
+ //************************************************************************************
+
+ for(int i = 0; i < appliedProfilesFromWS.length; i++) {
+
+
+
+
+ ModelSet modelset = ServiceUtilsForResource.getInstance().getModelSet(((Profile)appliedProfilesFromWS[i]).eResource());
+ String umlFileName = WSFileUtil.getFileName((Profile)appliedProfilesFromWS[i], "uml"); //$NON-NLS-1$
+
+ Resource umlProfile = modelset.getAssociatedResource((Profile)appliedProfilesFromWS[i], "uml"); //$NON-NLS-1$
+
+
+ //Visits all proxies in the model set and tries to resolve them.
+ EcoreUtil.resolveAll(modelset);
+
+
+
+
+
+ //copy the uml profile in the created plugin (xmi ids will be copied)
+ URI umlFilenewURI = URI.createPlatformResourceURI(localPluginName + resourcesFolderName + umlFileName, true);
+ URI umlFileoldURI = umlProfile.getURI();
+ umlProfile.setURI(umlFilenewURI);
+ umlProfile.save(null);
+
+ //resave the resource with the original uri
+ umlProfile.setURI(umlFileoldURI);
+ umlProfile.save(null);
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Resource newUmlProfileResource = resourceSet.getResource(umlFilenewURI, true);
+ EcoreUtil.resolveAll(resourceSet);
+ //Verify that the uml model does not import packages. If it is the case, create the imported resources in the generated plugin and export them as well
+ for(EObject obj : newUmlProfileResource.getContents()) {
+ if(obj instanceof Profile) {
+
+ EList<Package> importedPackages = ((Profile)obj).getImportedPackages();
+ for(Package pack : importedPackages) {
+
+ //if the package is stored in the workspace, export it in the resource directory of the created profile plugin
+ if(pack.eResource() != null) {
+ if(pack.eResource().getURI().isPlatformResource()) {
+ String umlPackageFileName = WSFileUtil.getFileName(pack, "uml"); //$NON-NLS-1$
+
+ //Create the uml file that contain the library
+ URI uri = pack.eResource().getURI();
+ URI newURI = URI.createPlatformResourceURI(localPluginName + resourcesFolderName + umlPackageFileName, true);
+ pack.eResource().setURI(newURI);
+ pack.eResource().save(null);
+
+
+ //set the uri to the platform/plugin URI
+ pack.eResource().setURI(URI.createURI("platform:/plugin/" + localPluginName + resourcesFolderName + umlPackageFileName)); //$NON-NLS-1$
+ //redefine the profile
+ ((Profile)obj).define();
+
+ //The variable importedLibrariesFromWS is used to store the libraries that will be declared in the extensions of plugin.xml
+ importedLibrariesFromWS.add(new ImportedLibrary(pack, "platform:/plugin/" + localPluginName + resourcesFolderName + umlPackageFileName, uri, pack.getName())); //$NON-NLS-1$
+
+
+ }
+ }
+ }
+
+ }
+ }
+ newUmlProfileResource.save(null);
+
+ }
+
+
+
+ //****************************************************************
+ //1.2 Plugin customization: adding extension points in plugin.xml
+ //****************************************************************
+ final WorkspacePluginModelBase model = new WorkspacePluginModel(project.getProject().getFile("plugin.xml"), false); //$NON-NLS-1$
+ IPluginBase base = model.getPluginBase();
+ //****************************************************************
+ //1.2.1 Adding extension "org.eclipse.emf.ecore.uri_mapping"
+ //****************************************************************
+ IPluginExtension uri_mapping_ext = model.createExtension();
+ base.add(uri_mapping_ext);
+ uri_mapping_ext.setPoint("org.eclipse.emf.ecore.uri_mapping"); //$NON-NLS-1$
+ IPluginElement uri_mapping_elem = model.createElement(uri_mapping_ext);
+ uri_mapping_ext.add(uri_mapping_elem);
+
+
+ uri_mapping_elem.setName("mapping"); //$NON-NLS-1$
+ uri_mapping_elem.setAttribute("source", "pathmap://EXPORTED_" + profilesConcatName + "PROFILES/"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ uri_mapping_elem.setAttribute("target", "platform:/plugin/" + localPluginName + resourcesFolderName); //$NON-NLS-1$ //$NON-NLS-2$
+ model.setDirty(true);
+ model.save();
+ //**********************************************************************
+ //1.2.2Adding Extension "org.eclipse.papyrus.uml.extensionpoints.UMLProfile"
+ //**********************************************************************
+ final List<InstalledProfileURI> installedProfilesUri = new ArrayList<InstalledProfileURI>();
+ for(int i1 = 0; i1 < appliedProfilesFromWS.length; i1++) {
+
+ IPluginExtension ext = model.createExtension();
+ base.add(ext);
+ ext.setPoint("org.eclipse.papyrus.uml.extensionpoints.UMLProfile"); //$NON-NLS-1$
+ IPluginElement elem = model.createElement(ext);
+ ext.add(elem);
+
+ Profile profile = (Profile)appliedProfilesFromWS[i1];
+
+ String umlFileName = WSFileUtil.getFileName(profile, "uml"); //$NON-NLS-1$
+ elem.setName("profile"); //$NON-NLS-1$
+ //mandatory attributes
+ elem.setAttribute("name", profile.getName()); //$NON-NLS-1$
+ elem.setAttribute("path", "platform:/plugin/" + localPluginName + resourcesFolderName + umlFileName); //$NON-NLS-1$ //$NON-NLS-2$
+ //optional attributes
+ elem.setAttribute("description", "UML Profile " + profile.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ elem.setAttribute("provider", param.getPluginProvider()); //$NON-NLS-1$
+ if(!(profilesIcons[i1] == null) && !(profilesIcons[i1].length() == 0)) {
+ File icon = FileUtil.getFile(profilesIcons[i1]);
+ String iconName = getFSFileName(icon.getAbsolutePath());
+ elem.setAttribute("iconpath", "icons/" + iconName);
+ //copying icon file into created project
+ WSFileUtil.copyFile(project, icon, "icons/", iconName);
+
+ }
+
+
+
+ installedProfilesUri.add(new InstalledProfileURI("platform:/plugin/" + localPluginName + resourcesFolderName + umlFileName, profile.eResource().getURI().toString())); //$NON-NLS-1$
+
+ model.setDirty(true);
+ model.save();
+ }
+ //**********************************************************************
+ //1.2.3 Adding Extension "org.eclipse.papyrus.uml.extensionpoints.UMLLibrary"
+ //**********************************************************************
+ if(!importedLibrariesFromWS.isEmpty()) {
+ for(ImportedLibrary importedLibrary : importedLibrariesFromWS) {
+ IPluginExtension ext = model.createExtension();
+ base.add(ext);
+ ext.setPoint("org.eclipse.papyrus.uml.extensionpoints.UMLLibrary"); //$NON-NLS-1$
+ IPluginElement elem = model.createElement(ext);
+ ext.add(elem);
+
+ elem.setName("library"); //$NON-NLS-1$
+ //mandatory attributes
+ elem.setAttribute("name", importedLibrary.getName()); //$NON-NLS-1$
+ elem.setAttribute("path", importedLibrary.getUri()); //$NON-NLS-1$
+ //optional attributes
+ elem.setAttribute("description", "UML Library " + importedLibrary.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ elem.setAttribute("provider", param.getPluginProvider()); //$NON-NLS-1$
+
+ model.setDirty(true);
+ model.save();
+
+ }
+ }
+
+ // Refresh workspace files
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+
+
+ monitor.worked(1);
+
+ //****************************************************************
+ //1.3 Plugin customization: adding build properties to Manifest
+ //****************************************************************
+ monitor.subTask("Plugin customization: adding build properties to Manifest ..."); //$NON-NLS-1$
+ BuildProperties buildproperties = new BuildProperties(project);
+ buildproperties.addBuildEntry("bin.includes", "META-INF/,.,plugin.xml,build.properties,model/,icons/"); //$NON-NLS-1$ //$NON-NLS-2$
+ monitor.worked(1);
+ //****************************************************************
+ //2. Export the plugin and install it
+ //****************************************************************
+ monitor.subTask(Messages.ExportProfilesCommand_5);
+ final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+
+ final IPluginModel pluginModel = PluginExportUtil.getPluginModelForProject(project);
+ Display.getDefault().asyncExec(new Runnable() {
+
+ public void run() {
+
+ pluginCreator.exportProfilePlugin(shell, pluginModel, root.getLocation().toString() + "/.metadata/.plugins/org.eclipse.pde.core/install/", installedProfilesUri); //$NON-NLS-1$
+
+
+ }
+
+
+ });
+
+ monitor.worked(1);
+ monitor.done();
+
+
+
+
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ServiceException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+
+
+
+ }
+
+
+
+
+ });
+
+ } catch (InvocationTargetException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (InterruptedException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ }
+
+ /**
+ * Gets the fS file name.
+ *
+ * @param path
+ * the path
+ * @return the fS file name
+ */
+ public static String getFSFileName(String path) {
+
+ String fileName;
+ if(path.indexOf("\\") < 0) { //$NON-NLS-1$
+ fileName = path;
+ } else {
+ fileName = path.substring(path.lastIndexOf("\\") + 1, path.length()); //$NON-NLS-1$
+ }
+ return fileName;
+ }
+
+}
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/messages/Messages.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/messages/Messages.java
new file mode 100644
index 00000000000..2b183df36b5
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/messages/Messages.java
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * 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:
+ * Saadia DHOUIB (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.export.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class Messages.
+ */
+public class Messages extends NLS {
+
+ /** The Constant BUNDLE_NAME. */
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.uml.export.messages.messages"; //$NON-NLS-1$
+
+ public static String EditProfileApplicationAction_0;
+
+ public static String ExportAppliedProfileHandler_0;
+
+ public static String ExportProfilesCommand_0;
+
+ public static String ExportProfilesCommand_1;
+
+ public static String ExportProfilesCommand_10;
+
+ public static String ExportProfilesCommand_11;
+
+ public static String ExportProfilesCommand_12;
+
+ public static String ExportProfilesCommand_2;
+
+ public static String ExportProfilesCommand_3;
+
+ public static String ExportProfilesCommand_4;
+
+ public static String ExportProfilesCommand_5;
+
+ public static String ExportProfilesCommand_6;
+
+ public static String ExportProfilesCommand_7;
+
+ public static String ExportProfilesCommand_8;
+
+ /** The Import package from file handler_ select registered model library. */
+ public static String ImportPackageFromFileHandler_SelectRegisteredModelLibrary;
+
+ /** The Profiles to export selection dialog_3. */
+ public static String ProfilesToExportSelectionDialog_3;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ /**
+ * Instantiates a new messages.
+ */
+ private Messages() {
+ }
+}
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/messages/messages.properties b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/messages/messages.properties
new file mode 100644
index 00000000000..211795bcfc0
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/messages/messages.properties
@@ -0,0 +1,24 @@
+EditProfileApplicationAction_0=No root defined in the model
+ExportAppliedProfileHandler_0=Export Applied Profiles From Workspace
+ExportProfilesCommand_0=/model/
+ExportProfilesCommand_1=CEA List
+ExportProfilesCommand_10=Exporting Applied Local Profiles ...
+ExportProfilesCommand_11=Generating Plugin encapsulating the applied profiles ...
+ExportProfilesCommand_12=Customization of the plugin encapsulating the applied profiles ...
+ExportProfilesCommand_2=org.eclipse.papyrus.exported.profile.
+ExportProfilesCommand_3=0.1.0
+ExportProfilesCommand_4=J2SE-1.5
+ExportProfilesCommand_5=Export the plugin and install it ...
+ExportProfilesCommand_6=Export applied profiles :
+ExportProfilesCommand_7=Error while executing the command
+ExportProfilesCommand_8=Error while executing the command
+ExportProfilesParametersDialog_0=Plugin Name
+ExportProfilesParametersDialog_1=Enter the name of the plugin that will contain the exported profiles
+ExportProfilesParametersDialog_10=Execution Environment
+ExportProfilesParametersDialog_11=Enter the version of the java execution environment
+ExportProfilesParametersDialog_12=Parameters for the exported profiles plugin
+ExportProfilesParametersDialog_2=Plugin Provider
+ExportProfilesParametersDialog_7=Enter the provider of the plugin to be installed
+ExportProfilesParametersDialog_8=Plugin Version
+ExportProfilesParametersDialog_9=Enter the version of the plugin to be installed
+ImportPackageFromFileHandler_SelectRegisteredModelLibrary=Select Registered ModelLibrary
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/AreThereAppliedProfilesFromWS.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/AreThereAppliedProfilesFromWS.java
new file mode 100644
index 00000000000..94007b6695d
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/AreThereAppliedProfilesFromWS.java
@@ -0,0 +1,89 @@
+/*****************************************************************************
+ * 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:
+ * Saadia DHOUIB (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.export.util;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.editor.PapyrusMultiDiagramEditor;
+import org.eclipse.papyrus.infra.core.resource.NotFoundException;
+import org.eclipse.papyrus.infra.core.resource.uml.UmlModel;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Profile;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class AreThereAppliedProfilesFromWS.
+ */
+public class AreThereAppliedProfilesFromWS extends PropertyTester {
+
+ /** The Constant ARE_THERE_APPLIED_PROFILES. */
+ public final static String ARE_THERE_APPLIED_PROFILES = "AreThereAppliedProfiles";
+
+
+
+ /**
+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+ *
+ * @param receiver
+ * @param property
+ * @param args
+ * @param expectedValue
+ * @return
+ */
+
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+
+ // Ensure Papyrus is the active editor
+
+ IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if((editor == null) || (!(editor instanceof PapyrusMultiDiagramEditor))) {
+ return false;
+ }
+ Object currentValue = null;
+ if(ARE_THERE_APPLIED_PROFILES.equals(property)) {
+
+ ServiceUtilsForActionHandlers serviceUtils = new ServiceUtilsForActionHandlers();
+ UmlModel openedModel;
+ try {
+ openedModel = (UmlModel)serviceUtils.getModelSet().getModel(UmlModel.MODEL_ID);
+ EObject root = openedModel.lookupRoot();
+ Object[] profiles = ProfileUtil.getAppliedProfilesFromWS(root);
+
+ for(int i = 0; i < profiles.length; i++) {
+ if(profiles[i] instanceof Profile) {
+ currentValue = true;
+ break;
+ }
+ }
+ return (currentValue == expectedValue);
+ } catch (ServiceException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ return false;
+ }
+
+
+
+}
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/BuildProperties.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/BuildProperties.java
new file mode 100644
index 00000000000..a9437512334
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/BuildProperties.java
@@ -0,0 +1,184 @@
+/*****************************************************************************
+ * 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:
+ * Saadia DHOUIB (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.export.util;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.pde.core.build.IBuild;
+import org.eclipse.pde.core.build.IBuildEntry;
+import org.eclipse.pde.core.build.IBuildModel;
+import org.eclipse.pde.core.plugin.IPluginModelBase;
+import org.eclipse.pde.core.plugin.PluginRegistry;
+import org.eclipse.pde.internal.core.build.WorkspaceBuildModel;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class BuildProperties.
+ */
+@SuppressWarnings("restriction")
+public class BuildProperties {
+
+ /** The Constant OVERWRITE_BUILD_PROPERTY. */
+ public static final String OVERWRITE_BUILD_PROPERTY = "overwrite build property?";
+
+ /** The Constant NL. */
+ public static final String NL = System.getProperty("line.separator");
+
+ /** The project. */
+ private final IProject project;
+
+ /** The its build model. */
+ private IBuildModel itsBuildModel;
+
+ /**
+ * Instantiates a new builds the properties.
+ *
+ * @param project
+ * the project
+ */
+ public BuildProperties(IProject project) {
+ this.project = project;
+ }
+
+ /**
+ * adds or overwrites an entry in the 'build.properties'.<br>
+ * returns <b>true</b> if adding was successful,<br>
+ * <b>false</b> is dialog did not confirm adding
+ *
+ * @param key
+ * the build property's name
+ * @param value
+ * the build property's value
+ * @return <b>true</b> if adding was successful,<br>
+ * <b>false</b> is dialog did not confirm adding
+ * @throws CoreException
+ * the core exception
+ */
+ public boolean addBuildEntry(String key, String value) throws CoreException {
+ Assert.isNotNull(key);
+ Assert.isNotNull(value);
+ boolean writeEntry = true;
+ if(hasBuildEntry(key)) {
+ if(getBuild().getEntry(key).contains(value)) {
+ return true;
+ }
+
+
+ removeExistingBuildEntry(key);
+
+ }
+
+ if(writeEntry) {
+ IBuildModel buildModel = getBuildModel();
+ IBuildEntry buildEntry = buildModel.getFactory().createEntry(key);
+ buildEntry.addToken(value);
+ getBuild().add(buildEntry);
+
+ ((WorkspaceBuildModel)buildModel).save();
+ }
+ return writeEntry;
+ }
+
+
+
+ /**
+ * removes an entry with the given name from the 'build.properties'
+ *
+ * @param key
+ * the build property's name
+ * @throws CoreException
+ * the core exception
+ */
+ public void removeExistingBuildEntry(String key) throws CoreException {
+ IBuildEntry entry = getBuild().getEntry(key);
+ if(entry != null) {
+ getBuild().remove(entry);
+ }
+ }
+
+ /**
+ * returns whether an entry exists for the given key.
+ *
+ * @param key
+ * the build property's name
+ * @return true, if successful
+ */
+ public boolean hasBuildEntry(final String key) {
+ return getBuild().getEntry(key) != null;
+ }
+
+
+
+ /**
+ * Gets the builds the.
+ *
+ * @return the builds the
+ */
+ private IBuild getBuild() {
+ IBuildModel buildModel = getBuildModel();
+ if(buildModel == null) {
+ return null;
+ }
+ return buildModel.getBuild();
+ }
+
+
+ /**
+ * Gets the properties.
+ *
+ * @param key
+ * the key
+ * @return the properties
+ */
+ public String[] getProperties(String key) {
+ return getBuild().getEntry(key).getTokens();
+ }
+
+
+
+ /**
+ * returns the Eclipse BuildModel.
+ *
+ * @return the Eclipse BuildModel
+ */
+ private IBuildModel getBuildModel() {
+ if(itsBuildModel == null) {
+ IPluginModelBase pluginModel = PluginRegistry.findModel(this.project);
+ itsBuildModel = createBuildModel(pluginModel);
+ }
+ return itsBuildModel;
+ }
+
+
+ /**
+ * see org.eclipse.pde.internal.core.ClasspathUtilCore.getBuild
+ *
+ * @param model
+ * the model
+ * @return the i build model
+ */
+ private IBuildModel createBuildModel(final IPluginModelBase model) {
+ IProject project = model.getUnderlyingResource().getProject();
+ IFile buildFile = project.getFile("build.properties"); //$NON-NLS-1$
+ if(!buildFile.exists()) {
+ return null;
+ }
+ WorkspaceBuildModel buildModel = new WorkspaceBuildModel(buildFile);
+ buildModel.load();
+ return buildModel;
+ }
+
+}
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ChangeProfileApplicationTester.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ChangeProfileApplicationTester.java
new file mode 100644
index 00000000000..6c7c5ddda91
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ChangeProfileApplicationTester.java
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * 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:
+ * Saadia DHOUIB (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.export.util;
+
+
+
+import org.eclipse.papyrus.uml.export.handlers.EditProfileApplicationAction;
+
+
+
+
+public class ChangeProfileApplicationTester extends org.eclipse.core.expressions.PropertyTester {
+
+
+
+
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if("ChangeProfileApplication".equals(property) || EditProfileApplicationAction.getIFile(receiver) != null) {
+
+
+ return EditProfileApplicationAction.isProfileApplicationEditable(receiver);
+ }
+ return false;
+ }
+
+
+}
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ExportProfilesUserParameters.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ExportProfilesUserParameters.java
new file mode 100644
index 00000000000..09807655544
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ExportProfilesUserParameters.java
@@ -0,0 +1,135 @@
+/*****************************************************************************
+ * 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:
+ * Saadia DHOUIB (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.export.util;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ExportProfilesUserParameters.
+ */
+public class ExportProfilesUserParameters {
+
+ /** The plugin name. */
+ private String pluginName;
+
+ /** The plugin provider. */
+ private String pluginProvider;
+
+ /** The plugin version. */
+ private String pluginVersion;
+
+ /** The plugin exec environment. */
+ private String pluginExecEnvironment;
+
+ /**
+ * Instantiates a new export profiles user parameters.
+ *
+ * @param pluginName
+ * the plugin name
+ * @param pluginProvider
+ * the plugin provider
+ * @param pluginVersion
+ * the plugin version
+ * @param execEnvironment
+ * the exec environment
+ */
+ public ExportProfilesUserParameters(String pluginName, String pluginProvider, String pluginVersion, String execEnvironment) {
+ this.pluginName = pluginName;
+ this.pluginProvider = pluginProvider;
+ this.pluginVersion = pluginVersion;
+ this.pluginExecEnvironment = execEnvironment;
+
+ }
+
+
+ /**
+ * Gets the plugin name.
+ *
+ * @return the plugin name
+ */
+ public String getPluginName() {
+ return pluginName;
+ }
+
+ /**
+ * Sets the plugin name.
+ *
+ * @param pluginName
+ * the new plugin name
+ */
+ public void setPluginName(String pluginName) {
+ this.pluginName = pluginName;
+ }
+
+ /**
+ * Gets the plugin provider.
+ *
+ * @return the plugin provider
+ */
+ public String getPluginProvider() {
+ return pluginProvider;
+ }
+
+ /**
+ * Sets the plugin provider.
+ *
+ * @param pluginProvider
+ * the new plugin provider
+ */
+ public void setPluginProvider(String pluginProvider) {
+ this.pluginProvider = pluginProvider;
+ }
+
+ /**
+ * Gets the plugin version.
+ *
+ * @return the plugin version
+ */
+ public String getPluginVersion() {
+ return pluginVersion;
+ }
+
+ /**
+ * Sets the plugin version.
+ *
+ * @param pluginVersion
+ * the new plugin version
+ */
+ public void setPluginVersion(String pluginVersion) {
+ this.pluginVersion = pluginVersion;
+ }
+
+ /**
+ * Gets the plugin exec environment.
+ *
+ * @return the plugin exec environment
+ */
+ public String getPluginExecEnvironment() {
+ return pluginExecEnvironment;
+ }
+
+ /**
+ * Sets the plugin exec environment.
+ *
+ * @param pluginExecEnvironment
+ * the new plugin exec environment
+ */
+ public void setPluginExecEnvironment(String pluginExecEnvironment) {
+ this.pluginExecEnvironment = pluginExecEnvironment;
+ }
+
+
+
+
+}
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ImportedLibrary.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ImportedLibrary.java
new file mode 100644
index 00000000000..e71a4148467
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ImportedLibrary.java
@@ -0,0 +1,147 @@
+/*****************************************************************************
+ * 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:
+ * Saadia DHOUIB (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.export.util;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ImportedLibrary.
+ */
+public class ImportedLibrary {
+
+ /** The library model. */
+ private EObject libraryModel;
+
+ /** The new uri. */
+ private String newUri;
+
+ /** The old uri. */
+ private URI oldURI;
+
+
+
+ /** The name. */
+ private String name;
+
+
+
+ /**
+ * Instantiates a new imported library.
+ *
+ * @param libraryModel
+ * the library model
+ * @param newUri
+ * the new uri
+ * @param oldURI
+ * the old uri
+ * @param libraryName
+ * the library name
+ */
+ public ImportedLibrary(EObject libraryModel, String newUri, URI oldURI, String libraryName) {
+ super();
+ this.libraryModel = libraryModel;
+ this.newUri = newUri;
+ this.name = libraryName;
+ this.oldURI = oldURI;
+
+ }
+
+
+ /**
+ * Gets the library model.
+ *
+ * @return the library model
+ */
+ public EObject getLibraryModel() {
+ return libraryModel;
+ }
+
+ /**
+ * Sets the library model.
+ *
+ * @param libraryModel
+ * the new library model
+ */
+ public void setLibraryModel(EObject libraryModel) {
+ this.libraryModel = libraryModel;
+ }
+
+ /**
+ * Gets the uri.
+ *
+ * @return the uri
+ */
+ public String getUri() {
+ return newUri;
+ }
+
+ /**
+ * Sets the uri.
+ *
+ * @param uri
+ * the new uri
+ */
+ public void setUri(String uri) {
+ this.newUri = uri;
+ }
+
+
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+
+ /**
+ * Sets the name.
+ *
+ * @param name
+ * the new name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+ /**
+ * Gets the old uri.
+ *
+ * @return the old uri
+ */
+ public URI getOldURI() {
+ return oldURI;
+ }
+
+
+ /**
+ * Sets the old uri.
+ *
+ * @param oldURI
+ * the new old uri
+ */
+ public void setOldURI(URI oldURI) {
+ this.oldURI = oldURI;
+ }
+
+
+
+
+
+}
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/InstalledProfileURI.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/InstalledProfileURI.java
new file mode 100644
index 00000000000..5f6f2b68802
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/InstalledProfileURI.java
@@ -0,0 +1,84 @@
+/*****************************************************************************
+ * 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:
+ * Saadia DHOUIB (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.export.util;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class InstalledProfileURI.
+ */
+public class InstalledProfileURI {
+
+ /**
+ * Instantiates a new installed profile uri.
+ *
+ * @param uri_installed
+ * the uri of the installed profile
+ * @param uri_local
+ * the uri of the corresponding local profile from which the installed profile has been copied
+ */
+ public InstalledProfileURI(String uri_installed, String uri_local) {
+ super();
+ this.uri_installed = uri_installed;
+ this.uri_local = uri_local;
+ }
+
+ /** The uri of the installed profile. */
+ public String uri_installed;
+
+ /** The uri of the local profile. */
+ public String uri_local;
+
+ /**
+ * Gets the uri of the installed profile.
+ *
+ * @return the uri of the installed profile
+ */
+ public String getUri_installed() {
+ return uri_installed;
+ }
+
+ /**
+ * Sets the uri of the installed profile.
+ *
+ * @param uri_installed
+ * the new uri of the installed profile
+ */
+ public void setUri_installed(String uri_installed) {
+ this.uri_installed = uri_installed;
+ }
+
+ /**
+ * Gets the uri of the local profile.
+ *
+ * @return the uri of the local profile
+ */
+ public String getUri_local() {
+ return uri_local;
+ }
+
+ /**
+ * Sets the uri of the local profile.
+ *
+ * @param uri_local
+ * the new uri of the local profile
+ */
+ public void setUri_local(String uri_local) {
+ this.uri_local = uri_local;
+ }
+
+
+
+
+}
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/PluginExportUtil.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/PluginExportUtil.java
new file mode 100644
index 00000000000..933fc6455d9
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/PluginExportUtil.java
@@ -0,0 +1,535 @@
+/*****************************************************************************
+ * 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:
+ * Saadia DHOUIB (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.export.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.pde.core.build.IBuildEntry;
+import org.eclipse.pde.core.build.IBuildModel;
+import org.eclipse.pde.core.plugin.IPluginBase;
+import org.eclipse.pde.core.plugin.IPluginModel;
+import org.eclipse.pde.core.plugin.IPluginModelBase;
+import org.eclipse.pde.internal.build.IBuildPropertiesConstants;
+import org.eclipse.pde.internal.core.PDECore;
+import org.eclipse.pde.internal.core.PDECoreMessages;
+import org.eclipse.pde.internal.core.PluginModelManager;
+import org.eclipse.pde.internal.core.build.WorkspaceBuildModel;
+import org.eclipse.pde.internal.core.exports.FeatureExportInfo;
+import org.eclipse.pde.internal.core.exports.PluginExportOperation;
+import org.eclipse.pde.internal.core.feature.WorkspaceFeatureModel;
+import org.eclipse.pde.internal.core.plugin.WorkspacePluginModelBase;
+import org.eclipse.pde.internal.core.project.PDEProject;
+import org.eclipse.pde.internal.ui.IPreferenceConstants;
+import org.eclipse.pde.internal.ui.PDELabelProvider;
+import org.eclipse.pde.internal.ui.PDEPlugin;
+import org.eclipse.pde.internal.ui.PDEPluginImages;
+import org.eclipse.pde.internal.ui.PDEUIMessages;
+import org.eclipse.pde.internal.ui.build.RuntimeInstallJob;
+import org.eclipse.pde.internal.ui.wizards.IProjectProvider;
+import org.eclipse.pde.internal.ui.wizards.plugin.NewProjectCreationOperation;
+import org.eclipse.pde.internal.ui.wizards.plugin.PluginFieldData;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.program.Program;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.progress.IProgressConstants;
+import org.osgi.service.prefs.BackingStoreException;
+
+import com.ibm.icu.text.MessageFormat;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class PluginExportUtil.
+ */
+@SuppressWarnings("restriction")
+public class PluginExportUtil {
+
+
+ /** The Constant MAX_RETRY. */
+ protected static final int MAX_RETRY = 3;
+
+ /** The Constant SrcFolderName. */
+ private static final String SrcFolderName = "src";
+
+
+
+
+
+ /**
+ * Creates the plugin.
+ *
+ * @param progressMonitor
+ * the progress monitor
+ * @param pluginName
+ * the plugin name
+ * @param executionEnvironment
+ * the execution environment
+ * @param pluginVersion
+ * the plugin version
+ * @param provider
+ * the provider
+ * @return the i project
+ */
+ public IProject createPlugin(IProgressMonitor progressMonitor, final String pluginName, String executionEnvironment, String pluginVersion, String provider) {
+
+
+ PluginFieldData fPluginData = new PluginFieldData();
+ fPluginData.setProvider(provider);
+ fPluginData.setId(pluginName);
+ fPluginData.setName(pluginName);
+ fPluginData.setSourceFolderName(SrcFolderName);
+ fPluginData.setVersion(pluginVersion);
+ fPluginData.setWorkingSets(null);
+ fPluginData.setClassname(pluginName + ".Activator");
+ fPluginData.setDoGenerateClass(true);
+ fPluginData.setExecutionEnvironment(executionEnvironment);
+ fPluginData.setOSGiFramework(null);
+ fPluginData.setHasBundleStructure(true);
+ fPluginData.setUIPlugin(true);
+ fPluginData.setLegacy(false);
+ fPluginData.setLibraryName(null);
+ fPluginData.setOutputFolderName("bin");
+ fPluginData.setRCPApplicationPlugin(false);
+ fPluginData.setEnableAPITooling(false);
+ fPluginData.setSimple(false);
+ fPluginData.setTargetVersion("3.7");
+ IWorkingSet[] workingSets = {};
+ fPluginData.setWorkingSets(workingSets);
+
+
+
+
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ final IProject project = root.getProject(pluginName);
+
+
+
+ IProjectProvider fProjectProvider = new IProjectProvider() {
+
+ public String getProjectName() {
+ // TODO Auto-generated method stub
+ return pluginName;
+ }
+
+ public IProject getProject() {
+ // TODO Auto-generated method stub
+ return project;
+ }
+
+ public IPath getLocationPath() {
+ // TODO Auto-generated method stub
+ return ResourcesPlugin.getWorkspace().getRoot().getLocation();
+ }
+ };
+
+ NewProjectCreationOperation op = new NewProjectCreationOperation(fPluginData, fProjectProvider, null);
+
+ try {
+
+ op.run(progressMonitor);
+ } catch (InvocationTargetException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (InterruptedException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ return project;
+
+ }
+
+ /**
+ * Export profile plugin.
+ *
+ * @param shell
+ * the shell
+ * @param object
+ * the object
+ * @param installationDirectory
+ * the installation directory
+ * @param installedProfilesUri
+ * the installed profiles uri
+ * @return true, if successful
+ */
+ public boolean exportProfilePlugin(Shell shell, Object object, String installationDirectory, List<InstalledProfileURI> installedProfilesUri) {
+
+ if(!PlatformUI.getWorkbench().saveAllEditors(true)) {
+ return false;
+ }
+
+ if(!performPreliminaryChecks(shell, object)) {
+ return false;
+ }
+
+ scheduleExportJob(object, installationDirectory, installedProfilesUri);
+
+ return true;
+
+ }
+
+
+ /**
+ * Schedule export job.
+ *
+ * @param object
+ * the object
+ * @param installationDirectory
+ * the installation directory
+ * @param installedProfilesUri
+ * the installed profiles uri
+ */
+ protected void scheduleExportJob(Object object, String installationDirectory, final List<InstalledProfileURI> installedProfilesUri) {
+ Object obj[] = new Object[1];
+ obj[0] = object;
+ final FeatureExportInfo info = new FeatureExportInfo();
+ info.toDirectory = true;
+ info.useJarFormat = true;
+ info.exportSource = true;
+ info.exportSourceBundle = false;
+ info.allowBinaryCycles = true;
+ info.useWorkspaceCompiledClasses = false;
+ info.destinationDirectory = installationDirectory;
+
+ info.zipFileName = null;
+ info.items = obj;
+ info.signingInfo = null;
+ info.qualifier = null;
+
+ final boolean installAfterExport = true;
+ if(installAfterExport) {
+ RuntimeInstallJob.modifyInfoForInstall(info);
+ }
+
+ final PluginExportOperation job = new PluginExportOperation(info, PDEUIMessages.PluginExportJob_name);
+ job.setUser(true);
+ job.setRule(ResourcesPlugin.getWorkspace().getRoot());
+ job.setProperty(IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_PLUGIN_OBJ);
+ job.addJobChangeListener(new JobChangeAdapter() {
+
+ @Override
+ public void done(IJobChangeEvent event) {
+ if(job.hasAntErrors()) {
+ // If there were errors when running the ant scripts, inform the user where the logs can be found.
+ final File logLocation = new File(info.destinationDirectory, "logs.zip"); //$NON-NLS-1$
+ if(logLocation.exists()) {
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+
+ public void run() {
+ ExportErrorDialog dialog = new ExportErrorDialog(logLocation);
+ dialog.open();
+ }
+ });
+ }
+ } else if(event.getResult().isOK() && installAfterExport) {
+ // Install the export into the current running platform
+ RuntimeInstallJob installJob = new RuntimeInstallJob(PDEUIMessages.PluginExportWizard_InstallJobName, info);
+ installJob.setUser(true);
+ installJob.setProperty(IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_FEATURE_OBJ);
+ //add preferences that contain the information about the correspondence between the installed and the local profiles
+ editPreferences(installedProfilesUri);
+ installJob.schedule();
+ }
+ }
+ });
+ job.schedule();
+ }
+
+ /**
+ * Edits the preferences.
+ *
+ * @param installedProfilesUri
+ * the installed profiles uri
+ */
+ private void editPreferences(List<InstalledProfileURI> installedProfilesUri) {
+ // TODO Auto-generated method stub
+ IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode("org.eclipse.papyrus.uml.export");
+ org.osgi.service.prefs.Preferences node = preferences.node("installedProfilesUriCorrespondance");
+ for(InstalledProfileURI p : installedProfilesUri) {
+ node.put(p.getUri_local(), p.getUri_installed());
+
+
+ try {
+ // Forces the application to save the preferences
+ preferences.flush();
+ } catch (BackingStoreException e2) {
+ e2.printStackTrace();
+ }
+ }
+
+ }
+
+ /**
+ * Perform preliminary checks.
+ *
+ * @param shell
+ * the shell
+ * @param object
+ * the object
+ * @return true, if successful
+ */
+ @SuppressWarnings("unchecked")
+ protected boolean performPreliminaryChecks(Shell shell, Object object) {
+ // Check if we are going to overwrite an existing build.xml file
+ if(!MessageDialogWithToggle.ALWAYS.equals(PDEPlugin.getDefault().getPreferenceStore().getString(IPreferenceConstants.OVERWRITE_BUILD_FILES_ON_EXPORT))) {
+
+ @SuppressWarnings("rawtypes")
+ List problemModels = new ArrayList();
+
+ String installLocation = null;
+ IResource underlyingResource = null;
+ if(object instanceof WorkspacePluginModelBase) {
+ installLocation = ((WorkspacePluginModelBase)object).getInstallLocation();
+ underlyingResource = ((WorkspacePluginModelBase)object).getUnderlyingResource();
+ } else if(object instanceof WorkspaceFeatureModel) {
+ installLocation = ((WorkspaceFeatureModel)object).getInstallLocation();
+ underlyingResource = ((WorkspaceFeatureModel)object).getUnderlyingResource();
+ }
+ if(installLocation != null && underlyingResource != null) {
+ File file = new File(installLocation, "build.xml"); //$NON-NLS-1$
+ if(file.exists()) {
+ try {
+ IFile buildFile = PDEProject.getBuildProperties(underlyingResource.getProject());
+ IBuildModel buildModel = new WorkspaceBuildModel(buildFile);
+ buildModel.load();
+ if(buildModel != null) {
+ IBuildEntry entry = buildModel.getBuild().getEntry(IBuildPropertiesConstants.PROPERTY_CUSTOM);
+ if(entry == null || !entry.contains(IBuildPropertiesConstants.TRUE)) {
+ problemModels.add(object);
+ }
+ }
+ } catch (CoreException e) {
+ PDEPlugin.log(e);
+ }
+ }
+ }
+
+ if(problemModels.size() > 0) {
+ StringBuffer buf = new StringBuffer();
+ PDELabelProvider labelProvider = new PDELabelProvider();
+ int maxCount = 10;
+ for(Iterator<Object> iterator = problemModels.iterator(); iterator.hasNext();) {
+ buf.append(labelProvider.getText(iterator.next()));
+ buf.append('\n');
+ maxCount--;
+ if(maxCount <= 0) {
+ buf.append(Dialog.ELLIPSIS);
+ break;
+ }
+ }
+
+ MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(shell, PDEUIMessages.AntGeneratingExportWizard_0, MessageFormat.format(PDEUIMessages.AntGeneratingExportWizard_1, buf.toString()), PDEUIMessages.AntGeneratingExportWizard_2, false, PDEPlugin.getDefault().getPreferenceStore(), IPreferenceConstants.OVERWRITE_BUILD_FILES_ON_EXPORT);
+ if(dialog.getReturnCode() == Window.CANCEL) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * The Class ExportErrorDialog.
+ */
+ protected class ExportErrorDialog extends MessageDialog {
+
+ /** The log location. */
+ private File fLogLocation;
+
+ /**
+ * Instantiates a new export error dialog.
+ *
+ * @param logLocation
+ * the log location
+ */
+ public ExportErrorDialog(File logLocation) {
+ super(PlatformUI.getWorkbench().getDisplay().getActiveShell(), PDECoreMessages.FeatureBasedExportOperation_ProblemDuringExport, null, null, MessageDialog.ERROR, new String[]{ IDialogConstants.OK_LABEL }, 0);
+ fLogLocation = logLocation;
+ }
+
+ /**
+ * Creates the message area.
+ *
+ * @param composite
+ * the composite
+ * @return the control
+ * @see org.eclipse.jface.dialogs.IconAndMessageDialog#createMessageArea(org.eclipse.swt.widgets.Composite)
+ */
+
+ @Override
+ protected Control createMessageArea(Composite composite) {
+ Link link = new Link(composite, SWT.WRAP);
+ try {
+ link.setText(NLS.bind(PDEUIMessages.PluginExportWizard_Ant_errors_during_export_logs_generated, "<a>" + fLogLocation.getCanonicalPath() + "</a>")); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (IOException e) {
+ PDEPlugin.log(e);
+ }
+ GridData data = new GridData();
+ data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
+ link.setLayoutData(data);
+ link.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ Program.launch(fLogLocation.getCanonicalPath());
+ } catch (IOException ex) {
+ PDEPlugin.log(ex);
+ }
+ }
+ });
+ return link;
+ }
+ }
+
+ // public void createJarFromPlugin(final IProject project, Shell parentShell){
+ // JarPackageData description= new JarPackageData();
+ // IPath location= new Path("projectDir+File.separator+jarFileName");
+ // description.setJarLocation(location);
+ // description.setManifestMainClass(mainType);
+ // description.setExportClassFiles(true);
+ // description.setExportOutputFolders(false);
+ // description.setExportErrors(true);
+ // description.setExportWarnings(true);
+ // description.setOverwrite(true);
+ // description.setGenerateManifest(true);
+ // description.setElements(filestoExport);
+ // IJarExportRunnable runnable= description.createJarExportRunnable(parentShell);
+ // try {
+ // new ProgressMonitorDialog(parentShell).run(true,true, runnable);S
+ // } catch (InvocationTargetException e) {
+ // } catch (InterruptedException e) {
+ // }
+ // return;
+ // }
+
+
+ /**
+ * Delete.
+ *
+ * @param project
+ * the project to delete.
+ * @throws CoreException
+ * the core exception
+ */
+ public void delete(final IProject project) throws CoreException {
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+
+ public void run(IProgressMonitor monitor) throws CoreException {
+ // jproject.setRawClasspath(new IClasspathEntry[0], jproject
+ // .getProject().getFullPath(), null);
+ for(int i = 0; i < MAX_RETRY; i++) {
+ try {
+ IProject tmpProject = project.getProject();
+ synchronized(tmpProject) {
+ if(tmpProject.exists()) {
+ tmpProject.delete(true, true, null);
+ }
+ }
+ i = MAX_RETRY;
+ } catch (CoreException e) {
+ if(i == MAX_RETRY - 1) {
+
+ throw e;
+ }
+ try {
+ Thread.sleep(1000); // sleep a second
+ } catch (InterruptedException e1) {
+ }
+ }
+ }
+ }
+ };
+ ResourcesPlugin.getWorkspace().run(runnable, null);
+ }
+
+ /**
+ * Gets the plugin model for project.
+ *
+ * @param project
+ * the project
+ * @return the plugin model for project
+ */
+ public static IPluginModel getPluginModelForProject(final IProject project) {
+
+ PluginModelManager pmm = PDECore.getDefault().getModelManager();
+ IPluginModelBase[] wsPlugins = pmm.getWorkspaceModels();
+
+ if(wsPlugins.length == 0) {
+ //ErrorHandler.reportError("Project " + project.getName() + " is not a plugin project (no plugin projects)?", false);
+ return null;
+ }
+ for(int i = 0; i < wsPlugins.length; i++) {
+ IPluginModelBase wsPlugin = wsPlugins[i];
+
+
+
+ // May get both workspace and project plugin models
+ // (although only the latter are of interest)
+ IPluginBase pmBase = wsPlugin.getPluginBase();
+ if(pmBase == null) {
+ continue;
+ }
+ String id = pmBase.getId();
+ if(id == null) {
+ continue;
+ }
+ String projName = project.getName();
+ if(projName == null) {
+ continue;
+ }
+
+
+ String resourceLocation = pmBase.getModel().getUnderlyingResource().getLocation().toString();
+ if(resourceLocation.endsWith(projName + "/META-INF/MANIFEST.MF")) {
+ return (IPluginModel)wsPlugin;
+ }
+
+ }
+ //ErrorHandler.reportError("Could not find plugin for project " + project.getName(), false);
+ return null;
+ }
+
+}
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ProfileUtil.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ProfileUtil.java
new file mode 100644
index 00000000000..380ee39c277
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ProfileUtil.java
@@ -0,0 +1,89 @@
+/*****************************************************************************
+ * 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:
+ * Saadia DHOUIB (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.export.util;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.uml2.uml.Profile;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ProfileUtil.
+ */
+public class ProfileUtil {
+
+ /**
+ * Gets the applied profiles from ws.
+ *
+ * @param openedModel
+ * the opened model
+ * @return the applied profiles from ws
+ */
+ public static Object[] getAppliedProfilesFromWS(EObject openedModel) {
+
+
+
+
+
+ //the list of root profiles, we will export only the root profiles and profiles that are applied from local workspace plugins
+ // use of set to not having duplicate elements
+ Set<EObject> rootProfiles = new HashSet<EObject>();
+
+
+ for(Profile p : ((org.eclipse.uml2.uml.Package)openedModel).getAllAppliedProfiles()) {
+
+ rootProfiles.add(getRootLocalProfile(p));
+
+ }
+
+
+
+ Object[] profilesToExport = rootProfiles.toArray(new Object[rootProfiles.size()]);
+ return profilesToExport;
+
+
+ }
+
+ /**
+ * Gets the root local profile.
+ *
+ * @param p
+ * the p
+ * @return the root local profile
+ */
+ public static EObject getRootLocalProfile(EObject p) {
+ if(p.eContainer() == null) {
+ Resource eResource = p.eResource();
+ if(eResource != null) {
+ URI eUri = eResource.getURI();
+ if(eUri.isPlatformResource()) {
+ return p;
+ } else
+ return null;
+ } else
+ return null;
+
+ } else
+ return getRootLocalProfile(p.eContainer());
+
+
+ }
+
+
+
+}
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ProfilesLabelProvider.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ProfilesLabelProvider.java
new file mode 100644
index 00000000000..deb037b6276
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/ProfilesLabelProvider.java
@@ -0,0 +1,51 @@
+/*****************************************************************************
+ * 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:
+ * Saadia DHOUIB (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.export.util;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.uml2.uml.Profile;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ProfilesLabelProvider.
+ */
+public class ProfilesLabelProvider extends LabelProvider {
+
+ /**
+ * Instantiates a new profiles label provider.
+ */
+ public ProfilesLabelProvider() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * Gets the text.
+ *
+ * @param element
+ * the element
+ * @return the text
+ * @{inheritedDoc
+ */
+ @Override
+ public String getText(Object element) {
+ if(!(element instanceof Profile)) {
+ return super.getText(element);
+ }
+
+ return ((Profile)element).getName();
+ }
+
+}
diff --git a/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/WSFileUtil.java b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/WSFileUtil.java
new file mode 100644
index 00000000000..5fbf773ca9a
--- /dev/null
+++ b/extraplugins/uml/org.eclipse.papyrus.uml.export/src/org/eclipse/papyrus/uml/export/util/WSFileUtil.java
@@ -0,0 +1,182 @@
+/*****************************************************************************
+ * 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:
+ * Saadia DHOUIB (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.export.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.common.util.WrappedException;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.FindReplaceDocumentAdapter;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.widgets.util.FileUtil;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.ReplaceEdit;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class WSFileUtil.
+ */
+public class WSFileUtil {
+
+
+
+ /**
+ * Gets the file name.
+ *
+ * @param model
+ * the model
+ * @param extension
+ * the extension
+ * @return the file name
+ * @throws ServiceException
+ * the service exception
+ */
+ public static String getFileName(EObject model, String extension) throws ServiceException {
+
+ Resource resource = model.eResource();
+ String resourcepath = resource.getURI().toString();
+ String umlFileName = resourcepath.substring(resourcepath.lastIndexOf("/") + 1, resourcepath.length());
+ return umlFileName;
+
+ }
+
+ /**
+ * Load resource.
+ *
+ * @param path
+ * the path
+ * @param resourceSet
+ * the resource set
+ * @return the resource
+ */
+ @SuppressWarnings("deprecation")
+ public static Resource loadResource(String path, ResourceSet resourceSet) {
+ //java.net.URL templateURL = Platform.getBundle(myPluginId).getResource(path);
+ //String fullUri = templateURL.getPath();
+ URI uri = URI.createPlatformResourceURI(path);
+ try {
+ Resource resource = resourceSet.getResource(uri, true);
+ if(resource.isLoaded()) {
+ return resource;
+ }
+ } catch (WrappedException ex) {
+ ex.printStackTrace();
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Search for a specific string in an xmi file and replace all its occurences by the new string.
+ *
+ * @param oldString
+ * the old uri
+ * @param newString
+ * the new uri
+ * @param adapter
+ * the adapter
+ * @param doc
+ * the doc
+ * @param offset
+ * the offset
+ * @param multiEdit
+ * the multi text edit
+ * @throws BadLocationException
+ * the bad location exception
+ */
+ public static void replaceString(String oldString, String newString, FindReplaceDocumentAdapter adapter, IDocument doc, int offset, MultiTextEdit multiEdit) throws BadLocationException {
+ IRegion region = adapter.find(offset, oldString, true, true, false, true);
+
+ if(region != null) {
+ multiEdit.addChild(new ReplaceEdit(region.getOffset(), region.getLength(), newString));
+ replaceString(oldString, newString, adapter, doc, region.getOffset() + region.getLength(), multiEdit);
+ //return new ReplaceEdit(region.getOffset(), region.getLength(), installedURI);
+ }
+
+
+ }
+
+
+ /**
+ * Copy.
+ *
+ * @param source
+ * the source
+ * @param target
+ * the target
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ */
+ public static void copy(InputStream source, File target) throws IOException {
+ if(!target.getParentFile().exists()) {
+ target.getParentFile().mkdirs();
+ }
+
+
+ OutputStream out = new FileOutputStream(target);
+
+
+ byte[] buf = new byte[1024];
+
+ int len;
+ try {
+ while((len = source.read(buf)) > 0) {
+
+ out.write(buf, 0, len);
+
+ }
+
+ } catch (IOException ex) {
+ throw ex;
+ } finally {
+
+ source.close();
+
+ out.close();
+ }
+ }
+
+
+ public static void copyFile(IProject project, File iconSrc, String destinationDir, String destFileName) {
+ // TODO Auto-generated method stub
+ File targetIconFile = FileUtil.getWorkspaceFile("/" + project.getName() + "/" + destinationDir + "/" + destFileName);
+
+ if(!targetIconFile.getParentFile().exists()) {
+ targetIconFile.getParentFile().mkdirs();
+
+ }
+ try {
+
+ WSFileUtil.copy(new FileInputStream(iconSrc), targetIconFile);
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+
+ }
+
+}

Back to the top