Package org.eclipse.jface.viewers

Examples of org.eclipse.jface.viewers.ISelectionProvider


    if (editor != null) {
      IEditorSite site= editor.getEditorSite();
      if (site == null)
        return;

      ISelectionProvider provider= editor.getEditorSite().getSelectionProvider();
      if (provider == null)
        return;

      provider.setSelection(new TextSelection(pos.offset, pos.length));
    }
  }
View Full Code Here


   */
  QuickDiffRestoreAction(String prefix, ITextEditor editor, boolean isRulerAction) {
    super(QuickDiffMessages.getBundleForConstructedKeys(), prefix, editor);
    fIsRulerAction= isRulerAction;

    ISelectionProvider selectionProvider= editor.getSelectionProvider();
    if (selectionProvider instanceof IPostSelectionProvider)
      ((IPostSelectionProvider)selectionProvider).addPostSelectionChangedListener(this);
  }
View Full Code Here

   * @return the editor's selection, or <code>null</code>
   */
  protected ITextSelection getSelection() {
    if (getTextEditor() == null)
      return null;
    ISelectionProvider sp= getTextEditor().getSelectionProvider();
    if (sp == null)
      return null;
    ISelection s= sp.getSelection();
    if (s instanceof ITextSelection)
      return (ITextSelection)s;
    return null;
  }
View Full Code Here

   * Returns the current selection.
   * @return ISelection
   * @since 2.1
   */
  protected ISelection doGetSelection() {
    ISelectionProvider sp= null;
    if (fSourceViewer != null)
      sp= fSourceViewer.getSelectionProvider();
    return (sp == null ? null : sp.getSelection());
  }
View Full Code Here

    fIsTextDragAndDropEnabled= true;
   
    final StyledText st= viewer.getTextWidget();
   
    // Install drag source
    final ISelectionProvider selectionProvider= viewer.getSelectionProvider();
    final DragSource source= new DragSource(st, DND.DROP_COPY | DND.DROP_MOVE);
    source.setTransfer(new Transfer[] {TextTransfer.getInstance()});
    source.addDragListener(new DragSourceAdapter() {
      String fSelectedText;
      Point fSelection;
      public void dragStart(DragSourceEvent event) {
        fTextDragAndDropToken= null;
       
        // XXX: This is only a workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=162192
        if (!fIsTextDragAndDropEnabled) {
          event.doit= false;
          event.image= null;
          return;
        }
       
        try {
          fSelection= st.getSelection();
          int offset= st.getOffsetAtLocation(new Point(event.x, event.y));
          Point p= st.getLocationAtOffset(offset);
          if (p.x > event.x)
            offset--;
          event.doit= offset > fSelection.x && offset < fSelection.y;

          ISelection selection= selectionProvider.getSelection();
          if (selection instanceof ITextSelection)
            fSelectedText= ((ITextSelection)selection).getText();
          else // fallback to widget
            fSelectedText= st.getSelectionText();
        } catch (IllegalArgumentException ex) {
View Full Code Here

        new IShellProvider() {
          public Shell getShell() {
            return getSite().getShell();
          }
        },
        new ISelectionProvider() {
          public void addSelectionChangedListener(ISelectionChangedListener listener) {
          }
          public ISelection getSelection() {
            return new StructuredSelection(getEditorInput());
          }
View Full Code Here

  public Object getAdapter(Class required) {

    if (IEditorStatusLine.class.equals(required)) {
      if (fEditorStatusLine == null) {
        IStatusLineManager statusLineManager= getStatusLineManager();
        ISelectionProvider selectionProvider= getSelectionProvider();
        if (statusLineManager != null && selectionProvider != null)
          fEditorStatusLine= new EditorStatusLine(statusLineManager, selectionProvider);
      }
      return fEditorStatusLine;
    }
View Full Code Here

    if (adapter == IShowInSource.class) {
      return new IShowInSource() {
        public ShowInContext getShowInContext() {
          ISelection selection= null;
          ISelectionProvider selectionProvider= getSelectionProvider();
          if (selectionProvider != null)
            selection= selectionProvider.getSelection();
          return new ShowInContext(getEditorInput(), selection);
        }
      };
    }
View Full Code Here

    protected ISelectionProvider sp;

    protected void setUp() throws Exception {
        super.setUp();
        manager = new ODOMSelectionManager(null);
        sp = new ISelectionProvider() {
            public void addSelectionChangedListener(
                    ISelectionChangedListener iSelectionChangedListener) {
            }

            public ISelection getSelection() {
View Full Code Here

        final StructuredSelection structuredSelection =
                new StructuredSelection(deviceElement);

        // An empty implementation as the selection provider isn't currently
        // used by the {@link ODOMSelectionManager#selectionChanged} method.
        ISelectionProvider sp = new ISelectionProvider() {
            public void addSelectionChangedListener(
                    ISelectionChangedListener iSelectionChangedListener) {
            }

            public ISelection getSelection() {
View Full Code Here

TOP

Related Classes of org.eclipse.jface.viewers.ISelectionProvider

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.