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 3920 Details for
Bug 4434
GPF when running SWT Tree code (1FNI25V)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
test case which was causing the stack trace
PR4434BIG.java (text/plain), 3.11 KB, created by
Christophe Cornu
on 2003-03-07 16:33:17 EST
(
hide
)
Description:
test case which was causing the stack trace
Filename:
MIME Type:
Creator:
Christophe Cornu
Created:
2003-03-07 16:33:17 EST
Size:
3.11 KB
patch
obsolete
>import org.eclipse.swt.*; >import org.eclipse.swt.widgets.*; >import org.eclipse.swt.graphics.*; >import org.eclipse.swt.layout.*; >import org.eclipse.swt.events.*; > >import java.util.*; > >public class PR4434BIG implements TreeListener { > >static private final String falseNodeText = "falseNode"; >static private final int treeDepth = 3; >static private final int childrenPerNode = 2; > >public static void main(String[] args) { > Display display = new Display(); > Shell shell = new Shell(); > shell.setText("GPF Example"); > shell.setBounds(0, 0, 500, 400); > shell.setBackground(new Color(shell.getDisplay(), 255, 255, 255)); > > shell.setLayout(new FillLayout()); > PR4434BIG pr = new PR4434BIG(); > final Tree tree = new Tree(shell, SWT.NONE); > tree.addTreeListener(pr); > > TreeNode root = TreeNode.createTree(treeDepth, childrenPerNode); > Vector children = root.getChildren(); > for (int i = 0; i < children.size(); i ++) { > TreeNode next = (TreeNode) children.elementAt(i); > TreeItem item = new TreeItem(tree, 0); > item.setData(next); > item.setText(next.getName()); > > if (next.getChildren().size() > 0) { > TreeItem fakeItem = new TreeItem (item, SWT.NULL); > fakeItem.setText(falseNodeText); > } > } > > final Button runTestButton = new Button(shell, SWT.PUSH); > runTestButton.setText("Run test."); > runTestButton.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { > TreeItem testItem = null; > TreeItem[] items = tree.getItems(); > for (int i = 0; i < treeDepth; i++) { > testItem = items[childrenPerNode - 1]; > > if (!testItem.getExpanded()) { > expandTree(testItem); > } > > items = testItem.getItems(); > } > > > TreeItem[] items2 = new TreeItem[1]; > items2[0] = testItem; > tree.setSelection(items2); > if (!testItem.isDisposed()) tree.showItem(testItem); > runTestButton.setText("Test Successful."); > } > }); > > shell.open (); > while (!shell.isDisposed ()) { > if (!display.readAndDispatch ()) display.sleep (); > } >} > > >public static void expandTree (TreeItem item) { > TreeNode node = (TreeNode) item.getData(); > Vector children = node.getChildren(); > > for (int i = 0; i < children.size(); i++) { > TreeNode next = (TreeNode) children.elementAt(i); > TreeItem nextItem = new TreeItem(item, SWT.NULL); > nextItem.setData(next); > nextItem.setText(next.getName()); > > if (next.getChildren().size() > 0) { > TreeItem dummyItem = new TreeItem(nextItem, SWT.NULL); > dummyItem.setText(falseNodeText); > } > } >} > >public void treeCollapsed(TreeEvent event) { >} > >/** > * > */ >public void treeExpanded(TreeEvent event) { > TreeItem item = (TreeItem) event.item; > // If the node hasn't been viewed yet it has a dummy node > // to allows expansion. Remove the dummy treeItem then > // populate the tree > Item[] items = item.getItems(); > Item item2 = items[0]; > String text = item2.getText(); > if (text.equals(falseNodeText)) { > // dispose of dummy items > TreeItem [] items2 = item.getItems (); > for (int i=0; i<items2.length; i++) items2 [i].dispose (); > > // expand the tree item > expandTree (item); > } >} > >}
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 4434
: 3920 |
3921