Example usage for com.vaadin.ui Button setData

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

Introduction

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

Prototype

public void setData(Object data) 

Source Link

Document

Sets the data object, that can be used for any application specific data.

Usage

From source file:com.hybridbpm.ui.component.bpm.OpenCaseColumnGenerator.java

License:Apache License

@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
    Case case1 = (Case) itemId;
    String title = (String) source.getItem(itemId).getItemProperty("caseTitle").getValue();
    Button button = new Button(title, clickListener);
    button.setData(case1);
    button.addStyleName(ValoTheme.BUTTON_LINK);
    button.setDescription("Open case");
    return button;
}

From source file:com.hybridbpm.ui.component.bpm.OpenTaskColumnGenerator.java

License:Apache License

@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
    Task task = (Task) itemId;/* w w w .j a v a2  s. c om*/
    Button button = new Button(task.getTaskTitle(), clickListener);
    button.setData(task);
    button.addStyleName(ValoTheme.BUTTON_LINK);
    button.setDescription("Open task");
    return button;
}

From source file:com.hybridbpm.ui.component.bpm.StartProcessColumnGenerator.java

License:Apache License

@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
    StartProcess spd = (StartProcess) itemId;
    Button button = new Button(spd.getProcessModel().getTitle().getValue(HybridbpmUI.getCurrent().getLocale()),
            clickListener);// w w w  .  j  a  va 2 s . co m
    button.setData(spd);
    button.addStyleName(ValoTheme.BUTTON_LINK);
    button.setIcon(FontAwesome.valueOf(spd.getIcon()));
    button.setDescription("Start case");
    return button;
}

From source file:com.hybridbpm.ui.component.document.DocumentColumnGenerator.java

License:Apache License

@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
    Document document = (Document) itemId;
    Button button = new Button(document.getName());
    button.setData(document);
    button.addStyleName(ValoTheme.BUTTON_LINK);
    if (Objects.equals(document.getType(), Document.TYPE.FILE)) {
        OnDemandFileDownloader onDemandFileDownloader = new OnDemandFileDownloader(document.getId().toString(),
                document.getName());/*  w  ww . ja  v a 2 s. c om*/
        onDemandFileDownloader.extend(button);
        button.setDescription(Translate.getMessage("btnDownload"));
    } else {
        button.setDescription(Translate.getMessage("btnOpen"));
        button.addClickListener(clickListener);
    }
    return button;
}

From source file:com.jiangyifen.ec2.ui.mgr.system.tabsheet.SystemLicence.java

/**
 * added by chb 20140520/*from   ww  w .j av  a 2  s . co m*/
 * @return
 */
