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 272017 Details for
Bug 529126
[Wayland][GTK3] Tree does not notify SWT.MouseDown listeners
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.
Sample code
VirtualOwnerDrawTreeTable.java (text/plain), 3.95 KB, created by
Thomas Singer
on 2017-12-22 04:05:14 EST
(
hide
)
Description:
Sample code
Filename:
MIME Type:
Creator:
Thomas Singer
Created:
2017-12-22 04:05:14 EST
Size:
3.95 KB
patch
obsolete
>import org.eclipse.swt.*; >import org.eclipse.swt.graphics.*; >import org.eclipse.swt.layout.*; >import org.eclipse.swt.widgets.*; > >/** > * @author Thomas Singer > */ >public class VirtualOwnerDrawTreeTable { > > // Static ================================================================= > > public static void main(String[] args) { > final Display display = new Display(); > final Shell shell = new Shell(display); > shell.setText("Custom gradient selection for Tree"); > shell.setLayout(new FillLayout()); > final Tree tree = new Tree(shell, SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL); > tree.setHeaderVisible(true); > tree.setLinesVisible(true); > final int columnCount = 4; > for (int i = 0; i < columnCount; i++) { > final TreeColumn column = new TreeColumn(tree, SWT.NONE); > column.setText("Column " + i); > } > > final int itemCount = 5; > for (int i = 0; i < itemCount; i++) { > final TreeItem item1 = new TreeItem(tree, SWT.NONE); > > for (int j = 0; j < i; j++) { > final TreeItem item2 = new TreeItem(item1, SWT.NONE); > > for (int k = 0; k < j; k++) { > new TreeItem(item2, SWT.NONE); > } > } > } > > tree.addListener(SWT.SetData, new Listener() { > @Override > public void handleEvent(Event event) { > final TreeItem item = (TreeItem)event.item; > > final TreeItem parentItem = item.getParentItem(); > final String text; > > if (parentItem != null) { > final String parentText = (String)parentItem.getData(); > text = parentText + event.index + "/"; > } > else { > text = "/"; > } > > item.setData(text); > } > }); > > tree.addListener(SWT.PaintItem, new Listener() { > @Override > public void handleEvent(Event event) { > final TreeItem item = (TreeItem)event.item; > final String text = (String)item.getData(); > event.gc.drawText(text + " [" + event.index + "]", event.x, event.y, true); > } > }); > > /* > * NOTE: MeasureItem, PaintItem and EraseItem are called repeatedly. > * Therefore, it is critical for performance that these methods be > * as efficient as possible. > */ > tree.addListener(SWT.EraseItem, new Listener() { > @Override > public void handleEvent(Event event) { > event.detail &= ~SWT.HOT; > if ((event.detail & SWT.SELECTED) != 0) { > final GC gc = event.gc; > final Rectangle area = tree.getClientArea(); > /* > * If you wish to paint the selection beyond the end of > * last column, you must change the clipping region. > */ > final int columnCount = tree.getColumnCount(); > if (event.index == columnCount - 1 || columnCount == 0) { > final int width = area.x + area.width - event.x; > if (width > 0) { > final Region region = new Region(); > gc.getClipping(region); > region.add(event.x, event.y, width, event.height); > gc.setClipping(region); > region.dispose(); > } > } > gc.setAdvanced(true); > if (gc.getAdvanced()) { > gc.setAlpha(127); > } > final Rectangle rect = event.getBounds(); > final Color foreground = gc.getForeground(); > final Color background = gc.getBackground(); > gc.setForeground(display.getSystemColor(SWT.COLOR_RED)); > gc.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND)); > gc.fillGradientRectangle(0, rect.y, 500, rect.height, false); > // restore colors for subsequent drawing > gc.setForeground(foreground); > gc.setBackground(background); > event.detail &= ~SWT.SELECTED; > } > } > }); > tree.getColumn(0).setWidth(200); > for (int i = 1; i < columnCount; i++) { > tree.getColumn(i).pack(); > } > tree.setSelection(tree.getItem(0)); > > tree.addListener(SWT.MouseDown, new Listener() { > @Override > public void handleEvent(Event event) { > System.out.println("event = " + event); > } > }); > shell.setSize(500, 500); > shell.open(); > while (!shell.isDisposed()) { > if (!display.readAndDispatch()) { > display.sleep(); > } > } > display.dispose(); > } >}
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 529126
: 272017