]> git.argeo.org Git - lgpl/argeo-commons.git/blob - server/plugins/org.argeo.jcr.ui.explorer/src/main/java/org/argeo/jcr/ui/explorer/dialogs/ChooseNameDialog.java
Stabilize JCR explorer
[lgpl/argeo-commons.git] / server / plugins / org.argeo.jcr.ui.explorer / src / main / java / org / argeo / jcr / ui / explorer / dialogs / ChooseNameDialog.java
1 /*
2 * Copyright (C) 2007-2012 Mathieu Baudier
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.jcr.ui.explorer.dialogs;
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 Text nameT;
33
34 public ChooseNameDialog(Shell parentShell) {
35 super(parentShell);
36 setTitle("Choose name");
37 }
38
39 protected Point getInitialSize() {
40 return new Point(300, 250);
41 }
42
43 protected Control createDialogArea(Composite parent) {
44 Composite dialogarea = (Composite) super.createDialogArea(parent);
45 dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
46 Composite composite = new Composite(dialogarea, SWT.NONE);
47 composite.setLayout(new GridLayout(2, false));
48 composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
49 nameT = createLT(composite, "Name");
50
51 setMessage("Choose name", IMessageProvider.INFORMATION);
52 parent.pack();
53 return composite;
54 }
55
56 /** Creates label and text. */
57 protected Text createLT(Composite parent, String label) {
58 new Label(parent, SWT.NONE).setText(label);
59 Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
60 text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
61 return text;
62 }
63
64 public String getName() {
65 return nameT.getText();
66 }
67 }