Examples of ITextEditor


Examples of org.eclipse.ui.texteditor.ITextEditor

  /** The XML editor's part ID */
  private static final String EDITOR_ID = "org.eclipse.core.runtime.xml.source"; //$NON-NLS-1$

  public boolean test(Object receiver, String property, Object[] args,  Object expectedValue) {
    if (receiver instanceof IEditorPart && PROPERTY.equals(property)) {
      ITextEditor editor = null;
      if (receiver instanceof ITextEditor)
        editor = (ITextEditor) receiver;
      else
        editor = (ITextEditor) ((IEditorPart) receiver).getAdapter(ITextEditor.class);
      if (editor != null) {
        IEditorSite site = editor.getEditorSite();
        if (site != null) {
          return EDITOR_ID.equals(site.getId());
        }
      }
    }
View Full Code Here

Examples of org.eclipse.ui.texteditor.ITextEditor

    getActionBars().updateActionBars();
   
    IActionBars actionBars = getActionBars();
    if (actionBars != null) {

      ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null;
     
      actionBars.setGlobalActionHandler(
        ActionFactory.DELETE.getId(),
        getAction(editor, ITextEditorActionConstants.DELETE));
      actionBars.setGlobalActionHandler(
View Full Code Here

Examples of org.eclipse.ui.texteditor.ITextEditor

      if (editor instanceof ITextEditor)
      {
        try {
          if ("java".equals(extension))
          {
            final ITextEditor textEditor = (ITextEditor)wEditor.getJavaEditor();
            final IDocument document = ((textEditor).getDocumentProvider()).getDocument(textEditor.getEditorInput());
            final FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
            final IRegion region = frda.find(0, '"' + wicketId + '"', true, true, false, false);
            if (region != null)
            {
              textEditor.selectAndReveal(region.getOffset() + 1, wicketId.length());
              wEditor.setActiveEditor(wEditor.getJavaEditor());
            }
          }
          else if ("html".equals(extension))
          {
            final ITextEditor textEditor = (ITextEditor)wEditor.getHtmlEditor();
            final IDocument document = ((textEditor).getDocumentProvider()).getDocument(textEditor.getEditorInput());
            final FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
            final IRegion region = frda.find(0, "wicket:id=\"" + wicketId, true, true, true, false);
            if (region != null)
            {
              textEditor.selectAndReveal(region.getOffset() + 11, wicketId.length());
              wEditor.setActiveEditor(wEditor.getHtmlEditor());
            }
          }
          else if ("properties".equals(extension) && propertiesEditor != null)
          {
            final ITextEditor textEditor = (ITextEditor)propertiesEditor;
            final IDocument document = ((textEditor).getDocumentProvider()).getDocument(textEditor.getEditorInput());
            final FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
            IRegion regionBegin = frda.find(0, wicketId, true, true, true, false);
            if (regionBegin != null)
            {
              regionBegin = frda.find(regionBegin.getOffset(), "=", true, true, false, false);
              if (regionBegin != null)
              {
                final IRegion lineRegion = document.getLineInformationOfOffset(regionBegin.getOffset());
                final int selectionLength = lineRegion.getOffset() + lineRegion.getLength() - regionBegin.getOffset();
                textEditor.selectAndReveal(regionBegin.getOffset() + 1, selectionLength);
                wEditor.setActiveEditor(propertiesEditor);
              }
            }
          }
        } catch (final BadLocationException e) {
View Full Code Here

Examples of org.eclipse.ui.texteditor.ITextEditor

    // do nothing
  }

  public void run(IAction action) {
    if (fEditor instanceof ITextEditor) {
      final ITextEditor editor = (ITextEditor) fEditor;
      Dialog cleanupDialog = new CleanupDialogXML(editor.getSite().getShell());
      if (cleanupDialog.open() == Window.OK) {
        // setup runnable
        Runnable runnable = new Runnable() {
          public void run() {
            IStructuredCleanupProcessor cleanupProcessor = getCleanupProcessor();
            if (cleanupProcessor != null) {
              IStructuredModel model = null;
              try {
                model = StructuredModelManager.getModelManager().getExistingModelForEdit(editor.getDocumentProvider().getDocument(editor.getEditorInput()));
                if (model != null) {
                  cleanupProcessor.cleanupModel(model);
                }
              }
              finally {
                if (model != null) {
                  model.releaseFromEdit();
                }
              }
            }
          }
        };

        // TODO: make independent of 'model'.
        IStructuredModel model = null;
        try {
          model = StructuredModelManager.getModelManager().getExistingModelForEdit(editor.getDocumentProvider().getDocument(editor.getEditorInput()));
          if (model != null) {
            // begin recording
            ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
            model.beginRecording(this, SSEUIMessages.Cleanup_Document_UI_, SSEUIMessages.Cleanup_Document_UI_, selection.getOffset(), selection.getLength());

            // tell the model that we are about to make a big
            // model change
            model.aboutToChangeModel();

            // run
            BusyIndicator.showWhile(fEditor.getEditorSite().getWorkbenchWindow().getShell().getDisplay(), runnable);
          }
        }
        finally {
          if (model != null) {
            // tell the model that we are done with the big
            // model
            // change
            model.changedModel();

            // end recording
            ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
            model.endRecording(this, selection.getOffset(), selection.getLength());
            model.releaseFromEdit();
          }
        }
      }
View Full Code Here

Examples of org.eclipse.ui.texteditor.ITextEditor

        activeEditorPart = part;

        IActionBars actionBars = getActionBars();
        if (actionBars != null) {

            ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null;

            actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), getAction(editor,
                ITextEditorActionConstants.DELETE));
            actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), getAction(editor,
                ITextEditorActionConstants.UNDO));
View Full Code Here

Examples of org.eclipse.ui.texteditor.ITextEditor

     * {@inheritDoc}
     */
    public void setActiveEditor( IEditorPart part )
    {
        super.setActiveEditor( part );
        ITextEditor editor = ( part instanceof ITextEditor ) ? ( ITextEditor ) part : null;
        contentAssist.setAction( getAction( editor, CONTENTASSIST_ACTION ) );
    }
View Full Code Here

Examples of org.eclipse.ui.texteditor.ITextEditor

  private void openInEditor(TestCaseFinder.TestCaseFinderResult result, IWorkbenchPage workbenchPage) {
    try {
      IEditorPart editor = getAndOpenEditor(result.getFile(), workbenchPage);
      if (editor instanceof ITextEditor) {
        ITextEditor textEditor = (ITextEditor) editor;
        textEditor.selectAndReveal(result.getMatchOffset(), result.getMatchLength());
      }

    } catch (PartInitException e) {
      logger.log(Level.SEVERE, "Could not open editor for: " + result.getFile(), e);
    }
View Full Code Here

Examples of org.eclipse.ui.texteditor.ITextEditor

        activeEditorPart = part;

        IActionBars actionBars = getActionBars();
        if (actionBars != null) {

            ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null;

            actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), getAction(editor,
                ITextEditorActionConstants.DELETE));
            actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), getAction(editor,
                ITextEditorActionConstants.UNDO));
View Full Code Here

Examples of org.eclipse.ui.texteditor.ITextEditor

   * Returns the action registed with the given text editor.
   *
   * @return IAction or null if editor is null.
   */
  protected IAction getAction(MultiPageEditorPart editor, String actionID) {
    ITextEditor txtEditor = ((MultiPageEditor) editor).getSourcePageEditor();
    return (txtEditor == null ? null : txtEditor.getAction(actionID));
  }
View Full Code Here

Examples of org.eclipse.ui.texteditor.ITextEditor

  public void setActivePage(IEditorPart part) {

    IActionBars actionBars = getActionBars();
    if (actionBars != null) {

      ITextEditor textEditor = (part instanceof XMLEditor) ? (ITextEditor) part : null;

      actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), getAction1(textEditor,
              ITextEditorActionConstants.DELETE));
      actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), getAction1(textEditor,
              ITextEditorActionConstants.UNDO));
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.