]> git.argeo.org Git - lgpl/argeo-commons.git/blob - ChooseNameDialog.java
8d786e8226dcd0afd7efec1692b8bb29a198d5ed
[lgpl/argeo-commons.git] / ChooseNameDialog.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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 /** Dialog to change the current user password */
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
52 setMessage("Choose name", IMessageProvider.INFORMATION);
53 parent.pack();
54 return composite;
55 }
56
57 /** Creates label and text. */
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 }