Java Code Examples for com.smartgwt.client.widgets.form.fields.ButtonItem#addClickHandler()

The following examples show how to use com.smartgwt.client.widgets.form.fields.ButtonItem#addClickHandler() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoginLayout.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
private ButtonItem createLoginButton() {
    ButtonItem loginButton = new ButtonItem();
    loginButton.setTitle(i18n.login());
    loginButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (LoginLayout.this.form.validate(false)) {
                login();
            }
        }
    });
    return loginButton;
}
 
Example 2
Source File: WorkflowDialog.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public WorkflowDialog(final long[] ids) {
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("startworkflow"));
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	setAutoSize(true);
	centerInPage();

	workflow = ItemFactory.newWorkflowSelector();
	workflow.setTitle(I18N.message("chooseworkflow"));
	workflow.setWrapTitle(false);
	workflow.setRequired(true);

	tag = ItemFactory.newTextItem("tag", I18N.message("tag"), null);
	tag.setWrapTitle(false);
	tag.setRequired(false);

	ButtonItem start = new ButtonItem();
	start.setTitle(I18N.message("startworkflow"));
	start.setAutoFit(true);
	start.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			onStart(ids);
		}
	});

	form.setTitleOrientation(TitleOrientation.TOP);
	form.setFields(workflow, tag, start);
	addItem(form);
}
 
Example 3
Source File: SendToArchiveDialog.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Constructor
 * 
 * @param ids Identifiers of the elements that have to be archived
 * @param document True if the ids refers to documents, False in case of
 *        folders
 */
public SendToArchiveDialog(final long[] ids, final boolean document) {
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);

	setTitle(I18N.message("sendtoexparchive"));
	setWidth(380);
	setHeight(100);
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();

	SelectItem archive = ItemFactory.newArchiveSelector(GUIArchive.MODE_EXPORT, GUIArchive.STATUS_OPENED);
	archive.setTitle(I18N.message("selectopenarchive"));
	archive.setWrapTitle(false);
	archive.setRequired(true);

	ButtonItem send = new ButtonItem();
	send.setStartRow(false);
	send.setTitle(I18N.message("sendtoexparchive"));
	send.setAutoFit(true);
	send.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			onSend(ids, document);
		}
	});

	form.setFields(archive, send);
	addItem(form);
}
 
Example 4
Source File: WorkflowNoteEditor.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public WorkflowNoteEditor(TaskDetailsDialog parentDialog) {
	super();
	this.parentDialog = parentDialog;

	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("note"));
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setAutoSize(true);

	message = new RichTextItem("message");
	message.setTitle(I18N.message("message"));
	message.setShowTitle(false);
	message.setRequired(true);
	message.setWidth(680);
	message.setHeight(230);

	save = new ButtonItem();
	save.setTitle(I18N.message("save"));
	save.setAutoFit(true);
	save.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			onSave();
		}
	});

	noteForm.setItems(message, save);
	addItem(noteForm);
}
 
Example 5
Source File: RegisterLayout.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
private ButtonItem createRegisterButton() {
    ButtonItem registerButton = new ButtonItem();
    registerButton.setTitle(i18n.register());
    registerButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            RegisterLayout.this.register();
        }
    });
    return registerButton;
}
 
Example 6
Source File: NoteUpdateDialog.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public NoteUpdateDialog(final long docId, final long noteId, String noteMessage, final NotesPanel notesPanel) {
	super();
	this.notesPanel = notesPanel;
	this.noteId = noteId;
	this.docId = docId;

	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("note"));
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setAutoSize(true);

	message = new RichTextItem("name");
	message.setTitle(I18N.message("message"));
	message.setShowTitle(false);
	message.setRequired(true);
	message.setWidth("*");
	message.setHeight("*");
	message.setValue(noteMessage);

	save = new ButtonItem();
	save.setTitle(I18N.message("save"));
	save.setAutoFit(true);
	save.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			onSave();
		}
	});

	noteForm.setItems(message, save);
	addItem(noteForm);
}
 