private VerticalLayout updateLicenseComponent() {
    VerticalLayout licenseUpdateLayout = new VerticalLayout();
    final VerticalLayout textAreaPlaceHolder = new VerticalLayout();
    final HorizontalLayout buttonPlaceHolder = new HorizontalLayout();
    buttonPlaceHolder.setSpacing(true);

    //
    final Button updateButton = new Button("License");
    updateButton.setData("show");

    //
    final Button cancelButton = new Button("?");

    //
    final TextArea licenseTextArea = new TextArea();
    licenseTextArea.setColumns(30);
    licenseTextArea.setRows(5);
    licenseTextArea.setWordwrap(true);
    licenseTextArea.setInputPrompt("??");

    //Layout
    buttonPlaceHolder.addComponent(updateButton);
    licenseUpdateLayout.addComponent(textAreaPlaceHolder);
    licenseUpdateLayout.addComponent(buttonPlaceHolder);

    //
    cancelButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            textAreaPlaceHolder.removeAllComponents();
            buttonPlaceHolder.removeComponent(cancelButton);
            updateButton.setData("show");
            updateButton.setCaption("License");
        }
    });

    updateButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (((String) event.getButton().getData()).equals("show")) {
                textAreaPlaceHolder.removeAllComponents();
                textAreaPlaceHolder.addComponent(licenseTextArea);
                buttonPlaceHolder.addComponent(cancelButton);
                event.getButton().setData("updateAndHide");
                event.getButton().setCaption("??");
            } else if (((String) event.getButton().getData()).equals("updateAndHide")) {
                StringReader stringReader = new StringReader(
                        StringUtils.trimToEmpty((String) licenseTextArea.getValue()));
                Properties props = new Properties();
                try {
                    props.load(stringReader);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                stringReader.close();
                //               Boolean isValidvalidateLicense(licenseTextArea.getValue());
                String license_date = props.getProperty(LicenseManager.LICENSE_DATE);
                String license_count = props.getProperty(LicenseManager.LICENSE_COUNT);
                String license_localmd5 = props.getProperty(LicenseManager.LICENSE_LOCALMD5);
                //
                Boolean isMatch = regexMatchCheck(license_date, license_count, license_localmd5);
                if (isMatch) {

                    Map<String, String> licenseMap = new HashMap<String, String>();
                    //??
                    //                  String license_count = (String)props.get(LicenseManager.LICENSE_COUNT);
                    license_count = license_count == null ? "" : license_count;
                    licenseMap.put(LicenseManager.LICENSE_COUNT, license_count);

                    //?
                    //                  String license_date = (String)props.get(LicenseManager.LICENSE_DATE);
                    license_date = license_date == null ? "" : license_date;
                    licenseMap.put(LicenseManager.LICENSE_DATE, license_date);

                    //???
                    //                  String license_localmd5 = (String)props.get(LicenseManager.LICENSE_LOCALMD5);
                    license_localmd5 = license_localmd5 == null ? "" : license_localmd5;
                    licenseMap.put(LicenseManager.LICENSE_LOCALMD5, license_localmd5);

                    //?License
                    Map<String, String> resultMap = LicenseManager.licenseValidate(licenseMap);

                    String validateResult = resultMap.get(LicenseManager.LICENSE_VALIDATE_RESULT);
                    if (LicenseManager.LICENSE_VALID.equals(validateResult)) {
                        //continue
                    } else {
                        NotificationUtil.showWarningNotification(SystemLicence.this,
                                "License ?License");
                        return;
                    }

                    try {
                        URL resourceurl = SystemLicence.class.getResource(LicenseManager.LICENSE_FILE);
                        //System.err.println("chb: SystemLicense"+resourceurl.getPath());
                        OutputStream fos = new FileOutputStream(resourceurl.getPath());
                        props.store(fos, "license");
                    } catch (Exception e) {
                        e.printStackTrace();
                        NotificationUtil.showWarningNotification(SystemLicence.this, "License ");
                        return;
                    }
                    textAreaPlaceHolder.removeAllComponents();
                    buttonPlaceHolder.removeComponent(cancelButton);
                    updateButton.setData("show");
                    updateButton.setCaption("License");
                    LicenseManager.loadLicenseFile(LicenseManager.LICENSE_FILE.substring(1));
                    //                  LicenseManager.loadLicenseFile(licenseFilename)
                    refreshLicenseInfo();
                    NotificationUtil.showWarningNotification(SystemLicence.this,
                            "License ?,?");
                } else {
                    NotificationUtil.showWarningNotification(SystemLicence.this,
                            "License ??");
                }
            }
        }

        /**
         * license ?
         * @param license_date
         * @param license_count
         * @param license_localmd5
         * @return
         */
        private Boolean regexMatchCheck(String license_date, String license_count, String license_localmd5) {
            if (StringUtils.isEmpty(license_date) || StringUtils.isEmpty(license_count)
                    || StringUtils.isEmpty(license_localmd5)) {
                return false;
            }
            String date_regex = "^\\d{4}-\\d{2}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2}$"; //?
            String count_regex = "^\\d+$"; //?
            String md5_32_regex = "^\\w{32}$"; //?
            return license_localmd5.matches(md5_32_regex) && license_date.matches(date_regex)
                    && license_count.matches(count_regex);
        }
    });

    return licenseUpdateLayout;
}

From source file:com.liferay.mail.vaadin.Folders.java

License:Open Source License

