diff options
author | Eric Williams | 2018-04-02 19:00:33 +0000 |
---|---|---|
committer | Eric Williams | 2018-04-10 18:38:46 +0000 |
commit | d507e3e31c7925b0ce1e47820c85d28732913713 (patch) | |
tree | de8894f91502e3246289032786dccd6d022deca7 /tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug106798_TreeCheckBoxTest.java | |
parent | 13e0a92eb06604985b73e89050f2814cadcbf876 (diff) | |
download | eclipse.platform.swt-d507e3e31c7925b0ce1e47820c85d28732913713.tar.gz eclipse.platform.swt-d507e3e31c7925b0ce1e47820c85d28732913713.tar.xz eclipse.platform.swt-d507e3e31c7925b0ce1e47820c85d28732913713.zip |
Bug 533145: [GTK] Contribute remaining manual snippets to GTK only repo
Add remaining reproducer snippets to the offical platform specific tests
repo.
Change-Id: Id8e63ce2650e3ad842d7fe1e7bbeb202a47e23e8
Signed-off-by: Eric Williams <ericwill@redhat.com>
Diffstat (limited to 'tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug106798_TreeCheckBoxTest.java')
-rw-r--r-- | tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug106798_TreeCheckBoxTest.java | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug106798_TreeCheckBoxTest.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug106798_TreeCheckBoxTest.java new file mode 100644 index 0000000000..126769635f --- /dev/null +++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug106798_TreeCheckBoxTest.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * Copyright (c) 2018 Red Hat and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.tests.gtk.snippets; + + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; + +public class Bug106798_TreeCheckBoxTest { + + static boolean[] myModel = new boolean[200]; + + public static void main(String[] args) { + Display display = new Display(); + Shell shell = new Shell(display); + GridLayout gridLayout = new GridLayout(1, false); + gridLayout.marginLeft = 10; + gridLayout.marginTop = 10; + gridLayout.marginBottom = 10; + gridLayout.marginRight = 10; + shell.setLayout(gridLayout); + + final Table table = new Table(shell, SWT.BORDER | SWT.VIRTUAL | SWT.CHECK + | SWT.FULL_SELECTION); + table.setHeaderVisible(true); + table.setLayoutData(new GridData(GridData.FILL_BOTH)); + table.addListener(SWT.SetData, new Listener() { + + @Override + public void handleEvent(Event event) { + TableItem item = (TableItem) event.item; + int index = table.indexOf(item); + boolean checked = myModel[index]; + item.setChecked(checked); + item.setText(0, "Row " + index + ": " + checked); + } + }); + + TableColumn tableColumn = new TableColumn(table, SWT.LEFT); + tableColumn.setWidth(100); + tableColumn.setText("BlahBlah"); + + table.setItemCount(myModel.length); + table.clearAll(); + + table.addListener(SWT.Selection, new Listener() { + @Override + public void handleEvent(Event e) { + if (e.detail == SWT.CHECK) { + TableItem item = (TableItem) e.item; + int index = table.indexOf(item); + boolean isChecked = item.getChecked(); + myModel[index] = isChecked; + myModel[index / 2] = isChecked; + table.clear(new int[] { index, index / 2 }); + } + } + }); + + shell.setSize(400, 300); + shell.open(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + display.dispose(); + } +}
\ No newline at end of file |