Search in sources :

Example 56 with ClickListener

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

the class NodeSelectionLinkGenerator method generateCell.

@Override
public Object generateCell(final Table source, final Object itemId, Object columnId) {
    final Property<Integer> nodeIdProperty = source.getContainerProperty(itemId, m_nodeIdProperty);
    Object cellValue = m_generator.generateCell(source, itemId, columnId);
    if (cellValue == null) {
        return null;
    } else {
        if (nodeIdProperty.getValue() == null) {
            return cellValue;
        } else {
            Button button = new Button(cellValue.toString());
            button.setStyleName(BaseTheme.BUTTON_LINK);
            button.setDescription(nodeIdProperty.getValue().toString());
            button.addClickListener(new ClickListener() {

                @Override
                public void buttonClick(ClickEvent event) {
                    Integer nodeId = nodeIdProperty.getValue();
                    String nodeLabel = (String) source.getContainerProperty(itemId, m_nodeLabelProperty).getValue();
                    VertexRef vertexRef = new DefaultVertexRef("nodes", String.valueOf(nodeId), nodeLabel);
                    fireVertexUpdatedEvent(vertexRef);
                }
            });
            return button;
        }
    }
}
Also used : DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) VertexRef(org.opennms.features.topology.api.topo.VertexRef) ClickListener(com.vaadin.ui.Button.ClickListener)

Example 57 with ClickListener

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

the class TaskInvolvedPeopleComponent method initAddPeopleButton.

protected void initAddPeopleButton(HorizontalLayout headerLayout) {
    addPeopleButton = new Button();
    addPeopleButton.addStyleName(ExplorerLayout.STYLE_ADD);
    headerLayout.addComponent(addPeopleButton);
    addPeopleButton.addListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            final SelectUsersPopupWindow involvePeoplePopupWindow = new SelectUsersPopupWindow(i18nManager.getMessage(Messages.PEOPLE_INVOLVE_POPUP_CAPTION), true);
            involvePeoplePopupWindow.addListener(new SubmitEventListener() {

                protected void submitted(SubmitEvent event) {
                    Collection<String> selectedUserIds = involvePeoplePopupWindow.getSelectedUserIds();
                    for (String userId : selectedUserIds) {
                        String role = involvePeoplePopupWindow.getSelectedUserRole(userId);
                        taskService.addUserIdentityLink(task.getId(), userId, role);
                    }
                    taskDetailPanel.notifyPeopleInvolvedChanged();
                }

                protected void cancelled(SubmitEvent event) {
                }
            });
            viewManager.showPopupWindow(involvePeoplePopupWindow);
        }
    });
}
Also used : SelectUsersPopupWindow(org.activiti.explorer.ui.custom.SelectUsersPopupWindow) Button(com.vaadin.ui.Button) SubmitEventListener(org.activiti.explorer.ui.event.SubmitEventListener) ClickEvent(com.vaadin.ui.Button.ClickEvent) ClickListener(com.vaadin.ui.Button.ClickListener) SubmitEvent(org.activiti.explorer.ui.event.SubmitEvent)

Example 58 with ClickListener

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

the class ConvertProcessDefinitionPopupWindow method addButtons.

protected void addButtons() {
    // Cancel
    Button cancelButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL));
    cancelButton.addStyleName(Reindeer.BUTTON_SMALL);
    cancelButton.addListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    // Convert
    Button convertButton = new Button(i18nManager.getMessage(Messages.PROCESS_CONVERT_POPUP_CONVERT_BUTTON));
    convertButton.addStyleName(Reindeer.BUTTON_SMALL);
    convertButton.addListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            try {
                InputStream bpmnStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), processDefinition.getResourceName());
                XMLInputFactory xif = XmlUtil.createSafeXmlInputFactory();
                InputStreamReader in = new InputStreamReader(bpmnStream, "UTF-8");
                XMLStreamReader xtr = xif.createXMLStreamReader(in);
                BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);
                if (bpmnModel.getMainProcess() == null || bpmnModel.getMainProcess().getId() == null) {
                    notificationManager.showErrorNotification(Messages.MODEL_IMPORT_FAILED, i18nManager.getMessage(Messages.MODEL_IMPORT_INVALID_BPMN_EXPLANATION));
                } else {
                    if (bpmnModel.getLocationMap().isEmpty()) {
                        notificationManager.showErrorNotification(Messages.MODEL_IMPORT_INVALID_BPMNDI, i18nManager.getMessage(Messages.MODEL_IMPORT_INVALID_BPMNDI_EXPLANATION));
                    } else {
                        BpmnJsonConverter converter = new BpmnJsonConverter();
                        ObjectNode modelNode = converter.convertToJson(bpmnModel);
                        Model modelData = repositoryService.newModel();
                        ObjectNode modelObjectNode = new ObjectMapper().createObjectNode();
                        modelObjectNode.put(MODEL_NAME, processDefinition.getName());
                        modelObjectNode.put(MODEL_REVISION, 1);
                        modelObjectNode.put(MODEL_DESCRIPTION, processDefinition.getDescription());
                        modelData.setMetaInfo(modelObjectNode.toString());
                        modelData.setName(processDefinition.getName());
                        repositoryService.saveModel(modelData);
                        repositoryService.addModelEditorSource(modelData.getId(), modelNode.toString().getBytes("utf-8"));
                        close();
                        ExplorerApp.get().getViewManager().showEditorProcessDefinitionPage(modelData.getId());
                        URL explorerURL = ExplorerApp.get().getURL();
                        URL url = new URL(explorerURL.getProtocol(), explorerURL.getHost(), explorerURL.getPort(), explorerURL.getPath().replace("/ui", "") + "modeler.html?modelId=" + modelData.getId());
                        ExplorerApp.get().getMainWindow().open(new ExternalResource(url));
                    }
                }
            } catch (Exception e) {
                notificationManager.showErrorNotification("error", e);
            }
        }
    });
    // Alignment
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.addComponent(cancelButton);
    buttonLayout.addComponent(convertButton);
    addComponent(buttonLayout);
    windowLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) InputStreamReader(java.io.InputStreamReader) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) InputStream(java.io.InputStream) ClickEvent(com.vaadin.ui.Button.ClickEvent) ExternalResource(com.vaadin.terminal.ExternalResource) URL(java.net.URL) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter) BpmnModel(org.activiti.bpmn.model.BpmnModel) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Button(com.vaadin.ui.Button) Model(org.activiti.engine.repository.Model) BpmnModel(org.activiti.bpmn.model.BpmnModel) BpmnJsonConverter(org.activiti.editor.language.json.converter.BpmnJsonConverter) ClickListener(com.vaadin.ui.Button.ClickListener) XMLInputFactory(javax.xml.stream.XMLInputFactory) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 59 with ClickListener

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

