Example usage for com.vaadin.ui Button getData

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

Introduction

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

Prototype

public Object getData() 

Source Link

Document

Gets the application specific data.

Usage

From source file:com.esofthead.mycollab.module.file.view.components.ResourcesDisplayComponent.java

License:Open Source License

public ResourcesDisplayComponent(final String rootPath, final Folder rootFolder) {
    this.setSpacing(true);
    this.baseFolder = rootFolder;
    this.rootPath = rootPath;
    externalResourceService = ApplicationContextUtil.getSpringBean(ExternalResourceService.class);
    externalDriveService = ApplicationContextUtil.getSpringBean(ExternalDriveService.class);
    resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class);

    VerticalLayout mainBodyLayout = new VerticalLayout();
    mainBodyLayout.setSpacing(true);/*from  ww w.java2 s . com*/
    mainBodyLayout.addStyleName("box-no-border-left");

    // file breadcrum ---------------------
    HorizontalLayout breadcrumbContainer = new HorizontalLayout();
    breadcrumbContainer.setMargin(false);
    fileBreadCrumb = new FileBreadcrumb(rootPath);
    breadcrumbContainer.addComponent(fileBreadCrumb);
    mainBodyLayout.addComponent(breadcrumbContainer);

    // Construct controllGroupBtn
    controllGroupBtn = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true));

    final Button selectAllBtn = new Button();
    selectAllBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    selectAllBtn.setIcon(FontAwesome.SQUARE_O);
    selectAllBtn.setData(false);
    selectAllBtn.setImmediate(true);
    selectAllBtn.setDescription("Select all");

    selectAllBtn.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (!(Boolean) selectAllBtn.getData()) {
                selectAllBtn.setIcon(FontAwesome.CHECK_SQUARE_O);
                selectAllBtn.setData(true);
                resourcesContainer.setAllValues(true);
            } else {
                selectAllBtn.setData(false);
                selectAllBtn.setIcon(FontAwesome.SQUARE_O);
                resourcesContainer.setAllValues(false);
            }
        }
    });
    controllGroupBtn.with(selectAllBtn).withAlign(selectAllBtn, Alignment.MIDDLE_LEFT);

    Button goUpBtn = new Button("Up");
    goUpBtn.setIcon(FontAwesome.ARROW_UP);

    goUpBtn.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            Folder parentFolder;
            if (baseFolder instanceof ExternalFolder) {
                if (baseFolder.getPath().equals("/")) {
                    parentFolder = baseFolder;
                } else {
                    parentFolder = externalResourceService.getParentResourceFolder(
                            ((ExternalFolder) baseFolder).getExternalDrive(), baseFolder.getPath());
                }
            } else if (!baseFolder.getPath().equals(rootPath)) {
                parentFolder = resourceService.getParentFolder(baseFolder.getPath());
            } else {
                parentFolder = baseFolder;
            }

            resourcesContainer.constructBody(parentFolder);
            baseFolder = parentFolder;
            fileBreadCrumb.gotoFolder(baseFolder);
        }
    });
    goUpBtn.setDescription("Back to parent folder");
    goUpBtn.setStyleName(UIConstants.THEME_BROWN_LINK);
    goUpBtn.setDescription("Go up");

    controllGroupBtn.with(goUpBtn).withAlign(goUpBtn, Alignment.MIDDLE_LEFT);

    ButtonGroup navButton = new ButtonGroup();
    navButton.addStyleName(UIConstants.THEME_BROWN_LINK);
    Button createBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CREATE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    AddNewFolderWindow addnewFolderWindow = new AddNewFolderWindow();
                    UI.getCurrent().addWindow(addnewFolderWindow);
                }
            });
    createBtn.setIcon(FontAwesome.PLUS);
    createBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    createBtn.setDescription("Create new folder");
    createBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(createBtn);

    Button uploadBtn = new Button("Upload", new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            MultiUploadContentWindow multiUploadWindow = new MultiUploadContentWindow();
            UI.getCurrent().addWindow(multiUploadWindow);
        }
    });
    uploadBtn.setIcon(FontAwesome.UPLOAD);
    uploadBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    uploadBtn.setDescription("Upload");

    uploadBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(uploadBtn);

    Button downloadBtn = new Button("Download");

    LazyStreamSource streamSource = new LazyStreamSource() {
        private static final long serialVersionUID = 1L;

        @Override
        protected StreamSource buildStreamSource() {
            Collection<Resource> selectedResources = getSelectedResources();
            return StreamDownloadResourceUtil.getStreamSourceSupportExtDrive(selectedResources);
        }

        @Override
        public String getFilename() {
            Collection<Resource> selectedResources = getSelectedResources();
            return StreamDownloadResourceUtil.getDownloadFileName(selectedResources);
        }
    };
    OnDemandFileDownloader downloaderExt = new OnDemandFileDownloader(streamSource);
    downloaderExt.extend(downloadBtn);

    downloadBtn.setIcon(FontAwesome.DOWNLOAD);
    downloadBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    downloadBtn.setDescription("Download");
    downloadBtn.setEnabled(AppContext.canRead(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(downloadBtn);

    Button moveToBtn = new Button("Move", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            Collection<Resource> selectedResources = getSelectedResources();
            if (CollectionUtils.isNotEmpty(selectedResources)) {
                MoveResourceWindow moveResourceWindow = new MoveResourceWindow(selectedResources);
                UI.getCurrent().addWindow(moveResourceWindow);
            } else {
                NotificationUtil.showWarningNotification("Please select at least one item to move");
            }
        }
    });
    moveToBtn.setIcon(FontAwesome.ARROWS);
    moveToBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    moveToBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    moveToBtn.setDescription("Move to");
    navButton.addButton(moveToBtn);

    Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    Collection<Resource> selectedResources = getSelectedResources();
                    if (CollectionUtils.isEmpty(selectedResources)) {
                        NotificationUtil.showWarningNotification("Please select at least one item to delete");
                    } else {
                        deleteResourceAction();
                    }
                }
            });
    deleteBtn.setIcon(FontAwesome.TRASH_O);
    deleteBtn.addStyleName(UIConstants.THEME_RED_LINK);
    deleteBtn.setDescription("Delete resource");
    deleteBtn.setEnabled(AppContext.canAccess(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));

    navButton.addButton(deleteBtn);
    controllGroupBtn.addComponent(navButton);

    mainBodyLayout.addComponent(controllGroupBtn);

    resourcesContainer = new ResourcesContainer(baseFolder);

    mainBodyLayout.addComponent(resourcesContainer);
    this.addComponent(mainBodyLayout);
}

