]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/scratch/org/simantics/databoard/forms/LayoutSnippet.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.databoard / scratch / org / simantics / databoard / forms / LayoutSnippet.java
diff --git a/bundles/org.simantics.databoard/scratch/org/simantics/databoard/forms/LayoutSnippet.java b/bundles/org.simantics.databoard/scratch/org/simantics/databoard/forms/LayoutSnippet.java
new file mode 100644 (file)
index 0000000..cbba432
--- /dev/null
@@ -0,0 +1,94 @@
+package org.simantics.databoard.forms;\r
+\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.layout.GridData;\r
+import org.eclipse.swt.layout.GridLayout;\r
+import org.eclipse.swt.layout.RowLayout;\r
+import org.eclipse.swt.widgets.Button;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Display;\r
+import org.eclipse.swt.widgets.Group;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.swt.widgets.Spinner;\r
+import org.eclipse.swt.widgets.Text;\r
+\r
+public class LayoutSnippet {\r
+  public static void main(String[] args) {\r
+    Display display = new Display();\r
+    Shell shell = new Shell(display);\r
+    // set the layout of the shell\r
+    shell.setLayout(new GridLayout(3, false));\r
+    // Create a label and a button\r
+    Label label = new Label(shell, SWT.NONE);\r
+    label.setText("A label");\r
+    Button button = new Button(shell, SWT.PUSH);\r
+    button.setText("Press Me");\r
+    \r
+    // Create a new label that will spam two columns\r
+    label = new Label(shell, SWT.BORDER);\r
+    label.setText("This is a label");\r
+    // Create new layout data\r
+    label.setLayoutData(new GridData(GridData.FILL, \r
+            GridData.BEGINNING, true, false, 2, 1));\r
+    \r
+    // Create a new label which is used as a separator\r
+    label = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);\r
+    // Create new layout data\r
+    label.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false, 2, 1));\r
+    \r
+    // Create a right aligned button\r
+    Button b = new Button(shell, SWT.PUSH);\r
+    b.setText("New Button");\r
+    \r
+    b.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false, 2, 1));\r
+\r
+    Spinner spinner = new Spinner(shell, SWT.READ_ONLY);\r
+    spinner.setMinimum(0);\r
+    spinner.setMaximum(1000);\r
+    spinner.setSelection(500);\r
+    spinner.setIncrement(1);\r
+    spinner.setPageIncrement(100);\r
+    GridData gridData = new GridData(SWT.FILL, \r
+        SWT.FILL, true, false);\r
+    gridData.widthHint = SWT.DEFAULT;\r
+    gridData.heightHint = SWT.DEFAULT;\r
+    gridData.horizontalSpan=2;\r
+    spinner.setLayoutData(gridData);\r
+    \r
+    Composite composite = new Composite(shell, SWT.BORDER);\r
+    gridData = new GridData(SWT.FILL, SWT.FILL, true, false);\r
+    gridData.horizontalSpan= 2;\r
+    composite.setLayoutData(gridData);\r
+    composite.setLayout(new GridLayout(1, false));\r
+    \r
+    \r
+    Text text = new Text(composite, SWT.NONE);\r
+    text.setText("Testing");\r
+    gridData = new GridData(SWT.FILL, SWT.FILL, true, false);\r
+    text.setLayoutData(gridData);\r
+    \r
+    text = new Text(composite, SWT.NONE);\r
+    text.setText("Another test");\r
+//    gridData = new GridData(SWT.FILL, SWT.FILL, true, false);\r
+//    text.setLayoutData(gridData);\r
+    Group group = new Group(shell, SWT.NONE);\r
+    group.setText("This is my group");\r
+    gridData = new GridData(SWT.FILL, SWT.FILL, true, false);\r
+    gridData.horizontalSpan= 2;\r
+    group.setLayoutData(gridData);\r
+    group.setLayout(new RowLayout(SWT.VERTICAL));\r
+    text = new Text(group, SWT.NONE);\r
+    text.setText("Another test");\r
+    \r
+    \r
+    //shell.pack();\r
+    shell.open();\r
+    while (!shell.isDisposed()) {\r
+      if (!display.readAndDispatch())\r
+        display.sleep();\r
+    }\r
+    display.dispose();\r
+  }\r
+\r
+} 
\ No newline at end of file