Search in sources :

Example 1 with CreateAttachmentPopupWindow

use of org.activiti.explorer.ui.content.CreateAttachmentPopupWindow in project Activiti by Activiti.

the class TaskRelatedContentComponent method initActions.

protected void initActions() {
    HorizontalLayout actionsContainer = new HorizontalLayout();
    actionsContainer.setSizeFull();
    // Title
    Label processTitle = new Label(i18nManager.getMessage(Messages.TASK_RELATED_CONTENT));
    processTitle.addStyleName(ExplorerLayout.STYLE_H3);
    processTitle.setSizeFull();
    actionsContainer.addComponent(processTitle);
    actionsContainer.setComponentAlignment(processTitle, Alignment.MIDDLE_LEFT);
    actionsContainer.setExpandRatio(processTitle, 1.0f);
    // Add content button
    Button addRelatedContentButton = new Button();
    addRelatedContentButton.addStyleName(ExplorerLayout.STYLE_ADD);
    addRelatedContentButton.addListener(new com.vaadin.ui.Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {
            CreateAttachmentPopupWindow popup = new CreateAttachmentPopupWindow();
            if (task.getProcessInstanceId() != null) {
                popup.setProcessInstanceId(task.getProcessInstanceId());
            } else {
                popup.setTaskId(task.getId());
            }
            // Add listener to update attachments when added
            popup.addListener(new SubmitEventListener() {

                private static final long serialVersionUID = 1L;

                @Override
                protected void submitted(SubmitEvent event) {
                    taskDetailPanel.notifyRelatedContentChanged();
                }

                @Override
                protected void cancelled(SubmitEvent event) {
                // No attachment was added so updating UI isn't needed.
                }
            });
            ExplorerApp.get().getViewManager().showPopupWindow(popup);
        }
    });
    actionsContainer.addComponent(addRelatedContentButton);
    actionsContainer.setComponentAlignment(processTitle, Alignment.MIDDLE_RIGHT);
    addComponent(actionsContainer);
}
Also used : Button(com.vaadin.ui.Button) SubmitEventListener(org.activiti.explorer.ui.event.SubmitEventListener) Label(com.vaadin.ui.Label) CreateAttachmentPopupWindow(org.activiti.explorer.ui.content.CreateAttachmentPopupWindow) HorizontalLayout(com.vaadin.ui.HorizontalLayout) SubmitEvent(org.activiti.explorer.ui.event.SubmitEvent)

Aggregations

Button (com.vaadin.ui.Button)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 Label (com.vaadin.ui.Label)1 CreateAttachmentPopupWindow (org.activiti.explorer.ui.content.CreateAttachmentPopupWindow)1 SubmitEvent (org.activiti.explorer.ui.event.SubmitEvent)1 SubmitEventListener (org.activiti.explorer.ui.event.SubmitEventListener)1