From source file:com.github.mjvesa.herd.wordset.VaadinWordSet.java

License:Apache License

@Override
public Word[] getWords() {
    return new Word[] {

            new BaseWord("new-button", "", Word.POSTPONED) {

                private static final long serialVersionUID = -2492817908731559368L;

                @Override/* ww  w. j  a  va2 s.  co  m*/
                public void execute(final Interpreter interpreter) {

                    Button b = new Button("", new Button.ClickListener() {
                        private static final long serialVersionUID = -4622489800920283752L;

                        @Override
                        public void buttonClick(ClickEvent event) {
                            Button b = event.getButton();
                            Word command = (Word) b.getData();
                            if (command != null) {
                                interpreter.execute(command);
                            }
                        }
                    });
                    interpreter.pushData(b);
                }
            },

            new BaseWord("set-click-listener", "", Word.POSTPONED) {

                private static final long serialVersionUID = 5749856686458297558L;

                @Override
                public void execute(Interpreter interpreter) {
                    Object o = interpreter.popData();
                    Button b = (Button) interpreter.popData();
                    b.setData(o);
                    interpreter.pushData(b);
                }
            },

            new BaseWord("new-hl", "", Word.POSTPONED) {

                private static final long serialVersionUID = 8813556668649386248L;

                @Override
                public void execute(Interpreter interpreter) {
                    HorizontalLayout hl = new HorizontalLayout();
                    hl.setSpacing(true);
                    interpreter.pushData(hl);
                }
            },

            new BaseWord("new-vl", "", Word.POSTPONED) {

                private static final long serialVersionUID = -1848213448504804229L;

                @Override
                public void execute(Interpreter interpreter) {
                    VerticalLayout vl = new VerticalLayout();
                    vl.setSpacing(true);
                    interpreter.pushData(vl);
                }
            },

            new BaseWord("new-gl", "( x y - gl )", Word.POSTPONED) {

                private static final long serialVersionUID = 4079634885691605257L;

                @Override
                public void execute(Interpreter interpreter) {
                    Integer height = (Integer) interpreter.popData();
                    Integer width = (Integer) interpreter.popData();
                    interpreter.pushData(new GridLayout(width, height));
                }
            },

            new BaseWord("gl-new-line", "", Word.POSTPONED) {

                private static final long serialVersionUID = 975877390052961807L;

                @Override
                public void execute(Interpreter interpreter) {
                    ((GridLayout) interpreter.peekData()).newLine();
                }
            },

            new BaseWord("new-window", "", Word.POSTPONED) {

                private static final long serialVersionUID = -6887364362728545090L;

                @Override
                public void execute(Interpreter interpreter) {
                    Window w = new Window();
                    VerticalLayout vl = new VerticalLayout();
                    vl.setSpacing(true);
                    w.setContent(vl);
                    interpreter.pushData(w);
                    interpreter.pushData(vl);
                }
            },

            new BaseWord("main-panel", "", Word.POSTPONED) {

                private static final long serialVersionUID = -8622281600566696475L;

                @Override
                public void execute(Interpreter interpreter) {
                    interpreter.pushData(interpreter.getMainPanel());
                }
            },

            new BaseWord("add-window", "", Word.POSTPONED) {

                private static final long serialVersionUID = 7106029415576813922L;

                @Override
                public void execute(Interpreter interpreter) {
                    Window w = (Window) interpreter.popData();
                    interpreter.getView().getUI().addWindow(w);
                }
            },

            new BaseWord("add-component", "", Word.POSTPONED) {

                private static final long serialVersionUID = 5640824046985354091L;

                @Override
                public void execute(Interpreter interpreter) {
                    Component comp = (Component) interpreter.popData();
                    ComponentContainer cc = (ComponentContainer) interpreter.popData();
                    cc.addComponent(comp);
                    interpreter.pushData(cc);
                }
            },

            new BaseWord("set-caption", "", Word.POSTPONED) {

                private static final long serialVersionUID = 5497598050469462487L;

                @Override
                public void execute(Interpreter interpreter) {
                    String s = (String) interpreter.popData();
                    Component c = (Component) interpreter.popData();
                    c.setCaption(s);
                    interpreter.pushData(c);
                }
            },

            new BaseWord("set-value", "", Word.POSTPONED) {

                private static final long serialVersionUID = -1769743552659215058L;

                @Override
                public void execute(Interpreter interpreter) {
                    Object o = interpreter.popData();
                    Property p = (Property) interpreter.popData();
                    p.setValue(o);
                    interpreter.pushData(p);
                }
            },

            new BaseWord("get-value", "", Word.POSTPONED) {

                private static final long serialVersionUID = 8445550546521886374L;

                @Override
                public void execute(Interpreter interpreter) {
                    Field f = (Field) interpreter.popData();
                    interpreter.pushData(f);
                    interpreter.pushData(f.getValue());

                }
            },

            new BaseWord("set-size-full", "", Word.POSTPONED) {

                private static final long serialVersionUID = -1206491811133054467L;

                @Override
                public void execute(Interpreter interpreter) {
                    Component comp = (Component) interpreter.popData();
                    comp.setSizeFull();
                    interpreter.pushData(comp);
                }
            },

            new BaseWord("set-size-undefined", "", Word.POSTPONED) {

                private static final long serialVersionUID = -3450618729379622987L;

                @Override
                public void execute(Interpreter interpreter) {
                    Component comp = (Component) interpreter.popData();
                    comp.setSizeUndefined();
                    interpreter.pushData(comp);
                }
            },

            new BaseWord("set-height", "", Word.POSTPONED) {

                private static final long serialVersionUID = -8426734568403715950L;

                @Override
                public void execute(Interpreter interpreter) {
                    String str = (String) interpreter.popData();
                    Component comp = (Component) interpreter.popData();
                    comp.setHeight(str);
                    interpreter.pushData(comp);
                }
            },

            new BaseWord("set-width", "", Word.POSTPONED) {

                private static final long serialVersionUID = -4558264143049463814L;

                @Override
                public void execute(Interpreter interpreter) {
                    String str = (String) interpreter.popData();
                    Component comp = (Component) interpreter.popData();
                    comp.setWidth(str);
                    interpreter.pushData(comp);
                }
            },

            new BaseWord("clear-container", "", Word.POSTPONED) {

                private static final long serialVersionUID = 1070175466682034329L;

                @Override
                public void execute(Interpreter interpreter) {
                    ComponentContainer cc = (ComponentContainer) interpreter.popData();
                    cc.removeAllComponents();
                }
            },

            new BaseWord("new-check-box", "", Word.POSTPONED) {

                private static final long serialVersionUID = 4018632924389912599L;

                @Override
                public void execute(Interpreter interpreter) {
                    interpreter.pushData(new CheckBox());
                }
            },

            new BaseWord("new-date-field", "", Word.POSTPONED) {

                private static final long serialVersionUID = 6313296566085274642L;

                @Override
                public void execute(final Interpreter interpreter) {
                    interpreter.pushData(new DateField());
                    final String dfCommand = (String) interpreter.popData();
                    DateField df = new DateField();
                    df.setImmediate(true);
                    df.addValueChangeListener(new ValueChangeListener() {
                        /**
                        * 
                        */
                        private static final long serialVersionUID = 1472139878970514093L;

                        public void valueChange(ValueChangeEvent event) {
                            interpreter.pushData(event.getProperty().getValue());
                            interpreter.interpret(dfCommand);
                        }

                    });
                    interpreter.pushData(df);
                }
            },

            new BaseWord("new-label", "", Word.POSTPONED) {

                private static final long serialVersionUID = -2825285195439247251L;

                @Override
                public void execute(Interpreter interpreter) {
                    interpreter.pushData(new Label());
                }
            },

            new BaseWord("new-text-field", "", Word.POSTPONED) {

                private static final long serialVersionUID = -1064489458253275380L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String tfCommand = interpreter.getNextNonNopWord();
                    TextField tf = new TextField();
                    tf.setCaption((String) interpreter.popData());
                    tf.setValue("");
                    tf.setImmediate(true);
                    tf.addValueChangeListener(new ValueChangeListener() {
                        private static final long serialVersionUID = 4325104922208051065L;

                        public void valueChange(ValueChangeEvent event) {
                            interpreter.pushData(event.getProperty().getValue());
                            interpreter.interpret(tfCommand);
                        }
                    });
                    interpreter.pushData(tf);
                }
            },

            new BaseWord("new-table", "", Word.POSTPONED) {

                private static final long serialVersionUID = -5052653341575232035L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String tableCommand = interpreter.getParser().getNextWord();
                    Table table = new Table();
                    table.setCaption((String) interpreter.popData());
                    table.setImmediate(true);
                    table.setSelectable(true);
                    table.addItemClickListener(new ItemClickListener() {

                        /**
                        *
                        */
                        private static final long serialVersionUID = 3585546076571010729L;

                        public void itemClick(ItemClickEvent event) {

                            interpreter.pushData(event.getItem());
                            interpreter.execute(interpreter.getDictionary().get(tableCommand));
                        }
                    });
                    interpreter.pushData(table);
                }
            },

            new BaseWord("new-combo-box", "", Word.POSTPONED) {

                private static final long serialVersionUID = 3881577354424928897L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String newItemCommand = interpreter.getParser().getNextWord();
                    final String itemSelectedCommand = interpreter.getParser().getNextWord();
                    final ComboBox cb = new ComboBox();
                    String str = (String) interpreter.popData();
                    cb.setNullSelectionAllowed(false);
                    cb.setCaption(str);
                    cb.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM);
                    cb.setNewItemsAllowed(true);
                    cb.setNewItemHandler(new NewItemHandler() {

                        /**
                        *
                        */
                        private static final long serialVersionUID = 3340658590351611289L;

                        public void addNewItem(String newItemCaption) {
                            cb.setImmediate(false);
                            interpreter.pushData(newItemCaption);
                            interpreter.interpret(newItemCommand);
                            cb.setImmediate(true);
                        }
                    });

                    cb.addValueChangeListener(new ValueChangeListener() {

                        /**
                        *
                        */
                        private static final long serialVersionUID = 2706579869793251379L;

                        public void valueChange(ValueChangeEvent event) {
                            interpreter.pushData(
                                    cb.getContainerDataSource().getItem(event.getProperty().getValue()));
                            interpreter.interpret(itemSelectedCommand);
                        }
                    });
                    cb.setImmediate(true);
                    interpreter.pushData(cb);
                }
            },

            new BaseWord("new-select", "", Word.POSTPONED) {

                private static final long serialVersionUID = -6142351970812196488L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String selCommand = interpreter.getParser().getNextWord();
                    final ComboBox sel = new ComboBox();
                    sel.setCaption((String) interpreter.popData());
                    sel.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM);
                    sel.setNullSelectionAllowed(false);
                    sel.setImmediate(true);
                    sel.addValueChangeListener(new ValueChangeListener() {
                        /**
                        *
                        */
                        private static final long serialVersionUID = -7705548618092166199L;

                        public void valueChange(ValueChangeEvent event) {
                            Item item = sel.getContainerDataSource().getItem(event.getProperty().getValue());
                            interpreter.pushData(item);
                            interpreter.interpret(selCommand);
                        }
                    });
                    interpreter.pushData(sel);
                }
            },

            new BaseWord("new-list-select", "", Word.POSTPONED) {
                private static final long serialVersionUID = 8686093227035249035L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String lselCommand = interpreter.getParser().getNextWord();
                    final ListSelect lsel = new ListSelect();
                    lsel.setCaption((String) interpreter.popData());
                    lsel.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM);
                    lsel.setNullSelectionAllowed(false);
                    lsel.setImmediate(true);
                    lsel.addValueChangeListener(new ValueChangeListener() {
                        private static final long serialVersionUID = -5523488417834167806L;

                        public void valueChange(ValueChangeEvent event) {
                            Item item = lsel.getContainerDataSource().getItem(event.getProperty().getValue());
                            interpreter.pushData(item);
                            interpreter.interpret(lselCommand);
                        }
                    });
                    interpreter.pushData(lsel);
                }
            },

            new BaseWord("set-container-data-source", "", Word.POSTPONED) {
                private static final long serialVersionUID = 8644721936358613031L;

                @Override
                public void execute(Interpreter interpreter) {
                    Container cont = (Container) interpreter.popData();
                    AbstractSelect as = (AbstractSelect) interpreter.popData();
                    as.setContainerDataSource(cont);
                    interpreter.pushData(as);
                }
            },

            new BaseWord("set-column-headers", "", Word.POSTPONED) {
                private static final long serialVersionUID = -7296881714369214846L;

                @Override
                public void execute(Interpreter interpreter) {
                    Table table = (Table) interpreter.popData();
                    table.setColumnHeaders((String[]) getArrayFromList(interpreter, new String[0]));
                }
            },

            new BaseWord("set-visible-columns", "", Word.POSTPONED) {
                private static final long serialVersionUID = 5674765074478598320L;

                @Override
                public void execute(Interpreter interpreter) {
                    Table table = (Table) interpreter.popData();
                    table.setVisibleColumns((String[]) getArrayFromList(interpreter, new String[0]));
                }
            }

    };
}

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

