use of com.vaadin.ui.Button.ClickEvent in project Activiti by Activiti.
the class TaskDetailPanel method initTaskForm.
protected void initTaskForm() {
// Check if task requires a form
TaskFormData formData = formService.getTaskFormData(task.getId());
if (formData != null && formData.getFormProperties() != null && !formData.getFormProperties().isEmpty()) {
taskForm = new FormPropertiesForm();
taskForm.setSubmitButtonCaption(i18nManager.getMessage(Messages.TASK_COMPLETE));
taskForm.setCancelButtonCaption(i18nManager.getMessage(Messages.TASK_RESET_FORM));
taskForm.setFormHelp(i18nManager.getMessage(Messages.TASK_FORM_HELP));
taskForm.setFormProperties(formData.getFormProperties());
taskForm.addListener(new FormPropertiesEventListener() {
private static final long serialVersionUID = -3893467157397686736L;
@Override
protected void handleFormSubmit(FormPropertiesEvent event) {
Map<String, String> properties = event.getFormProperties();
formService.submitTaskFormData(task.getId(), properties);
notificationManager.showInformationNotification(Messages.TASK_COMPLETED, task.getName());
taskPage.refreshSelectNext();
}
@Override
protected void handleFormCancel(FormPropertiesEvent event) {
// Clear the form values
taskForm.clear();
}
});
// Only if current user is task's assignee
taskForm.setEnabled(isCurrentUserAssignee());
// Add component to page
centralLayout.addComponent(taskForm);
} else {
// Just add a button to complete the task
// TODO: perhaps move to a better place
CssLayout buttonLayout = new CssLayout();
buttonLayout.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
buttonLayout.setWidth(100, UNITS_PERCENTAGE);
centralLayout.addComponent(buttonLayout);
completeButton = new Button(i18nManager.getMessage(Messages.TASK_COMPLETE));
completeButton.addListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
// If no owner, make assignee owner (will go into archived then)
if (task.getOwner() == null) {
task.setOwner(task.getAssignee());
taskService.setOwner(task.getId(), task.getAssignee());
}
taskService.complete(task.getId());
notificationManager.showInformationNotification(Messages.TASK_COMPLETED, task.getName());
taskPage.refreshSelectNext();
}
});
completeButton.setEnabled(isCurrentUserAssignee() || isCurrentUserOwner());
buttonLayout.addComponent(completeButton);
}
}
use of com.vaadin.ui.Button.ClickEvent in project Activiti by Activiti.
the class TaskMenuBar method initActions.
protected void initActions() {
Button newCaseButton = new Button();
newCaseButton.setCaption(i18nManager.getMessage(Messages.TASK_NEW));
newCaseButton.setIcon(Images.TASK_16);
addButton(newCaseButton);
newCaseButton.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
NewCasePopupWindow newTaskPopupWindow = new NewCasePopupWindow();
viewManager.showPopupWindow(newTaskPopupWindow);
}
});
}
use of com.vaadin.ui.Button.ClickEvent in project Activiti by Activiti.
the class SubTaskComponent method initAddButton.
protected void initAddButton() {
addSubTaskButton = new Button();
addSubTaskButton.addStyleName(ExplorerLayout.STYLE_ADD);
addSubTaskPanel.addComponent(addSubTaskButton);
addSubTaskButton.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
// Remove button
addSubTaskPanel.removeAllComponents();
// And add textfield
Label createSubTaskLabel = new Label("Create new subtask:");
createSubTaskLabel.addStyleName(Reindeer.LABEL_SMALL);
addSubTaskPanel.addComponent(createSubTaskLabel);
newTaskTextField = new TextField();
newTaskTextField.focus();
addSubTaskPanel.addComponent(newTaskTextField);
}
});
}
use of com.vaadin.ui.Button.ClickEvent in project Activiti by Activiti.
the class SubTaskComponent method populateSubTasks.
protected void populateSubTasks(List<HistoricTaskInstance> subTasks) {
if (!subTasks.isEmpty()) {
for (final HistoricTaskInstance subTask : subTasks) {
// icon
Embedded icon = null;
if (subTask.getEndTime() != null) {
icon = new Embedded(null, Images.TASK_FINISHED_22);
} else {
icon = new Embedded(null, Images.TASK_22);
}
icon.setWidth(22, UNITS_PIXELS);
icon.setWidth(22, UNITS_PIXELS);
subTaskLayout.addComponent(icon);
// Link to subtask
Button subTaskLink = new Button(subTask.getName());
subTaskLink.addStyleName(Reindeer.BUTTON_LINK);
subTaskLink.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
ExplorerApp.get().getViewManager().showTaskPage(subTask.getId());
}
});
subTaskLayout.addComponent(subTaskLink);
subTaskLayout.setComponentAlignment(subTaskLink, Alignment.MIDDLE_LEFT);
if (subTask.getEndTime() == null) {
// Delete icon only appears when task is not finished yet
Embedded deleteIcon = new Embedded(null, Images.DELETE);
deleteIcon.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
deleteIcon.addListener(new DeleteSubTaskClickListener(subTask, this));
subTaskLayout.addComponent(deleteIcon);
subTaskLayout.setComponentAlignment(deleteIcon, Alignment.MIDDLE_RIGHT);
} else {
// Next line of grid
subTaskLayout.newLine();
}
}
} else {
Label noSubTasksLabel = new Label(i18nManager.getMessage(Messages.TASK_NO_SUBTASKS));
noSubTasksLabel.setSizeUndefined();
noSubTasksLabel.addStyleName(Reindeer.LABEL_SMALL);
subTaskLayout.addComponent(noSubTasksLabel);
}
}
use of com.vaadin.ui.Button.ClickEvent in project Activiti by Activiti.
the class ChangeProcessSuspensionStatePopupWindow method addTimeSection.
protected void addTimeSection(boolean suspend) {
Label timeLabel = new Label(suspend ? i18nManager.getMessage(Messages.PROCESS_SUSPEND_POPUP_TIME_DESCRIPTION) : i18nManager.getMessage(Messages.PROCESS_ACTIVATE_POPUP_TIME_DESCRIPTION));
verticalLayout.addComponent(timeLabel);
verticalLayout.addComponent(new Label(" ", Label.CONTENT_XHTML));
nowCheckBox = new CheckBox(i18nManager.getMessage(Messages.PROCESS_SUSPEND_POPUP_TIME_NOW), true);
nowCheckBox.addStyleName(ExplorerLayout.STYLE_PROCESS_DEFINITION_SUSPEND_CHOICE);
nowCheckBox.setImmediate(true);
nowCheckBox.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
if (nowCheckBox.booleanValue() == true) {
dateField.setValue(null);
dateCheckBox.setValue(false);
} else {
dateCheckBox.setValue(true);
dateField.setValue(new Date());
}
}
});
verticalLayout.addComponent(nowCheckBox);
HorizontalLayout dateLayout = new HorizontalLayout();
verticalLayout.addComponent(dateLayout);
dateCheckBox = new CheckBox(i18nManager.getMessage(Messages.PROCESS_SUSPEND_POPUP_TIME_DATE));
dateCheckBox.addStyleName(ExplorerLayout.STYLE_PROCESS_DEFINITION_SUSPEND_CHOICE);
dateCheckBox.setImmediate(true);
dateCheckBox.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
if (dateCheckBox.booleanValue() == true) {
dateField.setValue(new Date());
nowCheckBox.setValue(false);
} else {
dateField.setValue(null);
nowCheckBox.setValue(true);
}
}
});
dateLayout.addComponent(dateCheckBox);
dateField = new DateField();
dateField.setImmediate(true);
dateField.addListener(new ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
if (dateField.getValue() != null) {
nowCheckBox.setValue(false);
dateCheckBox.setValue(true);
}
}
});
dateLayout.addComponent(dateField);
}
Aggregations