]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/scratch/org/simantics/databoard/forms/LayoutSnippet.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / scratch / org / simantics / databoard / forms / LayoutSnippet.java
1 package org.simantics.databoard.forms;
2
3 import org.eclipse.swt.SWT;
4 import org.eclipse.swt.layout.GridData;
5 import org.eclipse.swt.layout.GridLayout;
6 import org.eclipse.swt.layout.RowLayout;
7 import org.eclipse.swt.widgets.Button;
8 import org.eclipse.swt.widgets.Composite;
9 import org.eclipse.swt.widgets.Display;
10 import org.eclipse.swt.widgets.Group;
11 import org.eclipse.swt.widgets.Label;
12 import org.eclipse.swt.widgets.Shell;
13 import org.eclipse.swt.widgets.Spinner;
14 import org.eclipse.swt.widgets.Text;
15
16 public class LayoutSnippet {
17   public static void main(String[] args) {
18     Display display = new Display();
19     Shell shell = new Shell(display);
20     // set the layout of the shell
21     shell.setLayout(new GridLayout(3, false));
22     // Create a label and a button
23     Label label = new Label(shell, SWT.NONE);
24     label.setText("A label");
25     Button button = new Button(shell, SWT.PUSH);
26     button.setText("Press Me");
27     
28     // Create a new label that will spam two columns
29     label = new Label(shell, SWT.BORDER);
30     label.setText("This is a label");
31     // Create new layout data
32     label.setLayoutData(new GridData(GridData.FILL, 
33             GridData.BEGINNING, true, false, 2, 1));
34     
35     // Create a new label which is used as a separator
36     label = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
37     // Create new layout data
38     label.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false, 2, 1));
39     
40     // Create a right aligned button
41     Button b = new Button(shell, SWT.PUSH);
42     b.setText("New Button");
43     
44     b.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false, 2, 1));
45
46     Spinner spinner = new Spinner(shell, SWT.READ_ONLY);
47     spinner.setMinimum(0);
48     spinner.setMaximum(1000);
49     spinner.setSelection(500);
50     spinner.setIncrement(1);
51     spinner.setPageIncrement(100);
52     GridData gridData = new GridData(SWT.FILL, 
53         SWT.FILL, true, false);
54     gridData.widthHint = SWT.DEFAULT;
55     gridData.heightHint = SWT.DEFAULT;
56     gridData.horizontalSpan=2;
57     spinner.setLayoutData(gridData);
58     
59     Composite composite = new Composite(shell, SWT.BORDER);
60     gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
61     gridData.horizontalSpan= 2;
62     composite.setLayoutData(gridData);
63     composite.setLayout(new GridLayout(1, false));
64     
65     
66     Text text = new Text(composite, SWT.NONE);
67     text.setText("Testing");
68     gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
69     text.setLayoutData(gridData);
70     
71     text = new Text(composite, SWT.NONE);
72     text.setText("Another test");
73 //    gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
74 //    text.setLayoutData(gridData);
75     Group group = new Group(shell, SWT.NONE);
76     group.setText("This is my group");
77     gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
78     gridData.horizontalSpan= 2;
79     group.setLayoutData(gridData);
80     group.setLayout(new RowLayout(SWT.VERTICAL));
81     text = new Text(group, SWT.NONE);
82     text.setText("Another test");
83     
84     
85     //shell.pack();
86     shell.open();
87     while (!shell.isDisposed()) {
88       if (!display.readAndDispatch())
89         display.sleep();
90     }
91     display.dispose();
92   }
93
94