Search in sources :

Example 16 with Button

use of com.vaadin.ui.Button 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 17 with Button

use of com.vaadin.ui.Button in project Activiti by Activiti.

the class TaskDetailPanel method initClaimButton.

protected void initClaimButton(HorizontalLayout layout) {
    if (!isCurrentUserAssignee() && canUserClaimTask()) {
        claimButton = new Button(i18nManager.getMessage(Messages.TASK_CLAIM));
        claimButton.addListener(new ClaimTaskClickListener(task.getId(), taskService));
        layout.addComponent(claimButton);
        layout.setComponentAlignment(claimButton, Alignment.MIDDLE_LEFT);
    }
}
Also used : Button(com.vaadin.ui.Button) ClaimTaskClickListener(org.activiti.explorer.ui.task.listener.ClaimTaskClickListener)

Example 18 with Button

use of com.vaadin.ui.Button 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);
        }
    });
}
Also used : Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) ClickListener(com.vaadin.ui.Button.ClickListener)

Example 19 with Button

use of com.vaadin.ui.Button 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);
        }
    });
}
Also used : Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) Label(com.vaadin.ui.Label) TextField(com.vaadin.ui.TextField) ClickListener(com.vaadin.ui.Button.ClickListener) DeleteSubTaskClickListener(org.activiti.explorer.ui.task.listener.DeleteSubTaskClickListener)

Example 20 with Button

use of com.vaadin.ui.Button 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);
    }
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) Label(com.vaadin.ui.Label) DeleteSubTaskClickListener(org.activiti.explorer.ui.task.listener.DeleteSubTaskClickListener) Embedded(com.vaadin.ui.Embedded) ClickListener(com.vaadin.ui.Button.ClickListener) DeleteSubTaskClickListener(org.activiti.explorer.ui.task.listener.DeleteSubTaskClickListener)

Aggregations

Button (com.vaadin.ui.Button)94 ClickEvent (com.vaadin.ui.Button.ClickEvent)63 ClickListener (com.vaadin.ui.Button.ClickListener)61 HorizontalLayout (com.vaadin.ui.HorizontalLayout)26 Label (com.vaadin.ui.Label)19 VerticalLayout (com.vaadin.ui.VerticalLayout)13 LayoutClickEvent (com.vaadin.event.LayoutEvents.LayoutClickEvent)7 LayoutClickListener (com.vaadin.event.LayoutEvents.LayoutClickListener)7 SubmitEvent (org.activiti.explorer.ui.event.SubmitEvent)7 ClaimTaskClickListener (org.activiti.explorer.ui.task.listener.ClaimTaskClickListener)5 ValueChangeEvent (com.vaadin.data.Property.ValueChangeEvent)4 TextField (com.vaadin.ui.TextField)4 SubmitEventListener (org.activiti.explorer.ui.event.SubmitEventListener)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 Item (com.vaadin.data.Item)3 ValueChangeListener (com.vaadin.data.Property.ValueChangeListener)3 ExternalResource (com.vaadin.terminal.ExternalResource)3 ComboBox (com.vaadin.ui.ComboBox)3 FormLayout (com.vaadin.ui.FormLayout)3