package test.swt.designer; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; public class HiShell extends Shell { /** * Launch the application * @param args */ public static void main(String args[]) { try { Display display = Display.getDefault(); HiShell shell = new HiShell(display, SWT.SHELL_TRIM); shell.open(); shell.layout(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } catch (Exception e) { e.printStackTrace(); } } /** * Create the shell * @param display * @param style */ public HiShell(Display display, int style) { super(display, style); createContents(); } /** * Create contents of the window */ protected void createContents() { setText("SWT Application"); setSize(390, 333); final GridLayout gridLayout = new GridLayout(); setLayout(gridLayout); final Composite composite = new Composite(this, SWT.NONE); final GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1); gridData.heightHint = 70; composite.setLayoutData(gridData); final GridLayout gridLayout_1 = new GridLayout(); gridLayout_1.numColumns = 4; composite.setLayout(gridLayout_1); final Button button = new Button(composite, SWT.NONE); button.setText("Button"); final Button button_1 = new Button(composite, SWT.CHECK); button_1.setText("check button"); final Button button_2 = new Button(composite, SWT.TOGGLE); button_2.setText("toggle button"); button_1.addSelectionListener(new SelectionAdapter() { public void widgetSelected(final SelectionEvent e) { button_2.setSelection(button_1.getSelection()); } }); final Label helloLabel = new Label(composite, SWT.NONE); helloLabel.setLayoutData(new GridData(87, SWT.DEFAULT)); helloLabel.setText("Hello"); final Text text = new Text(composite, SWT.BORDER); final GridData gridData_2 = new GridData(GridData.FILL, GridData.CENTER, true, false, 4, 1); gridData_2.widthHint = 121; text.setLayoutData(gridData_2); new Label(composite, SWT.NONE); new Label(composite, SWT.NONE); new Label(composite, SWT.NONE); final Composite composite_1 = new Composite(this, SWT.NONE); composite_1.setLayout(new FillLayout()); final GridData gridData_1 = new GridData(GridData.FILL, GridData.CENTER, false, false); gridData_1.heightHint = 183; gridData_1.widthHint = 292; composite_1.setLayoutData(gridData_1); final Tree tree = new Tree(composite_1, SWT.BORDER); tree.addSelectionListener(new SelectionAdapter() { public void widgetSelected(final SelectionEvent e) { text.setText(tree.getSelection()[0].getText()); } }); final TreeItem newItemTreeItem = new TreeItem(tree, SWT.NONE); newItemTreeItem.setText("Role A"); final TreeItem newItemTreeItem_1 = new TreeItem(tree, SWT.NONE); newItemTreeItem_1.setText("Role B"); final TreeItem newItemTreeItem_2 = new TreeItem(newItemTreeItem_1, SWT.NONE); newItemTreeItem_2.setText("Actor 1"); final TreeItem newItemTreeItem_5 = new TreeItem(newItemTreeItem_2, SWT.NONE); newItemTreeItem_5.setText("Actoress"); final TreeItem newItemTreeItem_3 = new TreeItem(tree, SWT.NONE); newItemTreeItem_3.setText("Developer"); final TreeItem newItemTreeItem_4 = new TreeItem(newItemTreeItem_3, SWT.NONE); newItemTreeItem_4.setText("Josson Smith"); final Composite composite_2 = new Composite(this, SWT.NONE); final GridData gridData_3 = new GridData(GridData.CENTER, GridData.CENTER, false, false); gridData_3.widthHint = 180; composite_2.setLayoutData(gridData_3); final GridLayout gridLayout_2 = new GridLayout(); gridLayout_2.numColumns = 2; composite_2.setLayout(gridLayout_2); final Button buttonOK = new Button(composite_2, SWT.NONE); buttonOK.addSelectionListener(new SelectionAdapter() { public void widgetSelected(final SelectionEvent e) { close(); } }); buttonOK.setLayoutData(new GridData(76, SWT.DEFAULT)); buttonOK.setText("&OK"); final Button buttonCancel = new Button(composite_2, SWT.NONE); buttonCancel.setLayoutData(new GridData(76, SWT.DEFAULT)); buttonCancel.setText("&Cancel"); buttonCancel.addSelectionListener(new SelectionAdapter() { public void widgetSelected(final SelectionEvent e) { close(); } }); // } protected void checkSubclass() { // Disable the check that prevents subclassing of SWT components } }