List of usage examples for com.vaadin.ui Button addListener
@Override
public Registration addListener(Component.Listener listener)
From source file:org.activiti.explorer.ui.management.processdefinition.SuspendedProcessDefinitionDetailPanel.java
License:Apache License
protected void initActions(final AbstractPage parentPage) { SuspendedProcessDefinitionPage processDefinitionPage = (SuspendedProcessDefinitionPage) parentPage; Button activateButton = new Button(i18nManager.getMessage(Messages.PROCESS_ACTIVATE)); activateButton.addListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { ChangeProcessSuspensionStatePopupWindow popupWindow = new ChangeProcessSuspensionStatePopupWindow( processDefinition.getId(), parentPage, false); ExplorerApp.get().getViewManager().showPopupWindow(popupWindow); }//ww w . j av a 2 s .c om }); // Check if already activation job pending boolean activateJobPending = false; List<Job> jobs = ProcessEngines.getDefaultProcessEngine().getManagementService().createJobQuery() .processDefinitionId(processDefinition.getId()).list(); for (Job job : jobs) { // TODO: this is a hack. Needs to be cleaner in engine! if (((JobEntity) job).getJobHandlerType().equals(TimerActivateProcessDefinitionHandler.TYPE)) { activateJobPending = true; break; } } activateButton.setEnabled(!activateJobPending); // Clear toolbar and add 'start' button processDefinitionPage.getToolBar().removeAllButtons(); processDefinitionPage.getToolBar().addButton(activateButton); }
From source file:org.activiti.explorer.ui.process.simple.editor.FormPopupWindow.java
License:Apache License
protected void initUi() { VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true);// w w w.ja va 2 s .c o m addComponent(layout); // Description layout.addComponent(new Label(DESCRIPTION)); // Property table propertyTable = new PropertyTable(); layout.addComponent(propertyTable); fillFormFields(); // Buttons HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); // Save button Button saveButton = new Button(ExplorerApp.get().getI18nManager().getMessage(Messages.BUTTON_SAVE)); buttons.addComponent(saveButton); saveButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = -2906886872414089331L; public void buttonClick(ClickEvent event) { FormDefinition form = createForm(); formModel.addForm(taskItemId, form); close(); } }); // Delete button Button deleteButton = new Button(ExplorerApp.get().getI18nManager().getMessage(Messages.BUTTON_DELETE)); buttons.addComponent(deleteButton); deleteButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = 5267967369680365653L; public void buttonClick(ClickEvent event) { formModel.removeForm(taskItemId); close(); } }); layout.addComponent(new Label("")); layout.addComponent(buttons); }
From source file:org.activiti.explorer.ui.process.simple.editor.SimpleTableEditor.java
License:Apache License
protected void initButtons(GridLayout layout) { final Button saveButton = new Button( ExplorerApp.get().getI18nManager().getMessage(Messages.PROCESS_EDITOR_SAVE)); saveButton.setEnabled(nameField.getValue() != null && !"".equals((String) nameField.getValue())); toolBar.addButton(saveButton);/*from w w w . j a v a 2 s. c o m*/ saveButton.addListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { save(); } }); // Dependending on namefield value, save button is enabled nameField.addListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { if (nameField.getValue() != null && !"".equals((String) nameField.getValue())) { saveButton.setEnabled(true); } else { saveButton.setEnabled(false); } } }); }
From source file:org.activiti.explorer.ui.process.simple.editor.table.PropertyTable.java
License:Apache License
protected void addPropertyRow(Object itemId, String propertyName, String propertyType, Boolean required) { Object newItemId = null;//w ww. ja v a 2 s . co m if (itemId == null) { // add at the end of list newItemId = addItem(); } else { newItemId = addItemAfter(itemId); } Item newItem = getItem(newItemId); // name newItem.getItemProperty(ID_PROPERTY_NAME) .setValue(propertyName == null ? DEFAULT_PROPERTY_NAME : propertyName); // type ComboBox typeComboBox = new ComboBox("", Arrays.asList("text", "number", "date")); typeComboBox.setNullSelectionAllowed(false); if (propertyType == null) { typeComboBox.setValue(typeComboBox.getItemIds().iterator().next()); } else { typeComboBox.setValue(propertyType); } newItem.getItemProperty(ID_PROPERTY_TYPE).setValue(typeComboBox); // required CheckBox requiredCheckBox = new CheckBox(); requiredCheckBox.setValue(required == null ? false : required); newItem.getItemProperty(ID_PROPERTY_REQUIRED).setValue(requiredCheckBox); // actions HorizontalLayout actionButtons = new HorizontalLayout(); Button deleteRowButton = new Button("-"); deleteRowButton.setData(newItemId); deleteRowButton.addListener(new DeletePropertyClickListener(this)); actionButtons.addComponent(deleteRowButton); Button addRowButton = new Button("+"); addRowButton.setData(newItemId); addRowButton.addListener(new AddPropertyClickListener(this)); actionButtons.addComponent(addRowButton); newItem.getItemProperty(ID_PROPERTY_ACTIONS).setValue(actionButtons); }
From source file:org.activiti.explorer.ui.process.simple.editor.table.TaskTable.java
License:Apache License
protected HorizontalLayout generateActionButtons(Object taskItemId) { HorizontalLayout actionButtons = new HorizontalLayout(); FormDefinition form = taskFormModel.getForm(taskItemId); Button formButton = new Button( form == null ? i18nManager.getMessage(Messages.PROCESS_EDITOR_TASK_FORM_CREATE) : i18nManager.getMessage(Messages.PROCESS_EDITOR_TASK_FORM_EDIT)); formButton.addListener(new ShowFormClickListener(taskFormModel, taskItemId)); formButton.setData(taskItemId);// ww w . java 2 s. c o m actionButtons.addComponent(formButton); Button deleteTaskButton = new Button("-"); deleteTaskButton.setData(taskItemId); deleteTaskButton.addListener(new DeleteTaskClickListener(this)); actionButtons.addComponent(deleteTaskButton); Button addTaskButton = new Button("+"); addTaskButton.setData(taskItemId); addTaskButton.addListener(new AddTaskClickListener(this)); actionButtons.addComponent(addTaskButton); return actionButtons; }
From source file:org.activiti.explorer.ui.profile.ProfilePanel.java
License:Apache License
protected Button initEditProfileButton() { Button editProfileButton = new Button(i18nManager.getMessage(Messages.PROFILE_EDIT)); editProfileButton.setIcon(Images.EDIT); editProfileButton.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { editable = true;/*from w w w.jav a2s. co m*/ initUi(); } }); return editProfileButton; }
From source file:org.activiti.explorer.ui.profile.ProfilePanel.java
License:Apache License
protected Button initSaveProfileButton() { Button saveProfileButton = new Button(i18nManager.getMessage(Messages.PROFILE_SAVE)); saveProfileButton.setIcon(Images.SAVE); saveProfileButton.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { user.setFirstName((String) firstNameField.getValue()); user.setLastName((String) lastNameField.getValue()); user.setEmail((String) emailField.getValue()); identityService.saveUser(user); identityService.setUserInfo(user.getId(), Constants.USER_INFO_JOB_TITLE, jobTitleField.getValue().toString()); if (birthDateField.getValue() != null && !"".equals(birthDateField.getValue().toString())) { identityService.setUserInfo(user.getId(), Constants.USER_INFO_BIRTH_DATE, new SimpleDateFormat(Constants.DEFAULT_DATE_FORMAT).format(birthDateField.getValue())); }//from w ww . ja v a 2 s. c o m identityService.setUserInfo(user.getId(), Constants.USER_INFO_LOCATION, locationField.getValue().toString()); identityService.setUserInfo(user.getId(), Constants.USER_INFO_PHONE, phoneField.getValue().toString()); identityService.setUserInfo(user.getId(), Constants.USER_INFO_TWITTER, twitterField.getValue().toString()); identityService.setUserInfo(user.getId(), Constants.USER_INFO_SKYPE, skypeField.getValue().toString()); // UI editable = false; loadProfileData(); initUi(); } }); return saveProfileButton; }
From source file:org.activiti.explorer.ui.reports.ReportDetailPanel.java
License:Apache License
protected void initActions() { final Button saveButton = new Button(i18nManager.getMessage(Messages.BUTTON_SAVE)); saveButton.addListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { SaveReportPopupWindow saveReportPopupWindow = new SaveReportPopupWindow(); saveReportPopupWindow.setProcessDefinitionId(processDefinition.getId()); saveReportPopupWindow.setOriginalFormProperties(savedFormProperties); saveReportPopupWindow.setComponentToDisableOnClose(saveButton); ExplorerApp.get().getViewManager().showPopupWindow(saveReportPopupWindow); }//from w w w. j av a 2 s .c o m }); // Clear toolbar and add 'start' button parentPage.getToolBar().removeAllButtons(); parentPage.getToolBar().addButton(saveButton); }
From source file:org.activiti.explorer.ui.reports.SaveReportPopupWindow.java
License:Apache License
protected void createSaveButton(final I18nManager i18nManager, final VerticalLayout layout) { layout.addComponent(new Label(" ", Label.CONTENT_XHTML)); Button saveButton = new Button(i18nManager.getMessage(Messages.BUTTON_SAVE)); layout.addComponent(saveButton);/* www .j a v a 2s . c o m*/ layout.setComponentAlignment(saveButton, Alignment.MIDDLE_CENTER); saveButton.addListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { String reportName = null; // Validate String error = null; if (nameField.getValue() == null || ((String) nameField.getValue()).length() == 0) { error = i18nManager.getMessage(Messages.REPORTING_SAVE_POPUP_NAME_EMPTY); } else { reportName = ExplorerApp.get().getLoggedInUser().getId() + "_" + nameField.getValue(); if (reportName.length() > 255) { error = i18nManager.getMessage(Messages.REPORTING_SAVE_POPUP_NAME_TOO_LONG); } else { boolean nameUsed = ProcessEngines.getDefaultProcessEngine().getHistoryService() .createHistoricProcessInstanceQuery().processInstanceBusinessKey(reportName) .count() != 0; if (nameUsed) { error = i18nManager.getMessage(Messages.REPORTING_SAVE_POPUP_NAME_EXISTS); } } } if (error != null) { setHeight(185, UNITS_PIXELS); layout.addComponent(new Label(" ", Label.CONTENT_XHTML)); Label errorLabel = new Label(error); errorLabel.addStyleName(ExplorerLayout.STYLE_ERROR); layout.addComponent(errorLabel); } else { // Re-run reports to store the data for good now (the previous process instance was deleted) if (originalFormProperties != null) { startProcessInstanceWithFormProperties(reportName); } else { startProcessInstance(reportName); } // Remove the popup if (componentToDisableOnClose != null) { componentToDisableOnClose.setEnabled(false); } close(); } } }); }
From source file:org.activiti.explorer.ui.task.DescriptionComponent.java
License:Apache License
protected void initLayoutClickListener() { addListener(new LayoutClickListener() { public void layoutClick(LayoutClickEvent event) { if (event.getClickedComponent() != null && event.getClickedComponent().equals(descriptionLabel)) { // textarea final TextArea descriptionTextArea = new TextArea(); descriptionTextArea.setWidth(100, UNITS_PERCENTAGE); descriptionTextArea.setValue(task.getDescription()); editLayout.addComponent(descriptionTextArea); // ok button Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK)); editLayout.addComponent(okButton); editLayout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT); // replace replaceComponent(descriptionLabel, editLayout); // When OK is clicked -> update task data + ui okButton.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { // Update data task.setDescription(descriptionTextArea.getValue().toString()); taskService.saveTask(task); // Update UI descriptionLabel.setValue(task.getDescription()); replaceComponent(editLayout, descriptionLabel); }/*from w w w . j a va2 s. co m*/ }); } } }); }