| 1 | package de.ugoe.cs.eventbench.swt;
|
|---|
| 2 |
|
|---|
| 3 | import org.eclipse.swt.widgets.Dialog;
|
|---|
| 4 | import org.eclipse.swt.widgets.Display;
|
|---|
| 5 | import org.eclipse.swt.widgets.Shell;
|
|---|
| 6 | import org.eclipse.swt.widgets.List;
|
|---|
| 7 | import org.eclipse.swt.SWT;
|
|---|
| 8 | import org.eclipse.swt.widgets.Label;
|
|---|
| 9 | import org.eclipse.swt.widgets.Button;
|
|---|
| 10 | import org.eclipse.swt.layout.GridLayout;
|
|---|
| 11 | import org.eclipse.swt.layout.GridData;
|
|---|
| 12 |
|
|---|
| 13 | public class CommandHistory extends Dialog {
|
|---|
| 14 |
|
|---|
| 15 | protected Object result;
|
|---|
| 16 | protected Shell shell;
|
|---|
| 17 |
|
|---|
| 18 | /**
|
|---|
| 19 | * Create the dialog.
|
|---|
| 20 | * @param parent
|
|---|
| 21 | * @param style
|
|---|
| 22 | */
|
|---|
| 23 | public CommandHistory(Shell parent, int style) {
|
|---|
| 24 | super(parent, style);
|
|---|
| 25 | setText("SWT Dialog");
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | /**
|
|---|
| 29 | * Open the dialog.
|
|---|
| 30 | * @return the result
|
|---|
| 31 | */
|
|---|
| 32 | public Object open() {
|
|---|
| 33 | createContents();
|
|---|
| 34 | shell.open();
|
|---|
| 35 | shell.layout();
|
|---|
| 36 | Display display = getParent().getDisplay();
|
|---|
| 37 | while (!shell.isDisposed()) {
|
|---|
| 38 | if (!display.readAndDispatch()) {
|
|---|
| 39 | display.sleep();
|
|---|
| 40 | }
|
|---|
| 41 | }
|
|---|
| 42 | return result;
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | /**
|
|---|
| 46 | * Create contents of the dialog.
|
|---|
| 47 | */
|
|---|
| 48 | private void createContents() {
|
|---|
| 49 | shell = new Shell(getParent(), SWT.DIALOG_TRIM);
|
|---|
| 50 | shell.setSize(450, 300);
|
|---|
| 51 | shell.setText(getText());
|
|---|
| 52 | shell.setLayout(new GridLayout(3, false));
|
|---|
| 53 |
|
|---|
| 54 | Label lblRecentCommands = new Label(shell, SWT.NONE);
|
|---|
| 55 | lblRecentCommands.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
|
|---|
| 56 | lblRecentCommands.setText("Recent Commands:");
|
|---|
| 57 | new Label(shell, SWT.NONE);
|
|---|
| 58 |
|
|---|
| 59 | List list = new List(shell, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
|
|---|
| 60 | list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
|
|---|
| 61 |
|
|---|
| 62 | Button btnExec = new Button(shell, SWT.NONE);
|
|---|
| 63 | btnExec.setText("Execute");
|
|---|
| 64 |
|
|---|
| 65 | Button btnCopyToClipboard = new Button(shell, SWT.NONE);
|
|---|
| 66 | btnCopyToClipboard.setText("Copy to Clipboard");
|
|---|
| 67 |
|
|---|
| 68 | Button btnCreateBatchfile = new Button(shell, SWT.NONE);
|
|---|
| 69 | btnCreateBatchfile.setText("Create Batchfile");
|
|---|
| 70 |
|
|---|
| 71 | }
|
|---|
| 72 | }
|
|---|