Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-09-11 08:02:59 +0000
committerEike Stepper2012-09-11 08:02:59 +0000
commitb9d571b18e56715f5e69a1e741e401d91fd00659 (patch)
treec28442f20de5ebddd1ceac9975988e0889f9c04a /plugins/org.eclipse.emf.cdo.releng.version.ui
parent25a8adcee1ec2b5a414072e34a416faeb299e109 (diff)
downloadcdo-b9d571b18e56715f5e69a1e741e401d91fd00659.tar.gz
cdo-b9d571b18e56715f5e69a1e741e401d91fd00659.tar.xz
cdo-b9d571b18e56715f5e69a1e741e401d91fd00659.zip
Version Management changes, including suggesting a location for
the release.xml
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.releng.version.ui')
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/plugin.xml4
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/actions/AddNatureAction.java215
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/dialogs/ConfigurationDialog.java20
4 files changed, 228 insertions, 14 deletions
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.releng.version.ui/META-INF/MANIFEST.MF
index 264eb59926..2e28993e2b 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/META-INF/MANIFEST.MF
@@ -15,7 +15,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.8.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.4.0,4.0.0)",
org.eclipse.ui.ide;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.emf.cdo.releng.version;bundle-version="[2.0.0,3.0.0)";visibility:=reexport
+ org.eclipse.emf.cdo.releng.version;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
+ org.eclipse.pde.core;bundle-version="[3.4.0,4.0.0)"
Export-Package: org.eclipse.emf.cdo.releng.version.ui;version="2.0.0";x-internal:=true,
org.eclipse.emf.cdo.releng.version.ui.actions;version="2.0.0";x-internal:=true,
org.eclipse.emf.cdo.releng.version.ui.dialogs;version="2.0.0";x-internal:=true,
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/plugin.xml b/plugins/org.eclipse.emf.cdo.releng.version.ui/plugin.xml
index e206a10476..0c654cc143 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version.ui/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/plugin.xml
@@ -23,7 +23,7 @@
class="org.eclipse.emf.cdo.releng.version.ui.actions.AddNatureAction"
enablesFor="*"
id="org.eclipse.emf.cdo.releng.AddNatureAction"
- label="Add Version Management"
+ label="Add Version Management..."
menubarPath="org.eclipse.ui.projectConfigure/additions"
state="true"
style="push"
@@ -46,7 +46,7 @@
class="org.eclipse.emf.cdo.releng.version.ui.actions.ConfigureBuilderAction"
enablesFor="*"
id="org.eclipse.emf.cdo.releng.ConfigureBuilderAction"
- label="Configure Version Management"
+ label="Configure Version Management..."
menubarPath="org.eclipse.ui.projectConfigure/additions"
state="true"
style="push"
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/actions/AddNatureAction.java b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/actions/AddNatureAction.java
index 2009e2c7bd..f19c7d9dcd 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/actions/AddNatureAction.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/actions/AddNatureAction.java
@@ -11,20 +11,49 @@
package org.eclipse.emf.cdo.releng.version.ui.actions;
import org.eclipse.emf.cdo.releng.internal.version.IVersionBuilderArguments;
+import org.eclipse.emf.cdo.releng.internal.version.ReleaseManager;
import org.eclipse.emf.cdo.releng.internal.version.VersionBuilderArguments;
+import org.eclipse.emf.cdo.releng.internal.version.VersionNature;
+import org.eclipse.emf.cdo.releng.version.IElement;
+import org.eclipse.emf.cdo.releng.version.IReleaseManager;
+import org.eclipse.emf.cdo.releng.version.VersionUtil;
+import org.eclipse.emf.cdo.releng.version.ui.Activator;
import org.eclipse.emf.cdo.releng.version.ui.dialogs.ConfigurationDialog;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.osgi.service.resolver.VersionRange;
+import org.eclipse.pde.core.IEditableModel;
+import org.eclipse.pde.core.IModel;
+import org.eclipse.pde.core.build.IBuild;
+import org.eclipse.pde.core.build.IBuildEntry;
+import org.eclipse.pde.core.build.IBuildModel;
+import org.eclipse.pde.core.plugin.IPlugin;
+import org.eclipse.pde.core.plugin.IPluginImport;
+import org.eclipse.pde.core.plugin.IPluginModel;
+import org.eclipse.pde.core.plugin.IPluginModelBase;
+import org.eclipse.pde.core.plugin.PluginRegistry;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
/**
* @author Eike Stepper
*/
public class AddNatureAction extends AbstractAction<IVersionBuilderArguments>
{
+ private static final String SRC_INCLUDES = "src.includes";
+
public AddNatureAction()
{
super("Add Version Management");
@@ -33,11 +62,195 @@ public class AddNatureAction extends AbstractAction<IVersionBuilderArguments>
@Override
protected IVersionBuilderArguments promptArguments()
{
+ List<IProject> projects = new ArrayList<IProject>();
+ for (Iterator<?> it = ((IStructuredSelection)selection).iterator(); it.hasNext();)
+ {
+ Object element = it.next();
+ if (element instanceof IProject)
+ {
+ projects.add((IProject)element);
+ }
+ }
+
+ List<IProject> basePlugins = new ArrayList<IProject>();
+ List<IProject> baseFeatures = new ArrayList<IProject>();
+ for (int i = 0; i < projects.size(); ++i)
+ {
+ IProject project = projects.get(i);
+ IModel componentModel = VersionUtil.getComponentModel(project);
+ if (componentModel != null)
+ {
+ boolean dependenciesIncluded = false;
+ IElement element = IReleaseManager.INSTANCE.createElement(componentModel, true, false);
+ if (element.getType() == IElement.Type.FEATURE)
+ {
+ for (IElement child : element.getChildren())
+ {
+ IModel childComponentModel = ReleaseManager.INSTANCE.getComponentModel(child);
+ if (childComponentModel != null)
+ {
+ IResource childComponentModelFile = childComponentModel.getUnderlyingResource();
+ if (childComponentModelFile != null)
+ {
+ IProject childProject = childComponentModelFile.getProject();
+ if (projects.contains(childProject))
+ {
+ dependenciesIncluded = true;
+ }
+ else
+ {
+ try
+ {
+ if (!childProject.hasNature(VersionNature.NATURE_ID))
+ {
+ projects.add(childProject);
+ dependenciesIncluded = true;
+ }
+ }
+ catch (CoreException ex)
+ {
+ Activator.log(ex);
+ }
+ }
+ }
+ }
+ }
+
+ if (!dependenciesIncluded)
+ {
+ baseFeatures.add(project);
+ }
+ }
+ else
+ {
+ IPlugin plugin = ((IPluginModel)componentModel).getPlugin();
+ for (IPluginImport pluginImport : plugin.getImports())
+ {
+ String importedPluginID = pluginImport.getId();
+ String version = pluginImport.getVersion();
+ IPluginModelBase importedPlugin = PluginRegistry.findModel(importedPluginID, new VersionRange(version),
+ null);
+ if (importedPlugin != null)
+ {
+ IResource childComponentModelFile = importedPlugin.getUnderlyingResource();
+ if (childComponentModelFile != null)
+ {
+ IProject childProject = childComponentModelFile.getProject();
+ if (projects.contains(childProject))
+ {
+ dependenciesIncluded = true;
+ }
+ else
+ {
+ try
+ {
+ if (!childProject.hasNature(VersionNature.NATURE_ID))
+ {
+ projects.add(childProject);
+ dependenciesIncluded = true;
+ }
+ }
+ catch (CoreException ex)
+ {
+ Activator.log(ex);
+ }
+ }
+ }
+ }
+ }
+
+ if (!dependenciesIncluded)
+ {
+ basePlugins.add(project);
+ }
+ }
+ }
+ }
+
+ IProject candidate = null;
+ for (IProject project : basePlugins)
+ {
+ try
+ {
+ if (project.hasNature("org.eclipse.jdt.core.javanature"))
+ {
+ candidate = project;
+ break;
+ }
+ }
+ catch (CoreException ex)
+ {
+ Activator.log(ex);
+ }
+ }
+
+ if (candidate == null)
+ {
+ if (!basePlugins.isEmpty())
+ {
+ candidate = basePlugins.get(0);
+ }
+ else if (!baseFeatures.isEmpty())
+ {
+ candidate = baseFeatures.get(0);
+ }
+ }
+
+ selection = new StructuredSelection(projects);
VersionBuilderArguments arguments = new VersionBuilderArguments();
- ConfigurationDialog dialog = new ConfigurationDialog(shell, arguments);
+ if (candidate != null)
+ {
+ arguments.setReleasePath("/" + candidate.getName() + "/release.xml");
+ }
+ ConfigurationDialog dialog = new ConfigurationDialog(shell, arguments);
if (dialog.open() == ConfigurationDialog.OK)
{
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(dialog.getReleasePath()));
+ IProject project = file.getProject();
+ if (project.isAccessible())
+ {
+ IModel componentModel = VersionUtil.getComponentModel(project);
+ if (componentModel instanceof IPluginModelBase)
+ {
+ try
+ {
+ IBuildModel buildModel = VersionUtil.getBuildModel(componentModel);
+ if (buildModel instanceof IEditableModel)
+ {
+ IBuild build = buildModel.getBuild();
+ if (build != null)
+ {
+ IBuildEntry entry = build.getEntry(SRC_INCLUDES);
+ if (entry == null)
+ {
+ entry = buildModel.getFactory().createEntry(SRC_INCLUDES);
+ }
+
+ String[] tokens = entry.getTokens();
+ Set<String> value = new HashSet<String>();
+ if (tokens != null)
+ {
+ value.addAll(Arrays.asList(tokens));
+ }
+
+ String releasePath = file.getProjectRelativePath().makeRelative().removeFileExtension()
+ .addFileExtension("*").toString();
+ if (!value.contains(releasePath))
+ {
+ entry.addToken(releasePath);
+ ((IEditableModel)buildModel).save();
+ }
+ }
+ }
+ }
+ catch (CoreException ex)
+ {
+ Activator.log(ex);
+ }
+ }
+ }
+
return dialog;
}
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/dialogs/ConfigurationDialog.java b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/dialogs/ConfigurationDialog.java
index 6597be77ec..740b5187a9 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/dialogs/ConfigurationDialog.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/dialogs/ConfigurationDialog.java
@@ -169,52 +169,52 @@ public class ConfigurationDialog extends TitleAreaDialog implements IVersionBuil
public String getReleasePath()
{
- throw new UnsupportedOperationException();
+ return values.getReleasePath();
}
public String getValidatorClassName()
{
- throw new UnsupportedOperationException();
+ return values.getValidatorClassName();
}
public boolean isIgnoreMalformedVersions()
{
- throw new UnsupportedOperationException();
+ return values.isIgnoreMalformedVersions();
}
public boolean isIgnoreFeatureNature()
{
- throw new UnsupportedOperationException();
+ return values.isIgnoreFeatureNature();
}
public boolean isIgnoreSchemaBuilder()
{
- throw new UnsupportedOperationException();
+ return values.isIgnoreSchemaBuilder();
}
public boolean isIgnoreDebugOptions()
{
- throw new UnsupportedOperationException();
+ return values.isIgnoreDebugOptions();
}
public boolean isIgnoreMissingDependencyRanges()
{
- throw new UnsupportedOperationException();
+ return values.isIgnoreMissingDependencyRanges();
}
public boolean isIgnoreMissingExportVersions()
{
- throw new UnsupportedOperationException();
+ return values.isIgnoreMissingExportVersions();
}
public boolean isIgnoreFeatureContentRedundancy()
{
- throw new UnsupportedOperationException();
+ return values.isIgnoreFeatureContentRedundancy();
}
public boolean isIgnoreFeatureContentChanges()
{
- throw new UnsupportedOperationException();
+ return values.isIgnoreFeatureContentChanges();
}
public void applyTo(IProject project) throws CoreException

Back to the top