locations=locations
recentItems=recent items
-appTitle=Argeo Suite
\ No newline at end of file
+appTitle=Argeo Suite
+
+#
+# PEOPLE
+# org.argeo.people.ui.PeopleMsg
+#
+person=Person
+organisation=Organisation
+
+# NewPersonWizard
+firstName=First Name
+lastName=Last Name
+salutation=Salutation
+email=Email
+personWizardWindowTitle=New person
+personWizardPageTitle=Create a contact
+
+# NewOrgWizard
+legalName=Legal name
+legalForm=Legal form
+vatId=VAT ID
+orgWizardWindowTitle=New organisation
+orgWizardPageTitle=Create an organisation
+
+
+# ContextAddressComposite
+chooseAnOrganisation=Choose an organisation
+street=Street
+streetComplement=Street complement
+zipCode=Zip code
+city=City
+state=State
+country=Country
+geopoint=Geopoint
+
+# FilteredOrderableEntityTable
+filterHelp=Type filter criterion separated by a space
+
+# BankAccountComposite
+accountHolder=Account holder
+bankName=Bank name
+currency=Currency
+accountNumber=Account number
+bankNumber=Bank number
+BIC=BIC
+IBAN=IBAN
+
+# EditJobDialog
+position=Role
+chosenItem=Chose item
+department=Department
+isPrimary=Is primary
+searchAndChooseEntity=Search and choose a corresponding entity
+
+# ContactListCTab (e4)
+notes=Notes
+addAContact=Add a contact
+contactValue=Contact value
+linkedCompany=Linked company
+
+# OrgAdminInfoCTab (e4)
+paymentAccount=Payment account
+
+# OrgEditor (e4)
+orgDetails=Details
+orgActivityLog=Activity log
+team=Team
+orgAdmin=Admin.
+
+# PersonEditor (e4)
+personDetails=Contact details
+personActivityLog=Activity log
+personOrgs=Organisations
+personSecurity=Security
+
+# PersonSecurityCTab (e4)
+resetPassword=Reset password
+
+# Generic
+label=Label
+aCustomLabel=A custom label
+description=Description
+value=Value
+name=Name
+primary=Primary
+add=Add
+save=Save
+pickUp=Pick up
+
+# Tags
+confirmNewTag=Tag #{0} is not yet registered. Are you sure you want to create it?
+cannotCreateTag=Tag #{0} is not yet registered and you don't have enough rights to create it.
--- /dev/null
+dashboard=dashboard
+people=Kontakte
+documents=Dokumente
+locations=Orte
+recentItems=neulich
+
+appTitle=Argeo Suite
+
+#
+# PEOPLE
+# org.argeo.people.ui.PeopleMsg
+#
+person=Person
+organisation=Organisation
+
+# NewPersonWizard
+firstName=Vorname
+lastName=Nachname
+salutation=Salutation
+email=E-Mail
+personWizardWindowTitle=Neue Person
+personWizardPageTitle=Kontakt erstellen
+
+# NewOrgWizard
+legalName=Name
+legalForm=Geschäftsform
+vatId=Ust ID
+orgWizardWindowTitle=Neue Organisation
+orgWizardPageTitle=Organisation erstellen
+
+
+# ContextAddressComposite
+chooseAnOrganisation=Organisation wählen
+street=Strasse
+streetComplement=Strasse Zusatz
+zipCode=PLZ
+city=Stadt
+state=Bundesland
+country=Land
+geopoint=Geopoint
+
+# FilteredOrderableEntityTable
+filterHelp=Type filter criterion separated by a space
+
+# BankAccountComposite
+accountHolder=Kontoinhaber
+bankName=Name der Bank
+currency=Währung
+accountNumber=Kontonummer
+bankNumber=BLZ
+BIC=BIC
+IBAN=IBAN
+
+# EditJobDialog
+position=Rolle
+chosenItem=Auswahl
+department=Abteilung
+isPrimary=Ist Primär
+searchAndChooseEntity=Suche und wähle ein zugehöriges Objekt
+
+# ContactListCTab (e4)
+notes=Bemerkungen
+addAContact=Kontakt hinzufügen
+contactValue=Kontakt value
+linkedCompany=zugehörige Firma
+
+# OrgAdminInfoCTab (e4)
+paymentAccount=Geschäftskonto
+
+# OrgEditor (e4)
+orgDetails=Details
+orgActivityLog=Aktivitäten Log
+team=Team
+orgAdmin=Admin.
+
+# PersonEditor (e4)
+personDetails=Kontakt Daten
+personActivityLog=Aktivitäten Log
+personOrgs=Organisationen
+personSecurity=Sicherheit
+
+# PersonSecurityCTab (e4)
+resetPassword=Passwort zurücksetzen
+
+# Generic
+label=Beschriftung
+aCustomLabel=Eine spezifische Beschriftung
+description=Beschreibung
+value=Wert
+name=Name
+primary=Haupt-
+add=Hinzufügen
+save=Speichern
+pickUp=Aussuchen
+
+# Tags
+confirmNewTag=Das Hashtag '{0}' existiert noch nicht. WollenSie es hinzufügen?
+cannotCreateTag=Das Hashtag '{0}' existiert nicht uns Sie haben nicht die Rechte, um es hinzufügen.
--- /dev/null
+dashboard=dashboard
+people=contacts
+documents=documents
+locations=lieux
+recentItems=récent
+
+appTitle=Argeo Suite
+
+#
+# GENERIC
+#
+
+#
+# PEOPLE
+# org.argeo.people.ui.PeopleMsg
+#
+person=Personne
+organisation=Organisation
+
+# NewPersonWizard
+firstName=Prénom
+lastName=Nom
+salutation=Salutation
+email=Email
+personWizardWindowTitle=Nouvelle personne
+personWizardPageTitle=Créer un contact
+
+# NewOrgWizard
+legalName=Nom
+legalForm=Forme légale
+vatId=ID TVA
+orgWizardWindowTitle=Nouvelle organisation
+orgWizardPageTitle=Créer une organisation
+
+
+# ContextAddressComposite
+chooseAnOrganisation=Choisir une organisation
+street=Rue
+streetComplement=Complément rue
+zipCode=Code postal
+city=Ville
+state=État
+country=Pays
+geopoint=Géocoordonnées
+
+# FilteredOrderableEntityTable
+filterHelp=Sasir les critères de filtrage séparés par des espaces
+
+# BankAccountComposite
+accountHolder=Propriétaire du compte
+bankName=Nom de la banque
+currency=Devise
+accountNumber=Numéro de compte
+bankNumber=Numéro de banque
+BIC=BIC
+IBAN=IBAN
+
+# EditJobDialog
+position=Rôle
+chosenItem=Choisir une élément
+department=Service
+isPrimary=Principal
+searchAndChooseEntity=Cherhcer et choisir l'entitée correspondante
+
+# ContactListCTab (e4)
+notes=Notes
+addAContact=Ajouter un contact
+contactValue=Valeur
+linkedCompany=Entreprise liée
+
+# OrgAdminInfoCTab (e4)
+paymentAccount=Compte de paiement
+
+# OrgEditor (e4)
+orgDetails=Détails
+orgActivityLog=Activités
+team=Équipe
+orgAdmin=Admin.
+
+# PersonEditor (e4)
+personDetails=Détails du contact
+personActivityLog=Activités
+personOrgs=Organisations
+personSecurity=Accès
+
+# PersonSecurityCTab (e4)
+resetPassword=Force le mot de passe
+
+# Generic
+label=Étiquette
+aCustomLabel=Une étiquette spécifique
+description=Description
+value=Valeur
+name=Nom
+primary=Principal
+add=Ajouter
+save=Sauver
+pickUp=Choisir
+
+# Tags
+confirmNewTag=Le tag #{0} n'existe pas encore. Voulez-vous le créer?
+cannotCreateTag=Le tag #{0} n'existe pas encore et vous n'avez pas les droits pour le créer.
org.argeo.entity,\
org.eclipse.core.commands.common,\
org.eclipse.jface.window,\
+org.eclipse.jface.dialogs,\
org.argeo.eclipse.ui.dialogs,\
*
import javax.jcr.Node;
import javax.jcr.RepositoryException;
-import org.argeo.api.NodeConstants;
import org.argeo.cms.CmsUserManager;
import org.argeo.cms.ui.CmsTheme;
import org.argeo.cms.ui.CmsUiProvider;
import org.argeo.cms.ui.CmsView;
+import org.argeo.cms.ui.dialogs.CmsWizardDialog;
import org.argeo.cms.ui.util.CmsUiUtils;
-import org.argeo.entity.EntityType;
-import org.argeo.jcr.Jcr;
-import org.argeo.jcr.JcrUtils;
+import org.argeo.eclipse.ui.Selected;
import org.argeo.naming.LdapAttrs;
import org.argeo.suite.SuiteRole;
+import org.argeo.suite.ui.dialogs.NewUserWizard;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.Wizard;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
}
});
+ addItem.addSelectionListener((Selected) (e) -> {
+ //SuiteUtils.getOrCreateUserNode(adminSession, userDn);
+ Wizard wizard = new NewUserWizard(null);
+ CmsWizardDialog dialog = new CmsWizardDialog(parent.getShell(), wizard);
+ // WizardDialog dialog = new WizardDialog(shell, wizard);
+ if (dialog.open() == Window.OK) {
+ // TODO create
+ }
+ });
+
usersViewer.getTable().setLayoutData(CmsUiUtils.fillAll());
usersViewer.setInput(cmsUserManager);
@Override
public void setState(Composite parent, String state) {
- if (state == null || !state.startsWith("/"))
+ if (state == null)
+ return;
+ if (!state.startsWith("/")) {
+ if (parent instanceof SuiteUi) {
+ SuiteUi ui = (SuiteUi) parent;
+ String currentLayerId = ui.getCurrentLayerId();
+ if (state.equals(currentLayerId))
+ return; // does nothing
+ else {
+ Map<String, Object> properties = new HashMap<>();
+ properties.put(SuiteEvent.LAYER, state);
+ ui.getCmsView().sendEvent(SuiteEvent.switchLayer.topic(), properties);
+ }
+ }
return;
+ }
SuiteUi suiteUi = (SuiteUi) parent;
Node node = stateToNode(suiteUi, state);
if (node == null) {
private Node stateToNode(SuiteUi suiteUi, String state) {
if (suiteUi == null)
return null;
- if (state == null)
+ if (state == null || !state.startsWith("/"))
return null;
String path = state.substring(1);
CmsUiProvider uiProvider = findByType(uiProvidersByType, node);
SuiteLayer layer = findByType(layersByType, node);
ui.switchToLayer(layer, node);
- layer.view(uiProvider, ui.getCurrentWorkArea(), node);
+ ui.getCmsView().runAs(() -> layer.view(uiProvider, ui.getCurrentWorkArea(), node));
ui.getCmsView().stateChanged(nodeToState(node), Jcr.getTitle(node));
} else if (isTopic(event, SuiteEvent.openNewPart)) {
Node node = getNode(ui, event);
CmsUiProvider uiProvider = findByType(uiProvidersByType, node);
SuiteLayer layer = findByType(layersByType, node);
ui.switchToLayer(layer, node);
- layer.open(uiProvider, ui.getCurrentWorkArea(), node);
+ ui.getCmsView().runAs(() -> layer.open(uiProvider, ui.getCurrentWorkArea(), node));
ui.getCmsView().stateChanged(nodeToState(node), Jcr.getTitle(node));
} else if (isTopic(event, SuiteEvent.switchLayer)) {
String layerId = get(event, SuiteEvent.LAYER);
if (layerId != null) {
- ui.switchToLayer(layerId, ui.getUserDir());
- // ui.getCmsView().navigateTo("~");
+// ui.switchToLayer(layerId, ui.getUserDir());
+ ui.getCmsView().runAs(() -> ui.switchToLayer(layerId, ui.getUserDir()));
+ ui.getCmsView().navigateTo(layerId);
} else {
Node node = getNode(ui, event);
if (node != null) {
SuiteLayer layer = findByType(layersByType, node);
- ui.switchToLayer(layer, node);
+ ui.getCmsView().runAs(() -> ui.switchToLayer(layer, node));
}
}
}
/** Localized messages. */
public enum SuiteMsg implements Localized {
- dashboard,people,documents,locations,recentItems;
+ dashboard, people, documents, locations, recentItems,
+ // NewPersonWizard
+ firstName, lastName, salutation, email, personWizardWindowTitle, personWizardPageTitle,
+ // NewOrgWizard
+ orgWizardWindowTitle, orgWizardPageTitle, legalName, legalForm, vatId,
+ // ContextAddressComposite
+ chooseAnOrganisation, street, streetComplement, zipCode, city, state, country, geopoint,
+ // FilteredOrderableEntityTable
+ filterHelp,
+ // BankAccountComposite
+ accountHolder, bankName, currency, accountNumber, bankNumber, BIC, IBAN,
+ // EditJobDialog
+ position, chosenItem, department, isPrimary, searchAndChooseEntity,
+ // ContactListCTab (e4)
+ notes, addAContact, contactValue, linkedCompany,
+ // OrgAdminInfoCTab (e4)
+ paymentAccount,
+ // OrgEditor (e4)
+ orgDetails, orgActivityLog, team, orgAdmin,
+ // PersonEditor (e4)
+ personDetails, personActivityLog, personOrgs, personSecurity,
+ // PersonSecurityCTab (e4)
+ resetPassword,
+ // Generic
+ label, aCustomLabel, description, value, name, primary, add, save, pickup,
+ // Tag
+ confirmNewTag, cannotCreateTag;
}
import javax.jcr.Session;
import org.argeo.api.NodeConstants;
+import org.argeo.cms.Localized;
import org.argeo.cms.ui.dialogs.CmsWizardDialog;
import org.argeo.cms.ui.util.CmsUiUtils;
+import org.argeo.eclipse.ui.EclipseUiUtils;
import org.argeo.entity.EntityNames;
import org.argeo.entity.EntityType;
import org.argeo.jcr.JcrException;
public static Label addFormLabel(Composite parent, String label) {
Label lbl = new Label(parent, SWT.WRAP);
lbl.setText(label);
- lbl.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, true, true));
+ //lbl.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, true, true));
CmsUiUtils.style(lbl, SuiteStyle.simpleLabel);
return lbl;
}
public static Text addFormLine(Composite parent, String label, String text) {
Composite lineComposite = new Composite(parent, SWT.NONE);
lineComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- lineComposite.setLayout(new GridLayout(2, true));
+ lineComposite.setLayout(new GridLayout(2, false));
CmsUiUtils.style(lineComposite, SuiteStyle.formLine);
addFormLabel(lineComposite, label);
Text txt = addFormTextField(lineComposite, text, null);
public static Text addFormInput(Composite parent, String label, String placeholder) {
Composite lineComposite = new Composite(parent, SWT.NONE);
lineComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- lineComposite.setLayout(new GridLayout(2, true));
+ lineComposite.setLayout(new GridLayout(2, false));
CmsUiUtils.style(lineComposite, SuiteStyle.formLine);
addFormLabel(lineComposite, label);
Text txt = addFormInputField(lineComposite, placeholder);
return txt;
}
+ public static Label createBoldLabel(Composite parent, Localized localized) {
+ Label label = new Label(parent, SWT.LEAD);
+ label.setText(localized.lead());
+ label.setFont(EclipseUiUtils.getBoldFont(parent));
+ label.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false));
+ return label;
+ }
+
public static Label addFormPicture(Composite parent, String label, Node fileNode) throws RepositoryException {
Composite lineComposite = new Composite(parent, SWT.NONE);
lineComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
package org.argeo.suite.ui;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import org.argeo.cms.ui.viewers.Section;
import org.argeo.naming.LdapAttrs;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Text;
import org.osgi.service.useradmin.User;
/** Edit a suite user. */
public class SuiteUserUiProvider implements CmsUiProvider {
+ private String[] availableRoles;
private CmsUserManager cmsUserManager;
@Override
String uid = context.getName();
User user = cmsUserManager.getUserFromLocalId(uid);
- Text givenName = new Text(main, SWT.SINGLE);
- givenName.setText(getUserProperty(user, LdapAttrs.givenName.name()));
+// Text givenName = new Text(main, SWT.SINGLE);
+// givenName.setText(getUserProperty(user, LdapAttrs.givenName.name()));
+ Text givenName = SuiteUiUtils.addFormInput(main, SuiteMsg.firstName.lead(),
+ getUserProperty(user, LdapAttrs.givenName.name()));
- Text sn = new Text(main, SWT.SINGLE);
- sn.setText(getUserProperty(user, LdapAttrs.sn.name()));
+ Text sn = SuiteUiUtils.addFormInput(main, SuiteMsg.lastName.lead(), getUserProperty(user, LdapAttrs.sn.name()));
+ // sn.setText(getUserProperty(user, LdapAttrs.sn.name()));
- Text email = new Text(main, SWT.SINGLE);
- email.setText(getUserProperty(user, LdapAttrs.mail.name()));
+ Text email = SuiteUiUtils.addFormInput(main, SuiteMsg.email.lead(),
+ getUserProperty(user, LdapAttrs.mail.name()));
+ // email.setText(getUserProperty(user, LdapAttrs.mail.name()));
- Label lbl = new Label(main, SWT.NONE);
- lbl.setText(uid);
+ Text uidT = SuiteUiUtils.addFormLine(main, "uid", getUserProperty(user, LdapAttrs.uid.name()));
+ uidT.setText(uid);
- Label dnL = new Label(main, SWT.NONE);
- dnL.setText(user.getName());
+// Label dnL = new Label(main, SWT.NONE);
+// dnL.setText(user.getName());
// roles
- Section rolesSection = new Section(main, SWT.NONE, context);
- new Label(rolesSection, SWT.NONE).setText("Roles:");
- String[] roles = cmsUserManager.getUserRoles(user.getName());
- for (String role : roles) {
- new Label(rolesSection, SWT.NONE).setText(role);
+ // Section rolesSection = new Section(main, SWT.NONE, context);
+ Group rolesSection = new Group(main, SWT.NONE);
+ rolesSection.setText("Roles");
+ rolesSection.setLayoutData(CmsUiUtils.fillWidth());
+ rolesSection.setLayout(new GridLayout());
+ // new Label(rolesSection, SWT.NONE).setText("Roles:");
+ List<String> roles = Arrays.asList(cmsUserManager.getUserRoles(user.getName()));
+ for (String role : availableRoles) {
+ // new Label(rolesSection, SWT.NONE).setText(role);
+ Button radio = new Button(rolesSection, SWT.CHECK);
+ radio.setText(role);
+ if (roles.contains(role))
+ radio.setSelection(true);
}
- return lbl;
+ return main;
}
public void setCmsUserManager(CmsUserManager cmsUserManager) {
return value != null ? value.toString() : null;
}
+ public void init(Map<String, Object> properties) {
+ availableRoles = (String[]) properties.get("availableRoles");
+ }
}
--- /dev/null
+package org.argeo.suite.ui.dialogs;
+
+import org.argeo.suite.ui.SuiteMsg;
+import org.argeo.suite.ui.SuiteUiUtils;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+public class NewPersonPage extends WizardPage {
+ private static final long serialVersionUID = -944349994177526468L;
+ protected Text lastNameTxt;
+ protected Text firstNameTxt;
+ protected Text emailTxt;
+
+ protected NewPersonPage(String pageName) {
+ super(pageName);
+ setTitle(SuiteMsg.personWizardPageTitle.lead());
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ parent.setLayout(new GridLayout(2, false));
+
+ // FirstName
+ SuiteUiUtils.createBoldLabel(parent, SuiteMsg.firstName);
+ firstNameTxt = new Text(parent, SWT.BORDER);
+ firstNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ // LastName
+ SuiteUiUtils.createBoldLabel(parent, SuiteMsg.lastName);
+ lastNameTxt = new Text(parent, SWT.BORDER);
+ lastNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ SuiteUiUtils.createBoldLabel(parent, SuiteMsg.email);
+ emailTxt = new Text(parent, SWT.BORDER);
+ emailTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ ModifyListener ml = new ModifyListener() {
+ private static final long serialVersionUID = -1628130380128946886L;
+
+ @Override
+ public void modifyText(ModifyEvent event) {
+ getContainer().updateButtons();
+ }
+ };
+
+ firstNameTxt.addModifyListener(ml);
+ lastNameTxt.addModifyListener(ml);
+ emailTxt.addModifyListener(ml);
+
+ // Don't forget this.
+ setControl(firstNameTxt);
+ firstNameTxt.setFocus();
+
+ }
+
+// public void updateNode(Node node, PeopleService peopleService, ResourcesService resourcesService) {
+// ConnectJcrUtils.setJcrProperty(node, PeopleNames.PEOPLE_LAST_NAME, PropertyType.STRING, lastNameTxt.getText());
+// ConnectJcrUtils.setJcrProperty(node, PeopleNames.PEOPLE_FIRST_NAME, PropertyType.STRING,
+// firstNameTxt.getText());
+// ConnectJcrUtils.setJcrProperty(node, PeopleNames.PEOPLE_DISPLAY_NAME, PropertyType.STRING,
+// firstNameTxt.getText() + " " + lastNameTxt.getText());
+// String email = emailTxt.getText();
+// ConnectJcrUtils.setJcrProperty(node, PeopleNames.PEOPLE_PRIMARY_EMAIL, PropertyType.STRING, email);
+// PeopleJcrUtils.createEmail(resourcesService, peopleService, node, email, true, null, null);
+// }
+}
--- /dev/null
+package org.argeo.suite.ui.dialogs;
+
+import static org.argeo.eclipse.ui.EclipseUiUtils.isEmpty;
+
+import javax.jcr.Node;
+
+import org.argeo.eclipse.ui.EclipseUiUtils;
+import org.argeo.suite.ui.SuiteMsg;
+import org.argeo.suite.ui.SuiteUiUtils;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+/** Ask first & last name. Update the passed node on finish */
+public class NewPersonWizard extends Wizard {
+ // private final static Log log = LogFactory.getLog(NewPersonWizard.class);
+
+ // Context
+ private Node person;
+
+ // This page widgets
+ protected Text lastNameTxt;
+ protected Text firstNameTxt;
+ // private Button useDistinctDisplayNameBtn;
+ // private Text displayNameTxt;
+
+ public NewPersonWizard(Node person) {
+ this.person = person;
+ }
+
+ @Override
+ public void addPages() {
+ try {
+ MainInfoPage page = new MainInfoPage("Main page");
+ addPage(page);
+ } catch (Exception e) {
+ throw new RuntimeException("Cannot add page to wizard", e);
+ }
+ setWindowTitle(SuiteMsg.personWizardWindowTitle.lead());
+ }
+
+ /**
+ * Called when the user click on 'Finish' in the wizard. The task is then
+ * created and the corresponding session saved.
+ */
+ @Override
+ public boolean performFinish() {
+ String lastName = lastNameTxt.getText();
+ String firstName = firstNameTxt.getText();
+ // String displayName = displayNameTxt.getText();
+ // boolean useDistinct = useDistinctDisplayNameBtn.getSelection();
+ if (EclipseUiUtils.isEmpty(lastName) && EclipseUiUtils.isEmpty(firstName)) {
+ MessageDialog.openError(getShell(), "Non-valid information",
+ "Please enter at least a name that is not empty.");
+ return false;
+ } else {
+// ConnectJcrUtils.setJcrProperty(person, PEOPLE_LAST_NAME, PropertyType.STRING, lastName);
+// ConnectJcrUtils.setJcrProperty(person, PEOPLE_FIRST_NAME, PropertyType.STRING, firstName);
+// String fullName = firstName + " " + lastName;
+// ConnectJcrUtils.setJcrProperty(person, PEOPLE_DISPLAY_NAME, PropertyType.STRING, fullName);
+ return true;
+ }
+ }
+
+ @Override
+ public boolean performCancel() {
+ return true;
+ }
+
+ @Override
+ public boolean canFinish() {
+ String lastName = lastNameTxt.getText();
+ String firstName = firstNameTxt.getText();
+ if (isEmpty(lastName) && isEmpty(firstName)) {
+ return false;
+ } else
+ return true;
+ }
+
+ protected class MainInfoPage extends WizardPage {
+ private static final long serialVersionUID = 1L;
+
+ public MainInfoPage(String pageName) {
+ super(pageName);
+ setTitle(SuiteMsg.personWizardPageTitle.lead());
+ // setMessage("Please enter a last name and/or a first name.");
+ }
+
+ public void createControl(Composite parent) {
+ parent.setLayout(new GridLayout(2, false));
+
+ // FirstName
+ SuiteUiUtils.createBoldLabel(parent, SuiteMsg.firstName);
+ firstNameTxt = new Text(parent, SWT.BORDER);
+ // firstNameTxt.setMessage("a first name");
+ firstNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ // LastName
+ SuiteUiUtils.createBoldLabel(parent, SuiteMsg.lastName);
+ lastNameTxt = new Text(parent, SWT.BORDER);
+ // lastNameTxt.setMessage("a last name");
+ lastNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ // Display Name
+ // useDistinctDisplayNameBtn = new Button(parent, SWT.CHECK);
+ // useDistinctDisplayNameBtn.setText("Define a disting display name");
+ // useDistinctDisplayNameBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
+ // true, false, 2, 1));
+ //
+ // ConnectWorkbenchUtils.createBoldLabel(parent, "Display Name");
+ // displayNameTxt = new Text(parent, SWT.BORDER);
+ // displayNameTxt.setMessage("an optional display name");
+ // displayNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
+ // false));
+ // displayNameTxt.setEnabled(false);
+ //
+ // useDistinctDisplayNameBtn.addSelectionListener(new SelectionAdapter() {
+ // private static final long serialVersionUID = 1L;
+ //
+ // @Override
+ // public void widgetSelected(SelectionEvent e) {
+ // displayNameTxt.setEnabled(useDistinctDisplayNameBtn.getSelection());
+ // }
+ // });
+
+ ModifyListener ml = new ModifyListener() {
+ private static final long serialVersionUID = -1628130380128946886L;
+
+ @Override
+ public void modifyText(ModifyEvent event) {
+ getContainer().updateButtons();
+ }
+ };
+
+ firstNameTxt.addModifyListener(ml);
+ lastNameTxt.addModifyListener(ml);
+ // displayNameTxt.addModifyListener(ml);
+
+ // Don't forget this.
+ setControl(firstNameTxt);
+ firstNameTxt.setFocus();
+ }
+ }
+}
--- /dev/null
+package org.argeo.suite.ui.dialogs;
+
+import static org.argeo.eclipse.ui.EclipseUiUtils.isEmpty;
+
+import javax.jcr.Node;
+
+import org.argeo.eclipse.ui.EclipseUiUtils;
+import org.argeo.suite.ui.SuiteMsg;
+import org.argeo.suite.ui.SuiteUiUtils;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+/** Ask first & last name. Update the passed node on finish */
+public class NewUserWizard extends Wizard {
+ // private final static Log log = LogFactory.getLog(NewPersonWizard.class);
+
+ // Context
+ private Node person;
+
+ // This page widgets
+ protected Text lastNameTxt;
+ protected Text firstNameTxt;
+ // private Button useDistinctDisplayNameBtn;
+ // private Text displayNameTxt;
+
+ public NewUserWizard(Node person) {
+ this.person = person;
+ }
+
+ @Override
+ public void addPages() {
+ try {
+ MainInfoPage page = new MainInfoPage("Main page");
+ addPage(page);
+ } catch (Exception e) {
+ throw new RuntimeException("Cannot add page to wizard", e);
+ }
+ setWindowTitle(SuiteMsg.personWizardWindowTitle.lead());
+ }
+
+ /**
+ * Called when the user click on 'Finish' in the wizard. The task is then
+ * created and the corresponding session saved.
+ */
+ @Override
+ public boolean performFinish() {
+ String lastName = lastNameTxt.getText();
+ String firstName = firstNameTxt.getText();
+ // String displayName = displayNameTxt.getText();
+ // boolean useDistinct = useDistinctDisplayNameBtn.getSelection();
+ if (EclipseUiUtils.isEmpty(lastName) && EclipseUiUtils.isEmpty(firstName)) {
+ MessageDialog.openError(getShell(), "Non-valid information",
+ "Please enter at least a name that is not empty.");
+ return false;
+ } else {
+// ConnectJcrUtils.setJcrProperty(person, PEOPLE_LAST_NAME, PropertyType.STRING, lastName);
+// ConnectJcrUtils.setJcrProperty(person, PEOPLE_FIRST_NAME, PropertyType.STRING, firstName);
+// String fullName = firstName + " " + lastName;
+// ConnectJcrUtils.setJcrProperty(person, PEOPLE_DISPLAY_NAME, PropertyType.STRING, fullName);
+ return true;
+ }
+ }
+
+ @Override
+ public boolean performCancel() {
+ return true;
+ }
+
+ @Override
+ public boolean canFinish() {
+ String lastName = lastNameTxt.getText();
+ String firstName = firstNameTxt.getText();
+ if (isEmpty(lastName) && isEmpty(firstName)) {
+ return false;
+ } else
+ return true;
+ }
+
+ protected class MainInfoPage extends WizardPage {
+ private static final long serialVersionUID = 1L;
+
+ public MainInfoPage(String pageName) {
+ super(pageName);
+ setTitle(SuiteMsg.personWizardPageTitle.lead());
+ // setMessage("Please enter a last name and/or a first name.");
+ }
+
+ public void createControl(Composite parent) {
+ parent.setLayout(new GridLayout(2, false));
+
+ // FirstName
+ SuiteUiUtils.createBoldLabel(parent, SuiteMsg.firstName);
+ firstNameTxt = new Text(parent, SWT.BORDER);
+ // firstNameTxt.setMessage("a first name");
+ firstNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ // LastName
+ SuiteUiUtils.createBoldLabel(parent, SuiteMsg.lastName);
+ lastNameTxt = new Text(parent, SWT.BORDER);
+ // lastNameTxt.setMessage("a last name");
+ lastNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ // Display Name
+ // useDistinctDisplayNameBtn = new Button(parent, SWT.CHECK);
+ // useDistinctDisplayNameBtn.setText("Define a disting display name");
+ // useDistinctDisplayNameBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
+ // true, false, 2, 1));
+ //
+ // ConnectWorkbenchUtils.createBoldLabel(parent, "Display Name");
+ // displayNameTxt = new Text(parent, SWT.BORDER);
+ // displayNameTxt.setMessage("an optional display name");
+ // displayNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
+ // false));
+ // displayNameTxt.setEnabled(false);
+ //
+ // useDistinctDisplayNameBtn.addSelectionListener(new SelectionAdapter() {
+ // private static final long serialVersionUID = 1L;
+ //
+ // @Override
+ // public void widgetSelected(SelectionEvent e) {
+ // displayNameTxt.setEnabled(useDistinctDisplayNameBtn.getSelection());
+ // }
+ // });
+
+ ModifyListener ml = new ModifyListener() {
+ private static final long serialVersionUID = -1628130380128946886L;
+
+ @Override
+ public void modifyText(ModifyEvent event) {
+ getContainer().updateButtons();
+ }
+ };
+
+ firstNameTxt.addModifyListener(ml);
+ lastNameTxt.addModifyListener(ml);
+ // displayNameTxt.addModifyListener(ml);
+
+ // Don't forget this.
+ setControl(firstNameTxt);
+ firstNameTxt.setFocus();
+ }
+ }
+}