Example 7
Source File: AddForm.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public AddForm() {
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);

	setTitle(I18N.message("addform"));
	setAutoSize(true);
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();

	formSelector = ItemFactory.newFormSelector();
	formSelector.setWrapTitle(false);
	formSelector.setRequired(true);

	TextItem title = ItemFactory.newTextItem("title", "title", null);
	title.setRequired(true);

	ButtonItem save = new ButtonItem();
	save.setTitle(I18N.message("save"));
	save.setAutoFit(true);
	save.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			onSave();
		}
	});

	form.setNumCols(2);
	form.setTitleOrientation(TitleOrientation.TOP);
	form.setFields(title, formSelector, save);
	addItem(form);
}
 
Example 8
Source File: StampDialog.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public StampDialog(final DocumentsGrid sourceGrid) {
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("applystamp"));
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	setAutoSize(true);
	centerInPage();

	stamp = ItemFactory.newStampSelector();
	stamp.setTitle(I18N.message("choosestamp"));
	stamp.setWrapTitle(false);
	stamp.setRequired(true);

	visualPositioning = new CheckboxItem();
	visualPositioning.setName("visualpositioning");
	visualPositioning.setTitle(I18N.message("visualpositioning"));

	ButtonItem apply = new ButtonItem();
	apply.setTitle(I18N.message("apply"));
	apply.setAutoFit(true);
	apply.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			onApply(sourceGrid);
		}
	});

	form.setTitleOrientation(TitleOrientation.TOP);
	form.setFields(stamp, visualPositioning, apply);

	addItem(form);
}
 
Example 9
Source File: SetAdminPassword.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public SetAdminPassword(final String tenantName) {
	super();

	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("changepassword"));
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setAutoSize(true);

	final ValuesManager vm = new ValuesManager();
	final DynamicForm form = new DynamicForm();
	form.setValuesManager(vm);

	MatchesFieldValidator equalsValidator = new MatchesFieldValidator();
	equalsValidator.setOtherField(NEWPASSWORDAGAIN);
	equalsValidator.setErrorMessage(I18N.message("passwordnotmatch"));

	LengthRangeValidator sizeValidator = new LengthRangeValidator();
	sizeValidator.setErrorMessage(I18N.message("errorfieldminlenght",
			Integer.toString(Session.get().getUser().getPasswordMinLenght())));
	sizeValidator.setMin(Session.get().getUser().getPasswordMinLenght());

	PasswordItem newPass = new PasswordItem();
	newPass.setName(NEWPASSWORD);
	newPass.setTitle(I18N.message(NEWPASSWORD));
	newPass.setRequired(true);
	newPass.setValidators(equalsValidator, sizeValidator);

	PasswordItem newPassAgain = new PasswordItem();
	newPassAgain.setName(NEWPASSWORDAGAIN);
	newPassAgain.setTitle(I18N.message(NEWPASSWORDAGAIN));
	newPassAgain.setWrapTitle(false);
	newPassAgain.setRequired(true);

	final ButtonItem apply = new ButtonItem();
	apply.setTitle(I18N.message("apply"));
	apply.setAutoFit(true);
	apply.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			vm.validate();
			if (!vm.hasErrors()) {
				apply.setDisabled(true);
				TenantService.Instance.get().changeAdminPassword(vm.getValueAsString(NEWPASSWORD).trim(),
						tenantName, new AsyncCallback<Void>() {

							@Override
							public void onFailure(Throwable caught) {
								SC.warn(caught.getMessage());
								apply.setDisabled(false);
							}

							@Override
							public void onSuccess(Void arg) {
								apply.setDisabled(false);
								SetAdminPassword.this.destroy();
								Log.info(I18N.message("event.user.passwordchanged"), null);
							}
						});
			}
		}
	});

	form.setFields(newPass, newPassAgain, apply);
	addItem(form);
}
 
