Example usage for com.vaadin.ui.themes ValoTheme BUTTON_ICON_ONLY

List of usage examples for com.vaadin.ui.themes ValoTheme BUTTON_ICON_ONLY

Introduction

In this page you can find the example usage for com.vaadin.ui.themes ValoTheme BUTTON_ICON_ONLY.

Prototype

String BUTTON_ICON_ONLY

To view the source code for com.vaadin.ui.themes ValoTheme BUTTON_ICON_ONLY.

Click Source Link

Document

Only show the icon in the button, and size the button to a square shape.

Usage

From source file:org.eclipse.hawkbit.ui.decorators.SPUIButtonStylePrimarySmall.java

License:Open Source License

@Override
public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) {
    button.addStyleName(ValoTheme.BUTTON_PRIMARY + " " + ValoTheme.BUTTON_SMALL);
    // Set Style/*from w w w  .  jav  a 2s .  co m*/
    if (null != style) {
        if (setStyle) {
            button.setStyleName(style);
        } else {
            button.addStyleName(style);
        }

    }
    // Set icon
    if (null != icon) {
        button.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        button.setIcon(icon);
    }
    return button;
}

From source file:org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall.java

License:Open Source License

@Override
public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) {
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    if (style != null) {
        if (setStyle) {
            button.setStyleName(style);// www.j  av a2  s.c o  m
        } else {
            button.addStyleName(style);
        }
    }
    if (icon != null) {
        button.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        button.setIcon(icon);
    }
    return button;
}

From source file:org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder.java

License:Open Source License

/**
 * Decorate Button and return./*from   w w  w  .ja v  a 2 s .com*/
 * 
 * @param button
 *            as Button
 * @param style
 *            as String
 * @param setStyle
 *            as String
 * @param icon
 *            as resource
 * @return Button
 */
@Override
public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) {
    // Set Style
    if (null != style && setStyle) {
        button.addStyleName(style);
    }
    button.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    // Set icon
    if (null != icon) {
        button.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        button.addStyleName("button-no-border");
        button.setIcon(icon);
    }

    return button;
}

From source file:org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorderUH.java

License:Open Source License

@Override
public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) {
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    button.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
    button.setHeightUndefined();/* ww  w  . j  a va2s  .c om*/
    // Set Style
    if (null != style) {
        if (setStyle) {
            button.setStyleName(style);
        } else {
            button.addStyleName(style);
        }
    }
    // Set icon
    if (null != icon) {
        button.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        button.setIcon(icon);
    }
    return button;
}

From source file:org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorderUHS.java

License:Open Source License

@Override
public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) {
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    button.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    button.setHeightUndefined();/*from w  w  w  .  ja  v  a2  s. com*/
    button.setSizeUndefined();
    // Set Style
    if (null != style) {
        if (setStyle) {
            button.setStyleName(style);
        } else {
            button.addStyleName(style);
        }
    }
    // Set icon
    if (null != icon) {
        button.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        button.setIcon(icon);
    }
    return button;
}

From source file:org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny.java

License:Open Source License

@Override
public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) {
    button.addStyleName(ValoTheme.BUTTON_TINY);
    // Set Style/*from w  ww  .  j  a va  2  s.  c  om*/
    if (null != style) {
        if (setStyle) {
            button.setStyleName(style);
        } else {
            button.addStyleName(style);
        }
    }
    // Set icon
    if (null != icon) {
        button.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        button.setIcon(icon);
    }
    return button;
}

From source file:org.eclipse.hawkbit.ui.management.targettable.TargetTable.java

License:Open Source License