License:Open Source License

public void buttonClick(ClickEvent event) {

    Button b = event.getButton();
    Object data = b.getData();
    if (data != null && data instanceof Attachment) {
        final Attachment attachment = (Attachment) data;
        try {//from w  w w. ja  v a2 s. c o  m
            final AttachmentHandler handler = Controller.get().getMailManager()
                    .getAttachment(attachment.getAttachmentId());
            StreamResource r = new StreamResource(new StreamResource.StreamSource() {
                public InputStream getStream() {

                    return handler.getInputStream();
                }

            }, attachment.getFileName(), Controller.get().getApplication());

            String contentType = MimeTypesUtil.getContentType(attachment.getFileName());
            r.setMIMEType(contentType);

            Controller.get().getApplication().getMainWindow().open(r);
        } catch (PortalException e) {
            Controller.get().showError(Lang.get("unable-to-fetch-attachment"), e);
        } catch (SystemException e) {
            Controller.get().showError(Lang.get("unable-to-fetch-attachment"), e);
        } catch (IOException e) {
            Controller.get().showError(Lang.get("unable-to-fetch-attachment"), e);
        }
    }
}

From source file:com.skysql.manager.ui.MonitorsLayout.java

License:Open Source License

/**
 * Adds a new monitor row.// w w  w.j a v a 2  s .c  om
 *
 * @param monitorID the monitor id
 * @return the component
 */
