Example usage for com.vaadin.ui Button setDescription

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

Introduction

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

Prototype

public void setDescription(String description) 

Source Link

Document

Sets the component's description.

Usage

From source file:annis.gui.CitationLinkGenerator.java

License:Apache License

@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
    Button btLink = new Button();
    btLink.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    btLink.setIcon(FontAwesome.SHARE_ALT);
    btLink.setDescription("Share query reference link");
    btLink.addClickListener(this);

    if (itemId instanceof DisplayedResultQuery) {
        btLink.addClickListener(new LinkClickListener((DisplayedResultQuery) itemId));
    } else if (itemId instanceof Query) {
        final CitationProvider citationProvider = new CitationProviderForQuery((Query) itemId);
        btLink.addClickListener(new LinkClickListener(citationProvider));
    } else if (itemId instanceof CitationProvider) {
        final CitationProvider citationProvider = (CitationProvider) itemId;
        btLink.addClickListener(new LinkClickListener(citationProvider));
    }/*from  w w  w . j  a  v a  2  s.  co  m*/

    return btLink;
}

From source file:annis.gui.controlpanel.CorpusListPanel.java

License:Apache License

public CorpusListPanel(InstanceConfig instanceConfig, ExampleQueriesPanel autoGenQueries, final AnnisUI ui) {
    this.instanceConfig = instanceConfig;
    this.autoGenQueries = autoGenQueries;
    this.ui = ui;

    final CorpusListPanel finalThis = this;

    setSizeFull();/*from w  w w  .  j a  v a  2  s .c o  m*/

    selectionLayout = new HorizontalLayout();
    selectionLayout.setWidth("100%");
    selectionLayout.setHeight("-1px");
    selectionLayout.setVisible(false);

    Label lblVisible = new Label("Visible: ");
    lblVisible.setSizeUndefined();
    selectionLayout.addComponent(lblVisible);

    cbSelection = new ComboBox();
    cbSelection.setDescription("Choose corpus selection set");
    cbSelection.setWidth("100%");
    cbSelection.setHeight("-1px");
    cbSelection.addStyleName(ValoTheme.COMBOBOX_SMALL);
    cbSelection.setInputPrompt("Add new corpus selection set");
    cbSelection.setNullSelectionAllowed(false);
    cbSelection.setNewItemsAllowed(true);
    cbSelection.setNewItemHandler((AbstractSelect.NewItemHandler) this);
    cbSelection.setImmediate(true);
    cbSelection.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {

            updateCorpusTable();
            updateAutoGeneratedQueriesPanel();

        }
    });

    selectionLayout.addComponent(cbSelection);
    selectionLayout.setExpandRatio(cbSelection, 1.0f);
    selectionLayout.setSpacing(true);
    selectionLayout.setComponentAlignment(cbSelection, Alignment.MIDDLE_RIGHT);
    selectionLayout.setComponentAlignment(lblVisible, Alignment.MIDDLE_LEFT);

    addComponent(selectionLayout);

    txtFilter = new TextField();
    txtFilter.setVisible(false);
    txtFilter.setInputPrompt("Filter");
    txtFilter.setImmediate(true);
    txtFilter.setTextChangeTimeout(500);
    txtFilter.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            BeanContainer<String, AnnisCorpus> availableCorpora = ui.getQueryState().getAvailableCorpora();

            if (textFilter != null) {
                // remove the old filter
                availableCorpora.removeContainerFilter(textFilter);
                textFilter = null;
            }

            if (event.getText() != null && !event.getText().isEmpty()) {
                Set<String> selectedIDs = ui.getQueryState().getSelectedCorpora().getValue();

                textFilter = new SimpleStringFilter("name", event.getText(), true, false);
                availableCorpora.addContainerFilter(textFilter);
                // select the first item
                List<String> filteredIDs = availableCorpora.getItemIds();

                Set<String> selectedAndFiltered = new HashSet<>(selectedIDs);
                selectedAndFiltered.retainAll(filteredIDs);

                Set<String> selectedAndOutsideFilter = new HashSet<>(selectedIDs);
                selectedAndOutsideFilter.removeAll(filteredIDs);

                for (String id : selectedAndOutsideFilter) {
                    tblCorpora.unselect(id);
                }

                if (selectedAndFiltered.isEmpty() && !filteredIDs.isEmpty()) {
                    for (String id : selectedIDs) {
                        tblCorpora.unselect(id);
                    }
                    tblCorpora.select(filteredIDs.get(0));
                }
            }
        }
    });
    txtFilter.setWidth("100%");
    txtFilter.setHeight("-1px");
    txtFilter.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    addComponent(txtFilter);

    pbLoadCorpora = new ProgressBar();
    pbLoadCorpora.setCaption("Loading corpus list...");
    pbLoadCorpora.setIndeterminate(true);
    addComponent(pbLoadCorpora);

    tblCorpora = new Table();

    addComponent(tblCorpora);

    tblCorpora.setVisible(false); // don't show list before it was not loaded
    tblCorpora.setContainerDataSource(ui.getQueryState().getAvailableCorpora());
    tblCorpora.setMultiSelect(true);
    tblCorpora.setPropertyDataSource(ui.getQueryState().getSelectedCorpora());

    tblCorpora.addGeneratedColumn("info", new InfoGenerator());
    tblCorpora.addGeneratedColumn("docs", new DocLinkGenerator());

    tblCorpora.setVisibleColumns("name", "textCount", "tokenCount", "info", "docs");
    tblCorpora.setColumnHeaders("Name", "Texts", "Tokens", "", "");
    tblCorpora.setHeight("100%");
    tblCorpora.setWidth("100%");
    tblCorpora.setSelectable(true);
    tblCorpora.setNullSelectionAllowed(false);
    tblCorpora.setColumnExpandRatio("name", 0.6f);
    tblCorpora.setColumnExpandRatio("textCount", 0.15f);
    tblCorpora.setColumnExpandRatio("tokenCount", 0.25f);
    tblCorpora.addStyleName(ValoTheme.TABLE_SMALL);

    tblCorpora.addActionHandler((Action.Handler) this);
    tblCorpora.setImmediate(true);
    tblCorpora.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            Set selections = (Set) tblCorpora.getValue();
            if (selections.size() == 1 && event.isCtrlKey() && tblCorpora.isSelected(event.getItemId())) {
                tblCorpora.setValue(null);
            }
        }
    });
    tblCorpora.setItemDescriptionGenerator(new TooltipGenerator());
    tblCorpora.addValueChangeListener(new CorpusTableChangedListener(finalThis));

    Button btReload = new Button();
    btReload.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            updateCorpusSetList(false, false);
            Notification.show("Reloaded corpus list", Notification.Type.HUMANIZED_MESSAGE);
        }
    });
    btReload.setIcon(FontAwesome.REFRESH);
    btReload.setDescription("Reload corpus list");
    btReload.addStyleName(ValoTheme.BUTTON_ICON_ONLY);

    selectionLayout.addComponent(btReload);
    selectionLayout.setComponentAlignment(btReload, Alignment.MIDDLE_RIGHT);

    tblCorpora.setSortContainerPropertyId("name");

    setExpandRatio(tblCorpora, 1.0f);

    updateCorpusSetList(true, true);

}

