1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.cms.ui.workbench.internal.jcr.parts;
17
18 import org.eclipse.jface.dialogs.IMessageProvider;
19 import org.eclipse.jface.dialogs.TitleAreaDialog;
20 import org.eclipse.swt.SWT;
21 import org.eclipse.swt.graphics.Point;
22 import org.eclipse.swt.layout.GridData;
23 import org.eclipse.swt.layout.GridLayout;
24 import org.eclipse.swt.widgets.Composite;
25 import org.eclipse.swt.widgets.Control;
26 import org.eclipse.swt.widgets.Label;
27 import org.eclipse.swt.widgets.Shell;
28 import org.eclipse.swt.widgets.Text;
29
30
31 public class ChooseNameDialog extends TitleAreaDialog {
32 private static final long serialVersionUID = 280139710002698692L;
33 private Text nameTxt;
34
35 public ChooseNameDialog(Shell parentShell) {
36 super(parentShell);
37 setTitle("Choose name");
38 }
39
40 protected Point getInitialSize() {
41 return new Point(300, 250);
42 }
43
44 protected Control createDialogArea(Composite parent) {
45 Composite dialogarea = (Composite) super.createDialogArea(parent);
46 dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
47 Composite composite = new Composite(dialogarea, SWT.NONE);
48 composite.setLayout(new GridLayout(2, false));
49 composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
50 nameTxt = createLT(composite, "Name");
51 setMessage("Choose name", IMessageProvider.INFORMATION);
52 parent.pack();
53 nameTxt.setFocus();
54 return composite;
55 }
56
57
58 protected Text createLT(Composite parent, String label) {
59 new Label(parent, SWT.NONE).setText(label);
60 Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
61 text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
62 return text;
63 }
64
65 public String getName() {
66 return nameTxt.getText();
67 }
68 }