Example 10
Source File: ResetPassword.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ResetPassword(String product) {
	this.productName = product;
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("passwordreset"));
	setWidth(340);
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setPadding(5);
	setAutoSize(true);
	setMargin(5);

	DynamicForm form = new DynamicForm();
	form.setMargin(5);
	form.setValuesManager(vm);
	TextItem username = ItemFactory.newTextItem("username", "username", "");
	username.setRequired(true);
	TextItem email = ItemFactory.newEmailItem("email", "email", false);
	email.setRequired(true);
	form.setFields(username, email);
	addItem(form);

	Label pwdResetMsg = new Label(I18N.message("passwordresetmessage"));
	pwdResetMsg.setWidth100();
	pwdResetMsg.setMargin(5);
	addItem(pwdResetMsg);

	final DynamicForm buttonForm = new DynamicForm();
	buttonForm.setMargin(5);
	ButtonItem resetButton = new ButtonItem("reset", I18N.message("reset"));
	resetButton.setAutoFit(true);
	resetButton.addClickHandler(new ClickHandler() {
		@SuppressWarnings("unchecked")
		public void onClick(ClickEvent event) {
			Map<String, Object> values = (Map<String, Object>) vm.getValues();

			if (vm.validate()) {
				final String userName = (String) values.get("username");
				final String emailAddress = (String) values.get("email");
				buttonForm.setDisabled(true);
				loginService.resetPassword(userName, emailAddress, productName, new AsyncCallback<Void>() {

					@Override
					public void onFailure(Throwable caught) {
						Log.serverError(caught);
						buttonForm.setDisabled(false);
					}

					@Override
					public void onSuccess(Void result) {
						buttonForm.setDisabled(false);
						SC.say(I18N.message("amessagewassentto", emailAddress));
						destroy();
					}
				});
			}
		}
	});
	buttonForm.setItems(resetButton);
	addItem(buttonForm);
}
 
Example 11
Source File: ConversionDialog.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ConversionDialog(GUIDocument document) {
	this.document = document;
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);

	setTitle(I18N.message("convert") + " - " + document.getFileName());
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setAutoSize(true);

	final RadioGroupItem action = ItemFactory.newRadioGroup("action", I18N.message("action"));
	action.setRequired(true);
	action.setEndRow(true);

	final SelectItem format = ItemFactory.newConversionFormatItem(document.getFileName());
	format.setEndRow(true);
	format.setRequired(true);

	final ButtonItem convert = new ButtonItem();
	convert.setStartRow(false);
	convert.setTitle(I18N.message("convert"));
	convert.setAutoFit(true);
	convert.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			onConvert();
		}
	});

	FolderService.Instance.get().getFolder(document.getFolder().getId(), false, false, false, 
			new AsyncCallback<GUIFolder>() {

				@Override
				public void onFailure(Throwable caught) {
					Log.serverError(caught);
				}

				@Override
				public void onSuccess(GUIFolder folder) {
					convert.setDisabled(!folder.isDownload() && !folder.isWrite());

					LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
					if (folder.isDownload())
						map.put("download", I18N.message("download"));
					if (folder.isWrite())
						map.put("save", I18N.message("save"));
					action.setValueMap(map);
					action.setValue("download");

					form.setFields(format, action, convert);
					addItem(form);
				}
			});
}
 
