X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.databoard%2Fscratch%2Forg%2Fsimantics%2Fdataboard%2Fforms%2FLayoutSnippet.java;h=f70c8b8b0ce4a1960140b9e22c18c032ddf21e5c;hb=5c9442334a992c4e9899673fd1b56fb7a94b65f4;hp=cbba432ee8a281c912778936498c1433998d1a93;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git 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 index cbba432ee..f70c8b8b0 100644 --- a/bundles/org.simantics.databoard/scratch/org/simantics/databoard/forms/LayoutSnippet.java +++ b/bundles/org.simantics.databoard/scratch/org/simantics/databoard/forms/LayoutSnippet.java @@ -1,94 +1,94 @@ -package org.simantics.databoard.forms; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Spinner; -import org.eclipse.swt.widgets.Text; - -public class LayoutSnippet { - public static void main(String[] args) { - Display display = new Display(); - Shell shell = new Shell(display); - // set the layout of the shell - shell.setLayout(new GridLayout(3, false)); - // Create a label and a button - Label label = new Label(shell, SWT.NONE); - label.setText("A label"); - Button button = new Button(shell, SWT.PUSH); - button.setText("Press Me"); - - // Create a new label that will spam two columns - label = new Label(shell, SWT.BORDER); - label.setText("This is a label"); - // Create new layout data - label.setLayoutData(new GridData(GridData.FILL, - GridData.BEGINNING, true, false, 2, 1)); - - // Create a new label which is used as a separator - label = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); - // Create new layout data - label.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false, 2, 1)); - - // Create a right aligned button - Button b = new Button(shell, SWT.PUSH); - b.setText("New Button"); - - b.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false, 2, 1)); - - Spinner spinner = new Spinner(shell, SWT.READ_ONLY); - spinner.setMinimum(0); - spinner.setMaximum(1000); - spinner.setSelection(500); - spinner.setIncrement(1); - spinner.setPageIncrement(100); - GridData gridData = new GridData(SWT.FILL, - SWT.FILL, true, false); - gridData.widthHint = SWT.DEFAULT; - gridData.heightHint = SWT.DEFAULT; - gridData.horizontalSpan=2; - spinner.setLayoutData(gridData); - - Composite composite = new Composite(shell, SWT.BORDER); - gridData = new GridData(SWT.FILL, SWT.FILL, true, false); - gridData.horizontalSpan= 2; - composite.setLayoutData(gridData); - composite.setLayout(new GridLayout(1, false)); - - - Text text = new Text(composite, SWT.NONE); - text.setText("Testing"); - gridData = new GridData(SWT.FILL, SWT.FILL, true, false); - text.setLayoutData(gridData); - - text = new Text(composite, SWT.NONE); - text.setText("Another test"); -// gridData = new GridData(SWT.FILL, SWT.FILL, true, false); -// text.setLayoutData(gridData); - Group group = new Group(shell, SWT.NONE); - group.setText("This is my group"); - gridData = new GridData(SWT.FILL, SWT.FILL, true, false); - gridData.horizontalSpan= 2; - group.setLayoutData(gridData); - group.setLayout(new RowLayout(SWT.VERTICAL)); - text = new Text(group, SWT.NONE); - text.setText("Another test"); - - - //shell.pack(); - shell.open(); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) - display.sleep(); - } - display.dispose(); - } - +package org.simantics.databoard.forms; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Spinner; +import org.eclipse.swt.widgets.Text; + +public class LayoutSnippet { + public static void main(String[] args) { + Display display = new Display(); + Shell shell = new Shell(display); + // set the layout of the shell + shell.setLayout(new GridLayout(3, false)); + // Create a label and a button + Label label = new Label(shell, SWT.NONE); + label.setText("A label"); + Button button = new Button(shell, SWT.PUSH); + button.setText("Press Me"); + + // Create a new label that will spam two columns + label = new Label(shell, SWT.BORDER); + label.setText("This is a label"); + // Create new layout data + label.setLayoutData(new GridData(GridData.FILL, + GridData.BEGINNING, true, false, 2, 1)); + + // Create a new label which is used as a separator + label = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); + // Create new layout data + label.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false, 2, 1)); + + // Create a right aligned button + Button b = new Button(shell, SWT.PUSH); + b.setText("New Button"); + + b.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false, 2, 1)); + + Spinner spinner = new Spinner(shell, SWT.READ_ONLY); + spinner.setMinimum(0); + spinner.setMaximum(1000); + spinner.setSelection(500); + spinner.setIncrement(1); + spinner.setPageIncrement(100); + GridData gridData = new GridData(SWT.FILL, + SWT.FILL, true, false); + gridData.widthHint = SWT.DEFAULT; + gridData.heightHint = SWT.DEFAULT; + gridData.horizontalSpan=2; + spinner.setLayoutData(gridData); + + Composite composite = new Composite(shell, SWT.BORDER); + gridData = new GridData(SWT.FILL, SWT.FILL, true, false); + gridData.horizontalSpan= 2; + composite.setLayoutData(gridData); + composite.setLayout(new GridLayout(1, false)); + + + Text text = new Text(composite, SWT.NONE); + text.setText("Testing"); + gridData = new GridData(SWT.FILL, SWT.FILL, true, false); + text.setLayoutData(gridData); + + text = new Text(composite, SWT.NONE); + text.setText("Another test"); +// gridData = new GridData(SWT.FILL, SWT.FILL, true, false); +// text.setLayoutData(gridData); + Group group = new Group(shell, SWT.NONE); + group.setText("This is my group"); + gridData = new GridData(SWT.FILL, SWT.FILL, true, false); + gridData.horizontalSpan= 2; + group.setLayoutData(gridData); + group.setLayout(new RowLayout(SWT.VERTICAL)); + text = new Text(group, SWT.NONE); + text.setText("Another test"); + + + //shell.pack(); + shell.open(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + display.dispose(); + } + } \ No newline at end of file