Package org.eclipse.wst.sse.core.internal.undo

Examples of org.eclipse.wst.sse.core.internal.undo.IStructuredTextUndoManager


      document = editor.getDocument();
      if (document != null)
        fRecorder = StructuredModelManager.getModelManager().getExistingModelForEdit(document);
      // Prepare for Undo
      if (fRecorder != null) {
        IStructuredTextUndoManager um = fRecorder.getUndoManager();
        if (um != null) {
          um.beginRecording(this, ((IAction) this.obj).getText(), ((IAction) this.obj).getDescription());
        }
      }
    }
  }
View Full Code Here


    }
  }

  private void endRecording() {
    if (fRecorder != null) {
      IStructuredTextUndoManager um = fRecorder.getUndoManager();
      if (um != null) {
        um.endRecording(this);
      }
      fRecorder.releaseFromEdit();
      fRecorder = null;
    }
  }
View Full Code Here

  private void endRecording(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.endRecording(this, documentSelection.getOffset(), documentSelection.getLength());
    }
    else {
      // TODO: how to handle other document types?
    }
  }
View Full Code Here

  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?
    }
  }
View Full Code Here

        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);
View Full Code Here

        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);
View Full Code Here

      document = editor.getDocument();
      if (document != null)
        fRecorder = StructuredModelManager.getModelManager().getExistingModelForEdit(document);
      // Prepare for Undo
      if (fRecorder != null) {
        IStructuredTextUndoManager um = fRecorder.getUndoManager();
        if (um != null) {
          if (this.obj instanceof IAction)
            um.beginRecording(this, ((IAction) this.obj).getText(), ((IAction) this.obj).getDescription());
          else
            um.beginRecording(this);
        }
      }
    }
  }
View Full Code Here

    }
  }

  private void endRecording() {
    if (fRecorder != null) {
      IStructuredTextUndoManager um = fRecorder.getUndoManager();
      if (um != null)
        um.endRecording(this);
      fRecorder.releaseFromEdit();
      fRecorder = null;
    }
  }
View Full Code Here

  private void endRecording(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.endRecording(this, documentSelection.getOffset(), documentSelection.getLength());
    }
    else {
      // TODO: how to handle other document types?
    }
  }
View Full Code Here

  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?
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.wst.sse.core.internal.undo.IStructuredTextUndoManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.