Example usage for com.vaadin.ui Button addListener

List of usage examples for com.vaadin.ui Button addListener

Introduction

In this page you can find the example usage for com.vaadin.ui Button addListener.

Prototype

@Override
    public Registration addListener(Component.Listener listener) 

Source Link

Usage

From source file:gov.va.ds4p.ds4pmobileportal.ui.eHealthExchange.java

License:Open Source License

private void buildView() {
    CssLayout content = new CssLayout();
    content.setWidth("100%");
    setCaption("eHealth Exchange - " + AdminContext.getSessionAttributes().getSelectedPatientName());

    VerticalComponentGroup vGroup = new VerticalComponentGroup();

    Label displayAction = new Label(
            "<div style='color:#333;'><p>First perform a secured <b>Search</b> (DocumentQuery) for all available patient documents."
                    + "  Then <b>highlight</b> the document of interest in the table, then click"
                    + " on the <b>Retrieve Document</b> button to perform a secured DocumentRetrieve."
                    + "  Decrpyt the document by clicking any of the 2 <b>Decryption</b> buttons results may vary depending"
                    + " on you privileges.  Once decrypted you may view the HTML form by clicking on the <b>View Clinical Document</b>.</p></div>",
            Label.CONTENT_XHTML);

    vGroup.addComponent(displayAction);/*from w  w w  .  java2s  .  co  m*/

    Button searchBTN = new Button("Search");
    searchBTN.setStyleName(Runo.BUTTON_SMALL);
    searchBTN.setWidth("100");
    content.addComponent(vGroup);
    content.addComponent(searchBTN);

    table = new Table();
    table.setWidth("100%");
    table.setHeight("350px");
    table.setMultiSelect(false);
    table.setSelectable(true);
    table.setImmediate(true); // react at once when something is selected
    table.setEditable(false);
    table.setWriteThrough(true);
    table.setContainerDataSource(populateTable());

    table.setColumnReorderingAllowed(true);
    table.setColumnCollapsingAllowed(false);
    table.setVisibleColumns(new Object[] { "patientId", "docId", "docType", "respId", "msgId" });
    table.setColumnHeaders(
            new String[] { "Patient ID", "Document ID", "Document Type", "Repository", "Message" });

    content.addComponent(table);

    retrieveBTN = new Button("Retrieve Document");
    decryptDocBTN = new Button("Decrypt Document");
    decryptDocMaskBTN = new Button("Decrypt Doc and Entries");
    viewHTMLBTN = new Button("View Clinical Document");
    viewPDFBTN = new Button("Consent PDF");
    viewXACMLBTN = new Button("Consent Policy");
    viewSAMLBTN = new Button("View Authorization (SAML)");
    viewMetaData = new Button("View Meta Data");

    HorizontalComponentGroup hGroup = new HorizontalComponentGroup();
    hGroup.setWidth("100%");

    retrieveBTN.setEnabled(false);
    decryptDocBTN.setEnabled(false);
    decryptDocMaskBTN.setEnabled(false);
    viewHTMLBTN.setEnabled(false);
    viewPDFBTN.setEnabled(false);
    viewXACMLBTN.setEnabled(false);
    viewSAMLBTN.setEnabled(false);
    viewMetaData.setEnabled(false);

    hGroup.addComponent(retrieveBTN);
    hGroup.addComponent(decryptDocBTN);
    hGroup.addComponent(decryptDocMaskBTN);
    hGroup.addComponent(viewHTMLBTN);
    hGroup.addComponent(viewPDFBTN);
    hGroup.addComponent(viewXACMLBTN);
    hGroup.addComponent(viewSAMLBTN);
    hGroup.addComponent(viewMetaData);

    content.addComponent(hGroup);

    searchBTN.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            patientId = AdminContext.getSessionAttributes().getSelectedPatientId();
            patientName = AdminContext.getSessionAttributes().getSelectedPatientName();
            currentDocument = "";
            decryptDocument = "";
            requestedService = "DocQuery";
            //area.setValue(currentDocument);
            //area.setCaption("No Documents Selected");

            String decision = "Permit";
            if (patientId.equals("PUI100015060013")) {
                PolicyEnforcementObject pObj = policyEngine.enforceResouce(
                        AdminContext.getSessionAttributes().getPurposeOfUse(), "PSY", "DocumentQueryOut");
                decision = pObj.getPdpDecision();
            }
            if (decision.equals("Permit")) {
                String res = lookUpPatient();
                metaData = res;
                if (res.indexOf("XDSDocumentEntry.uniqueId") > -1) {
                    AdhocQueryResponse adhoc = getQueryResponse(res);

                    RegistryObjectListType rList = adhoc.getRegistryObjectList();
                    List<ExchangeResults> xList = processMetaData(rList);
                    refreshTable(xList);
                } else {
                    //throw warning 
                    docId = "NA";
                    docType = "NA";
                    messageId = "NA";
                    respId = "1.3.6.1.4.1.21367.2010.1.2.1040";
                    ExchangeResults eR = new ExchangeResults(patientName, patientId, docId, docType, "", "", "",
                            messageId, respId);
                    List<ExchangeResults> xList = new ArrayList();
                    xList.add(eR);
                    refreshTable(xList);
                    displayErrorMessage(res);
                }
                retrieveBTN.setEnabled(false);
                decryptDocBTN.setEnabled(false);
                decryptDocMaskBTN.setEnabled(false);
                viewHTMLBTN.setEnabled(false);
                viewPDFBTN.setEnabled(false);
                viewXACMLBTN.setEnabled(false);
                viewSAMLBTN.setEnabled(true);
                viewMetaData.setEnabled(true);
            } else {
                getWindow().showNotification("Warning",
                        "You do not have the necessary authorization privileges to perform this operation.",
                        Window.Notification.TYPE_WARNING_MESSAGE);
            }
        }
    });

    table.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            Object rowId = table.getValue();
            if (rowId != null) {
                patientName = (String) table.getContainerProperty(rowId, "patientName").getValue();
                patientId = (String) table.getContainerProperty(rowId, "patientId").getValue();
                docId = (String) table.getContainerProperty(rowId, "docId").getValue();
                docType = (String) table.getContainerProperty(rowId, "docType").getValue();
                respId = (String) table.getContainerProperty(rowId, "respId").getValue();
                messageId = (String) table.getContainerProperty(rowId, "msgId").getValue();
                if (docType.equals("Consult Notes")) {
                    retrieveBTN.setEnabled(true);
                    decryptDocBTN.setEnabled(true);
                    decryptDocBTN.setCaption("Decrypt Document");
                    decryptDocMaskBTN.setEnabled(true);
                    viewHTMLBTN.setEnabled(true);
                    viewPDFBTN.setEnabled(false);
                    viewXACMLBTN.setEnabled(false);
                } else if (docType.equals("Consent Notes") || docType.equals("Consult")) {
                    retrieveBTN.setEnabled(true);
                    decryptDocBTN.setEnabled(true);
                    decryptDocBTN.setCaption("Extract Document");
                    decryptDocMaskBTN.setEnabled(false);
                    viewHTMLBTN.setEnabled(true);
                    viewPDFBTN.setEnabled(true);
                    viewXACMLBTN.setEnabled(true);
                } else {
                    getWindow().showNotification("Warning", "Could not determine document type for processing.",
                            Window.Notification.TYPE_WARNING_MESSAGE);
                }
            }

        }
    });

    retrieveBTN.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Object rowId = table.getValue();
            String decision = "Permit";
            if (patientId.equals("PUI100015060013")) {
                PolicyEnforcementObject pObj = policyEngine.enforceResouce(
                        AdminContext.getSessionAttributes().getPurposeOfUse(), "PSY", "DocumentRetrieveOut");
                decision = pObj.getPdpDecision();
            }
            if (decision.equals("Permit")) {
                if (rowId != null) {
                    getDocument();
                    requestedService = "DocRetrieve";
                    System.out.println("CURRENT DOCUMENT SIZE: " + currentDocument.length());
                    Popover popover = getPopoverTextArea(currentDocument, "Document Retrieve Response");
                    popover.showRelativeTo(getNavigationBar());
                } else {
                    getWindow().showNotification("Warning",
                            "No row selected, Please select document for retrieval.",
                            Window.Notification.TYPE_WARNING_MESSAGE);
                }
            } else {
                getWindow().showNotification("Warning",
                        "You do not have the necessary authorization privileges to perform this operation.",
                        Window.Notification.TYPE_WARNING_MESSAGE);
            }
        }
    });

    decryptDocBTN.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (currentDocument.length() == 0) {
                getWindow().showNotification("Warning", "You must select and retrieve document first.",
                        Window.Notification.TYPE_WARNING_MESSAGE);
            } else {

                try {
                    String sOrg = AdminContext.getSessionAttributes().getSelectedOrg();
                    if (sOrg.equals("FEISystems")) {
                        ihe.iti.xds_b._2007.RetrieveDocumentSetResponse xdsbRetrieveDocumentSetResponse = unmarshallFromXml(
                                ihe.iti.xds_b._2007.RetrieveDocumentSetResponse.class, currentDocument);
                        ihe.iti.xds_b._2007.RetrieveDocumentSetResponse.DocumentResponse documentResponse = xdsbRetrieveDocumentSetResponse
                                .getDocumentResponse().get(0);
                        if (docType.equals("Consult Notes")) {
                            byte[] processDocBytes = documentResponse.getDocument();

                            decryptDocument = decryptDocumentExcludeElements(processDocBytes, keyD);
                        } else {
                            byte[] processDocBytes = documentResponse.getDocument();
                            decryptDocument = new String(processDocBytes);
                        }
                    } else {
                        decryptDocument = currentDocument;
                    }
                    Popover popover = getPopoverLabel(convertXMLtoXHTML(decryptDocument),
                            "Decrypted - Document Only");
                    popover.showRelativeTo(getNavigationBar());
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    });

    decryptDocMaskBTN.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (currentDocument.length() == 0) {
                getWindow().showNotification("Warning", "You must select and retrieve document first.",
                        Window.Notification.TYPE_WARNING_MESSAGE);
            } else {
                String decision = "Permit";

                if (patientId.equals("PUI100015060013")) {
                    PolicyEnforcementObject pObj = policyEngine.enforceResouce(
                            AdminContext.getSessionAttributes().getPurposeOfUse(), "PSY",
                            "DocumentEntryUnMask");
                    decision = pObj.getPdpDecision();
                }
                if (decision.equals("Permit")) {
                    try {
                        ihe.iti.xds_b._2007.RetrieveDocumentSetResponse xdsbRetrieveDocumentSetResponse = unmarshallFromXml(
                                ihe.iti.xds_b._2007.RetrieveDocumentSetResponse.class, currentDocument);
                        ihe.iti.xds_b._2007.RetrieveDocumentSetResponse.DocumentResponse documentResponse = xdsbRetrieveDocumentSetResponse
                                .getDocumentResponse().get(0);
                        if (docType.equals("Consult Notes")) {
                            byte[] processDocBytes = documentResponse.getDocument();

                            decryptDocument = decryptDocument(processDocBytes, keyD, keyM);
                        } else {
                            byte[] processDocBytes = documentResponse.getDocument();
                            decryptDocument = new String(processDocBytes);
                        }
                        Popover popover = getPopoverLabel(convertXMLtoXHTML(decryptDocument),
                                "Decrypted - Document and Masked Entries");
                        popover.showRelativeTo(getNavigationBar());
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                } else {
                    getWindow().showNotification("Warning",
                            "You do not have the necessary authorization privileges to perform this operation.",
                            Window.Notification.TYPE_WARNING_MESSAGE);
                }
            }
        }
    });

    viewHTMLBTN.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (decryptDocument.length() == 0) {
                getWindow().showNotification("Warning",
                        "You must select and retrieve document first, then view decrypted version, before attempting to transform it.",
                        Window.Notification.TYPE_WARNING_MESSAGE);
            } else {
                String decision = "Permit";

                if (patientId.equals("PUI100015060013")) {
                    PolicyEnforcementObject pObj = policyEngine.enforceResouce(
                            AdminContext.getSessionAttributes().getPurposeOfUse(), "PSY", "DocumentView");
                    decision = pObj.getPdpDecision();
                }
                if (decision.equals("Permit")) {
                    String sOrg = AdminContext.getSessionAttributes().getSelectedOrg();
                    if (sOrg.equals("FEISystems")) {
                        getWindow().showNotification("Warning", disclosure,
                                Window.Notification.TYPE_WARNING_MESSAGE);
                    }
                    String title = "";
                    if (docType.equals("Consult Notes")) {
                        title = "Summary of Episode - C32";
                    } else if (docType.equals("Consent Notes")) {
                        title = "CDA R2 Consent Directive";
                    } else {
                        title = "Unknown Document Type";
                    }

                    Popover popover = getPopoverLabel(getHTMLVersionOfCDA(decryptDocument), title);
                    popover.showRelativeTo(getNavigationBar());
                } else {
                    getWindow().showNotification("Warning",
                            "You do not have the necessary authorization privileges to perform this operation.",
                            Window.Notification.TYPE_WARNING_MESSAGE);
                }
            }
        }
    });

    viewPDFBTN.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            processPDFForViewing();
        }
    });

    viewXACMLBTN.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            processXACMLForViewing();
        }
    });

    viewSAMLBTN.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            processSAMLForViewing();
        }
    });

    viewMetaData.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            processMetaDataForViewing();
        }
    });

    setContent(content);

}