private Component addRow(String monitorID) {
    HorizontalLayout row = new HorizontalLayout();
    ComboBox selectMonitor = new ComboBox();
    for (MonitorRecord availMonitor : availableMonitors.values()) {
        selectMonitor.addItem(availMonitor.getID());
        selectMonitor.setItemCaption(availMonitor.getID(), availMonitor.getName());
    }
    row.addComponent(selectMonitor);
    selectMonitorList.add(selectMonitor);

    selectMonitor.setValue(monitorID);
    selectMonitor.setNullSelectionAllowed(false);
    selectMonitor.setImmediate(true);
    selectMonitor.addValueChangeListener(monitorSelectListener);

    if (getComponentCount() > componentIndex) {
        Button deleteButton = new Button("X");
        row.addComponent(deleteButton);
        deleteButton.setData(selectMonitor);
        deleteButton.addClickListener(new Button.ClickListener() {
            private static final long serialVersionUID = 0x4C656F6E6172646FL;

            public void buttonClick(ClickEvent event) {
                // remove combobox from list
                Button button = event.getButton();
                ComboBox select = (ComboBox) button.getData();
                selectMonitorList.remove(select);

                // remove layout from dialog
                int layoutIndex = getComponentIndex(button.getParent());
                HorizontalLayout layout = (HorizontalLayout) getComponent(layoutIndex);
                removeComponent(layout);

                refreshMonitors();
            }
        });
    }

    focus();

    return (row);

}

