Example usage for com.vaadin.ui Button setEnabled

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

Introduction

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

Prototype

@Override
    public void setEnabled(boolean enabled) 

Source Link

Usage

From source file:com.snowy.PostLoginView.java

@PostConstruct
void init() {//from w  w  w.jav  a  2  s.  c  o m
    //Logger.getLogger(PostLoginView.class.getName()).info(d);
    d = ((MyVaadinUI) UI.getCurrent()).getDataObject();
    //Logger.getLogger(PostLoginView.class.getName()).info(d);
    g = new GameWindow(d);
    c = new ChatWindow(d);
    HorizontalLayout hl = new HorizontalLayout();
    setMargin(true);
    /*this.getUI().addPollListener(new UIEvents.PollListener(){
    @Override
    public void poll(UIEvents.PollEvent event) {
        c.getUsersList().retrieveActiveUsers();
    }
            
    });*/

    this.setSizeFull();
    Button b = new Button("Logout");
    b.addClickListener(e -> {

        d.logout(VaadinSession.getCurrent().getCsrfToken());
        VaadinSession.getCurrent().close();

        Page.getCurrent().setLocation("/");
    });
    Button ccc = new Button("Unpause polling");
    ccc.setEnabled(false);
    Button cc = new Button("Pause polling");
    cc.addClickListener(e -> {
        if (ccc.isEnabled() == false) {
            UI.getCurrent().setPollInterval(1000000000);
            cc.setEnabled(false);
            ccc.setEnabled(true);
        }
    });
    ccc.addClickListener(e -> {
        if (cc.isEnabled() == false) {
            UI.getCurrent().setPollInterval(1000);
            cc.setEnabled(true);
            ccc.setEnabled(false);
        }
    });
    hl.setSizeFull();
    hl.setSpacing(true);
    //whdjwandjawd
    //this.addComponent(cc);
    //this.addComponent(ccc);
    this.addComponent(b);

    //this.setHeightUndefined();
    this.setSpacing(true);
    this.setComponentAlignment(b, Alignment.TOP_RIGHT);
    //this.addComponent(c);
    //this.addComponent(ul);
    hl.addComponent(g);

    hl.addComponent(c);

    //this.addComponent(c);
    hl.setExpandRatio(c, 1);
    hl.setExpandRatio(g, 3);
    g.setSizeFull();
    c.setSizeFull();
    this.addComponent(hl);
    //this.setExpandRatio(g, 2);
    this.setExpandRatio(hl, 1);
}

From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java

private void addLinkUserContainer() {

    VerticalLayout cDeletePrompt = new VerticalLayout();
    cPlaceholder.addComponent(cDeletePrompt);
    cPlaceholder.setComponentAlignment(cDeletePrompt, Alignment.MIDDLE_CENTER);
    // cDeletePrompt.setWidth("100%");
    cDeletePrompt.setStyleName("c_link");
    cDeletePrompt.setSpacing(true);/*from w ww.j ava2 s.com*/
    String username = curUser;

    Label lbActivationPrompt = new Label(
            "<span style='text-align: center;'>Please enter Child Username to link to " + username
                    + "'s Account</span>");
    lbActivationPrompt.setContentMode(ContentMode.HTML);
    lbActivationPrompt.setWidth("300px");
    lbActivationPrompt.setStyleName("lb_link_user");

    cDeletePrompt.addComponent(lbActivationPrompt);
    cDeletePrompt.setComponentAlignment(lbActivationPrompt, Alignment.TOP_LEFT);

    VerticalLayout frmDeleteReason = new VerticalLayout();
    frmDeleteReason.setSizeUndefined();
    frmDeleteReason.setSpacing(true);
    frmDeleteReason.setMargin(true);
    cDeletePrompt.addComponent(frmDeleteReason);
    cDeletePrompt.setComponentAlignment(frmDeleteReason, Alignment.TOP_CENTER);

    tFU = new TextField("Child Username");
    tFU.setRequired(true);

    final ComboBox comboUProf = new ComboBox("Select Profile");
    comboUProf.setNullSelectionAllowed(false);
    comboUProf.setRequired(true);
    comboUProf.addItem(8);
    comboUProf.setItemCaption(8, "DEPOSIT_ONLY");

    comboUProf.addItem(9);
    comboUProf.setItemCaption(9, "DEPOSIT_AND_WITHDRAWAL");

    comboUProf.select(8);

    final TextField tFP = new TextField("Parent Account ID");
    tFP.setValue(username);
    tFP.setEnabled(false);

    final TextField tFInitUser = new TextField("Initiating User");
    tFInitUser.setValue(UI.getCurrent().getSession().getAttribute("user").toString());
    tFInitUser.focus();
    tFInitUser.setEnabled(false);

    frmDeleteReason.addComponent(tFU);
    frmDeleteReason.addComponent(comboUProf);
    frmDeleteReason.addComponent(tFP);
    frmDeleteReason.addComponent(tFInitUser);

    HorizontalLayout cPopupBtns = new HorizontalLayout();
    cPopupBtns.setSizeUndefined();
    cPopupBtns.setSpacing(true);

    final Button btnCancel = new Button();
    btnCancel.setIcon(FontAwesome.UNDO);
    btnCancel.setStyleName("btn_link");
    btnCancel.setDescription("Cancel");

    final Button btnSet = new Button("Link");
    btnSet.setDescription("Link specified account.");
    btnSet.setIcon(FontAwesome.LINK);
    cPopupBtns.addComponent(btnSet);
    cPopupBtns.addComponent(btnCancel);
    frmDeleteReason.addComponent(cPopupBtns);

    cDeletePrompt.setComponentAlignment(frmDeleteReason, Alignment.MIDDLE_CENTER);
    btnSet.setClickShortcut(KeyCode.ENTER, null);

    btnSet.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = -6318666715385643538L;

        @Override
        public void buttonClick(ClickEvent event) {

            tFU.validate();
            btnSet.setEnabled(false);
            btnCancel.setEnabled(false);

            Button btn = event.getButton();

            if (ums == null)
                ums = new UserManagementService();
            btn.setEnabled(false);

            String strResponse = null;
            try {

                strResponse = UserManagementService.linkUser(tFP.getValue(),
                        new Integer(comboUProf.getValue().toString()), tFInitUser.getValue(), tFU.getValue());

                if (strResponse.equals("The operation was successful and completed")) {

                    updateLinksTable(tFU.getValue());
                    cPlaceholder.setVisible(false);
                    tFU.setValue("");
                    btnLink.setVisible(true);

                    NotifCustom.show("Link", strResponse);

                } else {
                    NotifCustom.show("Link", strResponse);
                }

            } catch (RemoteException e) {

                e.printStackTrace();

            }

            btnSet.setEnabled(true);
            btnCancel.setEnabled(true);

        }
    });

    btnCancel.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 7161821652386306043L;

        @Override
        public void buttonClick(ClickEvent event) {
            btnLink.setVisible(true);
            cPlaceholder.setVisible(false);

        }

    });

}

