Mercurial > projects > dwt-linux
annotate dwt/browser.old/PromptDialog.d @ 288:4ee8c4237614
old branches... commit by mistake
author | John Reimer<terminal.node@gmail.com> |
---|---|
date | Tue, 05 Aug 2008 18:00:50 -0700 |
parents | |
children |
rev | line source |
---|---|
288
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
1 /******************************************************************************* |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2003, 2007 IBM Corporation and others. |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
3 * All rights reserved. This program and the accompanying materials |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
5 * which accompanies this distribution, and is available at |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
6 * http://www.eclipse.org/legal/epl-v10.html |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
7 * |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
8 * Contributors: |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
9 * IBM Corporation - initial API and implementation |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
10 *******************************************************************************/ |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
11 module dwt.browser.PromptDialog; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
12 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
13 import dwt.dwthelper.utils; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
14 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
15 import dwt.DWT; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
16 import dwt.layout.GridData; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
17 import dwt.layout.GridLayout; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
18 import dwt.widgets.Button; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
19 import dwt.widgets.Composite; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
20 import dwt.widgets.Dialog; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
21 import dwt.widgets.Display; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
22 import dwt.widgets.Event; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
23 import dwt.widgets.Label; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
24 import dwt.widgets.Listener; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
25 import dwt.widgets.Monitor; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
26 import dwt.widgets.Shell; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
27 import dwt.widgets.Text; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
28 import dwt.widgets.Widget; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
29 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
30 class PromptDialog extends Dialog { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
31 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
32 PromptDialog(Shell parent, int style) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
33 super(parent, style); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
34 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
35 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
36 PromptDialog(Shell parent) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
37 this(parent, 0); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
38 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
39 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
40 void alertCheck(String title, String text, String check, ref int checkValue) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
41 Shell parent = getParent(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
42 final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
43 if (title !is null) shell.setText(title); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
44 GridLayout gridLayout = new GridLayout(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
45 shell.setLayout(gridLayout); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
46 Label label = new Label(shell, DWT.WRAP); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
47 label.setText(text); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
48 GridData data = new GridData(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
49 Monitor monitor = parent.getMonitor(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
50 int maxWidth = monitor.getBounds().width * 2 / 3; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
51 int width = label.computeSize(DWT.DEFAULT, DWT.DEFAULT).x; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
52 data.widthHint = Math.min(width, maxWidth); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
53 data.horizontalAlignment = GridData.FILL; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
54 data.grabExcessHorizontalSpace = true; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
55 label.setLayoutData (data); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
56 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
57 final Button checkButton = check !is null ? new Button(shell, DWT.CHECK) : null; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
58 if (checkButton !is null) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
59 checkButton.setText(check); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
60 checkButton.setSelection(checkValue[0] !is 0); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
61 data = new GridData (); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
62 data.horizontalAlignment = GridData.BEGINNING; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
63 checkButton.setLayoutData (data); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
64 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
65 Button okButton = new Button(shell, DWT.PUSH); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
66 okButton.setText(DWT.getMessage("SWT_OK")); //$NON-NLS-1$ |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
67 data = new GridData (); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
68 data.horizontalAlignment = GridData.CENTER; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
69 okButton.setLayoutData (data); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
70 okButton.addListener(DWT.Selection, new Listener() { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
71 public void handleEvent(Event event) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
72 if (checkButton !is null) checkValue[0] = checkButton.getSelection() ? 1 : 0; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
73 shell.close(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
74 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
75 }); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
76 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
77 shell.pack(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
78 shell.open(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
79 Display display = parent.getDisplay(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
80 while (!shell.isDisposed()) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
81 if (!display.readAndDispatch()) display.sleep(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
82 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
83 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
84 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
85 void confirmEx(String title, String text, String check, String button0, String button1, String button2, int defaultIndex, final int[] checkValue, final int[] result) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
86 Shell parent = getParent(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
87 final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
88 shell.setText(title); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
89 GridLayout gridLayout = new GridLayout(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
90 shell.setLayout(gridLayout); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
91 Label label = new Label(shell, DWT.WRAP); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
92 label.setText(text); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
93 GridData data = new GridData(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
94 Monitor monitor = parent.getMonitor(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
95 int maxWidth = monitor.getBounds().width * 2 / 3; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
96 int width = label.computeSize(DWT.DEFAULT, DWT.DEFAULT).x; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
97 data.widthHint = Math.min(width, maxWidth); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
98 data.horizontalAlignment = GridData.FILL; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
99 data.grabExcessHorizontalSpace = true; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
100 label.setLayoutData (data); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
101 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
102 final Button[] buttons = new Button[4]; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
103 Listener listener = new Listener() { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
104 public void handleEvent(Event event) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
105 if (buttons[0] !is null) checkValue[0] = buttons[0].getSelection() ? 1 : 0; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
106 Widget widget = event.widget; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
107 for (int i = 1; i < buttons.length; i++) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
108 if (widget is buttons[i]) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
109 result[0] = i - 1; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
110 break; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
111 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
112 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
113 shell.close(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
114 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
115 }; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
116 if (check !is null) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
117 buttons[0] = new Button(shell, DWT.CHECK); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
118 buttons[0].setText(check); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
119 buttons[0].setSelection(checkValue[0] !is 0); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
120 data = new GridData (); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
121 data.horizontalAlignment = GridData.BEGINNING; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
122 buttons[0].setLayoutData (data); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
123 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
124 Composite composite = new Composite(shell, DWT.NONE); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
125 data = new GridData(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
126 data.horizontalAlignment = GridData.CENTER; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
127 composite.setLayoutData (data); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
128 GridLayout layout = new GridLayout(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
129 layout.makeColumnsEqualWidth = true; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
130 composite.setLayout(layout); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
131 int buttonCount = 0; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
132 if (button0 !is null) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
133 buttons[1] = new Button(composite, DWT.PUSH); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
134 buttons[1].setText(button0); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
135 buttons[1].addListener(DWT.Selection, listener); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
136 buttons[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
137 buttonCount++; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
138 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
139 if (button1 !is null) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
140 buttons[2] = new Button(composite, DWT.PUSH); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
141 buttons[2].setText(button1); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
142 buttons[2].addListener(DWT.Selection, listener); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
143 buttons[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
144 buttonCount++; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
145 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
146 if (button2 !is null) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
147 buttons[3] = new Button(composite, DWT.PUSH); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
148 buttons[3].setText(button2); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
149 buttons[3].addListener(DWT.Selection, listener); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
150 buttons[3].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
151 buttonCount++; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
152 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
153 layout.numColumns = buttonCount; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
154 Button defaultButton = buttons [defaultIndex + 1]; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
155 if (defaultButton !is null) shell.setDefaultButton (defaultButton); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
156 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
157 shell.pack(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
158 shell.open(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
159 Display display = parent.getDisplay(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
160 while (!shell.isDisposed()) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
161 if (!display.readAndDispatch()) display.sleep(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
162 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
163 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
164 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
165 void prompt(String title, String text, String check, final String[] value, final int[] checkValue, final int[] result) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
166 Shell parent = getParent(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
167 final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
168 if (title !is null) shell.setText(title); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
169 GridLayout gridLayout = new GridLayout(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
170 shell.setLayout(gridLayout); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
171 Label label = new Label(shell, DWT.WRAP); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
172 label.setText(text); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
173 GridData data = new GridData(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
174 Monitor monitor = parent.getMonitor(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
175 int maxWidth = monitor.getBounds().width * 2 / 3; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
176 int width = label.computeSize(DWT.DEFAULT, DWT.DEFAULT).x; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
177 data.widthHint = Math.min(width, maxWidth); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
178 data.horizontalAlignment = GridData.FILL; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
179 data.grabExcessHorizontalSpace = true; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
180 label.setLayoutData (data); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
181 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
182 final Text valueText = new Text(shell, DWT.BORDER); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
183 if (value[0] !is null) valueText.setText(value[0]); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
184 data = new GridData(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
185 width = valueText.computeSize(DWT.DEFAULT, DWT.DEFAULT).x; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
186 if (width > maxWidth) data.widthHint = maxWidth; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
187 data.horizontalAlignment = GridData.FILL; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
188 data.grabExcessHorizontalSpace = true; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
189 valueText.setLayoutData(data); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
190 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
191 final Button[] buttons = new Button[3]; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
192 Listener listener = new Listener() { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
193 public void handleEvent(Event event) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
194 if (buttons[0] !is null) checkValue[0] = buttons[0].getSelection() ? 1 : 0; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
195 value[0] = valueText.getText(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
196 result[0] = event.widget is buttons[1] ? 1 : 0; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
197 shell.close(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
198 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
199 }; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
200 if (check !is null) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
201 buttons[0] = new Button(shell, DWT.CHECK); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
202 buttons[0].setText(check); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
203 buttons[0].setSelection(checkValue[0] !is 0); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
204 data = new GridData (); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
205 data.horizontalAlignment = GridData.BEGINNING; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
206 buttons[0].setLayoutData (data); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
207 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
208 Composite composite = new Composite(shell, DWT.NONE); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
209 data = new GridData(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
210 data.horizontalAlignment = GridData.CENTER; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
211 composite.setLayoutData (data); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
212 composite.setLayout(new GridLayout(2, true)); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
213 buttons[1] = new Button(composite, DWT.PUSH); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
214 buttons[1].setText(DWT.getMessage("SWT_OK")); //$NON-NLS-1$ |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
215 buttons[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
216 buttons[1].addListener(DWT.Selection, listener); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
217 buttons[2] = new Button(composite, DWT.PUSH); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
218 buttons[2].setText(DWT.getMessage("SWT_Cancel")); //$NON-NLS-1$ |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
219 buttons[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
220 buttons[2].addListener(DWT.Selection, listener); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
221 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
222 shell.pack(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
223 shell.open(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
224 Display display = parent.getDisplay(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
225 while (!shell.isDisposed()) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
226 if (!display.readAndDispatch()) display.sleep(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
227 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
228 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
229 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
230 void promptUsernameAndPassword(String title, String text, String check, final String[] user, final String[] pass, final int[] checkValue, final int[] result) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
231 Shell parent = getParent(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
232 final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
233 shell.setText(title); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
234 GridLayout gridLayout = new GridLayout(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
235 shell.setLayout(gridLayout); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
236 Label label = new Label(shell, DWT.WRAP); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
237 label.setText(text); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
238 GridData data = new GridData(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
239 Monitor monitor = parent.getMonitor(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
240 int maxWidth = monitor.getBounds().width * 2 / 3; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
241 int width = label.computeSize(DWT.DEFAULT, DWT.DEFAULT).x; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
242 data.widthHint = Math.min(width, maxWidth); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
243 data.horizontalAlignment = GridData.FILL; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
244 data.grabExcessHorizontalSpace = true; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
245 label.setLayoutData (data); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
246 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
247 Label userLabel = new Label(shell, DWT.NONE); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
248 userLabel.setText(DWT.getMessage("SWT_Username")); //$NON-NLS-1$ |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
249 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
250 final Text userText = new Text(shell, DWT.BORDER); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
251 if (user[0] !is null) userText.setText(user[0]); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
252 data = new GridData(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
253 data.horizontalAlignment = GridData.FILL; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
254 data.grabExcessHorizontalSpace = true; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
255 userText.setLayoutData(data); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
256 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
257 Label passwordLabel = new Label(shell, DWT.NONE); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
258 passwordLabel.setText(DWT.getMessage("SWT_Password")); //$NON-NLS-1$ |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
259 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
260 final Text passwordText = new Text(shell, DWT.PASSWORD | DWT.BORDER); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
261 if (pass[0] !is null) passwordText.setText(pass[0]); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
262 data = new GridData(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
263 data.horizontalAlignment = GridData.FILL; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
264 data.grabExcessHorizontalSpace = true; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
265 passwordText.setLayoutData(data); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
266 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
267 final Button[] buttons = new Button[3]; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
268 Listener listener = new Listener() { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
269 public void handleEvent(Event event) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
270 if (buttons[0] !is null) checkValue[0] = buttons[0].getSelection() ? 1 : 0; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
271 user[0] = userText.getText(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
272 pass[0] = passwordText.getText(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
273 result[0] = event.widget is buttons[1] ? 1 : 0; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
274 shell.close(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
275 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
276 }; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
277 if (check !is null) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
278 buttons[0] = new Button(shell, DWT.CHECK); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
279 buttons[0].setText(check); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
280 buttons[0].setSelection(checkValue[0] !is 0); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
281 data = new GridData (); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
282 data.horizontalAlignment = GridData.BEGINNING; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
283 buttons[0].setLayoutData (data); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
284 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
285 Composite composite = new Composite(shell, DWT.NONE); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
286 data = new GridData(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
287 data.horizontalAlignment = GridData.CENTER; |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
288 composite.setLayoutData (data); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
289 composite.setLayout(new GridLayout(2, true)); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
290 buttons[1] = new Button(composite, DWT.PUSH); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
291 buttons[1].setText(DWT.getMessage("SWT_OK")); //$NON-NLS-1$ |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
292 buttons[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
293 buttons[1].addListener(DWT.Selection, listener); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
294 buttons[2] = new Button(composite, DWT.PUSH); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
295 buttons[2].setText(DWT.getMessage("SWT_Cancel")); //$NON-NLS-1$ |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
296 buttons[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
297 buttons[2].addListener(DWT.Selection, listener); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
298 |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
299 shell.setDefaultButton(buttons[1]); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
300 shell.pack(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
301 shell.open(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
302 Display display = parent.getDisplay(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
303 while (!shell.isDisposed()) { |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
304 if (!display.readAndDispatch()) display.sleep(); |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
305 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
306 } |
4ee8c4237614
old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
307 } |