Search in sources :

Example 1 with ClickListener

use of com.vaadin.ui.Button.ClickListener in project opennms by OpenNMS.

the class AlarmIdColumnLinkGenerator method generateCell.

@Override
public Object generateCell(final Table source, Object itemId, Object columnId) {
    // no source
    if (source == null)
        return null;
    Property<Integer> alarmIdProperty = source.getContainerProperty(itemId, alarmIdPropertyName);
    final Integer alarmId = alarmIdProperty.getValue();
    // no value
    if (alarmId == null)
        return null;
    // create Link
    Button button = new Button("" + alarmId);
    button.setStyleName(BaseTheme.BUTTON_LINK);
    button.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 3698209256202413810L;

        @Override
        public void buttonClick(ClickEvent event) {
            // try if alarm is there, otherwise show information dialog
            OnmsAlarm alarm = alarmDao.get(alarmId);
            if (alarm == null) {
                new DialogWindow(source.getUI(), "Alarm does not exist!", "The alarm information cannot be shown. \nThe alarm does not exist anymore. \n\nPlease refresh the Alarm Table.");
                return;
            }
            // alarm still exists, show alarm details
            final URI currentLocation = Page.getCurrent().getLocation();
            final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath();
            final String redirectFragment = contextRoot + "/alarm/detail.htm?quiet=true&id=" + alarmId;
            LOG.debug("alarm {} clicked, current location = {}, uri = {}", alarmId, currentLocation, redirectFragment);
            try {
                source.getUI().addWindow(new InfoWindow(new URL(currentLocation.toURL(), redirectFragment), new LabelCreator() {

                    @Override
                    public String getLabel() {
                        return "Alarm Info " + alarmId;
                    }
                }));
            } catch (MalformedURLException e) {
                LOG.error(e.getMessage(), e);
            }
        }
    });
    return button;
}
Also used : MalformedURLException(java.net.MalformedURLException) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) ClickEvent(com.vaadin.ui.Button.ClickEvent) InfoWindow(org.opennms.features.topology.api.support.InfoWindow) URI(java.net.URI) URL(java.net.URL) Button(com.vaadin.ui.Button) DialogWindow(org.opennms.features.topology.api.support.DialogWindow) ClickListener(com.vaadin.ui.Button.ClickListener) LabelCreator(org.opennms.features.topology.api.support.InfoWindow.LabelCreator)

Example 2 with ClickListener

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

the class TaskDetailPanel method initProcessLink.

protected void initProcessLink() {
    if (task.getProcessInstanceId() != null) {
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
        Button showProcessInstanceButton = new Button(i18nManager.getMessage(Messages.TASK_PART_OF_PROCESS, getProcessDisplayName(processDefinition)));
        showProcessInstanceButton.addStyleName(Reindeer.BUTTON_LINK);
        showProcessInstanceButton.addListener(new ClickListener() {

            public void buttonClick(ClickEvent event) {
                viewManager.showMyProcessInstancesPage(task.getProcessInstanceId());
            }
        });
        centralLayout.addComponent(showProcessInstanceButton);
        addEmptySpace(centralLayout);
    }
}
Also used : Button(com.vaadin.ui.Button) LayoutClickEvent(com.vaadin.event.LayoutEvents.LayoutClickEvent) ClickEvent(com.vaadin.ui.Button.ClickEvent) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ClickListener(com.vaadin.ui.Button.ClickListener) LayoutClickListener(com.vaadin.event.LayoutEvents.LayoutClickListener) ClaimTaskClickListener(org.activiti.explorer.ui.task.listener.ClaimTaskClickListener)

Example 3 with ClickListener

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

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

the class TaskDetailPanel method initParentTaskLink.

protected void initParentTaskLink() {
    if (task.getParentTaskId() != null) {
        final Task parentTask = taskService.createTaskQuery().taskId(task.getParentTaskId()).singleResult();
        Button showParentTaskButton = new Button(i18nManager.getMessage(Messages.TASK_SUBTASK_OF_PARENT_TASK, parentTask.getName()));
        showParentTaskButton.addStyleName(Reindeer.BUTTON_LINK);
        showParentTaskButton.addListener(new ClickListener() {

            public void buttonClick(ClickEvent event) {
                viewManager.showTaskPage(parentTask.getId());
            }
        });
        centralLayout.addComponent(showParentTaskButton);
        addEmptySpace(centralLayout);
    }
}
Also used : Task(org.activiti.engine.task.Task) Button(com.vaadin.ui.Button) LayoutClickEvent(com.vaadin.event.LayoutEvents.LayoutClickEvent) ClickEvent(com.vaadin.ui.Button.ClickEvent) ClickListener(com.vaadin.ui.Button.ClickListener) LayoutClickListener(com.vaadin.event.LayoutEvents.LayoutClickListener) ClaimTaskClickListener(org.activiti.explorer.ui.task.listener.ClaimTaskClickListener)

Example 5 with ClickListener

use of com.vaadin.ui.Button.ClickListener 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)

Aggregations

ClickEvent (com.vaadin.ui.Button.ClickEvent)66 ClickListener (com.vaadin.ui.Button.ClickListener)66 Button (com.vaadin.ui.Button)61 HorizontalLayout (com.vaadin.ui.HorizontalLayout)15 Label (com.vaadin.ui.Label)11 SubmitEvent (org.activiti.explorer.ui.event.SubmitEvent)8 LayoutClickEvent (com.vaadin.event.LayoutEvents.LayoutClickEvent)7 LayoutClickListener (com.vaadin.event.LayoutEvents.LayoutClickListener)7 VerticalLayout (com.vaadin.ui.VerticalLayout)6 ValueChangeEvent (com.vaadin.data.Property.ValueChangeEvent)4 ValueChangeListener (com.vaadin.data.Property.ValueChangeListener)4 TextField (com.vaadin.ui.TextField)4 Map (java.util.Map)4 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)4 ClaimTaskClickListener (org.activiti.explorer.ui.task.listener.ClaimTaskClickListener)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 ExternalResource (com.vaadin.terminal.ExternalResource)3 Form (com.vaadin.ui.Form)3 URL (java.net.URL)3