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, ClickListener listener) 

Source Link

Document

Creates a new push button with a click listener.

Usage

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

License:Apache License

private void createButtons() {
    buttons = new HorizontalLayout();
    buttons.setSpacing(true);/*from  w ww . j ava2s  .c om*/
    buttons.setWidth("640px");

    btnOk = new Button("Ok", this);
    btnOk.addStyleName("default");
    btnOk.setIcon(new ThemeResource("icons/16/ok.png"));
    buttons.addComponent(btnOk);
    buttons.setComponentAlignment(btnOk, Alignment.MIDDLE_RIGHT);
    buttons.setExpandRatio(btnOk, 1);

    btnCancel = new Button("Cancela", this);
    btnCancel.setIcon(new ThemeResource("icons/16/cancel.png"));
    buttons.addComponent(btnCancel);
    buttons.setComponentAlignment(btnCancel, Alignment.MIDDLE_RIGHT);

    parameterForm.getFooter().addComponent(buttons);
}

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

License:Apache License

private void createButtons() {
    buttons = new HorizontalLayout();
    buttons.setSpacing(true);/* w  w w. j  ava 2  s . com*/
    buttons.setWidth("100%");

    btnAddParameter = new Button("Adicionar", this);
    btnAddParameter.setIcon(new ThemeResource("icons/16/parameterAdd.png"));
    buttons.addComponent(btnAddParameter);
    buttons.setComponentAlignment(btnAddParameter, Alignment.MIDDLE_LEFT);

    btnRemoveParameter = new Button("Remover", this);
    btnRemoveParameter.setIcon(new ThemeResource("icons/16/parameterRemove.png"));
    buttons.addComponent(btnRemoveParameter);
    buttons.setComponentAlignment(btnRemoveParameter, Alignment.MIDDLE_LEFT);

    btnEditParameter = new Button("Editar", this);
    btnEditParameter.setIcon(new ThemeResource("icons/16/parameterEdit.png"));
    buttons.addComponent(btnEditParameter);
    buttons.setComponentAlignment(btnEditParameter, Alignment.MIDDLE_LEFT);

    btnImport = new Button("Importar parmetros", this);
    btnImport.setIcon(new ThemeResource("icons/16/import.png"));
    buttons.addComponent(btnImport);
    buttons.setComponentAlignment(btnImport, Alignment.MIDDLE_LEFT);

    btnMoveUp = new Button("Mover p/cima", this);
    btnMoveUp.setIcon(new ThemeResource("icons/16/moveUp.png"));
    buttons.addComponent(btnMoveUp);
    buttons.setComponentAlignment(btnMoveUp, Alignment.MIDDLE_LEFT);

    btnMoveDown = new Button("Mover p/baixo", this);
    btnMoveDown.setIcon(new ThemeResource("icons/16/moveDown.png"));
    buttons.addComponent(btnMoveDown);
    buttons.setComponentAlignment(btnMoveDown, Alignment.MIDDLE_LEFT);

    btnOk = new Button("Ok", this);
    btnOk.addStyleName("default");
    btnOk.setIcon(new ThemeResource("icons/16/ok.png"));
    buttons.addComponent(btnOk);
    buttons.setComponentAlignment(btnOk, Alignment.MIDDLE_RIGHT);
    buttons.setExpandRatio(btnOk, 1);

    btnCancel = new Button("Cancela", this);
    btnCancel.setIcon(new ThemeResource("icons/16/cancel.png"));
    buttons.addComponent(btnCancel);
    buttons.setComponentAlignment(btnCancel, Alignment.MIDDLE_RIGHT);
    buttons.setMargin(true, false, true, false);
}

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

License:Apache License