From source file:cz.zcu.pia.social.network.frontend.components.profile.friends.ComponentManageFriendRequest.java

/**
 * Adds content//w  ww.  ja v a 2s .  co  m
 */
private void addContent() {
    Long userId = securityHelper.getLogedInUser().getId();
    List<FriendRequest> friendRequestList = friendRequestService.getFriendRequests(userId);
    for (FriendRequest fr : friendRequestList) {
        Button accept = new Button(msgs.getMessage("request.accept"));
        accept.setData(fr);
        accept.addClickListener(new Button.ClickListener() {

            @Override
            public void buttonClick(Button.ClickEvent event) {
                FriendRequest fr = (FriendRequest) event.getButton().getData();
                friendRequestService.confirmFriendRequest(fr);
                table.removeItem(fr.getId());
                parentReference.reload();
            }
        });
        Button deny = new Button(msgs.getMessage("request.deny"));
        HorizontalLayout wrapper = new HorizontalLayout();
        wrapper.setSpacing(true);
        wrapper.addComponent(accept);
        wrapper.addComponent(deny);
        if (fr.isDenyed()) {
            deny.setEnabled(false);
        } else {
            deny.setData(fr);
            deny.addClickListener(new Button.ClickListener() {

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    FriendRequest fr = (FriendRequest) event.getButton().getData();
                    friendRequestService.denyFriendRequest(fr);
                    event.getButton().setEnabled(false);
                }
            });
        }
        table.addItem(new Object[] { fr.getUserSender().getName(), fr.getUserSender().getSurname(),
                getTimeStamp(fr.getDateSent()), wrapper }, fr.getId());
    }

}

From source file:de.decidr.ui.view.AbstractListComponent.java

License:Apache License

protected void updateButtonStatus() {
    int numSelected = 0;
    Object value = contentTable.getValue();
    if (value != null) {
        if (value instanceof Set<?>) {
            numSelected = ((Set<?>) value).size();
        } else {/* ww  w.  j  a  v  a  2  s .  c om*/
            numSelected = 1;
        }
    }
    for (Button button : buttonPolicies.keySet()) {
        if (buttonPolicies.get(button) == ButtonPolicy.ANY_SELECTED) {
            button.setEnabled(numSelected >= 1);
        } else if (buttonPolicies.get(button) == ButtonPolicy.ONE_SELECTED) {
            button.setEnabled(numSelected == 1);
        }
    }

}

From source file:de.escidoc.admintool.view.EscidocPagedTable.java

License:Open Source License

