Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 121426 Details for
Bug 235657
[Markers][Undo] regression: can no longer undo marker operations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Patch 2
patch_235657_2.txt (text/plain), 27.35 KB, created by
Hitesh
on 2009-01-02 06:02:19 EST
(
hide
)
Description:
Patch 2
Filename:
MIME Type:
Creator:
Hitesh
Created:
2009-01-02 06:02:19 EST
Size:
27.35 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.ide >Index: src/org/eclipse/ui/internal/ide/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/messages.properties,v >retrieving revision 1.161 >diff -u -r1.161 messages.properties >--- src/org/eclipse/ui/internal/ide/messages.properties 14 Nov 2008 09:52:16 -0000 1.161 >+++ src/org/eclipse/ui/internal/ide/messages.properties 2 Jan 2009 09:00:38 -0000 >@@ -613,6 +613,7 @@ > > MarkerResolutionSelectionDialog_title = Quick Fix > MarkerResolutionSelectionDialog_messageLabel = &Available fixes: >+MarkerDeleteHandler_JobTitle = Delete Markers ({0}) > > FilteredResourcesSelectionDialog_showDerivedResourcesAction=Show &Derived Resources > >Index: src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java,v >retrieving revision 1.58 >diff -u -r1.58 IDEWorkbenchMessages.java >--- src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java 14 Nov 2008 09:52:16 -0000 1.58 >+++ src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java 2 Jan 2009 09:00:37 -0000 >@@ -591,7 +591,8 @@ > > public static String MarkerResolutionSelectionDialog_title; > public static String MarkerResolutionSelectionDialog_messageLabel; >- >+ public static String MarkerDeleteHandler_JobTitle; >+ > public static String FilteredResourcesSelectionDialog_showDerivedResourcesAction; > > public static String ResourceSelectionDialog_label; >Index: src/org/eclipse/ui/internal/views/markers/BookmarksView.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/BookmarksView.java,v >retrieving revision 1.1 >diff -u -r1.1 BookmarksView.java >--- src/org/eclipse/ui/internal/views/markers/BookmarksView.java 11 Jan 2008 20:36:39 -0000 1.1 >+++ src/org/eclipse/ui/internal/views/markers/BookmarksView.java 2 Jan 2009 09:00:38 -0000 >@@ -11,6 +11,8 @@ > > package org.eclipse.ui.internal.views.markers; > >+import org.eclipse.core.commands.operations.IUndoContext; >+import org.eclipse.ui.ide.undo.WorkspaceUndoUtil; > import org.eclipse.ui.views.markers.MarkerSupportView; > import org.eclipse.ui.views.markers.internal.MarkerSupportRegistry; > >@@ -28,4 +30,12 @@ > super(MarkerSupportRegistry.BOOKMARKS_GENERATOR); > > } >+ /* >+ * (non-Javadoc) >+ * @see ExtendedMarkersView#getUndoContext() >+ * @return the IUndoContext BookmarksUndoContext >+ */ >+ protected IUndoContext getUndoContext(){ >+ return WorkspaceUndoUtil.getBookmarksUndoContext(); >+ } > } >Index: src/org/eclipse/ui/internal/views/markers/ExtendedMarkersView.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ExtendedMarkersView.java,v >retrieving revision 1.30 >diff -u -r1.30 ExtendedMarkersView.java >--- src/org/eclipse/ui/internal/views/markers/ExtendedMarkersView.java 20 Oct 2008 10:35:03 -0000 1.30 >+++ src/org/eclipse/ui/internal/views/markers/ExtendedMarkersView.java 2 Jan 2009 09:00:39 -0000 >@@ -17,14 +17,40 @@ > import java.util.Iterator; > import java.util.List; > >-import com.ibm.icu.text.MessageFormat; >- >-import org.osgi.framework.Bundle; >- >+import org.eclipse.core.commands.operations.IUndoContext; >+import org.eclipse.core.commands.operations.ObjectUndoContext; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IMarker; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.mapping.ResourceMapping; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.IAdapterFactory; >+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.help.IContext; > import org.eclipse.help.IContextProvider; >+import org.eclipse.jface.action.ContributionManager; >+import org.eclipse.jface.action.MenuManager; >+import org.eclipse.jface.util.IPropertyChangeListener; >+import org.eclipse.jface.util.OpenStrategy; >+import org.eclipse.jface.util.PropertyChangeEvent; >+import org.eclipse.jface.viewers.ColumnPixelData; >+import org.eclipse.jface.viewers.EditingSupport; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.viewers.TableLayout; >+import org.eclipse.jface.viewers.TreeViewer; >+import org.eclipse.jface.viewers.TreeViewerColumn; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.window.SameShellProvider; >+import org.eclipse.jface.window.Window; > import org.eclipse.osgi.util.NLS; >- > import org.eclipse.swt.SWT; > import org.eclipse.swt.dnd.Clipboard; > import org.eclipse.swt.dnd.DND; >@@ -50,39 +76,6 @@ > import org.eclipse.swt.widgets.Scrollable; > import org.eclipse.swt.widgets.Tree; > import org.eclipse.swt.widgets.TreeColumn; >- >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.IAdapterFactory; >-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.resources.IFile; >-import org.eclipse.core.resources.IMarker; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.resources.mapping.ResourceMapping; >- >-import org.eclipse.jface.action.ContributionManager; >-import org.eclipse.jface.action.MenuManager; >-import org.eclipse.jface.util.IPropertyChangeListener; >-import org.eclipse.jface.util.OpenStrategy; >-import org.eclipse.jface.util.PropertyChangeEvent; >-import org.eclipse.jface.viewers.ColumnPixelData; >-import org.eclipse.jface.viewers.EditingSupport; >-import org.eclipse.jface.viewers.ISelection; >-import org.eclipse.jface.viewers.IStructuredSelection; >-import org.eclipse.jface.viewers.ITreeContentProvider; >-import org.eclipse.jface.viewers.StructuredSelection; >-import org.eclipse.jface.viewers.TableLayout; >-import org.eclipse.jface.viewers.TreeViewer; >-import org.eclipse.jface.viewers.TreeViewerColumn; >-import org.eclipse.jface.viewers.Viewer; >-import org.eclipse.jface.window.SameShellProvider; >-import org.eclipse.jface.window.Window; >- > import org.eclipse.ui.IEditorInput; > import org.eclipse.ui.IEditorPart; > import org.eclipse.ui.IMemento; >@@ -113,6 +106,9 @@ > import org.eclipse.ui.views.markers.internal.MarkerMessages; > import org.eclipse.ui.views.markers.internal.MarkerSupportRegistry; > import org.eclipse.ui.views.tasklist.ITaskListResourceAdapter; >+import org.osgi.framework.Bundle; >+ >+import com.ibm.icu.text.MessageFormat; > > /** > * The ExtendedMarkersView is the internal implementation of the view that shows >@@ -297,6 +293,8 @@ > private String[] defaultGeneratorIds = new String[0]; > > private IPropertyChangeListener workingSetListener; >+ >+ private IUndoContext undoContext; > > /** > * Return a new instance of the receiver. >@@ -1882,5 +1880,15 @@ > TreeViewer getViewer() { > return viewer; > } >- >+ >+ /** >+ * @return the IUndoContext >+ * @since 3.5 >+ */ >+ protected IUndoContext getUndoContext(){ >+ if(undoContext==null){ >+ undoContext=new ObjectUndoContext(this); >+ } >+ return undoContext; >+ } > } >Index: src/org/eclipse/ui/internal/views/markers/DeleteHandler.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/DeleteHandler.java,v >retrieving revision 1.7 >diff -u -r1.7 DeleteHandler.java >--- src/org/eclipse/ui/internal/views/markers/DeleteHandler.java 21 Nov 2008 05:36:17 -0000 1.7 >+++ src/org/eclipse/ui/internal/views/markers/DeleteHandler.java 2 Jan 2009 09:00:38 -0000 >@@ -10,17 +10,22 @@ > *******************************************************************************/ > package org.eclipse.ui.internal.views.markers; > >-import org.eclipse.core.runtime.CoreException; >- >-import org.eclipse.core.resources.IMarker; >- > import org.eclipse.core.commands.ExecutionEvent; > import org.eclipse.core.commands.ExecutionException; >- >+import org.eclipse.core.commands.operations.IUndoableOperation; >+import org.eclipse.core.resources.IMarker; >+import org.eclipse.core.resources.WorkspaceJob; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.dialogs.IDialogConstants; > import org.eclipse.jface.dialogs.MessageDialog; >- >-import org.eclipse.ui.internal.ide.Policy; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.ui.ide.undo.DeleteMarkersOperation; >+import org.eclipse.ui.ide.undo.WorkspaceUndoUtil; >+import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; > import org.eclipse.ui.views.markers.MarkerSupportView; > import org.eclipse.ui.views.markers.MarkerViewHandler; > import org.eclipse.ui.views.markers.internal.MarkerMessages; >@@ -40,12 +45,12 @@ > */ > public Object execute(ExecutionEvent event) throws ExecutionException { > >- MarkerSupportView view = getView(event); >+ final MarkerSupportView view = getView(event); > if (view == null) > return this; > > final IMarker[] selected = getSelectedMarkers(event); >- >+ > // Verify. > MessageDialog dialog = new MessageDialog( > view.getSite().getShell(), >@@ -54,20 +59,30 @@ > MarkerMessages.deleteActionConfirmMessage, > MessageDialog.WARNING, > new String[] { IDialogConstants.YES_LABEL, >- IDialogConstants.NO_LABEL }, 0); >+ IDialogConstants.NO_LABEL }, 0); > >- if (dialog.open() != 0) { >+ if (dialog.open() != Dialog.OK) { > return view; > } >- >- for (int i = 0; i < selected.length; i++) { >- try { >- selected[i].delete(); >- } catch (CoreException e) { >- Policy.handle(e); >- throw new ExecutionException(e.getMessage(), e); >- } >- } >+ final String title=NLS.bind(IDEWorkbenchMessages.MarkerDeleteHandler_JobTitle, >+ Integer.toString(selected.length)); >+ WorkspaceJob deleteJob = new WorkspaceJob(title){ >+ public IStatus runInWorkspace(IProgressMonitor monitor) >+ throws CoreException { >+ try { >+ IUndoableOperation op = new DeleteMarkersOperation(selected,title); >+ op.addContext(view.getUndoContext()); >+ execute(op,title, monitor, >+ WorkspaceUndoUtil.getUIInfoAdapter(view.getSite().getShell())); >+ }finally{ >+ monitor.done(); >+ } >+ return Status.OK_STATUS; >+ } >+ }; >+ deleteJob.setUser(true); >+ deleteJob.schedule(); >+ > return this; > } > } >Index: src/org/eclipse/ui/internal/views/markers/TasksView.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/TasksView.java,v >retrieving revision 1.1 >diff -u -r1.1 TasksView.java >--- src/org/eclipse/ui/internal/views/markers/TasksView.java 11 Jan 2008 20:36:39 -0000 1.1 >+++ src/org/eclipse/ui/internal/views/markers/TasksView.java 2 Jan 2009 09:00:39 -0000 >@@ -11,6 +11,8 @@ > > package org.eclipse.ui.internal.views.markers; > >+import org.eclipse.core.commands.operations.IUndoContext; >+import org.eclipse.ui.ide.undo.WorkspaceUndoUtil; > import org.eclipse.ui.views.markers.MarkerSupportView; > import org.eclipse.ui.views.markers.internal.MarkerSupportRegistry; > >@@ -28,4 +30,12 @@ > super(MarkerSupportRegistry.TASKS_GENERATOR); > > } >+ /* >+ * (non-Javadoc) >+ * @see ExtendedMarkersView#getUndoContext() >+ * @return the IUndoContext TasksUndoContext >+ */ >+ protected IUndoContext getUndoContext(){ >+ return WorkspaceUndoUtil.getTasksUndoContext(); >+ } > } >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/plugin.xml,v >retrieving revision 1.281 >diff -u -r1.281 plugin.xml >--- plugin.xml 22 Dec 2008 15:50:53 -0000 1.281 >+++ plugin.xml 2 Jan 2009 09:00:35 -0000 >@@ -1534,6 +1534,14 @@ > visible="true"> > </separator> > <command >+ commandId="org.eclipse.ui.edit.undo"/> >+ <command >+ commandId="org.eclipse.ui.edit.redo" /> >+ <separator >+ name="org.eclipse.ui.ide.separator5" >+ visible="true"> >+ </separator> >+ <command > commandId="org.eclipse.ui.edit.copy"> > </command> > <command >@@ -1992,6 +2000,48 @@ > </activeWhen> > </handler> > <handler >+ class="org.eclipse.ui.internal.views.markers.UndoMarkersHandler" >+ commandId="org.eclipse.ui.edit.undo"> >+ <enabledWhen> >+ <with >+ variable="activePart"> >+ <test >+ property="org.eclipse.ui.ide.markerview.hasUndo"> >+ </test> >+ </with> >+ </enabledWhen> >+ <activeWhen> >+ <with >+ variable="activePart"> >+ <test >+ args="any" >+ property="org.eclipse.ui.ide.contentGenerator"> >+ </test> >+ </with> >+ </activeWhen> >+ </handler> >+ <handler >+ class="org.eclipse.ui.internal.views.markers.RedoMarkersHandler" >+ commandId="org.eclipse.ui.edit.redo"> >+ <enabledWhen> >+ <with >+ variable="activePart"> >+ <test >+ property="org.eclipse.ui.ide.markerview.hasRedo"> >+ </test> >+ </with> >+ </enabledWhen> >+ <activeWhen> >+ <with >+ variable="activePart"> >+ <test >+ args="any" >+ property="org.eclipse.ui.ide.contentGenerator"> >+ </test> >+ </with> >+ </activeWhen> >+ </handler> >+ <handler > class="org.eclipse.ui.internal.views.markers.MarkerSelectAllHandler" > commandId="org.eclipse.ui.edit.selectAll"> > <activeWhen> >@@ -2081,7 +2131,7 @@ > </test> > </iterate> > </enabledWhen> >- <activeWhen> >+ <activeWhen> > <with > variable="activePart"> > <test >@@ -2185,6 +2235,13 @@ > type="org.eclipse.ui.internal.views.markers.ExtendedMarkersView"> > </propertyTester> > <propertyTester >+ class="org.eclipse.ui.internal.views.markers.MarkerUndoRedoTester" >+ id="org.eclipse.ui.ide.markerviewUndoTester" >+ namespace="org.eclipse.ui.ide.markerview" >+ properties="hasUndo,hasRedo" >+ type="org.eclipse.ui.internal.views.markers.ExtendedMarkersView"> >+ </propertyTester> >+ <propertyTester > class="org.eclipse.ui.internal.views.markers.MarkerPropertyTester" > id="org.eclipse.ui.ide.markerTester" > namespace="org.eclipse.ui.ide.marker" >Index: src/org/eclipse/ui/ide/undo/WorkspaceUndoUtil.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/WorkspaceUndoUtil.java,v >retrieving revision 1.16 >diff -u -r1.16 WorkspaceUndoUtil.java >--- src/org/eclipse/ui/ide/undo/WorkspaceUndoUtil.java 16 Mar 2007 19:52:55 -0000 1.16 >+++ src/org/eclipse/ui/ide/undo/WorkspaceUndoUtil.java 2 Jan 2009 09:00:36 -0000 >@@ -78,7 +78,7 @@ > if (tasksUndoContext == null) { > tasksUndoContext = new ObjectUndoContext(new Object(), > "Tasks Context"); //$NON-NLS-1$ >- tasksUndoContext.addMatch(getWorkspaceUndoContext()); >+ //tasksUndoContext.addMatch(getWorkspaceUndoContext()); > } > return tasksUndoContext; > } >@@ -93,7 +93,7 @@ > if (bookmarksUndoContext == null) { > bookmarksUndoContext = new ObjectUndoContext(new Object(), > "Bookmarks Context"); //$NON-NLS-1$ >- bookmarksUndoContext.addMatch(getWorkspaceUndoContext()); >+ //bookmarksUndoContext.addMatch(getWorkspaceUndoContext()); > } > return bookmarksUndoContext; > } >Index: src/org/eclipse/ui/internal/views/markers/MarkerUndoRedoTester.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/views/markers/MarkerUndoRedoTester.java >diff -N src/org/eclipse/ui/internal/views/markers/MarkerUndoRedoTester.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/views/markers/MarkerUndoRedoTester.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,77 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation 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: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal.views.markers; >+ >+import org.eclipse.core.commands.operations.IOperationHistory; >+import org.eclipse.core.commands.operations.IUndoContext; >+import org.eclipse.core.expressions.PropertyTester; >+import org.eclipse.ui.PlatformUI; >+ >+/** >+ * A Property Tester to check the enablement of undo and redo commands on marker >+ * based views. >+ * @since 3.5 >+ * >+ */ >+public class MarkerUndoRedoTester extends PropertyTester{ >+ >+ private static final String REDO_ENABLEMENT = "hasRedo"; //$NON-NLS-1$ >+ >+ private static final String UNDO_ENABLEMENT = "hasUndo"; //$NON-NLS-1$ >+ >+ /** >+ * Create a new instance of the receiver. >+ */ >+ public MarkerUndoRedoTester() { >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, >+ * java.lang.String, java.lang.Object[], java.lang.Object) >+ */ >+ public boolean test(Object receiver, String property, Object[] args, >+ Object expectedValue) { >+ >+ if (!(receiver instanceof ExtendedMarkersView)) >+ return false; >+ >+ ExtendedMarkersView view = (ExtendedMarkersView) receiver; >+ >+ if (property.equals(REDO_ENABLEMENT)) >+ return testRedo(view); >+ if (property.equals(UNDO_ENABLEMENT)) >+ return testUndo(view); >+ >+ return false; >+ } >+ >+ private boolean testUndo(ExtendedMarkersView view) { >+ IUndoContext context=view.getUndoContext(); >+ if(context==null)return false; >+ return getHistory().canUndo(context); >+ } >+ >+ private boolean testRedo(ExtendedMarkersView view) { >+ IUndoContext context=view.getUndoContext(); >+ if(context==null)return false; >+ return getHistory().canRedo(context); >+ } >+ /* >+ * Return the operation history we are using. >+ */ >+ static IOperationHistory getHistory() { >+ return PlatformUI.getWorkbench().getOperationSupport() >+ .getOperationHistory(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/ui/internal/views/markers/MarkersOperationsHandler.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/views/markers/MarkersOperationsHandler.java >diff -N src/org/eclipse/ui/internal/views/markers/MarkersOperationsHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/views/markers/MarkersOperationsHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,85 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation 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: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal.views.markers; >+ >+import java.lang.reflect.InvocationTargetException; >+ >+import org.eclipse.core.commands.operations.IOperationHistory; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.ISafeRunnable; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.SafeRunner; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.actions.WorkspaceModifyOperation; >+import org.eclipse.ui.internal.ide.StatusUtil; >+import org.eclipse.ui.progress.IProgressService; >+import org.eclipse.ui.statushandlers.StatusManager; >+import org.eclipse.ui.views.markers.MarkerViewHandler; >+ >+/** >+ * A base class for allowing Undo and Redo commands to marker views to >+ * support undoing/redoing of operations such delete,add task,etc. >+ * to be undone or redone >+ * @since 3.5 >+ * >+ */ >+public abstract class MarkersOperationsHandler extends MarkerViewHandler { >+ /* >+ * Return the operation history we are using. >+ */ >+ static IOperationHistory getHistory() { >+ return PlatformUI.getWorkbench().getOperationSupport() >+ .getOperationHistory(); >+ } >+ >+ /** >+ * Execute ISafeRunnable with the Workbench ProgressService, >+ * any resource change (event) notifications is reported after the >+ * <code>ISafeRunnable</code> finishes. >+ * @param code to run >+ */ >+ void run(final ISafeRunnable code) { >+ if(code==null){ >+ return; >+ } >+ //prevent firing multiple resource change events >+ WorkspaceModifyOperation op = new WorkspaceModifyOperation(null) { >+ protected void execute(IProgressMonitor monitor){ >+ SafeRunner.run(code); >+ } >+ }; >+ // Use the progess service to execute the op >+ IProgressService service = PlatformUI.getWorkbench().getProgressService(); >+ try { >+ service.run(true, true, op); >+ } catch (InvocationTargetException e) { >+ // unexpected runtime errors. >+ StatusManager.getManager().handle(StatusUtil.newStatus(IStatus.ERROR, >+ e.getLocalizedMessage(), e),StatusManager.LOG); >+ } catch (InterruptedException e) { >+ //ignore >+ } >+ } >+ >+ /** >+ * Display the exception to user using StatusManager.handle() >+ * any resource change (event) notifications is reported after the >+ * ISafeRunnable finishes. >+ * @param code to run >+ */ >+ >+ void showException(Throwable throwable){ >+ StatusManager.getManager().handle(StatusUtil.newStatus(IStatus.ERROR, >+ throwable.getLocalizedMessage(), throwable),StatusManager.SHOW); >+ } >+ >+} >Index: src/org/eclipse/ui/internal/views/markers/UndoMarkersHandler.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/views/markers/UndoMarkersHandler.java >diff -N src/org/eclipse/ui/internal/views/markers/UndoMarkersHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/views/markers/UndoMarkersHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,58 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation 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: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal.views.markers; >+ >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.operations.IUndoContext; >+import org.eclipse.core.runtime.ISafeRunnable; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.ui.views.markers.MarkerSupportView; >+ >+/** >+ * >+ * Add Undo Support to marker based views >+ * >+ * @since 3.5 >+ * >+ */ >+public class UndoMarkersHandler extends MarkersOperationsHandler { >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands. >+ * ExecutionEvent) >+ */ >+ public Object execute(ExecutionEvent event) { >+ final MarkerSupportView view = getView(event); >+ if (view == null) { >+ return null; >+ } >+ final IUndoContext context = view.getUndoContext(); >+ if (context == null) { >+ return null; >+ } >+ run(new ISafeRunnable() { >+ public void run() throws Exception { >+ if (getHistory().canUndo(context)) { >+ getHistory().undo(context, new NullProgressMonitor(), view); >+ } >+ } >+ >+ public void handleException(Throwable throwable) { >+ UndoMarkersHandler.super.showException(throwable); >+ } >+ }); >+ return this; >+ } >+} >Index: src/org/eclipse/ui/internal/views/markers/RedoMarkersHandler.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/views/markers/RedoMarkersHandler.java >diff -N src/org/eclipse/ui/internal/views/markers/RedoMarkersHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/views/markers/RedoMarkersHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,51 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation 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: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal.views.markers; >+ >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.operations.IUndoContext; >+import org.eclipse.core.runtime.ISafeRunnable; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.ui.views.markers.MarkerSupportView; >+ >+/** >+ * Add Redo Support to marker based views >+ * @since 3.5 >+ * >+ */ >+public class RedoMarkersHandler extends MarkersOperationsHandler { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) >+ */ >+ public Object execute(ExecutionEvent event) { >+ final MarkerSupportView view=getView(event); >+ if(view==null){ >+ return null; >+ } >+ final IUndoContext context=view.getUndoContext(); >+ if(context==null){ >+ return null; >+ } >+ run( new ISafeRunnable(){ >+ public void run() throws Exception { >+ if(getHistory().canRedo(context)){ >+ getHistory().redo(context, new NullProgressMonitor(), view); >+ } >+ } >+ public void handleException(Throwable throwable) { >+ RedoMarkersHandler.super.showException(throwable); >+ } >+ }); >+ return this; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 235657
:
120175
|
121426
|
186256