Example usage for com.vaadin.ui Button setStyleName

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

Introduction

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

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

From source file:org.airline.CelestiaLogin.java

@Override
protected void init(VaadinRequest request) {
    //Vista final para la UI
    final VerticalLayout layout = new VerticalLayout();

    Panel loginPanel = new Panel("Login");
    CustomLayout login = new CustomLayout("LoginLayout");
    //Seccin de Vista del Login
    //VerticalLayout login=new VerticalLayout(); 
    Label label = new Label("Iniciar Sesin / Registrarse");
    TextField user = new TextField("", "Usuario");
    TextField passwd = new TextField("", "Contrasea");

    Button init_session = new Button("Iniciar Sesin");
    init_session.setStyleName(ValoTheme.BUTTON_PRIMARY);
    init_session.addClickListener(cliqueo -> {
        Notification.show("Bienvenido " + user.getValue());
    });/*from   ww w . j  a va2 s  . c  om*/

    login.addComponent(label);
    login.addComponent(user);
    login.addComponent(passwd);
    login.addComponent(init_session);
    login.setWidth("500px");
    //login.setMargin(true);
    login.setResponsive(true);

    layout.addComponent(login);
    layout.setComponentAlignment(login, Alignment.MIDDLE_CENTER);
    setContent(login);
}

From source file:org.apache.ace.tageditor.TagTableEntry.java

License:Apache License

public Object addTo(final Table table) {
    Button deleteButton = new Button() {
        @Override/*from  w  ww  .ja v  a2  s . c om*/
        public boolean isEnabled() {
            return super.isEnabled() && m_id != null;
        }
    };
    deleteButton.setCaption("x");
    deleteButton.setStyleName("small");
    deleteButton.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            removeFrom(table);
        }
    });

    m_id = table.addItem(new Object[] { m_keyField, m_valueField, deleteButton }, null);
    return m_id;
}

From source file:org.apache.ace.useradmin.ui.vaadin.UserAdminWindow.java

License:Apache License

/**
 * Creates a new {@link UserAdminWindow} instance.
 *//*from   ww  w .j  ava2s. c  o m*/