public HorizontalLayout createControls() {
    // final Label itemsPerPageLabel = new Label("Items per page:");
    final Label pageLabel = new Label("Page:&nbsp;", Label.CONTENT_XHTML);
    final TextField currentPageTextField = new TextField();
    currentPageTextField.setValue(String.valueOf(getCurrentPage()));
    currentPageTextField.addValidator(new IntegerValidator(null));
    final Label separatorLabel = new Label("&nbsp;/&nbsp;", Label.CONTENT_XHTML);
    final Label totalPagesLabel = new Label(String.valueOf(getTotalAmountOfPages()), Label.CONTENT_XHTML);
    currentPageTextField.setStyleName(Reindeer.TEXTFIELD_SMALL);
    currentPageTextField.setImmediate(true);
    currentPageTextField.addListener(new ValueChangeListener() {
        private static final long serialVersionUID = -2255853716069800092L;

        public void valueChange(final com.vaadin.data.Property.ValueChangeEvent event) {
            if (currentPageTextField.isValid() && currentPageTextField.getValue() != null) {
                @SuppressWarnings("boxing")
                final int page = Integer.valueOf(String.valueOf(currentPageTextField.getValue()));
                setCurrentPage(page);//from  w w w. j  a  v  a 2s.c o  m
            }
        }
    });
    pageLabel.setWidth(null);
    currentPageTextField.setWidth("20px");
    separatorLabel.setWidth(null);
    totalPagesLabel.setWidth(null);

    final HorizontalLayout controlBar = new HorizontalLayout();
    final HorizontalLayout pageSize = new HorizontalLayout();
    final HorizontalLayout pageManagement = new HorizontalLayout();
    final Button first = new Button("<<", new ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        public void buttonClick(final ClickEvent event) {
            setCurrentPage(0);
        }
    });
    final Button previous = new Button("<", new ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        public void buttonClick(final ClickEvent event) {
            previousPage();
        }
    });
    final Button next = new Button(">", new ClickListener() {
        private static final long serialVersionUID = -1927138212640638452L;

        public void buttonClick(final ClickEvent event) {
            nextPage();
        }
    });
    final Button last = new Button(">>", new ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        public void buttonClick(final ClickEvent event) {
            setCurrentPage(getTotalAmountOfPages());
        }
    });
    first.setStyleName(BaseTheme.BUTTON_LINK);
    previous.setStyleName(BaseTheme.BUTTON_LINK);
    next.setStyleName(BaseTheme.BUTTON_LINK);
    last.setStyleName(BaseTheme.BUTTON_LINK);

    pageLabel.addStyleName("pagedtable-pagecaption");
    currentPageTextField.addStyleName("pagedtable-pagefield");
    separatorLabel.addStyleName("pagedtable-separator");
    totalPagesLabel.addStyleName("pagedtable-total");
    first.addStyleName("pagedtable-first");
    previous.addStyleName("pagedtable-previous");
    next.addStyleName("pagedtable-next");
    last.addStyleName("pagedtable-last");

    pageLabel.addStyleName("pagedtable-label");
    currentPageTextField.addStyleName("pagedtable-label");
    separatorLabel.addStyleName("pagedtable-label");
    totalPagesLabel.addStyleName("pagedtable-label");
    first.addStyleName("pagedtable-button");
    previous.addStyleName("pagedtable-button");
    next.addStyleName("pagedtable-button");
    last.addStyleName("pagedtable-button");

    pageSize.setSpacing(true);
    pageManagement.addComponent(first);
    pageManagement.addComponent(previous);
    pageManagement.addComponent(pageLabel);
    pageManagement.addComponent(currentPageTextField);
    pageManagement.addComponent(separatorLabel);
    pageManagement.addComponent(totalPagesLabel);
    pageManagement.addComponent(next);
    pageManagement.addComponent(last);
    pageManagement.setComponentAlignment(first, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(previous, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(pageLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(currentPageTextField, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(separatorLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(totalPagesLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(next, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(last, Alignment.MIDDLE_LEFT);
    pageManagement.setWidth(null);
    pageManagement.setSpacing(true);
    controlBar.addComponent(pageSize);
    controlBar.addComponent(pageManagement);
    controlBar.setComponentAlignment(pageManagement, Alignment.MIDDLE_CENTER);
    controlBar.setWidth("100%");
    controlBar.setExpandRatio(pageSize, 1);
    addListener(new PageChangeListener() {
        @SuppressWarnings("boxing")
        public void pageChanged(final PagedTableChangeEvent event) {
            previous.setEnabled(true);
            next.setEnabled(true);
            currentPageTextField.setValue(String.valueOf(getCurrentPage()));
            totalPagesLabel.setValue(getTotalAmountOfPages());
        }
    });
    return controlBar;
}

From source file:de.fatalix.bookery.view.admin.AdminView.java

License:Open Source License

public VerticalLayout createServerSettings() {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);/*w  w  w. j av  a 2 s .  c om*/
    Label titleLabel = new Label("General Settings");
    titleLabel.addStyleName(ValoTheme.LABEL_H2);

    //layout.addComponent(titleLabel);
    layout.addComponent(serverSettingsLayout);
    Button resetIndex = new Button("reset Index", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {

            try {
                presenter.resetIndex();
                Notification.show("Succesfully reset Index", Notification.Type.HUMANIZED_MESSAGE);
            } catch (IOException | SolrServerException ex) {
                Notification.show(ex.getMessage(), Notification.Type.ERROR_MESSAGE);
            }
        }
    });
    resetIndex.addStyleName(ValoTheme.BUTTON_DANGER);

    final TextField eMailAdress = new TextField(null, "felix.husse@medavis.de");
    eMailAdress.setColumns(35);
    Button testMail = new Button("Test Mail", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                presenter.sendEmail(eMailAdress.getValue());
                Notification.show("Mail succesfully sent!", Notification.Type.HUMANIZED_MESSAGE);
            } catch (MessagingException ex) {
                Notification.show("Mail failed!" + ex.getMessage(), Notification.Type.ERROR_MESSAGE);
            }
        }
    });
    testMail.setEnabled(true);

    Button resetBatchJobs = new Button("reset BatchJobs", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            presenter.resetBatchJobs();
            Notification.show("Succesfully reset Batchjobs", Notification.Type.HUMANIZED_MESSAGE);

        }
    });
    resetBatchJobs.addStyleName(ValoTheme.BUTTON_DANGER);

    HorizontalLayout mailLayout = new HorizontalLayout(eMailAdress, testMail, resetBatchJobs);
    layout.addComponents(resetIndex, mailLayout);

    return layout;
}