the class EditorProcessDefinitionDetailPanel method deploySimpleTableEditorModel.

protected void deploySimpleTableEditorModel(final byte[] model) {
    final DeployModelPopupWindow deployModelPopupWindow = new DeployModelPopupWindow(modelData);
    deployModelPopupWindow.getDeployButton().addListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            // Convert to simple workflow definition
            WorkflowDefinition workflowDefinition = ExplorerApp.get().getSimpleWorkflowJsonConverter().readWorkflowDefinition(model);
            // Update model name
            modelData.setName(deployModelPopupWindow.getProcessName());
            workflowDefinition.setName(deployModelPopupWindow.getProcessName());
            WorkflowDefinitionConversion conversion = ExplorerApp.get().getWorkflowDefinitionConversionFactory().createWorkflowDefinitionConversion(workflowDefinition);
            conversion.convert();
            // Deploy to database
            byte[] bpmnBytes = null;
            try {
                bpmnBytes = conversion.getBpmn20Xml().getBytes("utf-8");
                String processName = modelData.getName() + ".bpmn20.xml";
                Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes)).deploy();
                // Generate reports
                if (deployModelPopupWindow.isGenerateReports()) {
                    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
                    ReportingUtil.generateTaskDurationReport(processDefinition.getId());
                }
                // Close popup and show new deployment
                deployModelPopupWindow.closePopupWindow();
                ExplorerApp.get().getViewManager().showDeploymentPage(deployment.getId());
            } catch (UnsupportedEncodingException e) {
                ExplorerApp.get().getNotificationManager().showErrorNotification(Messages.PROCESS_TOXML_FAILED, e);
                deployModelPopupWindow.closePopupWindow();
            }
        }
    });
    deployModelPopupWindow.showPopupWindow();
}
Also used : WorkflowDefinitionConversion(org.activiti.workflow.simple.converter.WorkflowDefinitionConversion) ClickEvent(com.vaadin.ui.Button.ClickEvent) WorkflowDefinition(org.activiti.workflow.simple.definition.WorkflowDefinition) Deployment(org.activiti.engine.repository.Deployment) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ClickListener(com.vaadin.ui.Button.ClickListener) ImportModelClickListener(org.activiti.explorer.ui.process.listener.ImportModelClickListener) NewModelClickListener(org.activiti.explorer.ui.process.listener.NewModelClickListener) EditModelClickListener(org.activiti.explorer.ui.process.listener.EditModelClickListener)

Example 60 with ClickListener

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

the class CreateAttachmentPopupWindow method initActions.

protected void initActions() {
    okButton = new Button(i18nManager.getMessage(Messages.RELATED_CONTENT_CREATE));
    detailLayout.addComponent(okButton, 0, 1);
    okButton.setEnabled(false);
    okButton.addListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            saveAttachment();
        }
    });
    detailLayout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT);
}
Also used : Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) ClickListener(com.vaadin.ui.Button.ClickListener)

Aggregations

ClickEvent (com.vaadin.ui.Button.ClickEvent)69 ClickListener (com.vaadin.ui.Button.ClickListener)69 Button (com.vaadin.ui.Button)64 HorizontalLayout (com.vaadin.ui.HorizontalLayout)15 Label (com.vaadin.ui.Label)12 VerticalLayout (com.vaadin.ui.VerticalLayout)8 SubmitEvent (org.activiti.explorer.ui.event.SubmitEvent)8 LayoutClickEvent (com.vaadin.event.LayoutEvents.LayoutClickEvent)7 LayoutClickListener (com.vaadin.event.LayoutEvents.LayoutClickListener)7 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