use of org.eclipse.wst.sse.core.internal.undo.IStructuredTextUndoManager in project webtools.sourceediting by eclipse.
the class ExtendedEditorActionProxy method endRecording.
private void endRecording() {
if (fRecorder != null) {
IStructuredTextUndoManager um = fRecorder.getUndoManager();
if (um != null) {
um.endRecording(this);
}
fRecorder.releaseFromEdit();
fRecorder = null;
}
}
use of org.eclipse.wst.sse.core.internal.undo.IStructuredTextUndoManager in project webtools.sourceediting by eclipse.
the class DropActionProxy method endRecording.
private void endRecording() {
if (fRecorder != null) {
IStructuredTextUndoManager um = fRecorder.getUndoManager();
if (um != null)
um.endRecording(this);
fRecorder.releaseFromEdit();
fRecorder = null;
}
}
use of org.eclipse.wst.sse.core.internal.undo.IStructuredTextUndoManager in project webtools.sourceediting by eclipse.
the class StructuredTextEditor method updateMenuText.
private void updateMenuText() {
ITextViewer viewer = getTextViewer();
StyledText widget = null;
if (viewer != null)
widget = viewer.getTextWidget();
if (fStructuredModel != null && !fStructuredModel.isModelStateChanging() && viewer != null && widget != null && !widget.isDisposed()) {
// performance: don't force an update of the action bars unless
// required as it is expensive
String previousUndoText = null;
String previousUndoDesc = null;
String previousRedoText = null;
String previousRedoDesc = null;
boolean updateActions = false;
IAction undoAction = getAction(ITextEditorActionConstants.UNDO);
IAction redoAction = getAction(ITextEditorActionConstants.REDO);
if (undoAction != null) {
previousUndoText = undoAction.getText();
previousUndoDesc = undoAction.getDescription();
updateActions = updateActions || previousUndoText == null || previousUndoDesc == null;
undoAction.setText(UNDO_ACTION_TEXT_DEFAULT);
undoAction.setDescription(UNDO_ACTION_DESC_DEFAULT);
}
if (redoAction != null) {
previousRedoText = redoAction.getText();
previousRedoDesc = redoAction.getDescription();
updateActions = updateActions || previousRedoText == null || previousRedoDesc == null;
redoAction.setText(REDO_ACTION_TEXT_DEFAULT);
redoAction.setDescription(REDO_ACTION_DESC_DEFAULT);
}
if (fStructuredModel.getUndoManager() != null) {
IStructuredTextUndoManager undoManager = fStructuredModel.getUndoManager();
// get undo command
Command undoCommand = undoManager.getUndoCommand();
// set undo label and description
if (undoAction != null) {
undoAction.setEnabled(undoManager.undoable());
if (undoCommand != null) {
String label = undoCommand.getLabel();
if (label != null) {
String customText = MessageFormat.format(UNDO_ACTION_TEXT, new String[] { label });
updateActions = updateActions || customText == null || previousUndoText == null || !customText.equals(previousUndoText);
undoAction.setText(customText);
}
String desc = undoCommand.getDescription();
if (desc != null) {
String customDesc = MessageFormat.format(UNDO_ACTION_DESC, new String[] { desc });
updateActions = updateActions || customDesc == null || previousRedoDesc == null || !customDesc.equals(previousUndoDesc);
undoAction.setDescription(customDesc);
}
}
}
// get redo command
Command redoCommand = undoManager.getRedoCommand();
// set redo label and description
if (redoAction != null) {
redoAction.setEnabled(undoManager.redoable());
if (redoCommand != null) {
String label = redoCommand.getLabel();
if (label != null) {
String customText = MessageFormat.format(REDO_ACTION_TEXT, new String[] { label });
updateActions = updateActions || customText == null || previousRedoText == null || !customText.equals(previousRedoText);
redoAction.setText(customText);
}
String desc = redoCommand.getDescription();
if (desc != null) {
String customDesc = MessageFormat.format(REDO_ACTION_DESC, new String[] { desc });
updateActions = updateActions || customDesc == null || previousRedoDesc == null || !customDesc.equals(previousRedoDesc);
redoAction.setDescription(customDesc);
}
}
}
}
// tell the action bars to update
if (updateActions) {
if (getEditorSite().getActionBars() != null) {
getEditorSite().getActionBars().updateActionBars();
} else if (getEditorPart() != null && getEditorPart().getEditorSite().getActionBars() != null) {
getEditorPart().getEditorSite().getActionBars().updateActionBars();
}
}
}
}
use of org.eclipse.wst.sse.core.internal.undo.IStructuredTextUndoManager in project webtools.sourceediting by eclipse.
the class AbstractStructuredModel method getUndoManager.
public IStructuredTextUndoManager getUndoManager() {
IStructuredTextUndoManager structuredTextUndoManager = null;
IStructuredDocument structuredDocument = getStructuredDocument();
if (structuredDocument == null) {
structuredTextUndoManager = null;
} else {
structuredTextUndoManager = structuredDocument.getUndoManager();
}
return structuredTextUndoManager;
}
use of org.eclipse.wst.sse.core.internal.undo.IStructuredTextUndoManager in project webtools.sourceediting by eclipse.
the class StructuredTextViewer method beginRecording.
private void beginRecording(String label, String description, int cursorPosition, int selectionLength) {
IDocument doc = getDocument();
if (doc instanceof IStructuredDocument) {
IStructuredDocument structuredDocument = (IStructuredDocument) doc;
IStructuredTextUndoManager undoManager = structuredDocument.getUndoManager();
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=198617
// undo after paste in document with folds - wrong behavior
IRegion widgetSelection = new Region(cursorPosition, selectionLength);
IRegion documentSelection = widgetRange2ModelRange(widgetSelection);
if (documentSelection == null)
documentSelection = widgetSelection;
undoManager.beginRecording(this, label, description, documentSelection.getOffset(), documentSelection.getLength());
} else {
// TODO: how to handle other document types?
}
}
Aggregations