Example usage for com.vaadin.ui Button addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:com.freebox.engeneering.application.web.layout.LeftSideBarController.java

License:Apache License

private void createFooterSideBar() {
    VerticalLayout verticalLayout = super.getView();

    sideBarFooter.setSizeUndefined();/*w  ww  .j av a  2 s. c  o m*/
    sideBarFooter.addStyleName("user");
    Image profilePic = new Image(null, new ThemeResource("img/profile-pic.png"));
    profilePic.setWidth("34px");
    sideBarFooter.addComponent(profilePic);
    Label userName = new Label("MOHELLEBI ATAF");
    userName.setSizeUndefined();
    sideBarFooter.addComponent(userName);

    Command cmd = new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
        }
    };
    MenuBar settings = new MenuBar();
    MenuItem settingsMenu = settings.addItem("", null);
    settingsMenu.setStyleName("icon-cog");
    settingsMenu.addItem("Settings", cmd);
    settingsMenu.addItem("Preferences", cmd);
    settingsMenu.addSeparator();
    settingsMenu.addItem("My Account", cmd);
    sideBarFooter.addComponent(settings);

    Button exit = new NativeButton("Exit");
    exit.addStyleName("icon-cancel");
    exit.setDescription("Sign Out");
    sideBarFooter.addComponent(exit);
    exit.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
        }
    });

    verticalLayout.addComponent(sideBarFooter);
}

From source file:com.freebox.engeneering.application.web.layout.LeftSideBarController.java

License:Apache License

private void createMenuSideBar() {

    menu.addStyleName("no-vertical-drag-hints");
    menu.addStyleName("no-horizontal-drag-hints");
    menu.addStyleName("menu");
    menu.setHeight("100%");

    Button freeboxState;
    Button freeboxDownloads;/* ww  w  .ja va2  s .  co  m*/
    Button freeboxContacts;
    Button freeboxCalls;

    freeboxState = new NativeButton("Etat Freebox");//Etat de la freebox
    freeboxState.addStyleName("icon-dashboard");

    freeboxState.addClickListener(new Button.ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            getEventProcessor().fireEvent("register");
        }
    });

    menu.addComponent(freeboxState);

    freeboxDownloads = new NativeButton("Dashbord");//Tlchargement
    freeboxDownloads.addStyleName("icon-sales");

    freeboxDownloads.addClickListener(new Button.ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            eventProcessor.fireEvent("dashboard", "");
        }
    });

    menu.addComponent(freeboxDownloads);

    freeboxContacts = new NativeButton("Contacts");
    freeboxContacts.addStyleName("icon-transactions");

    freeboxContacts.addClickListener(new Button.ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            getEventProcessor().fireEvent("register");
        }
    });

    menu.addComponent(freeboxContacts);

    freeboxCalls = new NativeButton("Journal");
    freeboxCalls.addStyleName("icon-reports");

    freeboxCalls.addClickListener(new Button.ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            getEventProcessor().fireEvent("register");
        }
    });

    menu.addComponent(freeboxCalls);

    freeboxState = new NativeButton("Explorateur");
    freeboxState.addStyleName("icon-schedule");

    freeboxState.addClickListener(new Button.ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            getEventProcessor().fireEvent("explorer");
        }
    });

    menu.addComponent(freeboxState);

    freeboxState = new NativeButton("Etat");
    freeboxState.addStyleName("icon-dashboard");

    freeboxState.addClickListener(new Button.ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            getEventProcessor().fireEvent("register");
        }
    });

    menu.addComponent(freeboxState);

    freeboxState = new NativeButton("Etat");
    freeboxState.addStyleName("icon-dashboard");

    freeboxState.addClickListener(new Button.ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

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

            getEventProcessor().fireEvent("register");
        }
    });

    menu.addComponent(freeboxState);

    freeboxState = new NativeButton("Etat");
    freeboxState.addStyleName("icon-dashboard");

    freeboxState.addClickListener(new Button.ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            getEventProcessor().fireEvent("register");
        }
    });

    VerticalLayout verticalLayout = super.getView();
    verticalLayout.addComponent(menu);
    verticalLayout.setExpandRatio(menu, 1);

}

From source file:com.github.djabry.platform.vaadin.view.BannerView.java

License:Open Source License