From source file:gov.va.ds4p.ds4pmobileportal.ui.LoginView.java

License:Open Source License

private Panel getLoginPanel() {
    Panel p = new Panel();
    VerticalLayout v = (VerticalLayout) p.getContent();
    v.setSpacing(true);/*from   w w w  .  ja  v a  2  s. c  o  m*/
    v.setHeight("300px");
    Label sandi = new Label("");
    sandi.setIcon(new ThemeResource("onc_s_and_i_logo.png"));
    v.addComponent(sandi);

    final TextField username = new TextField("User Name:");
    final PasswordField userpass = new PasswordField("Password:");
    username.setWidth("500px");
    userpass.setWidth("500px");
    v.addComponent(username);
    v.addComponent(userpass);

    HorizontalLayout h = new HorizontalLayout();
    h.setSpacing(true);
    h.setWidth("500px");
    Button okBTN = new Button("Ok");
    Label l = new Label("");
    l.setIcon(new ThemeResource("header-logo.png"));
    h.addComponent(okBTN);
    h.addComponent(l);
    v.addComponent(h);
    okBTN.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            userN = (String) username.getValue();
            userP = (String) userpass.getValue();
            authenticate();
            if (userProfile == null) {
                getWindow().showNotification("Login Error", "Incorrect username or password combination.",
                        Window.Notification.TYPE_WARNING_MESSAGE);
            } else {
                AdminContext.getSessionAttributes().setUserProfile(userProfile);
                ((MyVaadinApplication) getApplication()).loginComplete();
            }
        }
    });

    okBTN.setImmediate(true);

    return p;
}

