Example usage for com.vaadin.ui Button Button

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

Introduction

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

Prototype

public Button(Resource icon) 

Source Link

Document

Creates a new push button with the given icon.

Usage

From source file:au.org.scoutmaster.views.ContactView.java

@Override
protected AbstractLayout getAdvancedSearchLayout() {
    final VerticalLayout advancedSearchLayout = new VerticalLayout();
    advancedSearchLayout.setSpacing(true);

    final HorizontalLayout tagSearchLayout = new HorizontalLayout();
    this.tagSearchField = new TagField("Search Tags", true);
    tagSearchLayout.addComponent(this.tagSearchField);

    tagSearchLayout.setSizeFull();//from  w  ww. ja  v a2s .  c  o  m
    advancedSearchLayout.addComponent(tagSearchLayout);

    final HorizontalLayout stringSearchLayout = new HorizontalLayout();
    stringSearchLayout.addComponent(this.searchField);
    stringSearchLayout.setWidth("100%");

    advancedSearchLayout.addComponent(stringSearchLayout);

    final Button searchButton = new Button("Search");
    final Action1<ClickEvent> searchClickAction = new SearchClickAction();
    ButtonEventSource.fromActionOf(searchButton).subscribe(searchClickAction);

    advancedSearchLayout.addComponent(searchButton);
    advancedSearchLayout.setComponentAlignment(searchButton, Alignment.MIDDLE_RIGHT);

    return advancedSearchLayout;

}

From source file:biz.eelis.translation.EntryFlowlet.java

License:Apache License

@Override
public void initialize() {
    entityManager = getSite().getSiteContext().getObject(EntityManager.class);

    final GridLayout gridLayout = new GridLayout(1, 3);
    gridLayout.setSizeFull();//from w  ww .ja v a 2s. c  o m
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(2, 1f);
    setViewContent(gridLayout);

    entryEditor = new ValidatingEditor(TranslationSiteFields.getFieldDescriptors(Entry.class));
    entryEditor.setCaption("Entry");
    entryEditor.addListener((ValidatingEditorStateListener) this);
    gridLayout.addComponent(entryEditor, 0, 0);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    gridLayout.addComponent(buttonLayout, 0, 1);

    saveButton = new Button("Save");
    saveButton.setImmediate(true);
    buttonLayout.addComponent(saveButton);
    saveButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            entryEditor.commit();
            entityManager.getTransaction().begin();
            try {
                entity = entityManager.merge(entity);
                entity.setAuthor(getSite().getSecurityProvider().getUser());
                entity.setModified(new Date());
                entityManager.persist(entity);
                entityManager.getTransaction().commit();
                entityManager.detach(entity);
                entryEditor.discard();
                container.refresh();
            } catch (final Throwable t) {
                if (entityManager.getTransaction().isActive()) {
                    entityManager.getTransaction().rollback();
                }
                throw new RuntimeException("Failed to save entity: " + entity, t);
            }
        }
    });

    discardButton = new Button("Discard");
    discardButton.setImmediate(true);
    buttonLayout.addComponent(discardButton);
    discardButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            entryEditor.discard();
        }
    });

    final List<FieldDescriptor> fieldDescriptors = TranslationSiteFields.getFieldDescriptors(Entry.class);

    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();

    container = new LazyEntityContainer<Entry>(entityManager, true, true, false, Entry.class, 1000,
            new String[] { "basename", "key", "language", "country" }, new boolean[] { true, true, true, true },
            "entryId");
    container.getQueryView().getQueryDefinition().setMaxQuerySize(1);

    ContainerUtil.addContainerProperties(container, fieldDescriptors);

    final Table table = new FormattingTable();
    final Grid grid = new Grid(table, container);
    grid.setCaption("All Translations");
    grid.setSizeFull();
    grid.setFields(fieldDescriptors);
    grid.setFilters(filterDefinitions);

    table.setColumnCollapsed("entryId", true);
    table.setColumnCollapsed("path", true);
    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    gridLayout.addComponent(grid, 0, 2);

}

From source file:br.com.anteros.mobileserver.app.form.LogForm.java

