Search in sources :

Example 61 with ClickListener

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

the class NewModelPopupWindow method addButtons.

protected void addButtons() {
    // Create
    Button createButton = new Button(i18nManager.getMessage(Messages.PROCESS_NEW_POPUP_CREATE_BUTTON));
    createButton.setWidth("200px");
    createButton.addListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            if (StringUtils.isEmpty((String) nameTextField.getValue())) {
                nameTextField.setComponentError(new UserError("The name field is required."));
                return;
            }
            if (selectEditorComponent.isModelerPreferred()) {
                try {
                    ObjectMapper objectMapper = new ObjectMapper();
                    ObjectNode editorNode = objectMapper.createObjectNode();
                    editorNode.put("id", "canvas");
                    editorNode.put("resourceId", "canvas");
                    ObjectNode stencilSetNode = objectMapper.createObjectNode();
                    stencilSetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#");
                    editorNode.put("stencilset", stencilSetNode);
                    Model modelData = repositoryService.newModel();
                    ObjectNode modelObjectNode = objectMapper.createObjectNode();
                    modelObjectNode.put(MODEL_NAME, (String) nameTextField.getValue());
                    modelObjectNode.put(MODEL_REVISION, 1);
                    String description = null;
                    if (StringUtils.isNotEmpty((String) descriptionTextArea.getValue())) {
                        description = (String) descriptionTextArea.getValue();
                    } else {
                        description = "";
                    }
                    modelObjectNode.put(MODEL_DESCRIPTION, description);
                    modelData.setMetaInfo(modelObjectNode.toString());
                    modelData.setName((String) nameTextField.getValue());
                    repositoryService.saveModel(modelData);
                    repositoryService.addModelEditorSource(modelData.getId(), editorNode.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);
                }
            } else {
                close();
                ExplorerApp.get().getViewManager().showSimpleTableProcessEditor((String) nameTextField.getValue(), (String) descriptionTextArea.getValue());
            }
        }
    });
    // Alignment
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.addComponent(createButton);
    addComponent(buttonLayout);
    windowLayout.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER);
}
Also used : UserError(com.vaadin.terminal.UserError) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ClickEvent(com.vaadin.ui.Button.ClickEvent) ExternalResource(com.vaadin.terminal.ExternalResource) URL(java.net.URL) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Button(com.vaadin.ui.Button) Model(org.activiti.engine.repository.Model) ClickListener(com.vaadin.ui.Button.ClickListener) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 62 with ClickListener

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

the class SelectEditorComponent method createModelerEditorChoice.

protected void createModelerEditorChoice() {
    modelerLayout = new HorizontalLayout();
    modelerLayout.setWidth("300px");
    modelerLayout.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
    addComponent(modelerLayout);
    modelerButton = new Button();
    modelerButton.setIcon(Images.PROCESS_EDITOR_BPMN);
    modelerButton.setStyleName(Reindeer.BUTTON_LINK);
    modelerLayout.addComponent(modelerButton);
    modelerLayout.setComponentAlignment(modelerButton, Alignment.MIDDLE_LEFT);
    VerticalLayout modelerTextLayout = new VerticalLayout();
    modelerLayout.addComponent(modelerTextLayout);
    modelerLayout.setExpandRatio(modelerTextLayout, 1.0f);
    modelerLabel = new Label(i18nManager.getMessage(Messages.PROCESS_EDITOR_MODELER));
    modelerLabel.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
    modelerTextLayout.addComponent(modelerLabel);
    modelerDescriptionLabel = new Label(i18nManager.getMessage(Messages.PROCESS_EDITOR_MODELER_DESCRIPTION));
    modelerDescriptionLabel.addStyleName(Reindeer.LABEL_SMALL);
    modelerDescriptionLabel.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
    modelerTextLayout.addComponent(modelerDescriptionLabel);
    modelerLayout.addListener(new LayoutClickListener() {

        public void layoutClick(LayoutClickEvent event) {
            preferModeler();
        }
    });
    modelerButton.addListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            preferModeler();
        }
    });
}
Also used : LayoutClickEvent(com.vaadin.event.LayoutEvents.LayoutClickEvent) Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) LayoutClickEvent(com.vaadin.event.LayoutEvents.LayoutClickEvent) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) ClickListener(com.vaadin.ui.Button.ClickListener) LayoutClickListener(com.vaadin.event.LayoutEvents.LayoutClickListener) HorizontalLayout(com.vaadin.ui.HorizontalLayout) LayoutClickListener(com.vaadin.event.LayoutEvents.LayoutClickListener)