From source file:annis.gui.controlpanel.QueryPanel.java

License:Apache License

public QueryPanel(final AnnisUI ui) {
    super(4, 5);/*from w  w  w  .  j  av  a2s. co m*/
    this.ui = ui;

    this.lastPublicStatus = "Welcome to ANNIS! " + "A tutorial is available on the right side.";

    this.state = ui.getQueryState();

    setSpacing(true);
    setMargin(false);

    setRowExpandRatio(0, 1.0f);
    setColumnExpandRatio(0, 0.0f);
    setColumnExpandRatio(1, 0.1f);
    setColumnExpandRatio(2, 0.0f);
    setColumnExpandRatio(3, 0.0f);

    txtQuery = new AqlCodeEditor();
    txtQuery.setPropertyDataSource(state.getAql());
    txtQuery.setInputPrompt("Please enter AQL query");
    txtQuery.addStyleName("query");
    if (ui.getInstanceFont() == null) {
        txtQuery.addStyleName("default-query-font");
        txtQuery.setTextareaStyle("default-query-font");
    } else {
        txtQuery.addStyleName(Helper.CORPUS_FONT);
        txtQuery.setTextareaStyle(Helper.CORPUS_FONT);
    }

    txtQuery.addStyleName("keyboardInput");
    txtQuery.setWidth("100%");
    txtQuery.setHeight(15f, Unit.EM);
    txtQuery.setTextChangeTimeout(500);

    final VirtualKeyboardCodeEditor virtualKeyboard;
    if (ui.getInstanceConfig().getKeyboardLayout() == null) {
        virtualKeyboard = null;
    } else {
        virtualKeyboard = new VirtualKeyboardCodeEditor();
        virtualKeyboard.setKeyboardLayout(ui.getInstanceConfig().getKeyboardLayout());
        virtualKeyboard.extend(txtQuery);
    }

    txtStatus = new TextArea();
    txtStatus.setValue(this.lastPublicStatus);
    txtStatus.setWidth("100%");
    txtStatus.setHeight(4.0f, Unit.EM);
    txtStatus.addStyleName("border-layout");
    txtStatus.setReadOnly(true);

    piCount = new ProgressBar();
    piCount.setIndeterminate(true);
    piCount.setEnabled(false);
    piCount.setVisible(false);

    btShowResult = new Button("Search");
    btShowResult.setIcon(FontAwesome.SEARCH);
    btShowResult.setWidth("100%");
    btShowResult.addClickListener(new ShowResultClickListener());
    btShowResult.setDescription("<strong>Show Result</strong><br />Ctrl + Enter");
    btShowResult.setClickShortcut(KeyCode.ENTER, ModifierKey.CTRL);
    btShowResult.setDisableOnClick(true);

    VerticalLayout historyListLayout = new VerticalLayout();
    historyListLayout.setSizeUndefined();

    lstHistory = new ListSelect();
    lstHistory.setWidth("200px");
    lstHistory.setNullSelectionAllowed(false);
    lstHistory.setValue(null);
    lstHistory.addValueChangeListener((ValueChangeListener) this);
    lstHistory.setImmediate(true);
    lstHistory.setContainerDataSource(historyContainer);
    lstHistory.setItemCaptionPropertyId("query");
    lstHistory.addStyleName(Helper.CORPUS_FONT);

    Button btShowMoreHistory = new Button("Show more details", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (historyWindow == null) {
                historyWindow = new Window("History");
                historyWindow.setModal(false);
                historyWindow.setWidth("400px");
                historyWindow.setHeight("250px");
            }
            historyWindow.setContent(new HistoryPanel(state.getHistory(), ui.getQueryController()));

            if (UI.getCurrent().getWindows().contains(historyWindow)) {
                historyWindow.bringToFront();
            } else {
                UI.getCurrent().addWindow(historyWindow);
            }
        }
    });
    btShowMoreHistory.setWidth("100%");

    historyListLayout.addComponent(lstHistory);
    historyListLayout.addComponent(btShowMoreHistory);

    historyListLayout.setExpandRatio(lstHistory, 1.0f);
    historyListLayout.setExpandRatio(btShowMoreHistory, 0.0f);

    btHistory = new PopupButton("History");
    btHistory.setContent(historyListLayout);
    btHistory.setDescription("<strong>Show History</strong><br />"
            + "Either use the short overview (arrow down) or click on the button " + "for the extended view.");

    Button btShowKeyboard = null;
    if (virtualKeyboard != null) {
        btShowKeyboard = new Button();
        btShowKeyboard.setWidth("100%");
        btShowKeyboard.setDescription("Click to show a virtual keyboard");
        btShowKeyboard.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        btShowKeyboard.addStyleName(ValoTheme.BUTTON_SMALL);
        btShowKeyboard.setIcon(new ClassResource(VirtualKeyboardCodeEditor.class, "keyboard.png"));
        btShowKeyboard.addClickListener(new ShowKeyboardClickListener(virtualKeyboard));
    }

    Button btShowQueryBuilder = new Button("Query<br />Builder");
    btShowQueryBuilder.setHtmlContentAllowed(true);
    btShowQueryBuilder.addStyleName(ValoTheme.BUTTON_SMALL);
    btShowQueryBuilder.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
    btShowQueryBuilder.setIcon(new ThemeResource("images/tango-icons/32x32/document-properties.png"));
    btShowQueryBuilder.addClickListener(new ShowQueryBuilderClickListener(ui));

    VerticalLayout moreActionsLayout = new VerticalLayout();
    moreActionsLayout.setWidth("250px");
    btMoreActions = new PopupButton("More");
    btMoreActions.setContent(moreActionsLayout);

    //    btShowResultNewTab = new Button("Search (open in new tab)");
    //    btShowResultNewTab.setWidth("100%");
    //    btShowResultNewTab.addClickListener(new ShowResultInNewTabClickListener());
    //    btShowResultNewTab.setDescription("<strong>Show Result and open result in new tab</strong><br />Ctrl + Shift + Enter");
    //    btShowResultNewTab.setDisableOnClick(true);
    //    btShowResultNewTab.setClickShortcut(KeyCode.ENTER, ModifierKey.CTRL, ModifierKey.SHIFT);
    //    moreActionsLayout.addComponent(btShowResultNewTab);

    Button btShowExport = new Button("Export", new ShowExportClickListener(ui));
    btShowExport.setIcon(FontAwesome.DOWNLOAD);
    btShowExport.setWidth("100%");
    moreActionsLayout.addComponent(btShowExport);

    Button btShowFrequency = new Button("Frequency Analysis", new ShowFrequencyClickListener(ui));
    btShowFrequency.setIcon(FontAwesome.BAR_CHART_O);
    btShowFrequency.setWidth("100%");
    moreActionsLayout.addComponent(btShowFrequency);

    /*
     * We use the grid layout for a better rendering efficiency, but this comes
     * with the cost of some complexity when defining the positions of the
     * elements in the layout.
     * 
     * This grid hopefully helps a little bit in understanding the "magic"
     * numbers better.
     * 
     * Q: Query text field
     * QB: Button to toggle query builder // TODO
     * KEY: Button to show virtual keyboard
     * SEA: "Search" button
     * MOR: "More actions" button 
     * HIST: "History" button
     * STAT: Text field with the real status
     * PROG: indefinite progress bar (spinning circle)
     * 
     *   \  0  |  1  |  2  |  3  
     * --+-----+---+---+---+-----
     * 0 |  Q  |  Q  |  Q  | QB 
     * --+-----+-----+-----+-----
     * 1 |  Q  |  Q  |  Q  | KEY 
     * --+-----+-----+-----+-----
     * 2 | SEA | MOR | HIST|     
     * --+-----+-----+-----+-----
     * 3 | STAT| STAT| STAT| PROG
     */
    addComponent(txtQuery, 0, 0, 2, 1);
    addComponent(txtStatus, 0, 3, 2, 3);
    addComponent(btShowResult, 0, 2);
    addComponent(btMoreActions, 1, 2);
    addComponent(btHistory, 2, 2);
    addComponent(piCount, 3, 3);
    addComponent(btShowQueryBuilder, 3, 0);
    if (btShowKeyboard != null) {
        addComponent(btShowKeyboard, 3, 1);
    }

    // alignment
    setRowExpandRatio(0, 0.0f);
    setRowExpandRatio(1, 1.0f);
    setColumnExpandRatio(0, 1.0f);
    setColumnExpandRatio(1, 0.0f);
    setColumnExpandRatio(2, 0.0f);
    setColumnExpandRatio(3, 0.0f);

    //setComponentAlignment(btShowQueryBuilder, Alignment.BOTTOM_CENTER);
}

