Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2016-02-11 21:38:52 +0000
committerChristian W. Damus2016-02-24 22:26:27 +0000
commit09fde7a4087685b065b7f1e40375686fb9f19f2a (patch)
tree36668c0515a08586179a74cefcf1dc6197311d70 /plugins/editor
parent2f0dd86c51f8543f56a99cd4371965a01287fcaa (diff)
downloadorg.eclipse.papyrus-09fde7a4087685b065b7f1e40375686fb9f19f2a.tar.gz
org.eclipse.papyrus-09fde7a4087685b065b7f1e40375686fb9f19f2a.tar.xz
org.eclipse.papyrus-09fde7a4087685b065b7f1e40375686fb9f19f2a.zip
Bug 485220: [Architecture] Provide a more modular architecture
https://bugs.eclipse.org/bugs/show_bug.cgi?id=485220 Implement version management: PDE API Tooling and Oomph Version Management. Introduce two new plug-in projects to manage versioning using Oomph: * org.eclipse.papyrus.releng.main.release for the Main bundles and features * org.eclipse.papyrus.releng.dev.release for the Dev Tools Add new menu actions to the Dev Tools: * main menu bar: * synchronize POM and manifest versions * "Configure" context menu on bundle projects and MANIFEST.MF * optimize bundle dependencies and re-exports * update dependency version ranges to match current workspace and PDE target Remove obsolete menu actions from the Dev Tools: * main menu bar: * Set all Papyrus feature versions * Set all Papyrus plug-in versions * Set versions of all Papyrus dependencies in Papyrus plug-ins Fix versioning errors reported by PDE and Oomph. Ensure proper version ranges consistent with latest build target. Optimize the dependencies of all Papyrus Main bundles and Dev Tools. Remove version- and reexport-checking tests in the BundlesTests that are now not needed because, on the one hand, we now implement discrete bundle versioning (managed by PDE/Oomph) and on the other, we now use re-exports properly to ensure classpath consistency in clients of a bundle's API. Thorough overhaul of the "project editors" API, including: * rationalize the API interfaces * refactor the all-in-one PluginEditor class from the customization bundle to the project-editors bundle * update clients in the Customization and DSML Validation components * fix a bunch of operations that didn't work * add missing operations required by the new Dev Tools actions * complete some unimplemented APIs * add a comprehensive JUnit test suite covering all of the project-editors API Change-Id: I6a699d93909f61099226ceb994140f03ea99a70f
Diffstat (limited to 'plugins/editor')
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/.classpath6
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/.project24
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/.settings/org.eclipse.jdt.core.prefs6
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/META-INF/MANIFEST.MF16
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/pom.xml4
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/Activator.java37
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/AbstractFileEditor.java75
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/BuildEditor.java144
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/BundlePropertiesEditor.java17
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/ClasspathEditor.java83
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/ManifestEditor.java713
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IBuildEditor.java8
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IClasspathEditor.java29
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IFeatureProjectEditor.java91
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IFileEditor.java19
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IJavaProjectEditor.java25
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IManifestEditor.java155
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IPluginEditor.java29
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IPluginProjectEditor.java2
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IProjectEditor.java21
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/ProjectEditors.java155
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/AbstractProjectEditor.java96
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/FeatureProjectEditor.java453
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/JavaProjectEditor.java149
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/PluginEditor.java369
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/PluginProjectEditor.java91
-rw-r--r--plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/ProjectEditor.java40
-rw-r--r--plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/.project80
-rw-r--r--plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/META-INF/MANIFEST.MF25
-rw-r--r--plugins/editor/org.eclipse.papyrus.editor/.project80
-rw-r--r--plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF33
31 files changed, 2021 insertions, 1054 deletions
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/.classpath b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/.classpath
index 49a283a34c3..eca7bdba8f0 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/.classpath
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/.classpath
@@ -1,7 +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.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
<classpathentry kind="src" path="src"/>
-</classpath> \ No newline at end of file
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/.project b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/.project
index a37a2764ede..3adca6c4f7c 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/.project
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/.project
@@ -20,9 +20,33 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.oomph.version.VersionBuilder</name>
+ <arguments>
+ <dictionary>
+ <key>check.maven.pom</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>ignore.lower.bound.dependency.ranges</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>release.path</key>
+ <value>/org.eclipse.papyrus.releng.main.release/release.xml</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ <nature>org.eclipse.oomph.version.VersionNature</nature>
</natures>
</projectDescription>
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/.settings/org.eclipse.jdt.core.prefs b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/.settings/org.eclipse.jdt.core.prefs
index c585cc455ae..b3aa6d60f94 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/META-INF/MANIFEST.MF b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/META-INF/MANIFEST.MF
index ccac5349524..b9714dff646 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/META-INF/MANIFEST.MF
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/META-INF/MANIFEST.MF
@@ -2,20 +2,16 @@ Manifest-Version: 1.0
Export-Package: org.eclipse.papyrus.eclipse.project.editors.file,
org.eclipse.papyrus.eclipse.project.editors.interfaces,
org.eclipse.papyrus.eclipse.project.editors.project
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0",
- org.eclipse.core.resources,
- org.eclipse.jdt.core,
- org.eclipse.papyrus.infra.widgets;bundle-version="1.2.0",
- org.eclipse.pde.ui;bundle-version="3.6.100",
- org.eclipse.emf.ecore;bundle-version="2.10.0"
+Require-Bundle: org.eclipse.jdt.core;bundle-version="[3.12.0,4.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.widgets;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.pde.core;bundle-version="[3.11.0,4.0.0)";visibility:=reexport,
+ org.eclipse.pde.ui;bundle-version="[3.9.0,4.0.0)"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 2.0.0.qualifier
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-Activator: org.eclipse.papyrus.eclipse.project.editors.Activator
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.papyrus.eclipse.project.editors
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/pom.xml b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/pom.xml
index 872d5ce559d..4b1502b4f2d 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/pom.xml
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/pom.xml
@@ -7,6 +7,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.eclipse.project.editors</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
-</project>
+</project> \ No newline at end of file
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/Activator.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/Activator.java
index db1f9227ddb..e6f578de4c0 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/Activator.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/Activator.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,13 +8,16 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 485220
*
*****************************************************************************/
package org.eclipse.papyrus.eclipse.project.editors;
import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.pde.core.project.IBundleProjectService;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
/**
* The activator class controls the plug-in life cycle
@@ -30,35 +32,30 @@ public class Activator extends AbstractUIPlugin {
public static LogHelper log;
+ private ServiceTracker<IBundleProjectService, IBundleProjectService> bundleProjectService;
+
/**
* The constructor
*/
public Activator() {
+ super();
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
- * )
- */
@Override
public void start(final BundleContext context) throws Exception {
super.start(context);
plugin = this;
log = new LogHelper(this);
+
+ bundleProjectService = new ServiceTracker<>(context, IBundleProjectService.class, null);
+ bundleProjectService.open();
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
- * )
- */
@Override
public void stop(final BundleContext context) throws Exception {
+ bundleProjectService.close();
+ bundleProjectService = null;
+
plugin = null;
super.stop(context);
}
@@ -72,4 +69,12 @@ public class Activator extends AbstractUIPlugin {
return plugin;
}
+ /**
+ * Obtains the PDE's bundle project service, if available.
+ *
+ * @return the bundle project service, or {@code null} if none
+ */
+ public IBundleProjectService getBundleProjectService() {
+ return bundleProjectService.getService();
+ }
}
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/AbstractFileEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/AbstractFileEditor.java
index 2fbe4dd44a1..7279d4d4e8c 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/AbstractFileEditor.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/AbstractFileEditor.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +8,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 485220
*
*****************************************************************************/
package org.eclipse.papyrus.eclipse.project.editors.file;
@@ -33,6 +33,7 @@ public abstract class AbstractFileEditor implements IFileEditor {
/** the Eclipse Project */
private final IProject project;
+ private boolean dirty;
/**
*
@@ -48,28 +49,19 @@ public abstract class AbstractFileEditor implements IFileEditor {
/**
*
* @return
- * the eclipse project
+ * the eclipse project
*/
+ @Override
public IProject getProject() {
return this.project;
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.AbstractProjectEditor#init()
- *
- * {@inheritDoc}
- */
+ @Override
public void init() {
-
+ // Pass
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IProjectEditor#getMissingFiles()
- *
- * {@inheritDoc}
- */
+ @Override
public Set<String> getMissingFiles() {
return new HashSet<String>();
}
@@ -79,7 +71,7 @@ public abstract class AbstractFileEditor implements IFileEditor {
* @param text
* the initial text
* @return
- * an input stream
+ * an input stream
*/
protected InputStream getInputStream(final String text) {
if (text == null) {
@@ -99,24 +91,49 @@ public abstract class AbstractFileEditor implements IFileEditor {
return is;
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.AbstractProjectEditor.plugin.AbstractEditor#exists()
- *
- * {@inheritDoc}
- */
+ @Override
public boolean exists() {
return getMissingFiles().size() == 0;
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IFileEditor#create()
- *
- * {@inheritDoc}
- */
+ @Override
public void create() {
createFiles(getMissingFiles());
init();
}
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public boolean isDirty() {
+ return dirty;
+ }
+
+ /**
+ * Marks me {@linkplain #isDirty() dirty}.
+ *
+ * @since 2.0
+ */
+ protected final void touch() {
+ this.dirty = true;
+ }
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public final void save() {
+ if (isDirty()) {
+ doSave();
+ dirty = false;
+ }
+ }
+
+ /**
+ * Implemented by subclasses to perform the save behaviour.
+ *
+ * @since 2.0
+ */
+ protected abstract void doSave();
}
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/BuildEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/BuildEditor.java
index cfb832ef2d3..6fba9a140a7 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/BuildEditor.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/BuildEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,31 +9,34 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Vincent Lorenzo (CEA-LIST) vincent.lorenzo@cea.fr
+ * Christian W. Damus - bug 485220
+ *
*****************************************************************************/
package org.eclipse.papyrus.eclipse.project.editors.file;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.Set;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.ecore.resource.impl.PlatformResourceURIHandlerImpl;
import org.eclipse.papyrus.eclipse.project.editors.Activator;
import org.eclipse.papyrus.eclipse.project.editors.interfaces.IBuildEditor;
-import org.eclipse.papyrus.infra.widgets.util.FileUtil;
public class BuildEditor extends AbstractFileEditor implements IBuildEditor {
/** the build config */
private Properties buildConfig;
- /** the buidl file */
- private File buildFile;
+ /** the build file */
+ private IFile buildFile;
/**
* The build key to edit
@@ -50,7 +53,7 @@ public class BuildEditor extends AbstractFileEditor implements IBuildEditor {
* the eclipse project
*/
public BuildEditor(final IProject project) {
- super(project);
+ this(project, null);
}
/**
@@ -67,49 +70,35 @@ public class BuildEditor extends AbstractFileEditor implements IBuildEditor {
*/
public BuildEditor(final IProject project, String buildKey) {
super(project);
+
+ buildFile = project.getFile(BUILD_PROPERTIES_FILE);
if (buildKey != null) {
this.buildKey = buildKey;
}
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.ProjectEditor#init()
- *
- * {@inheritDoc}
- */
@Override
public void init() {
this.buildConfig = new Properties();
- this.buildFile = getBuildProperties();
- if (this.buildFile != null && this.buildFile.exists()) {
- try {
- this.buildConfig.load(new FileInputStream(this.buildFile));
- } catch (FileNotFoundException e) {
- Activator.log.error(e);
+ if (this.buildFile.exists()) {
+ try (InputStream input = this.buildFile.getContents()) {
+ this.buildConfig.load(input);
+ } catch (CoreException e) {
+ Activator.log.log(e.getStatus());
} catch (IOException e) {
Activator.log.error(e);
}
}
}
-
- private File getBuildProperties() {
- return this.buildFile = FileUtil.getWorkspaceFile("/" + getProject().getName() + "/" + BUILD_PROPERTIES_FILE); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IBuildEditor#addToBuild(java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public void addToBuild(final String path) {
if (exists()) {
String currentValue = this.buildConfig.getProperty(buildKey);
if (Arrays.asList(getElementsInBuild()).contains(path)) {
return;
}
+ touch();
if (currentValue == null || currentValue.trim().equals("")) { //$NON-NLS-1$
this.buildConfig.setProperty(buildKey, path);
} else {
@@ -118,14 +107,11 @@ public class BuildEditor extends AbstractFileEditor implements IBuildEditor {
}
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IBuildEditor#removeFromBuild(java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public void removeFromBuild(String path) {
if (isRegisteredSourceFolder(path)) {
+ touch();
+
// Get the files from the build
List<String> allFiles = Arrays.asList(getElementsInBuild());
@@ -141,19 +127,11 @@ public class BuildEditor extends AbstractFileEditor implements IBuildEditor {
}
}
- /**
- *
- * @throws Throwable
- * @see org.eclipse.papyrus.eclipse.project.editors.project.ProjectEditor#save()
- *
- * {@inheritDoc}
- */
- public void save() {
+ @Override
+ protected void doSave() {
if (exists()) {
- try {
- this.buildConfig.store(new FileOutputStream(this.buildFile), "");
- } catch (FileNotFoundException ex) {
- Activator.log.error(ex);
+ try (OutputStream output = new PlatformResourceURIHandlerImpl.PlatformResourceOutputStream(this.buildFile, false, true, null)) {
+ this.buildConfig.store(output, ""); //$NON-NLS-1$
} catch (IOException ex) {
Activator.log.error(ex);
}
@@ -161,14 +139,11 @@ public class BuildEditor extends AbstractFileEditor implements IBuildEditor {
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IBuildEditor#registerSourceFolder(java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public void registerSourceFolder(final String path) {
if (exists() && !isRegisteredSourceFolder(path)) {
+ touch();
+
String currentValue = this.buildConfig.getProperty(SOURCE_FOLDER_KEY);
if (currentValue == null || currentValue.trim().equals("")) { //$NON-NLS-1$
this.buildConfig.setProperty(SOURCE_FOLDER_KEY, path);
@@ -178,37 +153,21 @@ public class BuildEditor extends AbstractFileEditor implements IBuildEditor {
}
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IBuildEditor#isRegistred(java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public boolean isRegisteredSourceFolder(final String path) {
return Arrays.asList(getSourceFolders()).contains(path);
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.file.AbstractFileEditor#getMissingFiles()
- *
- * {@inheritDoc}
- */
@Override
public Set<String> getMissingFiles() {
Set<String> files = super.getMissingFiles();
- if (!getBuildProperties().exists()) {
+ if (!this.buildFile.exists()) {
files.add(BUILD_PROPERTIES_FILE);
}
return files;
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IBuildEditor#getSourceFolders()
- *
- * {@inheritDoc}
- */
+ @Override
public String[] getSourceFolders() {
if (exists()) {
String currentValue = this.buildConfig.getProperty(SOURCE_FOLDER_KEY, "").replaceAll("\t|\r|\n", "").trim();
@@ -218,45 +177,26 @@ public class BuildEditor extends AbstractFileEditor implements IBuildEditor {
return new String[0];
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.AbstractProjectEditor#exists()
- *
- * {@inheritDoc}
- */
@Override
public boolean exists() {
- return this.buildFile.getParentFile().exists() && this.buildFile.exists() && super.exists();
+ return super.exists() && this.buildFile.exists();
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.ProjectEditor#createFiles(Set)
- *
- * {@inheritDoc}
- */
+ @Override
public void createFiles(final Set<String> files) {
if (files.contains(BUILD_PROPERTIES_FILE)) {
if (!this.buildFile.exists()) {
- if (!this.buildFile.getParentFile().exists()) {
- this.buildFile.getParentFile().mkdirs();
- }
try {
- this.buildFile.createNewFile();
+ this.buildFile.create(new ByteArrayInputStream(new byte[0]), false, null);
init();
- } catch (IOException e) {
- Activator.log.error(e);
+ } catch (CoreException e) {
+ Activator.log.log(e.getStatus());
}
}
}
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IBuildEditor#getElementsInBuild()
- *
- * {@inheritDoc}
- */
+ @Override
public String[] getElementsInBuild() {
String value = this.buildConfig.getProperty(buildKey);
return splitValues(value);
@@ -269,11 +209,14 @@ public class BuildEditor extends AbstractFileEditor implements IBuildEditor {
return value.replace("\t|\r|\n", "").split(","); //$NON-NLS-1$ //$NON-NLS-2$
}
+ @Override
public void registerBinFolder(String binFolder) {
if (isRegisteredBinFolder(binFolder)) {
return;
}
+ touch();
+
String value = this.buildConfig.getProperty(BIN_KEY, ""); //$NON-NLS-1$
if (value.trim().equals("")) { //$NON-NLS-1$
value = binFolder;
@@ -283,6 +226,7 @@ public class BuildEditor extends AbstractFileEditor implements IBuildEditor {
this.buildConfig.setProperty(BIN_KEY, value);
}
+ @Override
public boolean isRegisteredBinFolder(String binFolder) {
List<String> folders = Arrays.asList(splitValues(this.buildConfig.getProperty(BIN_KEY, ""))); //$NON-NLS-1$
return folders.contains(binFolder);
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/BundlePropertiesEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/BundlePropertiesEditor.java
index ba870790e50..56b5434941a 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/BundlePropertiesEditor.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/BundlePropertiesEditor.java
@@ -1,3 +1,16 @@
+/*****************************************************************************
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 485220
+ *
+ *****************************************************************************/
package org.eclipse.papyrus.eclipse.project.editors.file;
import java.io.File;
@@ -42,12 +55,14 @@ public class BundlePropertiesEditor extends AbstractFileEditor {
// }
}
+ @Override
public void createFiles(Set<String> files) {
// TODO Auto-generated method stub
}
- public void save() {
+ @Override
+ protected void doSave() {
// TODO Auto-generated method stub
}
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/ClasspathEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/ClasspathEditor.java
index e16d91c449f..5ad206efb32 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/ClasspathEditor.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/ClasspathEditor.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -10,6 +9,7 @@
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr
+ * Christian W. Damus - bug 485220
*
*****************************************************************************/
package org.eclipse.papyrus.eclipse.project.editors.file;
@@ -27,14 +27,10 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IAccessRule;
-import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.internal.core.ClasspathEntry;
import org.eclipse.papyrus.eclipse.project.editors.Activator;
import org.eclipse.papyrus.eclipse.project.editors.interfaces.IClasspathEditor;
@@ -75,16 +71,7 @@ public class ClasspathEditor extends AbstractFileEditor implements IClasspathEdi
}
@Override
- public void init() {
- // nothing to do here
- }
-
- /**
- * save the modification
- *
- * @throws Throwable
- */
- public void save() {
+ protected void doSave() {
try {
this.javaProject.save(new NullProgressMonitor(), true);
} catch (JavaModelException ex) {
@@ -92,29 +79,26 @@ public class ClasspathEditor extends AbstractFileEditor implements IClasspathEdi
}
}
+ @Override
+ public void addSourceFolderToClasspath(final String folderPath) {
+ addSourceFolderToClasspath(folderPath, null);
+ }
+
/**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IClasspathEditor#addSourceFolderToClasspath(java.lang.String)
- *
- * {@inheritDoc}
+ * @since 2.0
*/
- public void addSourceFolderToClasspath(final String folderPath) {
+ @Override
+ public void addSourceFolderToClasspath(final String srcPath, final String binPath) {
- if (exists() && !isSourceFolderRegistered(folderPath)) {
+ if (exists() && !isSourceFolderRegistered(srcPath)) {
+ touch();
// parameters for the new ClasspathEntry
- boolean isExported = false;
IPath[] exclusionPatterns = new IPath[0];
- IPath sourceAttachmentPath = null;
- IPath specificOutputLocation = null;
- boolean combineAccessRules = false;
- IClasspathAttribute[] extraAttributes = new IClasspathAttribute[0];
- IPath sourceAttachmentRootPath = null;
- IAccessRule[] accessRules = null;
- int contentKind = IPackageFragmentRoot.K_SOURCE;
- IPath[] inclusionPatterns = new IPath[0];
- int entryKind = IClasspathEntry.CPE_SOURCE;
- IPath path2 = new Path(folderPath);
+ IPath absoluteSourcePath = javaProject.getPath().append(srcPath).addTrailingSeparator();
+ IPath specificOutputLocation = (binPath == null)
+ ? null
+ : javaProject.getPath().append(binPath).addTrailingSeparator();
IClasspathEntry[] classpathes = null;
try {
@@ -127,8 +111,10 @@ public class ClasspathEditor extends AbstractFileEditor implements IClasspathEdi
for (int i = 0; i < classpathes.length; i++) {
entries[i] = classpathes[i];
}
- entries[classpathes.length] = new ClasspathEntry(contentKind, entryKind, path2, inclusionPatterns, exclusionPatterns, sourceAttachmentPath, sourceAttachmentRootPath, specificOutputLocation, isExported, accessRules, combineAccessRules,
- extraAttributes);
+ entries[classpathes.length] = JavaCore.newSourceEntry(
+ absoluteSourcePath,
+ exclusionPatterns,
+ specificOutputLocation);
try {
this.javaProject.setRawClasspath(entries, new NullProgressMonitor());
} catch (JavaModelException e) {
@@ -137,24 +123,20 @@ public class ClasspathEditor extends AbstractFileEditor implements IClasspathEdi
}
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IClasspathEditor#isSourceFolderRegistered(java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public boolean isSourceFolderRegistered(final String folderPath) {
IClasspathEntry[] entries = null;
try {
entries = this.javaProject.getRawClasspath();
} catch (JavaModelException e) {
Activator.log.error(e);
+ return false;
}
for (int i = 0; i < entries.length; i++) {
IClasspathEntry entry = entries[i];
if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
- if (entry.getPath().equals(new Path(folderPath))) {
+ if (entry.getPath().makeRelativeTo(javaProject.getPath()).equals(new Path(folderPath))) {
return true;
}
}
@@ -175,12 +157,6 @@ public class ClasspathEditor extends AbstractFileEditor implements IClasspathEdi
return classpath.exists();
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.ProjectEditor#getMissingFiles()
- *
- * {@inheritDoc}
- */
@Override
public Set<String> getMissingFiles() {
Set<String> files = super.getMissingFiles();
@@ -191,12 +167,7 @@ public class ClasspathEditor extends AbstractFileEditor implements IClasspathEdi
return files;
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.ProjectEditor#createFiles(Set)
- *
- * {@inheritDoc}
- */
+ @Override
public void createFiles(final Set<String> files) {
if (files.contains(CLASSPATH_FILE)) {
IFile classpath = getProject().getFile(CLASSPATH_FILE);
@@ -212,6 +183,7 @@ public class ClasspathEditor extends AbstractFileEditor implements IClasspathEdi
}
}
+ @Override
public String[] getSourceFolders() {
List<String> sourceFolders = new LinkedList<String>();
IClasspathEntry[] entries = null;
@@ -231,6 +203,7 @@ public class ClasspathEditor extends AbstractFileEditor implements IClasspathEdi
return sourceFolders.toArray(new String[sourceFolders.size()]);
}
+ @Override
public String[] getBinFolders() {
List<String> binFolders = new LinkedList<String>();
try {
@@ -251,7 +224,7 @@ public class ClasspathEditor extends AbstractFileEditor implements IClasspathEdi
if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
if (entry.getOutputLocation() != null) {
// Bin folder associated to each source folder
- binFolders.add(entry.getOutputLocation().makeRelativeTo(javaProject.getPath()).toString());
+ binFolders.add(entry.getOutputLocation().makeRelativeTo(javaProject.getPath()).removeTrailingSeparator().toString());
}
}
}
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/ManifestEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/ManifestEditor.java
index 91767d21074..253eba79c47 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/ManifestEditor.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/file/ManifestEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 485220
+ *
*****************************************************************************/
package org.eclipse.papyrus.eclipse.project.editors.file;
@@ -15,19 +17,34 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
import java.util.Set;
+import java.util.function.BiFunction;
+import java.util.function.Predicate;
import java.util.jar.Attributes;
-import java.util.jar.Attributes.Name;
import java.util.jar.Manifest;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.osgi.service.resolver.VersionRange;
import org.eclipse.papyrus.eclipse.project.editors.Activator;
import org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor;
import org.eclipse.papyrus.eclipse.project.editors.project.ProjectEditor;
+import org.eclipse.pde.core.project.IBundleProjectService;
+import org.eclipse.pde.core.project.IPackageImportDescription;
+import org.eclipse.pde.core.project.IRequiredBundleDescription;
public class ManifestEditor extends ProjectEditor implements IManifestEditor {
@@ -40,7 +57,12 @@ public class ManifestEditor extends ProjectEditor implements IManifestEditor {
private static final String COMMA = ","; //$NON-NLS-1$
- private static final String ASSIGN = "="; //$NON-NLS-1$
+ // Pattern for splitting on commas that are not within version ranges
+ private static final String COMMA_SPLIT = ",(?!\\s*\\d)"; //$NON-NLS-1$
+
+ private static final String EQUALS = "="; //$NON-NLS-1$
+
+ private static final String ASSIGN = ":="; //$NON-NLS-1$
private static final String BUNDLE_SYMBOLIC_NAME = "Bundle-SymbolicName"; //$NON-NLS-1$
@@ -50,11 +72,17 @@ public class ManifestEditor extends ProjectEditor implements IManifestEditor {
private static final String SINGLETON = "singleton:="; //$NON-NLS-1$
+ private static final String VISIBILITY = "visibility"; //$NON-NLS-1$
+
+ private static final String REEXPORT = "reexport"; //$NON-NLS-1$
+
+ private static final String VERSION = "version"; //$NON-NLS-1$
+
/** the manifest file */
private IFile manifestFile;
/** the manifest itself */
- private Manifest manifest;
+ private Optional<Manifest> manifest = Optional.empty();
/**
*
@@ -68,36 +96,18 @@ public class ManifestEditor extends ProjectEditor implements IManifestEditor {
super(project);
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#initOk()
- *
- * {@inheritDoc}
- */
public boolean initOk() {
- return manifest != null && manifestFile != null;
+ return manifest.isPresent() && (manifestFile != null);
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#addDependency(java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public void addDependency(final String dependency) {
addDependency(dependency, null);
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.ProjectEditor#init()
- *
- * {@inheritDoc}
- */
@Override
public void init() {
- super.init();
- if (manifest != null && manifestFile != null) {
+ if (initOk()) {
return;
}
if (manifestFile == null) {
@@ -105,7 +115,7 @@ public class ManifestEditor extends ProjectEditor implements IManifestEditor {
}
if (manifestFile != null) {
try {
- manifest = new Manifest(manifestFile.getContents());
+ manifest = Optional.of(new Manifest(manifestFile.getContents()));
} catch (final IOException e) {
Activator.log.error(e);
// assure that exception is not silently captured (for users not examining the error log)
@@ -119,124 +129,222 @@ public class ManifestEditor extends ProjectEditor implements IManifestEditor {
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#addDependency(java.lang.String, java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public void addDependency(final String dependency, final String version) {
- final Name rqBundle = new Name(REQUIRED_BUNDLE);
- String requireBundle = manifest.getMainAttributes().getValue(rqBundle);
-
- // TODO : Improve the detection of existing dependency
- // If a.b.c exists, then a.b cannot be added (Because it is already contained)
- // Moreover, the Manifest allows newlines anywhere (Including in the
- // middle of a word) : check if these newlines appear in this map,
- // or if they have already been parsed. If the manifest value is copied as-is in the map,
- // then we need to take care of newlines when parsing it
+ if (hasDependency(dependency)) {
+ // Easy case: Just update the version
+ Map<String, String> attributes = (version == null)
+ ? null
+ : Collections.singletonMap("bundle-version", version); //$NON-NLS-1$
+ updateDependencies(dependency::equals, attributes, null);
+ } else {
+ // Only slightly more difficult case: Add the new dependency
+ String newDependency = (version == null)
+ ? dependency
+ : String.format("%s;bundle-version=\"%s\"", dependency, version); //$NON-NLS-1$
- if (requireBundle == null) {
- requireBundle = dependency;
+ String requireBundle = getMainAttribute(REQUIRED_BUNDLE)
+ .map(rb -> rb + COMMA + newDependency)
+ .orElse(newDependency);
- if (version != null) {
- requireBundle += SEMICOLON + "bundle-version=\"" + version + "\"";
- }
- } else if (!requireBundle.contains(dependency)) {
- requireBundle += COMMA + dependency;
- // TODO: Update version
+ setMainAttribute(REQUIRED_BUNDLE, requireBundle);
}
+ }
- manifest.getMainAttributes().put(rqBundle, requireBundle);
+ @Override
+ public boolean hasDependency(final String dependency) {
+ // Match a dependency if it is
+ // (a) preceded by another dependency or the beginning of the input, AND
+ // (b) followed by another dependency or an attribute/directive or the end of the input
+ Pattern namePattern = Pattern.compile(String.format("(?<=^|,)\\Q%s\\E(?=,|;|$)", dependency)); //$NON-NLS-1$
+ return getMainAttribute(REQUIRED_BUNDLE)
+ .map(rb -> namePattern.matcher(rb).find()) // $NON-NLS-1$
+ .orElse(false);
}
/**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#hasDependency(java.lang.String)
- *
- * {@inheritDoc}
+ * @since 2.0
*/
- public boolean hasDependency(final String dependency) {
- final Name rqBundle = new Name(REQUIRED_BUNDLE);
- String requireBundle = manifest.getMainAttributes().getValue(rqBundle);
- return requireBundle != null && requireBundle.contains(dependency);
+ public boolean hasPackage(final String packageName, final String type) {
+ // Match a package if it is
+ // (a) preceded by another dependency or the beginning of the input, AND
+ // (b) followed by another dependency or an attribute/directive or the end of the input
+ Pattern namePattern = Pattern.compile(String.format("(?<=^|,)\\Q%s\\E(?=,|;|$)", packageName)); //$NON-NLS-1$
+ return getMainAttribute(type)
+ .map(ip -> namePattern.matcher(ip).find()) // $NON-NLS-1$
+ .orElse(false);
}
+ @Override
+ @Deprecated
public void setDependenciesVersion(final String dependencyPattern, final String newVersion) {
- final Name rqBundle = new Name(REQUIRED_BUNDLE);
- final String requireBundles = manifest.getMainAttributes().getValue(rqBundle);
- final String[] bundles = requireBundles.split(COMMA);
- String newRequiredBundles = ""; //$NON-NLS-1$
- for (int ii = 0; ii < bundles.length; ii++) {// we iterate on the declared dependencies
- final String currentDependency = bundles[ii];
- final String[] dependencyValue = currentDependency.split(SEMICOLON);
- if (dependencyValue[0].contains(dependencyPattern)) {
- final String newBundleVersion = BUNDLE_VERSION + ASSIGN + '"' + newVersion + '"';
- newRequiredBundles += dependencyValue[0] + SEMICOLON + newBundleVersion;
- for (int i = 1; i < dependencyValue.length; i++) {
- final String declaration = dependencyValue[i];
- if (declaration.contains(BUNDLE_VERSION + ASSIGN)) {
- // we ignore it
- } else {
- newRequiredBundles += SEMICOLON + dependencyValue[i];// we add the others declaration
+ updateDependencies(
+ name -> name.contains(dependencyPattern), // Update dependencies like this
+ Collections.singletonMap("bundle-version", newVersion), // To have this version attribute
+ null); // And don't change directives such as optionality
+ }
+
+ private void updateDependencies(Predicate<String> predicate, Map<String, String> attributes, Map<String, String> directives) {
+ updateHeader(REQUIRED_BUNDLE, predicate, attributes, directives);
+ }
+
+ private void updatePackages(Predicate<String> predicate, String type, Map<String, String> attributes, Map<String, String> directives) {
+ updateHeader(type, predicate, attributes, directives);
+ }
+
+ private void updateHeader(String headerName, Predicate<String> predicate, Map<String, String> attributes, Map<String, String> directives) {
+ // Match an attribute or directive, capturing:
+ // 1 - the attribute/directive name
+ // 2 - the equality/assignment operator
+ // 3 - the quotation delimiter, if any
+ Pattern attributeOrDirective = Pattern.compile("([^:]+)(:?=)([\"']?).*\\3");
+
+ transformHeader(headerName, predicate, (dependency, attrs) -> {
+ StringBuilder result = new StringBuilder();
+
+ Map<String, String> newAttributes = (attributes == null) ? Collections.emptyMap() : new HashMap<>(attributes);
+ Map<String, String> newDirectives = (directives == null) ? Collections.emptyMap() : new HashMap<>(directives);
+ result.append(dependency);
+
+ for (String next : attrs) {
+ Matcher m = attributeOrDirective.matcher(next);
+
+ if (!m.matches()) {
+ // Unexpected formulation. Just append it as is
+ result.append(SEMICOLON).append(next);
+ } else {
+ String name = m.group(1);
+ boolean explicit = newAttributes.containsKey(name) || newDirectives.containsKey(name);
+ String value = newAttributes.remove(name);
+ if (value == null) {
+ value = newDirectives.remove(name);
}
+
+ if (value != null) {
+ // Replace this attribute or directive
+ result.append(SEMICOLON);
+ result.append(name).append(m.group(2));
+ result.append(m.group(3)).append(value).append(m.group(3));
+ } else if (!explicit) {
+ // Just append it as is
+ result.append(SEMICOLON).append(m.group());
+ } // else an explicit null value: remove the attribute or directive
}
- } else {
- newRequiredBundles += currentDependency;// we copy the existing declaration
}
- if (ii < bundles.length - 1) {
- newRequiredBundles += COMMA;
+
+ // Left-overs
+ for (Map.Entry<String, String> next : newAttributes.entrySet()) {
+ result.append(SEMICOLON);
+ result.append(next.getKey()).append(EQUALS).append('"').append(next.getValue()).append('"');
+ }
+ for (Map.Entry<String, String> next : newDirectives.entrySet()) {
+ result.append(SEMICOLON);
+ result.append(next.getKey()).append(ASSIGN).append(next.getValue());
+ }
+
+ return result.toString();
+ });
+ }
+
+ private void transformDependencies(Predicate<String> predicate, BiFunction<String, List<String>, String> transformation) {
+ transformHeader(REQUIRED_BUNDLE, predicate, transformation);
+ }
+
+ private void transformImportedPackages(Predicate<String> predicate, BiFunction<String, List<String>, String> transformation) {
+ transformHeader(IMPORT_PACKAGE, predicate, transformation);
+ }
+
+ private void transformHeader(String headerName, Predicate<String> predicate, BiFunction<String, List<String>, String> transformation) {
+ final String entryList = getMainAttribute(headerName).orElse(""); //$NON-NLS-1$
+ final String[] entries = entryList.isEmpty() ? new String[0] : entryList.split(COMMA_SPLIT);
+ StringBuilder newEntryList = new StringBuilder();
+ for (int i = 0; i < entries.length; i++) {// we iterate on the declared dependencies
+ String entry = entries[i];
+ List<String> parts = Arrays.asList(entry.split(SEMICOLON));
+ String dependencyName = parts.get(0);
+
+ if (!predicate.test(dependencyName)) {
+ // Retain this one as is
+ if (newEntryList.length() > 0) {
+ newEntryList.append(COMMA);
+ }
+ newEntryList.append(entry);
+ } else {
+ String transformed = transformation.apply(dependencyName, parts.subList(1, parts.size()));
+ if (transformed != null) {
+ if (newEntryList.length() > 0) {
+ newEntryList.append(COMMA);
+ }
+ newEntryList.append(transformed);
+ }
}
}
- setValue(REQUIRED_BUNDLE, newRequiredBundles);
+ setMainAttribute(headerName, (newEntryList.length() == 0) ? null : newEntryList.toString());
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#setValue(java.lang.String, java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public void setValue(final String key, final String value) {
- setValue(key, "", value); //$NON-NLS-1$
+ setMainAttribute(key, value);
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#setValue(java.lang.String, java.lang.String, java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public void setValue(final String key, final String name, final String value) {
- manifest.getMainAttributes().putValue(key, value);
- // this.manifest.getAttributes(key).put(name, value);
+ setAttribute(key, name, value);
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#removeValue(java.lang.String, java.lang.String)
- *
- * {@inheritDoc}
- */
- public void removeValue(final String key, final String value) {
+ void setMainAttribute(String name, String value) {
+ if (value == null) {
+ removeMainAttribute(name);
+ } else {
+ manifest.map(Manifest::getMainAttributes).ifPresent(attrs -> {
+ if (!Objects.equals(attrs.getValue(name), value)) {
+ touch();
+ attrs.putValue(name, value);
+ }
+ });
+ }
+ }
+ void setAttribute(String section, String name, String value) {
+ if (value == null) {
+ removeAttribute(section, name);
+ } else {
+ manifest.map(m -> m.getAttributes(section)).ifPresent(attrs -> {
+ if (!Objects.equals(attrs.getValue(name), value)) {
+ touch();
+ attrs.putValue(name, value);
+ }
+ });
+ }
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#removeValue(java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
+ public void removeValue(final String section, final String name) {
+ removeAttribute(section, name);
+ }
+
+ @Override
public void removeValue(final String key) {
- manifest.getAttributes(key).remove(key);
+ removeMainAttribute(key);
+ }
+
+ void removeMainAttribute(String name) {
+ manifest.map(m -> m.getMainAttributes()).ifPresent(attrs -> {
+ if (attrs.remove(new Attributes.Name(name)) != null) {
+ touch();
+ }
+ });
+ }
+
+ void removeAttribute(String section, String name) {
+ manifest.map(m -> m.getAttributes(section)).ifPresent(attrs -> {
+ if (attrs.remove(new Attributes.Name(name)) != null) {
+ touch();
+ }
+ });
}
- /**
- *
- * @return
- */
private IFile getManifestFile() {
final IFile manifest = getProject().getFile("META-INF/MANIFEST.MF"); //$NON-NLS-1$
if (manifest.exists()) {
@@ -245,44 +353,36 @@ public class ManifestEditor extends ProjectEditor implements IManifestEditor {
return null;
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.AbstractProjectEditor#exists()
- *
- * {@inheritDoc}
- */
@Override
public boolean exists() {
return super.exists() && getManifestFile() != null && getSymbolicBundleName() != null && getBundleVersion() != null;
}
/**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.ProjectEditor#save()
- *
- * {@inheritDoc}
+ * @since 2.0
*/
@Override
- public void save() {
-
- final ByteArrayOutputStream os = new ByteArrayOutputStream();
+ protected void doSave() {
+ if (manifest.isPresent()) {
+ final ByteArrayOutputStream os = new ByteArrayOutputStream();
- try {
- manifest.write(os);
+ try {
+ manifest.get().write(os);
- final StringReader reader = new StringReader(format(os.toString("UTF-8"))); //$NON-NLS-1$
- manifestFile.setContents(new InputStream() {
+ final StringReader reader = new StringReader(format(os.toString("UTF-8"))); //$NON-NLS-1$
+ manifestFile.setContents(new InputStream() {
- @Override
- public int read() throws IOException {
- return reader.read();
- }
- }, true, true, null);
+ @Override
+ public int read() throws IOException {
+ return reader.read();
+ }
+ }, true, true, null);
- } catch (final IOException ex) {
- Activator.log.error(ex);
- } catch (final CoreException ex) {
- Activator.log.error(ex);
+ } catch (final IOException ex) {
+ Activator.log.error(ex);
+ } catch (final CoreException ex) {
+ Activator.log.error(ex);
+ }
}
}
@@ -297,8 +397,8 @@ public class ManifestEditor extends ProjectEditor implements IManifestEditor {
for (String line : lines) {
non72safe += line;
}
- // 2. split lines on comma
- lines = non72safe.split(COMMA);
+ // 2. split lines on comma (but not within version ranges)
+ lines = non72safe.split(",(?!\\s*\\d)");
String newText = ""; //$NON-NLS-1$
for (int i = 0; i < lines.length; i++) {
newText += lines[i].trim();
@@ -319,19 +419,13 @@ public class ManifestEditor extends ProjectEditor implements IManifestEditor {
return files;
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.ProjectEditor#createFiles(java.util.Set)
- *
- * {@inheritDoc}
- */
@Override
public void createFiles(final Set<String> files) {
if (files.contains(MANIFEST_PATH)) {
manifestFile = getProject().getFile(MANIFEST_PATH);
if (!manifestFile.exists()) {
try {
- final String input = "Manifest-Version: 1.0\n"; //without the "/n", it doesn't work!!!!! //$NON-NLS-1$
+ final String input = "Manifest-Version: 1.0\n"; // without the "/n", it doesn't work!!!!! //$NON-NLS-1$
if (!manifestFile.getParent().exists()) {
final IContainer parent = manifestFile.getParent();
if (parent instanceof IFolder) {
@@ -354,162 +448,106 @@ public class ManifestEditor extends ProjectEditor implements IManifestEditor {
Activator.log.error(ex);
}
}
- }
- try {
- manifest = new Manifest(manifestFile.getContents());
- } catch (IOException e) {
- Activator.log.error(e);
- } catch (CoreException e) {
- Activator.log.error(e);
- }
+ try (InputStream contents = manifestFile.getContents()) {
+ manifest = Optional.of(new Manifest(contents));
+ } catch (IOException e) {
+ Activator.log.error(e);
+ } catch (CoreException e) {
+ Activator.log.error(e);
+ }
- if (getSymbolicBundleName() == null) {
- setSymbolicBundleName(getProject().getName());
- }
+ if (getSymbolicBundleName() == null) {
+ setSymbolicBundleName(getProject().getName());
+ }
- if (getBundleVersion() == null) {
- setBundleVersion("0.0.1"); //$NON-NLS-1$
+ if (getBundleVersion() == null) {
+ setBundleVersion("0.0.1"); //$NON-NLS-1$
+ }
}
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#setSymbolicBundleName(java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public void setSymbolicBundleName(String newName) {
if (newName == null) {
newName = "noName"; //$NON-NLS-1$
}
- final Name symbolicName = new Name(BUNDLE_SYMBOLIC_NAME);
- manifest.getMainAttributes().put(symbolicName, newName);
+ setMainAttribute(BUNDLE_SYMBOLIC_NAME, newName);
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#getSymbolicBundleName()
- *
- * {@inheritDoc}
- */
+ @Override
public String getSymbolicBundleName() {
- if (manifest != null) {
- final Name symbolicName = new Name(BUNDLE_SYMBOLIC_NAME);
- final String name = manifest.getMainAttributes().getValue(symbolicName);
-
- if (name != null) {
- int semiColon = name.indexOf(SEMICOLON);
- return semiColon != -1 ? name.substring(0, semiColon) : name;
- }
- }
-
- return null;
+ // Without the <String> hint, javac balks but JDT does not
+ return getMainAttribute(BUNDLE_SYMBOLIC_NAME)
+ .<String> map(name -> {
+ int semiColon = name.indexOf(SEMICOLON);
+ return semiColon >= 0 ? name.substring(0, semiColon) : name;
+ }).orElse(null);
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#getBundleVersion()
- *
- * {@inheritDoc}
- */
+ @Override
public String getBundleVersion() {
- if (manifest != null) {
- final Name symbolicName = new Name(BUNDLE_VERSION);
- final String version = manifest.getMainAttributes().getValue(symbolicName);
- return version;
- }
- return null;
+ return getMainAttribute(BUNDLE_VERSION).orElse(null);
}
- /**
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#setBundleVersion(java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public void setBundleVersion(final String version) {
- if (manifest != null) {
- final Name bundleVersion = new Name(BUNDLE_VERSION);
- if (version == null) {
- manifest.getMainAttributes().remove(bundleVersion);
- } else {
- manifest.getMainAttributes().put(bundleVersion, version);
- }
- }
+ setMainAttribute(BUNDLE_VERSION, version);
}
- /**
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#getBundleVendor()
- *
- * {@inheritDoc}
- */
+ @Override
public String getBundleVendor() {
- if (manifest != null) {
- final Name bundleVendor = new Name(BUNDLE_VENDOR);
- return manifest.getMainAttributes().getValue(bundleVendor);
- }
- return null;
+ return getMainAttribute(BUNDLE_VENDOR).orElse(null);
+ }
+
+ @Override
+ public void setBundleVendor(final String vendor) {
+ setMainAttribute(BUNDLE_VENDOR, vendor);
+ }
+
+ @Override
+ public String getValue(final String name) {
+ return getMainAttribute(name).orElse(null);
}
/**
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#setBundleVendor(java.lang.String)
- *
- * {@inheritDoc}
+ * @since 2.0
*/
- public void setBundleVendor(final String vendor) {
- if (manifest != null) {
- final Name bundleVendor = new Name(BUNDLE_VENDOR);
- if (vendor == null) {
- manifest.getMainAttributes().remove(bundleVendor);
- } else {
- manifest.getMainAttributes().put(bundleVendor, vendor);
- }
- }
+ @Override
+ public String getValue(String key, String name) {
+ return getAttribute(key, name).orElse(null);
}
- public String getValue(final String key) {
- if (manifest != null) {
- String value = manifest.getMainAttributes().getValue(key);
- if (value == null) {
- final Attributes attributes = manifest.getAttributes(key);
- if (attributes != null) {
- value = attributes.getValue(key);
- }
- }
- return value;
- }
- return null;
+ Optional<String> getMainAttribute(String name) {
+ return manifest.map(Manifest::getMainAttributes).map(attrs -> attrs.getValue(name));
+ }
+
+ Optional<String> getAttribute(String section, String name) {
+ return manifest.map(m -> m.getAttributes(section)).map(attrs -> attrs.getValue(name));
}
+ @Override
public String getBundleName() {
- if (manifest != null) {
- final Name bundleName = new Name(BUNDLE_NAME);
- final String name = manifest.getMainAttributes().getValue(bundleName);
- return name;
- }
- return null;
+ return getMainAttribute(BUNDLE_NAME).orElse(null);
}
+ @Override
public void setBundleName(String newName) {
if (newName == null) {
newName = "noName"; //$NON-NLS-1$
}
- final Name bundleNameName = new Name(BUNDLE_NAME);
- manifest.getMainAttributes().put(bundleNameName, newName);
+ setMainAttribute(BUNDLE_NAME, newName);
}
+ @Override
public String getBundleLocalization() {
- if (manifest != null) {
- final Name bundleLocalization = new Name(BUNDLE_LOCALIZATION);
- final String name = manifest.getMainAttributes().getValue(bundleLocalization);
- return name;
- }
- return null;
+ return getMainAttribute(BUNDLE_LOCALIZATION).orElse(null);
}
+ @Override
public void setSingleton(final boolean singleton) {
- String value = manifest.getMainAttributes().getValue(BUNDLE_SYMBOLIC_NAME);
- final String[] directives = value.split(SEMICOLON);
+ String value = getMainAttribute(BUNDLE_SYMBOLIC_NAME).orElse(""); //$NON-NLS-1$
+ final String[] directives = value.isEmpty() ? new String[0] : value.split(SEMICOLON);
if (directives.length == 0) {
return; // This should not happen if the Manifest is well-formed
@@ -529,18 +567,24 @@ public class ManifestEditor extends ProjectEditor implements IManifestEditor {
}
}
- manifest.getMainAttributes().putValue(BUNDLE_SYMBOLIC_NAME, value);
+ setMainAttribute(BUNDLE_SYMBOLIC_NAME, value);
}
/**
* @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#addImportPackage(java.lang.String)
*
* @param packageName
+ * @since 2.0
*/
+ @Override
public void addImportPackage(String packageName) {
addImportPackage(packageName, null);
}
+ /**
+ * @since 2.0
+ */
+ @Override
public void addImportPackage(String packageName, String version) {
addPackage(packageName, IMPORT_PACKAGE, version);
}
@@ -549,7 +593,9 @@ public class ManifestEditor extends ProjectEditor implements IManifestEditor {
* @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#addExportPackage(java.lang.String)
*
* @param packageName
+ * @since 2.0
*/
+ @Override
public void addExportPackage(String packageName) {
addExportPackage(packageName, null);
}
@@ -560,7 +606,9 @@ public class ManifestEditor extends ProjectEditor implements IManifestEditor {
*
* @param packageName
* @param version
+ * @since 2.0
*/
+ @Override
public void addExportPackage(String packageName, String version) {
addPackage(packageName, EXPORT_PACKAGE, version);
}
@@ -568,27 +616,144 @@ public class ManifestEditor extends ProjectEditor implements IManifestEditor {
/**
* Adds a package name in a manifest header type.
*
- * @param packageName the package name to add
- * @param type IMPORT_PACKAGE or EXPORT_PACKAGE
+ * @param packageName
+ * the package name to add
+ * @param type
+ * IMPORT_PACKAGE or EXPORT_PACKAGE
*/
private void addPackage(String packageName, String type, String version) {
- final Name manifestHeader = new Name(type);
- String manifestHeaderValue = manifest.getMainAttributes().getValue(manifestHeader);
+ if (hasPackage(packageName, type)) {
+ // Easy case: Just update the version
+ Map<String, String> attributes = (version == null)
+ ? null
+ : Collections.singletonMap(VERSION, version); // $NON-NLS-1$
+ updatePackages(packageName::equals, type, attributes, null);
+ } else {
+ // Only slightly more difficult case: Add the new import
+ String newPackage = (version == null)
+ ? packageName
+ : String.format("%s;version=\"%s\"", packageName, version); //$NON-NLS-1$
- // TODO: Same as addDependency(final String, final String) : Improve the detection of existing packages
+ String importPackage = getMainAttribute(type)
+ .map(ip -> ip + COMMA + newPackage)
+ .orElse(newPackage);
- if (manifestHeaderValue == null) {
- manifestHeaderValue = packageName;
+ setMainAttribute(type, importPackage);
+ }
+ }
- if (version != null) {
- manifestHeaderValue += SEMICOLON + "version=\"" + version + "\"";
+ /**
+ * @since 2.0
+ */
+ @Override
+ public List<IRequiredBundleDescription> getRequiredBundles() {
+ List<IRequiredBundleDescription> result = new ArrayList<>();
+
+ Pattern versionPattern = Pattern.compile("bundle-version=([\"']?)(.*)\\1"); //$NON-NLS-1$
+ Pattern optionalPattern = Pattern.compile("resolution:?=([\"']?)optional\\1"); //$NON-NLS-1$
+ Pattern reexportPattern = Pattern.compile("visibility:?=([\"']?)reexport\\1"); //$NON-NLS-1$
+
+ IBundleProjectService service = Activator.getDefault().getBundleProjectService();
+ String requireBundles = getMainAttribute(REQUIRED_BUNDLE).orElse(""); //$NON-NLS-1$
+ String[] bundles = requireBundles.isEmpty() ? new String[0] : requireBundles.split(COMMA_SPLIT);
+
+ for (int i = 0; i < bundles.length; i++) {
+ String dependency = bundles[i];
+ String[] parts = dependency.split(SEMICOLON);
+
+ String name = parts[0];
+ VersionRange version = VersionRange.emptyRange;
+ boolean optional = false;
+ boolean reexported = false;
+
+ for (int j = 1; j < parts.length; j++) {
+ Matcher m = versionPattern.matcher(parts[j]);
+ if (m.matches()) {
+ version = new VersionRange(m.group(2));
+ } else {
+ m = optionalPattern.matcher(parts[j]);
+ if (m.matches()) {
+ optional = true;
+ } else {
+ m = reexportPattern.matcher(parts[j]);
+ if (m.matches()) {
+ reexported = true;
+ }
+ }
+ }
+ }
+
+ result.add(service.newRequiredBundle(name, version, optional, reexported));
+ }
+
+ return result;
+ }
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public List<IPackageImportDescription> getImportedPackages() {
+ List<IPackageImportDescription> result = new ArrayList<>();
+
+ Pattern versionPattern = Pattern.compile("version=([\"']?)(.*)\\1"); //$NON-NLS-1$
+ Pattern optionalPattern = Pattern.compile("resolution:?=([\"']?)optional\\1"); //$NON-NLS-1$
+
+ IBundleProjectService service = Activator.getDefault().getBundleProjectService();
+ String importedPackages = getMainAttribute(IMPORT_PACKAGE).orElse(""); //$NON-NLS-1$
+ String[] packages = importedPackages.isEmpty() ? new String[0] : importedPackages.split(COMMA_SPLIT);
+
+ for (int i = 0; i < packages.length; i++) {
+ String package_ = packages[i];
+ String[] parts = package_.split(SEMICOLON);
+
+ String name = parts[0];
+ VersionRange version = VersionRange.emptyRange;
+ boolean optional = false;
+
+ for (int j = 1; j < parts.length; j++) {
+ Matcher m = versionPattern.matcher(parts[j]);
+ if (m.matches()) {
+ version = new VersionRange(m.group(2));
+ } else {
+ m = optionalPattern.matcher(parts[j]);
+ if (m.matches()) {
+ optional = true;
+ }
+ }
}
- } else if (!manifestHeaderValue.contains(packageName)) {
- manifestHeaderValue += COMMA + packageName;
- // TODO: Update version
+ result.add(service.newPackageImport(name, version, optional));
}
- manifest.getMainAttributes().put(manifestHeader, manifestHeaderValue);
+ return result;
+ }
+
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public void setRequiredBundleExported(String bundleName, boolean exported) {
+ updateDependencies(
+ bundleName::equals, // Update bundles having this name
+ null, // Don't change attributes such as version
+ Collections.singletonMap(VISIBILITY, exported ? REEXPORT : null)); // Set the visibility directive
+ }
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public void removeRequiredBundle(String bundleName) {
+ transformDependencies(bundleName::equals, (dep, parts) -> null);
+ }
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public void removeImportedPackage(String packageName) {
+ transformImportedPackages(packageName::equals, (dep, parts) -> null);
}
}
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IBuildEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IBuildEditor.java
index 960e018af6e..bf65ae957fc 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IBuildEditor.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IBuildEditor.java
@@ -17,7 +17,9 @@ package org.eclipse.papyrus.eclipse.project.editors.interfaces;
/**
*
* Editor for the build.properties
- *
+ *
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
*/
public interface IBuildEditor extends IFileEditor {
@@ -84,7 +86,7 @@ public interface IBuildEditor extends IFileEditor {
* Returns all the registered source folders
*
* @return
- * all the registered source folders
+ * all the registered source folders
*/
public String[] getSourceFolders();
@@ -92,7 +94,7 @@ public interface IBuildEditor extends IFileEditor {
* Returns all the files added to the build
*
* @return
- * all the files added to the build
+ * all the files added to the build
*/
public String[] getElementsInBuild();
}
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IClasspathEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IClasspathEditor.java
index e8921a045a1..e701d5faf07 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IClasspathEditor.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IClasspathEditor.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -10,6 +9,7 @@
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr
+ * Christian W. Damus - bug 485220
*
*****************************************************************************/
package org.eclipse.papyrus.eclipse.project.editors.interfaces;
@@ -18,7 +18,9 @@ package org.eclipse.papyrus.eclipse.project.editors.interfaces;
/**
*
* This interface for the file .classpath
- *
+ *
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
*/
public interface IClasspathEditor extends IFileEditor {
@@ -26,19 +28,32 @@ public interface IClasspathEditor extends IFileEditor {
public static final String CLASSPATH_FILE = ".classpath"; //$NON-NLS-1$
/**
- * add a source folder to the class path
+ * Add a source folder to the class path.
*
* @param folderPath
+ * a folder path relative to the project path
*/
public void addSourceFolderToClasspath(final String folderPath);
/**
- * Tests if a folder is already registered in the classpath
+ * Add a source folder with optional output folder to the class path.
+ *
+ * @param srcPath
+ * the source path relative to the project path (may not be {@code null})
+ * @param binPath
+ * the output path relative to the project path (may be {@code null})
+ *
+ * @since 2.0
+ */
+ public void addSourceFolderToClasspath(final String srcPath, final String binPath);
+
+ /**
+ * Tests if a folder is already registered in the classpath.
*
* @param folderPath
- * a folder path
+ * a folder path relative to the project path
* @return
- * <code>true</code> if the folderPath is already registered
+ * <code>true</code> if the folderPath is already registered
*/
public boolean isSourceFolderRegistered(final String folderPath);
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IFeatureProjectEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IFeatureProjectEditor.java
index f3ebd669f0e..45f3c4334a3 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IFeatureProjectEditor.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IFeatureProjectEditor.java
@@ -1,16 +1,12 @@
package org.eclipse.papyrus.eclipse.project.editors.interfaces;
-import java.util.Set;
-
import org.w3c.dom.Document;
-public interface IFeatureProjectEditor {
-
- void init();
-
- void save();
-
- void createFiles(final Set<String> files);
+/**
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface IFeatureProjectEditor extends IProjectEditor {
/**
* Retrieves the feature.xml XML Document associated to this project.
@@ -23,6 +19,7 @@ public interface IFeatureProjectEditor {
* Gets the feature's id.
*
* @return the feature's id
+ * @since 2.0
*/
String getId();
@@ -49,58 +46,132 @@ public interface IFeatureProjectEditor {
/**
* Gets the operating system of the feature
+ *
* @return
+ * @since 2.0
*/
String getOS();
+ /**
+ * @since 2.0
+ */
String getWS();
+ /**
+ * @since 2.0
+ */
String getNL();
+ /**
+ * @since 2.0
+ */
String getArch();
+ /**
+ * @since 2.0
+ */
String getDescriptionText();
+ /**
+ * @since 2.0
+ */
String getDescriptionURL();
+ /**
+ * @since 2.0
+ */
String getCopyrightText();
+ /**
+ * @since 2.0
+ */
String getCopyrightURL();
+ /**
+ * @since 2.0
+ */
String getLicenseText();
- String getLicenceURL();
+ /**
+ * @since 2.0
+ */
+ String getLicenseURL();
+ /**
+ * @since 2.0
+ */
void setId(final String id);
void setLabel(final String label);
+ /**
+ * @since 2.0
+ */
void setVersion(final String version);
+ /**
+ * @since 2.0
+ */
void setProviderName(final String providerName);
+ /**
+ * @since 2.0
+ */
void setOS(final String os);
+ /**
+ * @since 2.0
+ */
void setWS(final String ws);
+ /**
+ * @since 2.0
+ */
void setNL(final String nl);
+ /**
+ * @since 2.0
+ */
void setArch(final String arch);
+ /**
+ * @since 2.0
+ */
void setDescription(final String descriptionURL, final String descriptionDesc);
+ /**
+ * @since 2.0
+ */
void setCopyright(final String copyrightURL, final String copyrightDesc);
+ /**
+ * @since 2.0
+ */
void setLicense(final String licenseURL, final String licenseDesc);
+ /**
+ * @since 2.0
+ */
void setUpdateURL(final String urlLabel, final String url);
+ /**
+ * @since 2.0
+ */
void addPlugin(final String pluginName);
+ /**
+ * @since 2.0
+ */
void addRequiredFeature(final String featureName, final String version);
+ /**
+ * @since 2.0
+ */
void addRequiredPlugin(String pluginName);
+ /**
+ * @since 2.0
+ */
void addInclude(String featureName, String version);
}
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IFileEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IFileEditor.java
index 89879fcba2f..c74cd754494 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IFileEditor.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IFileEditor.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +8,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 485220
*
*****************************************************************************/
package org.eclipse.papyrus.eclipse.project.editors.interfaces;
@@ -20,7 +20,9 @@ import org.eclipse.core.resources.IProject;
/**
*
* Interface to edit file
- *
+ *
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
*/
public interface IFileEditor {
@@ -40,7 +42,7 @@ public interface IFileEditor {
/**
*
* @return
- * the missing files for the project
+ * the missing files for the project
*/
public Set<String> getMissingFiles();
@@ -51,15 +53,20 @@ public interface IFileEditor {
*/
public void createFiles(final Set<String> files);
+ /**
+ * Queries whether the editor has any unsaved changes.
+ *
+ * @since 2.0
+ */
+ public boolean isDirty();
- // TODO : Remove that "Throwable" exception...
/** save the modification on the editor */
public void save();
/**
*
* @return
- * the eclipse project
+ * the eclipse project
*/
public IProject getProject();
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IJavaProjectEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IJavaProjectEditor.java
index 6a470f16208..73bd98dc743 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IJavaProjectEditor.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IJavaProjectEditor.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +8,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 485220
*
*****************************************************************************/
package org.eclipse.papyrus.eclipse.project.editors.interfaces;
@@ -16,9 +16,11 @@ package org.eclipse.papyrus.eclipse.project.editors.interfaces;
/**
*
* Editor for the java project
- *
+ *
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
*/
-public interface IJavaProjectEditor extends IBuildEditor {
+public interface IJavaProjectEditor extends IProjectEditor, IBuildEditor, IClasspathEditor {
/** The java nature */
public static final String JAVA_NATURE = "org.eclipse.jdt.core.javanature"; //$NON-NLS-1$
@@ -34,19 +36,4 @@ public interface IJavaProjectEditor extends IBuildEditor {
*/
public void addJavaSourceFolder(final String path);
- /**
- * Gets the classpath editor.
- *
- * @return the classpath editor
- */
- public IClasspathEditor getClasspathEditor();
-
-
- /**
- * Gets the builds the editor.
- *
- * @return the builds the editor
- */
- public IBuildEditor getBuildEditor();
-
}
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IManifestEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IManifestEditor.java
index 7ffb9f48d01..73e5fef8183 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IManifestEditor.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IManifestEditor.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -10,16 +9,22 @@
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr
+ * Christian W. Damus - bug 485220
*
*****************************************************************************/
package org.eclipse.papyrus.eclipse.project.editors.interfaces;
+import java.util.List;
+import org.eclipse.pde.core.project.IPackageImportDescription;
+import org.eclipse.pde.core.project.IRequiredBundleDescription;
/**
*
* Editor for the Manifest
- *
+ *
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
*/
public interface IManifestEditor extends IProjectEditor, IFileEditor {
@@ -52,6 +57,7 @@ public interface IManifestEditor extends IProjectEditor, IFileEditor {
/**
* Add a dependency to the MANIFEST
+ *
* @param dependency
* the dependency to add
*/
@@ -76,45 +82,69 @@ public interface IManifestEditor extends IProjectEditor, IFileEditor {
public boolean hasDependency(final String dependency);
/**
- *
- * @param key
- * the key
+ * Sets the value of a header in the main section of the manifest.
+ *
+ * @param name
+ * the header name
* @param value
- * the new value for the key
+ * the new value for the header
*/
- public void setValue(final String key, final String value);
+ public void setValue(final String name, final String value);
- public String getValue(final String key);
+ /**
+ * Queries the value of a header in the main section of the manifest.
+ *
+ * @param name
+ * the header name
+ * @return the value of the header, {@code null} if none
+ */
+ public String getValue(final String name);
/**
- *
+ * Sets the value of an attribute in a named section of the manifest.
+ *
* @param key
- * the key
+ * the key (section name)
* @param name
- * the name
+ * the name of the attribute
* @param value
- * the new value for the key
+ * the new value for the attribute
*/
public void setValue(final String key, final String name, final String value);
/**
- *
+ * Queries the value of a header in a named section of the manifest.
+ *
* @param key
- * the key
- * @param value
- * the value to remove for this key
+ * the key (section name)
+ * @param name
+ * the header (attribute) name to set
+ * @return the value of the header, {@code null} if none
+ *
+ * @since 2.0
*/
- public void removeValue(final String key, final String value);
+ public String getValue(final String key, String name);
/**
- *
+ * Removes a header from the main section of the manifest
+ *
* @param key
- * a key to remove from the manifest
+ * the header to remove from the manifest
*
*/
public void removeValue(final String key);
/**
+ * Removes an attribute in a named section of the manifest.
+ *
+ * @param key
+ * the key (section name)
+ * @param name
+ * the attribute to remove from this section
+ */
+ public void removeValue(final String key, final String name);
+
+ /**
*
* @param name
* the symbolic name for the bundle
@@ -125,14 +155,14 @@ public interface IManifestEditor extends IProjectEditor, IFileEditor {
/**
*
* @return
- * the bundle name for the project
+ * the bundle name for the project
*/
public String getSymbolicBundleName();
/**
*
* @return
- * the symbolic bundle name for the project
+ * the symbolic bundle name for the project
*/
public String getBundleName();
@@ -146,7 +176,7 @@ public interface IManifestEditor extends IProjectEditor, IFileEditor {
/**
*
* @return
- * the version of the bundle
+ * the version of the bundle
*/
public String getBundleVersion();
@@ -159,7 +189,7 @@ public interface IManifestEditor extends IProjectEditor, IFileEditor {
* Gets this plug-in's provider
*
* @return
- * this plug-in's provider
+ * this plug-in's provider
*/
public String getBundleVendor();
@@ -175,7 +205,7 @@ public interface IManifestEditor extends IProjectEditor, IFileEditor {
* Get the bundle localization
*
* @return
- * the bundle localization
+ * the bundle localization
*/
public String getBundleLocalization();
@@ -193,37 +223,100 @@ public interface IManifestEditor extends IProjectEditor, IFileEditor {
* the pattern for the dependency to update
* @param newVersion
* the version for the dependency
+ *
+ * @deprecated Bulk updates of the bundle dependencies are no longer policy since release 2.0.
*/
+ @Deprecated
public void setDependenciesVersion(final String dependencyPattern, final String newVersion);
/**
* Adds an import package to the MANIFEST.
*
- * @param packageName the package name to add
+ * @param packageName
+ * the package name to add
+ * @since 2.0
*/
public void addImportPackage(String packageName);
/**
* Adds an import package and its version to the MANIFEST.
*
- * @param packageName the package name to add
- * @param version the package version
+ * @param packageName
+ * the package name to add
+ * @param version
+ * the package version
+ * @since 2.0
*/
public void addImportPackage(String packageName, String version);
/**
* Adds an export package to the MANFIEST.
*
- * @param packageName the package name to add
+ * @param packageName
+ * the package name to add
+ * @since 2.0
*/
public void addExportPackage(String packageName);
/**
* Adds an export package and its version to the MANIFEST.
*
- * @param packageName the package name to add
- * @param version the package version
+ * @param packageName
+ * the package name to add
+ * @param version
+ * the package version
+ * @since 2.0
*/
public void addExportPackage(String packageName, String version);
+ /**
+ * Queries the existing bundle requirements.
+ *
+ * @return the existing <tt>Require-Bundle</tt> dependencies
+ *
+ * @since 2.0
+ */
+ public List<IRequiredBundleDescription> getRequiredBundles();
+
+ /**
+ * Queries the existing package imports.
+ *
+ * @return the existing <tt>Import-Package</tt> dependencies
+ *
+ * @since 2.0
+ */
+ public List<IPackageImportDescription> getImportedPackages();
+
+ /**
+ * Sets whether a <tt>Require-Bundle</tt> dependency is re-exported.
+ *
+ * @param bundleName
+ * the required bundle
+ * @param exported
+ * whether the required bundle is re-exported
+ *
+ * @since 2.0
+ */
+ public void setRequiredBundleExported(String bundleName, boolean exported);
+
+ /**
+ * Removes a <tt>Require-Bundle</tt> dependency.
+ *
+ * @param bundleName
+ * the required bundle to remove
+ *
+ * @since 2.0
+ */
+ public void removeRequiredBundle(String bundleName);
+
+ /**
+ * Removes an <tt>Import-package</tt> dependency.
+ *
+ * @param packageName
+ * the imported package to remove
+ *
+ * @since 2.0
+ */
+ public void removeImportedPackage(String packageName);
+
}
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IPluginEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IPluginEditor.java
new file mode 100644
index 00000000000..e5a08490a86
--- /dev/null
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IPluginEditor.java
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * Copyright (c) 2016 Christian W. Damus and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.eclipse.project.editors.interfaces;
+
+/**
+ * A synthesis of all of the editors required to manipulate the metadata
+ * of a plug-in bundle project.
+ *
+ * @since 2.0
+ */
+public interface IPluginEditor extends IPluginProjectEditor, IJavaProjectEditor, IManifestEditor {
+ /**
+ * Queries whether the <tt>plugin.xml</tt> file, in particualr, exists.
+ *
+ * @return whether the plug-in manifest exists
+ */
+ boolean pluginManifestExists();
+}
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IPluginProjectEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IPluginProjectEditor.java
index 085ad042945..e05d2be0346 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IPluginProjectEditor.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IPluginProjectEditor.java
@@ -23,6 +23,8 @@ import org.w3c.dom.Node;
*
* Editor for the file plugin.xml
*
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
*/
public interface IPluginProjectEditor extends IProjectEditor, IFileEditor {
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IProjectEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IProjectEditor.java
index 233c679d40a..e1fb920391b 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IProjectEditor.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/IProjectEditor.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +8,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 485220
*
*****************************************************************************/
package org.eclipse.papyrus.eclipse.project.editors.interfaces;
@@ -19,7 +19,9 @@ import java.util.Set;
/**
*
* This interface defines the methods for the ProjectEditor
- *
+ *
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
*/
public interface IProjectEditor extends IFileEditor {
@@ -46,23 +48,28 @@ public interface IProjectEditor extends IFileEditor {
/**
*
* @return
- * the missing nature for the project
+ * the missing nature for the project
*/
public Set<String> getMissingNature();
/**
+ * @since 2.0
+ */
+ public void addNatures(Set<String> natures);
+
+ /**
*
* @param nature
* a nature
* @return
- * <code>true</code> if the project has this nature
+ * <code>true</code> if the project has this nature
*/
public boolean hasNature(final String nature);
/**
*
* @return
- * the missing build command
+ * the missing build command
*/
public Set<String> getMissingBuildCommand();
@@ -78,7 +85,7 @@ public interface IProjectEditor extends IFileEditor {
* @param command
* a build command
* @return
- * <code>true</code> if the project has the build command
+ * <code>true</code> if the project has the build command
*/
public boolean hasBuildCommand(String command);
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/ProjectEditors.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/ProjectEditors.java
new file mode 100644
index 00000000000..659ab73327e
--- /dev/null
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/interfaces/ProjectEditors.java
@@ -0,0 +1,155 @@
+/*****************************************************************************
+ * Copyright (c) 2016 Christian W. Damus and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.eclipse.project.editors.interfaces;
+
+import java.io.IOException;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.papyrus.eclipse.project.editors.Activator;
+import org.eclipse.papyrus.eclipse.project.editors.file.ManifestEditor;
+import org.eclipse.papyrus.eclipse.project.editors.project.FeatureProjectEditor;
+import org.eclipse.papyrus.eclipse.project.editors.project.JavaProjectEditor;
+import org.eclipse.papyrus.eclipse.project.editors.project.PluginEditor;
+import org.eclipse.papyrus.eclipse.project.editors.project.PluginProjectEditor;
+import org.eclipse.papyrus.eclipse.project.editors.project.ProjectEditor;
+import org.xml.sax.SAXException;
+
+/**
+ * Factory for access to editors for the various project metadata files supported
+ * by the framework.
+ *
+ * @since 2.0
+ */
+public class ProjectEditors {
+
+ /**
+ * Not instantiable by clients.
+ */
+ private ProjectEditors() {
+ super();
+ }
+
+ /**
+ * Obtains an editor for all of the various metadata of a plug-in bundle project.
+ *
+ * @param project
+ * the project to edit
+ * @return the complete editor
+ *
+ * @throws CoreException
+ * on failure to create the editor (for example, if the project
+ * is not {@link IResource#isAccessible() accessible})
+ */
+ public static IPluginEditor getPluginEditor(IProject project) throws CoreException {
+ try {
+ return new PluginEditor(project);
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to create plugin.xml editor", e));
+ }
+ }
+
+ /**
+ * Obtains an editor for the <tt>.project</tt> file of a project.
+ *
+ * @param project
+ * the project to edit
+ * @return the <tt>.project</tt> editor
+ *
+ * @throws CoreException
+ * on failure to create the editor (for example, if the project
+ * is not {@link IResource#isAccessible() accessible})
+ */
+ public static IProjectEditor getProjectEditor(IProject project) throws CoreException {
+ return new ProjectEditor(project);
+ }
+
+ /**
+ * Obtains an editor for the <tt>.project</tt>, <tt>.classpath</tt>, and
+ * <tt>build.properties</tt> files of a Java project.
+ *
+ * @param project
+ * the project to edit
+ * @return the Java project editor
+ *
+ * @throws CoreException
+ * on failure to create the editor (for example, if the project
+ * is not {@link IResource#isAccessible() accessible})
+ */
+ public static IJavaProjectEditor getJavaProjectEditor(IProject project) throws CoreException {
+ return new JavaProjectEditor(project);
+ }
+
+ /**
+ * Obtains an editor for the <tt>plugin.xml</tt> file of a bundle project.
+ *
+ * @param project
+ * the project to edit
+ * @return the <tt>plugin.xml</tt> editor
+ *
+ * @throws CoreException
+ * on failure to create the editor (for example, if the project
+ * is not {@link IResource#isAccessible() accessible})
+ */
+ public static IPluginProjectEditor getPluginProjectEditor(IProject project) throws CoreException {
+ try {
+ return new PluginProjectEditor(project);
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to create plugin.xml editor", e));
+ }
+ }
+
+ /**
+ * Obtains an editor for the <tt>META-INF/MANIFEST</tt> file of a bundle project.
+ *
+ * @param project
+ * the project to edit
+ * @return the <tt>META-INF/MANIFEST.MF</tt> editor
+ *
+ * @throws CoreException
+ * on failure to create the editor (for example, if the project
+ * is not {@link IResource#isAccessible() accessible})
+ */
+ public static IManifestEditor getManifestEditor(IProject project) throws CoreException {
+ try {
+ return new ManifestEditor(project);
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to create manifest editor", e));
+ }
+ }
+
+ /**
+ * Obtains an editor for the <tt>feature.xml</tt> file of a feature project.
+ *
+ * @param project
+ * the project to edit
+ * @return the <tt>feature.xml</tt> editor
+ *
+ * @throws CoreException
+ * on failure to create the editor (for example, if the project
+ * is not {@link IResource#isAccessible() accessible})
+ */
+ public static IFeatureProjectEditor getFeatureProjectEditor(IProject project) throws CoreException {
+ try {
+ return new FeatureProjectEditor(project);
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to create feature editor", e));
+ }
+ }
+}
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/AbstractProjectEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/AbstractProjectEditor.java
index e01a43355b0..a074a6a3297 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/AbstractProjectEditor.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/AbstractProjectEditor.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +8,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 485220
*
*****************************************************************************/
package org.eclipse.papyrus.eclipse.project.editors.project;
@@ -21,7 +21,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
-import org.eclipse.core.internal.events.BuildCommand;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
@@ -59,24 +58,24 @@ public abstract class AbstractProjectEditor extends AbstractFileEditor implement
this.description = getProject().getDescription();
}
-
/**
+ * Initializes me as a slave to another editor, which maintains the canonical
+ * project description.
*
- * @see org.eclipse.papyrus.eclipse.project.editors.project.AbstractProjectEditor.plugin.AbstractEditor#exists()
- *
- * {@inheritDoc}
+ * @param master
+ * my master editor
*/
+ AbstractProjectEditor(AbstractProjectEditor master) {
+ super(master.getProject());
+
+ this.description = master.description;
+ }
+
@Override
public boolean exists() {
return super.exists() && getMissingNature().size() == 0 && getMissingBuildCommand().size() == 0;
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.file.AbstractFileEditor#create()
- *
- * {@inheritDoc}
- */
@Override
public void create() {
createFiles(getMissingFiles());
@@ -85,52 +84,37 @@ public abstract class AbstractProjectEditor extends AbstractFileEditor implement
init();
}
- /**
- *
- * @param nature
- * a nature
- * @return
- * <code>true</code> if the project has the wanted nature
- */
+ @Override
public boolean hasNature(final String nature) {
List<String> natures = new LinkedList<String>(Arrays.asList(this.description.getNatureIds()));
return natures.contains(nature);
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IProjectEditor#getMissingNature()
- *
- * {@inheritDoc}
- */
+ @Override
public Set<String> getMissingNature() {
return new HashSet<String>();
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IProjectEditor#addNatures(java.util.List)
- *
- * {@inheritDoc}
- */
+ @Override
public void addNatures(final Set<String> natures) {
List<String> existingNatures = new LinkedList<String>(Arrays.asList(this.description.getNatureIds()));
+ boolean added = false;
Iterator<String> iter = natures.iterator();
while (iter.hasNext()) {
String nature = iter.next();
if (!existingNatures.contains(nature)) {
existingNatures.add(nature);
+ added = true;
}
}
- this.description.setNatureIds(existingNatures.toArray(new String[existingNatures.size()]));
+
+ if (added) {
+ touch();
+ this.description.setNatureIds(existingNatures.toArray(new String[existingNatures.size()]));
+ }
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.AbstractProjectEditor#hasBuildCommand(java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public boolean hasBuildCommand(final String command) {
ICommand[] buildSpec = this.description.getBuildSpec();
for (int i = 0; i < buildSpec.length; i++) {
@@ -141,38 +125,33 @@ public abstract class AbstractProjectEditor extends AbstractFileEditor implement
return false;
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.AbstractProjectEditor#addBuildCommands(java.util.Set)
- *
- * {@inheritDoc}
- */
+ @Override
public void addBuildCommands(final Set<String> commands) {
ICommand[] buildSpec = this.description.getBuildSpec();
List<ICommand> buildSpecList = new ArrayList<ICommand>();
buildSpecList.addAll(Arrays.asList(buildSpec));
+ boolean added = false;
Iterator<String> iter = commands.iterator();
while (iter.hasNext()) {
String name = iter.next();
if (!hasBuildCommand(name)) {
- ICommand cmd = new BuildCommand();
+ ICommand cmd = this.description.newCommand();
cmd.setBuilderName(name);
buildSpecList.add(cmd);
+ added = true;
}
}
- this.description.setBuildSpec(buildSpecList.toArray(new ICommand[buildSpecList.size()]));
+
+ if (added) {
+ touch();
+ this.description.setBuildSpec(buildSpecList.toArray(new ICommand[buildSpecList.size()]));
+ }
}
- /**
- *
- * @throws Throwable
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IProjectEditor#save()
- *
- * {@inheritDoc}
- */
- public void save() {
+ @Override
+ protected void doSave() {
if (this.description != null) {
try {
getProject().setDescription(this.description, null);
@@ -182,12 +161,7 @@ public abstract class AbstractProjectEditor extends AbstractFileEditor implement
}
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IProjectEditor#getMissingBuildCommand()
- *
- * {@inheritDoc}
- */
+ @Override
public Set<String> getMissingBuildCommand() {
return new HashSet<String>();
}
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/FeatureProjectEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/FeatureProjectEditor.java
index 9a828ba2622..b34b9e9ad68 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/FeatureProjectEditor.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/FeatureProjectEditor.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +8,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 485220
*
*****************************************************************************/
package org.eclipse.papyrus.eclipse.project.editors.project;
@@ -16,7 +16,7 @@ package org.eclipse.papyrus.eclipse.project.editors.project;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
-import java.util.Collections;
+import java.util.Objects;
import java.util.Properties;
import java.util.Set;
@@ -43,8 +43,15 @@ import org.xml.sax.SAXException;
public class FeatureProjectEditor extends ProjectEditor implements IFeatureProjectEditor {
- /** the name of the file feature.xml */
- public static final String FRAGMENT_XML_FILE = "feature.xml"; //$NON-NLS-1$
+ /**
+ * the name of the file feature.xml
+ *
+ * @since 2.0
+ */
+ public static final String FEATURE_XML_FILE = "feature.xml"; //$NON-NLS-1$
+
+ private static final String FEATURE_NATURE = "org.eclipse.pde.FeatureNature"; //$NON-NLS-1$
+ private static final String FEATURE_BUILDER = "org.eclipse.pde.FeatureBuilder"; //$NON-NLS-1$
private static final String ID = "id"; //$NON-NLS-1$
private static final String LABEL = "label"; //$NON-NLS-1$
@@ -68,18 +75,19 @@ public class FeatureProjectEditor extends ProjectEditor implements IFeatureProje
private static final String REQUIRES = "requires"; //$NON-NLS-1$
private static final String FEATURE = "feature"; //$NON-NLS-1$
- // TODO pour l'externalization : utiliser l'éditeur de Properties! dans java Utils
+ // TODO pour l'externalization : utiliser l'�diteur de Properties! dans java Utils
- private Document fragmentXML;
+ private Document featureXML;
- private IFile fragmentFile;
+ private IFile featureFile;
- private Element fragmentRoot;
+ private Element featureRoot;
/**
* Constructor.
*
- * @param project the eclipse project
+ * @param project
+ * the eclipse project
* @throws ParserConfigurationException
* @throws SAXException
* @throws IOException
@@ -91,13 +99,13 @@ public class FeatureProjectEditor extends ProjectEditor implements IFeatureProje
@Override
public void init() {
- fragmentFile = getFeature();
- if (fragmentFile != null && fragmentFile.exists()) {
+ featureFile = getFeature();
+ if ((featureFile != null) && featureFile.exists()) {
final DocumentBuilderFactory documentFactory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder documentBuilder = documentFactory.newDocumentBuilder();
- fragmentXML = documentBuilder.parse(fragmentFile.getLocation().toOSString());
- fragmentRoot = fragmentXML.getDocumentElement();
+ featureXML = documentBuilder.parse(featureFile.getLocation().toOSString());
+ featureRoot = featureXML.getDocumentElement();
} catch (final ParserConfigurationException e) {
Activator.log.error(e);
} catch (final SAXException e) {
@@ -110,13 +118,13 @@ public class FeatureProjectEditor extends ProjectEditor implements IFeatureProje
@Override
public void createFiles(final Set<String> files) {
- if (files.contains(FRAGMENT_XML_FILE)) {
- fragmentFile = getProject().getFile(FRAGMENT_XML_FILE);
- if (!fragmentFile.exists()) {
+ if (files.contains(FEATURE_XML_FILE)) {
+ featureFile = getProject().getFile(FEATURE_XML_FILE);
+ if (!featureFile.exists()) {
InputStream content = getInputStream("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<feature>\n</feature>\n\n"); //$NON-NLS-1$
try {
- fragmentFile.create(content, true, null);
+ featureFile.create(content, true, null);
} catch (CoreException e) {
Activator.log.error(e);
}
@@ -129,93 +137,147 @@ public class FeatureProjectEditor extends ProjectEditor implements IFeatureProje
return getFeature().exists() && super.exists();
}
- public void setAttribute(final Element element, final String attributeName, final String attributeValue) {
- element.setAttribute(attributeName, attributeValue);
+ private void setAttribute(final String attributeName, final String attributeValue) {
+ setAttribute(featureRoot, attributeName, attributeValue);
+ }
+
+ private void setAttribute(final Element element, final String attributeName, final String attributeValue) {
+ if (!Objects.equals(element.getAttribute(attributeName), attributeValue)) {
+ touch();
+ element.setAttribute(attributeName, attributeValue);
+ }
+ }
+
+ private void setTextContent(Element element, String text) {
+ if (!Objects.equals(element.getTextContent(), text)) {
+ touch();
+ element.setTextContent(text);
+ }
}
/**
* @return the feature.xml file if it exists
*/
private IFile getFeature() {
- final IFile fragment = getProject().getFile(FRAGMENT_XML_FILE);
+ final IFile result = getProject().getFile(FEATURE_XML_FILE);
- if (fragment.exists()) {
- return fragment;
+ if (result.exists()) {
+ return result;
}
return null;
}
+ /**
+ * @since 2.0
+ */
@Override
- public void save() {
- if (exists()) {
+ protected void doSave() {
+ if ((featureFile != null) && featureFile.exists()) {
try {
final TransformerFactory transformerFactory = TransformerFactory.newInstance();
final Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
final StreamResult result = new StreamResult(new StringWriter());
- final DOMSource source = new DOMSource(fragmentXML);
+ final DOMSource source = new DOMSource(featureXML);
transformer.transform(source, result);
final InputStream inputStream = getInputStream(result.getWriter().toString());
- fragmentFile.setContents(inputStream, true, true, null);
+ featureFile.setContents(inputStream, true, true, null);
} catch (final TransformerException ex) {
Activator.log.error(ex);
} catch (final CoreException ex) {
Activator.log.error(ex);
}
}
- super.save();
+ super.doSave();
}
@Override
public Set<String> getMissingNature() {
- // TODO
- return Collections.emptySet();
+ Set<String> result = super.getMissingNature();
+ if (!hasNature(FEATURE_NATURE)) {
+ result.add(FEATURE_NATURE);
+ }
+ return result;
}
@Override
public Set<String> getMissingFiles() {
- // TODO
- return Collections.emptySet();
+ Set<String> result = super.getMissingFiles();
+ IFile feature = getProject().getFile(FEATURE_XML_FILE);
+ if (!feature.exists()) {
+ result.add(FEATURE_XML_FILE);
+ }
+ return result;
}
@Override
public Set<String> getMissingBuildCommand() {
- // TODO
- return Collections.emptySet();
+ Set<String> result = super.getMissingBuildCommand();
+ if (!hasBuildCommand(FEATURE_BUILDER)) {
+ result.add(FEATURE_BUILDER);
+ }
+ return result;
}
+ @Override
public Document getDocument() {
- return fragmentXML;
+ return featureXML;
+ }
+
+ private String getAttribute(String name) {
+ return getAttribute(featureRoot, name);
}
+ private String getAttribute(Element element, String name) {
+ return element.getAttribute(name);
+ }
+
+ /**
+ * @since 2.0
+ */
+ @Override
public String getId() {
- return fragmentRoot.getAttribute(ID);
+ return getAttribute(ID);
}
+ @Override
public String getLabel() {
- return fragmentRoot.getAttribute(LABEL);
+ return getAttribute(LABEL);
}
+ @Override
public String getVersion() {
- return fragmentRoot.getAttribute(VERSION);
+ return getAttribute(VERSION);
}
+ @Override
public String getProviderName() {
- return fragmentRoot.getAttribute(PROVIDER);
+ return getAttribute(PROVIDER);
}
+ /**
+ * @since 2.0
+ */
+ @Override
public String getDescriptionText() {
- // TODO Auto-generated method stub
- return null;
+ Element description = getNodeChild(DESCRIPTION, featureRoot);
+ return (description == null) ? null : description.getTextContent().trim();
}
+ /**
+ * @since 2.0
+ */
+ @Override
public String getDescriptionURL() {
- // TODO Auto-generated method stub
- return null;
+ Element description = getNodeChild(DESCRIPTION, featureRoot);
+ return (description == null) || !description.hasAttribute(URL)
+ ? null
+ : description.getAttribute(URL);
}
+ @Override
public String getCopyrightURL() {
final Element copyrightNode = getNode(COPYRIGHT);
if (copyrightNode != null) {
@@ -240,203 +302,239 @@ public class FeatureProjectEditor extends ProjectEditor implements IFeatureProje
return null;
}
+ @Override
public String getCopyrightText() {
final Element copyrightNode = getNode(COPYRIGHT);
return copyrightNode != null ? copyrightNode.getTextContent() : null;
}
+ /**
+ * @since 2.0
+ */
+ @Override
public String getLicenseText() {
- // TODO Auto-generated method stub
- return null;
+ Element license = getNodeChild(LICENSE, featureRoot);
+ return (license == null)
+ ? null
+ : license.getTextContent().trim();
}
- public String getLicenceURL() {
- // TODO Auto-generated method stub
- return null;
+ /**
+ * @since 2.0
+ */
+ @Override
+ public String getLicenseURL() {
+ Element license = getNodeChild(LICENSE, featureRoot);
+ return (license == null) || !license.hasAttribute(URL)
+ ? null
+ : license.getAttribute(URL);
}
+ /**
+ * @since 2.0
+ */
+ @Override
public String getOS() {
- return fragmentRoot.getAttribute(OS);
+ return getAttribute(OS);
}
+ /**
+ * @since 2.0
+ */
+ @Override
public String getWS() {
- return fragmentRoot.getAttribute(WS);
+ return getAttribute(WS);
}
+ /**
+ * @since 2.0
+ */
+ @Override
public String getNL() {
- return fragmentRoot.getAttribute(NL);
+ return getAttribute(NL);
}
+ /**
+ * @since 2.0
+ */
+ @Override
public String getArch() {
- return fragmentRoot.getAttribute(ARCH);
+ return getAttribute(ARCH);
}
+ /**
+ * @since 2.0
+ */
+ @Override
public void setId(final String id) {
- fragmentRoot.setAttribute(ID, id);
+ setAttribute(ID, id);
}
+ @Override
public void setLabel(final String label) {
- fragmentRoot.setAttribute(LABEL, label);
+ setAttribute(LABEL, label);
}
+ @Override
public void setVersion(final String version) {
- fragmentRoot.setAttribute(VERSION, version);
+ setAttribute(VERSION, version);
}
+ @Override
public void setProviderName(final String providerName) {
- fragmentRoot.setAttribute(PROVIDER, providerName);
+ setAttribute(PROVIDER, providerName);
}
- public void setDescription(final String descriptionURL, final String description) {
- if (exists()) {
- Element extension = getNode(DESCRIPTION);
+ private Element forceElement(String name) {
+ return forceElement(featureRoot, name);
+ }
- if (extension == null) {
- extension = fragmentXML.createElement(DESCRIPTION);
- fragmentRoot.appendChild(extension);
- }
+ private Element forceElement(Element parent, String name) {
+ Element result = getNodeChild(name, parent);
+ if (result == null) {
+ touch();
+ result = createElement(name);
+ parent.appendChild(result);
+ }
+ return result;
+ }
- extension.setAttribute(URL, descriptionURL);
- extension.setTextContent(description);
+ @Override
+ public void setDescription(final String descriptionURL, final String description) {
+ if (featureRoot != null) {
+ Element extension = forceElement(DESCRIPTION);
+ setAttribute(extension, URL, descriptionURL);
+ setTextContent(extension, description);
}
}
+ @Override
public void setCopyright(final String copyrightURL, final String copyrightDesc) {
setURLNode(COPYRIGHT, copyrightURL, copyrightDesc);
}
+ /**
+ * @since 2.0
+ */
+ @Override
public void setLicense(final String licenseURL, final String licenseDesc) {
setURLNode(LICENSE, licenseURL, licenseDesc);
}
+ /**
+ * @since 2.0
+ */
+ @Override
public void setOS(final String os) {
- fragmentRoot.setAttribute(OS, os);
+ setAttribute(OS, os);
}
+ /**
+ * @since 2.0
+ */
+ @Override
public void setWS(final String ws) {
- fragmentRoot.setAttribute(WS, ws);
+ setAttribute(WS, ws);
}
+ /**
+ * @since 2.0
+ */
+ @Override
public void setNL(final String nl) {
- fragmentRoot.setAttribute(NL, nl);
+ setAttribute(NL, nl);
}
+ /**
+ * @since 2.0
+ */
+ @Override
public void setArch(final String architecture) {
- fragmentRoot.setAttribute(ARCH, architecture);
+ setAttribute(ARCH, architecture);
}
+ /**
+ * @since 2.0
+ */
+ @Override
public void setUpdateURL(final String urlLabel, final String url) {
- Element urlNode = getNode(URL);
-
- if (urlNode == null) {
- urlNode = createElement(URL);
- fragmentRoot.appendChild(urlNode);
- }
+ Element urlNode = forceElement(URL);
+ Element updateNode = forceElement(urlNode, UPDATE);
- Element updateNode = getNodeChild(UPDATE, urlNode);
- if (updateNode == null) {
- updateNode = createElement(UPDATE);
- urlNode.appendChild(updateNode);
- }
-
- updateNode.setAttribute(LABEL, urlLabel);
- updateNode.setAttribute(URL, url);
+ setAttribute(updateNode, LABEL, urlLabel);
+ setAttribute(updateNode, URL, url);
}
+ /**
+ * @since 2.0
+ */
+ @Override
public void addPlugin(final String pluginName) {
// Get the plug-in element or create it if it does not exist
- Element pluginNode = getPlugin(pluginName);
-
- if (pluginNode == null) {
- pluginNode = createElement(PLUGIN);
- fragmentRoot.appendChild(pluginNode);
+ Element plugin = forcePlugin(pluginName);
+ if (!plugin.hasAttribute(VERSION)) {
+ plugin.setAttribute(VERSION, "0.0.0"); //$NON-NLS-1$
+ }
+ if (!plugin.hasAttribute("download-size")) {
+ plugin.setAttribute("download-size", "0"); //$NON-NLS-1$
+ }
+ if (!plugin.hasAttribute("install-size")) {
+ plugin.setAttribute("install-size", "0"); //$NON-NLS-1$
+ }
+ if (!plugin.hasAttribute("unpack")) {
+ plugin.setAttribute("unpack", "false"); //$NON-NLS-1$
}
-
- // Set the id on the element
- pluginNode.setAttribute(ID, pluginName);
}
+ /**
+ * @since 2.0
+ */
+ @Override
public void addRequiredFeature(final String featureName, final String version) {
- // Make sure the "requires" element exists
- Element requires = getNode(REQUIRES);
-
- if (requires == null) {
- requires = createElement(REQUIRES);
- fragmentRoot.appendChild(requires);
- }
-
// Get or create the required feature element
- Element feature = getRequiredFeature(featureName);
-
- if (feature == null) {
- feature = createElement(IMPORT);
- requires.appendChild(feature);
- }
+ Element feature = forceRequiredFeature(featureName);
// Set the element values
- feature.setAttribute(FEATURE, featureName);
feature.setAttribute(VERSION, version);
}
+ /**
+ * @since 2.0
+ */
+ @Override
public void addRequiredPlugin(final String pluginName) {
- // Make sure the "requires" element exists
- Element requires = getNode(REQUIRES);
-
- if (requires == null) {
- requires = createElement(REQUIRES);
- fragmentRoot.appendChild(requires);
- }
-
// Get or create the plug-in element
- Element plugin = getRequiredPlugin(pluginName);
-
- if (plugin == null) {
- plugin = createElement(IMPORT);
- requires.appendChild(plugin);
- }
-
- plugin.setAttribute(PLUGIN, pluginName);
+ forceRequiredPlugin(pluginName);
}
+ /**
+ * @since 2.0
+ */
+ @Override
public void addInclude(final String featureName, final String version) {
- Element includeNode = getInclude(featureName);
-
- if (includeNode == null) {
- includeNode = createElement(INCLUDES);
- fragmentRoot.appendChild(includeNode);
- }
-
- includeNode.setAttribute(ID, featureName);
- includeNode.setAttribute(VERSION, version);
+ Element includeNode = forceInclude(featureName);
+ setAttribute(includeNode, VERSION, (version == null) ? "0.0.0" : version);
}
/**
* Creates an element and returns it.
*
- * @param elementName the name of the element to create
+ * @param elementName
+ * the name of the element to create
* @return the created element
*/
private Element createElement(String elementName) {
- return fragmentXML.createElement(elementName);
+ return featureXML.createElement(elementName);
}
protected void setURLNode(final String nodeName, final String url, final String description) {
- if (exists()) {
- Element extension = getNode(nodeName);
- if (extension == null) {
- extension = fragmentXML.createElement(nodeName);
- if (url != null) {
- extension.setAttribute(URL, url);
- }
- extension.setTextContent(description);
- fragmentRoot.appendChild(extension);
- } else {
- if (url != null) {
- extension.setAttribute(URL, url);
- }
- extension.setTextContent(description);
+ if (featureRoot != null) {
+ Element urlNode = forceElement(nodeName);
+ if (url != null) {
+ setAttribute(urlNode, URL, url);
}
+ setTextContent(urlNode, description);
}
}
@@ -444,8 +542,10 @@ public class FeatureProjectEditor extends ProjectEditor implements IFeatureProje
* Gets an element inside a parent element.
*
* @param parentElement
- * @param nodeName the node name of the element
- * @param attributeValue the value of the element's attribute to retrieve
+ * @param nodeName
+ * the node name of the element
+ * @param attributeValue
+ * the value of the element's attribute to retrieve
* @return the element or null if it does not exist
*/
private Element getElement(final Element parentElement, final String nodeName, final String attributeName, final String attributeValue) {
@@ -489,12 +589,13 @@ public class FeatureProjectEditor extends ProjectEditor implements IFeatureProje
/**
* Gets a node element inside the root element.
*
- * @param nodeName the node name
+ * @param nodeName
+ * the node name
* @return the node element or null if it does not exist.
*/
private Element getNode(final String nodeName) {
- if (exists()) {
- final NodeList nodes = fragmentRoot.getChildNodes();
+ if (featureRoot != null) {
+ final NodeList nodes = featureRoot.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
final Node item = nodes.item(i);
if (item instanceof NodeList) {
@@ -512,11 +613,31 @@ public class FeatureProjectEditor extends ProjectEditor implements IFeatureProje
}
private Element getPlugin(String pluginName) {
- return getElement(fragmentRoot, PLUGIN, ID, pluginName);
+ return getElement(featureRoot, PLUGIN, ID, pluginName);
+ }
+
+ private Element forcePlugin(String pluginName) {
+ Element result = getPlugin(pluginName);
+ if (result == null) {
+ result = createElement(PLUGIN);
+ featureRoot.appendChild(result);
+ setAttribute(result, ID, pluginName);
+ }
+ return result;
}
private Element getInclude(String featureName) {
- return getElement(fragmentRoot, INCLUDES, ID, featureName);
+ return getElement(featureRoot, INCLUDES, ID, featureName);
+ }
+
+ private Element forceInclude(String featureName) {
+ Element result = getInclude(featureName);
+ if (result == null) {
+ result = createElement(INCLUDES);
+ featureRoot.appendChild(result);
+ setAttribute(result, ID, featureName);
+ }
+ return result;
}
/**
@@ -533,6 +654,18 @@ public class FeatureProjectEditor extends ProjectEditor implements IFeatureProje
return null;
}
+ private Element forceRequiredPlugin(String pluginName) {
+ Element result = getRequiredPlugin(pluginName);
+
+ if (result == null) {
+ result = createElement(IMPORT);
+ forceElement(REQUIRES).appendChild(result);
+ setAttribute(result, PLUGIN, pluginName);
+ }
+
+ return result;
+ }
+
private String getNodeAttribute(Node node, String name) {
Node attribute = node.getAttributes().getNamedItem(name);
@@ -549,4 +682,16 @@ public class FeatureProjectEditor extends ProjectEditor implements IFeatureProje
return null;
}
+ private Element forceRequiredFeature(String featureName) {
+ Element result = getRequiredFeature(featureName);
+
+ if (result == null) {
+ result = createElement(IMPORT);
+ forceElement(REQUIRES).appendChild(result);
+ setAttribute(result, FEATURE, featureName);
+ }
+
+ return result;
+ }
+
}
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/JavaProjectEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/JavaProjectEditor.java
index e53e0677537..f76d2f5213d 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/JavaProjectEditor.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/JavaProjectEditor.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +8,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 485220
*
*****************************************************************************/
package org.eclipse.papyrus.eclipse.project.editors.project;
@@ -76,15 +76,31 @@ public class JavaProjectEditor extends ProjectEditor implements IJavaProjectEdit
*/
public JavaProjectEditor(final IProject project) throws CoreException {
super(project);
+
this.javaProject = JavaCore.create(project);
this.buildEditor = new BuildEditor(project);
this.classpathEditor = new ClasspathEditor(this.javaProject);
}
/**
+ * Initializes me as a slave to another editor, which maintains the canonical
+ * project description.
+ *
+ * @param master
+ * my master editor
+ */
+ JavaProjectEditor(AbstractProjectEditor master) {
+ super(master);
+
+ this.javaProject = JavaCore.create(master.getProject());
+ this.buildEditor = new BuildEditor(master.getProject());
+ this.classpathEditor = new ClasspathEditor(this.javaProject);
+ }
+
+ /**
*
* @return
- * <code>true</code> if the project is a java project :
+ * <code>true</code> if the project is a java project :
*
*/
@Override
@@ -92,12 +108,6 @@ public class JavaProjectEditor extends ProjectEditor implements IJavaProjectEdit
return super.exists() && this.javaProject.exists();
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.ProjectEditor#getMissingFiles()
- *
- * {@inheritDoc}
- */
@Override
public Set<String> getMissingFiles() {
Set<String> files = super.getMissingFiles();
@@ -106,12 +116,6 @@ public class JavaProjectEditor extends ProjectEditor implements IJavaProjectEdit
return files;
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.AbstractProjectEditor#getMissingNature()
- *
- * {@inheritDoc}
- */
@Override
public Set<String> getMissingNature() {
Set<String> natures = super.getMissingNature();
@@ -123,8 +127,6 @@ public class JavaProjectEditor extends ProjectEditor implements IJavaProjectEdit
@Override
public void init() {
- // TODO Auto-generated method stub
- super.init();
this.classpathEditor.init();
this.buildEditor.init();
}
@@ -137,15 +139,19 @@ public class JavaProjectEditor extends ProjectEditor implements IJavaProjectEdit
}
+ @Override
+ public boolean isDirty() {
+ return super.isDirty() || classpathEditor.isDirty() || buildEditor.isDirty();
+ }
/**
* save the modification
- *
- * @throws Throwable
+ *
+ * @since 2.0
*/
@Override
- public void save() {
- super.save();
+ protected void doSave() {
+ super.doSave();
try {
this.javaProject.save(new NullProgressMonitor(), true);
} catch (JavaModelException ex) {
@@ -155,12 +161,7 @@ public class JavaProjectEditor extends ProjectEditor implements IJavaProjectEdit
this.buildEditor.save();
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IJavaProjectEditor#addJavaSourceFolder(java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public void addJavaSourceFolder(final String path) {
if (exists()) {
// we add this source folder to the class path
@@ -173,54 +174,28 @@ public class JavaProjectEditor extends ProjectEditor implements IJavaProjectEdit
}
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IBuildEditor#registerSourceFolder(java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public void registerSourceFolder(final String string) {
this.buildEditor.registerSourceFolder(string);
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IBuildEditor#addToBuild(java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public void addToBuild(final String path) {
this.buildEditor.addToBuild(path);
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IBuildEditor#isRegistred(java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public boolean isRegisteredSourceFolder(final String path) {
return this.buildEditor.isRegisteredSourceFolder(path);
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IBuildEditor#getSourceFolders()
- *
- * {@inheritDoc}
- */
+ @Override
public String[] getSourceFolders() {
return this.buildEditor.getSourceFolders();
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.file.AbstractFileEditor#getMissingBuildCommand()
- *
- * {@inheritDoc}
- */
@Override
public Set<String> getMissingBuildCommand() {
Set<String> buildCommand = super.getMissingBuildCommand();
@@ -230,43 +205,55 @@ public class JavaProjectEditor extends ProjectEditor implements IJavaProjectEdit
return buildCommand;
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IBuildEditor#removeFromBuild(java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public void removeFromBuild(String path) {
buildEditor.removeFromBuild(path);
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IBuildEditor#getElementsInBuild()
- *
- * {@inheritDoc}
- */
+ @Override
public String[] getElementsInBuild() {
return buildEditor.getElementsInBuild();
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IBuildEditor#registerBinFolder(java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public void registerBinFolder(String binFolder) {
buildEditor.registerBinFolder(binFolder);
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IBuildEditor#isRegisteredBinFolder(java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public boolean isRegisteredBinFolder(String binFolder) {
return buildEditor.isRegisteredBinFolder(binFolder);
}
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public void addSourceFolderToClasspath(String folderPath) {
+ classpathEditor.addSourceFolderToClasspath(folderPath);
+ }
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public void addSourceFolderToClasspath(String srcPath, String binPath) {
+ classpathEditor.addSourceFolderToClasspath(srcPath, binPath);
+ }
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public boolean isSourceFolderRegistered(String folderPath) {
+ return classpathEditor.isSourceFolderRegistered(folderPath);
+ }
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public String[] getBinFolders() {
+ return classpathEditor.getBinFolders();
+ }
}
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/PluginEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/PluginEditor.java
new file mode 100644
index 00000000000..143d73c1b65
--- /dev/null
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/PluginEditor.java
@@ -0,0 +1,369 @@
+/*****************************************************************************
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 485220
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.eclipse.project.editors.project;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.papyrus.eclipse.project.editors.file.ManifestEditor;
+import org.eclipse.papyrus.eclipse.project.editors.interfaces.IJavaProjectEditor;
+import org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor;
+import org.eclipse.papyrus.eclipse.project.editors.interfaces.IPluginEditor;
+import org.eclipse.pde.core.project.IPackageImportDescription;
+import org.eclipse.pde.core.project.IRequiredBundleDescription;
+import org.xml.sax.SAXException;
+
+/**
+ * @since 2.0
+ */
+public class PluginEditor extends PluginProjectEditor implements IPluginEditor {
+
+ protected IManifestEditor manifest;
+
+ protected IJavaProjectEditor java;
+
+ public PluginEditor(IProject project) throws CoreException, IOException, SAXException, ParserConfigurationException {
+ super(project);
+
+ manifest = new ManifestEditor(project);
+ java = new JavaProjectEditor(this);
+ }
+
+ public PluginProjectEditor getPluginEditor() {
+ return this;
+ }
+
+ public IManifestEditor getManifestEditor() {
+ return manifest;
+ }
+
+ public IJavaProjectEditor getJavaProjectEditor() {
+ return java;
+ }
+
+ @Override
+ public Set<String> getMissingFiles() {
+ Set<String> result = super.getMissingFiles();
+ result.addAll(java.getMissingFiles());
+ result.addAll(manifest.getMissingFiles());
+ return result;
+ }
+
+ @Override
+ public Set<String> getMissingNature() {
+ Set<String> result = super.getMissingNature();
+ result.addAll(java.getMissingNature());
+ result.addAll(manifest.getMissingNature());
+ return result;
+ }
+
+ @Override
+ public Set<String> getMissingBuildCommand() {
+ Set<String> result = super.getMissingBuildCommand();
+ result.addAll(java.getMissingBuildCommand());
+ result.addAll(manifest.getMissingBuildCommand());
+ return result;
+ }
+
+ @Override
+ public void init() {
+ super.init();
+
+ java.init();
+ manifest.init();
+ }
+
+ @Override
+ public void create() {
+ super.create();
+
+ java.create();
+ manifest.create();
+ }
+
+ @Override
+ public void createFiles(Set<String> files) {
+ super.createFiles(files);
+
+ java.createFiles(files);
+ manifest.createFiles(files);
+ }
+
+ @Override
+ public boolean exists() {
+ // The plugin.xml doesn't have to exist for me to exist as a plug-in
+ return java.exists() && manifest.exists();
+ }
+
+ @Override
+ public boolean pluginManifestExists() {
+ return super.exists();
+ }
+
+ @Override
+ public void registerSourceFolder(String source) {
+ java.registerSourceFolder(source);
+ }
+
+ @Override
+ public void addToBuild(String path) {
+ java.addToBuild(path);
+ }
+
+ @Override
+ public String[] getSourceFolders() {
+ return java.getSourceFolders();
+ }
+
+ @Override
+ public void addDependency(String dependency) {
+ manifest.addDependency(dependency);
+ }
+
+ @Override
+ public void addDependency(String dependency, String version) {
+ manifest.addDependency(dependency, version);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#hasDependency(java.lang.String)
+ *
+ * @param dependency
+ * @return
+ */
+ @Override
+ public boolean hasDependency(String dependency) {
+ return manifest.hasDependency(dependency);
+ }
+
+ @Override
+ public void setValue(String key, String value) {
+ manifest.setValue(key, value);
+ }
+
+ @Override
+ public void setValue(String key, String name, String value) {
+ manifest.setValue(key, name, value);
+ }
+
+ @Override
+ public void removeValue(String key, String value) {
+ manifest.removeValue(key, value);
+ }
+
+ @Override
+ public void removeValue(String key) {
+ manifest.removeValue(key);
+ }
+
+ @Override
+ public void setBundleName(String name) {
+ manifest.setBundleName(name);
+ }
+
+ @Override
+ public String getSymbolicBundleName() {
+ return manifest.getSymbolicBundleName();
+ }
+
+ @Override
+ public String getBundleVersion() {
+ return manifest.getBundleVersion();
+ }
+
+ @Override
+ public void setBundleVersion(String version) {
+ manifest.setBundleVersion(version);
+ }
+
+ @Override
+ public boolean isDirty() {
+ return super.isDirty() || manifest.isDirty() || java.isDirty();
+ }
+
+ @Override
+ protected void doSave() {
+ super.doSave();
+ manifest.save();
+ java.save();
+ }
+
+ @Override
+ public void registerBinFolder(String binFolder) {
+ java.registerBinFolder(binFolder);
+ }
+
+ @Override
+ public void removeFromBuild(String path) {
+ java.removeFromBuild(path);
+ }
+
+ @Override
+ public boolean isRegisteredSourceFolder(String path) {
+ return java.isRegisteredSourceFolder(path);
+ }
+
+ @Override
+ public boolean isRegisteredBinFolder(String binFolder) {
+ return java.isRegisteredBinFolder(binFolder);
+ }
+
+ @Override
+ public String[] getElementsInBuild() {
+ return java.getElementsInBuild();
+ }
+
+ @Override
+ public String getBundleVendor() {
+ return manifest.getBundleVendor();
+ }
+
+ @Override
+ public void setBundleVendor(String vendor) {
+ manifest.setBundleVendor(vendor);
+ }
+
+ @Override
+ public String getValue(String key) {
+ return manifest.getValue(key);
+ }
+
+ @Override
+ public String getValue(String key, String name) {
+ return manifest.getValue(key, name);
+ }
+
+ @Override
+ public void setSymbolicBundleName(String name) {
+ manifest.setSymbolicBundleName(name);
+ }
+
+ @Override
+ public String getBundleName() {
+ return manifest.getBundleName();
+ }
+
+ @Override
+ public String getBundleLocalization() {
+ return manifest.getBundleLocalization();
+ }
+
+ @Override
+ public void setSingleton(boolean singleton) {
+ manifest.setSingleton(singleton);
+ }
+
+ @Override
+ @Deprecated
+ public void setDependenciesVersion(String dependencyPattern, String newVersion) {
+ manifest.setDependenciesVersion(dependencyPattern, newVersion);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#addImportPackage(java.lang.String)
+ *
+ * @param packageName
+ */
+ @Override
+ public void addImportPackage(String packageName) {
+ manifest.addImportPackage(packageName);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#addImportPackage(java.lang.String, java.lang.String)
+ *
+ * @param packageName
+ * @param version
+ */
+ @Override
+ public void addImportPackage(String packageName, String version) {
+ manifest.addImportPackage(packageName, version);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#addExportPackage(java.lang.String)
+ *
+ * @param packageName
+ */
+ @Override
+ public void addExportPackage(String packageName) {
+ manifest.addExportPackage(packageName);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IManifestEditor#addExportPackage(java.lang.String, java.lang.String)
+ *
+ * @param packageName
+ * @param version
+ */
+ @Override
+ public void addExportPackage(String packageName, String version) {
+ manifest.addExportPackage(packageName, version);
+ }
+
+ @Override
+ public List<IRequiredBundleDescription> getRequiredBundles() {
+ return manifest.getRequiredBundles();
+ }
+
+ @Override
+ public List<IPackageImportDescription> getImportedPackages() {
+ return manifest.getImportedPackages();
+ }
+
+ @Override
+ public void setRequiredBundleExported(String bundleName, boolean exported) {
+ manifest.setRequiredBundleExported(bundleName, exported);
+ }
+
+ @Override
+ public void removeRequiredBundle(String bundleName) {
+ manifest.removeRequiredBundle(bundleName);
+ }
+
+ @Override
+ public void removeImportedPackage(String packageName) {
+ manifest.removeImportedPackage(packageName);
+ }
+
+ @Override
+ public void addJavaSourceFolder(String path) {
+ java.addJavaSourceFolder(path);
+ }
+
+ @Override
+ public void addSourceFolderToClasspath(String folderPath) {
+ java.addSourceFolderToClasspath(folderPath);
+ }
+
+ @Override
+ public void addSourceFolderToClasspath(String srcPath, String binPath) {
+ java.addSourceFolderToClasspath(srcPath, binPath);
+ }
+
+ @Override
+ public boolean isSourceFolderRegistered(String folderPath) {
+ return java.isSourceFolderRegistered(folderPath);
+ }
+
+ @Override
+ public String[] getBinFolders() {
+ return java.getBinFolders();
+ }
+}
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/PluginProjectEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/PluginProjectEditor.java
index fd9563ad056..f14390a4d7a 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/PluginProjectEditor.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/PluginProjectEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +9,8 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Vincent Lorenzot (CEA-LIST) vincent.lorenzo@cea.fr
+ * Christian W. Damus - bug 485220
+ *
*****************************************************************************/
package org.eclipse.papyrus.eclipse.project.editors.project;
@@ -17,6 +19,7 @@ import java.io.InputStream;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
@@ -70,11 +73,16 @@ public class PluginProjectEditor extends ProjectEditor implements IPluginProject
}
/**
+ * Initializes me as a slave to another editor, which maintains the canonical
+ * project description.
*
- * @see org.eclipse.papyrus.eclipse.project.editors.project.ProjectEditor#init()
- *
- * {@inheritDoc}
+ * @param master
+ * my master editor
*/
+ PluginProjectEditor(AbstractProjectEditor master) {
+ super(master);
+ }
+
@Override
public void init() {
this.pluginFile = getPlugin();
@@ -118,26 +126,16 @@ public class PluginProjectEditor extends ProjectEditor implements IPluginProject
super.createFiles(files);
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.AbstractProjectEditor.plugin.AbstractEditor#exists()
- *
- * {@inheritDoc}
- */
@Override
public boolean exists() {
IFile plugin = getProject().getFile(PLUGIN_XML_FILE);
return plugin.exists() && super.exists();
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IPluginProjectEditor#addExtension(java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public Element addExtension(final String extensionPoint) {
if (exists()) {
+ touch();
Element extension = this.pluginXML.createElement(EXTENSION);
extension.setAttribute(POINT, extensionPoint);
this.pluginRoot.appendChild(extension);
@@ -152,8 +150,9 @@ public class PluginProjectEditor extends ProjectEditor implements IPluginProject
* @param extensionPoint
* the name of an extension point
* @return
- * the list of the registered extension with this extension point
+ * the list of the registered extension with this extension point
*/
+ @Override
public List<Node> getExtensions(final String extensionPoint) {
if (exists()) {
NodeList nodes = this.pluginRoot.getChildNodes();
@@ -179,33 +178,22 @@ public class PluginProjectEditor extends ProjectEditor implements IPluginProject
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IPluginProjectEditor#setAttribute(org.w3c.dom.Element, java.lang.String, java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public void setAttribute(final Element element, final String attributeName, final String attributeValue) {
- element.setAttribute(attributeName, attributeValue);
+ if (!Objects.equals(element.getAttribute(attributeName), attributeValue)) {
+ touch();
+ element.setAttribute(attributeName, attributeValue);
+ }
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IPluginProjectEditor#addChild(org.w3c.dom.Element, java.lang.String)
- *
- * {@inheritDoc}
- */
+ @Override
public Element addChild(final Element element, final String childName) {
+ touch();
Element child = this.pluginXML.createElement(childName);
element.appendChild(child);
return child;
}
- /**
- *
- * @return
- * the plugin file if it exists
- */
private IFile getPlugin() {
IFile plugin = getProject().getFile(PLUGIN_XML_FILE);
if (plugin.exists()) {
@@ -216,13 +204,10 @@ public class PluginProjectEditor extends ProjectEditor implements IPluginProject
/**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.ProjectEditor#save()
- *
- * {@inheritDoc}
+ * @since 2.0
*/
@Override
- public void save() {
+ protected void doSave() {
if (exists()) {
try {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
@@ -247,15 +232,9 @@ public class PluginProjectEditor extends ProjectEditor implements IPluginProject
Activator.log.error(ex);
}
}
- super.save();
+ super.doSave();
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.ProjectEditor#getMissingNature()
- *
- * {@inheritDoc}
- */
@Override
public Set<String> getMissingNature() {
Set<String> natures = super.getMissingNature();
@@ -265,12 +244,6 @@ public class PluginProjectEditor extends ProjectEditor implements IPluginProject
return natures;
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.project.ProjectEditor#getMissingFiles()
- *
- * {@inheritDoc}
- */
@Override
public Set<String> getMissingFiles() {
Set<String> files = super.getMissingFiles();
@@ -281,12 +254,6 @@ public class PluginProjectEditor extends ProjectEditor implements IPluginProject
return files;
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.file.AbstractFileEditor#getMissingBuildCommand()
- *
- * {@inheritDoc}
- */
@Override
public Set<String> getMissingBuildCommand() {
Set<String> commands = super.getMissingBuildCommand();
@@ -296,11 +263,7 @@ public class PluginProjectEditor extends ProjectEditor implements IPluginProject
return commands;
}
- /**
- * @return The XML Document associated to this plugin.xml file
- * @see PluginProjectEditor#init()
- * @see PluginProjectEditor#create()
- */
+ @Override
public Document getDocument() {
return pluginXML;
}
diff --git a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/ProjectEditor.java b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/ProjectEditor.java
index 253339a1b4f..1537800954d 100644
--- a/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/ProjectEditor.java
+++ b/plugins/editor/org.eclipse.papyrus.eclipse.project.editors/src/org/eclipse/papyrus/eclipse/project/editors/project/ProjectEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 485220
+ *
*****************************************************************************/
package org.eclipse.papyrus.eclipse.project.editors.project;
@@ -17,7 +19,6 @@ import java.net.URL;
import java.util.Set;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -47,22 +48,16 @@ public class ProjectEditor extends AbstractProjectEditor implements IProjectEdit
}
/**
+ * Initializes me as a slave to another editor, which maintains the canonical
+ * project description.
*
- * Constructor.
- *
- * @param folder
- * a folder
- * @throws CoreException
+ * @param master
+ * my master editor
*/
- public ProjectEditor(final IFolder folder) throws CoreException {
- super(null);
- // TODO : create an action to import a folder as a project!
- // this will allow to test the create method
- throw new UnsupportedOperationException();
+ ProjectEditor(AbstractProjectEditor master) {
+ super(master);
}
-
-
/**
* Create the project file
* TODO NOT TESTED
@@ -71,6 +66,7 @@ public class ProjectEditor extends AbstractProjectEditor implements IProjectEdit
*
* {@inheritDoc}
*/
+ @Override
public void createFiles(final Set<String> files) {
if (files.contains(PROJECT_FILE)) {
final IFile file = getProject().getFile(PROJECT_FILE);
@@ -97,12 +93,6 @@ public class ProjectEditor extends AbstractProjectEditor implements IProjectEdit
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IProjectEditor#getMissingFiles()
- *
- * {@inheritDoc}
- */
@Override
public Set<String> getMissingFiles() {
final Set<String> missingFile = super.getMissingFiles();
@@ -113,14 +103,7 @@ public class ProjectEditor extends AbstractProjectEditor implements IProjectEdit
return missingFile;
}
- /**
- *
- * @see org.eclipse.papyrus.eclipse.project.editors.interfaces.IProjectEditor#addFile(java.net.URL, java.lang.String)
- *
- * @param url
- * @param fileDestinationPath
- * @param eraseExitingFile
- */
+ @Override
public void addFile(final URL url, final String fileDestinationPath, final boolean eraseExitingFile) {
final IFile targetFile = getProject().getFile(new Path(fileDestinationPath));
if (targetFile.exists()) {
@@ -136,7 +119,6 @@ public class ProjectEditor extends AbstractProjectEditor implements IProjectEdit
}
try {
final InputStream is = url.openStream();
- ;
targetFile.create(is, false, new NullProgressMonitor());
is.close();
targetFile.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
diff --git a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/.project b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/.project
index 0bab1c4c8a4..5772f26c161 100644
--- a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/.project
+++ b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/.project
@@ -1,28 +1,52 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.papyrus.editor.perspectiveconfiguration</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>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.editor.perspectiveconfiguration</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.oomph.version.VersionBuilder</name>
+ <arguments>
+ <dictionary>
+ <key>check.maven.pom</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>ignore.lower.bound.dependency.ranges</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>release.path</key>
+ <value>org.eclipse.papyrus.releng.main.release/release.xml</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ <nature>org.eclipse.oomph.version.VersionNature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/META-INF/MANIFEST.MF b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/META-INF/MANIFEST.MF
index bd8e6cf307d..aad551d052c 100644
--- a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/META-INF/MANIFEST.MF
+++ b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/META-INF/MANIFEST.MF
@@ -1,13 +1,12 @@
-Manifest-Version: 1.0
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0"
-Bundle-Vendor: %providerName
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.2.0.qualifier
-Bundle-Localization: plugin
-Bundle-Name: %pluginName
-Bundle-Activator: org.eclipse.papyrus.editor.perspectiveconfiguration.Activator
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.papyrus.editor.perspectiveconfiguration;singleton:=true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.ui;bundle-version="[3.107.0,4.0.0)",
+ org.eclipse.papyrus.infra.core.log;bundle-version="[1.2.0,2.0.0)"
+Bundle-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 1.2.0.qualifier
+Bundle-Localization: plugin
+Bundle-Name: %pluginName
+Bundle-Activator: org.eclipse.papyrus.editor.perspectiveconfiguration.Activator
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.papyrus.editor.perspectiveconfiguration;singleton:=true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/editor/org.eclipse.papyrus.editor/.project b/plugins/editor/org.eclipse.papyrus.editor/.project
index a1655428dd3..bcda344097c 100644
--- a/plugins/editor/org.eclipse.papyrus.editor/.project
+++ b/plugins/editor/org.eclipse.papyrus.editor/.project
@@ -1,28 +1,52 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.papyrus.editor</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>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.editor</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.oomph.version.VersionBuilder</name>
+ <arguments>
+ <dictionary>
+ <key>check.maven.pom</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>ignore.lower.bound.dependency.ranges</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>release.path</key>
+ <value>/org.eclipse.papyrus.releng.main.release/release.xml</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ <nature>org.eclipse.oomph.version.VersionNature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF b/plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF
index db81ddb06ad..d23769077ef 100644
--- a/plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF
+++ b/plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF
@@ -1,20 +1,13 @@
-Manifest-Version: 1.0
-Export-Package: org.eclipse.papyrus.editor
-Require-Bundle: org.eclipse.papyrus.infra.core;bundle-version="1.2.0",
- org.eclipse.emf.transaction;bundle-version="1.4.0",
- org.eclipse.gmf.runtime.notation;bundle-version="1.5.0",
- org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0",
- org.eclipse.papyrus.infra.core.sasheditor;bundle-version="1.2.0",
- org.eclipse.ui.ide;bundle-version="3.8.0",
- org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0",
- com.google.guava;bundle-version="11.0.0",
- org.eclipse.papyrus.infra.ui;bundle-version="1.2.0"
-Bundle-Vendor: %providerName
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.2.0.qualifier
-Bundle-Localization: plugin
-Bundle-Name: %pluginName
-Bundle-Activator: org.eclipse.papyrus.editor.Activator
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.papyrus.editor;singleton:=true
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Manifest-Version: 1.0
+Export-Package: org.eclipse.papyrus.editor
+Require-Bundle: org.eclipse.gmf.runtime.diagram.ui;bundle-version="[1.8.0,2.0.0)",
+ org.eclipse.papyrus.infra.ui;bundle-version="[1.2.0,2.0.0)";visibility:=reexport
+Bundle-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 1.2.0.qualifier
+Bundle-Localization: plugin
+Bundle-Name: %pluginName
+Bundle-Activator: org.eclipse.papyrus.editor.Activator
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.papyrus.editor;singleton:=true
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6

Back to the top