private Button getTagetPinButton(final Object itemId) {
    final Button pinBtn = new Button();
    final String controllerId = (String) getContainerDataSource().getItem(itemId)
            .getItemProperty(SPUILabelDefinitions.VAR_CONT_ID).getValue();
    final TargetIdName pinnedTarget = new TargetIdName((Long) itemId, controllerId);
    final StringBuilder pinBtnStyle = new StringBuilder(ValoTheme.BUTTON_BORDERLESS_COLORED);
    pinBtnStyle.append(' ');
    pinBtnStyle.append(ValoTheme.BUTTON_SMALL);
    pinBtnStyle.append(' ');
    pinBtnStyle.append(ValoTheme.BUTTON_ICON_ONLY);
    pinBtn.setStyleName(pinBtnStyle.toString());
    pinBtn.setHeightUndefined();//  w  w w .  ja v  a 2 s .c  om
    pinBtn.setData(pinnedTarget);
    pinBtn.setId(UIComponentIdProvider.TARGET_PIN_ICON + controllerId);
    pinBtn.addClickListener(this::addPinClickListener);
    pinBtn.setDescription(getI18n().getMessage(UIMessageIdProvider.TOOLTIP_TARGET_PIN));
    if (isPinned(pinnedTarget)) {
        pinBtn.addStyleName(TARGET_PINNED);
        targetPinned = Boolean.TRUE;
        targetPinnedBtn = pinBtn;
        getEventBus().publish(this, PinUnpinEvent.PIN_TARGET);
    }
    pinBtn.addStyleName(SPUIStyleDefinitions.TARGET_STATUS_PIN_TOGGLE);
    HawkbitCommonUtil.applyStatusLblStyle(this, pinBtn, itemId);
    return pinBtn;
}

From source file:org.ikasan.dashboard.ui.administration.panel.PolicyManagementPanel.java

License:BSD License

/**
 * /*from  ww w  .  j  av  a 2 s .c om*/
 */