Example 12
Source File: Registration.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Registration(String[] reg) {
	super();

	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("registration"));
	setWidth(350);
	setHeight(150);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setAutoSize(true);

	final DynamicForm form = new DynamicForm();
	form.setValuesManager(vm);
	form.setMargin(5);
	form.setNumCols(2);
	form.setTitleOrientation(TitleOrientation.TOP);

	TextItem regName = ItemFactory.newTextItem("reg_name", "name", null);
	regName.setWrapTitle(false);
	regName.setValue(reg[0]);

	TextItem regEmail = ItemFactory.newEmailItem("reg_email", "email", false);
	regEmail.setWrapTitle(false);
	regEmail.setValue(reg[1]);

	TextItem regOrganization = ItemFactory.newTextItem("reg_organization", "organization", null);
	regOrganization.setWrapTitle(false);
	regOrganization.setValue(reg[2]);

	TextItem regWebsite = ItemFactory.newTextItem("reg_website", "website", null);
	regWebsite.setWidth(180);
	regWebsite.setWrapTitle(false);
	regWebsite.setValue(reg[3]);

	ButtonItem apply = new ButtonItem();
	apply.setTitle(I18N.message("apply"));
	apply.setAutoFit(true);
	apply.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			vm.validate();
			if (!vm.hasErrors()) {
				SettingService.Instance.get().saveRegistration(form.getValueAsString("reg_name"),
						form.getValueAsString("reg_email"), form.getValueAsString("reg_organization"),
						form.getValueAsString("reg_website"), new AsyncCallback<Void>() {
							@Override
							public void onFailure(Throwable caught) {
								SC.warn(caught.getMessage());
							}

							@Override
							public void onSuccess(Void ret) {
								afterSave();
								Registration.this.destroy();
							}
						});
			}
		}
	});

	form.setFields(regName, regEmail, regOrganization, regWebsite, apply);

	addItem(form);
}
 
Example 13
Source File: SetPassword.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public SetPassword(final long userId) {
	super();

	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("changepassword"));
	setWidth(300);
	setHeight(140);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setAutoSize(true);

	final ValuesManager vm = new ValuesManager();
	final DynamicForm form = new DynamicForm();
	form.setValuesManager(vm);
	form.setWidth(350);

	MatchesFieldValidator equalsValidator = new MatchesFieldValidator();
	equalsValidator.setOtherField(NEWPASSWORDAGAIN);
	equalsValidator.setErrorMessage(I18N.message("passwordnotmatch"));

	LengthRangeValidator sizeValidator = new LengthRangeValidator();
	sizeValidator.setErrorMessage(
			I18N.message("errorfieldminlenght", Integer.toString(Session.get().getUser().getPasswordMinLenght())));
	sizeValidator.setMin(Session.get().getUser().getPasswordMinLenght());

	PasswordItem newPass = new PasswordItem();
	newPass.setName(NEWPASSWORD);
	newPass.setTitle(I18N.message(NEWPASSWORD));
	newPass.setRequired(true);
	newPass.setAutoComplete(AutoComplete.NONE);
	newPass.setValidators(equalsValidator, sizeValidator);

	PasswordItem newPassAgain = new PasswordItem();
	newPassAgain.setName(NEWPASSWORDAGAIN);
	newPassAgain.setTitle(I18N.message(NEWPASSWORDAGAIN));
	newPassAgain.setAutoComplete(AutoComplete.NONE);
	newPassAgain.setWrapTitle(false);
	newPassAgain.setRequired(true);

	final CheckboxItem notify = ItemFactory.newCheckbox(NOTIFY, "notifycredentials");
	notify.setValue(false);

	final ButtonItem apply = new ButtonItem();
	apply.setTitle(I18N.message("apply"));
	apply.setAutoFit(true);
	apply.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			vm.validate();
			if (!vm.hasErrors()) {
				apply.setDisabled(true);
				SecurityService.Instance.get().changePassword(Session.get().getUser().getId(), userId, null,
						vm.getValueAsString(NEWPASSWORD), notify.getValueAsBoolean(), new AsyncCallback<Integer>() {

							@Override
							public void onFailure(Throwable caught) {
								SC.warn(caught.getMessage());
								apply.setDisabled(false);
							}

							@Override
							public void onSuccess(Integer ret) {
								apply.setDisabled(false);
								if (ret.intValue() > 0) {
									// Alert the user and maintain the popup
									// opened
									if (ret == 1)
										Log.warn(I18N.message("wrongpassword"), null);
									else if (ret == 2)
										Log.warn(I18N.message("passwdnotnotified"), null);
									else
										Log.warn(I18N.message("genericerror"), null);
								}
								SetPassword.this.destroy();
							}
						});
			}
		}
	});

	form.setFields(newPass, newPassAgain, notify, apply);

	addItem(form);
}
 
