Example usage for com.vaadin.ui Button addListener

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

Introduction

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

Prototype

@Override
    public Registration addListener(Component.Listener listener) 

Source Link

Usage

From source file:org.escidoc.browser.ui.tools.FilterButtonListener.java

License:Open Source License

private void addPurgeButton() {
    final Button purgeButton = new Button(ViewConstants.PURGE);
    purgeButton.setStyleName(Reindeer.BUTTON_SMALL);
    buttonLayout.addComponent(purgeButton);
    purgeButton.addListener(new PurgeButtonListener(this, mainWindow, resultDataSource));
}

From source file:org.escidoc.browser.ui.tools.ImportView.java

License:Open Source License

private void addContent() {
    final Label urlLabel = new Label(ViewConstants.URL);
    final TextField sourceUrlField = new TextField();
    sourceUrlField.setWidth("400px");
    sourceUrlField.setValue(ViewConstants.DEFAULT_CONTENT_MODEL_URI);
    final Button importButton = new Button(ViewConstants.IMPORT);
    importButton.setStyleName(Reindeer.BUTTON_SMALL);
    importButton.addListener(new ImportListener(sourceUrlField));

    final HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);/*  w w  w .  j  ava2s  .  c  o  m*/
    hl.addComponent(urlLabel);
    hl.addComponent(sourceUrlField);
    hl.addComponent(importButton);
    addComponent(hl);
}

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

License:Open Source License

@Override
public void buttonClick(@SuppressWarnings("unused") final com.vaadin.ui.Button.ClickEvent event) {
    addPreference.setEnabled(false);/*w w  w  .  j  ava 2 s.  c  o m*/
    final HorizontalLayout hl = new HorizontalLayout();
    final TextField key = new TextField();
    key.setCaption("Name");
    key.setImmediate(false);
    key.setWidth("-1px");
    key.setHeight("-1px");
    key.setInvalidAllowed(false);
    key.setRequired(true);

    final TextField value = new TextField();
    value.setCaption("Value");
    value.setImmediate(false);
    value.setWidth("-1px");
    value.setHeight("-1px");
    value.setInvalidAllowed(false);
    value.setRequired(true);

    final Button addButton = new Button();
    addButton.setIcon(new ThemeResource("images/assets/plus.png"));
    addButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(@SuppressWarnings("unused") final com.vaadin.ui.Button.ClickEvent event) {
            if (UserAccountView.isNotValid(key, value)) {
                OnAddPreference.this.userAccountView.showMessage();
            } else {
                try {
                    OnAddPreference.this.userAccountView.ur.createPreference(
                            OnAddPreference.this.userAccountView.userProxy,
                            new Preference(key.getValue().toString(), value.getValue().toString()));
                    OnAddPreference.this.userAccountView.router.getMainWindow().showNotification(
                            "Preference added successfully ", Window.Notification.TYPE_TRAY_NOTIFICATION);
                    hl.removeAllComponents();
                    addPreference.setEnabled(true);
                    userPrefTable.createItem(userPrefTable.getTableContainer(), key.getValue().toString(),
                            key.getValue().toString(), value.getValue().toString());
                } catch (final EscidocClientException e) {
                    OnAddPreference.this.userAccountView.router.getMainWindow().showNotification(
                            ViewConstants.ERROR_CREATING_USER_PREFERENCE + e.getLocalizedMessage(),
                            Window.Notification.TYPE_ERROR_MESSAGE);
                }
            }
        }

    });
    hl.addComponent(key);
    hl.addComponent(value);
    hl.addComponent(addButton);
    hl.setComponentAlignment(addButton, Alignment.BOTTOM_RIGHT);
    preferencePanel.addComponent(hl);
}

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
            .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/*from  ww  w .j a  v a2  s .  com*/
        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);/*from  ww w . j a va  2  s.  c om*/
    btnRemoveTabs.addStyleName(ViewConstants.FLOAT_RIGHT);
    btnRemoveTabs.addListener(this);
    layout.addComponent(btnRemoveTabs);
}

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  ww w . j  a  v  a2  s .  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 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  ww  .j ava 2 s  .c  om*/
        public void buttonClick(ClickEvent event) {
            folderController.getRouter().getMainWindow().showNotification(
                    "Not yet Implemented " + child.getId(), Notification.TYPE_HUMANIZED_MESSAGE);

        }
    });
    return edit;
}