protected void createPolicyDropPanel() {
    this.policyDropPanel = new Panel();

    Label rolePoliciesLabel = new Label("Role/Policy Associations");
    rolePoliciesLabel.setStyleName(ValoTheme.LABEL_HUGE);

    this.policyDropPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    this.policyDropPanel.setHeight("100%");
    this.policyDropPanel.setWidth("100%");

    this.rolesCombo = new ComboBox("Roles");
    this.rolesCombo.setWidth("90%");
    this.rolesCombo.addValueChangeListener(new Property.ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            final Role role = (Role) event.getProperty().getValue();

            if (role != null) {
                List<Policy> policies = securityService.getAllPoliciesWithRole(role.getName());

                PolicyManagementPanel.this.policyDropTable.removeAllItems();

                for (final Policy policy : policies) {
                    Button deleteButton = new Button();
                    deleteButton.setIcon(VaadinIcons.TRASH);
                    deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                    deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                    deleteButton.setDescription("Remove Policy from this Role");

                    deleteButton.addClickListener(new Button.ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            role.getPolicies().remove(policy);
                            PolicyManagementPanel.this.saveRole(role);

                            PolicyManagementPanel.this.policyDropTable.removeItem(policy.getName());
                            PolicyManagementPanel.this.roleTable.removeItem(role);
                        }
                    });

                    PolicyManagementPanel.this.policyDropTable
                            .addItem(new Object[] { policy.getName(), deleteButton }, policy.getName());
                }
            }
        }
    });

    this.policyDropTable = new Table();
    this.policyDropTable.addContainerProperty("Role Policies", String.class, null);
    this.policyDropTable.addContainerProperty("", Button.class, null);
    this.policyDropTable.setHeight("700px");
    this.policyDropTable.setWidth("300px");

    this.policyDropTable.setDragMode(TableDragMode.ROW);
    this.policyDropTable.setDropHandler(new DropHandler() {
        @Override
        public void drop(final DragAndDropEvent dropEvent) {
            // criteria verify that this is safe
            logger.info("Trying to drop: " + dropEvent);

            if (rolesCombo.getValue() == null) {
                // Do nothing if there is no role selected
                logger.info("Ignoring drop: " + dropEvent);
                return;
            }

            final WrapperTransferable t = (WrapperTransferable) dropEvent.getTransferable();

            final AutocompleteField sourceContainer = (AutocompleteField) t.getDraggedComponent();
            logger.info("sourceContainer.getText(): " + sourceContainer.getText());

            Button deleteButton = new Button();
            deleteButton.setIcon(VaadinIcons.TRASH);
            deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
            deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
            deleteButton.setDescription("Remove Policy from this Role");

            final Policy policy = PolicyManagementPanel.this.securityService
                    .findPolicyByName(sourceContainer.getText());

            final Role selectedRole = PolicyManagementPanel.this.securityService
                    .findRoleByName(((Role) rolesCombo.getValue()).getName());

            deleteButton.addClickListener(new Button.ClickListener() {
                public void buttonClick(ClickEvent event) {
                    selectedRole.getPolicies().remove(policy);
                    PolicyManagementPanel.this.saveRole(selectedRole);

                    policyDropTable.removeItem(policy.getName());
                    roleTable.removeItem(selectedRole);
                }
            });

            PolicyManagementPanel.this.policyDropTable.addItem(
                    new Object[] { sourceContainer.getText(), deleteButton }, sourceContainer.getText());

            selectedRole.getPolicies().add(policy);

            PolicyManagementPanel.this.saveRole(selectedRole);
            policy.getRoles().add(selectedRole);

            PolicyManagementPanel.this.roleTable.removeAllItems();

            for (final Role role : policy.getRoles()) {
                Button roleDeleteButton = new Button();
                roleDeleteButton.setIcon(VaadinIcons.TRASH);
                roleDeleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                deleteButton.setDescription("Remove Policy from this Role");

                roleDeleteButton.addClickListener(new Button.ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        selectedRole.getPolicies().remove(policy);
                        PolicyManagementPanel.this.saveRole(selectedRole);

                        PolicyManagementPanel.this.roleTable.removeItem(role);
                        PolicyManagementPanel.this.policyDropTable.removeItem(policy.getName());
                    }
                });

                PolicyManagementPanel.this.roleTable.addItem(new Object[] { role.getName(), roleDeleteButton },
                        role);
            }
        }

        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }
    });

    GridLayout layout = new GridLayout();
    layout.setSpacing(true);
    layout.setWidth("100%");
    layout.setHeight("100%");

    layout.addComponent(rolePoliciesLabel);
    layout.addComponent(this.rolesCombo);

    Label policyDropHintLabel = new Label();
    policyDropHintLabel.setCaptionAsHtml(true);
    policyDropHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " Drop a policy into the table below to associate with a role.");
    policyDropHintLabel.addStyleName(ValoTheme.LABEL_TINY);
    policyDropHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
    layout.addComponent(policyDropHintLabel);

    layout.addComponent(this.policyDropTable);

    this.policyDropPanel.setContent(layout);
}

From source file:org.ikasan.dashboard.ui.administration.panel.PolicyManagementPanel.java

License:BSD License

/**
 * Helper method to initialise behaviour of the policy name field.
 * // w w w.  j  a v a  2s.  c om
 * @return
 */
