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.etest.view.testbank.cellitem.CellCaseItemWindow.java

Table populateDataTable() {
    table.removeAllItems();//  w w w. j  a v a 2 s .c  o  m
    int i = 0;
    for (CellItem ci : cis.getCellItemByCase(getCellCaseId())) {
        VerticalLayout v = new VerticalLayout();
        v.setSizeFull();

        Button edit = new Button("modify");
        edit.setWidth("100%");
        edit.setData(ci.getCellItemId());
        edit.setIcon(FontAwesome.PENCIL);
        edit.addStyleName(ValoTheme.BUTTON_LINK);
        edit.addStyleName(ValoTheme.BUTTON_TINY);
        edit.addStyleName(ValoTheme.BUTTON_QUIET);
        edit.addClickListener(modifyBtnClickListener);
        v.addComponent(edit);
        v.setComponentAlignment(edit, Alignment.MIDDLE_LEFT);

        Button approve = new Button("status");
        approve.setWidth("100%");
        approve.setData(ci.getCellItemId());
        approve.addStyleName(ValoTheme.BUTTON_LINK);
        approve.addStyleName(ValoTheme.BUTTON_TINY);
        approve.addStyleName(ValoTheme.BUTTON_QUIET);
        v.addComponent(approve);
        v.setComponentAlignment(approve, Alignment.MIDDLE_LEFT);

        Button view = new Button("view");
        view.setWidth("100%");
        view.setData(ci.getCellItemId());
        view.setIcon(FontAwesome.PLAY_CIRCLE);
        view.addStyleName(ValoTheme.BUTTON_LINK);
        view.addStyleName(ValoTheme.BUTTON_TINY);
        view.addStyleName(ValoTheme.BUTTON_QUIET);
        view.addClickListener(modifyBtnClickListener);
        v.addComponent(view);
        v.setComponentAlignment(view, Alignment.MIDDLE_LEFT);

        if (ci.getApproveItemStatus() == 0) {
            approve.setIcon(FontAwesome.THUMBS_DOWN);
        } else {
            approve.setIcon(FontAwesome.THUMBS_UP);
        }

        Label label = new Label(ci.getItem());
        label.setStyleName("label-padding");

        table.addItem(new Object[] { ci.getCellItemId(), label, v }, i);
        i++;
    }
    table.setPageLength(table.size());

    return table;
}

From source file:com.etest.view.testbank.cellitem.ViewStemWindow.java

Table populateDataTable() {
    table.removeAllItems();/*from   w  ww. j  a  va 2  s. co m*/
    int i = 0;
    for (ItemKeys key : k.getItemKeysByCellItemId(getCellItemId())) {
        Button delete = new Button("remove");
        delete.setWidth("100%");
        delete.setData(key.getItemKeyId());
        delete.setIcon(FontAwesome.TRASH_O);
        delete.addStyleName(ValoTheme.BUTTON_LINK);
        delete.addStyleName(ValoTheme.BUTTON_TINY);
        delete.addStyleName(ValoTheme.BUTTON_QUIET);
        delete.addClickListener(removeBtnClickListener);

        table.addItem(new Object[] { key.getItemKey(), key.getAnswer(), delete }, i);
        i++;
    }
    table.setPageLength(table.size());

    return table;
}

From source file:com.etest.view.tq.itemanalysis.TQItemAnalysisUI.java

public Table populateDataTable() {
    removeAllItems();//from   w w  w.j  a  va2 s. c  om
    int i = 0;
    for (TQCoverage t : tq.getAllTQCoverage()) {
        VerticalLayout v = new VerticalLayout();
        v.setWidth("100%");

        Button analyze = new Button();
        analyze.setWidthUndefined();
        analyze.setData(t.getTqCoverageId());
        analyze.setCaption((t.getAnalyzed() == 0) ? "Unanalyze" : "Analyzed");
        analyze.setIcon(FontAwesome.BULLSEYE);
        analyze.addStyleName(ValoTheme.BUTTON_LINK);
        analyze.addStyleName(ValoTheme.BUTTON_TINY);
        analyze.addStyleName(ValoTheme.BUTTON_QUIET);
        analyze.addStyleName("button-container");
        analyze.setEnabled(t.getAnalyzed() == 0);
        analyze.addClickListener(buttonClickListener);
        v.addComponent(analyze);
        v.setComponentAlignment(analyze, Alignment.MIDDLE_LEFT);

        Button view = new Button("View");
        view.setWidthUndefined();
        view.setData(t.getTqCoverageId());
        view.setIcon(FontAwesome.VIDEO_CAMERA);
        view.addStyleName(ValoTheme.BUTTON_LINK);
        view.addStyleName(ValoTheme.BUTTON_TINY);
        view.addStyleName(ValoTheme.BUTTON_QUIET);
        view.addStyleName("button-container");
        view.setVisible((t.getAnalyzed() != 0));
        view.addClickListener(buttonClickListener);
        v.addComponent(view);
        v.setComponentAlignment(view, Alignment.MIDDLE_LEFT);

        addItem(new Object[] { t.getExamTitle(), cs.getCurriculumById(t.getCurriculumId()).getSubject(),
                t.getDateCreated(), t.getTotalHoursCoverage(), t.getTotalItems(), v }, i);
        i++;
    }
    setPageLength(size());

    return this;
}

