Search in sources :

Example 1 with CssLayout

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

the class TaskDetailPanel method initDescription.

protected void initDescription(HorizontalLayout layout) {
    final CssLayout descriptionLayout = new CssLayout();
    descriptionLayout.setWidth(100, UNITS_PERCENTAGE);
    layout.addComponent(descriptionLayout);
    layout.setExpandRatio(descriptionLayout, 1.0f);
    layout.setComponentAlignment(descriptionLayout, Alignment.MIDDLE_LEFT);
    String descriptionText = null;
    if (task.getDescription() != null && !"".equals(task.getDescription())) {
        descriptionText = task.getDescription();
    } else {
        descriptionText = i18nManager.getMessage(Messages.TASK_NO_DESCRIPTION);
    }
    final Label descriptionLabel = new Label(descriptionText);
    descriptionLabel.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
    descriptionLayout.addComponent(descriptionLabel);
    descriptionLayout.addListener(new LayoutClickListener() {

        public void layoutClick(LayoutClickEvent event) {
            if (event.getClickedComponent() != null && event.getClickedComponent().equals(descriptionLabel)) {
                // layout for textarea + ok button
                final VerticalLayout editLayout = new VerticalLayout();
                editLayout.setSpacing(true);
                // textarea
                final TextArea descriptionTextArea = new TextArea();
                descriptionTextArea.setNullRepresentation("");
                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
                descriptionLayout.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());
                        descriptionLayout.replaceComponent(editLayout, descriptionLabel);
                    }
                });
            }
        }
    });
}
Also used : LayoutClickEvent(com.vaadin.event.LayoutEvents.LayoutClickEvent) CssLayout(com.vaadin.ui.CssLayout) TextArea(com.vaadin.ui.TextArea) Button(com.vaadin.ui.Button) LayoutClickEvent(com.vaadin.event.LayoutEvents.LayoutClickEvent) ClickEvent(com.vaadin.ui.Button.ClickEvent) Label(com.vaadin.ui.Label) PrettyTimeLabel(org.activiti.explorer.ui.custom.PrettyTimeLabel) VerticalLayout(com.vaadin.ui.VerticalLayout) ClickListener(com.vaadin.ui.Button.ClickListener) LayoutClickListener(com.vaadin.event.LayoutEvents.LayoutClickListener) ClaimTaskClickListener(org.activiti.explorer.ui.task.listener.ClaimTaskClickListener) LayoutClickListener(com.vaadin.event.LayoutEvents.LayoutClickListener)

Example 2 with CssLayout

use of com.vaadin.ui.CssLayout 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 3 with CssLayout

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

the class HistoricTaskDetailPanel method initDescription.

protected void initDescription() {
    CssLayout descriptionLayout = new CssLayout();
    descriptionLayout.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    descriptionLayout.setWidth(100, UNITS_PERCENTAGE);
    if (historicTask.getDescription() != null) {
        Label descriptionLabel = new Label(historicTask.getDescription());
        descriptionLayout.addComponent(descriptionLabel);
    }
    centralLayout.addComponent(descriptionLayout);
}
Also used : CssLayout(com.vaadin.ui.CssLayout) Label(com.vaadin.ui.Label) PrettyTimeLabel(org.activiti.explorer.ui.custom.PrettyTimeLabel)

Example 4 with CssLayout

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

the class MainLayout method initMain.

protected void initMain() {
    main = new CssLayout();
    main.setSizeFull();
    main.addStyleName(ExplorerLayout.STYLE_MAIN_CONTENT);
    addComponent(main);
    setExpandRatio(main, 1.0f);
}
Also used : CssLayout(com.vaadin.ui.CssLayout)

Example 5 with CssLayout

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

the class MainLayout method initHeader.

protected void initHeader() {
    header = new CssLayout();
    header.addStyleName(ExplorerLayout.STYLE_HEADER);
    header.setWidth(100, UNITS_PERCENTAGE);
    addComponent(header);
}
Also used : CssLayout(com.vaadin.ui.CssLayout)

Aggregations

CssLayout (com.vaadin.ui.CssLayout)23 Label (com.vaadin.ui.Label)8 Button (com.vaadin.ui.Button)7 ClickEvent (com.vaadin.ui.Button.ClickEvent)4 ClickListener (com.vaadin.ui.Button.ClickListener)4 VerticalLayout (com.vaadin.ui.VerticalLayout)4 Component (com.vaadin.ui.Component)3 HorizontalLayout (com.vaadin.ui.HorizontalLayout)3 TextField (com.vaadin.ui.TextField)3 LayoutClickEvent (com.vaadin.event.LayoutEvents.LayoutClickEvent)2 LayoutClickListener (com.vaadin.event.LayoutEvents.LayoutClickListener)2 ValoTheme (com.vaadin.ui.themes.ValoTheme)2 PrettyTimeLabel (org.activiti.explorer.ui.custom.PrettyTimeLabel)2 ClaimTaskClickListener (org.activiti.explorer.ui.task.listener.ClaimTaskClickListener)2 WebAbstractComponent (com.haulmont.cuba.web.gui.components.WebAbstractComponent)1 WebAppWorkArea (com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea)1 WindowBreadCrumbs (com.haulmont.cuba.web.sys.WindowBreadCrumbs)1 GrayTheme (com.vaadin.addon.charts.themes.GrayTheme)1 GridTheme (com.vaadin.addon.charts.themes.GridTheme)1 HighChartsDefaultTheme (com.vaadin.addon.charts.themes.HighChartsDefaultTheme)1