Package org.eclipse.ui.texteditor

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


  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

    super.setActiveEditor(part);
    if (!(part instanceof ITextEditor)) return;
    IActionBars actionBars = getActionBars();
    if (actionBars == null) return;
   
    ITextEditor editor = (ITextEditor)part;
   
    actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(),
        getAction(editor, IDEActionFactory.ADD_TASK.getId()));

    actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(),
View Full Code Here

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

        activeEditorPart = part;

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

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

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

   *
   * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
   */
  public 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) {
      boolean isJavaFile = textEditor.getEditorInput().getName().endsWith(".java");
      boolean isHtmlFile = textEditor.getEditorInput().getName().endsWith(".html");
      IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
      if (document != null /* && document instanceof IStructuredDocument */) {
        ITextSelection textSelection = getCurrentSelection(textEditor);
        if (!textSelection.isEmpty()) {
          IRegion wicketIdRegion = null;

View Full Code Here

          if (file != null && file.exists()) {
            // open in editor
            final IEditorPart editor = IDE.openEditor(activePage, file, false);
            Assert.isNotNull(editor);

            final ITextEditor textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
            final IDocument document = ((textEditor).getDocumentProvider()).getDocument(editor.getEditorInput());
            Assert.isNotNull(document);

            final FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
            try {
              if (JAVA.equals(extension)) {
                IRegion region = frda.find(0, '"' + wicketId + '"', true, true, false, false);
                if (region != null) {
                  while (region != null) {
                    final IRegion li = document.getLineInformationOfOffset(region.getOffset());
                    String line = document.get(li.getOffset(), li.getLength()).trim();
                    if (line.startsWith("*") || line.startsWith("/*") || line.startsWith("//")) {
                      region = frda.find(region.getOffset() + 1, '"' + wicketId + '"', true, true, false, false);
                    } else {
                      DocumentHelper.markOccurrence(textEditor, DocumentHelper.getStringConstantName(line));
                      textEditor.selectAndReveal(region.getOffset() + 1, wicketId.length());
                      found = true;
                      break;
                    }
                  }
                } else {
                  // wicket id not found in file, so search up in tree
                  final List<Object> supertypes = TypeHelper.getSupertypes(file);
                  if (supertypes.size() > 0) {
                    if (supertypes.get(0) instanceof IFile) {
                      final IEditorPart oe = IDE.openEditor(activePage, (IFile) supertypes.get(0), false);
                      open();
                      if (!found) {
                        activePage.closeEditor(oe, false);
                      }
                    }
                  }
                }
              } else if (HTML.equals(extension)) {
                String wid_const = DocumentHelper.getNamespacePrefix(document);
                final IRegion region = frda.find(0, wid_const + ":id=\"" + wicketId, true, true, true, false);
                if (region != null) {
                  textEditor.selectAndReveal(region.getOffset() + wid_const.length() + 5, wicketId.length());
                  break;
                }
              } else if (PROPERTIES.equals(extension)) {
                // for the wicket tags that use wicket:message
                if (wicketId.startsWith("value:")) {
                  wicketId = wicketId.substring(6);
                }
                final IRegion regionBegin = frda.find(0, wicketId, true, true, false, false);
                if (regionBegin != null) {
                  IRegion sr = frda.find(regionBegin.getOffset(), "\">", true, true, false, false);
                  if (sr == null) { // properties, select till eol
                    sr = frda.find(regionBegin.getOffset(), "=", true, true, false, false);
                    if (sr == null) {
                      activePage.closeEditor(editor, false);
                      continue;
                    }
                    final IRegion lineRegion = document.getLineInformationOfOffset(sr.getOffset());
                    final int selectionLength = lineRegion.getOffset() + lineRegion.getLength() - sr.getOffset();
                    textEditor.selectAndReveal(sr.getOffset() + 1, selectionLength - 1);
                    foundInPropertiesFile = true;
                    break;
                  } else { // xml, select till </
                    final IRegion selEnd = frda.find(regionBegin.getOffset(), "</", true, true, false, false);
                    textEditor.selectAndReveal(sr.getOffset() + 2, selEnd.getOffset() - sr.getOffset() - 2);
                    foundInPropertiesFile = true;
                    break;
                  }
                } else {
                  activePage.closeEditor(editor, false);
                  continue;
                }
              }
            } catch (final BadLocationException e) {
              textEditor.resetHighlightRange();
              return;
            }
          } else {
            if (!found) {
              if (JAVA.equals(extension) && !openedResource.getName().contains("_")) {
View Full Code Here

        });
      }
    }

    private void showPopup(StyledText textWidget, IExpression expression) {
      final ITextEditor textEditor;
      final ISelection originalSelection;

      IWorkbenchPart part = editorPart;
      if (part instanceof ITextEditor) {
        textEditor = (ITextEditor) part;
        originalSelection = getTargetSelection(editorPart);
      } else {
        textEditor = null;
        originalSelection = null;
      }
      Shell shell = editorPart.getSite().getShell();
      DebugPopup displayPopup =
          new InspectPopupDialog(shell, getPopupAnchor(textWidget), ACTION_DEFINITION_ID,
              expression) {
            @Override
            public boolean close() {
              boolean returnValue = super.close();
              if (textEditor != null && originalSelection != null) {
                textEditor.getSelectionProvider().setSelection(originalSelection);
              }
              return returnValue;
            }
          };
      displayPopup.open();
View Full Code Here

  public static LiveEditResultDialog.ErrorPositionHighlighter createPositionHighlighter(
      IWorkbenchPart workbenchPart) {
    if (workbenchPart instanceof ITextEditor == false) {
      return null;
    }
    final ITextEditor textEditor = (ITextEditor) workbenchPart;
    return new LiveEditResultDialog.ErrorPositionHighlighter() {
      @Override
      public void highlight(int offset, int length) {
        textEditor.selectAndReveal(offset, length);
      }
    };
  }
View Full Code Here

       
    public static IDocument getActiveDocument(ExecutionEvent event) {
        IEditorPart part = HandlerUtil.getActiveEditor(event);
        IDocument doc = null;
        if ((part != null) && (part instanceof AbstractTextEditor)) {
            ITextEditor editor = (ITextEditor)part;
            doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
        }
       
        return doc;
    }
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.