Example usage for com.vaadin.ui Button setIcon

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

Introduction

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

Prototype

@Override
public void setIcon(Resource icon) 

Source Link

Document

Sets the component's icon.

Usage

From source file:org.escidoc.browser.ui.useraccount.UserAccountView.java

License:Open Source License

private Button buildAddAttributeButton(final UserAccountAttributes attributeTable) {
    final Button addAttributeButton = new Button();
    addAttributeButton.setDescription("Add new Attribute");
    addAttributeButton.setIcon(new ThemeResource("images/assets/plus.png"));
    addAttributeButton.addListener(new OnAddAttribute(addAttributeButton, attributeTable));
    return addAttributeButton;
}

From source file:org.escidoc.browser.ui.useraccount.UserAccountView.java

License:Open Source License

private Button buildAddPreferenceButton(final Panel preferencePanel,
        final UserAccountPreferences userPrefTable) {
    final Button addPreferenceButton = new Button();
    addPreferenceButton.setDescription("Add new Preference");
    addPreferenceButton.setIcon(new ThemeResource("images/assets/plus.png"));
    addPreferenceButton/*from ww w.  ja v  a 2s .  c o  m*/
            .addListener(new OnAddPreference(this, preferencePanel, userPrefTable, addPreferenceButton));
    return addPreferenceButton;
}

From source file:org.escidoc.browser.ui.useraccount.UserRolesView.java

License:Open Source License

private Button buildAssignGrantButton(final NativeSelect resourceSelect, final NativeSelect roleNameSelect) {
    Button assignGrantButton = new Button();
    assignGrantButton.setIcon(new ThemeResource("images/assets/plus.png"));
    assignGrantButton.addListener(new Button.ClickListener() {

        @Override//ww w.ja  v a  2s . c  om
        public void buttonClick(@SuppressWarnings("unused") ClickEvent event) {
            try {
                if (getSelectedRole() == null) {
                    router.getMainWindow().showNotification("Role can not be empty", "",
                            Window.Notification.TYPE_WARNING_MESSAGE);
                    return;
                }
                Grant grant = assignGrantInServer();
                updateView();
                showSuccessMessage(grant);
            } catch (EscidocClientException e) {
                router.getMainWindow().showNotification("Error Message",
                        "Something wrong happens. Cause: " + e.getMessage(), Notification.TYPE_ERROR_MESSAGE);
            }
        }

        private void showSuccessMessage(Grant grant) {
            router.getMainWindow().showNotification("",
                    "Sucessfully assign grant " + grant.getXLinkTitle() + " to " + userProxy.getName(),
                    Notification.TYPE_TRAY_NOTIFICATION);

        }

        private Grant assignGrantInServer() throws EscidocClientException {
            return repositories.user().assign(userProxy.getId()).withRole(getSelectedRole())
                    .onResources(getSelectedResources()).execute();
        }

        private RoleModel getSelectedRole() {
            final Object value = roleNameSelect.getValue();
            if (value instanceof RoleModel) {
                return (RoleModel) value;
            }
            return null;
        }

        private Set<ResourceModel> getSelectedResources() {
            final Object value = resourceSelect.getValue();
            if (value instanceof ResourceModel) {
                return Collections.singleton((ResourceModel) value);
            }
            return Collections.emptySet();
        }

        private void updateView() throws EscidocClientException {
            listRolesForUser(rolesLayout);
        }
    });
    return assignGrantButton;
}

From source file:org.escidoc.browser.ui.useraccount.UserRolesView.java

License:Open Source License

private Button buildRemoveButton(int rowNumber, Grant grant) {
    Button removeButton = new Button();
    removeButton.setIcon(new ThemeResource("images/assets/minus.png"));
    removeButton.setData(Integer.valueOf(rowNumber));
    removeButton.addListener(new OnRemoveGrant(grant, userProxy, repositories, router.getMainWindow()));
    return removeButton;
}

From source file:org.escidoc.browser.ui.view.helpers.CloseTabsViewHelper.java

License:Open Source License

private void buildButton() {
    Button btnRemoveTabs = new Button();
    ThemeResource icon = new ThemeResource("images/assets/close.gif");
    btnRemoveTabs.setStyleName(BaseTheme.BUTTON_LINK);
    btnRemoveTabs.addStyleName("closeallTabs");
    btnRemoveTabs.setDescription(ViewConstants.CLOSE_ALL_OPEN_TABS);
    btnRemoveTabs.setIcon(icon);
    btnRemoveTabs.addStyleName(ViewConstants.FLOAT_RIGHT);
    btnRemoveTabs.addListener(this);
    layout.addComponent(btnRemoveTabs);//w w  w  . j  a v  a  2  s . c om
}

From source file:org.escidoc.browser.ui.view.helpers.CreateResourceLinksVH.java

License:Open Source License