From source file:de.steinwedel.messagebox.MessageBox.java

License:Apache License

/**
 * Adds a button. If an event listener (java.lang.Runnable) should be applied, the Runnable must be
 * assigned to the object attribute data.
 *
 * @param button  The button/*from  w  ww.ja v a2s .c  o  m*/
 * @param options Some optional {@link ButtonOption}s
 * @return The {@link MessageBox} instance
 */
public MessageBox withButton(Button button, ButtonOption... options) {
    if (immutable) {
        throw new IllegalStateException(
                "The dialog cannot be enhanced with a button after it has been opened.");
    }
    if (button != null) {
        buttonLayout.addComponent(button);

        buttonAdded = true;

        if (button.getData() != null && button.getData() instanceof Runnable) {
            button.addClickListener(new ClickListener() {

                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    Runnable runnable = (Runnable) event.getButton().getData();
                    runnable.run();
                }

            });
        }

        boolean autoCloseNotFound = true;
        for (ButtonOption option : options) {
            option.apply(this, button);
            if (option instanceof ButtonOption.CloseOnClick) {
                autoCloseNotFound = false;
            }
        }
        if (autoCloseNotFound) {
            new ButtonOption.CloseOnClick(true).apply(this, button);
        }
    }
    return this;
}

From source file:fr.amapj.view.views.producteur.livraison.ProducteurLivraisonsView.java