protected DragAndDropWrapper initPolicyNameField() {
    // The policy field name is an autocomplete field.
    this.policyNameField = new AutocompleteField<Policy>();
    this.policyNameField.setWidth("70%");

    // We also want it to be drag and drop friendly.
    final DragAndDropWrapper policyNameFieldWrap = new DragAndDropWrapper(policyNameField);
    policyNameFieldWrap.setDragStartMode(DragStartMode.COMPONENT);

    // In order to have the auto complete work we must add a query listener.
    // The query listener gets activated when a user begins to type into 
    // the field and hits the database looking for suggestions.
    policyNameField.setQueryListener(new AutocompleteQueryListener<Policy>() {
        @Override
        public void handleUserQuery(AutocompleteField<Policy> field, String query) {
            // Iterate over the returned results and add them as suggestions
            for (Policy policy : securityService.getPolicyByNameLike(query)) {
                field.addSuggestion(policy, policy.getName());
            }
        }
    });

    // Once a suggestion is selected the listener below gets fired and we populate
    // associated fields as required.
    policyNameField.setSuggestionPickedListener(new AutocompleteSuggestionPickedListener<Policy>() {
        @Override
        public void onSuggestionPicked(final Policy pickedPolicy) {
            PolicyManagementPanel.this.policy = pickedPolicy;

            // Populate all the policy related fields.
            PolicyManagementPanel.this.policyItem = new BeanItem<Policy>(PolicyManagementPanel.this.policy);
            PolicyManagementPanel.this.policyNameField
                    .setPropertyDataSource(policyItem.getItemProperty("name"));
            PolicyManagementPanel.this.descriptionField
                    .setPropertyDataSource(policyItem.getItemProperty("description"));

            if (PolicyManagementPanel.this.policy.getPolicyLink() != null) {
                PolicyManagementPanel.this.linkedEntity.setVisible(true);
                PolicyManagementPanel.this.linkType.setVisible(true);
                PolicyManagementPanel.this.linkTypeLabel.setVisible(true);
                PolicyManagementPanel.this.linkedEntityLabel.setVisible(true);
                PolicyManagementPanel.this.linkType.setValue(
                        PolicyManagementPanel.this.policy.getPolicyLink().getPolicyLinkType().getName());
                PolicyManagementPanel.this.linkedEntity
                        .setValue(PolicyManagementPanel.this.policy.getPolicyLink().getName());
            } else {
                PolicyManagementPanel.this.linkType.setValue(null);
                PolicyManagementPanel.this.linkedEntity.setValue(new String());

                PolicyManagementPanel.this.linkedEntity.setVisible(false);
                PolicyManagementPanel.this.linkedEntityLabel.setVisible(false);
                PolicyManagementPanel.this.linkType.setVisible(false);
                PolicyManagementPanel.this.linkTypeLabel.setVisible(false);
            }

            roleTable.removeAllItems();

            // Add all the associated roles to the role table.
            for (final Role role : policy.getRoles()) {
                Button deleteButton = new Button();
                deleteButton.setIcon(VaadinIcons.TRASH);
                deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                deleteButton.setDescription("Remove Policy from this Role");

                // Add the delete functionality to each role that is added
                deleteButton.addClickListener(new Button.ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        // Update the roles associated with policy
                        // and update in the DB.
                        policy.getRoles().remove(role);
                        PolicyManagementPanel.this.savePolicy(policy);

                        // Once we are happy that the DB call was fine
                        // update the UI components to reflect the change.
                        roleTable.removeItem(role);
                        policyDropTable.removeItem(policy.getName());
                    }
                });

                roleTable.addItem(new Object[] { role.getName(), deleteButton }, role);
            }

            PolicyManagementPanel.this.cancelButton.setVisible(false);
            PolicyManagementPanel.this.newButton.setVisible(true);
            PolicyManagementPanel.this.deleteButton.setVisible(true);
        }
    });

    return policyNameFieldWrap;
}

From source file:org.ikasan.dashboard.ui.administration.panel.PolicyManagementPanel.java

License:BSD License

/**
 * //from   ww  w. j a  v a 2 s .co m
 */
