Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.ITextSelection


    addAction(menu,GROUP_XML,ACTION_GEN_XSD);
  }
 
  protected void updateSelectionDependentActions() {
    super.updateSelectionDependentActions();
    ITextSelection sel = (ITextSelection)getSelectionProvider().getSelection();
    if(sel.getText().equals("")){
      getAction(ACTION_ESCAPE_XML).setEnabled(false);
    } else {
      getAction(ACTION_ESCAPE_XML).setEnabled(true);
    }
  }
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.escapeXML(sel.getText()));
      } catch (BadLocationException e) {
        HTMLPlugin.logException(e);
      }
    }
View Full Code Here

    return this.content;
  }
 
  public void execute(HTMLSourceEditor editor){
    IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
    ITextSelection sel = (ITextSelection)editor.getSelectionProvider().getSelection();
    try {
      int caret = content.length();
      if(content.indexOf("></")!=-1){
        caret = content.indexOf("></") + 1;
      }
      doc.replace(sel.getOffset(),sel.getLength(),content);
      editor.selectAndReveal(sel.getOffset() + caret, 0);
    } catch(Exception ex){
      HTMLPlugin.logException(ex);
    }
  }
View Full Code Here

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

    return HTMLPlugin.getDefault().getImageRegistry().get(HTMLPlugin.ICON_TEMPLATE);
  }
 
  public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {

    ITextSelection selection= (ITextSelection) viewer.getSelectionProvider().getSelection();

    // adjust offset to end of normalized selection
    if (selection.getOffset() == offset)
      offset= selection.getOffset() + selection.getLength();

    String prefix= extractPrefix(viewer, offset);
    Region region= new Region(offset - prefix.length(), prefix.length());
    TemplateContext context= createContext(viewer, region);
    if (context == null)
      return new ICompletionProposal[0];

    context.setVariable("selection", selection.getText()); // name of the selection variables {line, word}_selection //$NON-NLS-1$

    Template[] templates= getTemplates(context.getContextType().getId());

    List matches= new ArrayList();
    for (int i= 0; i < templates.length; i++) {
View Full Code Here

    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    ColorDialog dialog = new ColorDialog(window.getShell());
    RGB color = dialog.open();
    if(color!=null){
      IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
      ITextSelection sel = (ITextSelection)editor.getSelectionProvider().getSelection();
      try {
        doc.replace(sel.getOffset(), 0, HTMLUtil.toHex(color));
      } catch(Exception ex){
        HTMLPlugin.logException(ex);
      }
    }
  }
View Full Code Here

    setAction(ACTION_COMMENT,new CommentAction());
  }
 
  protected void updateSelectionDependentActions() {
    super.updateSelectionDependentActions();
    ITextSelection sel = (ITextSelection)getSelectionProvider().getSelection();
    if(sel.getText().equals("")){
      getAction(ACTION_COMMENT).setEnabled(false);
    } else {
      getAction(ACTION_COMMENT).setEnabled(true);
    }
  }
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();
      try {
        if(text.startsWith("//")){
          text = text.replaceAll("(^|\r\n|\r|\n)//","$1");
        } else {
          text = text.replaceAll("(^|\r\n|\r|\n)(.+?)","$1//$2");
        }
        doc.replace(sel.getOffset(),sel.getLength(),text);
      } catch (BadLocationException e) {
        HTMLPlugin.logException(e);
      }
    }
View Full Code Here

  protected Image getImage(Template template) {
    return ToolPlugin.getDefault().getImageRegistry().get("notuds.gif");
  }

  public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
    ITextSelection selection= (ITextSelection) viewer.getSelectionProvider().getSelection();
    // adjust offset to end of normalized selection
    if (selection.getOffset() == offset)
      offset= selection.getOffset() + selection.getLength();
    String prefix = extractPrefix(viewer, offset);
   
    Region region = new Region(offset - prefix.length(), prefix.length());
    TemplateContext context = createContext(viewer, region);
    if (context == null)
      return new ICompletionProposal[0];
    context.setVariable("selection", selection.getText()); // name of the selection variables {line, word_selection //$NON-NLS-1$
   
    Template[] templates = getTemplates(context.getContextType().getId());
    List<ICompletionProposal> matches = new ArrayList<ICompletionProposal>();
    for (int i= 0; i < templates.length; i++) {
      Template template= templates[i];
View Full Code Here

    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;

          if (isJavaFile) {
            final IRegion[] wicketRegions = DocumentHelper.findWicketRegions(editor, document, textSelection.getOffset());
            if (wicketRegions == null) {
              return null;
            }
            wicketIdRegion = wicketRegions[0];
          } else if (isHtmlFile) {
            QWickieHtmlHyperlinkDetector detector = new QWickieHtmlHyperlinkDetector();
            wicketIdRegion = detector.findWicketId(document, textSelection.getOffset());
          }

          if (wicketIdRegion == null) {
            return null;
          }
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.