From source file:annis.gui.docbrowser.DocBrowserTable.java

License:Apache License

private Panel generateVisualizerLinks(String docName) {
    Panel p = new Panel();
    VerticalLayout l = new VerticalLayout();
    p.addStyleName(ChameleonTheme.PANEL_BORDERLESS);

    if (docVisualizerConfig != null) {
        Visualizer[] visualizers = docVisualizerConfig.getVisualizers();

        if (visualizers != null) {
            for (Visualizer visualizer : visualizers) {
                Button openVis = new Button(visualizer.getDisplayName());
                openVis.setDescription("open visualizer with the full text of " + docName);
                openVis.addClickListener(new OpenVisualizerWindow(docName, visualizer, openVis));
                openVis.setStyleName(BaseTheme.BUTTON_LINK);
                openVis.setDisableOnClick(true);
                l.addComponent(openVis);
            }// ww w .  java  2s . c  o  m
        }
    }

    p.setContent(l);
    return p;
}

From source file:com.anphat.list.controller.DialogAddMapStaffCustomerController.java

private void initCustTable(CommonTableFilterPanel filterPanel, boolean isAddTable) {
    filterPanel.getToolbar().setVisible(false);
    if (isAddTable) {
        containerLeft = new BeanItemContainer(CustomerDTO.class);
        tblLeft = filterPanel.getMainTable();
        tableUtils = new TableUtils();
        tableUtils.generateColumn(tblLeft);
        tblLeft.setColumnExpandRatio(Constants.CUSTOMER.NAME, 3);
        tblLeft.setColumnExpandRatio(Constants.CUSTOMER.CODE, 1);
        tblLeft.setColumnWidth(Constants.CHECKBOX_COLUMN, 40);
        CommonFunctionTableFilter.initTable(filterPanel, headerCustLeft, containerLeft, captionCustTable,
                tblSize, langCust);//from w w  w  . jav a2 s .c  om
        tblLeft.setColumnHeader(Constants.CHECKBOX_COLUMN, "");
    } else {
        containerRight = new BeanItemContainer(MapStaffCustomerDTO.class);
        if (!DataUtil.isListNullOrEmpty(lstMapStaffCustomerDTOs)) {
            containerRight.addAll(lstMapStaffCustomerDTOs);
        }
        tblRight = filterPanel.getMainTable();
        tblRight.addGeneratedColumn("delete", new CustomTable.ColumnGenerator() {

            @Override
            public Object generateCell(final CustomTable source, final Object itemId, Object columnId) {
                final MapStaffCustomerDTO sdto = (MapStaffCustomerDTO) itemId;
                if (DataUtil.isStringNullOrEmpty(sdto.getMapId())) {
                    Button btnCancel = new Button(new ThemeResource(Constants.ICON.CANCEL));
                    btnCancel.setDescription(BundleUtils.getString("common.button.cancel"));
                    btnCancel.addStyleName(Constants.ICON.V_LINK);
                    btnCancel.addClickListener(new Button.ClickListener() {

                        @Override
                        public void buttonClick(Button.ClickEvent event) {
                            source.removeItem(itemId);
                            tblRight.resetPage();
                        }
                    });
                    return btnCancel;
                } else {
                    Button btnDelete = new Button(new ThemeResource(Constants.ICON.DELETE));
                    btnDelete.setDescription(BundleUtils.getString("common.button.delete"));
                    btnDelete.addStyleName(Constants.ICON.V_LINK);
                    btnDelete.addClickListener(new Button.ClickListener() {

                        @Override
                        public void buttonClick(Button.ClickEvent event) {
                            ConfirmDialog.show(UI.getCurrent(), BundleUtils.getString("delete.item.title"),
                                    BundleUtils.getString("delete.item.body"), BundleUtils.getString("yes"),
                                    BundleUtils.getString("no"), new ConfirmDialog.Listener() {
                                        @Override
                                        public void onClose(ConfirmDialog dialog) {
                                            if (dialog.isConfirmed()) {
                                                String returnValue = WSMapStaffCustomer
                                                        .deleteMapStaffCustomer(sdto.getMapId());
                                                if (returnValue.equalsIgnoreCase(Constants.SUCCESS)) {
                                                    tblRight.removeItem(itemId);
                                                    tblRight.resetPage();
                                                    Notification.show(BundleUtils.getString("actionSuccess"),
                                                            Notification.Type.HUMANIZED_MESSAGE);
                                                } else {
                                                    Notification.show(BundleUtils.getString("actionFail"),
                                                            Notification.Type.ERROR_MESSAGE);
                                                }
                                            }

                                        }
                                    });
                        }
                    });
                    return btnDelete;
                }
            }
        });
        //            tblRight.addGeneratedColumn("cancel", new CustomTable.ColumnGenerator() {
        //
        //                @Override
        //                public Object generateCell(final CustomTable source, final Object itemId, Object columnId) {
        //                    MapStaffCustomerDTO sdto = (MapStaffCustomerDTO) itemId;
        //                    if (!DataUtil.isStringNullOrEmpty(sdto.getMapId())) {
        //                        return "";
        //                    }
        //                    Button btnCancel = new Button(new ThemeResource(Constants.ICON.CANCEL));
        //                    btnCancel.setDescription(BundleUtils.getString("common.button.cancel"));
        //                    btnCancel.addStyleName(Constants.ICON.V_LINK);
        //                    btnCancel.addClickListener(new Button.ClickListener() {
        //
        //                        @Override
        //                        public void buttonClick(Button.ClickEvent event) {
        //                            source.removeItem(itemId);
        //                            tblRight.resetPage();
        //                        }
        //                    });
        //                    return btnCancel;
        //                }
        //            });
        tblRight.setColumnWidth("delete", 100);
        //            tblRight.setColumnWidth("cancel", 60);
        tblRight.setColumnExpandRatio("custName", 3);
        tblRight.setColumnExpandRatio("custCode", 1);
        CommonFunctionTableFilter.initTable(filterPanel, headerCustRight, containerRight, captionCustTableView,
                tblSize, langCust);
        tblRight.setColumnHeader("delete", BundleUtils.getString("common.button.delete") + "/"
                + BundleUtils.getString("common.button.cancel"));
        //            tblRight.setColumnHeader("cancel", "");
    }
}

