Package org.eclipse.jface.viewers

Examples of org.eclipse.jface.viewers.ISelectionProvider


  private void hookContextMenu() {
    final MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);

    Control lControl = null;
    ISelectionProvider lProvider = null;
    if (mMediaView.getCurrentView() == MediaView.MEDIA_VIEW) {
      lControl = mMediaView.getMediaViewer().mTableViewer.getControl();
      lProvider = mMediaView.getMediaViewer().mTableViewer;
    } else {
      lControl = mMediaView.getItemViewer().mTreeViewer.getControl();
      lProvider = mMediaView.getItemViewer().mTreeViewer;
    }

    final IStructuredSelection selection = (IStructuredSelection) lProvider
        .getSelection();

    if (selection.isEmpty()) {
      // CB TODO decide what to do on an empty selection.
    }
View Full Code Here


  public static IStructuredSelection getActiveFeedViewSelection() {
    FeedView feedview = getActiveFeedView();
    if (feedview == null)
      return StructuredSelection.EMPTY;

    ISelectionProvider selectionProvider = feedview.getSite().getSelectionProvider();
    if (selectionProvider == null)
      return StructuredSelection.EMPTY;

    return (IStructuredSelection) selectionProvider.getSelection();
  }
View Full Code Here

  public static IStructuredSelection getActiveSelection() {
    IWorkbenchPage page = getPage();
    if (page != null) {
      IWorkbenchPart part = page.getActivePart();
      if (part != null && part.getSite() != null) {
        ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
        if (selectionProvider != null) {
          ISelection selection = selectionProvider.getSelection();
          if (!selection.isEmpty() && selection instanceof IStructuredSelection)
            return (IStructuredSelection) selection;
        }
      }
    }
View Full Code Here

    return editor != null && doc != null;
  }
 
  @Override
  public SelectionData getSelectionRange() {
    ISelectionProvider sp = editor.getEditorSite().getSelectionProvider();
    ISelection selection = sp.getSelection();
     
    SelectionData result = new SelectionData();
   
    if (selection instanceof ITextSelection) {
      ITextSelection txSel = (ITextSelection) selection;
View Full Code Here

    public void run()
    {
        if (getBreakpoint() != null)
        {
            PropertyDialogAction action =
                new PropertyDialogAction(getEditor().getEditorSite(), new ISelectionProvider()
                    {
                        public void addSelectionChangedListener(ISelectionChangedListener listener)
                        {
                            // empty impl
                        }
View Full Code Here

            openSubAction.run();

            // Check that the module editor opened with the right selection
            moduleEditor = findEditor("EPICTest/lib/TestOpenSub.pm");
            assertNotNull(moduleEditor);
            ISelectionProvider provider = moduleEditor.getSelectionProvider();
            ITextSelection selection = (ITextSelection) provider.getSelection();
            assertEquals("some_sub", selection.getText());
            assertEquals(
                "sub some_sub #ok",
                moduleEditor.getTestInterface().getText().substring(
                    selection.getOffset() - 4,
View Full Code Here

            openSubAction.run();
           
            // Check that the module editor opened with the right selection
            moduleEditor = findEditor("EPICTest/lib/TestOpenSub.pm");
            assertNotNull(moduleEditor);
            ISelectionProvider provider = moduleEditor.getSelectionProvider();
            ITextSelection selection = (ITextSelection) provider.getSelection();
            assertEquals("some_sub", selection.getText());
            assertEquals(
                "sub some_sub #ok",
                moduleEditor.getTestInterface().getText().substring(
                    selection.getOffset() - 4,
                    selection.getOffset() - 4 + "sub some_sub #ok".length()));
           
            IDocument doc1 = editor.getViewer().getDocument();
            appendText(doc1, "\n\nzzz();");
           
            IDocument doc2 = moduleEditor.getViewer().getDocument();
            appendText(doc2, "\n\nsub zzz { }");
           
            testIface.selectText("zzz");
            openSubAction.run();
            selection = (ITextSelection) provider.getSelection();
            assertEquals(
                "sub zzz",
                moduleEditor.getTestInterface().getText().substring(
                    selection.getOffset() - 4,
                    selection.getOffset() - 4 + "sub zzz".length()));
View Full Code Here

            if (serversViewPart != null) {

              IViewSite viewSite = serversViewPart.getViewSite();
              if (viewSite != null) {
                ISelectionProvider selectionProvider = viewSite.getSelectionProvider();
                if (selectionProvider != null) {
                  ISelection selection = selectionProvider.getSelection();
                  if (selection instanceof IStructuredSelection) {
                    return (IStructuredSelection) selection;
                  }
                }
              }
View Full Code Here

        fFindReferencesInWorkingSetAction = new FindReferencesInWorkingSetAction(site);
        fFindReferencesInWorkingSetAction
                .setActionDefinitionId("org.erlide.ui.search.references.in.workset");

        // register the actions as selection listeners
        final ISelectionProvider provider = fSite.getSelectionProvider();
        final ISelection selection = provider.getSelection();
        registerAction(fFindReferencesAction, provider, selection);
        registerAction(fFindReferencesInProjectAction, provider, selection);
        registerAction(fFindReferencesInWorkingSetAction, provider, selection);
    }
View Full Code Here

    /*
     * Overrides method declared in ActionGroup
     */
    @Override
    public void dispose() {
        final ISelectionProvider provider = fSite.getSelectionProvider();
        if (provider != null) {
            disposeAction(fFindReferencesAction, provider);
            disposeAction(fFindReferencesInProjectAction, provider);
            disposeAction(fFindReferencesInWorkingSetAction, provider);
        }
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.