From source file:gov.va.ds4p.ds4pmobileportal.ui.LogoutView.java

License:Open Source License

private void buildView() {
    CssLayout content = new CssLayout();
    content.setWidth("100%");
    setCaption("Logout / End Session");

    VerticalComponentGroup vGroup = new VerticalComponentGroup();
    logoutAction = new Label(
            "<div style='color:#333;'><p>You have requested to end your session, if true continue by clicking the \"Ok\" button.</p></div>",
            Label.CONTENT_XHTML);
    Button okBTN = new Button("Ok");
    okBTN.addListener(new Button.ClickListener() {

        @Override/*from  w  w  w  .j a va2s  .com*/
        public void buttonClick(ClickEvent event) {
            ((MyVaadinApplication) getApplication()).logoutRequest();
        }
    });
    vGroup.addComponent(logoutAction);
    vGroup.addComponent(okBTN);
    content.addComponent(vGroup);
    setContent(content);

}

From source file:gov.va.ehtac.appsonfhir.ui.LogoutView.java

License:Open Source License

private void buildView() {
    CssLayout content = new CssLayout();
    content.setWidth("100%");
    setCaption("Logout / End Session");

    VerticalComponentGroup vGroup = new VerticalComponentGroup();
    logoutAction = new Label(
            "<div style='color:#333;'><p>You have requested to end your session, if true continue by clicking the \"Ok\" button.</p></div>",
            Label.CONTENT_XHTML);
    Button okBTN = new Button("Ok");
    okBTN.addListener(new Button.ClickListener() {

        @Override//w w  w  .  ja  v a2  s.  co m
        public void buttonClick(ClickEvent event) {
            ((HealthElementsTouchKitUI) UI.getCurrent()).getSession().close();
        }
    });
    vGroup.addComponent(logoutAction);
    vGroup.addComponent(okBTN);
    content.addComponent(vGroup);
    setContent(content);

}