private void createButtons() {
    buttons = new HorizontalLayout();
    buttons.setSpacing(true);/*from  w  w  w . j av a 2  s  .c om*/
    buttons.setWidth("100%");

    buttons.addComponent(buttonsFields);
    buttons.setExpandRatio(buttonsFields, 1);

    btnOk = new Button("Ok", this);
    btnOk.addStyleName("default");
    btnOk.setIcon(new ThemeResource("icons/16/ok.png"));
    btnOk.addListener(this);
    buttons.addComponent(btnOk);
    buttons.setComponentAlignment(btnOk, Alignment.MIDDLE_RIGHT);

    btnCancel = new Button("Cancela", this);
    btnCancel.setIcon(new ThemeResource("icons/16/cancel.png"));
    btnCancel.addListener(this);
    buttons.addComponent(btnCancel);
    buttons.setComponentAlignment(btnCancel, Alignment.MIDDLE_RIGHT);
    buttons.setMargin(true, false, true, false);
}

From source file:br.com.anteros.mobileserver.util.UserMessages.java

License:Apache License

public Window confirm(String title, String message, String okTitle, String cancelTitle,
        Button.ClickListener listener) {

    if (title == null) {
        title = CONFIRM_OK_TITLE;//from   w  w w .  ja  v  a2  s.c o  m
    }
    if (cancelTitle == null) {
        cancelTitle = CONFIRM_CANCEL_TITLE;
    }
    if (okTitle == null) {
        okTitle = CONFIRM_OK_TITLE;
    }

    final Window confirm = new Window(title);
    this.confirm = confirm;
    win.addWindow(confirm);

    confirm.addListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1971800928047045825L;

        public void windowClose(CloseEvent ce) {
            Object data = ce.getWindow().getData();
            if (data != null) {
                try {
                } catch (Exception exception) {
                    error("Unhandled Exception", exception);
                }
            }
        }
    });

    int chrW = 5;
    int chrH = 15;
    int txtWidth = Math.max(250, Math.min(350, message.length() * chrW));
    int btnHeight = 25;
    int vmargin = 100;
    int hmargin = 40;

    int txtHeight = 2 * chrH * (message.length() * chrW) / txtWidth;

    confirm.setWidth((txtWidth + hmargin) + "px");
    confirm.setHeight((vmargin + txtHeight + btnHeight) + "px");
    confirm.getContent().setSizeFull();

    confirm.center();
    confirm.setModal(true);

    Label text = new Label(message);
    text.setWidth("100%");
    text.setHeight("100%");

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setHeight(btnHeight + 5 + "px");
    buttons.setWidth("100%");
    buttons.setSpacing(true);
    buttons.setMargin(false);

    Button cancel = new Button(cancelTitle, listener);
    cancel.setIcon(new ThemeResource("icons/16/no.png"));
    cancel.setData(USER_CONFIRM_CANCEL);
    cancel.setClickShortcut(KeyCode.ESCAPE);
    Button ok = new Button(okTitle, listener);
    ok.setIcon(new ThemeResource("icons/16/yes.png"));
    ok.setData(USER_CONFIRM_OK);
    ok.setClickShortcut(KeyCode.ENTER);
    buttons.addComponent(ok);
    buttons.setExpandRatio(ok, 1);
    buttons.setComponentAlignment(ok, Alignment.MIDDLE_RIGHT);

    buttons.addComponent(cancel);
    buttons.setComponentAlignment(cancel, Alignment.MIDDLE_RIGHT);

    confirm.addComponent(text);
    confirm.addComponent(buttons);
    ((VerticalLayout) confirm.getContent()).setExpandRatio(text, 1f);
    confirm.setResizable(false);
    return confirm;
}

From source file:by.bigvova.views.AdminView.java

License:Apache License

@Autowired
public AdminView(MyBackend backend) {
    this.backend = backend;
    Button button = new Button("Call admin backend", new Button.ClickListener() {
        @Override//  w ww  .  j a  v a  2  s  .c  o  m
        public void buttonClick(Button.ClickEvent event) {
            Notification.show(AdminView.this.backend.adminOnlyEcho("Hello Admin World!"));
        }
    });
    setCompositionRoot(button);
}