Example 14
Source File: ZohoSettings.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ZohoSettings() {
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("zoho"));
	setAutoSize(true);
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setPadding(2);

	form.setTitleOrientation(TitleOrientation.TOP);

	final TextItem authToken = ItemFactory.newTextItem("authtoken", "authtoken", null);
	authToken.setWidth(370);
	authToken.setRequired(true);
	authToken.setEndRow(true);

	ButtonItem save = new ButtonItem("save", I18N.message("save"));
	save.setAutoFit(true);

	save.addClickHandler(new ClickHandler() {

		@Override
		public void onClick(ClickEvent event) {
			onAuthenticate();
		}
	});

	form.setFields(authToken, save);

	addItem(form);

	ZohoService.Instance.get().loadAuthToken(new AsyncCallback<String>() {

		@Override
		public void onFailure(Throwable caught) {
			Log.serverError(caught);
		}

		@Override
		public void onSuccess(String setting) {
			authToken.setValue(setting);
		}
	});
}
 
Example 15
Source File: FolderExtendedPropertiesPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public FolderExtendedPropertiesPanel(GUIFolder folder, ChangedHandler changedHandler,
		ChangedHandler templateChangedHandler) {
	super(folder, changedHandler);
	setWidth100();
	setHeight100();
	setMembersMargin(1);

	RadioGroupItem locked = ItemFactory.newBooleanSelector("locked", "templatelocked");
	locked.setValue(folder.getTemplateLocked() == 1 ? "yes" : "no");
	locked.addChangedHandler(changedHandler);
	locked.setEndRow(true);

	ButtonItem applyMetadata = new ButtonItem(I18N.message("applytosubfolders"));
	applyMetadata.setAutoFit(true);
	applyMetadata.setEndRow(true);
	applyMetadata.setDisabled(!folder.isWrite());
	applyMetadata.setColSpan(1);
	applyMetadata.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			ContactingServer.get().show();
			FolderService.Instance.get().applyMetadata(folder.getId(), new AsyncCallback<Void>() {

				@Override
				public void onFailure(Throwable caught) {
					ContactingServer.get().hide();
					Log.serverError(caught);
				}

				@Override
				public void onSuccess(Void v) {
					ContactingServer.get().hide();
				}
			});
		}
	});

	form1 = new DynamicForm();
	form1.setWidth(200);
	form1.setNumCols(1);
	form1.setTitleOrientation(TitleOrientation.TOP);
	form1.setItems(locked, applyMetadata);

	propertiesPanel = new ExtendedPropertiesPanel(folder, changedHandler, templateChangedHandler, folder.isWrite(), false, true);
	setMembers(form1, propertiesPanel);
}
 
