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:songstock.web.extensions.shoppingcart.ShoppingCartController.java

License:Open Source License

@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void contributeUITo(Component component, Object data) throws Exception {
    if (component instanceof Table) {
        Table table = (Table) component;
        table.addContainerProperty(UI_CONTRIBUTION, Button.class, null);
        if (data instanceof List) {
            List itemIds = (List) data;
            for (Object itemId : itemIds) {
                Button buttonAddToCart = new Button("Add to Cart");
                buttonAddToCart.setData(itemId);
                buttonAddToCart.addClickListener(new ClickListener() {

                    private static final long serialVersionUID = 1L;

                    @Override//  w  w  w . j  a v a 2s  .  com
                    public void buttonClick(ClickEvent event) {
                        ShoppingCartController.getInstance().addItem(event.getButton().getData());
                    }
                });
                Property p = table.getItem(itemId).getItemProperty(UI_CONTRIBUTION);
                IUser user = Registry.get(SongStockUI.USER);
                if (user == null)
                    buttonAddToCart.setEnabled(false);
                else
                    buttonAddToCart.setEnabled(true);
                p.setValue(buttonAddToCart);
            }
        } else {
            throw new Exception("Data type not supported");
        }
    } else {
        throw new Exception("Component type not supported");
    }

}

From source file:sph.vaadin.ui.ComponentFactory.java

License:Apache License

/**
 * Creates a new image push Button an optional icon image.
 * /*from  w ww  .  j a  v  a2 s. c o m*/
 * @.post  <em>RESULT.getStyleNames().equals(com.vaadin.ui.themes.BaseTheme.BUTTON_LINK)</em>
 * @param  description the description text of the image button.
 * @param  pathToIcon the path to the icon image of the button.
 * @param  enabled a boolean value specifying if the component should be enabled or not.
 * @return the created component.
 */
public static Button createImageButton(String description, String pathToIcon, boolean enabled) {
    Button btn = new Button();
    btn.setDescription(description);
    btn.setIcon(new ThemeResource(pathToIcon));
    btn.setStyleName(BaseTheme.BUTTON_LINK);
    btn.setEnabled(enabled);
    return btn;
}

From source file:sph.vaadin.ui.ComponentFactory.java

License:Apache License

/**
 * Creates a new image push Button an optional icon image.
 * /*  www . j av a  2  s .c  o  m*/
 * @.post  <em>RESULT.getStyleNames().equals(com.vaadin.ui.themes.BaseTheme.BUTTON_LINK)</em>
 * @param  caption button's caption String. Caption is the visible name of the button.
 * @param  description the description text of the image button.
 * @param  pathToIcon the path to the icon image of the button.
 * @param  enabled a boolean value specifying if the component should be enabled or not.
 * @return the created component.
 */
public static Button createImageButtonWithCaption(String caption, String description, String pathToIcon,
        boolean enabled) {
    Button btn = new Button(caption);
    btn.setDescription(description);
    btn.setIcon(new ThemeResource(pathToIcon));
    btn.setStyleName(BaseTheme.BUTTON_LINK);
    btn.setEnabled(enabled);
    return btn;
}

From source file:sph.vaadin.ui.ComponentFactory.java

License:Apache License

/**
 * Creates a new blue push Button with an optional icon image.
 * //from   w  w w  .  ja v a2  s.c  o  m
 * @.post  <em>RESULT.getStyleNames().equals({@link SPH_Theme#BLUE_BUTTON})</em>
 * @param  caption button's caption String. Caption is the visible name of the button.
 * @param  enabled a boolean value specifying if the component should be enabled or not.
 * @param  pathToIcon the path to the icon image of the button or null.
 * @return the created component.
 */
public static Button createBlueButton(String caption, boolean enabled, String pathToIcon) {
    Button btn = new Button(caption);
    btn.setStyleName(SPH_Theme.BLUE_BUTTON);
    btn.setEnabled(enabled);
    if (pathToIcon != null) {
        btn.setIcon(new ThemeResource(pathToIcon));
    }
    return btn;
}

From source file:sph.vaadin.ui.ComponentFactory.java

License:Apache License

/**
 * Creates a new large blue push Button with an optional icon image.
 * /*from w w  w . j ava  2s.  co m*/
 * @.post  <em>RESULT.getStyleNames().equals({@link SPH_Theme#LARGE_BLUE_BUTTON})</em>
 * @param  caption component's caption String. Caption is the visible name of the component.
 * @param  enabled a boolean value specifying if the component should be enabled or not.
 * @param  pathToIcon the path to the icon image of the button or null.
 * @return the created component.
 */
public static Button createLargeBlueButton(String caption, boolean enabled, String pathToIcon) {
    Button btn = new Button(caption);
    btn.setStyleName(SPH_Theme.LARGE_BLUE_BUTTON);
    btn.setEnabled(enabled);
    if (pathToIcon != null) {
        btn.setIcon(new ThemeResource(pathToIcon));
    }
    return btn;
}

From source file:sph.vaadin.ui.ComponentFactory.java

License:Apache License

/**
 * Creates a new small blue push Button with an optional icon image.
 * /*from  w  ww.ja  v a  2 s  .  c  om*/
 * @.post  <em>RESULT.getStyleNames().equals({@link SPH_Theme#SMALL_BLUE_BUTTON})</em>
 * @param  caption component's caption String. Caption is the visible name of the component.
 * @param  enabled a boolean value specifying if the component should be enabled or not.
 * @param  pathToIcon the path to the icon image of the button or null.
 * @return the created component.
 */
public static Button createSmallBlueButton(String caption, boolean enabled, String pathToIcon) {
    Button btn = new Button(caption);
    btn.setStyleName(SPH_Theme.SMALL_BLUE_BUTTON);
    btn.setEnabled(enabled);
    if (pathToIcon != null) {
        btn.setIcon(new ThemeResource(pathToIcon));
    }
    return btn;
}