From source file:gov.va.ehtac.myappsonfhir.ui.LogoutView.java

License:Open Source License

private void buildView() {
    CssLayout content = new CssLayout();
    content.setWidth("100%");
    setCaption("Logout / End Session");

    VerticalComponentGroup vGroup = new VerticalComponentGroup();
    logoutAction = new Label(
            "<div style='color:#333;'><p>You have requested to end your session, if true continue by clicking the \"Ok\" button.</p></div>",
            Label.CONTENT_XHTML);
    Button okBTN = new Button("Ok");
    okBTN.addListener(new Button.ClickListener() {

        @Override//w w w. ja va  2 s  .c  o m
        public void buttonClick(ClickEvent event) {
            ((HealthElementsForPatientTouchKitUI) UI.getCurrent()).getSession().close();
        }
    });
    vGroup.addComponent(logoutAction);
    vGroup.addComponent(okBTN);
    content.addComponent(vGroup);
    setContent(content);

}

From source file:it.vige.greenarea.bpm.custom.ui.dettaglio.KmlDocumentViewer.java

License:Apache License

public KmlDocumentViewer(String focusedFeature, Coordinate coordinate) {
    super();/*from  w  w  w  . j  av a 2 s. c o  m*/
    setImmediate(true);
    loadDocument();
    setWidth(100, UNITS_PERCENTAGE);
    addComponent(ufu);
    addLayer(osm);
    addLayer(vectorLayer);

    extractStyles(doc);

    displayFeatures(focusedFeature);

    vectorLayer.setSelectionMode(SIMPLE);
    vectorLayer.setImmediate(true);
    vectorLayer.addListener(new VectorSelectedListener() {
        public void vectorSelected(VectorSelectedEvent event) {
            final Area component = (Area) event.getVector();
            final String data = (String) component.getData();

            final Window window = new Window("Details");
            window.getContent().setSizeFull();
            window.setHeight("50%");
            window.setWidth("50%");

            Button button = new Button("Focus this feature");
            button.addListener(new ClickListener() {
                private static final long serialVersionUID = 3286851301965195290L;

                @Override
                public void buttonClick(ClickEvent event) {
                    ufu.setFragment(data);
                    displayFeatures(data);
                    window.getParent().removeWindow(window);
                }
            });
            window.addComponent(button);
            window.setClosable(true);
            window.center();
            getWindow().addWindow(window);
            vectorLayer.setSelectedVector(null);
        }
    });

    if (coordinate != null) {
        // Definig a Marker Layer
        MarkerLayer markerLayer = new MarkerLayer();

        // Defining a new Marker

        final Marker marker = new Marker(coordinate.getLongitude(), coordinate.getLatitude());
        // URL of marker Icon
        marker.setIcon(new ThemeResource("img/marker.png"), 60, 60);
        markerLayer.addComponent(marker);
        addLayer(markerLayer);
        setCenter(coordinate.getLongitude(), coordinate.getLatitude());
    }

}