Example 16
Source File: ChangePassword.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ChangePassword() {
	super();

	GUIUser user = Session.get().getUser();

	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("changepassword"));
	setWidth(300);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setAutoSize(true);

	final ValuesManager vm = new ValuesManager();
	final DynamicForm form = new DynamicForm();
	form.setValuesManager(vm);
	form.setWidth(350);
	form.setMargin(5);

	PasswordItem password = new PasswordItem();
	password.setName(PASSWORD);
	password.setTitle(I18N.message(PASSWORD));
	password.setRequired(true);

	MatchesFieldValidator equalsValidator = new MatchesFieldValidator();
	equalsValidator.setOtherField(NEWPASSWORDAGAIN);
	equalsValidator.setErrorMessage(I18N.message("passwordnotmatch"));

	LengthRangeValidator sizeValidator = new LengthRangeValidator();
	sizeValidator
			.setErrorMessage(I18N.message("errorfieldminlenght", Integer.toString(user.getPasswordMinLenght())));
	sizeValidator.setMin(user.getPasswordMinLenght());

	PasswordItem newPass = new PasswordItem();
	newPass.setName(NEWPASSWORD);
	newPass.setTitle(I18N.message(NEWPASSWORD));
	newPass.setRequired(true);
	newPass.setValidators(equalsValidator, sizeValidator);

	PasswordItem newPassAgain = new PasswordItem();
	newPassAgain.setName(NEWPASSWORDAGAIN);
	newPassAgain.setTitle(I18N.message(NEWPASSWORDAGAIN));
	newPassAgain.setWrapTitle(false);
	newPassAgain.setRequired(true);

	final ButtonItem apply = new ButtonItem();
	apply.setTitle(I18N.message("apply"));
	apply.setAutoFit(true);
	apply.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			vm.validate();
			if (!vm.hasErrors()) {
				if (vm.getValueAsString(PASSWORD).equals(vm.getValueAsString(NEWPASSWORD))) {
					Map<String, String> errors = new HashMap<String, String>();
					errors.put(NEWPASSWORD, I18N.message("useanotherpassword"));
					vm.setErrors(errors, true);
					return;
				}

				apply.setDisabled(true);

				SecurityService.Instance.get().changePassword(user.getId(), user.getId(),
						vm.getValueAsString(PASSWORD), vm.getValueAsString(NEWPASSWORD), false,
						new AsyncCallback<Integer>() {

							@Override
							public void onFailure(Throwable caught) {
								apply.setDisabled(false);
								SC.warn(caught.getMessage());
							}

							@Override
							public void onSuccess(Integer ret) {
								apply.setDisabled(false);
								if (ret.intValue() > 0) {
									// Alert the user and maintain the popup
									// opened
									if (ret == 1)
										SC.warn(I18N.message("wrongpassword"));
									else if (ret == 2)
										SC.warn(I18N.message("passwdnotnotified"));
									else
										SC.warn(I18N.message("genericerror"));
								} else {
									SC.say(I18N.message("yourpasswordhaschanged"));
									Log.info(I18N.message("event.user.passwordchanged"), null);
								}

								// Close the popup
								ChangePassword.this.destroy();
							}
						});
			}
		}
	});

	form.setFields(password, newPass, newPassAgain, apply);

	addItem(form);
}
 
Example 17
Source File: StatusDialog.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public StatusDialog(StateWidget widget) {
	this.widget = widget;

	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("editworkflowstate", I18N.message("task")));
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	setMargin(3);
	setAutoSize(true);
	setWidth(400);
	centerInPage();

	form = new DynamicForm();
	form.setTitleOrientation(TitleOrientation.TOP);
	form.setNumCols(1);
	form.setValuesManager(vm);

	TextItem name = ItemFactory.newTextItem("name", "name", widget.getTransition().getText());
	name.setRequired(true);

	ButtonItem save = new ButtonItem("save", I18N.message("save"));
	save.setAutoFit(true);
	save.addClickHandler(new ClickHandler() {
		@SuppressWarnings("unchecked")
		public void onClick(ClickEvent event) {
			Map<String, Object> values = (Map<String, Object>) vm.getValues();

			if (vm.validate()) {
				if (vm.validate()) {
					StatusDialog.this.widget.getWfState().setName((String) values.get("name"));

					StatusDialog.this.widget.setContents("<b>" + (String) values.get("name") + "</b>");
					StatusDialog.this.widget.getDrawingPanel().getDiagramController().update();

					destroy();
				}
			}
		}
	});

	form.setItems(name, save);
	addItem(form);
}
 
Example 18
Source File: GDriveSettings.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public GDriveSettings() {
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("googledrive"));
	setWidth(400);
	setHeight(150);
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setPadding(2);

	form.setTitleOrientation(TitleOrientation.TOP);

	final TextItem clientId = ItemFactory.newTextItem("clientid", "clientid", null);
	clientId.setWidth(370);
	clientId.setRequired(true);
	clientId.setEndRow(true);

	final TextItem clientSecret = ItemFactory.newTextItem("clientsecret", "clientsecret", null);
	clientSecret.setWidth(370);
	clientSecret.setRequired(true);
	clientSecret.setEndRow(true);

	ButtonItem authorize = new ButtonItem("authorize", I18N.message("authorize"));
	authorize.setAutoFit(true);

	authorize.addClickHandler(new ClickHandler() {

		@Override
		public void onClick(ClickEvent event) {
			onAuthenticate();
		}
	});

	form.setFields(clientId, clientSecret, authorize);

	addItem(form);

	GDriveService.Instance.get().loadSettings(new AsyncCallback<String[]>() {

		@Override
		public void onFailure(Throwable caught) {
			Log.serverError(caught);
		}

		@Override
		public void onSuccess(String[] settings) {
			clientId.setValue(settings[0]);
			clientSecret.setValue(settings[1]);
		}
	});
}
 