protected Layout initControlLayout() {
    this.cancelButton.setVisible(false);
    this.deleteButton.setVisible(false);

    this.newButton.setIcon(VaadinIcons.PLUS);
    this.newButton.setDescription("Create a New Policy");
    this.newButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    this.newButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    this.newButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            final NewPolicyWindow newPolicyWindow = new NewPolicyWindow(userService, securityService,
                    policyAssociationMappingSearchWindow, policyAssociationFlowSearchWindow,
                    policyAssociationModuleSearchWindow, policyAssociationBusinessStreamSearchWindow);
            UI.getCurrent().addWindow(newPolicyWindow);

            newPolicyWindow.addCloseListener(new Window.CloseListener() {
                // inline close-listener
                public void windowClose(CloseEvent e) {
                    PolicyManagementPanel.this.policy = newPolicyWindow.getPolicy();

                    PolicyManagementPanel.this.policyItem = new BeanItem<Policy>(
                            PolicyManagementPanel.this.policy);
                    PolicyManagementPanel.this.policyNameField
                            .setText(PolicyManagementPanel.this.policy.getName());
                    PolicyManagementPanel.this.policyNameField
                            .setPropertyDataSource(policyItem.getItemProperty("name"));
                    PolicyManagementPanel.this.descriptionField
                            .setPropertyDataSource(policyItem.getItemProperty("description"));

                    if (PolicyManagementPanel.this.policy.getPolicyLink() != null) {
                        PolicyManagementPanel.this.linkType.setValue(PolicyManagementPanel.this.policy
                                .getPolicyLink().getPolicyLinkType().getName());
                        PolicyManagementPanel.this.linkedEntity
                                .setValue(PolicyManagementPanel.this.policy.getPolicyLink().getName());

                        PolicyManagementPanel.this.linkedEntity.setVisible(true);
                        PolicyManagementPanel.this.linkType.setVisible(true);
                    } else {
                        PolicyManagementPanel.this.linkedEntity.setVisible(false);
                        PolicyManagementPanel.this.linkType.setVisible(false);
                    }

                    PolicyManagementPanel.this.roleTable.removeAllItems();

                    PolicyManagementPanel.this.newButton.setVisible(true);
                    PolicyManagementPanel.this.deleteButton.setVisible(false);
                }
            });
        }
    });

    this.deleteButton.setIcon(VaadinIcons.TRASH);
    this.deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    this.deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    this.deleteButton.setDescription("Delete the Current Policy");
    this.deleteButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                PolicyManagementPanel.this.securityService.deletePolicy(policy);

                PolicyManagementPanel.this.policyNameField.setText("");
                PolicyManagementPanel.this.descriptionField.setValue("");
                PolicyManagementPanel.this.linkType.setValue(null);
                PolicyManagementPanel.this.linkedEntity.setValue("");

                PolicyManagementPanel.this.linkedEntity.setVisible(false);

                Notification.show("Deleted");

                PolicyManagementPanel.this.cancelButton.setVisible(false);
                PolicyManagementPanel.this.newButton.setVisible(true);
                PolicyManagementPanel.this.deleteButton.setVisible(false);
            } catch (RuntimeException e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                Notification.show("Cauget exception trying to delete a Policy!", sw.toString(),
                        Notification.Type.ERROR_MESSAGE);
            }
        }
    });

    this.cancelButton.setStyleName(ValoTheme.BUTTON_LINK);
    this.cancelButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            PolicyManagementPanel.this.policyNameField.setText("");
            PolicyManagementPanel.this.descriptionField.setValue("");
            PolicyManagementPanel.this.linkType.setValue(null);
            PolicyManagementPanel.this.linkedEntity.setValue("");
            PolicyManagementPanel.this.linkedEntity.setVisible(false);

            PolicyManagementPanel.this.cancelButton.setVisible(false);
            PolicyManagementPanel.this.newButton.setVisible(true);
            PolicyManagementPanel.this.deleteButton.setVisible(false);
        }
    });

    HorizontalLayout controlLayout = new HorizontalLayout();
    controlLayout.setWidth("100%");
    Label spacerLabel = new Label("");
    controlLayout.addComponent(spacerLabel);
    controlLayout.setExpandRatio(spacerLabel, 0.865f);
    controlLayout.addComponent(newButton);
    controlLayout.setExpandRatio(newButton, 0.045f);
    controlLayout.addComponent(deleteButton);
    controlLayout.setExpandRatio(deleteButton, 0.045f);
    controlLayout.addComponent(cancelButton);
    controlLayout.setExpandRatio(cancelButton, 0.045f);

    return controlLayout;
}