License:Open Source License

public void buttonClick(Label detail, Button b, Long idModeleContratDate) {
    boolean status = (Boolean) b.getData();
    status = !status;/*from w  w w. j a v a  2  s.  c  om*/
    b.setData(status);

    if (status) {
        //
        b.setCaption("Masquer le dtail par amapien");
        b.setIcon(FontAwesome.CHEVRON_UP);
        //
        String content = new GestionContratService().getDetailContrat(idModeleContratDate);
        detail.setValue("<br/>" + content);
    } else {
        //
        b.setCaption("Voir le dtail par amapien");
        b.setIcon(FontAwesome.CHEVRON_DOWN);
        //
        detail.setValue("");
    }
}

From source file:jp.primecloud.auto.ui.ServiceTable.java

License:Open Source License

void loadBalancerButtonClick(ClickEvent event) {
    Button btn = event.getButton();
    LoadBalancerDto dto = (LoadBalancerDto) btn.getData();

    MyCloudTabs myCloudTabs = null;/*from w ww.j av  a 2  s.c  o m*/
    Component c = ServiceTable.this;
    while (c != null) {
        if (c instanceof MyCloudTabs) {
            myCloudTabs = (MyCloudTabs) c;
            break;
        }
        c = c.getParent();
    }
    //??
    myCloudTabs.loadBalancerTable.select(dto);
    //?Tab?
    myCloudTabs.tabDesc.setSelectedTab(myCloudTabs.pnLoadBalancer);
}