License:Apache License

private void createForm() {
    btnRefresh = new Button("Atualizar");
    btnRefresh.addListener(this);
    header = new VerticalLayout();
    header.addComponent(btnRefresh);//from   w  w  w  .  j a v a 2s . c  o  m
    header.setWidth("100%");
    header.setComponentAlignment(btnRefresh, Alignment.MIDDLE_LEFT);
    addComponent(header);

    textPanel = new Panel();
    textPanel.setImmediate(true);
    textPanel.setHeight("100%");
    textPanel.setWidth("100%");

    textLog = new Label();
    textLog.setContentMode(Label.CONTENT_XHTML);
    textLog.setWidth("100%");
    textLog.setHeight("100%");
    addComponent(textPanel);
    textPanel.addComponent(textLog);
}

From source file:br.gov.frameworkdemoiselle.vaadin.ui.CrudForm.java

License:Open Source License

protected void createButtons() {
    buttonSave = new Button(this.bundle.getString("button.save"));
    buttonClear = new Button(this.bundle.getString("button.clear"));
    buttonDelete = new Button(this.bundle.getString("button.delete"));

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);//from   w  w w.j  a  va  2s  . co  m
    buttons.addComponent(getButtonSave());
    buttons.addComponent(getButtonDelete());
    buttons.addComponent(buttonClear);
    getFooter().addComponent(buttons);

    getButtonSave().addListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                commit();
            } catch (InvalidValueException exception) {
                beanManager.fireEvent(getBean(), new AnnotationLiteral<ProcessInvalidValue>() {
                });
                getWindow().showNotification(exception.getMessage(), Notification.TYPE_WARNING_MESSAGE);
                return;
            }
            beanManager.fireEvent(getBean(), new AnnotationLiteral<ProcessSave>() {
            });
        }

    });

    buttonClear.addListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            CrudForm.this.discard();
            beanManager.fireEvent(getBean(), new AnnotationLiteral<ProcessClear>() {
            });
        }

    });

    getButtonDelete().addListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            beanManager.fireEvent(getBean(), new AnnotationLiteral<ProcessDelete>() {
            });
        }

    });
}

From source file:br.gov.sp.saovicente.MyVaadinApplication.java

License:Apache License

@Override
public void init() {

    final Window mainWindow = new Window("Sampleinvientchart2 Application");
    mainWindow.setSizeFull();/*from   w w w .j a  va  2  s.c  o  m*/
    setMainWindow(mainWindow);

    mgberr = new MessageBox(getMainWindow(), "My message ERRO...", MessageBox.Icon.ERROR, "Hello World!",
            new MessageBox.ButtonConfig(ButtonType.OK, "Ok"));

    mgbinf = new MessageBox(getMainWindow(), "My message INFO...", MessageBox.Icon.INFO, "Hello World!",
            new MessageBox.ButtonConfig(ButtonType.OK, "Ok"));

    mgbquest = new MessageBox(getMainWindow(), "My message QUESTION...", MessageBox.Icon.QUESTION,
            "Hello World!", new MessageBox.ButtonConfig(ButtonType.YES, "YES"),
            new MessageBox.ButtonConfig(ButtonType.NO, "NO"));

    mgbnone = new MessageBox(getMainWindow(), "My message NONE...", MessageBox.Icon.QUESTION, "Hello World!",
            new MessageBox.ButtonConfig(ButtonType.OK, "Ok"));

    mgbwarn = new MessageBox(getMainWindow(), "My message WARN...", MessageBox.Icon.WARN, "Hello World!",
            new MessageBox.ButtonConfig(ButtonType.OK, "Ok"));

    infomacao = new Button("Informao");

    infomacao.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            mgbinf.show(new MessageBox.EventListener() {

                public void buttonClicked(ButtonType buttonType) {
                }
            });
        }
    });

    erro = new Button("Erro");

    erro.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            mgberr.show(new MessageBox.EventListener() {

                public void buttonClicked(ButtonType buttonType) {
                    System.out.println("Este boto foi pressionado: " + buttonType);
                }
            });
        }
    });

    none = new Button("None");

    none.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            mgbnone.show(new MessageBox.EventListener() {

                public void buttonClicked(ButtonType buttonType) {
                    System.out.println("Este boto foi pressionado: " + buttonType);
                }
            });
        }
    });

    question = new Button("Question");

    question.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            mgbquest.show(new MessageBox.EventListener() {

                public void buttonClicked(ButtonType buttonType) {
                    if (buttonType.toString().equals("YES")) {
                        mainWindow.open(new ExternalResource("http://10.171.0.9:8080/bic/"));
                        System.out.println("Este boto foi pressionado: " + buttonType);
                    } else if (buttonType.toString().equals("NO")) {
                        mainWindow.open(new ExternalResource("http://localhost:8080/modelo/"));
                    }
                }
            });
        }
    });

    warn = new Button("Warn");

    warn.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            mgbwarn.show(new MessageBox.EventListener() {

                public void buttonClicked(ButtonType buttonType) {
                    System.out.println("Este boto foi pressionado: " + buttonType);
                }
            });
        }
    });

    HorizontalLayout botao = new HorizontalLayout();
    botao.setSpacing(true);
    botao.addComponent(erro);
    botao.addComponent(warn);
    botao.addComponent(none);
    botao.addComponent(infomacao);
    botao.addComponent(question);

    // CustomDateField df = new CustomDateField();
    //df.setbTwelveHourClock(false);
    // df.setbTwelveHourClock(true);
    // mainWindow.addComponent(df);
    //mainWindow.addComponent(new WidgetSetTest());

    mainWindow.addComponent(botao);

}

