]>
git.argeo.org Git - gpl/argeo-suite.git/blob - core/org.argeo.suite.ui/src/org/argeo/suite/ui/dialogs/NewUserWizard.java
1 package org
.argeo
.suite
.ui
.dialogs
;
3 import static org
.argeo
.eclipse
.ui
.EclipseUiUtils
.isEmpty
;
7 import org
.argeo
.eclipse
.ui
.EclipseUiUtils
;
8 import org
.argeo
.suite
.ui
.SuiteMsg
;
9 import org
.argeo
.suite
.ui
.SuiteUiUtils
;
10 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
11 import org
.eclipse
.jface
.wizard
.Wizard
;
12 import org
.eclipse
.jface
.wizard
.WizardPage
;
13 import org
.eclipse
.swt
.SWT
;
14 import org
.eclipse
.swt
.events
.ModifyEvent
;
15 import org
.eclipse
.swt
.events
.ModifyListener
;
16 import org
.eclipse
.swt
.layout
.GridData
;
17 import org
.eclipse
.swt
.layout
.GridLayout
;
18 import org
.eclipse
.swt
.widgets
.Composite
;
19 import org
.eclipse
.swt
.widgets
.Text
;
21 /** Ask first & last name. Update the passed node on finish */
22 public class NewUserWizard
extends Wizard
{
23 // private final static Log log = LogFactory.getLog(NewPersonWizard.class);
29 protected Text lastNameTxt
;
30 protected Text firstNameTxt
;
31 // private Button useDistinctDisplayNameBtn;
32 // private Text displayNameTxt;
34 public NewUserWizard(Node person
) {
39 public void addPages() {
41 MainInfoPage page
= new MainInfoPage("Main page");
43 } catch (Exception e
) {
44 throw new RuntimeException("Cannot add page to wizard", e
);
46 setWindowTitle(SuiteMsg
.personWizardWindowTitle
.lead());
50 * Called when the user click on 'Finish' in the wizard. The task is then
51 * created and the corresponding session saved.
54 public boolean performFinish() {
55 String lastName
= lastNameTxt
.getText();
56 String firstName
= firstNameTxt
.getText();
57 // String displayName = displayNameTxt.getText();
58 // boolean useDistinct = useDistinctDisplayNameBtn.getSelection();
59 if (EclipseUiUtils
.isEmpty(lastName
) && EclipseUiUtils
.isEmpty(firstName
)) {
60 MessageDialog
.openError(getShell(), "Non-valid information",
61 "Please enter at least a name that is not empty.");
64 // ConnectJcrUtils.setJcrProperty(person, PEOPLE_LAST_NAME, PropertyType.STRING, lastName);
65 // ConnectJcrUtils.setJcrProperty(person, PEOPLE_FIRST_NAME, PropertyType.STRING, firstName);
66 // String fullName = firstName + " " + lastName;
67 // ConnectJcrUtils.setJcrProperty(person, PEOPLE_DISPLAY_NAME, PropertyType.STRING, fullName);
73 public boolean performCancel() {
78 public boolean canFinish() {
79 String lastName
= lastNameTxt
.getText();
80 String firstName
= firstNameTxt
.getText();
81 if (isEmpty(lastName
) && isEmpty(firstName
)) {
87 protected class MainInfoPage
extends WizardPage
{
88 private static final long serialVersionUID
= 1L;
90 public MainInfoPage(String pageName
) {
92 setTitle(SuiteMsg
.personWizardPageTitle
.lead());
93 // setMessage("Please enter a last name and/or a first name.");
96 public void createControl(Composite parent
) {
97 parent
.setLayout(new GridLayout(2, false));
100 SuiteUiUtils
.createBoldLabel(parent
, SuiteMsg
.firstName
);
101 firstNameTxt
= new Text(parent
, SWT
.BORDER
);
102 // firstNameTxt.setMessage("a first name");
103 firstNameTxt
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
106 SuiteUiUtils
.createBoldLabel(parent
, SuiteMsg
.lastName
);
107 lastNameTxt
= new Text(parent
, SWT
.BORDER
);
108 // lastNameTxt.setMessage("a last name");
109 lastNameTxt
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
112 // useDistinctDisplayNameBtn = new Button(parent, SWT.CHECK);
113 // useDistinctDisplayNameBtn.setText("Define a disting display name");
114 // useDistinctDisplayNameBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
115 // true, false, 2, 1));
117 // ConnectWorkbenchUtils.createBoldLabel(parent, "Display Name");
118 // displayNameTxt = new Text(parent, SWT.BORDER);
119 // displayNameTxt.setMessage("an optional display name");
120 // displayNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
122 // displayNameTxt.setEnabled(false);
124 // useDistinctDisplayNameBtn.addSelectionListener(new SelectionAdapter() {
125 // private static final long serialVersionUID = 1L;
128 // public void widgetSelected(SelectionEvent e) {
129 // displayNameTxt.setEnabled(useDistinctDisplayNameBtn.getSelection());
133 ModifyListener ml
= new ModifyListener() {
134 private static final long serialVersionUID
= -1628130380128946886L;
137 public void modifyText(ModifyEvent event
) {
138 getContainer().updateButtons();
142 firstNameTxt
.addModifyListener(ml
);
143 lastNameTxt
.addModifyListener(ml
);
144 // displayNameTxt.addModifyListener(ml);
146 // Don't forget this.
147 setControl(firstNameTxt
);
148 firstNameTxt
.setFocus();