From source file:org.eclipse.hawkbit.ui.artifacts.smtype.filter.SMTypeFilterButtonClick.java

License:Open Source License

@Override
protected void filterClicked(final Button clickedButton) {
    softwareModuleTypeManagement.getByName(clickedButton.getData().toString()).ifPresent(softwareModuleType -> {
        artifactUploadState.getSoftwareModuleFilters().setSoftwareModuleType(softwareModuleType);
        eventBus.publish(this, new RefreshSoftwareModuleByFilterEvent());
    });//www  .ja v a  2s .  c  o m
}

From source file:org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons.java

License:Open Source License

private DragAndDropWrapper addGeneratedCell(final Object itemId) {

    final Item item = getItem(itemId);
    final Long id = (Long) item.getItemProperty(SPUILabelDefinitions.VAR_ID).getValue();
    final String name = (String) item.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
    final String desc = (String) item.getItemProperty(SPUILabelDefinitions.VAR_DESC).getValue() != null
            ? item.getItemProperty(SPUILabelDefinitions.VAR_DESC).getValue().toString()
            : null;//from   w  ww.  j  av a 2 s.  co  m
    final String color = (String) item.getItemProperty(SPUILabelDefinitions.VAR_COLOR).getValue() != null
            ? item.getItemProperty(SPUILabelDefinitions.VAR_COLOR).getValue().toString()
            : DEFAULT_GREEN;
    final Button typeButton = createFilterButton(id, name, desc, color, itemId);
    typeButton.addClickListener(filterButtonClickBehaviour::processFilterButtonClick);

    if ((NO_TAG_BUTTON_ID.equals(typeButton.getData()) && isNoTagStateSelected())
            || (id != null && isClickedByDefault(name))) {
        filterButtonClickBehaviour.setDefaultClickedButton(typeButton);
    }

    return createDragAndDropWrapper(typeButton, name, id);
}

From source file:org.eclipse.hawkbit.ui.distributions.disttype.DSTypeFilterButtonClick.java

License:Open Source License

@Override
protected void filterClicked(final Button clickedButton) {
    distributionSetTypeManagement.getByName(clickedButton.getData().toString())
            .ifPresent(manageDistUIState.getManageDistFilters()::setClickedDistSetType);
    eventBus.publish(this, new RefreshDistributionTableByFilterEvent());
}