From source file:it.vige.greenarea.bpm.custom.ui.form.GreenareaAbstractFormPropertyRenderer.java

License:Apache License

protected void addButton(String operation, HorizontalLayout buttons, final String item, final Table table) {
    final String finalOperation = operation;
    final Button button = new Button();
    if (operation.equals(MODIFICA.name()))
        button.setIcon(new ThemeResource("img/edit.png"));
    else if (operation.equals(CANCELLAZIONE.name()))
        button.setIcon(new ThemeResource("img/delete.png"));
    else/*ww  w  .j a  va2 s  . c o  m*/
        button.setIcon(new ThemeResource("img/task-16.png"));
    button.addStyleName(BUTTON_LINK);
    I18nManager i18nManager = get().getI18nManager();
    button.setDescription(i18nManager.getMessage(operation));
    buttons.addComponent(button);
    buttons.setComponentAlignment(button, BOTTOM_RIGHT);
    button.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 {
                table.select(item);
                Map<String, String> formProperties = greenareaFormPropertiesForm
                        .getGreenareaFormPropertiesComponent().getFormPropertyValues();
                setOperation(formProperties, finalOperation);
                greenareaFormPropertiesForm.getMainTitle()
                        .setPropertyDataSource(new ObjectProperty<String>(
                                greenareaFormPropertiesForm.getMainTitle().getValue() + " > " + finalOperation,
                                String.class));
                FormPropertiesEvent formPropertiesEvent = greenareaFormPropertiesForm.new FormPropertiesEvent(
                        greenareaFormPropertiesForm, TYPE_SUBMIT, formProperties);
                greenareaFormPropertiesForm.fireEvent(formPropertiesEvent);
                button.setComponentError(null);
            } catch (InvalidValueException ive) {
                // Error is presented to user by the form component
            }
        }
    });

}

