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 165138 Details for
Bug 302396
UI thread going crazy with owner-drawn tree in parent shell
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
testcase
PR302396.java (text/plain), 8.92 KB, created by
Felipe Heidrich
on 2010-04-16 15:23:44 EDT
(
hide
)
Description:
testcase
Filename:
MIME Type:
Creator:
Felipe Heidrich
Created:
2010-04-16 15:23:44 EDT
Size:
8.92 KB
patch
obsolete
>package misc.prs; > > >import org.eclipse.swt.SWT; >import org.eclipse.swt.layout.*; >import org.eclipse.swt.widgets.*; >import org.eclipse.swt.custom.CTabFolder; >import org.eclipse.swt.custom.CTabItem; >import org.eclipse.swt.graphics.*; >import org.eclipse.swt.internal.Callback; >import org.eclipse.swt.internal.win32.LOGFONT; >import org.eclipse.swt.internal.win32.MSG; >import org.eclipse.swt.internal.win32.NONCLIENTMETRICS; >import org.eclipse.swt.internal.win32.NONCLIENTMETRICSA; >import org.eclipse.swt.internal.win32.NONCLIENTMETRICSW; >import org.eclipse.swt.internal.win32.OS; >import org.eclipse.swt.internal.win32.TCHAR; >import org.eclipse.swt.internal.win32.TVINSERTSTRUCT; > >public class PR302396 { > > public static void main(String[] args) { > mainPI (args); > } > > static Tree createTree(Composite parent) { > final Tree tree= new Tree(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); >// tree.setHeaderVisible(true); >// tree.setLinesVisible(true); > int columnCount= 0; > for (int i= 0; i < columnCount; i++) { > TreeColumn column= new TreeColumn(tree, SWT.NONE); > column.setText("column 1"); > } > int itemCount= 50; > for (int i= 0; i < itemCount; i++) { > TreeItem item1= new TreeItem(tree, SWT.NONE); > item1.setText(new String("item " + i)); > TreeItem item2= new TreeItem(item1, SWT.NONE); > item2.setText("bbbb"); > } > > final boolean PRINT = false; > final long time = 0; > tree.addListener(SWT.EraseItem, new Listener() { > private int eraseCount= 0; > public void handleEvent(Event event) { > if (PRINT) System.out.println("erase " + Integer.toString(eraseCount++)); > if (time > 0) try {Thread.sleep(time);} catch (InterruptedException e) {} > } > }); > tree.addListener(SWT.MeasureItem, new Listener() { > private int measureCount= 0; > public void handleEvent(Event event) { > if (PRINT) System.out.println("measure " + Integer.toString(measureCount++)); > if (time > 0) try {Thread.sleep(time);} catch (InterruptedException e) {} > } > }); > tree.addListener(SWT.PaintItem, new Listener() { > private int paintCount= 0; > public void handleEvent(Event event) { > if (PRINT) System.out.println("paint " + Integer.toString(paintCount++) + " " + tree.indexOf((TreeItem)event.item)); > if (time > 0) try {Thread.sleep(time);} catch (InterruptedException e) {} >// for (int i = 0; i < 50000; i++) { >// i += Math.pow(3, 10); >// i -= Math.pow(3, 10); >// } > } > }); > for (int i= 0; i < columnCount; i++) { > tree.getColumn(i).pack(); > } > return tree; > } > > public static void mainSWT (String[] args) { > final Display display= new Display(); > final Shell shell= new Shell(display); > FillLayout layout = new FillLayout(); > layout.marginHeight = layout.marginWidth = 10; > shell.setLayout(layout); >// createTree(shell); >// createTree(shell); >// CTabFolder folder = new CTabFolder(shell, 0); >// CTabItem item = new CTabItem (folder, 0); >// item.setText("item0"); >// item.setControl(createTree(folder)); >// item = new CTabItem (folder, 0); >// item.setText("item1"); >// final Tree tree = createTree(folder); >// item.setControl(tree); > final Composite c = new Composite (shell, 0); > c.setLayout(new FillLayout()); > final Tree tree = createTree(c); > tree.setBounds(0, 0, 300, 300); >// final Canvas s = new Canvas(c, SWT.BORDER); >// s.setBounds(0, 0, 300, 300); >// tree.moveAbove(s); > > new Button(shell, SWT.PUSH).setText("push"); > > display.addFilter(SWT.KeyDown, new Listener() { > public void handleEvent(Event e) { > if (e.keyCode == SWT.F1) { > System.out.println("sleep"); > try {Thread.sleep(2000);} catch (InterruptedException ex) {} > System.out.println("awake"); > } else if (e.keyCode == SWT.F2) { > Shell dialog = new Shell(shell); > Point pt = display.getCursorLocation(); > dialog.setBounds(pt.x, pt.y, 80, 80); > dialog.open(); > } else if (e.keyCode == SWT.F3) { > tree.setVisible(!tree.getVisible()); >// c.setVisible(!c.getVisible()); >// tree.moveAbove(s); > } else if (e.keyCode == SWT.F4) { > //tree.setVisible(!tree.getVisible()); >// c.setVisible(!c.getVisible()); >// s.moveAbove(tree); > } > } > }); > shell.setSize(400, 600); > shell.open(); > while (!shell.isDisposed()) { > if (!display.readAndDispatch()) > display.sleep(); > } > display.dispose(); > } > > > public static void mainPI (String[] args) { > OS.InitCommonControls(); > TCHAR windowClass = new TCHAR(0, OS.IsWinCE ? "Dialog" : "#32770", true); > int hwndShell = OS.CreateWindowEx(0, > windowClass, > null, > OS.WS_VISIBLE | OS.WS_OVERLAPPEDWINDOW, OS.CW_USEDEFAULT, > 0, OS.CW_USEDEFAULT, 0, 0, > 0, > OS.GetModuleHandle(null), > null); > final int hwndTree = OS.CreateWindowEx( > OS.WS_EX_CLIENTEDGE, > new TCHAR(0, OS.WC_TREEVIEW, true), > null, > OS.WS_VISIBLE | OS.WS_CHILD | OS.WS_TABSTOP | OS.WS_CLIPSIBLINGS | OS.TVS_TRACKSELECT | OS.TVS_DISABLEDRAGDROP | OS.TVS_HASBUTTONS | OS.TVS_LINESATROOT , > 10, 10, 300, 300, > hwndShell, > 0, > OS.GetModuleHandle(null), > null); > > final int hwndbutton = OS.CreateWindowEx( > 0, > new TCHAR(0, "BUTTON", true), > new TCHAR(0, "BUTTON", true), > OS.WS_VISIBLE | OS.WS_CHILD | OS.BS_PUSHBUTTON | OS.WS_TABSTOP | OS.WS_CLIPSIBLINGS, > 400, 10, 100, 30, > hwndShell, > 0, > OS.GetModuleHandle(null), > null); > > OS.SetWindowTheme (hwndTree, "Explorer\0".toCharArray(), null); > int bits = OS.TVS_EX_DOUBLEBUFFER | OS.TVS_EX_FADEINOUTEXPANDOS | OS.TVS_EX_RICHTOOLTIP; > OS.SendMessage (hwndTree, OS.TVM_SETEXTENDEDSTYLE, 0, bits); > OS.SendMessage (hwndTree, OS.TVM_SETBKCOLOR, 0, -1); > int /*long*/ hFont = OS.GetStockObject (OS.SYSTEM_FONT); > NONCLIENTMETRICS info = OS.IsUnicode ? (NONCLIENTMETRICS) new NONCLIENTMETRICSW () : new NONCLIENTMETRICSA (); > info.cbSize = NONCLIENTMETRICS.sizeof; > if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, info, 0)) { > LOGFONT logFont = OS.IsUnicode ? (LOGFONT) ((NONCLIENTMETRICSW)info).lfMessageFont : ((NONCLIENTMETRICSA)info).lfMessageFont; > hFont = OS.CreateFontIndirect (logFont); > } > OS.SendMessage (hwndTree, OS.WM_SETFONT, hFont, 0); > OS.SendMessage (hwndbutton, OS.WM_SETFONT, hFont, 0); > > final int oldProc = OS.GetWindowLong(hwndShell, OS.GWL_WNDPROC); > Object windowProc = new Object() { > public int windowProc(int hwnd, int msg, int wParam, int lParam) { > switch (msg) { > case OS.WM_CLOSE: { > OS.PostMessage (hwnd, /*OS.WM_QUIT*/ 0x12, 0, 0); > break; > } > case OS.WM_COMMAND: { > if (lParam == hwndbutton) { > int code = OS.HIWORD (wParam); > switch (code) { > case OS.BN_CLICKED: > case OS.BN_DOUBLECLICKED: > System.out.println("Click"); > int bits = OS.GetWindowLong (hwndTree, OS.GWL_STYLE); > boolean visible = (bits & OS.WS_VISIBLE) != 0; > OS.ShowWindow (hwndTree, !visible ? OS.SW_SHOW : OS.SW_HIDE); > break; > } > } > } > } > return OS.CallWindowProc (oldProc, hwnd, msg, wParam, lParam); > } > }; > Callback newProc = new Callback(windowProc, "windowProc", 4); > OS.SetWindowLong(hwndShell, OS.GWL_WNDPROC, newProc.getAddress()); > > > final int oldProc2 = OS.GetWindowLong(hwndTree, OS.GWL_WNDPROC); > Object windowProc2 = new Object() { > public int windowProc(int hwnd, int msg, int wParam, int lParam) { > switch (msg) { > case OS.WM_TIMER: { > System.out.println("WM_TIMER " + wParam + " " + lParam); > break; > } > } > return OS.CallWindowProc (oldProc2, hwnd, msg, wParam, lParam); > } > }; > Callback newProc2 = new Callback(windowProc2, "windowProc", 4); > OS.SetWindowLong(hwndTree, OS.GWL_WNDPROC, newProc2.getAddress()); > > int hHeap = OS.GetProcessHeap(); > TCHAR buffer = new TCHAR(0, "Long item 123456789", true); > int byteCount = buffer.length() * TCHAR.sizeof; > int pszText = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount); > OS.MoveMemory(pszText, buffer, byteCount); > buffer = new TCHAR(0, "subItem", true); > byteCount = buffer.length() * TCHAR.sizeof; > int pszText2 = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount); > OS.MoveMemory(pszText2, buffer, byteCount); > for (int i = 0; i < 50; i++) { > TVINSERTSTRUCT tvInsert = new TVINSERTSTRUCT(); > tvInsert.hParent = 0; > tvInsert.hInsertAfter = 0; > tvInsert.lParam = i; > tvInsert.pszText = pszText; > tvInsert.mask = OS.TVIF_TEXT | OS.TVIF_HANDLE | OS.TVIF_PARAM; > int /*long*/ hItem = OS.SendMessage(hwndTree, OS.TVM_INSERTITEM, 0, tvInsert); > tvInsert.hParent = hItem; > tvInsert.pszText = pszText2; > OS.SendMessage(hwndTree, OS.TVM_INSERTITEM, 0, tvInsert); > } > if (pszText != 0) OS.HeapFree(hHeap, 0, pszText); > if (pszText2 != 0) OS.HeapFree(hHeap, 0, pszText2); > > OS.ShowWindow(hwndShell, OS.SW_SHOW); > MSG msg = new MSG (); > while (OS.GetMessage(msg, 0, 0, 0)) { > OS.TranslateMessage(msg); > OS.DispatchMessage(msg); > } > } >}
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 302396
:
163084
|
165117
| 165138