Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-07-28 16:19:20 +0000
committerEike Stepper2012-07-28 16:19:20 +0000
commit6674748a1cc82cfe4440621ef4b77f0f06293d48 (patch)
tree896b23c1ca545fe8b690b3e849425bba974016ad /plugins
parentf90897e88076acf7862923fbd8592ee330a80c01 (diff)
downloadcdo-6674748a1cc82cfe4440621ef4b77f0f06293d48.tar.gz
cdo-6674748a1cc82cfe4440621ef4b77f0f06293d48.tar.xz
cdo-6674748a1cc82cfe4440621ef4b77f0f06293d48.zip
Better structure for version UI
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/META-INF/MANIFEST.MF5
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/plugin.xml8
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/QuickFixer.java307
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/actions/AbstractAction.java (renamed from plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/AbstractAction.java)4
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/actions/AddNatureAction.java (renamed from plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/AddNatureAction.java)3
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/actions/ConfigureBuilderAction.java (renamed from plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/ConfigureBuilderAction.java)3
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/actions/RemoveNatureAction.java (renamed from plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/RemoveNatureAction.java)2
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/dialogs/ConfigurationDialog.java (renamed from plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/ConfigurationDialog.java)2
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/AbstractDocumentResolution.java60
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/AbstractResolution.java99
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/ConfigureResolution.java57
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/ReplaceResolution.java92
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/VersionResolutionGenerator.java65
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/Release.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/VersionBuilder.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/VersionNature.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/Markers.java (renamed from plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/Markers.java)4
17 files changed, 396 insertions, 318 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 7dbb35e101..8714f5e351 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
@@ -16,5 +16,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.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
-Export-Package: org.eclipse.emf.cdo.releng.version.ui;version="2.0.0";x-internal:=true
+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,
+ org.eclipse.emf.cdo.releng.version.ui.quickfixes;version="2.0.0";x-internal:=true
Eclipse-BuddyPolicy: dependent
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 7c3d49483a..0e5097f622 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version.ui/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/plugin.xml
@@ -20,7 +20,7 @@
id="org.eclipse.emf.cdo.releng.version.ui.contribution1"
objectClass="org.eclipse.core.resources.IProject">
<action
- class="org.eclipse.emf.cdo.releng.version.ui.AddNatureAction"
+ class="org.eclipse.emf.cdo.releng.version.ui.actions.AddNatureAction"
enablesFor="*"
id="org.eclipse.emf.cdo.releng.AddNatureAction"
label="Add Version Management"
@@ -43,7 +43,7 @@
id="org.eclipse.emf.cdo.releng.version.ui.contribution2"
objectClass="org.eclipse.core.resources.IProject">
<action
- class="org.eclipse.emf.cdo.releng.version.ui.ConfigureBuilderAction"
+ class="org.eclipse.emf.cdo.releng.version.ui.actions.ConfigureBuilderAction"
enablesFor="*"
id="org.eclipse.emf.cdo.releng.ConfigureBuilderAction"
label="Configure Version Management"
@@ -64,7 +64,7 @@
id="org.eclipse.emf.cdo.releng.version.ui.contribution3"
objectClass="org.eclipse.core.resources.IProject">
<action
- class="org.eclipse.emf.cdo.releng.version.ui.RemoveNatureAction"
+ class="org.eclipse.emf.cdo.releng.version.ui.actions.RemoveNatureAction"
enablesFor="*"
id="org.eclipse.emf.cdo.releng.RemoveNatureAction"
label="Remove Version Management"
@@ -85,7 +85,7 @@
<extension
point="org.eclipse.ui.ide.markerResolution">
<markerResolutionGenerator
- class="org.eclipse.emf.cdo.releng.version.ui.QuickFixer"
+ class="org.eclipse.emf.cdo.releng.version.ui.quickfixes.VersionResolutionGenerator"
markerType="org.eclipse.emf.cdo.releng.version.VersionProblem">
</markerResolutionGenerator>
</extension>
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/QuickFixer.java b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/QuickFixer.java
deleted file mode 100644
index fd156bb11e..0000000000
--- a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/QuickFixer.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * 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;
-
-import org.eclipse.emf.cdo.releng.internal.version.Markers;
-import org.eclipse.emf.cdo.releng.internal.version.VersionBuilderArguments;
-
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-import org.eclipse.core.filebuffers.LocationKind;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IMarkerResolution;
-import org.eclipse.ui.IMarkerResolutionGenerator2;
-import org.eclipse.ui.views.markers.WorkbenchMarkerResolution;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * @author Eike Stepper
- */
-public class QuickFixer implements IMarkerResolutionGenerator2
-{
- public QuickFixer()
- {
- }
-
- public IMarkerResolution[] getResolutions(IMarker marker)
- {
- List<IMarkerResolution> resolutions = new ArrayList<IMarkerResolution>();
-
- String regEx = Markers.getQuickFixPattern(marker);
- if (regEx != null)
- {
- String replacement = Markers.getQuickFixReplacement(marker);
- resolutions.add(new ReplaceResolution(marker, replacement));
- }
-
- String ignoreOption = Markers.getQuickFixConfigureOption(marker);
- if (ignoreOption != null)
- {
- resolutions.add(new ConfigureResolution(marker, ignoreOption));
- }
-
- return resolutions.toArray(new IMarkerResolution[resolutions.size()]);
- }
-
- public boolean hasResolutions(IMarker marker)
- {
- if (Markers.getQuickFixPattern(marker) != null)
- {
- return true;
- }
-
- if (Markers.getQuickFixConfigureOption(marker) != null)
- {
- return true;
- }
-
- return false;
- }
-
- /**
- * @author Eike Stepper
- */
- private abstract class AbstractResolution extends WorkbenchMarkerResolution
- {
- private IMarker marker;
-
- private String label;
-
- private String imageKey;
-
- public AbstractResolution(IMarker marker, String label, String imageKey)
- {
- this.marker = marker;
- this.label = label;
- this.imageKey = imageKey;
- }
-
- public IMarker getMarker()
- {
- return marker;
- }
-
- public String getLabel()
- {
- return label;
- }
-
- public String getDescription()
- {
- return "";
- }
-
- public final Image getImage()
- {
- ImageRegistry imageRegistry = Activator.getPlugin().getImageRegistry();
- return imageRegistry.get(imageKey);
- }
-
- @Override
- public IMarker[] findOtherMarkers(IMarker[] markers)
- {
- List<IMarker> result = new ArrayList<IMarker>();
- for (IMarker marker : markers)
- {
- try
- {
- if (marker != this.marker && isApplicable(marker))
- {
- result.add(marker);
- }
- }
- catch (Exception ex)
- {
- Activator.log(ex);
- }
- }
-
- return result.toArray(new IMarker[result.size()]);
- }
-
- protected abstract boolean isApplicable(IMarker marker) throws Exception;
-
- public final void run(IMarker marker)
- {
- try
- {
- apply(marker);
- }
- catch (Exception ex)
- {
- Activator.log(ex);
- }
- }
-
- protected abstract void apply(IMarker marker) throws Exception;
- }
-
- /**
- * @author Eike Stepper
- */
- private abstract class AbstractDocumentResolution extends AbstractResolution
- {
- public AbstractDocumentResolution(IMarker marker, String label, String imageKey)
- {
- super(marker, label, imageKey);
- }
-
- @Override
- protected final void apply(IMarker marker) throws Exception
- {
- IPath fullPath = ((IFile)marker.getResource()).getFullPath();
- ITextFileBufferManager.DEFAULT.connect(fullPath, LocationKind.IFILE, new NullProgressMonitor());
-
- try
- {
- ITextFileBuffer buffer = ITextFileBufferManager.DEFAULT.getTextFileBuffer(fullPath, LocationKind.IFILE);
- boolean wasDirty = buffer.isDirty();
-
- IDocument document = buffer.getDocument();
- if (apply(marker, document))
- {
- if (!wasDirty && !buffer.isShared())
- {
- buffer.commit(new NullProgressMonitor(), true);
- }
- }
- }
- finally
- {
- ITextFileBufferManager.DEFAULT.disconnect(fullPath, LocationKind.IFILE, new NullProgressMonitor());
- }
- }
-
- protected abstract boolean apply(IMarker marker, IDocument document) throws Exception;
- }
-
- /**
- * @author Eike Stepper
- */
- private class ReplaceResolution extends AbstractDocumentResolution
- {
- private String replacement;
-
- public ReplaceResolution(IMarker marker, String replacement)
- {
- super(marker, replacement == null ? "Remove the reference" : "Change the version",
- replacement == null ? Activator.CORRECTION_DELETE_GIF : Activator.CORRECTION_CHANGE_GIF);
- this.replacement = replacement == null ? "" : replacement;
- }
-
- @Override
- public String getDescription()
- {
- if (replacement.length() != 0)
- {
- return getLabel() + " to " + replacement;
- }
-
- return super.getDescription();
- }
-
- @Override
- protected boolean isApplicable(IMarker marker)
- {
- if (Markers.getQuickFixPattern(marker) == null)
- {
- return false;
- }
-
- boolean expectedReplacement = replacement.length() != 0;
- boolean actualReplacement = Markers.getQuickFixReplacement(marker) != null;
- return actualReplacement == expectedReplacement;
- }
-
- @Override
- protected boolean apply(IMarker marker, IDocument document) throws Exception
- {
- String content = document.get();
-
- String regEx = Markers.getQuickFixPattern(marker);
- String replacement = Markers.getQuickFixReplacement(marker);
-
- Pattern pattern = Pattern.compile(regEx, Pattern.MULTILINE | Pattern.DOTALL);
- Matcher matcher = pattern.matcher(content);
- if (matcher.find())
- {
- int start;
- int end;
- if (replacement != null && replacement.length() != 0)
- {
- start = matcher.start(1);
- end = matcher.end(1);
- }
- else
- {
- start = matcher.start();
- end = matcher.end();
- replacement = "";
- }
-
- document.replace(start, end - start, replacement);
- return true;
- }
-
- return false;
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private class ConfigureResolution extends AbstractResolution
- {
- private String option;
-
- public ConfigureResolution(IMarker marker, String option)
- {
- super(marker, "Configure the project to ignore the problem", Activator.CORRECTION_CONFIGURE_GIF);
- this.option = option;
- }
-
- @Override
- public String getDescription()
- {
- IProject project = getMarker().getResource().getProject();
- return "Set " + option + " = true in '/" + project.getName() + "/.project'";
- }
-
- @Override
- protected boolean isApplicable(IMarker marker)
- {
- String requiredOption = Markers.getQuickFixConfigureOption(marker);
- return option.equals(requiredOption);
- }
-
- @Override
- protected void apply(IMarker marker) throws Exception
- {
- String option = Markers.getQuickFixConfigureOption(marker);
-
- IProject project = marker.getResource().getProject();
- VersionBuilderArguments arguments = new VersionBuilderArguments(project);
- arguments.put(option, "true");
- arguments.applyTo(project);
- }
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/AbstractAction.java b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/actions/AbstractAction.java
index 394d4baa9d..afceef4032 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/AbstractAction.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/actions/AbstractAction.java
@@ -8,7 +8,9 @@
* Contributors:
* Eike Stepper - initial API and implementation
*/
-package org.eclipse.emf.cdo.releng.version.ui;
+package org.eclipse.emf.cdo.releng.version.ui.actions;
+
+import org.eclipse.emf.cdo.releng.version.ui.Activator;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/AddNatureAction.java b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/actions/AddNatureAction.java
index ee3fa1ea34..2009e2c7bd 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/AddNatureAction.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/actions/AddNatureAction.java
@@ -8,10 +8,11 @@
* Contributors:
* Eike Stepper - initial API and implementation
*/
-package org.eclipse.emf.cdo.releng.version.ui;
+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.VersionBuilderArguments;
+import org.eclipse.emf.cdo.releng.version.ui.dialogs.ConfigurationDialog;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/ConfigureBuilderAction.java b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/actions/ConfigureBuilderAction.java
index 8c9315de3e..f7482b742b 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/ConfigureBuilderAction.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/actions/ConfigureBuilderAction.java
@@ -8,11 +8,12 @@
* Contributors:
* Eike Stepper - initial API and implementation
*/
-package org.eclipse.emf.cdo.releng.version.ui;
+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.VersionBuilderArguments;
import org.eclipse.emf.cdo.releng.version.VersionUtil;
+import org.eclipse.emf.cdo.releng.version.ui.dialogs.ConfigurationDialog;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/RemoveNatureAction.java b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/actions/RemoveNatureAction.java
index 4bdd695ef2..03e73e277f 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/RemoveNatureAction.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/actions/RemoveNatureAction.java
@@ -8,7 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
*/
-package org.eclipse.emf.cdo.releng.version.ui;
+package org.eclipse.emf.cdo.releng.version.ui.actions;
import org.eclipse.emf.cdo.releng.internal.version.VersionBuilderArguments;
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/ConfigurationDialog.java b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/dialogs/ConfigurationDialog.java
index 85e62b0854..b56c071518 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/ConfigurationDialog.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/dialogs/ConfigurationDialog.java
@@ -8,7 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
*/
-package org.eclipse.emf.cdo.releng.version.ui;
+package org.eclipse.emf.cdo.releng.version.ui.dialogs;
import org.eclipse.emf.cdo.releng.internal.version.IVersionBuilderArguments;
import org.eclipse.emf.cdo.releng.internal.version.VersionBuilderArguments;
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/AbstractDocumentResolution.java b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/AbstractDocumentResolution.java
new file mode 100644
index 0000000000..9e8d9000d8
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/AbstractDocumentResolution.java
@@ -0,0 +1,60 @@
+/*
+ * 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.core.filebuffers.ITextFileBuffer;
+import org.eclipse.core.filebuffers.ITextFileBufferManager;
+import org.eclipse.core.filebuffers.LocationKind;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.text.IDocument;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractDocumentResolution extends AbstractResolution
+{
+ public AbstractDocumentResolution(IMarker marker, String label, String imageKey)
+ {
+ super(marker, label, imageKey);
+ }
+
+ @Override
+ protected final void apply(IMarker marker) throws Exception
+ {
+ IPath fullPath = ((IFile)marker.getResource()).getFullPath();
+ ITextFileBufferManager.DEFAULT.connect(fullPath, LocationKind.IFILE, new NullProgressMonitor());
+
+ try
+ {
+ ITextFileBuffer buffer = ITextFileBufferManager.DEFAULT.getTextFileBuffer(fullPath, LocationKind.IFILE);
+ boolean wasDirty = buffer.isDirty();
+
+ IDocument document = buffer.getDocument();
+ if (apply(marker, document))
+ {
+ if (!wasDirty && !buffer.isShared())
+ {
+ buffer.commit(new NullProgressMonitor(), true);
+ }
+ }
+ }
+ finally
+ {
+ ITextFileBufferManager.DEFAULT.disconnect(fullPath, LocationKind.IFILE, new NullProgressMonitor());
+ }
+ }
+
+ protected abstract boolean apply(IMarker marker, IDocument document) throws Exception;
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/AbstractResolution.java b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/AbstractResolution.java
new file mode 100644
index 0000000000..d0fed0b52f
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/AbstractResolution.java
@@ -0,0 +1,99 @@
+/*
+ * 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.version.ui.Activator;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.views.markers.WorkbenchMarkerResolution;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractResolution extends WorkbenchMarkerResolution
+{
+ private IMarker marker;
+
+ private String label;
+
+ private String imageKey;
+
+ public AbstractResolution(IMarker marker, String label, String imageKey)
+ {
+ this.marker = marker;
+ this.label = label;
+ this.imageKey = imageKey;
+ }
+
+ public IMarker getMarker()
+ {
+ return marker;
+ }
+
+ public String getLabel()
+ {
+ return label;
+ }
+
+ public String getDescription()
+ {
+ return "";
+ }
+
+ public final Image getImage()
+ {
+ ImageRegistry imageRegistry = Activator.getPlugin().getImageRegistry();
+ return imageRegistry.get(imageKey);
+ }
+
+ @Override
+ public IMarker[] findOtherMarkers(IMarker[] markers)
+ {
+ List<IMarker> result = new ArrayList<IMarker>();
+ for (IMarker marker : markers)
+ {
+ try
+ {
+ if (marker != this.marker && isApplicable(marker))
+ {
+ result.add(marker);
+ }
+ }
+ catch (Exception ex)
+ {
+ Activator.log(ex);
+ }
+ }
+
+ return result.toArray(new IMarker[result.size()]);
+ }
+
+ protected abstract boolean isApplicable(IMarker marker) throws Exception;
+
+ public final void run(IMarker marker)
+ {
+ try
+ {
+ apply(marker);
+ }
+ catch (Exception ex)
+ {
+ Activator.log(ex);
+ }
+ }
+
+ protected abstract void apply(IMarker marker) throws Exception;
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/ConfigureResolution.java b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/ConfigureResolution.java
new file mode 100644
index 0000000000..fc4a44e9cc
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/ConfigureResolution.java
@@ -0,0 +1,57 @@
+/*
+ * 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.ui.Activator;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+
+/**
+ * @author Eike Stepper
+ */
+public class ConfigureResolution extends AbstractResolution
+{
+ private String option;
+
+ public ConfigureResolution(IMarker marker, String option)
+ {
+ super(marker, "Configure the project to ignore the problem", Activator.CORRECTION_CONFIGURE_GIF);
+ this.option = option;
+ }
+
+ @Override
+ public String getDescription()
+ {
+ IProject project = getMarker().getResource().getProject();
+ return "Set " + option + " = true in '/" + project.getName() + "/.project'";
+ }
+
+ @Override
+ protected boolean isApplicable(IMarker marker)
+ {
+ String requiredOption = Markers.getQuickFixConfigureOption(marker);
+ return option.equals(requiredOption);
+ }
+
+ @Override
+ protected void apply(IMarker marker) throws Exception
+ {
+ String option = Markers.getQuickFixConfigureOption(marker);
+
+ IProject project = marker.getResource().getProject();
+ VersionBuilderArguments arguments = new VersionBuilderArguments(project);
+ arguments.put(option, "true");
+ arguments.applyTo(project);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/ReplaceResolution.java b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/ReplaceResolution.java
new file mode 100644
index 0000000000..b64f503a2f
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/ReplaceResolution.java
@@ -0,0 +1,92 @@
+/*
+ * 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.version.Markers;
+import org.eclipse.emf.cdo.releng.version.ui.Activator;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.jface.text.IDocument;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author Eike Stepper
+ */
+public class ReplaceResolution extends AbstractDocumentResolution
+{
+ private String replacement;
+
+ public ReplaceResolution(IMarker marker, String replacement)
+ {
+ super(marker, replacement == null ? "Remove the reference" : "Change the version",
+ replacement == null ? Activator.CORRECTION_DELETE_GIF : Activator.CORRECTION_CHANGE_GIF);
+ this.replacement = replacement == null ? "" : replacement;
+ }
+
+ @Override
+ public String getDescription()
+ {
+ if (replacement.length() != 0)
+ {
+ return getLabel() + " to " + replacement;
+ }
+
+ return super.getDescription();
+ }
+
+ @Override
+ protected boolean isApplicable(IMarker marker)
+ {
+ if (Markers.getQuickFixPattern(marker) == null)
+ {
+ return false;
+ }
+
+ boolean expectedReplacement = replacement.length() != 0;
+ boolean actualReplacement = Markers.getQuickFixReplacement(marker) != null;
+ return actualReplacement == expectedReplacement;
+ }
+
+ @Override
+ protected boolean apply(IMarker marker, IDocument document) throws Exception
+ {
+ String content = document.get();
+
+ String regEx = Markers.getQuickFixPattern(marker);
+ String replacement = Markers.getQuickFixReplacement(marker);
+
+ Pattern pattern = Pattern.compile(regEx, Pattern.MULTILINE | Pattern.DOTALL);
+ Matcher matcher = pattern.matcher(content);
+ if (matcher.find())
+ {
+ int start;
+ int end;
+ if (replacement != null && replacement.length() != 0)
+ {
+ start = matcher.start(1);
+ end = matcher.end(1);
+ }
+ else
+ {
+ start = matcher.start();
+ end = matcher.end();
+ replacement = "";
+ }
+
+ document.replace(start, end - start, replacement);
+ return true;
+ }
+
+ return false;
+ }
+} \ No newline at end of file
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
new file mode 100644
index 0000000000..e1dcb10a86
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.version.ui/src/org/eclipse/emf/cdo/releng/version/ui/quickfixes/VersionResolutionGenerator.java
@@ -0,0 +1,65 @@
+/*
+ * 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.version.Markers;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.ui.IMarkerResolution;
+import org.eclipse.ui.IMarkerResolutionGenerator2;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class VersionResolutionGenerator implements IMarkerResolutionGenerator2
+{
+ public VersionResolutionGenerator()
+ {
+ }
+
+ public IMarkerResolution[] getResolutions(IMarker marker)
+ {
+ List<IMarkerResolution> resolutions = new ArrayList<IMarkerResolution>();
+
+ String regEx = Markers.getQuickFixPattern(marker);
+ if (regEx != null)
+ {
+ String replacement = Markers.getQuickFixReplacement(marker);
+ resolutions.add(new ReplaceResolution(marker, replacement));
+ }
+
+ String ignoreOption = Markers.getQuickFixConfigureOption(marker);
+ if (ignoreOption != null)
+ {
+ resolutions.add(new ConfigureResolution(marker, ignoreOption));
+ }
+
+ return resolutions.toArray(new IMarkerResolution[resolutions.size()]);
+ }
+
+ public boolean hasResolutions(IMarker marker)
+ {
+ if (Markers.getQuickFixPattern(marker) != null)
+ {
+ return true;
+ }
+
+ if (Markers.getQuickFixConfigureOption(marker) != null)
+ {
+ return true;
+ }
+
+ return false;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/Release.java b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/Release.java
index 10789cf941..6c31017fc3 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/Release.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/Release.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.cdo.releng.internal.version;
import org.eclipse.emf.cdo.releng.version.IElement;
import org.eclipse.emf.cdo.releng.version.IRelease;
+import org.eclipse.emf.cdo.releng.version.Markers;
import org.eclipse.emf.cdo.releng.version.VersionUtil;
import org.eclipse.core.resources.IFile;
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 a2923e6f29..a4d9c4c8ff 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
@@ -14,6 +14,7 @@ import org.eclipse.emf.cdo.releng.version.IElement;
import org.eclipse.emf.cdo.releng.version.IElementResolver;
import org.eclipse.emf.cdo.releng.version.IRelease;
import org.eclipse.emf.cdo.releng.version.IReleaseManager;
+import org.eclipse.emf.cdo.releng.version.Markers;
import org.eclipse.emf.cdo.releng.version.VersionUtil;
import org.eclipse.emf.cdo.releng.version.VersionValidator;
diff --git a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/VersionNature.java b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/VersionNature.java
index 130d3ed2f6..7c80870c2d 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/VersionNature.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/VersionNature.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.emf.cdo.releng.internal.version;
+import org.eclipse.emf.cdo.releng.version.Markers;
import org.eclipse.emf.cdo.releng.version.VersionUtil;
import org.eclipse.core.resources.ICommand;
diff --git a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/Markers.java b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/Markers.java
index dd24f482b4..65306a4327 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/internal/version/Markers.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/Markers.java
@@ -8,7 +8,9 @@
* Contributors:
* Eike Stepper - initial API and implementation
*/
-package org.eclipse.emf.cdo.releng.internal.version;
+package org.eclipse.emf.cdo.releng.version;
+
+import org.eclipse.emf.cdo.releng.internal.version.Activator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;

Back to the top