From source file:com.etest.view.tq.TQListUI.java

public Table populateDataTable() {
    removeAllItems();/* ww  w.ja v a2  s .co m*/
    int i = 0;
    for (TQCoverage t : tq.getAllTQCoverage()) {
        VerticalLayout v = new VerticalLayout();
        v.setWidth("100%");

        Button view = new Button("view");
        view.setSizeFull();
        view.setData(t.getTqCoverageId());
        view.setIcon(FontAwesome.VIDEO_CAMERA);
        view.addStyleName(ValoTheme.BUTTON_LINK);
        view.addStyleName(ValoTheme.BUTTON_TINY);
        view.addStyleName(ValoTheme.BUTTON_QUIET);
        view.addStyleName("button-container");
        view.addClickListener(remarksBtnClickListener);
        v.addComponent(view);
        v.setComponentAlignment(view, Alignment.MIDDLE_LEFT);

        Button approve = new Button("status");
        approve.setSizeFull();
        approve.setData(t.getTqCoverageId());
        approve.addStyleName(ValoTheme.BUTTON_LINK);
        approve.addStyleName(ValoTheme.BUTTON_TINY);
        approve.addStyleName(ValoTheme.BUTTON_QUIET);
        approve.addStyleName("button-container");
        v.addComponent(approve);
        v.setComponentAlignment(approve, Alignment.MIDDLE_LEFT);

        //            Button print = new Button("print");
        //            print.setSizeFull();
        //            print.setData(t.getTqCoverageId());  
        //            print.setIcon(FontAwesome.PRINT);
        //            print.addStyleName(ValoTheme.BUTTON_LINK);
        //            print.addStyleName(ValoTheme.BUTTON_TINY);
        //            print.addStyleName(ValoTheme.BUTTON_QUIET);
        //            print.addStyleName("button-container");
        //            print.addClickListener(remarksBtnClickListener);
        //            v.addComponent(print);
        //            v.setComponentAlignment(print, Alignment.MIDDLE_LEFT);

        if (t.getStatus() == 0) {
            approve.setIcon(FontAwesome.THUMBS_DOWN);
            //                print.setVisible(false);
        } else {
            approve.setIcon(FontAwesome.THUMBS_UP);
            //                print.setVisible(true);
        }

        addItem(new Object[] { t.getExamTitle(), cs.getCurriculumById(t.getCurriculumId()).getSubject(),
                t.getDateCreated(), t.getTotalHoursCoverage(), t.getTotalItems(), v }, i);
        i++;
    }
    setPageLength(size());

    return this;
}

From source file:com.fatminds.vaadin.cmis.components.CmisList.java

License:Apache License

public void addDeleteButtonColumn() {
    this.addGeneratedColumn("Delete", new Table.ColumnGenerator() {
        public Component generateCell(Table source, Object itemId, Object columnId) {
            CmisItem item = (CmisItem) getItem(itemId);
            // the Link -component:
            Button itemsButton = new Button("X");
            itemsButton.setData(item);
            itemsButton.addListener(new Button.ClickListener() {

                public void buttonClick(ClickEvent event) {
                    final CmisItem item = (CmisItem) event.getButton().getData();
                    setSelectedItem(item);
                    getContainerDataSource().removeItem(item.getItemId());

                    /**/*w w  w . j  a  v  a2  s. c o m*/
                     * In practice, you'll want to confirm before deleting...
                     * 
                     * 
                                       ConfirmDialog.show(CatalogManagerApplication.getCurrentNavigableAppLevelWindow(), "Please Confirm:", "Are you sure you want to delete this item.?",
                       "Yes", "No", new ConfirmDialog.Listener() {
                            
                           public void onClose(ConfirmDialog dialog) {
                               if (dialog.isConfirmed()) {
                                   // Confirmed to continue
                                  container.removeItem(item.getItemId());
                               } 
                           }
                       });
                    **/
                }

            });

            return itemsButton;
        }

    });
}

From source file:com.fatminds.vaadin.cmis.components.CmisList.java

License:Apache License

