package Layoutmanagement;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
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.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
public class Layoutmanagement {
Shell shell;
Display display;
public Layoutmanagement(Display display) {
this.display = display;
this.shell = new Shell(display);
shell.setText("Layoutmanagement");
}
private void createGui() {
shell.setLayout(new FillLayout());
// Erstellen einer Sashform
SashForm sashForm = new SashForm(shell, SWT.HORIZONTAL);
// Erstellen von Dummyinhalt mit 10px Abstand im linken Sash
FillLayout fillLayout = new FillLayout();
fillLayout.marginHeight = 3;
fillLayout.marginWidth = 3;
compositeLeft.setLayout(fillLayout);
button.setText("TEST");
// Erstellen des rechten Sash
FormLayout formLayout = new FormLayout();
formLayout.marginHeight = 3;
formLayout.marginWidth = 3;
compositeRight.setLayout(formLayout);
// Label im äußeren Composite des 2ten Sash
Label label
= new Label(compositeRight, SWT.
BOLD); label.setText("Visual Editor");
FormData formData = new FormData();
formData.top = new FormAttachment(0);
formData.left = new FormAttachment(0);
formData.right = new FormAttachment(100);
label.setLayoutData(formData);
// Tabfolder im äußeren Composite des zweiten Sash, unter dem Label
TabFolder tabfolder = new TabFolder(compositeRight, SWT.TOP);
formData = new FormData();
formData.left = new FormAttachment(0);
formData.top = new FormAttachment(label,10);
formData.right = new FormAttachment(100);
formData.bottom = new FormAttachment(100);
tabfolder.setLayoutData(formData);
TabItem item = new TabItem(tabfolder, SWT.NONE);
item.setText("Appearance");
item.setControl(compositeAppearance);
new TabItem(tabfolder, SWT.NONE).setText("Code Generation");
new TabItem(tabfolder, SWT.NONE).setText("Pattern Styles");
// Inhalt des ersten Tabs
formLayout = new FormLayout();
formLayout.marginHeight = 3;
formLayout.marginWidth = 3;
compositeAppearance.setLayout(formLayout);
formData = new FormData();
formData.left = new FormAttachment(0);
formData.right = new FormAttachment(100);
formData.top = new FormAttachment(0);
compositeTop.setLayoutData(formData);
RowLayout rowLayout = new RowLayout(SWT.VERTICAL);
rowLayout.spacing = 3;
compositeTop.setLayout(rowLayout);
button
= new Button(compositeTop, SWT.
CHECK); button.setText("Open Properties View");
button
= new Button(compositeTop, SWT.
CHECK); button.setText("Open Beans View");
label
= new Label(compositeAppearance, SWT.
NONE); label.setText("Swing Look and Feel:");
formData = new FormData();
formData.left = new FormAttachment(0);
formData.right = new FormAttachment(100);
formData.top = new FormAttachment(compositeTop, 10);
label.setLayoutData(formData);
fillLayout = new FillLayout(SWT.VERTICAL);
fillLayout.spacing = 3;
compositeOptions.setLayout(fillLayout);
formData = new FormData();
formData.right = new FormAttachment(100);
formData.top = new FormAttachment(label, 10);
compositeOptions.setLayoutData(formData);
new Button(compositeOptions, SWT.
PUSH).
setText("New"); new Button(compositeOptions, SWT.
PUSH).
setText("Edit"); new Button(compositeOptions, SWT.
PUSH).
setText("Remove");
Table table = new Table(compositeAppearance, SWT.BORDER|SWT.H_SCROLL|SWT.V_SCROLL);
formData = new FormData();
formData.top = new FormAttachment(label,10);
formData.bottom = new FormAttachment(compositeBottom, -10);
formData.left = new FormAttachment(0);
formData.right = new FormAttachment(compositeOptions,-10);
table.setLayoutData(formData);
rowLayout = new RowLayout(SWT.VERTICAL);
rowLayout.spacing = 3;
compositeBottom.setLayout(rowLayout);
formData = new FormData();
formData.left = new FormAttachment(0);
formData.right = new FormAttachment(100);
formData.bottom = new FormAttachment(100);
compositeBottom.setLayoutData(formData);
new Button(compositeBottom, SWT.
CHECK).
setText("Show Grid when Container or " + "its children are selected");
fillLayout = new FillLayout(SWT.HORIZONTAL);
fillLayout.spacing = 3;
xy.setLayout(fillLayout);
new Label(xy, SWT.
BEGINNING).
setText("X/Y grid spacing"); new Text(xy, SWT.BORDER);
new Button(compositeBottom, SWT.
CHECK).
setText("Prompt for Bean Name during Creation"); new Button(compositeBottom, SWT.
CHECK).
setText("Caret location in source selects " + "graphical components");
shell.pack();
}
public void run() {
createGui();
shell.open();
while(!shell.isDisposed()) {
if(!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
public static void main
(String[] args
) { new Layoutmanagement(Display.getDefault()).run();
}
}