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 50183 Details for
Bug 154779
[misc] Support marker undo
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]
org.eclipse.ui.editors.patch
org.eclipse.ui.editors.patch (text/plain), 7.01 KB, created by
Susan McCourt
on 2006-09-14 14:35:34 EDT
(
hide
)
Description:
org.eclipse.ui.editors.patch
Filename:
MIME Type:
Creator:
Susan McCourt
Created:
2006-09-14 14:35:34 EDT
Size:
7.01 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.editors >Index: src/org/eclipse/ui/texteditor/MarkerRulerAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java,v >retrieving revision 1.17 >diff -u -r1.17 MarkerRulerAction.java >--- src/org/eclipse/ui/texteditor/MarkerRulerAction.java 28 Mar 2006 16:37:45 -0000 1.17 >+++ src/org/eclipse/ui/texteditor/MarkerRulerAction.java 14 Sep 2006 18:36:07 -0000 >@@ -20,14 +20,14 @@ > > import org.osgi.framework.Bundle; > >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.commands.operations.IUndoableOperation; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IMarker; > import org.eclipse.core.resources.IResource; >-import org.eclipse.core.resources.IWorkspace; >-import org.eclipse.core.resources.IWorkspaceRunnable; > import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.ILog; >-import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.Status; >@@ -49,7 +49,8 @@ > > import org.eclipse.ui.IEditorInput; > import org.eclipse.ui.PlatformUI; >- >+import org.eclipse.ui.ide.undo.CreateMarkersOperation; >+import org.eclipse.ui.ide.undo.DeleteMarkersOperation; > > /** > * A ruler action which can add and remove markers which have a visual >@@ -365,12 +366,9 @@ > if (!askForLabel(attributes)) > return; > } >- >- try { >- MarkerUtilities.createMarker(resource, attributes, fMarkerType); >- } catch (CoreException x) { >- handleCoreException(x, TextEditorMessages.MarkerRulerAction_addMarker); >- } >+ IUndoableOperation op = new CreateMarkersOperation(fMarkerType, >+ attributes, resource, getText()); >+ execute(op); > } > > /** >@@ -379,18 +377,9 @@ > * @param markers the markers to be deleted > */ > protected void removeMarkers(final List markers) { >- try { >- getResource().getWorkspace().run(new IWorkspaceRunnable() { >- public void run(IProgressMonitor monitor) throws CoreException { >- for (int i= 0; i < markers.size(); ++i) { >- IMarker marker= (IMarker) markers.get(i); >- marker.delete(); >- } >- } >- }, null, IWorkspace.AVOID_UPDATE, null); >- } catch (CoreException x) { >- handleCoreException(x, TextEditorMessages.MarkerRulerAction_removeMarkers); >- } >+ IMarker[] markersArray = (IMarker[]) markers.toArray(new IMarker[markers.size()]); >+ IUndoableOperation op = new DeleteMarkersOperation(markersArray, getText()); >+ execute(op); > } > > /** >@@ -491,4 +480,33 @@ > return null; > } > } >+ >+ /** >+ * Execute the specified undoable operation >+ * @param operation the operation to execute >+ * >+ * @since 3.3 >+ */ >+ private void execute(IUndoableOperation operation) { >+ try { >+ PlatformUI.getWorkbench().getOperationSupport() >+ .getOperationHistory().execute(operation, null, >+ new IAdaptable() { >+ public Object getAdapter(Class clazz) { >+ if (clazz == Shell.class && getTextEditor() != null) { >+ return getTextEditor().getSite().getShell(); >+ } >+ return null; >+ } >+ }); >+ } catch (ExecutionException e) { >+ // TODO: A generic error has already been shown by the undoable >+ // operation. We log the error again to preserve the error message >+ // originally used. This may be removed if considered redundant. >+ Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID); >+ ILog log= Platform.getLog(bundle); >+ String msg= getString(fBundle, fPrefix + "error.dialog.message", fPrefix + "error.dialog.message"); //$NON-NLS-2$ //$NON-NLS-1$ >+ log.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, msg, e)); >+ } >+ } > } >Index: src/org/eclipse/ui/texteditor/AddMarkerAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java,v >retrieving revision 1.12 >diff -u -r1.12 AddMarkerAction.java >--- src/org/eclipse/ui/texteditor/AddMarkerAction.java 17 Jun 2005 15:48:27 -0000 1.12 >+++ src/org/eclipse/ui/texteditor/AddMarkerAction.java 14 Sep 2006 18:36:07 -0000 >@@ -16,15 +16,17 @@ > > import org.osgi.framework.Bundle; > >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.commands.operations.IUndoableOperation; > import org.eclipse.core.resources.IResource; >-import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.ILog; >+import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.Status; > > import org.eclipse.swt.widgets.Shell; > >-import org.eclipse.jface.dialogs.ErrorDialog; > import org.eclipse.jface.dialogs.IInputValidator; > import org.eclipse.jface.dialogs.InputDialog; > import org.eclipse.jface.window.Window; >@@ -35,6 +37,7 @@ > > import org.eclipse.ui.IEditorInput; > import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.ide.undo.CreateMarkersOperation; > > > /** >@@ -124,18 +127,35 @@ > } > > try { >- MarkerUtilities.createMarker(resource, attributes, fMarkerType); >- } catch (CoreException x) { >- >+ // TODO: client could have set tooltip text to null, or >+ // resource bundle is missing. >+ // Is there a better course of action than a hard coded >+ // default or an NPE in CreateMarkersOperation? >+ String text = getToolTipText(); >+ if (text == null) { >+ text = "Missing Label Text (Add Marker)"; //$NON-NLS-1$ >+ } >+ IUndoableOperation op = new CreateMarkersOperation(fMarkerType, >+ attributes, resource, text); >+ final ITextEditor editor = getTextEditor(); >+ PlatformUI.getWorkbench().getOperationSupport() >+ .getOperationHistory().execute(op, null, >+ new IAdaptable() { >+ public Object getAdapter(Class clazz) { >+ if (clazz == Shell.class && editor != null) { >+ return editor.getSite().getShell(); >+ } >+ return null; >+ } >+ }); >+ } catch (ExecutionException e) { > Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID); > ILog log= Platform.getLog(bundle); >- log.log(x.getStatus()); >- >- Shell shell= getTextEditor().getSite().getShell(); >- String title= getString(fBundle, fPrefix + "error.dialog.title", fPrefix + "error.dialog.title"); //$NON-NLS-2$ //$NON-NLS-1$ >+ // TODO: A generic error has already been shown by the undoable >+ // operation. We log the error again to preserve the error message >+ // originally used. This may be removed if considered redundant. > String msg= getString(fBundle, fPrefix + "error.dialog.message", fPrefix + "error.dialog.message"); //$NON-NLS-2$ //$NON-NLS-1$ >- >- ErrorDialog.openError(shell, title, msg, x.getStatus()); >+ log.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, msg, e)); > } > } >
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 Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 154779
:
48425
|
50080
| 50183