Bug 438059 - Template "Plug-in with a View" does not set selection provider
Summary: Template "Plug-in with a View" does not set selection provider
Status: VERIFIED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.4   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: 4.5 M1   Edit
Assignee: Alex Blewitt CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2014-06-24 10:59 EDT by Alex Blewitt CLA
Modified: 2014-08-13 06:25 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Blewitt CLA 2014-06-24 10:59:24 EDT
The "Plug-in with a View" template for PDE does not set the site selection provider in the createPartControl method. Therefore, pop-up items do not work as expected when the example is used out-of-the-box.
Comment 1 Vikas Chandra CLA 2014-06-24 11:01:29 EDT
Can you please list down the steps to recreate the problem?
Comment 2 Alex Blewitt CLA 2014-06-24 11:10:56 EDT
If I can find where the example is, I can submit a patch :)

Steps to reproduce:

1. Create new plug-in project, based on Eclipse, will contribute to UI, not RCP
2. Next -> Next
3. Select "Plug-in with a view" example

Source code for SampleView is created as follows:

public void createPartControl(Composite parent) {
 viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
 viewer.setContentProvider(new ViewContentProvider());
 viewer.setLabelProvider(new ViewLabelProvider());
 viewer.setSorter(new NameSorter());
 viewer.setInput(getViewSite());

 // Create the help context id for the viewer's control
 PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "example.viewer");
 makeActions();
 hookContextMenu();
 hookDoubleClickAction();
 contributeToActionBars();
}

The code should have

getSite().setSelectionProvider(viewer);

To test: run the application, go to the view. Select an item. Note that the selection doesn't change (use the selection spy to see).

Add line, re-run view, make a selection, and the selection does change.
Comment 3 Vikas Chandra CLA 2014-06-24 11:23:58 EDT
In org.eclipse.pde.ui.templates, you can check

org.eclipse.pde.ui.templates\templates_3.0\view\java\$className$.java

The base level function called is
org.eclipse.pde.ui.templates.AbstractNewPluginTemplateWizard.performFinish
Comment 4 Alex Blewitt CLA 2014-06-24 11:57:55 EDT
Suggested change:

https://git.eclipse.org/r/28929
Comment 5 Curtis Windatt CLA 2014-07-09 17:23:50 EDT
http://git.eclipse.org/c/pde/eclipse.pde.ui.git/commit/?id=665c6be26f708ce414df6852464946500207ff40

Looks good, merged with master

I see you included the Bug: tag in the commit message which is great, but please consider putting the bug number in the first line of the message as well.  Makes for easier lookups when using git.eclipse.org.
Comment 6 Alex Blewitt CLA 2014-07-09 17:29:07 EDT
Why can't you use this instead?

https://git.eclipse.org/r/#/q/tr:438059,n,z

Put any bug number in there, you'll get the change. Much easier than using a reference in the first line of a commit.
Comment 7 Curtis Windatt CLA 2014-07-09 17:41:29 EDT
(In reply to Alex Blewitt from comment #6)
> Why can't you use this instead?
> 
> https://git.eclipse.org/r/#/q/tr:438059,n,z
> 
> Put any bug number in there, you'll get the change. Much easier than using a
> reference in the first line of a commit.

I find the log page at git.eclipse.org a lot easier to read with the bug numbers at the start.  Same goes for the eGit history view.
Comment 8 Alex Blewitt CLA 2014-07-09 17:49:01 EDT
OK, I'll bear that in mind for future for PDE. But it seems to be a CVS/SVN convention that has been carried forward into Git - and that only existed because there wasn't a good way of having multi-line commits or fast indexing them. You'll note that the JGit and EGit projects don't put bug numbers in the first line of the message:

https://git.eclipse.org/c/egit/egit.git/log/
https://git.eclipse.org/c/jgit/jgit.git/log/

Anyway, I wanted to point out that in general Git repositories refer to bugs in the footer, rather than in the first subject line. Still, I'll try and remember to provide submissions with bug in for PDE in the future.
Comment 9 Vikas Chandra CLA 2014-08-13 06:04:48 EDT
verified on  4.5 M1 eclipse-SDK-I20140806-2000-win32