public void addAssociationButtonColumn(final String headerText, final String buttonTextAdd,
        final String buttonTextRemove, final String dialogTextConfirmAdd, final String dialogTextConfirmRemove,
        final CmisAssociationContainer assocContainer, final CmisObject associationSource) {
    this.addGeneratedColumn(headerText, new Table.ColumnGenerator() {
        public Component generateCell(Table source, final Object itemId, final Object columnId) {
            CmisItem item = (CmisItem) getItem(itemId);
            // Find out if this item is already in the association
            boolean isAssociated = assocContainer.containsId(itemId);
            // the Link -component:
            final Button itemsButton = new Button(isAssociated ? buttonTextRemove : buttonTextAdd);
            itemsButton.setData(item);
            itemsButton.addListener(new Button.ClickListener() {

                public void buttonClick(ClickEvent event) {
                    final CmisItem item = (CmisItem) event.getButton().getData();
                    setSelectedItem(item);
                    boolean exists = assocContainer.containsId(itemId);
                    if (assocContainer.containsId(itemId)) {
                        assocContainer.removeItem(itemId);
                        itemsButton.setCaption(buttonTextAdd);
                    } else {
                        assocContainer.addItem(item);
                        itemsButton.setCaption(buttonTextRemove);
                    }//from w ww .ja v  a 2 s  .co  m
                    /**
                     * Preferred impl needs an app-level window to display its confirmation dialog; replace with your favorite flavor 
                     * (we use an adaptation of navigator7)
                     * 
                     *                       ConfirmDialog.show(CatalogManagerApplication.getCurrentNavigableAppLevelWindow(), 
                     "Please Confirm", 
                     (exists ? dialogTextConfirmRemove : dialogTextConfirmAdd),
                       "Yes", 
                       "No", 
                       new ConfirmDialog.Listener() {
                            
                           public void onClose(ConfirmDialog dialog) {
                               if (dialog.isConfirmed()) {
                                   // Confirmed to continue
                                  if (assocContainer.containsId(itemId)) {
                                     assocContainer.removeItem(itemId);
                                     itemsButton.setCaption(buttonTextAdd);
                                  }
                                  else {
                                      assocContainer.addItem(item);
                                      itemsButton.setCaption(buttonTextRemove);
                                  }
                               } 
                           }
                       });
                    **/
                }

            });

            return itemsButton;
        }
    });
}

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//from www  .  java  2 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.github.peholmst.mvp4vaadin.navigation.ui.NavigationBar.java

License:Apache License

/**
 * Adds a breadcrumb to the navigation bar for the specified view. If there
 * already is one or more breadcrumbs in the bar, a separator will be added
 * before the actual navigation button://ww  w.  ja  v a 2s  .c om
 * 
 * <pre>
 * First view >> Second view >> Third view
 * </pre>
 * 
 * A click on the navigation button will result in a request to the view
 * controller to navigate to that particular view.
 * 
 * @see #addViewButton(String)
 * @see #addViewSeparator()
 * 
 * @param view
 *            the view to add (must not be <code>null</code>).
 */
protected void addBreadcrumbForView(final ControllableView view) {
    if (getViewController().getTrail().size() > 1) {
        Label separator = addViewSeparator();
        separator.setData(view);
    }

    final Button btn = addViewButton(view.getDisplayName());
    btn.setDescription(view.getViewDescription());
    btn.addListener(new Button.ClickListener() {

        private static final long serialVersionUID = -2163467482631873920L;

        @Override
        public void buttonClick(ClickEvent event) {
            getViewController().goToView(view);
        }
    });
    btn.setData(view);
}

From source file:com.github.peholmst.springsecuritydemo.ui.LoginView.java

License:Apache License