From source file:by.bigvova.LoginUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    getPage().setTitle("Vaadin Shared Security Demo Login");

    FormLayout loginForm = new FormLayout();
    loginForm.setSizeUndefined();/*ww w  .  ja  v a  2 s  .  c om*/

    userName = new TextField("Username");
    passwordField = new PasswordField("Password");
    rememberMe = new CheckBox("Remember me");
    login = new Button("Login");
    Label label = new Label("Name: User / Password: password");
    loginForm.addComponent(userName);
    loginForm.addComponent(passwordField);
    loginForm.addComponent(rememberMe);
    loginForm.addComponent(login);
    login.addStyleName(ValoTheme.BUTTON_PRIMARY);
    login.setDisableOnClick(true);
    login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    login.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            login();
        }
    });

    VerticalLayout loginLayout = new VerticalLayout();
    loginLayout.setSpacing(true);
    loginLayout.setSizeUndefined();

    if (request.getParameter("logout") != null) {
        loggedOutLabel = new Label("You have been logged out!");
        loggedOutLabel.addStyleName(ValoTheme.LABEL_SUCCESS);
        loggedOutLabel.setSizeUndefined();
        loginLayout.addComponent(loggedOutLabel);
        loginLayout.setComponentAlignment(loggedOutLabel, Alignment.BOTTOM_CENTER);
    }

    loginLayout.addComponent(loginFailedLabel = new Label());
    loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER);
    loginFailedLabel.setSizeUndefined();
    loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE);
    loginFailedLabel.setVisible(false);

    loginLayout.addComponent(label);
    loginLayout.addComponent(loginForm);
    loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER);

    VerticalLayout rootLayout = new VerticalLayout(loginLayout);
    rootLayout.setSizeFull();
    rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER);
    setContent(rootLayout);
    setSizeFull();
}

From source file:by.bigvova.ui.LoginUI.java

License:Apache License

private Component buildFields() {
    final VerticalLayout layout = new VerticalLayout();
    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);//  w  w  w  .j ava  2s.c o  m
    fields.addStyleName("fields");

    final TextField username = new TextField("Username");
    username.setIcon(FontAwesome.USER);
    username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final PasswordField password = new PasswordField("Password");
    password.setIcon(FontAwesome.LOCK);
    password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final Button signin = new Button("Sign In");
    signin.addStyleName(ValoTheme.BUTTON_PRIMARY);
    signin.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    signin.focus();

    final CheckBox checkBox = new CheckBox("Remember me", true);

    signin.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            login(username.getValue(), password.getValue(), checkBox.getValue());
        }
    });

    fields.addComponents(username, password, signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    layout.setSpacing(true);
    layout.addComponent(fields);
    layout.addComponent(checkBox);
    return layout;
}

