1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-14 12:35:22 +02:00

[221392][shells] Undo command doesn't work with Eclipse 3.4M5

This commit is contained in:
Radoslav Gerganov 2008-05-03 07:18:24 +00:00
parent 61fe39fc5f
commit d2a39dbeb8

View file

@ -16,6 +16,7 @@
* API to the user actions plugin * API to the user actions plugin
* Radoslav Gerganov (ProSyst) - [181563] Fix hardcoded Ctrl+Space for remote shell content assist * Radoslav Gerganov (ProSyst) - [181563] Fix hardcoded Ctrl+Space for remote shell content assist
* David McKnight (IBM) - [223103] [cleanup] fix broken externalized strings * David McKnight (IBM) - [223103] [cleanup] fix broken externalized strings
* Radoslav Gerganov (ProSyst) - [221392] [shells] Undo command doesn't work with Eclipse 3.4M5
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.shells.ui.view; package org.eclipse.rse.shells.ui.view;
@ -37,6 +38,8 @@ import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextListener; import org.eclipse.jface.text.ITextListener;
import org.eclipse.jface.text.ITextOperationTarget; import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.IUndoManager;
import org.eclipse.jface.text.IUndoManagerExtension;
import org.eclipse.jface.text.IWidgetTokenKeeper; import org.eclipse.jface.text.IWidgetTokenKeeper;
import org.eclipse.jface.text.TextEvent; import org.eclipse.jface.text.TextEvent;
import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.text.source.SourceViewer;
@ -54,6 +57,7 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IActionBars; import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IViewSite; import org.eclipse.ui.IViewSite;
import org.eclipse.ui.operations.UndoActionHandler;
import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.ui.texteditor.IUpdate; import org.eclipse.ui.texteditor.IUpdate;
@ -75,7 +79,7 @@ public class SystemCommandEditor extends SourceViewer
private IViewSite _site; private IViewSite _site;
private Vector listeners = new Vector(); private Vector listeners = new Vector();
private TextViewerAction _undoAction = null; private Action _undoAction = null;
private TextViewerAction _cutAction = null; private TextViewerAction _cutAction = null;
private TextViewerAction _copyAction = null; private TextViewerAction _copyAction = null;
private TextViewerAction _pasteAction = null; private TextViewerAction _pasteAction = null;
@ -129,7 +133,6 @@ public class SystemCommandEditor extends SourceViewer
{ {
public void textChanged(TextEvent event) public void textChanged(TextEvent event)
{ {
updateUndoAction();
if (ignoreChanges || !getTextWidget().isEnabled()) if (ignoreChanges || !getTextWidget().isEnabled())
return; return;
String cmdText = getCommandText(); String cmdText = getCommandText();
@ -198,10 +201,12 @@ public class SystemCommandEditor extends SourceViewer
} }
private void fillContextMenu(IMenuManager menu) private void fillContextMenu(IMenuManager menu)
{ {
menu.add(new GroupMarker(ITextEditorActionConstants.GROUP_UNDO)); if (fGlobalActions.containsKey(ITextEditorActionConstants.UNDO)) {
menu.appendToGroup( menu.add(new GroupMarker(ITextEditorActionConstants.GROUP_UNDO));
ITextEditorActionConstants.GROUP_UNDO, menu.appendToGroup(
(IAction) fGlobalActions.get(ITextEditorActionConstants.UNDO)); ITextEditorActionConstants.GROUP_UNDO,
(IAction) fGlobalActions.get(ITextEditorActionConstants.UNDO));
}
menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT)); menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT));
menu.appendToGroup( menu.appendToGroup(
ITextEditorActionConstants.GROUP_EDIT, ITextEditorActionConstants.GROUP_EDIT,
@ -233,11 +238,12 @@ public class SystemCommandEditor extends SourceViewer
} }
private void initializeActions() private void initializeActions()
{ {
_undoAction = new TextViewerAction(this, UNDO); IUndoManager undoManager = getUndoManager();
_undoAction.setText(SystemResources.ACTION_UNDO_LABEL); if (undoManager instanceof IUndoManagerExtension) {
_undoAction.setToolTipText(SystemResources.ACTION_UNDO_TOOLTIP); IUndoManagerExtension undoManagerExt = (IUndoManagerExtension) undoManager;
fGlobalActions.put(ITextEditorActionConstants.UNDO, _undoAction); _undoAction = new UndoActionHandler(_site, undoManagerExt.getUndoContext());
_undoAction.setEnabled(false); // defect 46369 fGlobalActions.put(ITextEditorActionConstants.UNDO, _undoAction);
}
_cutAction = new TextViewerAction(this, CUT); _cutAction = new TextViewerAction(this, CUT);
_cutAction.setText(SystemResources.ACTION_CUT_LABEL); _cutAction.setText(SystemResources.ACTION_CUT_LABEL);
@ -324,16 +330,7 @@ public class SystemCommandEditor extends SourceViewer
while (iterator.hasNext()) while (iterator.hasNext())
updateAction((String) iterator.next()); updateAction((String) iterator.next());
} }
protected void updateUndoAction()
{
Object obj = fGlobalActions.get(ITextEditorActionConstants.UNDO);
if (obj instanceof IAction)
{
IAction action = (IAction) obj;
if (action instanceof IUpdate)
((IUpdate) action).update();
}
}
protected void updateAction(String actionId) protected void updateAction(String actionId)
{ {
Object obj = fGlobalActions.get(actionId); Object obj = fGlobalActions.get(actionId);