Package org.eclipse.ui.texteditor

Examples of org.eclipse.ui.texteditor.ITextEditor


  }

  public void run(IAction action) {
    boolean okay = false;
    if (fEditor instanceof ITextEditor) {
      ITextEditor textEditor = (ITextEditor) fEditor;
      IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
      if (document != null) {
        ITextSelection textSelection = getTextSelection(textEditor);
        FindOccurrencesProcessor findOccurrenceProcessor = getProcessorForCurrentSelection(document, textSelection);
        if (findOccurrenceProcessor != null) {
          if (textEditor.getEditorInput() instanceof IFileEditorInput) {
            IFile file = ((IFileEditorInput) textEditor.getEditorInput()).getFile();
            okay = findOccurrenceProcessor.findOccurrences(document, textSelection, file);
          }
        }
      }
    }
View Full Code Here


  /**
   * @param editor
   * @return
   */
  protected ITextEditor getTextEditor(IEditorPart editor) {
    ITextEditor textEditor = null;
    if (editor instanceof ITextEditor)
      textEditor = (ITextEditor) editor;
    if (textEditor == null && editor != null)
      textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
    return textEditor;
View Full Code Here

  public void setActiveEditor(IEditorPart activeEditor) {
    if (getActiveEditorPart() == activeEditor)
      return;
    super.setActiveEditor(activeEditor);

    ITextEditor textEditor = getTextEditor(activeEditor);

/*    IActionBars actionBars = getActionBars();
    if (actionBars != null) {
      actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, fNextAnnotation);
      actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, fPreviousAnnotation);
View Full Code Here

      if (page != null) {
        IEditorPart editor = page.getActiveEditor();
        if (editor != null) {
          if (editor instanceof ITextEditor)
            return editor;
          ITextEditor textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
          if (textEditor != null)
            return textEditor;
          return editor;
        }
      }
View Full Code Here

      if (page != null) {
        IEditorPart editor = page.getActiveEditor();
        if (editor != null) {
          if (editor instanceof ITextEditor)
            return editor;
          ITextEditor textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
          if (textEditor != null)
            return textEditor;
          return editor;
        }
      }
View Full Code Here

   * @return
   */
  private boolean isSmartInsertMode() {
    boolean isSmartInsertMode = false;

    ITextEditor textEditor = null;
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
      IWorkbenchPage page = window.getActivePage();
      if (page != null) {
        IEditorPart editor = page.getActiveEditor();
View Full Code Here

     * only" IStorageEditorInput, for the ActiveScript debugger. But this
     * means sometimes the ActiveScript provider might get an input from
     * CVS or something that is not related to debugging.
     */

    ITextEditor editor = getTextEditor();
    IEditorInput input = editor.getEditorInput();
    IDocument document = editor.getDocumentProvider().getDocument(input);
    if (document == null)
      return false;

    String contentType = getContentType(document);
    IBreakpointProvider[] providers = BreakpointProviderBuilder.getInstance().getBreakpointProviders(editor, contentType, getFileExtension(input));

    int pos = -1;
    ISourceEditingTextTools tools = (ISourceEditingTextTools) editor.getAdapter(ISourceEditingTextTools.class);
    if (tools != null) {
      pos = tools.getCaretOffset();
    }

    final int n = providers.length;
    List errors = new ArrayList(0);
    for (int i = 0; i < n; i++) {
      try {
        if (Debug.debugBreakpoints)
          System.out.println(providers[i].getClass().getName() + " adding breakpoint to line " + lineNumber); //$NON-NLS-1$
        IStatus status = providers[i].addBreakpoint(document, input, lineNumber, pos);
        if (status != null && !status.isOK()) {
          errors.add(status);
        }
      }
      catch (CoreException e) {
        errors.add(e.getStatus());
      }
      catch (Exception t) {
        Logger.logException("exception while adding breakpoint", t); //$NON-NLS-1$
      }
    }

    IStatus status = null;
    if (errors.size() > 0) {
      Shell shell = editor.getSite().getShell();
      if (errors.size() > 1) {
        status = new MultiStatus(SSEUIPlugin.ID, IStatus.OK, (IStatus[]) errors.toArray(new IStatus[0]), SSEUIMessages.ManageBreakpoints_error_adding_message1, null); //$NON-NLS-1$
      }
      else {
        status = (IStatus) errors.get(0);
View Full Code Here

            Object part = service.getActivePart();
            if (part != null && part instanceof IEditorPart) {
              editorPart = (IEditorPart) part;
              if (editorPart != null) {
                IStructuredModel model = null;
                ITextEditor textEditor = null;
                try {
                  if (editorPart instanceof ITextEditor) {
                    textEditor = (ITextEditor) editorPart;
                  }
                  if (textEditor == null) {
                    textEditor = (ITextEditor) editorPart.getAdapter(ITextEditor.class);
                  }
                  if (textEditor != null) {
                    IDocument textDocument = textEditor.getDocumentProvider().getDocument(input);
                    model = StructuredModelManager.getModelManager().getExistingModelForRead(textDocument);
                    if (model != null) {
                      resource = BreakpointProviderBuilder.getInstance().getResource(input, model.getContentTypeIdentifier(), getFileExtension(input));
                    }
                  }
View Full Code Here

    if (tools != null) {
      doc = tools.getDocument();
      selection = tools.getSelection();
    }

    ITextEditor textEditor = null;
    if (targetEditor instanceof ITextEditor) {
      textEditor = (ITextEditor) targetEditor;
    }
    if (textEditor == null) {
      textEditor = (ITextEditor) ((IAdaptable) targetEditor).getAdapter(ITextEditor.class);
    }
    if (textEditor == null && tools != null && tools.getEditorPart() instanceof ITextEditor) {
      textEditor = (ITextEditor) tools.getEditorPart();
    }
    if (textEditor == null && tools != null && tools.getEditorPart() != null) {
      textEditor = (ITextEditor) tools.getEditorPart().getAdapter(ITextEditor.class);
    }

    if (selection == null && textEditor != null) {
      selection = textEditor.getSelectionProvider().getSelection();
    }
    if (doc == null && textEditor != null) {
      doc = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
    }

    if (selection instanceof ITextSelection) {
      textSelection = (ITextSelection) selection;
      try {
        doc.replace(textSelection.getOffset(), textSelection.getLength(), text);
      }
      catch (BadLocationException e) {
        return false;
      }
    }
    if (textEditor != null && textSelection != null) {
      ISelectionProvider sp = textEditor.getSelectionProvider();
      ITextSelection sel = new TextSelection(textSelection.getOffset(), text.length());
      sp.setSelection(sel);
      textEditor.selectAndReveal(sel.getOffset(), sel.getLength());
    }

    return true;
  }
View Full Code Here

    run(action);
  }

  public void run(IAction action) {
    if (fEditor instanceof ITextEditor) {
      ITextEditor textEditor = (ITextEditor) fEditor;

      ISelection selection = textEditor.getSelectionProvider().getSelection();
      IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
      // determine current text selection
      if (selection instanceof ITextSelection && document != null) {
        ITextSelection textSelection = (ITextSelection) selection;

        if (textSelection.getLength() < document.getLength()) {
          // get current indexed region
          IndexedRegion cursorIndexedRegion = getCursorIndexedRegion(document, textSelection);

          // determine new selection based on current indexed region
          Region newSelectionRegion = getNewSelectionRegion(cursorIndexedRegion, textSelection);

          // select new selection
          if (newSelectionRegion != null) {
            fHistory.remember(new Region(textSelection.getOffset(), textSelection.getLength()));
            try {
              fHistory.ignoreSelectionChanges();
              textEditor.selectAndReveal(newSelectionRegion.getOffset(), newSelectionRegion.getLength());
            }
            finally {
              fHistory.listenToSelectionChanges();
            }
          }
View Full Code Here

TOP

Related Classes of org.eclipse.ui.texteditor.ITextEditor

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.