From source file:com.anphat.list.controller.ListStaffController.java

private void initTable() {
    itemContainer = new BeanItemContainer<>(StaffDTO.class);
    //add detail link into tblstaff
    tblStaffs.addGeneratedColumn("resetPassword", new CustomTable.ColumnGenerator() {
        @Override/* w ww . jav a 2  s  .co  m*/
        public Object generateCell(CustomTable source, final Object itemId, Object columnId) {
            final Button linkDetails = new Button();
            linkDetails.setIcon(FontAwesome.KEY);
            linkDetails.setStyleName(Runo.BUTTON_LINK);
            linkDetails.addStyleName("v-button-link-left");
            linkDetails.addClickListener(new Button.ClickListener() {

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    final StaffDTO staffDTO = (StaffDTO) itemId;
                    ConfirmDialog.show(UI.getCurrent(), "Reset mt khu",
                            "?t li mt khu mc nh cho ti khon " + staffDTO.getName(),
                            "?ng ", "Hu b?", new ConfirmDialog.Listener() {
                                @Override
                                public void onClose(ConfirmDialog dialog) {
                                    if (dialog.isConfirmed()) {
                                        staffDTO.setPassword(
                                                DataUtil.md5(BundleUtils.getStringCas("password_default")));
                                        // Confirmed to continue
                                        String result = WSStaff.updateStaff(staffDTO);
                                        if (Constants.SUCCESS.equalsIgnoreCase(result)) {
                                            CommonMessages.showMessageUpdateSuccess("pass");
                                        }
                                    }
                                }
                            });
                }
            });
            linkDetails.setDescription(BundleUtils.getString("resetPassword"));
            return linkDetails;
        }
    });
    tblStaffs.addGeneratedColumn("detailRole", new CustomTable.ColumnGenerator() {

        @Override
        public Object generateCell(CustomTable source, final Object itemId, Object columnId) {
            final Button btnAddRole = new Button(BundleUtils.getString("detail.roles"));
            btnAddRole.setStyleName(Runo.BUTTON_LINK);
            btnAddRole.addStyleName("v-button-link-left");
            btnAddRole.addClickListener(new Button.ClickListener() {

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    StaffDTO staffDTO = (StaffDTO) itemId;
                    MapStaffRolesDiaglog diaglog = new MapStaffRolesDiaglog(
                            BundleUtils.getString("map.staff.roles.view"));
                    diaglog.setTblRolesVisiableOnly();

                    MapStaffRolesController controller = new MapStaffRolesController(diaglog);
                    controller.initOnlyView(staffDTO);
                    UI.getCurrent().addWindow(diaglog);
                }
            });
            btnAddRole.setDescription(BundleUtils.getString("lb.header.staff.addCustomer.decr"));
            return btnAddRole;
        }
    });
    //160316 NgocND6 them chuc nang hang hoa quan ly cua tung nhan vien
    tblStaffs.addGeneratedColumn("goodsManage", new CustomTable.ColumnGenerator() {

        @Override
        public Object generateCell(CustomTable source, final Object itemId, Object columnId) {
            final Button linkDetails = new Button(BundleUtils.getString("lb.header.staff.goodsManage"));
            linkDetails.setStyleName(Runo.BUTTON_LINK);
            linkDetails.addStyleName("v-button-link-left");
            linkDetails.addClickListener(new Button.ClickListener() {

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    //                        StaffDTO staffDTO = (StaffDTO) itemId;
                    //                        if (staffDTO.getStatus().equalsIgnoreCase("1")) {
                    //                            getListMapStaffCustomer(staffDTO);
                    //                            if (listMapStaffCustomer != null) {
                    //                                DialogGoodsManagement dialogGoodsManagement = new DialogGoodsManagement(BundleUtils.getString("transfer.goods.manage.managoodsassignstaff"));
                    //                                dialogGoodsManagement.initDialog();
                    //                                DialogGoodsManagementController dgmc = new DialogGoodsManagementController(staffDTO, dialogGoodsManagement);
                    //                                UI.getCurrent().addWindow(dialogGoodsManagement);
                    //                            }else{
                    //                                Notification.show(BundleUtils.getString("transfer.goods.manage.staffdontassigncust"), Notification.Type.WARNING_MESSAGE);
                    //                            }
                    //                        } else {
                    //                            Notification.show(BundleUtils.getString("dept.staff.alert.message.notActive"));
                    //                        }
                }
            });
            linkDetails.setDescription(BundleUtils.getString("lb.header.staff.addCustomer.decr"));
            return linkDetails;
        }
    });
    tableUtils = new TableUtils();
    tableUtils.generateColumn(tblStaffs);
    CommonFunctionTableFilter.initTable(staffTablePanel, headerData, itemContainer, captionfieldsetListStaff, 5,
            "lb.header.staff");
    CommonUtils.convertFieldAppParamTable(tblStaffs, Constants.STAFF.STATUS,
            Constants.APP_PARAMS.COMMON_STATUS);
    CommonUtils.convertFieldAppParamTable(tblStaffs, Constants.STAFF.STAFF_TYPE,
            Constants.APP_PARAMS.STAFF_TYPE);
    //        tblStaffs.setColumnHeader("addStock", BundleUtils.getString("add.staff.for.stock"));

}