From source file:de.mendelson.comm.as2.webclient2.AS2WebUI.java

private HorizontalLayout createButtonBar() {
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSizeFull();/*from   w w w. j  a va 2s .  c  o  m*/
    Button buttonRefresh = new Button("Refresh");
    buttonRefresh.setIcon(new ThemeResource("images/refresh16x16.gif"));
    buttonRefresh.setEnabled(true);
    buttonRefresh.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            AS2WebUI.this.refreshOverviewTableData();
        }
    });
    buttonLayout.addComponent(buttonRefresh);
    this.buttonDetails = new Button("Message details");
    this.buttonDetails.setIcon(new ThemeResource("images/messagedetails16x16.gif"));
    this.buttonDetails.setEnabled(false);
    this.buttonDetails.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            AS2WebUI.this.displayMessageDetailsOfSelectedRow();
        }
    });
    buttonLayout.addComponent(this.buttonDetails);
    this.labelUsername.setWidth(null);
    buttonLayout.addComponent(this.labelUsername);
    buttonLayout.setComponentAlignment(this.labelUsername, Alignment.MIDDLE_RIGHT);
    buttonLayout.setExpandRatio(buttonRefresh, 0.0f);
    buttonLayout.setExpandRatio(this.buttonDetails, 0.0f);
    buttonLayout.setExpandRatio(this.labelUsername, 1.0f);
    return (buttonLayout);
}

From source file:de.metas.ui.web.vaadin.window.components.ATabToolbar.java

License:Open Source License

private void addToolbarButton(final ActionInfo actionInfo) {
    final String action = actionInfo.getAction();

    final Button button = new Button();
    button.setCaption(action);//  w  w  w  .j  av a2s  .  com
    button.setData(actionInfo);
    button.setEnabled(model.isActionEnabled(action));
    button.addClickListener(actionButtonListener);

    action2button.put(action, button);

    addComponent(button);
}

From source file:de.metas.ui.web.vaadin.window.components.ATabToolbar.java

License:Open Source License

private void onActionEnabledChanged(final String action, final boolean enabled) {
    final Button button = action2button.get(action);
    if (button == null) {
        return;//from w ww  . j a  v  a  2 s. c om
    }

    button.setEnabled(enabled);
}

From source file:de.symeda.sormas.ui.utils.CssStyles.java

License:Open Source License

/**
 * Styles and (de-)activates the given buttons.
 * /*from   w  w  w.  j a v a  2 s .  c o m*/
 * @param activeButton
 *      This button is styled as active but disabled.
 * @param allOrOtherButtons
 *      These buttons lose their active styling and become enabled. {@code activeButton} may be included here.
 */
public static <B extends Button> void styleSectionFilterButton(Button activeButton,
        Iterable<B> allOrOtherButtons) {

    for (Button button : allOrOtherButtons) {
        button.setEnabled(true);
        button.removeStyleName(CssStyles.LINK_ACTIVE);
    }

    activeButton.setEnabled(false);
    activeButton.addStyleName(CssStyles.LINK_ACTIVE);
}