use of org.activiti.explorer.ui.form.FormPropertiesForm 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 org.activiti.explorer.ui.form.FormPropertiesForm in project Activiti by Activiti.
the class ProcessDefinitionDetailPanel method showProcessStartForm.
public void showProcessStartForm(StartFormData startFormData) {
if (processDefinitionStartForm == null) {
processDefinitionStartForm = new FormPropertiesForm();
processDefinitionStartForm.setSubmitButtonCaption(i18nManager.getMessage(Messages.PROCESS_START));
processDefinitionStartForm.setCancelButtonCaption(i18nManager.getMessage(Messages.BUTTON_CANCEL));
// When form is submitted/cancelled, show the info again
processDefinitionStartForm.addListener(new FormPropertiesEventListener() {
private static final long serialVersionUID = 1L;
protected void handleFormSubmit(FormPropertiesEvent event) {
formService.submitStartFormData(processDefinition.getId(), event.getFormProperties());
// Show notification
ExplorerApp.get().getMainWindow().showNotification(MessageFormat.format(i18nManager.getMessage(Messages.PROCESS_STARTED_NOTIFICATION), getProcessDisplayName(processDefinition)));
initProcessDefinitionInfo();
}
protected void handleFormCancel(FormPropertiesEvent event) {
initProcessDefinitionInfo();
}
});
}
processDefinitionStartForm.setFormProperties(startFormData.getFormProperties());
startProcessInstanceButton.setEnabled(false);
detailContainer.removeAllComponents();
detailContainer.addComponent(processDefinitionStartForm);
}
use of org.activiti.explorer.ui.form.FormPropertiesForm in project Activiti by Activiti.
the class ReportDetailPanel method initForm.
protected void initForm() {
// Check if a start form is defined
final ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
StartFormData startFormData = processEngine.getFormService().getStartFormData(processDefinition.getId());
if (startFormData != null && ((startFormData.getFormProperties() != null && !startFormData.getFormProperties().isEmpty()) || startFormData.getFormKey() != null)) {
processDefinitionStartForm = new FormPropertiesForm();
detailContainer.addComponent(processDefinitionStartForm);
processDefinitionStartForm.setFormProperties(startFormData.getFormProperties());
processDefinitionStartForm.setSubmitButtonCaption(i18nManager.getMessage(Messages.REPORTING_GENERATE_REPORT));
processDefinitionStartForm.hideCancelButton();
processDefinitionStartForm.addListener(new FormPropertiesEventListener() {
private static final long serialVersionUID = 1L;
protected void handleFormSubmit(FormPropertiesEvent event) {
// Report is generated by running a process and storing the dataset in the history tablkes
savedFormProperties = event.getFormProperties();
ProcessInstance processInstance = startProcessInstanceWithFormProperties(processDefinition.getId(), event.getFormProperties());
generateReport(processInstance);
}
protected void handleFormCancel(FormPropertiesEvent event) {
// Not needed, cancel button not shown in report panels
}
});
} else {
// Just start the process-instance since it has no form.
ProcessInstance processInstance = startProcessInstance(processDefinition.getId());
generateReport(processInstance);
}
}
Aggregations