private Button buildLogoutButton() {
    Button logout = new Button("Sign out");
    logout.setIcon(FontAwesome.SIGN_OUT);
    logout.addStyleName(ValoTheme.BUTTON_PRIMARY);
    logout.addClickListener(new ClickListener() {

        public void buttonClick(Button.ClickEvent event) {
            logoutAction.run();//w w  w  .  ja v  a2s  .co  m
        }
    });
    logout.setVisible(false);
    return logout;
}

From source file:com.github.djabry.platform.vaadin.view.LoginView.java

License:Open Source License

private Component buildFields() {
    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);//from  w  w  w  . ja  va  2s  .c  o m

    userField = new TextField("Username");

    userField.setIcon(FontAwesome.USER);
    userField.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    //username.addStyleName(ValoTheme.TEXTFIELD_TINY);

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

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

    fields.addComponents(userField, passwordField, signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    signin.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            loginAction.login(userField.getValue(), passwordField.getValue());
        }
    });
    return fields;
}

From source file:com.github.peholmst.mvp4vaadin.navigation.ui.NavigationBar.java

License:Apache License

/**
 * Creates and adds a new button to the navigation bar. Listeners etc. will
 * be added by the {@link #addBreadcrumbForView(ControllableView)} method.
 * /*from w ww.  ja va2s . c o  m*/
 * @param viewName
 *            the name of the view to show on the button.
 * @return the added button.
 */
protected Button addViewButton(String viewName) {
    final Button btn = new Button(viewName);
    btn.setStyleName(BaseTheme.BUTTON_LINK);
    btn.setSizeUndefined();
    btn.addStyleName(BREADCRUMB_ELEMENT);
    addComponent(btn);
    // setComponentAlignment(btn, Alignment.MIDDLE_LEFT);
    return btn;
}

From source file:com.haulmont.cuba.web.exception.NoUserSessionHandler.java

License:Apache License

protected void showNoUserSessionDialog(App app) {
    Messages messages = AppBeans.get(Messages.NAME);

    Window dialog = new NoUserSessionExceptionDialog();
    dialog.setStyleName("c-nousersession-dialog");
    dialog.setCaption(messages.getMainMessage("dialogs.Information", locale));
    dialog.setClosable(false);//  w ww  . ja  va2  s.  com
    dialog.setResizable(false);
    dialog.setModal(true);

    AppUI ui = app.getAppUI();

    if (ui.isTestMode()) {
        dialog.setCubaId("optionDialog");
        dialog.setId(ui.getTestIdManager().getTestId("optionDialog"));
    }

    Label messageLab = new CubaLabel();
    messageLab.setWidthUndefined();
    messageLab.setValue(messages.getMainMessage("noUserSession.message", locale));

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setWidthUndefined();
    layout.setStyleName("c-nousersession-dialog-layout");
    layout.setSpacing(true);
    dialog.setContent(layout);

    Button reloginBtn = new Button();
    if (ui.isTestMode()) {
        reloginBtn.setCubaId("reloginBtn");
        reloginBtn.setId(ui.getTestIdManager().getTestId("reloginBtn"));
    }
    reloginBtn.addStyleName(WebButton.ICON_STYLE);
    reloginBtn.addStyleName("c-primary-action");
    reloginBtn.addClickListener(event -> relogin());
    reloginBtn.setCaption(messages.getMainMessage(Type.OK.getMsgKey()));

    String iconName = AppBeans.get(Icons.class).get(Type.OK.getIconKey());
    reloginBtn.setIcon(WebComponentsHelper.getIcon(iconName));

    ClientConfig clientConfig = AppBeans.get(Configuration.class).getConfig(ClientConfig.class);
    setClickShortcut(reloginBtn, clientConfig.getCommitShortcut());

    reloginBtn.focus();

    layout.addComponent(messageLab);
    layout.addComponent(reloginBtn);

    layout.setComponentAlignment(reloginBtn, Alignment.BOTTOM_RIGHT);

    ui.addWindow(dialog);

    dialog.center();
}

From source file:com.haulmont.cuba.web.WebWindowManager.java

License:Apache License