public void setFolders(List<Folder> folders) {

    for (Folder folder : folders) {
        Button b = new Button(folder.getDisplayName());
        b.setStyleName(BaseTheme.BUTTON_LINK);
        b.setData(folder);
        b.addListener(new ClickListener() {

            public void buttonClick(ClickEvent event) {

                showFolder(((Folder) event.getButton().getData()));
            }//from  www.  j ava  2s . com
        });

    }
}

From source file:com.liferay.mail.vaadin.MessageView.java

License:Open Source License

public void showMessage(Message msg) {

    if (msg == null) {
        messageLabel.setVisible(false);//  w  w w.  ja  va  2 s .c om
        headersAndAttachmentLayout.setVisible(false);
        return;
    } else {
        messageLabel.setVisible(true);
        headersAndAttachmentLayout.setVisible(true);
    }
    // Body
    String text = "";
    if (msg != null) {
        text = msg.getBody();
    }
    messageLabel.setValue(text);

    // Headers
    headersLayout = new FormLayout();
    headersLayout.setSpacing(false);
    headersLayout.setMargin(false);
    if (msg != null) {
        String to = msg.getTo();
        String cc = msg.getCc();
        // String replyTo = msg.get();

        Label subject = new Label(msg.getSubject());
        subject.setCaption(Lang.get("subject"));
        headersLayout.addComponent(subject);

        Label from = new Label(msg.getSender());
        from.setCaption(Lang.get("from"));
        headersLayout.addComponent(from);

        if (to != null && !to.equals("")) {
            Label toLabel = new Label(to);
            toLabel.setCaption(Lang.get("to"));
            headersLayout.addComponent(toLabel);
        }
        if (cc != null && !cc.equals("")) {
            Label ccLabel = new Label(cc);
            ccLabel.setCaption(Lang.get("cc"));
            headersLayout.addComponent(ccLabel);
        }

        Label date = new Label(formatDate(msg.getSentDate()));
        date.setCaption(Lang.get("date"));
        headersLayout.addComponent(date);

        if (MessageUtil.isImportant(msg)) {
            Label flag = new Label(Lang.get("important"));
            flag.setStyleName(MessageList.STYLE_IMPORTANT);
            flag.setCaption(Lang.get("flag"));
            headersLayout.addComponent(flag);

        }
    }

    // Attachments
    try {
        headersAndAttachmentLayout.removeAllComponents();
        headersAndAttachmentLayout.addComponent(headersLayout);

        Controller controller = Controller.get();
        List<Attachment> attachments = AttachmentLocalServiceUtil.getAttachments(msg.getMessageId());
        if (attachments != null && !attachments.isEmpty()) {
            for (Attachment attachment : attachments) {
                Button attachmentDownload = new Button();
                attachmentDownload.setStyleName(BaseTheme.BUTTON_LINK);

                attachmentDownload.setCaption(attachment.getFileName() + " "
                        + MessageUtil.formatSize(attachment.getSize(), controller.getUserLocale()));
                attachmentDownload.setData(attachment);
                attachmentDownload.addListener(this);

                headersAndAttachmentLayout.addComponent(attachmentDownload);
            }
        }
    } catch (SystemException e) {
        _log.debug(e);
    }
}

From source file:com.lst.deploymentautomation.vaadin.page.SettingsView.java

License:Open Source License