public CreateResourceLinksVH(String url, ResourceProxy resourceProxy,
        AbstractComponentContainer componentContainer, Router router) {
    HorizontalLayout vl = buildInitialElements();

    if (resourceProxy.getType().equals(ResourceType.ITEM)) {
        vl.setStyleName("permanentLinkItem");
    } else {// w ww.j  a va 2 s .co  m
        vl.setStyleName("permanentLink");
    }
    if (!resourceProxy.getType().equals(ResourceType.CONTEXT)) {

        final Button btnVersionHistory = new Button(" ", new VersionHistoryClickListener(resourceProxy,
                router.getMainWindow(), router.getRepositories()));
        btnVersionHistory.setStyleName(BaseTheme.BUTTON_LINK);
        btnVersionHistory.setDescription("Show Version history in a Pop-up");
        btnVersionHistory.addStyleName("paddingright10");
        btnVersionHistory.setIcon(ICON_HISTORY);
        vl.addComponent(btnVersionHistory);
    }
    try {
        l = new Link("",
                new ExternalResource(
                        url + "?id=" + resourceProxy.getId() + "&type=" + resourceProxy.getType().toString()
                                + "&escidocurl=" + router.getServiceLocation().getEscidocUrl()));
        l.setDescription(ViewConstants.PERMANENT_LINK);
        l.setIcon(new ThemeResource("images/wpzoom/globe-1.png"));
        vl.addComponent(l);

    } catch (MalformedURLException e) {
        componentContainer.getWindow().showNotification(ViewConstants.COULD_NOT_RETRIEVE_APPLICATION_URL);
        LOG.error(ViewConstants.COULD_NOT_RETRIEVE_APPLICATION_URL + e.getLocalizedMessage());
    }
    componentContainer.addComponent(hl);
}

From source file:org.escidoc.browser.ui.view.helpers.CreateResourceLinksVH.java

License:Open Source License

public CreateResourceLinksVH(String url, UserProxy userProxy, AbstractComponentContainer componentContainer,
        Router router, UserAccountController controller) {
    buildInitialElements();//from   w  ww.ja  va 2s . c  om
    // Checking if has access on changing password here as well
    HorizontalLayout hl = buildInitialElements();
    hl.setStyleName("permanentLink");
    final Button btnVersionHistory = new Button(" ", new ChangeUserPassword(userProxy, router, controller));
    btnVersionHistory.setStyleName(BaseTheme.BUTTON_LINK);
    btnVersionHistory.setDescription("Change user password");
    btnVersionHistory.addStyleName("paddingright10");
    btnVersionHistory.setIcon(ICON_KEY);
    hl.addComponent(btnVersionHistory);
    componentContainer.addComponent(hl);
}

From source file:org.escidoc.browser.ui.view.helpers.DirectMember.java

License:Open Source License

@SuppressWarnings("serial")
private CssLayout headerButton() throws EscidocClientException {
    CssLayout cssLayout = new CssLayout();
    cssLayout.addStyleName("v-accordion-item-caption v-caption v-captiontext");
    cssLayout.setWidth("100%");
    cssLayout.setMargin(false);/*from   w ww  . j a va 2s  .c o m*/

    final Label nameofPanel = new Label(ViewConstants.DIRECT_MEMBERS, Label.CONTENT_RAW);
    nameofPanel.setStyleName("accordion v-captiontext");
    nameofPanel.setWidth("70%");
    cssLayout.addComponent(nameofPanel);

    ThemeResource plusIcon = new ThemeResource("images/assets/plus.png");
    if (resourceType == ResourceType.CONTAINER.toString()) {
        resourceProxy = new ContainerProxyImpl(
                router.getRepositories().container().findContainerById(parentId));
        contextId = resourceProxy.getContext().getObjid();
    } else {
        // It has to be a context
        resourceProxy = router.getRepositories().context().findById(parentId);
    }

    final Button addResourceButton = new Button();
    addResourceButton.setStyleName(BaseTheme.BUTTON_LINK);
    addResourceButton.addStyleName("floatright paddingtop3");
    addResourceButton.setWidth("20px");
    addResourceButton.setIcon(plusIcon);
    addResourceButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) {
            try {
                new ResourceAddViewImpl(resourceProxy, contextId, router).openSubWindow();
            } catch (final EscidocClientException e) {
                mainWindow.showNotification(e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE);
            }

        }
    });
    cssLayout.addComponent(nameofPanel);
    cssLayout.addComponent(addResourceButton);
    return cssLayout;
}

From source file:org.escidoc.browser.ui.view.helpers.FolderChildrenVH.java

License:Open Source License

private Button showIcon(final ResourceModel child) {
    Button icon = new Button();
    icon.setStyleName(BaseTheme.BUTTON_LINK);
    LOG.debug(child.getType().toString());
    if (child.getType().toString().equals(ResourceType.CONTAINER.toString())) {
        icon.setDescription("Container");
        icon.setIcon(new ThemeResource("images/Container.png"));
    } else {/*w ww. j av  a  2 s. c o  m*/
        icon.setDescription("Item");
        icon.setIcon(new ThemeResource("images/Item.png"));
    }

    return icon;
}

From source file:org.escidoc.browser.ui.view.helpers.FolderChildrenVH.java

License:Open Source License

private Button showEdit(final ResourceModel child) {
    Button edit = new Button();
    edit.setStyleName(BaseTheme.BUTTON_LINK);
    edit.setDescription("Edit");
    edit.setIcon(new ThemeResource("images/wpzoom/pencil.png"));
    edit.addListener(new Button.ClickListener() {
        @Override// w  w  w  .j  a v  a 2  s. c o  m
        public void buttonClick(ClickEvent event) {
            folderController.getRouter().getMainWindow().showNotification(
                    "Not yet Implemented " + child.getId(), Notification.TYPE_HUMANIZED_MESSAGE);

        }
    });
    return edit;
}