Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.ITextSelection


    final Region region = new Region(21 * 25, 1);
    WicketHyperlink wh = new WicketHyperlink(region, "test", "html");
    wh.open();
    final ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
    final ITextSelection selection = (ITextSelection) selectionService.getSelection();
    assertEquals("test", selection.getText());
    assertEquals(7, selection.getStartLine());
    assertEquals(7, selection.getEndLine());
    final IResource resource = ResourceUtil.getResource(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput());
    assertEquals("RegistrationPage.html", resource.getName());

    activePage.closeAllEditors(false);

View Full Code Here


    final Region region = new Region(263, 1);
    WicketHyperlink wh = new WicketHyperlink(region, "test", "java");
    wh.open();
    final ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
    final ITextSelection selection = (ITextSelection) selectionService.getSelection();
    assertEquals("test", selection.getText());
    assertEquals(21, selection.getStartLine());
    assertEquals(21, selection.getEndLine());
    final IResource resource = ResourceUtil.getResource(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput());
    assertEquals("RegistrationPage.java", resource.getName());

    activePage.closeAllEditors(false);
View Full Code Here

    final Region region = new Region(763, 1);
    WicketHyperlink wh = new WicketHyperlink(region, "firstname", "properties");

    wh.open();
    final ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
    final ITextSelection selection = (ITextSelection) selectionService.getSelection();
    assertEquals("Your first name", selection.getText());
    assertEquals(0, selection.getStartLine());
    assertEquals(0, selection.getEndLine());
    final IResource resource = ResourceUtil.getResource(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput());
    assertEquals("wicket-package.properties", resource.getName());

    activePage.closeAllEditors(false);
View Full Code Here

  protected Image getImage(Template template) {
    return ToolEditorActivator.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

  }

  private static String retrieveSelection(IWorkbenchPart targetPart) {
    ISelection targetSelection = getTargetSelection(targetPart);
    if (targetSelection instanceof ITextSelection) {
      ITextSelection ts = (ITextSelection) targetSelection;
      String text = ts.getText();
      if (textHasContent(text)) {
        return text;
      } else if (targetPart instanceof IEditorPart) {
        IEditorPart editor = (IEditorPart) targetPart;
        if (editor instanceof ITextEditor) {
View Full Code Here

          currentView = viewer.getTree().getVerticalBar().getSelection();
        }
     
        // change view
        currentFile = (IFile) obj;
        ITextSelection textsel = (ITextSelection) selection;
        ViewInput input = new ViewInput(currentFile, textsel.getStartLine(), textsel.getEndLine());
        viewer.setInput(input);
       
        // refresh view (to previous meaningful state if possible)
        if (state != null) {
          viewer.expandAll();
View Full Code Here

    // will be valid.
    this.getViewer().getViewport().validate();

    ISelection sel = getAfterCommandDesignerSelection();
    if (sel != null) {
      ITextSelection textSel = SelectionHelper
          .convertFromDesignSelectionToTextSelection(sel);
      if (textSel != null) {
        getModel().endRecording(this, textSel.getOffset(),
            textSel.getLength());
      } else {
        getModel().endRecording(this);
      }
    } else {
      getModel().endRecording(this);
View Full Code Here

        // SelectionHelper.convertFromDesignSelection((DesignRange)selection);
        // event = new SelectionChangedEvent(_editor.getGraphicViewer(),
        // srcselection);
        // _viewerSelectionManager.selectionChanged(event);
        // }
        ITextSelection srcselection = SelectionHelper
            .convertFromDesignSelectionToTextSelection(selection);

        // ideally, we should let the text editor display the selection
        // through calls to _viewerSelectionManager,
        // but seemed _viewerSelectionManager don't support that, so we
        // do workaround by calling the text editor (lium)
        _editor.getHTMLEditor().getTextEditor().selectAndReveal(
            srcselection.getOffset(), srcselection.getLength());
      } finally {
        _firingChange = false;
      }
    }
  }
View Full Code Here

        // zero size for caret position.
        // @see ViewerSelectionManagerImpl.caretMoved
        // We try to ignore the second event by checking whether the
        // current real selection is empty
        if (start == end) {
          ITextSelection sel = (ITextSelection) _editor
              .getHTMLEditor().getTextEditor()
              .getSelectionProvider().getSelection();
          if (sel.getLength() != 0) {
            return;
          }
        }

        if (start > end) {
          int temp = start;
          start = end;
          end = temp;
        }
        int offset = start;
        int length = end - start;

        ITextSelection oldSelection = SelectionHelper
            .convertFromDesignSelectionToTextSelection(_editor
                .getGraphicViewer().getSelection());
        if (oldSelection != null && oldSelection.getOffset() == offset
            && oldSelection.getLength() == length) {
          return;
        }

        ISelection selection = SelectionHelper
            .convertToDesignerSelection(this._editor
View Full Code Here

    }

    private boolean isMultilineSelection() {
      ISelection selection = getSelectionProvider().getSelection();
      if (selection instanceof ITextSelection) {
        ITextSelection ts = (ITextSelection) selection;
        return ts.getStartLine() != ts.getEndLine();
      }
      return false;
    }
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.