@Override
public void showMessageDialog(String title, String message, MessageType messageType) {
    backgroundWorker.checkUIAccess();/* www.  j a  va  2  s  .  com*/

    final com.vaadin.ui.Window vWindow = new CubaWindow(title);

    if (ui.isTestMode()) {
        vWindow.setCubaId("messageDialog");
        vWindow.setId(ui.getTestIdManager().getTestId("messageDialog"));
    }

    String closeShortcut = clientConfig.getCloseShortcut();
    KeyCombination closeCombination = KeyCombination.create(closeShortcut);

    vWindow.addAction(new ShortcutListener("Esc", closeCombination.getKey().getCode(),
            KeyCombination.Modifier.codes(closeCombination.getModifiers())) {
        @Override
        public void handleAction(Object sender, Object target) {
            vWindow.close();
        }
    });

    vWindow.addAction(new ShortcutListener("Enter", ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            vWindow.close();
        }
    });

    VerticalLayout layout = new VerticalLayout();
    layout.setStyleName("c-app-message-dialog");
    layout.setSpacing(true);
    if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) {
        layout.setWidthUndefined();
    }
    vWindow.setContent(layout);

    Label messageLab = new CubaLabel();
    messageLab.setValue(message);
    if (MessageType.isHTML(messageType)) {
        messageLab.setContentMode(ContentMode.HTML);
    } else {
        messageLab.setContentMode(ContentMode.TEXT);
    }
    if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) {
        messageLab.setWidthUndefined();
    }
    layout.addComponent(messageLab);

    DialogAction action = new DialogAction(Type.OK);
    Button button = WebComponentsHelper.createButton();

    button.setCaption(action.getCaption());
    button.setIcon(WebComponentsHelper.getIcon(action.getIcon()));
    button.addStyleName(WebButton.ICON_STYLE);
    button.addClickListener(event -> vWindow.close());

    button.focus();

    layout.addComponent(button);

    layout.setComponentAlignment(button, Alignment.BOTTOM_RIGHT);

    float width;
    SizeUnit unit;
    DialogParams dialogParams = getDialogParams();
    if (messageType.getWidth() != null) {
        width = messageType.getWidth();
        unit = messageType.getWidthUnit();
    } else if (dialogParams.getWidth() != null) {
        width = dialogParams.getWidth();
        unit = dialogParams.getWidthUnit();
    } else {
        SizeWithUnit size = SizeWithUnit
                .parseStringSize(app.getThemeConstants().get("cuba.web.WebWindowManager.messageDialog.width"));
        width = size.getSize();
        unit = size.getUnit();
    }

    vWindow.setWidth(width, unit != null ? WebWrapperUtils.toVaadinUnit(unit) : Unit.PIXELS);
    vWindow.setResizable(false);

    boolean modal = true;
    if (!hasModalWindow()) {
        if (messageType.getModal() != null) {
            modal = messageType.getModal();
        } else if (dialogParams.getModal() != null) {
            modal = dialogParams.getModal();
        }
    }
    vWindow.setModal(modal);

    boolean closeOnClickOutside = false;
    if (vWindow.isModal()) {
        if (messageType.getCloseOnClickOutside() != null) {
            closeOnClickOutside = messageType.getCloseOnClickOutside();
        }
    }
    ((CubaWindow) vWindow).setCloseOnClickOutside(closeOnClickOutside);

    if (messageType.getMaximized() != null) {
        if (messageType.getMaximized()) {
            vWindow.setWindowMode(WindowMode.MAXIMIZED);
        } else {
            vWindow.setWindowMode(WindowMode.NORMAL);
        }
    }

    dialogParams.reset();

    ui.addWindow(vWindow);
    vWindow.center();
    vWindow.focus();
}

From source file:com.haulmont.cuba.web.WebWindowManager.java

License:Apache License