private void createView() {
    LspsUI ui = (LspsUI) getUI();/*from  w  w w .  j a  va2  s  . c  o  m*/
    Person user = ui.getUser().getPerson();
    userRights = user.getRights();

    setTitle(ui.getMessage(TITLE));

    Panel panel = new Panel();
    panel.addStyleName("l-border-none");
    setContent(panel);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    panel.setContent(layout);

    //user data and settings will be laid out next to each other
    HorizontalLayout topSection = new HorizontalLayout();
    topSection.setSpacing(true);
    topSection.setWidth("100%");
    layout.addComponent(topSection);

    VerticalLayout userData = createUserDataSection(ui, user);
    topSection.addComponent(userData);
    topSection.setExpandRatio(userData, 1);

    Label spacer = new Label();
    spacer.setWidth("20px");
    topSection.addComponent(spacer);

    VerticalLayout settings = createSettingsSection(ui);
    topSection.addComponent(settings);
    topSection.setExpandRatio(settings, 1);

    //substitution section
    VerticalLayout substitution = createSubstitutionSection(ui, user);
    layout.addComponent(substitution);

    Label spacer2 = new Label();
    spacer2.setHeight("10px");
    layout.addComponent(spacer2);

    //buttons
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    Button saveButton = new Button(ui.getMessage("action.save"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (save()) {
                if (requestReload) {
                    JavaScript.getCurrent().execute("window.location.reload()");
                } else {
                    close();
                }
            }
        }
    });
    saveButton.setData(BUTTON_TYPE_SAVE);
    buttons.addComponent(saveButton);
    Button cancelButton = new Button(ui.getMessage("action.cancel"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    buttons.addComponent(cancelButton);
    layout.addComponent(buttons);
}

From source file:com.selzlein.lojavirtual.vaadin.page.SettingsView.java

License:Open Source License

private void createView() {
    ui = (LspsUI) getUI();//from   w  ww  . jav  a  2s.  c  o m
    user = ui.getUser().getPerson();
    userRights = user.getRights();

    setTitle(ui.getMessage(TITLE));

    Panel panel = new Panel();
    panel.addStyleName("l-border-none");
    setContent(panel);

    VerticalLayout layout = new VerticalLayout();
    layout.addStyleName("l-settings");
    layout.setSizeFull();
    layout.setSpacing(true);
    layout.setMargin(true);
    panel.setContent(layout);

    //user data and settings will be laid out next to each other
    HorizontalLayout topSection = new HorizontalLayout();
    topSection.setSpacing(true);
    topSection.setWidth("100%");
    layout.addComponent(topSection);

    VerticalLayout userData = createUserDataSection(ui, user);
    topSection.addComponent(userData);
    topSection.setExpandRatio(userData, 1);

    Label spacer = new Label();
    spacer.setWidth("20px");
    topSection.addComponent(spacer);

    VerticalLayout settings = createSettingsSection(ui);
    topSection.addComponent(settings);
    topSection.setExpandRatio(settings, 1);

    //substitution section
    VerticalLayout substitution = createSubstitutionSection();
    layout.addComponent(substitution);
    layout.setExpandRatio(substitution, 2);

    //buttons
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    Button saveButton = new Button(ui.getMessage("action.save"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (save()) {
                if (requestReload) {
                    JavaScript.getCurrent().execute("window.location.reload()");
                } else {
                    close();
                }
            }
        }
    });
    saveButton.setData(BUTTON_TYPE_SAVE);
    buttons.addComponent(saveButton);
    Button cancelButton = new Button(ui.getMessage("action.cancel"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    buttons.addComponent(cancelButton);
    layout.addComponent(buttons);
}

From source file:com.skysql.manager.ui.components.ScriptingControlsLayout.java

License:Open Source License

/**
 * Instantiates a new scripting controls layout.
 *
 * @param runningTask the running task/*from  www .  j a  v  a2  s.com*/
 * @param controls the controls
 */
public ScriptingControlsLayout(final RunningTask runningTask, Controls[] controls) {

    addStyleName("scriptingControlsLayout");
    setSizeUndefined();
    setSpacing(true);
    setMargin(true);

    for (Controls control : controls) {
        final Button button = new Button(control.name());
        button.setImmediate(true);
        button.setEnabled(false);
        button.setData(control);
        addComponent(button);
        setComponentAlignment(button, Alignment.MIDDLE_CENTER);
        ctrlButtons.put(control.name(), button);
        button.addClickListener(new Button.ClickListener() {
            private static final long serialVersionUID = 0x4C656F6E6172646FL;

            public void buttonClick(ClickEvent event) {
                event.getButton().setEnabled(false);
                runningTask.controlClicked((Controls) event.getButton().getData());
            }
        });
    }

}