From source file:it.vige.greenarea.bpm.custom.ui.form.GreenareaFormPropertiesForm.java

License:Apache License

private void addButtons() {
    GreenareaFormPropertiesComponent greenareaFormPropertiesComponent = (GreenareaFormPropertiesComponent) formPropertiesComponent;
    List<String> operationsFromRenderers = getOperationsFromRenderers(greenareaFormPropertiesComponent);
    FormProperty operations = greenareaFormPropertiesComponent.getOperations();
    if (operations != null) {
        @SuppressWarnings("unchecked")
        Map<String, String> mapOperations = (Map<String, String>) operations.getType().getInformation("values");

        buttons = new HorizontalLayout();
        buttons.setSpacing(true);/*www . j  a  v a  2s.  co  m*/
        buttons.setWidth(100, UNITS_PERCENTAGE);
        buttons.addStyleName(STYLE_DETAIL_BLOCK);
        for (String operation : mapOperations.keySet()) {
            if (!operationsFromRenderers.contains(operation)) {
                final String finalOperation = operation;
                final Button button = new Button();
                button.setCaption(i18nManager.getMessage(operation));
                buttons.addComponent(button);
                buttons.setComponentAlignment(button, BOTTOM_RIGHT);
                button.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();
                            setOperation(formProperties, finalOperation);
                            mainTitle.setPropertyDataSource(new ObjectProperty<String>(
                                    mainTitle.getValue() + " > " + finalOperation, String.class));
                            fireEvent(new FormPropertiesEvent(GreenareaFormPropertiesForm.this, TYPE_SUBMIT,
                                    formProperties));
                            button.setComponentError(null);
                        } catch (InvalidValueException ive) {
                            // Error is presented to user by the form
                            // component
                        }
                    }
                });
            }
        }

        Label buttonSpacer = new Label();
        buttons.addComponent(buttonSpacer);
        buttons.setExpandRatio(buttonSpacer, 1.0f);
        addComponent(buttons);
    } else {
        submitFormButton = new Button();
        cancelFormButton = new Button();

        HorizontalLayout buttons = new HorizontalLayout();
        buttons.setSpacing(true);
        buttons.setWidth(100, UNITS_PERCENTAGE);
        buttons.addStyleName(STYLE_DETAIL_BLOCK);
        buttons.addComponent(submitFormButton);
        buttons.setComponentAlignment(submitFormButton, BOTTOM_RIGHT);

        // buttons.addComponent(cancelFormButton);
        // buttons.setComponentAlignment(cancelFormButton, BOTTOM_RIGHT);

        Label buttonSpacer = new Label();
        buttons.addComponent(buttonSpacer);
        buttons.setExpandRatio(buttonSpacer, 1.0f);
        addComponent(buttons);
        setSubmitButtonCaption(i18nManager.getMessage(TASK_COMPLETE));
        // setCancelButtonCaption(i18nManager.getMessage(TASK_RESET_FORM));
    }
}

From source file:it.vige.greenarea.bpm.custom.ui.LoginPanel.java

License:Apache License

