Package org.eclipse.ui.texteditor

Examples of org.eclipse.ui.texteditor.ITextEditor


      IRegion old = history.getLast();
      if (old != null) {
        try {
          history.ignoreSelectionChanges();

          ITextEditor textEditor = null;
          if (editor instanceof ITextEditor)
            textEditor = (ITextEditor) editor;
          else {
            Object o = editor.getAdapter(ITextEditor.class);
            if (o != null)
              textEditor = (ITextEditor) o;
          }
          if (textEditor != null)
            textEditor.selectAndReveal(old.getOffset(), old.getLength());
        }
        finally {
          history.listenToSelectionChanges();
        }
      }
View Full Code Here


   *
   * @see org.eclipse.wst.xml.ui.internal.handlers.CommentHandler#execute(org.eclipse.core.commands.ExecutionEvent)
   */
  public final Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    ITextEditor textEditor = null;
    if (editor instanceof ITextEditor)
      textEditor = (ITextEditor) editor;
    else {
      Object o = editor.getAdapter(ITextEditor.class);
      if (o != null)
        textEditor = (ITextEditor) o;
    }
    if (textEditor != null) {
      IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
      if (document != null && document instanceof IStructuredDocument) {
        // get current text selection
        ITextSelection textSelection = getCurrentSelection(textEditor);
        if (!textSelection.isEmpty()) {
          //call the implementers code to deal with the event
View Full Code Here

  }

  private void gotoSelectedElement() {
    Object element = getSelectedElement();
    dispose();
    ITextEditor editor = getActiveTextEditor();
    if (editor != null) {
      editor.selectAndReveal(((IndexedRegion) element).getStartOffset(), ((IndexedRegion) element).getEndOffset() - ((IndexedRegion) element).getStartOffset());
    }
  }
View Full Code Here

    }
  }

  private ITextEditor getActiveTextEditor() {
    IWorkbench wb = PlatformUI.getWorkbench();
    ITextEditor editor = null;
    if (wb != null) {
      IWorkbenchWindow ww = wb.getActiveWorkbenchWindow();
      IWorkbenchPage page = ww.getActivePage();
      if (page != null) {
        IEditorPart part = page.getActiveEditor();
View Full Code Here

  static boolean _displayTemporaryMessage(ITextViewer viewer, String msg, boolean isError) {
    boolean messageShown = false;
    IEditorPart editor = getActiveEditor();
    if (editor != null) {
      ITextEditor textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
      if (textEditor != null && textEditor instanceof StructuredTextEditor) {
        if (((StructuredTextEditor) textEditor).getTextViewer() == viewer) {
          IStatusLineManager statusLineManager = editor.getEditorSite().getActionBars().getStatusLineManager();
          if (isError)
            statusLineManager.setErrorMessage(msg);
View Full Code Here

   * @see org.eclipse.jface.action.IAction#run()
   */
  public void run() {
    BusyIndicator.showWhile(getTextEditor().getEditorSite().getShell().getDisplay(), new Runnable() {
      public void run() {
        ITextEditor editor = getTextEditor();

        // figure out current offset
        int offset = -1;
        ISourceEditingTextTools textTools = (ISourceEditingTextTools) getTextEditor().getAdapter(ISourceEditingTextTools.class);
        if (textTools != null) {
          offset = textTools.getCaretOffset();
        }
        else if (editor instanceof IExtendedSimpleEditor) {
          offset = ((IExtendedSimpleEditor) editor).getCaretPosition();
        }
        else {
          if (editor.getSelectionProvider() != null) {
            ISelection sel = editor.getSelectionProvider().getSelection();
            if (sel instanceof ITextSelection) {
              offset = ((ITextSelection) sel).getOffset();
            }
          }
        }
        IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
        IOpenOn openOn = OpenOnProvider.getInstance().getOpenOn(document, offset);
        if (openOn != null) {
          openOn.openOn(document, new Region(offset, 0));
        }
      }
View Full Code Here

   *
   * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart,
   *      org.eclipse.jface.viewers.ISelection)
   */
  public boolean canToggleLineBreakpoints(IWorkbenchPart part, ISelection selection) {
    ITextEditor editor = (ITextEditor) part.getAdapter(ITextEditor.class);
    if (selection instanceof ITextSelection) {
      ITextSelection textSelection = (ITextSelection) selection;
      IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
      if (document != null && textSelection.getOffset() > -1) {
        int lineNumber = -1;
        try {
          lineNumber = document.getLineOfOffset(textSelection.getOffset());
        }
View Full Code Here

   *
   * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart,
   *      org.eclipse.jface.viewers.ISelection)
   */
  public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
    ITextEditor editor = (ITextEditor) part.getAdapter(ITextEditor.class);
    if (selection instanceof ITextSelection) {
      ITextSelection textSelection = (ITextSelection) selection;
      IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
      int lineNumber = -1;
      try {
        lineNumber = document.getLineOfOffset(textSelection.getOffset());
      }
      catch (BadLocationException e) {
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

  }

  private void updateTargetAction() {
    if (fSite != null && fSite.getWorkbenchWindow() != null && fSite.getWorkbenchWindow().getActivePage() != null) {
      IEditorPart part = fSite.getWorkbenchWindow().getActivePage().getActiveEditor();
      ITextEditor editor = null;
      if (part instanceof ITextEditor)
        editor = (ITextEditor) part;
      else
        editor = (ITextEditor) (part != null ? part.getAdapter(ITextEditor.class) : null);
      if (editor != null) {
        fTargetAction = editor.getAction(fActionId);
      } else {
        fTargetAction = null;
      }
    } else
      fTargetAction = null;
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.