public UserAdminWindow() {
    setCaption("Manage users");
    setWidth("30%");

    m_userTable = new Table();
    m_userTable.setSizeFull();
    m_userTable.setImmediate(true);
    m_userTable.setSelectable(true);
    m_userTable.setSortDisabled(false);
    m_userTable.addContainerProperty("User", UserDTO.class, null);
    m_userTable.addListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            selectUser((UserDTO) m_userTable.getValue());
        }
    });

    VerticalLayout usersList = new VerticalLayout();
    usersList.setSizeFull();
    usersList.addComponent(m_userTable);

    Button addUserButton = new Button("+");
    addUserButton.setStyleName(Reindeer.BUTTON_SMALL);
    addUserButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            prepareForNewUser();
        }
    });

    m_removeUserButton = new Button();
    m_removeUserButton.setStyleName(Reindeer.BUTTON_SMALL);
    m_removeUserButton.setCaption("-");
    m_removeUserButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            removeSelectedUser((UserDTO) m_userTable.getValue());
        }
    });

    HorizontalLayout addRemoveUserButtons = new HorizontalLayout();
    addRemoveUserButtons.setMargin(true, false, false, false);
    addRemoveUserButtons.setSpacing(true);
    addRemoveUserButtons.addComponent(addUserButton);
    addRemoveUserButtons.addComponent(m_removeUserButton);
    usersList.addComponent(addRemoveUserButtons);

    usersList.setExpandRatio(m_userTable, 1.0f);
    usersList.setExpandRatio(addRemoveUserButtons, 0.0f);

    ValueChangeListener changeListener = new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            m_applyButton.setEnabled(isCurrentFormValid());
            m_cancelButton.setEnabled(true);
        }
    };

    m_usernameTextField = new TextField();
    m_usernameTextField.setCaption("Username");
    m_usernameTextField.setImmediate(true);
    m_usernameTextField.setRequired(true);
    m_usernameTextField.addListener(changeListener);

    m_passwordTextField = new PasswordField();
    m_passwordTextField.setCaption("Password");
    m_passwordTextField.setImmediate(true);
    m_passwordTextField.setRequired(true);
    m_passwordTextField.addListener(changeListener);

    m_groupSelect = new Select();
    m_groupSelect.setCaption("Role");
    m_groupSelect.setImmediate(true);
    m_groupSelect.setNullSelectionAllowed(false);
    m_groupSelect.setRequired(true);
    m_groupSelect.addListener(changeListener);

    FormLayout formLayout = new FormLayout();
    formLayout.addComponent(m_usernameTextField);
    formLayout.addComponent(m_passwordTextField);
    formLayout.addComponent(m_groupSelect);

    m_applyButton = new Button();
    m_applyButton.setCaption("Apply changes");
    m_applyButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            storeUserInfo();
        }
    });

    m_cancelButton = new Button();
    m_cancelButton.setEnabled(false);
    m_cancelButton.setCaption("Cancel");
    m_cancelButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            selectUser((UserDTO) m_userTable.getValue());
        }
    });

    HorizontalLayout addUserButtons = new HorizontalLayout();
    addUserButtons.setMargin(true, false, false, false);
    addUserButtons.setSpacing(true);
    addUserButtons.addComponent(m_applyButton);
    addUserButtons.addComponent(m_cancelButton);

    formLayout.addComponent(addUserButtons);

    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSizeFull();
    horizontalLayout.setSpacing(true);
    horizontalLayout.addComponent(usersList);
    horizontalLayout.addComponent(formLayout);

    horizontalLayout.setExpandRatio(usersList, 0.35f);
    horizontalLayout.setExpandRatio(formLayout, 0.65f);

    addComponent(horizontalLayout);

    updateState(null, false /* editAllowed */);
}

From source file:org.apache.ace.webui.vaadin.AddArtifactWindow.java

License:Apache License

/**
 * Create a new button that delete an OBREntry on-click.
 * //from  w ww  .  j a v a  2 s .c om
 * @param entry
 *            The entry
 * @return The button
 */
private Button createDeleteOBREntryButton(final OBREntry entry) {
    Button button = new Button("x");
    button.setStyleName(Reindeer.BUTTON_SMALL);
    button.setDescription("Delete " + entry.getName());

    button.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            event.getButton().setEnabled(false);

            try {
                int code = OBRUtil.deleteOBREntry(getConnectionFactory(), entry, m_obrUrl);
                if (code == HttpServletResponse.SC_OK) {
                    m_artifactsTable.removeItem(entry.getUri());
                } else {
                    showErrorNotification("Failed to delete resource",
                            "The OBR returned an unexpected response code: " + code);
                }
            } catch (IOException e) {
                showErrorNotification("Failed to delete resource", "Reason: " + e.getMessage());
            }

        }
    });

    return button;
}

From source file:org.apache.ace.webui.vaadin.component.BaseObjectPanel.java

License:Apache License

/**
 * Creates a remove-item button for the given repository object.
 * /*w w w  . j  a  v  a2s.  com*/
 * @param object
 *            the object to create a remove-item button, cannot be <code>null</code>;
 * @param displayName
 *            the display name for the description of the button, cannot be <code>null</code>.
 * @return a remove-item button, never <code>null</code>.
 */
protected final Button createRemoveItemButton(RepositoryObject object, String displayName) {
    Button result = new Button();
    result.setIcon(createIconResource("trash"));
    result.setData(object.getDefinition());
    result.setStyleName("small tiny");
    result.setDescription("Delete " + displayName);
    result.setDisableOnClick(true);

    result.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            try {
                handleItemRemoveObject(event.getButton().getData());
            } catch (Exception e) {
                // ACE-246: notify user when the removal failed!
                getWindow().showNotification("Failed to remove item!", "<br/>Reason: " + e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });

    return result;
}