private void addInputField() {
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);// w  ww  .ja  va  2s.co  m
    layout.setWidth(100, UNITS_PERCENTAGE);
    loginPanel.addComponent(layout);

    Panel textFieldPanel = new Panel(); // Hack: actionHandlers can only be
    // attached to panels or windows
    textFieldPanel.addStyleName(PANEL_LIGHT);
    textFieldPanel.setContent(new VerticalLayout());
    textFieldPanel.setWidth(100, UNITS_PERCENTAGE);
    layout.addComponent(textFieldPanel);
    layout.setExpandRatio(textFieldPanel, 1.0f);

    Label labelUserName = new Label(i18nManager.getMessage(USER_NAME_TITLE));
    labelUserName.addStyleName(LABEL_SMALL);
    userNameInputField = new TextField();
    userNameInputField.setWidth(100, UNITS_PERCENTAGE);
    Label labelPassword = new Label(i18nManager.getMessage(PASSWORD_TITLE));
    labelPassword.addStyleName(LABEL_SMALL);
    passwordInputField = new PasswordField();
    passwordInputField.setWidth(100, UNITS_PERCENTAGE);
    textFieldPanel.addComponent(labelUserName);
    textFieldPanel.addComponent(userNameInputField);
    textFieldPanel.addComponent(labelPassword);
    textFieldPanel.addComponent(passwordInputField);

    // Hack to catch keyboard 'enter'
    textFieldPanel.addActionHandler(new Handler() {
        private static final long serialVersionUID = 6928598745792215505L;

        public void handleAction(Action action, Object sender, Object target) {
            login(userNameInputField.getValue().toString(), passwordInputField.getValue().toString());
        }

        public Action[] getActions(Object target, Object sender) {
            return new Action[] { new ShortcutAction("enter", ENTER, null) };
        }
    });

    Button loginButton = new Button(i18nManager.getMessage(LOGIN));
    layout.addComponent(loginButton);
    layout.setComponentAlignment(loginButton, MIDDLE_LEFT);
    loginButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 7781253151592188006L;

        public void buttonClick(ClickEvent event) {
            login(userNameInputField.getValue().toString(), passwordInputField.getValue().toString());
        }
    });
}

From source file:it.vige.greenarea.bpm.custom.ui.mainlayout.GreenareaMainMenuBar.java

License:Apache License

@Override
protected void initButtons() {
    // TODO: fixed widths based on i18n strings?
    Button homeButton = addMenuButton(MAIN_NAVIGATION_HOME, i18nManager.getMessage(MAIN_MENU_HOME), null, false,
            80);//from  ww w  .  j ava  2s  .  c  om
    homeButton.addListener(new ShowHomeClickListener());
    menuItemButtons.put(MAIN_NAVIGATION_HOME, homeButton);

    if (get().getLoggedInUser().isAdmin()) {

        Button taskButton = addMenuButton(MAIN_NAVIGATION_TASK,
                i18nManager.getMessage(GreenareaMessages.MAIN_MENU_TASKS), null, false, 80);
        taskButton.addListener(new ShowTasksClickListener());
        menuItemButtons.put(MAIN_NAVIGATION_TASK, taskButton);

        Button processButton = addMenuButton(MAIN_NAVIGATION_PROCESS,
                i18nManager.getMessage(GreenareaMessages.MAIN_MENU_PROCESS), null, false, 80);
        processButton.addListener(new ShowProcessDefinitionsClickListener());
        menuItemButtons.put(MAIN_NAVIGATION_PROCESS, processButton);

        Button reportingButton = addMenuButton(MAIN_NAVIGATION_REPORT,
                i18nManager.getMessage(GreenareaMessages.MAIN_MENU_REPORTS), null, false, 80);
        reportingButton.addListener(new ShowReportsClickListener());
        menuItemButtons.put(MAIN_NAVIGATION_REPORT, reportingButton);

        Button manageButton = addMenuButton(MAIN_NAVIGATION_MANAGE,
                i18nManager.getMessage(GreenareaMessages.MAIN_MENU_MANAGEMENT), null, false, 90);
        manageButton.addListener(new ShowManagementClickListener());
        menuItemButtons.put(MAIN_NAVIGATION_MANAGE, manageButton);
    }
}