-// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
+import eu.etaxonomy.cdm.api.service.IUserService;
import eu.etaxonomy.cdm.model.common.User;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
-import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
+import eu.etaxonomy.taxeditor.l10n.Messages;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
/**
private Button button;
private ConversationHolder conversation;
-
- /**
- * @param formFactory
- * @param formElement
- */
+
public EditPasswordElement(CdmFormFactory formFactory,
ICdmFormElement formElement, String labelString, User user, ConversationHolder conversation) {
super(formFactory, formElement);
-
+
this.conversation = conversation;
this.user = user;
-
+
Label label = formFactory.createLabel(getLayoutComposite(), null);
addControl(label);
-
- String buttonLabelString = (labelString != null) ? labelString : "Change Password";
-
+
+ String buttonLabelString = (labelString != null) ? labelString : Messages.PasswordWizardPage_CHANGE_PASSWORD;
+
button = formFactory.createButton(getLayoutComposite(), buttonLabelString, SWT.PUSH);
button.setLayoutData(LayoutConstants.RIGHT());
addControl(button);
-
+
button.addSelectionListener(this);
}
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
@Override
public void widgetSelected(SelectionEvent e) {
- PasswordWizard wizard = new PasswordWizard(conversation, user);
- WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);
-
- dialog.open();
+ if(!CdmStore.getService(IUserService.class).userExists(user.getUsername())) {
+ MessagingUtils.warningDialog(Messages.EditPasswordElement_USERNAME_DOES_NOT_EXIST, this, String.format(Messages.EditPasswordElement_PLEASE_CREATE_OR_SAVE_USER, user.getUsername()));
+ } else {
+ PasswordWizard wizard = new PasswordWizard(user, conversation);
+ WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);
+ dialog.open();
+ }
}
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
- */
@Override
public void widgetDefaultSelected(SelectionEvent e) {}
- /* (non-Javadoc)
- * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
- */
@Override
public void update(CdmDataChangeMap arg0) {}
- /* (non-Javadoc)
- * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
- */
@Override
public ConversationHolder getConversationHolder() {
return conversation;