From source file:com.bsb.common.vaadin.embed.component.DevApplicationHeader.java

License:Apache License

/**
 * Creates an new instance with the specified {@link EmbedVaadinServer}
 * to manage.//from   w  ww  .  j a  v a 2  s  .  c  om
 *
 * @param server the server to manage
 */
public DevApplicationHeader(final EmbedVaadinServer server) {
    final Button shutdown = new Button("shutdown");
    shutdown.setStyleName(BaseTheme.BUTTON_LINK);
    shutdown.setDescription("Shutdown the embed server and close this tab");
    addComponent(shutdown);
    setComponentAlignment(shutdown, Alignment.MIDDLE_CENTER);

    shutdown.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            // Stop the server in a separate thread.
            final Thread thread = new Thread(new Runnable() {
                public void run() {
                    server.stop();
                }
            });
            // avoid that catalina's WebappClassLoader.clearReferencesThreads warns about the thread because it is
            // part of the web application being stopped.
            thread.setContextClassLoader(null);

            thread.start();

            // Close the browser tab
            getWindow().executeJavaScript("close();");
        }
    });
}

From source file:com.cms.utils.ShortcutUtils.java

public static void setTooltipForButton(Button button, String field) {

    button.setDescription(field);
}

From source file:com.esofthead.mycollab.module.crm.ui.components.CrmPreviewFormControlsGenerator.java