From source file:org.apache.ace.webui.vaadin.component.BaseObjectPanel.java

License:Apache License

/**
 * Creates a remove-link button for the given repository object.
 * /*w w w.  j  a  v  a  2  s .co  m*/
 * @param object
 *            the object to create a remove-link button, cannot be <code>null</code>;
 * @param displayName
 *            the display name for the description of the button, cannot be <code>null</code>.
 * @return a remove-link button, never <code>null</code>.
 */
protected final Button createRemoveLinkButton(RepositoryObject object, String displayName) {
    Button result = new Button();
    result.setIcon(createIconResource("unlink"));
    result.setStyleName("small tiny");
    result.setData(object.getDefinition());
    result.setDescription("Unlink " + displayName);
    // Only enable this button when actually selected...
    result.setEnabled(false);
    result.setDisableOnClick(true);

    result.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            handleItemRemoveLink(event.getButton().getData());
        }

    });

    return result;
}

From source file:org.apache.ace.webui.vaadin.component.ConfirmationDialog.java

License:Apache License

/**
 * Adds all components to this dialog./*from w  ww.ja va2 s.c om*/
 * 
 * @param message
 *            the optional message to display, can be <code>null</code>;
 * @param buttonNames
 *            the names of the buttons to add, never <code>null</code> or empty.
 */
protected void addComponents(String message, String defaultButton, String... buttonNames) {
    if (message != null) {
        addComponent(new Label(message));
    }

    GridLayout gl = new GridLayout(buttonNames.length + 1, 1);
    gl.setSpacing(true);
    gl.setWidth("100%");

    gl.addComponent(new Label(" "));
    gl.setColumnExpandRatio(0, 1.0f);

    for (String buttonName : buttonNames) {
        Button button = new Button(buttonName, this);
        button.setData(buttonName);
        if (defaultButton != null && defaultButton.equals(buttonName)) {
            button.setStyleName(Reindeer.BUTTON_DEFAULT);
            button.setClickShortcut(KeyCode.ENTER);
            // Request focus in this window...
            button.focus();
        }
        gl.addComponent(button);
    }

    addComponent(gl);
}

From source file:org.apache.ace.webui.vaadin.ManageResourceProcessorWindow.java

License:Apache License

private Button createRemoveButton(final ArtifactObject rp) {
    Button button = new Button("x");
    button.setStyleName(Reindeer.BUTTON_SMALL);
    button.setDescription("Remove " + rp.getAttribute(Constants.BUNDLE_SYMBOLICNAME));
    button.addListener(new ClickListener() {
        @Override//  w w  w  . j a v  a2s .com
        public void buttonClick(ClickEvent event) {
            event.getButton().setEnabled(false);

            try {
                getArtifactRepository().remove(rp);
                m_artifactsTable.removeItem(rp.getDefinition());
            } catch (Exception e) {
                getParent().showNotification("Failed to delete resource", "Reason: <br/>" + e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });
    return button;
}

From source file:org.apache.usergrid.chop.webapp.view.chart.layout.item.NoteLayout.java

License:Apache License

private Button createButton(String caption, String position, boolean visible) {

    Button button = UIUtil.addButton(this, caption, position, "50px");
    button.setStyleName(Reindeer.BUTTON_LINK);
    button.setVisible(visible);//from   w  ww  .  ja va  2s  .c o m

    return button;
}

From source file:org.apache.usergrid.chop.webapp.view.main.Breadcrumb.java

License:Apache License

private Button addButton(final int pos, int left, String width) {

    String position = String.format("left: %spx; top: 10px;", left);

    Button button = UIUtil.addButton(this, "", position, width);
    button.setStyleName(Reindeer.BUTTON_LINK);

    button.addClickListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            buttonClicked(pos);/*from  w  w  w  .j  a va2s .co m*/
        }
    });

    return button;
}