Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 257891 Details for
Bug 481987
Separators are displayed at wrong position in context menu
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Snippet to reproduce the problem
Snippet.java (text/plain), 4.93 KB, created by
Michael Klein
on 2015-11-12 02:40:03 EST
(
hide
)
Description:
Snippet to reproduce the problem
Filename:
MIME Type:
Creator:
Michael Klein
Created:
2015-11-12 02:40:03 EST
Size:
4.93 KB
patch
obsolete
>import org.eclipse.jface.action.Action; >import org.eclipse.jface.action.ActionContributionItem; >import org.eclipse.jface.action.IMenuListener; >import org.eclipse.jface.action.IMenuManager; >import org.eclipse.jface.action.MenuManager; >import org.eclipse.jface.action.Separator; >import org.eclipse.jface.viewers.IStructuredSelection; >import org.eclipse.jface.viewers.ITreeContentProvider; >import org.eclipse.jface.viewers.LabelProvider; >import org.eclipse.jface.viewers.TreeViewer; >import org.eclipse.jface.viewers.Viewer; >import org.eclipse.rap.rwt.application.EntryPoint; >import org.eclipse.swt.SWT; >import org.eclipse.swt.layout.GridData; >import org.eclipse.swt.layout.GridLayout; >import org.eclipse.swt.widgets.Control; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Menu; >import org.eclipse.swt.widgets.Shell; >import org.eclipse.swt.widgets.Tree; > >public class Snippet implements EntryPoint { > > private TreeViewer viewer; > > @Override > public int createUI() { > Display display = new Display(); > Shell shell = new Shell(display, SWT.TITLE); > createContent(shell); > shell.layout(); > shell.open(); > return 0; > } > > private void createContent(Shell shell) { > shell.setLayout(new GridLayout(1, false)); > > Tree tree = new Tree(shell, SWT.NONE | SWT.MULTI); > tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); > viewer = new TreeViewer(tree); > viewer.setLabelProvider(new LabelProvider()); > > viewer.setContentProvider(new ITreeContentProvider() { > @Override > public Object[] getElements(Object inputElement) { > return new Object[] {"Root"}; > } > @Override > public Object[] getChildren(Object parentElement) { > if (hasChildren(parentElement)) { > String[] input = new String[10]; > for (int i = 0; i < input.length; i++) { > input[i] = "Leaf " + i; > } > return input; > } > return new Object[0]; > } > @Override > public boolean hasChildren(Object element) { > return element.toString().startsWith("Root"); > } > @Override > public void dispose() { > } > @Override > public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { > } > @Override > public Object getParent(Object element) { > return null; > } > }); > > viewer.setInput(new Object[0]); > viewer.expandAll(); > > MenuManager contextMenuManager = new MenuManager(); > Control control = viewer.getControl(); > Menu contextMenu = contextMenuManager.createContextMenu(control); > > contextMenuManager.add(new Separator("sepRootLeaf-first")); > contextMenuManager.appendToGroup("sepRootLeaf-first", new RootLeafMenuItem("A (root && leaf)")); > contextMenuManager.appendToGroup("sepRootLeaf-first", new RootLeafMenuItem("B (root && leaf)")); > contextMenuManager.appendToGroup("sepRootLeaf-first", new RootLeafMenuItem("C (root && leaf)")); > contextMenuManager.add(new Separator("sepRoot")); > contextMenuManager.appendToGroup("sepRoot", new RootMenuItem("A (root)")); > contextMenuManager.appendToGroup("sepRoot", new RootMenuItem("B (root)")); > contextMenuManager.appendToGroup("sepRoot", new RootMenuItem("C (root)")); > contextMenuManager.add(new Separator("sepRootLeaf-second")); > contextMenuManager.appendToGroup("sepRootLeaf-second", new RootLeafMenuItem("D (root && leaf)")); > contextMenuManager.appendToGroup("sepRootLeaf-second", new RootLeafMenuItem("E (root && leaf)")); > contextMenuManager.appendToGroup("sepRootLeaf-second", new RootLeafMenuItem("F (root && leaf)")); > contextMenuManager.add(new Separator("sepLeaf")); > contextMenuManager.appendToGroup("sepLeaf", new LeafMenuItem("A (leaf)")); > contextMenuManager.appendToGroup("sepLeaf", new LeafMenuItem("B (leaf)")); > contextMenuManager.appendToGroup("sepLeaf", new LeafMenuItem("C (leaf)")); > > contextMenuManager.addMenuListener(new IMenuListener() { > @Override > public void menuAboutToShow(IMenuManager manager) { > manager.update(true); > } > }); > control.setMenu(contextMenu); > } > > private class RootMenuItem extends ActionContributionItem { > public RootMenuItem(String label) { > super(new Action(label) {}); > } > @Override > public boolean isVisible() { > IStructuredSelection sel = (IStructuredSelection)viewer.getSelection(); > if (!sel.isEmpty()) { > if (sel.getFirstElement().toString().equals("Root")) { > return true; > } > } > return false; > } > } > > private class LeafMenuItem extends ActionContributionItem { > public LeafMenuItem(String label) { > super(new Action(label) {}); > } > @Override > public boolean isVisible() { > IStructuredSelection sel = (IStructuredSelection)viewer.getSelection(); > if (!sel.isEmpty()) { > if (sel.getFirstElement().toString().startsWith("Leaf")) { > return true; > } > } > return false; > } > } > > private class RootLeafMenuItem extends ActionContributionItem { > public RootLeafMenuItem(String label) { > super(new Action(label) {}); > } > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 481987
:
257890
| 257891