From source file:cb_server.SettingsWindow.java

License:Open Source License

private void addSaveCancelButtons() {
    HorizontalLayout hl = new HorizontalLayout();
    final Button btnSave = new Button(Translation.Get("save".hashCode()));
    final Button btnCancel = new Button(Translation.Get("cancel".hashCode()));

    hl.addComponent(btnSave);// w  w w  .  ja va2 s  .c  o  m
    hl.addComponent(btnCancel);

    btnCancel.addClickListener(new ClickListener() {

        private static final long serialVersionUID = -4799987364890297976L;

        @Override
        public void buttonClick(ClickEvent event) {
            Config.settings.LoadFromLastValue();
            SettingsWindow.this.close();
        }
    });

    btnSave.addClickListener(new ClickListener() {

        private static final long serialVersionUID = -878673538684730570L;

        @Override
        public void buttonClick(ClickEvent event) {
            String lang = (String) langSpinner.getValue();

            for (Lang tmp : Translation.GetLangs(SettingsClass.LanguagePath.getValue())) {
                if (lang.equals(tmp.Name)) {
                    CB_UI_Base_Settings.Sel_LanguagePath.setValue(tmp.Path);
                    try {
                        Translation.LoadTranslation(tmp.Path);
                    } catch (Exception e) {
                        try {
                            Translation.LoadTranslation(CB_UI_Base_Settings.Sel_LanguagePath.getDefaultValue());
                        } catch (IOException e1) {
                            e1.printStackTrace();
                        }
                    }
                    break;
                }

            }

            Config.settings.WriteToDB();
            Config.settings.SaveToLastValue();

            SettingsWindow.this.close();
        }
    });

    content.addComponent(hl);
}

From source file:ccm.CCM1.ColorPickerApplication.java

License:Apache License

@Override
public void init() {
    setMainWindow(main);/*from w w  w . jav  a  2s .c  o  m*/

    // Listen for value change events in the custom component,
    // triggered when user clicks a button to select another color.
    colorselector.addListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            // Provide some server-side feedback
            colorname.setValue("Selected color: " + colorselector.getColor());
        }
    });
    main.addComponent(colorselector);

    // Add another component to give feedback from server-side code
    colorname = new Label("Selected color: " + colorselector.getColor());
    main.addComponent(colorname);

    // Server-side manipulation of the component state
    final Button button = new Button("Set to white");
    button.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            colorselector.setColor("white");
        }
    });
    main.addComponent(button);

    setTheme("mytheme");
}

From source file:ch.bfh.ti.soed.hs16.srs.black.view.loginView.LoginView.java

License:Open Source License

public LoginView() {
    usernameField = new TextField("Username");
    usernameField.setIcon(FontAwesome.USER);
    usernameField.setWidth(12, Unit.EM);
    passwordField = new PasswordField("Password");
    passwordField.setIcon(FontAwesome.KEY);
    passwordField.setWidth(12, Unit.EM);
    loginButton = new Button("Login");
    loginButton.setWidth(5, Unit.EM);// ww  w.  jav a2 s. c o  m
    loginButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    signUpButton = new Button("Sign Up");
    signUpButton.setWidth(6, Unit.EM);

    VerticalLayout layout = new VerticalLayout();
    HorizontalLayout layoutButtons = new HorizontalLayout(loginButton, signUpButton);
    layoutButtons.setSpacing(true);
    Panel panel = new Panel("Login - Smart ReservationEntity System");
    panel.setSizeUndefined();
    layout.addComponent(panel);

    FormLayout content = new FormLayout();
    content.addComponents(usernameField, passwordField, layoutButtons);
    content.setSizeFull();
    content.setMargin(true);
    panel.setContent(content);

    setCompositionRoot(layout);

    layout.setComponentAlignment(panel, Alignment.MIDDLE_CENTER);
    layout.setMargin(new MarginInfo(true, false, false, false));
}