From source file:ch.bfh.ti.soed.hs16.srs.black.view.reservationView.ReservationMakeView.java

License:Open Source License

public ReservationMakeView() {
    fromField = new DateField("Start Date");
    fromField.setLocale(new Locale("de", "DE"));
    fromField.setResolution(Resolution.MINUTE);
    fromField.setDateFormat("dd.MM.yyyy HH:mm");
    fromField.setIcon(FontAwesome.CALENDAR);
    fromField.setWidth(12, Unit.EM);/*from  w ww .  j a v a2  s  .  co  m*/
    toField = new DateField("End Date");
    toField.setLocale(new Locale("de", "DE"));
    toField.setResolution(Resolution.MINUTE);
    toField.setDateFormat("dd.MM.yyyy HH:mm");
    toField.setIcon(FontAwesome.CALENDAR);
    toField.setWidth(12, Unit.EM);
    roomSelect = new NativeSelect("Room Number");
    roomSelect.setIcon(FontAwesome.BED);
    roomSelect.setNullSelectionAllowed(true);
    roomSelect.setImmediate(true);
    makeReservationButton = new Button("Make Reservation", FontAwesome.CHECK);
    makeReservationButton.setWidth(12, Unit.EM);
    logoutButton = new Button("Logout");

    Panel panel = new Panel("Create New Reservation");
    FormLayout content = new FormLayout();
    content.addComponents(fromField, toField, roomSelect, makeReservationButton);
    content.setSizeUndefined();
    content.setMargin(true);
    VerticalLayout formAndLogout = new VerticalLayout(content, logoutButton);
    formAndLogout.setMargin(true);
    panel.setContent(formAndLogout);
    makeViewLayout = new VerticalLayout(panel);
    makeViewLayout.setSizeUndefined();
    makeViewLayout.setMargin(true);
}

From source file:ch.bfh.ti.soed.hs16.srs.red.ui.views.LoginView.java

License:Open Source License

public LoginView(Navigator nav) {

    try {/*from   ww w  .j  av  a  2s .  c o  m*/
        // @TODO remove before release
        DevDemo devdemo = new DevDemo();
    } catch (Exception ex) {
        Notification.show("Demo Entries failed to initialize.", ex.getMessage(),
                Notification.Type.ERROR_MESSAGE);
    }
    /*---------------------------------
    initialize Objects
    ---------------------------------*/
    this.nav = nav;
    this.vertical = new VerticalLayout();
    this.loginName = new TextField("username");
    this.passwordField = new PasswordField("password");
    this.loginButton = new Button("Login", this);

    /*-------------------------------
    add to css
    -------------------------------*/
    vertical.setPrimaryStyleName("rootLogin");
    loginButton.setStyleName("buttonLogin");

    /*-------------------------------
    add Components to Layout
    --------------------------------*/
    vertical.addComponents(loginName, passwordField, loginButton);
    setCompositionRoot(vertical);
}

From source file:ch.bfh.ti.soed.hs16.srs.red.ui.views.MyReservationView.java

License:Open Source License