@Override
public void showOptionDialog(String title, String message, MessageType messageType, Action[] actions) {
    backgroundWorker.checkUIAccess();// w w w .j  a  v a 2s.c om

    final com.vaadin.ui.Window window = new CubaWindow(title);

    if (ui.isTestMode()) {
        window.setCubaId("optionDialog");
        window.setId(ui.getTestIdManager().getTestId("optionDialog"));
    }
    window.setClosable(false);

    Label messageLab = new CubaLabel();
    messageLab.setValue(message);
    if (MessageType.isHTML(messageType)) {
        messageLab.setContentMode(ContentMode.HTML);
    } else {
        messageLab.setContentMode(ContentMode.TEXT);
    }
    if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) {
        messageLab.setWidthUndefined();
    }

    float width;
    SizeUnit unit;
    if (messageType.getWidth() != null) {
        width = messageType.getWidth();
        unit = messageType.getWidthUnit();
    } else if (getDialogParams().getWidth() != null) {
        width = getDialogParams().getWidth();
        unit = getDialogParams().getWidthUnit();
    } else {
        SizeWithUnit size = SizeWithUnit
                .parseStringSize(app.getThemeConstants().get("cuba.web.WebWindowManager.optionDialog.width"));
        width = size.getSize();
        unit = size.getUnit();
    }

    if (messageType.getModal() != null) {
        log.warn("MessageType.modal is not supported for showOptionDialog");
    }

    getDialogParams().reset();

    window.setWidth(width, unit != null ? WebWrapperUtils.toVaadinUnit(unit) : Unit.PIXELS);
    window.setResizable(false);
    window.setModal(true);

    boolean closeOnClickOutside = false;
    if (window.isModal()) {
        if (messageType.getCloseOnClickOutside() != null) {
            closeOnClickOutside = messageType.getCloseOnClickOutside();
        }
    }
    ((CubaWindow) window).setCloseOnClickOutside(closeOnClickOutside);

    if (messageType.getMaximized() != null) {
        if (messageType.getMaximized()) {
            window.setWindowMode(WindowMode.MAXIMIZED);
        } else {
            window.setWindowMode(WindowMode.NORMAL);
        }
    }

    VerticalLayout layout = new VerticalLayout();
    layout.setStyleName("c-app-option-dialog");
    layout.setSpacing(true);
    if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) {
        layout.setWidthUndefined();
    }
    window.setContent(layout);

    HorizontalLayout buttonsContainer = new HorizontalLayout();
    buttonsContainer.setSpacing(true);

    boolean hasPrimaryAction = false;
    Map<Action, Button> buttonMap = new HashMap<>();
    for (Action action : actions) {
        Button button = WebComponentsHelper.createButton();
        button.setCaption(action.getCaption());
        button.addClickListener(event -> {
            try {
                action.actionPerform(null);
            } finally {
                ui.removeWindow(window);
            }
        });

        if (StringUtils.isNotEmpty(action.getIcon())) {
            button.setIcon(WebComponentsHelper.getIcon(action.getIcon()));
            button.addStyleName(WebButton.ICON_STYLE);
        }

        if (action instanceof AbstractAction && ((AbstractAction) action).isPrimary()) {
            button.addStyleName("c-primary-action");
            button.focus();

            hasPrimaryAction = true;
        }

        if (ui.isTestMode()) {
            button.setCubaId("optionDialog_" + action.getId());
            button.setId(ui.getTestIdManager().getTestId("optionDialog_" + action.getId()));
        }

        buttonsContainer.addComponent(button);
        buttonMap.put(action, button);
    }

    assignDialogShortcuts(buttonMap);

    if (!hasPrimaryAction && actions.length > 0) {
        ((Button) buttonsContainer.getComponent(0)).focus();
    }

    layout.addComponent(messageLab);
    layout.addComponent(buttonsContainer);

    layout.setExpandRatio(messageLab, 1);
    layout.setComponentAlignment(buttonsContainer, Alignment.BOTTOM_RIGHT);

    ui.addWindow(window);
    window.center();
}

From source file:com.hris.payroll.thirteenthmonth.ThirteenthMonth.java

private Button generate13thMonth() {
    Button button = new Button("13th MONTH");
    button.setWidth("200px");
    button.setIcon(FontAwesome.SPINNER);
    button.addStyleName(ValoTheme.BUTTON_PRIMARY);
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    button.addClickListener((Button.ClickEvent event) -> {
        status.setValue(" Loading...");
        current = 1.0;/*from w w  w  .ja v  a  2s . c o  m*/
        dataSize = es.findEmployeeByBranch(getBranchId(), employmentStatus.getValue().toString(),
                CommonUtil.convertStringToInteger(year.getValue().toString())).size();

        populateDataGrid();
    });

    return button;
}

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);
        }/*  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);
    }
}