Examples of IStructuredTextUndoManager


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

   * (non-Javadoc)
   *
   * @see org.eclipse.gef.ui.actions.UpdateAction#update()
   */
  public void update() {
    IStructuredTextUndoManager undoManager = _designer.getHTMLEditor()
        .getModel().getUndoManager();
    if (_undo) {
      Command c = undoManager.getUndoCommand();
      this.setEnabled(undoManager.undoable());
      if (c != null) {
        String label = c.getLabel();
        this
            .setText(MessageFormat
                .format(
                    ActionsMessages
                        .getString("DesignerUndoRedoAction.UNDO_LABEL"), new Object[] { label })); //$NON-NLS-1$
      } else {
        this.setText(ActionsMessages
            .getString("DesignerUndoRedoAction.UNDO")); //$NON-NLS-1$
      }
    } else {
      Command c = undoManager.getRedoCommand();
      this.setEnabled(undoManager.redoable());
      if (c != null) {
        String label = c.getLabel();
        this
            .setText(MessageFormat
                .format(
View Full Code Here

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

   * (non-Javadoc)
   *
   * @see org.eclipse.jface.action.Action#run()
   */
  public void run() {
    IStructuredTextUndoManager undoManager = _designer.getHTMLEditor()
        .getModel().getUndoManager();
    if (_undo) {
      undoManager.undo(_designer);
    } else {
      undoManager.redo(_designer);
    }
  }
View Full Code Here

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

    return fCodeFormatterPreferences;
  }

  public void format(IDocument document, IRegion region) {
    IStructuredTextUndoManager undoManager = null;
    IStructuredModel structuredModel = null;
    try {
      if (document instanceof IStructuredDocument) {
        IStructuredDocument structuredDocument = (IStructuredDocument) document;
        structuredModel = StructuredModelManager.getModelManager()
            .getExistingModelForRead(document);
        DOMModelForPHP doModelForPHP = (DOMModelForPHP) structuredModel;

        IProject project = this.project;
        if (doModelForPHP != null) {
          project = getProject(doModelForPHP);
        }
        if (project == null) {
          Logger.logException(new IllegalStateException(
              "Cann't resolve file name")); //$NON-NLS-1$
          return;
        }

        undoManager = structuredDocument.getUndoManager();
        undoManager.beginRecording(this, "php format document", //$NON-NLS-1$
            "format PHP document", 0, document.getLength()); //$NON-NLS-1$

        // html format
        HTMLFormatProcessorImpl htmlFormatter = new HtmlFormatterForPhpCode();

        try {
          htmlFormatter.formatDocument(document);
        } catch (Exception e) {
          // TODO: handle exception
        }
        // php format
        PHPVersion version = ProjectOptions.getPhpVersion(project);
        boolean useShortTags = ProjectOptions.useShortTags(project);
        ICodeFormattingProcessor codeFormatterVisitor = getCodeFormattingProcessor(
            project, document, version, useShortTags, region);
        if (codeFormatterVisitor instanceof CodeFormatterVisitor) {
          List<ReplaceEdit> changes = ((CodeFormatterVisitor) codeFormatterVisitor)
              .getChanges();
          if (changes.size() > 0) {
            replaceAll(document, changes, doModelForPHP);
          }
        }

      } else {
        // TODO: how to handle other document types?
      }

    } catch (Exception e) {
      Logger.logException(e);
    } finally {
      if (undoManager != null) {
        undoManager.endRecording(this);
      }
      if (structuredModel != null) {
        structuredModel.releaseFromRead();
      }
    }
View Full Code Here

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

  }

  public void format(IDocument document, IRegion region, PHPVersion version) {
    // TODO Auto-generated method stub

    IStructuredTextUndoManager undoManager = null;
    IStructuredModel structuredModel = null;
    try {
      if (document instanceof IStructuredDocument) {
        IStructuredDocument structuredDocument = (IStructuredDocument) document;
        structuredModel = StructuredModelManager.getModelManager()
            .getExistingModelForRead(document);
        DOMModelForPHP doModelForPHP = (DOMModelForPHP) structuredModel;

        IProject project = this.project;
        if (doModelForPHP != null) {
          project = getProject(doModelForPHP);
        }
        if (project == null) {
          Logger.logException(new IllegalStateException(
              "Cann't resolve file name")); //$NON-NLS-1$
          return;
        }

        undoManager = structuredDocument.getUndoManager();
        undoManager.beginRecording(this, "php format document", //$NON-NLS-1$
            "format PHP document", 0, document.getLength()); //$NON-NLS-1$

        // html format
        HTMLFormatProcessorImpl htmlFormatter = new HtmlFormatterForPhpCode();

        try {
          htmlFormatter.formatDocument(document);
        } catch (Exception e) {
          // TODO: handle exception
        }
        // php format
        // PHPVersion version = ProjectOptions.getPhpVersion(project);
        boolean useShortTags = ProjectOptions.useShortTags(project);
        ICodeFormattingProcessor codeFormatterVisitor = getCodeFormattingProcessor(
            project, document, version, useShortTags, region);
        if (codeFormatterVisitor instanceof CodeFormatterVisitor) {
          List<ReplaceEdit> changes = ((CodeFormatterVisitor) codeFormatterVisitor)
              .getChanges();
          if (changes.size() > 0) {
            replaceAll(document, changes, doModelForPHP);
          }
        }

      } else {
        // TODO: how to handle other document types?
      }

    } catch (Exception e) {
      Logger.logException(e);
    } finally {
      if (undoManager != null) {
        undoManager.endRecording(this);
      }
      if (structuredModel != null) {
        structuredModel.releaseFromRead();
      }
    }
View Full Code Here

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

  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();
      undoManager.beginRecording(this, label, description,
          cursorPosition, selectionLength);
    } else {
      // TODO: how to handle other document types?
    }
  }
View Full Code Here

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

  private void endRecording(int cursorPosition, int selectionLength) {
    IDocument doc = getDocument();
    if (doc instanceof IStructuredDocument) {
      IStructuredDocument structuredDocument = (IStructuredDocument) doc;
      IStructuredTextUndoManager undoManager = structuredDocument
          .getUndoManager();
      undoManager.endRecording(this, cursorPosition, selectionLength);
    } else {
      // TODO: how to handle other document types?
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.