]> git.argeo.org Git - gpl/argeo-slc.git/blob - legacy/argeo-commons/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/parts/ChooseNameDialog.java
Adapt to changes in Argeo Commons
[gpl/argeo-slc.git] / legacy / argeo-commons / org.argeo.cms.ui.workbench / src / org / argeo / cms / ui / workbench / internal / jcr / parts / ChooseNameDialog.java
1 package org.argeo.cms.ui.workbench.internal.jcr.parts;
2
3 import org.eclipse.jface.dialogs.IMessageProvider;
4 import org.eclipse.jface.dialogs.TitleAreaDialog;
5 import org.eclipse.swt.SWT;
6 import org.eclipse.swt.graphics.Point;
7 import org.eclipse.swt.layout.GridData;
8 import org.eclipse.swt.layout.GridLayout;
9 import org.eclipse.swt.widgets.Composite;
10 import org.eclipse.swt.widgets.Control;
11 import org.eclipse.swt.widgets.Label;
12 import org.eclipse.swt.widgets.Shell;
13 import org.eclipse.swt.widgets.Text;
14
15 /** Ask end user for a name */
16 public class ChooseNameDialog extends TitleAreaDialog {
17 private static final long serialVersionUID = 280139710002698692L;
18 private Text nameTxt;
19
20 public ChooseNameDialog(Shell parentShell) {
21 super(parentShell);
22 setTitle("Choose name");
23 }
24
25 protected Point getInitialSize() {
26 return new Point(300, 250);
27 }
28
29 protected Control createDialogArea(Composite parent) {
30 Composite dialogarea = (Composite) super.createDialogArea(parent);
31 dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
32 Composite composite = new Composite(dialogarea, SWT.NONE);
33 composite.setLayout(new GridLayout(2, false));
34 composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
35 nameTxt = createLT(composite, "Name");
36 setMessage("Choose name", IMessageProvider.INFORMATION);
37 parent.pack();
38 nameTxt.setFocus();
39 return composite;
40 }
41
42 /** Creates label and text. */
43 protected Text createLT(Composite parent, String label) {
44 new Label(parent, SWT.NONE).setText(label);
45 Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
46 text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
47 return text;
48 }
49
50 public String getName() {
51 return nameTxt.getText();
52 }
53 }