Java Code Examples for org.eclipse.ui.IWorkbenchPartSite#setSelectionProvider()

The following examples show how to use org.eclipse.ui.IWorkbenchPartSite#setSelectionProvider() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UnansweredDocumentsView.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
public UnansweredDocumentsView(Composite parent, IWorkbenchPartSite site,
        Supplier<Questionnaire> questionnaireSupplier, Supplier<IProject> projectSupplier) {
    this.questionnaireSupplier = questionnaireSupplier;
    this.projectSupplier = projectSupplier;

    incompleteDocumentsLabel = new Label(parent, 0);
    incompleteDocumentsLabel.setText(TEMPLATE_ANSWERS_COMPLETE);
    incompleteDocumentsLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1));

    incompleteDocumentsList = new ListViewer(parent, SWT.V_SCROLL);
    GridData gd = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1);
    gd.heightHint = (int) (((org.eclipse.swt.widgets.List) incompleteDocumentsList.getControl()).getItemHeight()
            * 4);
    gd.widthHint = 300;
    incompleteDocumentsList.getControl().setLayoutData(gd);
    incompleteDocumentsList.getControl().setVisible(false);
    incompleteDocumentsList.setSorter(new ViewerSorter());
    incompleteDocumentsList.setContentProvider(ArrayContentProvider.getInstance());
    incompleteDocumentsList.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            return ((Document) element).getKey();
        }
    });
    site.setSelectionProvider(incompleteDocumentsList);
}
 
Example 2
Source File: StyledTextSelectionListener.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public StyledTextSelectionListener(IWorkbenchPartSite site, StyledText widget,
		ISelectionProvider selectionProviderOnFocusGain) {
	super(site, selectionProviderOnFocusGain, widget);
	site.setSelectionProvider(selectionProviderOnFocusGain);
	widget.addFocusListener(this);
	widget.addDisposeListener(this);
}
 
Example 3
Source File: BaseDebugView.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createPartControl(Composite parent) {
    IViewSite viewSite = getViewSite();
    if (viewSite != null) {
        configureToolBar(viewSite);
    }

    parent.setLayout(new GridLayout(1, true));

    viewer = new TreeViewer(parent);
    provider = createContentProvider();
    viewer.setContentProvider(provider);
    viewer.setLabelProvider(new PyDebugModelPresentation(false));

    GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getTree());

    MenuManager menuManager = new MenuManager();
    Menu menu = menuManager.createContextMenu(viewer.getTree());
    viewer.getTree().setMenu(menu);
    IWorkbenchPartSite site = getSite();
    site.registerContextMenu(menuManager, viewer);
    site.setSelectionProvider(viewer);

    this.parent = parent;

    listener = createListener();
    if (listener != null) {
        DebugPlugin plugin = DebugPlugin.getDefault();

        ILaunchManager launchManager = plugin.getLaunchManager();
        launchManager.addLaunchListener(listener);

        plugin.addDebugEventListener(listener);
    }
}
 
Example 4
Source File: ServersViewer.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
public void contributeTo ( final IWorkbenchPartSite site )
{
    site.setSelectionProvider ( this.viewer );
    hookContextMenu ( site );
}
 
Example 5
Source File: PackageExplorerPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void createPartControl(Composite parent) {

	final PerformanceStats stats= PerformanceStats.getStats(PERF_CREATE_PART_CONTROL, this);
	stats.startRun();

	fViewer= createViewer(parent);
	fViewer.setUseHashlookup(true);

	initDragAndDrop();

	setProviders();

	JavaPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);


	MenuManager menuMgr= new MenuManager("#PopupMenu"); //$NON-NLS-1$
	menuMgr.setRemoveAllWhenShown(true);
	menuMgr.addMenuListener(this);
	fContextMenu= menuMgr.createContextMenu(fViewer.getTree());
	fViewer.getTree().setMenu(fContextMenu);

	// Register viewer with site. This must be done before making the actions.
	IWorkbenchPartSite site= getSite();
	site.registerContextMenu(menuMgr, fViewer);
	site.setSelectionProvider(fViewer);

	makeActions(); // call before registering for selection changes

	// Set input after filter and sorter has been set. This avoids resorting and refiltering.
	restoreFilterAndSorter();
	fViewer.setInput(findInputElement());
	initFrameActions();
	initKeyListener();

	fViewer.addDoubleClickListener(new IDoubleClickListener() {
		public void doubleClick(DoubleClickEvent event) {
			fActionSet.handleDoubleClick(event);
		}
	});

	fOpenAndLinkWithEditorHelper= new OpenAndLinkWithEditorHelper(fViewer) {
		@Override
		protected void activate(ISelection selection) {
			try {
				final Object selectedElement= SelectionUtil.getSingleElement(selection);
				if (EditorUtility.isOpenInEditor(selectedElement) != null)
					EditorUtility.openInEditor(selectedElement, true);
			} catch (PartInitException ex) {
				// ignore if no editor input can be found
			}
		}

		@Override
		protected void linkToEditor(ISelection selection) {
			PackageExplorerPart.this.linkToEditor(selection);
		}

		@Override
		protected void open(ISelection selection, boolean activate) {
			fActionSet.handleOpen(selection, activate);
		}

	};

	IStatusLineManager slManager= getViewSite().getActionBars().getStatusLineManager();
	fViewer.addSelectionChangedListener(new StatusBarUpdater(slManager));
	fViewer.addTreeListener(fExpansionListener);

	// Set help for the view
	JavaUIHelp.setHelp(fViewer, IJavaHelpContextIds.PACKAGES_VIEW);

	fillActionBars();

	updateTitle();

	fFilterUpdater= new FilterUpdater(fViewer);
	ResourcesPlugin.getWorkspace().addResourceChangeListener(fFilterUpdater);

	// Sync'ing the package explorer has to be done here. It can't be done
	// when restoring the link state since the package explorers input isn't
	// set yet.
	setLinkingEnabled(isLinkingEnabled());

	stats.endRun();
}