Example 63 with ClickListener

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

the class FormPropertiesForm method initListeners.

protected void initListeners() {
    submitFormButton.addListener(new ClickListener() {

        private static final long serialVersionUID = -6091586145870618870L;

        public void buttonClick(ClickEvent event) {
            // Extract the submitted values from the form. Throws exception when validation fails.
            try {
                Map<String, String> formProperties = formPropertiesComponent.getFormPropertyValues();
                fireEvent(new FormPropertiesEvent(FormPropertiesForm.this, FormPropertiesEvent.TYPE_SUBMIT, formProperties));
                submitFormButton.setComponentError(null);
            } catch (InvalidValueException ive) {
            // Error is presented to user by the form component
            }
        }
    });
    cancelFormButton.addListener(new ClickListener() {

        private static final long serialVersionUID = -8980500491522472381L;

        public void buttonClick(ClickEvent event) {
            fireEvent(new FormPropertiesEvent(FormPropertiesForm.this, FormPropertiesEvent.TYPE_CANCEL));
            submitFormButton.setComponentError(null);
        }
    });
}
Also used : InvalidValueException(com.vaadin.data.Validator.InvalidValueException) ClickEvent(com.vaadin.ui.Button.ClickEvent) Map(java.util.Map) ClickListener(com.vaadin.ui.Button.ClickListener)

Example 64 with ClickListener

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

the class ToolbarEntry method initLabelComponent.

protected void initLabelComponent() {
    titleButton = new Button(title);
    titleButton.addStyleName(Reindeer.BUTTON_LINK);
    layout.addComponent(titleButton);
    layout.setComponentAlignment(titleButton, Alignment.MIDDLE_LEFT);
    titleButton.addListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            if (command != null) {
                command.toolBarItemSelected();
            }
        }
    });
}
Also used : Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) ClickListener(com.vaadin.ui.Button.ClickListener)

Example 65 with ClickListener

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

the class SelectUsersPopupWindow method initSelectMyselfButton.

protected void initSelectMyselfButton(HorizontalLayout searchLayout) {
    final LoggedInUser loggedInUser = ExplorerApp.get().getLoggedInUser();
    if (ignoredUserIds == null || !ignoredUserIds.contains(loggedInUser.getId())) {
        Button meButton = new Button(i18nManager.getMessage(Messages.PEOPLE_SELECT_MYSELF));
        meButton.setIcon(Images.USER_16);
        searchLayout.addComponent(meButton);
        searchLayout.setComponentAlignment(meButton, Alignment.MIDDLE_LEFT);
        if (multiSelect) {
            meButton.addListener(new ClickListener() {

                public void buttonClick(ClickEvent event) {
                    selectUser(loggedInUser.getId(), loggedInUser.getFullName());
                }
            });
        } else {
            meButton.addListener(new ClickListener() {

                public void buttonClick(ClickEvent event) {
                    addMatchingUser(loggedInUser.getId(), loggedInUser.getFullName());
                    matchingUsersTable.select(loggedInUser.getId());
                    fireEvent(new SubmitEvent(doneButton, SubmitEvent.SUBMITTED));
                    close();
                }
            });
        }
    }
}
Also used : Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) LoggedInUser(org.activiti.explorer.identity.LoggedInUser) ClickListener(com.vaadin.ui.Button.ClickListener) SubmitEvent(org.activiti.explorer.ui.event.SubmitEvent)

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