Example 19
Source File: SaveDialog.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public SaveDialog() {
	super();

	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("savesearch"));
	setWidth(350);
	setHeight(100);
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setPadding(5);
	setAutoSize(true);

	final ValuesManager vm = new ValuesManager();
	final DynamicForm form = new DynamicForm();
	form.setValuesManager(vm);
	form.setWidth(350);
	form.setMargin(5);

	TextItem name = ItemFactory.newTextItem("name", "name", null);
	name.setRequired(true);
	name.setValidators(new SimpleTextValidator());
	name.setWidth(100);

	TextItem description = ItemFactory.newTextItem("description", "description", null);
	description.setWidth(300);

	ButtonItem save = new ButtonItem();
	save.setTitle(I18N.message("save"));
	save.setAutoFit(true);
	save.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			vm.validate();
			if (!vm.hasErrors()) {
				final GUISearchOptions options = Search.get().getOptions();
				options.setName(vm.getValueAsString("name"));
				options.setDescription(vm.getValueAsString("description"));
				SearchService.Instance.get().save(Search.get().getOptions(), new AsyncCallback<Boolean>() {

					@Override
					public void onFailure(Throwable caught) {
						Log.serverError(caught);
					}

					@Override
					public void onSuccess(Boolean b) {
						if (!b)
							SC.warn(I18N.message("duplicateelement"));
						else {
							SavedSearchesPanel.get().addEntry(
									vm.getValueAsString("name"),
									vm.getValueAsString("description"),
									options.getType() == GUISearchOptions.TYPE_FULLTEXT ? I18N.message("fulltext")
											: I18N.message("parametric"));
							destroy();
						}
					}
				});
			}
		}
	});

	form.setFields(name, description, save);
	addItem(form);
}
 
Example 20
Source File: ReplicateUserSettings.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ReplicateUserSettings(List<Long> userIds, final UsersPanel panel) {
	super();

	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("replicatesettings"));
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setAutoSize(true);

	final ValuesManager vm = new ValuesManager();
	final DynamicForm form = new DynamicForm();
	form.setValuesManager(vm);
	form.setWidth(350);

	SelectItem masterUser = ItemFactory.newUserSelector("user", "masteruser", null, true);
	masterUser.setHint(I18N.message("masteruserhint"));

	final CheckboxItem userInterface = ItemFactory.newCheckbox("userinterface", "userinterface");
	userInterface.setValue(true);

	final CheckboxItem groups = ItemFactory.newCheckbox("groups", "groups");
	groups.setValue(false);

	final ButtonItem confirm = new ButtonItem();
	confirm.setTitle(I18N.message("confirm"));
	confirm.setAutoFit(true);
	confirm.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			vm.validate();
			if (!vm.hasErrors()) {
				long masterUserId = Long.parseLong(vm.getValueAsString("user"));
				ContactingServer.get().show();
				SecurityService.Instance.get().replicateUsersSettings(masterUserId, userIds.toArray(new Long[0]),
						userInterface.getValueAsBoolean(), groups.getValueAsBoolean(), new AsyncCallback<Void>() {

							@Override
							public void onFailure(Throwable caught) {
								ContactingServer.get().hide();
								Log.serverError(caught);
							}

							@Override
							public void onSuccess(Void arg0) {
								ContactingServer.get().hide();
								Log.info(I18N.message("userssaved"));
								destroy();
								panel.refresh();
							}
						});
			}
		}
	});

	form.setFields(masterUser, userInterface, groups, confirm);

	addItem(form);
}