@SuppressWarnings("serial")
protected void init() {
    final Panel loginPanel = new Panel();
    loginPanel.setCaption(getApplication().getMessage("login.title"));
    ((VerticalLayout) loginPanel.getContent()).setSpacing(true);

    final TextField username = new TextField(getApplication().getMessage("login.username"));
    username.setWidth("100%");
    loginPanel.addComponent(username);// w ww  .  j av  a2  s. c  o m

    final TextField password = new TextField(getApplication().getMessage("login.password"));
    password.setSecret(true);
    password.setWidth("100%");
    loginPanel.addComponent(password);

    final Button loginButton = new Button(getApplication().getMessage("login.button"));
    loginButton.setStyleName("primary");
    // TODO Make it possible to submit the form by pressing <Enter> in any
    // of the text fields
    loginPanel.addComponent(loginButton);
    ((VerticalLayout) loginPanel.getContent()).setComponentAlignment(loginButton, Alignment.MIDDLE_RIGHT);
    loginButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            final Authentication auth = new UsernamePasswordAuthenticationToken(username.getValue(),
                    password.getValue());
            try {
                if (logger.isDebugEnabled()) {
                    logger.debug("Attempting authentication for user '" + auth.getName() + "'");
                }
                Authentication returned = getAuthenticationManager().authenticate(auth);
                if (logger.isDebugEnabled()) {
                    logger.debug("Authentication for user '" + auth.getName() + "' succeeded");
                }
                fireEvent(new LoginEvent(LoginView.this, returned));
            } catch (BadCredentialsException e) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Bad credentials for user '" + auth.getName() + "'", e);
                }
                getWindow().showNotification(getApplication().getMessage("login.badCredentials.title"),
                        getApplication().getMessage("login.badCredentials.descr"),
                        Notification.TYPE_WARNING_MESSAGE);
            } catch (DisabledException e) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Account disabled for user '" + auth.getName() + "'", e);
                }
                getWindow().showNotification(getApplication().getMessage("login.disabled.title"),
                        getApplication().getMessage("login.disabled.descr"), Notification.TYPE_WARNING_MESSAGE);
            } catch (LockedException e) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Account locked for user '" + auth.getName() + "'", e);
                }
                getWindow().showNotification(getApplication().getMessage("login.locked.title"),
                        getApplication().getMessage("login.locked.descr"), Notification.TYPE_WARNING_MESSAGE);
            } catch (Exception e) {
                if (logger.isErrorEnabled()) {
                    logger.error("Error while attempting authentication for user '" + auth.getName() + "'");
                }
                ExceptionUtils.handleException(getWindow(), e);
            }
        }
    });

    HorizontalLayout languages = new HorizontalLayout();
    languages.setSpacing(true);
    final Button.ClickListener languageListener = new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Locale locale = (Locale) event.getButton().getData();
            if (logger.isDebugEnabled()) {
                logger.debug("Changing locale to [" + locale + "] and restarting the application");
            }
            getApplication().setLocale(locale);
            getApplication().close();
        }
    };
    for (Locale locale : getApplication().getSupportedLocales()) {
        if (!getLocale().equals(locale)) {
            final Button languageButton = new Button(getApplication().getLocaleDisplayName(locale));
            languageButton.setStyleName(Button.STYLE_LINK);
            languageButton.setData(locale);
            languageButton.addListener(languageListener);
            languages.addComponent(languageButton);
        }
    }
    loginPanel.addComponent(languages);

    loginPanel.setWidth("300px");

    final HorizontalLayout viewLayout = new HorizontalLayout();
    viewLayout.addComponent(loginPanel);
    viewLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
    viewLayout.setSizeFull();
    viewLayout.setMargin(true);

    setCompositionRoot(viewLayout);
    setSizeFull();
}

From source file:com.hybridbpm.ui.component.adaptive.AdaptiveTaskEditor.java

License:Apache License

@Override
public void buttonClick(Button.ClickEvent event) {
    if (event.getButton().equals(btnSend)) {
    } else if (event.getButton().equals(btnProcess)) {
        adaptiveLayout.setVisible(false);
        templateLayout.removeAllComponents();
        templateLayout.setVisible(true);
        for (StartProcess startProcess : HybridbpmUI.getBpmAPI().getMyProcessToStart()) {
            String startTaskTitle = startProcess.getProcessModel()
                    .getTaskModelByName(startProcess.getTaskName()).getTitle();
            String processTitle = startProcess.getProcessModel().getTitle()
                    .getValue(HybridbpmUI.getCurrent().getLocale());
            Button button = new Button(processTitle + " (" + startTaskTitle + ")");
            button.setData(startProcess);
            button.addClickListener(this);
            button.setStyleName(ValoTheme.BUTTON_LINK);
            button.addStyleName(ValoTheme.BUTTON_SMALL);
            button.setIcon(FontAwesome.valueOf(startProcess.getIcon()));
            templateLayout.addComponent(button);
        }//from w  w w  .  ja v  a  2  s.  co m
        templateLayout.addComponent(btnBack);
        templateLayout.setComponentAlignment(btnBack, Alignment.BOTTOM_RIGHT);
    } else if (event.getButton().getData() instanceof StartProcess) {
        StartProcess spd = (StartProcess) event.getButton().getData();
        if (taskLayout != null && card.getComponentIndex(taskLayout) > -1) {
            card.removeComponent(taskLayout);
        }
        taskLayout = new TaskLayout(null, spd.getProcessModel().getName(), spd.getTaskName(), true);
        card.addComponents(taskLayout);
        card.setExpandRatio(taskLayout, 1f);
        card.setSizeFull();
        topLayout.setVisible(false);
        //            panelView.toggleMaximized(this, true);
    } else if (event.getButton().equals(btnBack)) {
        adaptiveLayout.setVisible(true);
        templateLayout.setVisible(false);
    }
}