Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.ITextSelection


    if (fSourceViewer == null)
      return;

    ISelection selection= getSelectionProvider().getSelection();
    if (selection instanceof ITextSelection) {
      ITextSelection textSelection= (ITextSelection) selection;
      if (textSelection.getOffset() != 0 || textSelection.getLength() != 0)
        markInNavigationHistory();
    }

    StyledText widget= fSourceViewer.getTextWidget();
    widget.setRedraw(false);
View Full Code Here


   * @see #isNavigationTarget(Annotation)
   * @see #findAnnotation(int, int, boolean, Position)
   * @since 3.2
   */
  public Annotation gotoAnnotation(boolean forward) {
    ITextSelection selection= (ITextSelection) getSelectionProvider().getSelection();
    Position position= new Position(0, 0);
    Annotation annotation= findAnnotation(selection.getOffset(), selection.getLength(), forward, position);
    setStatusLineErrorMessage(null);
    setStatusLineMessage(null);
   
    if (annotation != null) {
      selectAndReveal(position.getOffset(), position.getLength());
View Full Code Here

   */
  protected Map getInitialAttributes() {

    Map attributes= new HashMap(11);

    ITextSelection selection= (ITextSelection) getTextEditor().getSelectionProvider().getSelection();
    if (!selection.isEmpty()) {

      int start= selection.getOffset();
      int length= selection.getLength();

      if (length < 0) {
        length= -length;
        start -= length;
      }

      MarkerUtilities.setCharStart(attributes, start);
      MarkerUtilities.setCharEnd(attributes, start + length);

      // marker line numbers are 1-based
      int line= selection.getStartLine();
      MarkerUtilities.setLineNumber(attributes, line == -1 ? -1 : line + 1);

      IDocument document= getTextEditor().getDocumentProvider().getDocument(getTextEditor().getEditorInput());
      MarkerUtilities.setMessage(attributes, getLabelProposal(document, start, length));

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) {
        breakpoint.delete();
        return;
View Full Code Here

  }

  // Watchpoints
  public boolean canToggleWatchpoints(IWorkbenchPart part, ISelection selection) {
    if (selection instanceof ITextSelection) {
      final ITextSelection textSelection = (ITextSelection) selection;
      final String text = textSelection.getText();
      if (part instanceof ScriptEditor) {
        ScriptEditor scriptEditor = (ScriptEditor) part;
        try {
          IDocument doc = scriptEditor.getScriptSourceViewer().getDocument();
          IRegion region = doc.getLineInformation(textSelection.getStartLine());
          String string = doc.get(region.getOffset(), region.getLength());

          return string.indexOf('=') != -1 || string.trim().startsWith("var ");
        } catch (BadLocationException e) {
          DLTKUIPlugin.log(e);
View Full Code Here

  }

  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();

      for (int i = 0; i < breakpoints.length; i++) {
View Full Code Here

      setEnabled(false);
      setAccelerator(SWT.CTRL | '\\');
    }
   
    public void run() {
      ITextSelection sel = (ITextSelection)getSelectionProvider().getSelection();
      IDocument doc = getDocumentProvider().getDocument(getEditorInput());
      try {
        doc.replace(sel.getOffset(),sel.getLength(),HTMLUtil.escapeHTML(sel.getText()));
      } catch (BadLocationException e) {
        HTMLPlugin.logException(e);
      }
    }
View Full Code Here

      setEnabled(false);
      setAccelerator(SWT.CTRL | '/');
    }
   
    public void run() {
      ITextSelection sel = (ITextSelection)getSelectionProvider().getSelection();
      IDocument doc = getDocumentProvider().getDocument(getEditorInput());
      String text = sel.getText().trim();
      try {
        if(text.startsWith("<!--") && text.indexOf("-->") > 3){
          text = sel.getText().replaceFirst("<!--", "");
          text = text.replaceFirst("-->", "");
          doc.replace(sel.getOffset(),sel.getLength(),text);
        } else {
          doc.replace(sel.getOffset(),sel.getLength(),"<!--" + sel.getText() + "-->");
        }
      } catch (BadLocationException e) {
        HTMLPlugin.logException(e);
      }
    }
View Full Code Here

    addAction(menu,GROUP_HTML,ACTION_JSP_COMMENT);
  }
 
  protected void updateSelectionDependentActions() {
    super.updateSelectionDependentActions();
    ITextSelection sel = (ITextSelection)getSelectionProvider().getSelection();
    if(sel.getText().equals("")){
      getAction(ACTION_JSP_COMMENT).setEnabled(false);
    } else {
      getAction(ACTION_JSP_COMMENT).setEnabled(true);
    }
  }
View Full Code Here

      setEnabled(false);
      setAccelerator(SWT.CTRL | SWT.ALT | '/');
    }
   
    public void run() {
      ITextSelection sel = (ITextSelection)getSelectionProvider().getSelection();
      IDocument doc = getDocumentProvider().getDocument(getEditorInput());
      String text = sel.getText().trim();
      try {
        if(text.startsWith("<%--") && text.endsWith("--%>")){
          text = sel.getText().replaceAll("<%--|--%>", "");
          doc.replace(sel.getOffset(),sel.getLength(),text);
        } else {
          doc.replace(sel.getOffset(),sel.getLength(),"<%--" + sel.getText() + "--%>");
        }
      } catch (BadLocationException e) {
        HTMLPlugin.logException(e);
      }
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.ITextSelection

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.