Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-08-28 12:01:41 +0000
committerEike Stepper2012-08-28 12:01:41 +0000
commit75c6827aa0a46243d7e8a5e6e542cea46947286f (patch)
tree8ccf2a8aad52aa1ac81500e79bc24d212f7e852b /plugins
parent5a8360ab2bbf49f8eb9a84d48f31fee7af28bfe0 (diff)
downloadcdo-75c6827aa0a46243d7e8a5e6e542cea46947286f.tar.gz
cdo-75c6827aa0a46243d7e8a5e6e542cea46947286f.tar.xz
cdo-75c6827aa0a46243d7e8a5e6e542cea46947286f.zip
Add Manage Ignored Releases
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/plugin.xml9
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/preferences/VersionBuilderPreferencePage.java116
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/ReleasePathResolution.java64
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/VersionResolutionGenerator.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/Activator.java132
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/VersionBuilder.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/Markers.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/VersionUtil.java70
8 files changed, 399 insertions, 18 deletions
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 f530571d43..772ccaf344 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version.ui/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/plugin.xml
@@ -90,4 +90,13 @@
</markerResolutionGenerator>
</extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ class="org.eclipse.emf.cdo.releng.version.ui.preferences.VersionBuilderPreferencePage"
+ id="org.eclipse.emf.cdo.releng.version.ui.preferences.VersionBuilderPreferencePage"
+ name="Extended Version Management">
+ </page>
+ </extension>
+
</plugin>
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/preferences/VersionBuilderPreferencePage.java b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/preferences/VersionBuilderPreferencePage.java
new file mode 100644
index 0000000000..2c89e3265f
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/preferences/VersionBuilderPreferencePage.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.releng.version.ui.preferences;
+
+import org.eclipse.emf.cdo.releng.internal.version.Activator;
+import org.eclipse.emf.cdo.releng.version.VersionUtil;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+import java.util.ArrayList;
+import java.util.Collections;
+
+/**
+ * @author Eike Stepper
+ */
+public class VersionBuilderPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+ public VersionBuilderPreferencePage()
+ {
+ super("XXX");
+ setDescription("Manage ignored releases:");
+ }
+
+ public void init(IWorkbench workbench)
+ {
+ // Do nothing
+ }
+
+ @Override
+ protected Control createContents(Composite parent)
+ {
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.numColumns = 2;
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(layout);
+
+ final List list = new List(composite, SWT.BORDER | SWT.SINGLE);
+ list.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
+
+ java.util.List<String> ignoredReleases = new ArrayList<String>(Activator.getIgnoredReleases());
+ Collections.sort(ignoredReleases);
+ for (String releasePath : ignoredReleases)
+ {
+ list.add(releasePath);
+ }
+
+ final Button button = new Button(composite, SWT.PUSH);
+ button.setText("Remove");
+ button.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+ button.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ String releasePath = getSelectedReleasePath(list);
+ if (releasePath != null)
+ {
+ list.remove(releasePath);
+ Activator.getIgnoredReleases().remove(releasePath);
+ VersionUtil.cleanReleaseProjects(releasePath);
+ adjustEnablement(list, button);
+ }
+ }
+ });
+
+ adjustEnablement(list, button);
+ list.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ adjustEnablement(list, button);
+ }
+ });
+
+ return composite;
+ }
+
+ private String getSelectedReleasePath(List list)
+ {
+ String[] selection = list.getSelection();
+ if (selection != null && selection.length != 0)
+ {
+ return selection[0];
+ }
+
+ return null;
+ }
+
+ private void adjustEnablement(final List list, final Button button)
+ {
+ button.setEnabled(getSelectedReleasePath(list) != null);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/ReleasePathResolution.java b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/ReleasePathResolution.java
new file mode 100644
index 0000000000..b584e871b1
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/ReleasePathResolution.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.releng.version.ui.quickfixes;
+
+import org.eclipse.emf.cdo.releng.internal.version.VersionBuilderArguments;
+import org.eclipse.emf.cdo.releng.version.Markers;
+import org.eclipse.emf.cdo.releng.version.VersionUtil;
+import org.eclipse.emf.cdo.releng.version.ui.Activator;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class ReleasePathResolution extends AbstractResolution
+{
+ public ReleasePathResolution(IMarker marker)
+ {
+ super(marker, "Add to ignored releases", Activator.CORRECTION_CONFIGURE_GIF);
+ }
+
+ @Override
+ protected boolean isApplicable(IMarker marker)
+ {
+ return Markers.RELEASE_PATH_PROBLEM.equals(Markers.getProblemType(marker));
+ }
+
+ @Override
+ public String getDescription()
+ {
+ IMarker marker = getMarker();
+ IProject project = marker.getResource().getProject();
+ VersionBuilderArguments arguments = new VersionBuilderArguments(project);
+
+ return "Add '"
+ + arguments.getReleasePath()
+ + "' to the set of ignored releases in the Version Management preferences. To re-enable this release use the Preferences dialog and manage the set of ignored releases.";
+ }
+
+ @Override
+ protected void apply(IMarker marker) throws Exception
+ {
+ IProject project = marker.getResource().getProject();
+ VersionBuilderArguments arguments = new VersionBuilderArguments(project);
+ final String releasePath = arguments.getReleasePath();
+
+ Set<String> ignoredReleases = org.eclipse.emf.cdo.releng.internal.version.Activator.getIgnoredReleases();
+ if (ignoredReleases.add(releasePath))
+ {
+ VersionUtil.cleanReleaseProjects(releasePath);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/VersionResolutionGenerator.java b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/VersionResolutionGenerator.java
index d790f5d0f9..a8c03bc0ba 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/VersionResolutionGenerator.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/VersionResolutionGenerator.java
@@ -68,6 +68,10 @@ public class VersionResolutionGenerator implements IMarkerResolutionGenerator2
{
resolutions.add(new RootProjectResolution(marker));
}
+ else if (Markers.RELEASE_PATH_PROBLEM.equals(problemType))
+ {
+ resolutions.add(new ReleasePathResolution(marker));
+ }
String ignoreOption = Markers.getQuickFixConfigureOption(marker);
if (ignoreOption != null)
@@ -106,6 +110,11 @@ public class VersionResolutionGenerator implements IMarkerResolutionGenerator2
return true;
}
+ if (Markers.RELEASE_PATH_PROBLEM.equals(problemType))
+ {
+ return true;
+ }
+
return false;
}
}
diff --git a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/Activator.java b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/Activator.java
index 322ad4a361..40b54878de 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/Activator.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/Activator.java
@@ -30,9 +30,11 @@ import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
/**
* @author Eike Stepper
@@ -41,13 +43,17 @@ public class Activator extends Plugin
{
public static final String PLUGIN_ID = "org.eclipse.emf.cdo.releng.version";
+ private static final String IGNORED_RELEASES = "ignoredReleases.bin";
+
+ private static final String BUILD_STATES = "buildStates.bin";
+
private static Activator plugin;
private static IResourceChangeListener postBuildListener;
- private Map<String, BuildState> buildStates;
+ private IgnoredReleases ignoredReleases;
- private File stateFile;
+ private Map<String, BuildState> buildStates;
public Activator()
{
@@ -61,8 +67,23 @@ public class Activator extends Plugin
try
{
- File stateFolder = Platform.getStateLocation(getBundle()).toFile();
- stateFile = new File(stateFolder, "buildStates.bin");
+ File stateFile = getStateFile(IGNORED_RELEASES);
+ if (stateFile.exists())
+ {
+ loadIgnoredReleases();
+ }
+ }
+ finally
+ {
+ if (ignoredReleases == null)
+ {
+ ignoredReleases = new IgnoredReleases();
+ }
+ }
+
+ try
+ {
+ File stateFile = getStateFile(BUILD_STATES);
if (stateFile.exists())
{
loadBuildStates();
@@ -93,18 +114,65 @@ public class Activator extends Plugin
buildStates = null;
}
- stateFile = null;
plugin = null;
super.stop(context);
}
+ private File getStateFile(String name)
+ {
+ File stateFolder = Platform.getStateLocation(getBundle()).toFile();
+ return new File(stateFolder, name);
+ }
+
+ private void loadIgnoredReleases()
+ {
+ ObjectInputStream stream = null;
+
+ try
+ {
+ File stateFile = getStateFile(IGNORED_RELEASES);
+ stream = new ObjectInputStream(new FileInputStream(stateFile));
+ ignoredReleases = (IgnoredReleases)stream.readObject();
+ }
+ catch (Exception ex)
+ {
+ log(ex);
+ }
+ finally
+ {
+ VersionUtil.close(stream);
+ }
+ }
+
+ private void saveIgnoredReleases()
+ {
+ ObjectOutputStream stream = null;
+
+ try
+ {
+ File stateFile = getStateFile(IGNORED_RELEASES);
+ stream = new ObjectOutputStream(new FileOutputStream(stateFile));
+ stream.writeObject(ignoredReleases);
+ }
+ catch (Exception ex)
+ {
+ log(ex);
+ }
+ finally
+ {
+ VersionUtil.close(stream);
+ }
+ }
+
private void loadBuildStates()
{
ObjectInputStream stream = null;
try
{
+ File stateFile = getStateFile(BUILD_STATES);
stream = new ObjectInputStream(new FileInputStream(stateFile));
+
@SuppressWarnings("unchecked")
Map<String, BuildState> object = (Map<String, BuildState>)stream.readObject();
buildStates = object;
@@ -136,6 +204,7 @@ public class Activator extends Plugin
try
{
+ File stateFile = getStateFile(BUILD_STATES);
stream = new ObjectOutputStream(new FileOutputStream(stateFile));
stream.writeObject(buildStates);
}
@@ -145,20 +214,15 @@ public class Activator extends Plugin
}
finally
{
- if (stream != null)
- {
- try
- {
- stream.close();
- }
- catch (Exception ex)
- {
- log(ex);
- }
- }
+ VersionUtil.close(stream);
}
}
+ public static Set<String> getIgnoredReleases()
+ {
+ return plugin.ignoredReleases;
+ }
+
public static BuildState getBuildState(IProject project)
{
String name = project.getName();
@@ -216,4 +280,40 @@ public class Activator extends Plugin
{
Activator.postBuildListener = postBuildListener;
}
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class IgnoredReleases extends HashSet<String>
+ {
+ private static final long serialVersionUID = 1L;
+
+ public IgnoredReleases()
+ {
+ }
+
+ @Override
+ public boolean add(String releasePath)
+ {
+ if (super.add(releasePath))
+ {
+ plugin.saveIgnoredReleases();
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean remove(Object releasePath)
+ {
+ if (super.remove(releasePath))
+ {
+ plugin.saveIgnoredReleases();
+ return true;
+ }
+
+ return false;
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/VersionBuilder.java b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/VersionBuilder.java
index 8d7b2b194a..967cc1d90c 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/VersionBuilder.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/VersionBuilder.java
@@ -203,6 +203,7 @@ public class VersionBuilder extends IncrementalProjectBuilder implements IElemen
arguments = null;
}
};
+
project.getWorkspace().addResourceChangeListener(postBuildListener, IResourceChangeEvent.POST_BUILD);
Activator.setPostBuildListener(postBuildListener);
}
@@ -233,6 +234,11 @@ public class VersionBuilder extends IncrementalProjectBuilder implements IElemen
return buildDpependencies.toArray(new IProject[buildDpependencies.size()]);
}
+ if (Activator.getIgnoredReleases().contains(releasePathArg))
+ {
+ return buildDpependencies.toArray(new IProject[buildDpependencies.size()]);
+ }
+
IPath releasePath = new Path(releasePathArg);
try
@@ -263,8 +269,13 @@ public class VersionBuilder extends IncrementalProjectBuilder implements IElemen
{
Activator.log(ex);
String msg = "Problem with release spec: " + releasePath + " (" + ex.getMessage() + ")";
- Markers.addMarker(projectDescription, msg, IMarker.SEVERITY_ERROR,
- "(" + releasePath.toString().replace(".", "\\.") + ")");
+ IMarker marker = Markers.addMarker(projectDescription, msg, IMarker.SEVERITY_ERROR, "("
+ + releasePath.toString().replace(".", "\\.") + ")");
+ if (marker != null)
+ {
+ marker.setAttribute(Markers.PROBLEM_TYPE, Markers.RELEASE_PATH_PROBLEM);
+ }
+
return buildDpependencies.toArray(new IProject[buildDpependencies.size()]);
}
diff --git a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/Markers.java b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/Markers.java
index 961ab1eb28..554b59a7b2 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/Markers.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/Markers.java
@@ -32,6 +32,8 @@ public final class Markers
public static final String DEVIATION_INFO = "deviation";
+ public static final String RELEASE_PATH_PROBLEM = "release.path";
+
public static final String MALFORMED_VERSION_PROBLEM = "malformed.version";
public static final String SCHEMA_BUILDER_PROBLEM = "schema.builder";
diff --git a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/VersionUtil.java b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/VersionUtil.java
index 0dc0b86b28..02dfd2239d 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/VersionUtil.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/VersionUtil.java
@@ -11,15 +11,24 @@
package org.eclipse.emf.cdo.releng.version;
import org.eclipse.emf.cdo.releng.internal.version.Activator;
+import org.eclipse.emf.cdo.releng.internal.version.VersionBuilderArguments;
+import org.eclipse.core.resources.IBuildConfiguration;
+import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.pde.core.IModel;
@@ -40,6 +49,8 @@ import java.io.OutputStream;
import java.io.Reader;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.List;
/**
* @author Eike Stepper
@@ -51,6 +62,8 @@ public final class VersionUtil
public static final boolean DEBUG = Boolean.valueOf(System.getProperty("org.eclipse.emf.cdo.releng.version.debug",
"false"));
+ private static final IWorkspace WORKSPACE = ResourcesPlugin.getWorkspace();
+
private static final byte[] BUFFER = new byte[8192];
private VersionUtil()
@@ -343,4 +356,61 @@ public final class VersionUtil
.getVersion());
return normalize(version);
}
+
+ public static void cleanReleaseProjects(final String releasePath)
+ {
+ new Job("Cleaning workspace")
+ {
+ @Override
+ protected IStatus run(IProgressMonitor monitor)
+ {
+ try
+ {
+ IBuildConfiguration[] buildConfigs = getBuildConfigs(releasePath);
+ WORKSPACE.build(buildConfigs, IncrementalProjectBuilder.CLEAN_BUILD, true, monitor);
+ return Status.OK_STATUS;
+ }
+ catch (CoreException ex)
+ {
+ return ex.getStatus();
+ }
+ }
+ }.schedule();
+ }
+
+ private static IBuildConfiguration[] getBuildConfigs(String releasePath)
+ {
+ List<IBuildConfiguration> buildConfigs = new ArrayList<IBuildConfiguration>();
+ for (IProject project : WORKSPACE.getRoot().getProjects())
+ {
+ if (project.isAccessible())
+ {
+ try
+ {
+ ICommand[] commands = project.getDescription().getBuildSpec();
+ for (ICommand command : commands)
+ {
+ if (BUILDER_ID.equals(command.getBuilderName()))
+ {
+ VersionBuilderArguments arguments = new VersionBuilderArguments(project);
+ String projectReleasePath = arguments.getReleasePath();
+ if (releasePath.equals(projectReleasePath))
+ {
+ IBuildConfiguration buildConfig = project.getActiveBuildConfig();
+ buildConfigs.add(buildConfig);
+ }
+
+ break;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Activator.log(ex);
+ }
+ }
+ }
+
+ return buildConfigs.toArray(new IBuildConfiguration[buildConfigs.size()]);
+ }
}

Back to the top