Package org.eclipse.ui.texteditor

Examples of org.eclipse.ui.texteditor.ITextEditor


    /*
     * @see IAction#run()
     */
    public void run() {

      ITextEditor editor= getTextEditor();
      if (editor == null)
        return;

      IEncodingSupport encodingSupport= (IEncodingSupport) editor.getAdapter(IEncodingSupport.class);
      if (encodingSupport == null)
        return;

      String title= TextEditorMessages.Editor_ConvertEncoding_Custom_dialog_title;
      String message= TextEditorMessages.Editor_ConvertEncoding_Custom_dialog_message;
      IInputValidator inputValidator = new IInputValidator() {
        public String isValid(String newText) {
          return (newText == null || newText.length() == 0) ? " " : null; //$NON-NLS-1$
        }
      };

      String initialValue= encodingSupport.getEncoding();
      if (initialValue == null)
        initialValue= encodingSupport.getDefaultEncoding();
      if (initialValue == null)
        initialValue= ""; //$NON-NLS-1$

      InputDialog d= new InputDialog(editor.getSite().getShell(), title, message, initialValue, inputValidator);
      if (d.open() == Window.OK)
        encodingSupport.setEncoding(d.getValue());
    }
View Full Code Here


   *
   * @param part the editor
   */
  private void doSetActiveEditor(final IEditorPart part) {

    ITextEditor textEditor= null;
    if (part instanceof ITextEditor)
      textEditor= (ITextEditor) part;

    /** The global actions to be connected with editor actions */
    IActionBars actionBars= getActionBars();
   
    actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), getAction(textEditor, IDEActionFactory.ADD_TASK.getId()));
    actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction(textEditor, IDEActionFactory.BOOKMARK.getId()));
   
    IAction action= getAction(textEditor, ITextEditorActionConstants.NEXT);
    actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, action);
    actionBars.setGlobalActionHandler(ITextEditorActionConstants.NEXT, action);
    action= getAction(textEditor, ITextEditorActionConstants.PREVIOUS);
    actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, action);
    actionBars.setGlobalActionHandler(ITextEditorActionConstants.PREVIOUS, action);

    action= getAction(textEditor, ActionFactory.REFRESH.getId());
    actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), action);

    fChangeEncodingAction.setAction(getAction(textEditor, ITextEditorActionConstants.CHANGE_ENCODING));
   
    IAction quickAssistAction= getAction(textEditor, ITextEditorActionConstants.QUICK_ASSIST);
    fQuickAssistAction.setAction(quickAssistAction);

    if (textEditor == null)
      return;
   
    // Update Quick Assist menu entry - for now don't show disabled entry
    IMenuManager menuMgr= textEditor.getEditorSite().getActionBars().getMenuManager();
    IMenuManager editMenu= menuMgr.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
    if (editMenu != null) {
      boolean isEnabled= quickAssistAction != null && quickAssistAction.isEnabled();
      fQuickAssistMenuEntry.setVisible(isEnabled);
      editMenu.update(true);
View Full Code Here

      return;
    }

    // Optimization - could also use else branch
    if (editor instanceof ITextEditor) {
      ITextEditor textEditor= (ITextEditor)editor;
      textEditor.selectAndReveal(pos.offset, pos.length);
      return;
    }

    /*
     * Workaround: send out a text selection
View Full Code Here

  /*
   * @see org.eclipse.jface.action.IAction#run()
   */
  public void run() {
    ITextEditor editor= getTextEditor();
    if (editor == null || !validateEditorInputState())
      return;
    IRewriteTarget target= (IRewriteTarget)editor.getAdapter(IRewriteTarget.class);
    if (target != null)
      target.beginCompoundChange();
    runCompoundChange();
    if (target != null)
      target.endCompoundChange();
View Full Code Here

  }

  @Override
  public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
    if (selection instanceof ITextSelection) {
      ITextEditor textEditor = getTextEditor(part);
      ITextSelection textSelection = (ITextSelection) selection;
      int lineNumber = textSelection.getStartLine() + 1; // one based

      ILineBreakpoint breakpoint = BreakpointUtils.findLineBreakpoint(textEditor, lineNumber);
      if (breakpoint != null) {
View Full Code Here

    return true;
  }

  public void toggleWatchpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
    if (selection instanceof ITextSelection) {
      ITextEditor editor = getTextEditor(part);
      ITextSelection textSelection = (ITextSelection) selection;
      int lineNumber = textSelection.getStartLine() + 1; // one based

      IResource resource = BreakpointUtils.getBreakpointResource(editor);
      IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints();
View Full Code Here

      Object sourceElement = getSourceModule(fileName);
      if (sourceElement != null) {
        IEditorPart part = EditorUtility.openInEditor(sourceElement);
        IEditorPart editorPart = EditorUtility.openInEditor(sourceElement);
        if (editorPart instanceof ITextEditor && lineNumber >= 0) {
          ITextEditor textEditor = (ITextEditor) editorPart;
          IDocumentProvider provider = textEditor.getDocumentProvider();
          IEditorInput input = part.getEditorInput();
          provider.connect(input);
          IDocument document = provider.getDocument(input);
          try {
            IRegion line = document.getLineInformation(lineNumber);
            textEditor.selectAndReveal(line.getOffset(), line.getLength());
          } catch (BadLocationException e) {

          }
          provider.disconnect(input);
        }
View Full Code Here

  protected IDocument getDocument() {
    if (!(targetEditor instanceof ITextEditor))
      return null;

    ITextEditor editor = (ITextEditor) targetEditor;
    IDocumentProvider dp = editor.getDocumentProvider();
    return dp.getDocument(editor.getEditorInput());
  }
View Full Code Here

        }
        if (editor == null) {
            return;
        }
        if (offset != 0 && length != 0) {
            ITextEditor textEditor = null;
            if (editor instanceof ITextEditor) {
                textEditor = (ITextEditor) editor;
            }
            if (textEditor == null && editor.getAdapter(ITextEditor.class) != null) {
                textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
            }
            if (textEditor != null) {
                textEditor.selectAndReveal(offset, length);
            }
        }
    }
View Full Code Here

    super.setActiveEditor(part);
    doSetActiveEditor(part);
  }
 
  private void doSetActiveEditor(IEditorPart part) {
    ITextEditor textEditor= null;
    if (part instanceof ITextEditor){
      textEditor = (ITextEditor) part;
    }
    if(textEditor!=null){
      for(int i=0;i<this.actions.size();i++){
        RetargetTextEditorAction action = (RetargetTextEditorAction)actions.get(i);
        IAction targetAction = textEditor.getAction((String)actionIds.get(i));
        if(targetAction!=null){
          action.setAccelerator(targetAction.getAccelerator());
          action.setAction(targetAction);
        } else {
          action.setAccelerator(SWT.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.