License:Open Source License

public HorizontalLayout createButtonControls(int buttonEnableFlags, final String permissionItem) {

    layout.setStyleName("control-buttons");
    layout.setSpacing(true);//from ww w  . j  a  v a 2s .  c o  m
    layout.setSizeUndefined();

    boolean canRead = true;
    boolean canWrite = true;
    boolean canAccess = true;
    if (permissionItem != null) {
        canRead = AppContext.canRead(permissionItem);
        canWrite = AppContext.canWrite(permissionItem);
        canAccess = AppContext.canAccess(permissionItem);
    }

    MVerticalLayout popupButtonsControl = new MVerticalLayout()
            .withMargin(new MarginInfo(false, true, false, true));

    if ((buttonEnableFlags & ADD_BTN_PRESENTED) == ADD_BTN_PRESENTED) {
        Button addBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ADD),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        optionBtn.setPopupVisible(false);
                        final T item = previewForm.getBean();
                        previewForm.fireAddForm(item);
                    }
                });
        addBtn.setIcon(FontAwesome.PLUS);
        addBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
        addBtn.setEnabled(canWrite);
        layout.addComponent(addBtn);
    }

    if ((buttonEnableFlags & EDIT_BTN_PRESENTED) == EDIT_BTN_PRESENTED) {
        Button editBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        optionBtn.setPopupVisible(false);
                        final T item = previewForm.getBean();
                        previewForm.fireEditForm(item);
                    }
                });
        editBtn.setIcon(FontAwesome.EDIT);
        editBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
        editBtn.setEnabled(canWrite);
        layout.addComponent(editBtn);
    }

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

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        final T item = previewForm.getBean();
                        previewForm.fireDeleteForm(item);
                    }
                });
        deleteBtn.setIcon(FontAwesome.TRASH_O);
        deleteBtn.setStyleName(UIConstants.THEME_RED_LINK);
        layout.addComponent(deleteBtn);
        deleteBtn.setEnabled(canAccess);
    }

    if ((buttonEnableFlags & CLONE_BTN_PRESENTED) == CLONE_BTN_PRESENTED) {
        Button cloneBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLONE),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        optionBtn.setPopupVisible(false);
                        final T item = previewForm.getBean();
                        previewForm.fireCloneForm(item);
                    }
                });
        cloneBtn.setIcon(FontAwesome.ROAD);
        cloneBtn.setStyleName("link");
        popupButtonsControl.addComponent(cloneBtn);
    }

    if ((buttonEnableFlags & HISTORY_BTN_PRESENTED) == HISTORY_BTN_PRESENTED) {
        Button historyBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_HISTORY),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        optionBtn.setPopupVisible(false);
                        previewForm.showHistory();
                    }
                });
        historyBtn.setIcon(FontAwesome.HISTORY);
        historyBtn.setStyleName("link");
        popupButtonsControl.addComponent(historyBtn);
    }

    optionBtn.setContent(popupButtonsControl);

    if ((buttonEnableFlags & CLONE_BTN_PRESENTED) == CLONE_BTN_PRESENTED
            | (buttonEnableFlags & EDIT_BTN_PRESENTED) == EDIT_BTN_PRESENTED) {

        layout.addComponent(optionBtn);
    }

    ButtonGroup navigationBtns = new ButtonGroup();
    navigationBtns.setStyleName("navigation-btns");

    if ((buttonEnableFlags & PREVIOUS_BTN_PRESENTED) == PREVIOUS_BTN_PRESENTED) {
        Button previousItem = new Button(null, new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                final T item = previewForm.getBean();
                previewForm.fireGotoPrevious(item);
            }
        });
        previousItem.setStyleName(UIConstants.THEME_GREEN_LINK);
        previousItem.setIcon(FontAwesome.CHEVRON_LEFT);
        previousItem.setDescription(AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_PREVIOUS_ITEM));
        navigationBtns.addButton(previousItem);
        previousItem.setEnabled(canRead);
    }

    if ((buttonEnableFlags & NEXT_BTN_PRESENTED) == NEXT_BTN_PRESENTED) {
        Button nextItemBtn = new Button(null, new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                final T item = previewForm.getBean();
                previewForm.fireGotoNextItem(item);
            }
        });
        nextItemBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
        nextItemBtn.setIcon(FontAwesome.CHEVRON_RIGHT);
        nextItemBtn.setDescription(AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_NEXT_ITEM));
        navigationBtns.addButton(nextItemBtn);
        nextItemBtn.setEnabled(canRead);
    }

    layout.addComponent(navigationBtns);

    return layout;
}

From source file:com.esofthead.mycollab.module.crm.view.account.AccountListDashlet.java

License:Open Source License

public AccountListDashlet() {
    super("My Accounts", new VerticalLayout());
    tableItem = new AccountTableDisplay(Arrays.asList(AccountTableFieldDef.accountname,
            AccountTableFieldDef.phoneoffice, AccountTableFieldDef.email));

    tableItem.addTableListener(new TableClickListener() {
        private static final long serialVersionUID = 1L;

        @Override//from  w w w. j a va 2s  .c om
        public void itemClick(final TableClickEvent event) {
            final SimpleAccount account = (SimpleAccount) event.getData();
            if ("accountname".equals(event.getFieldName())) {
                EventBusFactory.getInstance()
                        .post(new AccountEvent.GotoRead(AccountListDashlet.this, account.getId()));
            }
        }
    });
    bodyContent.addComponent(tableItem);

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

        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent()
                    .addWindow(new AccountListCustomizeWindow(AccountListDashlet.VIEW_DEF_ID, tableItem));

        }
    });
    customizeViewBtn.setIcon(FontAwesome.ADJUST);
    customizeViewBtn.setDescription("Layout Options");
    customizeViewBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY);

    this.addHeaderElement(customizeViewBtn);
}