public MyReservationView(Navigator nav) {

    /*---------------------------------
    initialize objects//from w w w.  j  a v a2 s.c om
    ---------------------------------*/
    this.root = new VerticalLayout();
    this.subWindowReservation = new Window();

    this.navigation = new Menu(nav);
    this.labelWelcome = new Label();
    this.error = new Label();
    this.calendarWeek = new Calendar();
    this.buttonAddRes = new Button("add Reservation", this::buttonAddReservation); //handle event in method addReservation
    this.contentSubWindow = new SubWindowReservation();
    this.saveButton = contentSubWindow.getButtonSave();
    this.deleteButton = contentSubWindow.getButtonDelete();

    this.reservationController = new ReservationController();
    this.userController = new UserController();
    this.roomController = new RoomController();

    /*---------------------------------
    specialize objects
    ---------------------------------*/
    calendarWeek.setFirstDayOfWeek(GregorianCalendar.MONDAY);
    saveButton.addClickListener(this::buttonSave);
    deleteButton.addClickListener(this::buttonDelete);

    List<Room> rooms = roomController.getAllRooms();
    for (int i = 0; i < rooms.size(); i++) {
        contentSubWindow.getRooms().addItem(rooms.get(i).getId() + " " + rooms.get(i).getName());
    }

    /*---------------------------------
    add style names
    ---------------------------------*/
    calendarWeek.setPrimaryStyleName("calendarWeek");

    /*-------------------------------
    add components to root
    --------------------------------*/
    Layout layoutMenu = navigation.getMenu();
    root.addComponents(layoutMenu, labelWelcome, error, buttonAddRes, calendarWeek);
    setCompositionRoot(root);

    /*-------------------------------
    double click on calendar events
    --------------------------------*/
    calendarWeek.setHandler((CalendarComponentEvents.EventClickHandler) event -> {
        addSubWindowToRoot(event);
    });

}

From source file:ch.wscr.management.ui.view.MemberView.java

/**
 * Kopfzeile fr das Grid erstellen//from  www.  jav  a 2  s .  co  m
 *
 * @param grid das Grid dem die Kopfzeile hinzugefgt werden soll
 */
private void setHeaderRow(final Grid grid) {
    // TODO Erstellung neuer Mitglieder muss noch optimiert werden

    final Button addMember = new Button("Neu", clickEvent -> {
        BeanItem<Member> beanItem = memberBeanItemContainer.addItem(new Member());
        grid.setEditorEnabled(true);
        //grid.editItem(beanItem);

    });

    addMember.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
    addMember.setIcon(FontAwesome.PLUS_CIRCLE);

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSizeFull();
    buttonLayout.setSpacing(true);
    buttonLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    buttonLayout.addComponent(addMember);

    HeaderRow headerRow = grid.prependHeaderRow();
    headerRow.join("memberId", "lastName", "firstName", "adrStreet", "adrPostalCode", "adrCity", "adrCountry",
            "birthDate", "driverLicense");
    headerRow.getCell("lastName").setComponent(buttonLayout);
}

From source file:com.aaron.mbpet.views.users.UserEditor.java

License:Apache License

public UserEditor(Item personItem, String lableText, boolean mode) {
    this.editMode = mode;
    //       this.setModal(true);
    center();/*from ww  w .jav  a 2 s.co m*/
    setResizable(true);
    setClosable(true);
    setModal(true);
    //      setSizeUndefined();
    setWidth(25, Unit.EM);

    this.currsessionuser = ((MbpetUI) UI.getCurrent()).getSessionUser();

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);

    this.personItem = personItem;
    editorForm = new Form();
    editorForm.setFormFieldFactory(this);
    editorForm.setBuffered(true);
    editorForm.setImmediate(true);
    editorForm.setItemDataSource(personItem,
            Arrays.asList("firstname", "lastname", "email", "username", "password", "organization"));

    //buttons        
    saveButton = new Button("Save", this);
    saveButton.setClickShortcut(KeyCode.ENTER);
    cancelButton = new Button("Cancel", this);
    saveButton.addStyleName(ValoTheme.BUTTON_PRIMARY);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setWidth("100%");
    buttons.addComponents(saveButton, cancelButton);
    buttons.setComponentAlignment(saveButton, Alignment.BOTTOM_LEFT);
    buttons.setComponentAlignment(cancelButton, Alignment.BOTTOM_RIGHT);

    //        editorForm.getFooter().addComponent(buttons);
    //        editorForm.getFooter().addComponent(cancelButton);

    layout.addComponent(new Label("<h3>" + lableText + "</h3>", ContentMode.HTML));
    layout.addComponent(editorForm);
    layout.setComponentAlignment(editorForm, Alignment.MIDDLE_CENTER);
    layout.addComponent(buttons);

    setContent(layout); //editorForm
    setCaption(buildCaption());
}