Search in sources :

Example 1 with FormPropertiesForm

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);
    }
}
Also used : CssLayout(com.vaadin.ui.CssLayout) FormPropertiesEventListener(org.activiti.explorer.ui.form.FormPropertiesEventListener) Button(com.vaadin.ui.Button) LayoutClickEvent(com.vaadin.event.LayoutEvents.LayoutClickEvent) ClickEvent(com.vaadin.ui.Button.ClickEvent) FormPropertiesForm(org.activiti.explorer.ui.form.FormPropertiesForm) TaskFormData(org.activiti.engine.form.TaskFormData) FormPropertiesEvent(org.activiti.explorer.ui.form.FormPropertiesForm.FormPropertiesEvent) Map(java.util.Map) ClickListener(com.vaadin.ui.Button.ClickListener) LayoutClickListener(com.vaadin.event.LayoutEvents.LayoutClickListener) ClaimTaskClickListener(org.activiti.explorer.ui.task.listener.ClaimTaskClickListener)

Example 2 with FormPropertiesForm

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);
}
Also used : FormPropertiesEventListener(org.activiti.explorer.ui.form.FormPropertiesEventListener) FormPropertiesForm(org.activiti.explorer.ui.form.FormPropertiesForm) FormPropertiesEvent(org.activiti.explorer.ui.form.FormPropertiesForm.FormPropertiesEvent)

Example 3 with FormPropertiesForm

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);
    }
}
Also used : FormPropertiesEventListener(org.activiti.explorer.ui.form.FormPropertiesEventListener) StartFormData(org.activiti.engine.form.StartFormData) FormPropertiesForm(org.activiti.explorer.ui.form.FormPropertiesForm) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) FormPropertiesEvent(org.activiti.explorer.ui.form.FormPropertiesForm.FormPropertiesEvent) ProcessEngine(org.activiti.engine.ProcessEngine)

Aggregations

FormPropertiesEventListener (org.activiti.explorer.ui.form.FormPropertiesEventListener)3 FormPropertiesForm (org.activiti.explorer.ui.form.FormPropertiesForm)3 FormPropertiesEvent (org.activiti.explorer.ui.form.FormPropertiesForm.FormPropertiesEvent)3 LayoutClickEvent (com.vaadin.event.LayoutEvents.LayoutClickEvent)1 LayoutClickListener (com.vaadin.event.LayoutEvents.LayoutClickListener)1 Button (com.vaadin.ui.Button)1 ClickEvent (com.vaadin.ui.Button.ClickEvent)1 ClickListener (com.vaadin.ui.Button.ClickListener)1 CssLayout (com.vaadin.ui.CssLayout)1 Map (java.util.Map)1 ProcessEngine (org.activiti.engine.ProcessEngine)1 StartFormData (org.activiti.engine.form.StartFormData)1 TaskFormData (org.activiti.engine.form.TaskFormData)1 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1 ClaimTaskClickListener (org.activiti.explorer.ui.task.listener.ClaimTaskClickListener)1