Java Code Examples for com.vaadin.ui.Button#setData()

The following examples show how to use com.vaadin.ui.Button#setData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServiceDescBasic.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
private Button createLoadBalancerButton(final LoadBalancerDto loadBalancer) {
    Button button = new Button();
    button.setCaption(loadBalancer.getLoadBalancer().getLoadBalancerName());
    button.setIcon(Icons.LOADBALANCER_TAB.resource());
    button.setData(loadBalancer);
    button.addStyleName("borderless");
    button.addStyleName("loadbalancer-button");
    button.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            // ロードバランサを選択
            sender.loadBalancerPanel.loadBalancerTable.select(loadBalancer);

            // ロードバランサタブに移動
            sender.tab.setSelectedTab(sender.loadBalancerPanel);
        }
    });
    return button;
}
 
Example 2
Source File: ServiceTable.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
private Button createLoadBalancerButton(final LoadBalancerDto loadBalancer) {
    Button button = new Button();
    button.setCaption(loadBalancer.getLoadBalancer().getLoadBalancerName());
    button.setIcon(Icons.LOADBALANCER_TAB.resource());
    button.setData(loadBalancer);
    button.addStyleName("borderless");
    button.addStyleName("loadbalancer-button");
    button.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            // ロードバランサを選択
            sender.loadBalancerPanel.loadBalancerTable.select(loadBalancer);

            // ロードバランサタブに移動
            sender.tab.setSelectedTab(sender.loadBalancerPanel);
        }
    });
    return button;
}
 
Example 3
Source File: ArtifactDetailsLayout.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
private Button getArtifactDownloadButton(final Table table, final Object itemId) {
    final String fileName = (String) table.getContainerDataSource().getItem(itemId)
            .getItemProperty(PROVIDED_FILE_NAME).getValue();
    final Button downloadIcon = SPUIComponentProvider.getButton(
            fileName + "-" + UIComponentIdProvider.ARTIFACT_FILE_DOWNLOAD_ICON, "",
            i18n.getMessage(UIMessageIdProvider.TOOLTIP_ARTIFACT_DOWNLOAD), ValoTheme.BUTTON_TINY + " " + "blueicon", 
            true, FontAwesome.DOWNLOAD, SPUIButtonStyleNoBorder.class);
    downloadIcon.setData(itemId);
    FileDownloader fileDownloader = new FileDownloader(createStreamResource((Long) itemId));
    fileDownloader.extend(downloadIcon);
    fileDownloader.setErrorHandler(new ErrorHandler() {

        /**
         * Error handler for file downloader
         */
        private static final long serialVersionUID = 4030230501114422570L;

        @Override
        public void error(com.vaadin.server.ErrorEvent event) {
            uINotification.displayValidationError(i18n.getMessage(UIMessageIdProvider.ARTIFACT_DOWNLOAD_FAILURE_MSG));
        }
    });
    return downloadIcon;
}
 
Example 4
Source File: DistributionTable.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
private Button createPinBtn(final Object itemId) {

        final Item item = getContainerDataSource().getItem(itemId);
        final String name = (String) item.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();

        final String version = (String) item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).getValue();
        final DistributionSetIdName distributionSetIdName = new DistributionSetIdName((Long) itemId, name, version);

        final Button pinBtn = new Button();
        pinBtn.setIcon(FontAwesome.THUMB_TACK);
        pinBtn.setHeightUndefined();
        pinBtn.addStyleName(getPinStyle());
        pinBtn.setData(distributionSetIdName);
        pinBtn.setId(getPinButtonId(name, version));
        pinBtn.setImmediate(true);
        pinBtn.setDescription(getI18n().getMessage(UIMessageIdProvider.TOOLTIP_DISTRIBUTION_SET_PIN));
        return pinBtn;
    }
 
Example 5
Source File: TargetTable.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
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();
    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;
}
 
Example 6
Source File: AbstractFilterButtons.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
private Button createFilterButton(final Long id, final String name, final String description, final String color,
        final Object itemId) {
    /**
     * No icon displayed for "NO TAG" button.
     */
    final Button button = SPUIComponentProvider.getButton("", name, description, "", false, null,
            SPUITagButtonStyle.class);
    button.setId(createButtonId(name));
    button.setCaptionAsHtml(true);
    if (id != null) {
        // Use button.getCaption() since the caption name is modified
        // according to the length
        // available in UI.
        button.setCaption(prepareFilterButtonCaption(button.getCaption(), color));
    }

    if (!StringUtils.isEmpty(description)) {
        button.setDescription(description);
    } else {
        button.setDescription(name);
    }
    button.setData(id == null ? SPUIDefinitions.NO_TAG_BUTTON_ID : itemId);

    return button;
}
 
Example 7
Source File: TargetFilterTable.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private Button customFilterDetailButton(final Long itemId) {
    final Item row1 = getItem(itemId);
    final String tfName = (String) row1.getItemProperty(SPUILabelDefinitions.NAME).getValue();

    final Button updateIcon = SPUIComponentProvider.getButton(getDetailLinkId(tfName), tfName,
            i18n.getMessage(UIMessageIdProvider.TOOLTIP_UPDATE_CUSTOM_FILTER), null, false, null,
            SPUIButtonStyleNoBorder.class);
    updateIcon.setData(tfName);
    updateIcon.addStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link");
    updateIcon.addClickListener(this::onClickOfDetailButton);
    return updateIcon;
}
 
Example 8
Source File: GenericConfigForm.java    From sensorhub with Mozilla Public License 2.0 5 votes vote down vote up
protected void addChangeModuleButton(final ComponentContainer parentForm, final String propId, final ComplexProperty prop, final Class<?> objectType)
{
    final Button chgButton = new Button("Modify");
    //chgButton.addStyleName(STYLE_QUIET);
    chgButton.addStyleName(STYLE_SMALL);
    chgButton.addStyleName(STYLE_SECTION_BUTTONS);
    chgButton.setIcon(REFRESH_ICON);
    
    chgButton.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;
        public void buttonClick(ClickEvent event)
        {
            // show popup to select among available module types
            ModuleTypeSelectionPopup popup = new ModuleTypeSelectionPopup(objectType, new ModuleTypeSelectionCallback() {
                public void configSelected(Class<?> moduleType, ModuleConfig config)
                {
                    // regenerate form
                    config.id = null;
                    config.name = null;
                    MyBeanItem<Object> newItem = new MyBeanItem<Object>(config, propId + ".");
                    prop.setValue(newItem);
                    IModuleConfigForm newForm = AdminUI.getInstance().generateForm(config.getClass());
                    newForm.build(propId, prop);
                    ((VerticalLayout)newForm).addComponent(chgButton, 0);
                                            
                    // replace old form in UI
                    allForms.add(newForm);
                    allForms.remove((IModuleConfigForm)chgButton.getData());
                    replaceComponent((Component)chgButton.getData(), newForm);
                    chgButton.setData(newForm);
                }
            });
            popup.setModal(true);
            AdminUI.getInstance().addWindow(popup);
        }
    });
    
    chgButton.setData(parentForm);
    ((VerticalLayout)parentForm).addComponent(chgButton, 0);
}
 
Example 9
Source File: MainLayout.java    From designer-tutorials with Apache License 2.0 5 votes vote down vote up
private void mapButton(Button button, String folderName,
        Optional<Supplier<Long>> badgeSupplier) {
    button.addClickListener(event -> navigateToFolder(folderName));
    button.setData(folderName);
    if (badgeSupplier.isPresent()) {
        badgeSuppliers.put(folderName, badgeSupplier.get());
    }
}
 
Example 10
Source File: AbstractMetadataDetailsLayout.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private Button customMetadataDetailButton(final String metadataKey) {
    //After Vaadin 8 migration: Enable tooltip again, currently it is set to [null] to avoid cross site scripting.
    final Button viewIcon = SPUIComponentProvider.getButton(getDetailLinkId(metadataKey), metadataKey,
            null, null, false, null, SPUIButtonStyleNoBorder.class);
    viewIcon.setData(metadataKey);
    viewIcon.addStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_LINK + " " + "on-focus-no-border link"
            + " " + "text-style");
    viewIcon.addClickListener(event -> showMetadataDetails(metadataKey));
    return viewIcon;
}
 
Example 11
Source File: TargetFilterQueryButtons.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private Button createFilterButton(final Long id, final String name, final Object itemId) {
    final Button button = SPUIComponentProvider.getButton("", name, name, "", false, null,
            SPUITagButtonStyle.class);
    button.addStyleName("custom-filter-button");
    button.setId(name);
    if (id != null) {
        button.setCaption(name);
    }
    //After Vaadin 8 migration: Enable tooltip again, currently it is set to [null] to avoid cross site scripting.
    button.setDescription(null);
    button.setData(itemId);
    button.addClickListener(event -> customTargetTagFilterButtonClick.processButtonClick(event));
    return button;
}
 
Example 12
Source File: ArtifactDetailsLayout.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private Button getArtifactDeleteButton(final Table table, final Object itemId) {
    final String fileName = (String) table.getContainerDataSource().getItem(itemId)
            .getItemProperty(PROVIDED_FILE_NAME).getValue();
    final Button deleteIcon = SPUIComponentProvider.getButton(
            fileName + "-" + UIComponentIdProvider.UPLOAD_FILE_DELETE_ICON, "",
            i18n.getMessage(UIMessageIdProvider.CAPTION_DISCARD), ValoTheme.BUTTON_TINY + " " + "blueicon", 
            true, FontAwesome.TRASH_O, SPUIButtonStyleNoBorder.class);
    deleteIcon.setData(itemId);
    deleteIcon.addClickListener(event -> confirmAndDeleteArtifact((Long) itemId, fileName));
    return deleteIcon;
}
 
Example 13
Source File: TargetFilterTable.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private Button customFilterDistributionSetButton(final Long itemId) {
    final Item row1 = getItem(itemId);
    final ProxyDistribution distSet = (ProxyDistribution) row1
            .getItemProperty(SPUILabelDefinitions.AUTO_ASSIGN_DISTRIBUTION_SET).getValue();
    final ActionType actionType = (ActionType) row1.getItemProperty(SPUILabelDefinitions.AUTO_ASSIGN_ACTION_TYPE)
            .getValue();

    final String buttonId = "distSetButton";
    Button updateIcon;
    if (distSet == null) {
        updateIcon = SPUIComponentProvider.getButton(buttonId,
                i18n.getMessage(UIMessageIdProvider.BUTTON_NO_AUTO_ASSIGNMENT),
                i18n.getMessage(UIMessageIdProvider.BUTTON_AUTO_ASSIGNMENT_DESCRIPTION), null, false, null,
                SPUIButtonStyleNoBorder.class);
    } else {
        updateIcon = actionType == ActionType.FORCED
                ? SPUIComponentProvider.getButton(buttonId, distSet.getNameVersion(),
                        i18n.getMessage(UIMessageIdProvider.BUTTON_AUTO_ASSIGNMENT_DESCRIPTION), null, false,
                        FontAwesome.BOLT, SPUIButtonStyleNoBorderWithIcon.class)
                : SPUIComponentProvider.getButton(buttonId, distSet.getNameVersion(),
                        i18n.getMessage(UIMessageIdProvider.BUTTON_AUTO_ASSIGNMENT_DESCRIPTION), null, false, null,
                        SPUIButtonStyleNoBorder.class);
        updateIcon.setSizeUndefined();
    }

    updateIcon.addClickListener(this::onClickOfDistributionSetButton);
    updateIcon.setData(row1);
    updateIcon.addStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link");

    return updateIcon;
}
 
Example 14
Source File: TargetFilterTable.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private Button getDeleteButton(final Long itemId) {
    final Item row = getItem(itemId);
    final String tfName = (String) row.getItemProperty(SPUILabelDefinitions.NAME).getValue();
    final Button deleteIcon = SPUIComponentProvider.getButton(getDeleteIconId(tfName), "",
            i18n.getMessage(UIMessageIdProvider.TOOLTIP_DELETE_CUSTOM_FILTER),
            ValoTheme.BUTTON_TINY + " " + "blueicon", true, FontAwesome.TRASH_O, SPUIButtonStyleNoBorder.class);
    deleteIcon.setData(itemId);
    deleteIcon.addClickListener(this::onDelete);
    return deleteIcon;
}
 
Example 15
Source File: MainLayout.java    From designer-tutorials with Apache License 2.0 4 votes vote down vote up
private void addNavigatorView(String viewName,
        Class<? extends View> viewClass, Button menuButton) {
    navigator.addView(viewName, viewClass);
    menuButton.addClickListener(event -> doNavigate(viewName));
    menuButton.setData(viewClass.getName());
}
 
Example 16
Source File: GenericConfigForm.java    From sensorhub with Mozilla Public License 2.0 4 votes vote down vote up
protected void addChangeObjectButton(final ComponentContainer parentForm, final String propId, final ComplexProperty prop, final Map<String, Class<?>> typeList)
{
    final Button chgButton = new Button("Modify");
    //chgButton.addStyleName(STYLE_QUIET);
    chgButton.addStyleName(STYLE_SMALL);
    chgButton.addStyleName(STYLE_SECTION_BUTTONS);
    chgButton.setIcon(REFRESH_ICON);
    
    chgButton.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;
        public void buttonClick(ClickEvent event)
        {
            // show popup to select among available module types
            ObjectTypeSelectionPopup popup = new ObjectTypeSelectionPopup("Select Type", typeList, new ObjectTypeSelectionCallback() {
                public void typeSelected(Class<?> objectType)
                {
                    try
                    {
                        // regenerate form
                        MyBeanItem<Object> newItem = new MyBeanItem<Object>(objectType.newInstance(), propId + ".");
                        prop.setValue(newItem);
                        IModuleConfigForm newForm = AdminUI.getInstance().generateForm(objectType);
                        newForm.build(propId, prop);
                        ((VerticalLayout)newForm).addComponent(chgButton, 0);
                                                
                        // replace old form in UI
                        allForms.add(newForm);
                        allForms.remove((IModuleConfigForm)chgButton.getData());
                        replaceComponent((Component)chgButton.getData(), newForm);
                        chgButton.setData(newForm);
                    }
                    catch (Exception e)
                    {
                        Notification.show("Error", e.getMessage(), Notification.Type.ERROR_MESSAGE);
                    }
                }
            });
            popup.setModal(true);
            AdminUI.getInstance().addWindow(popup);
        }
    });
    chgButton.setData(parentForm);
    ((VerticalLayout)parentForm).addComponent(chgButton, 0);
}
 
Example 17
Source File: MainLayout.java    From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 4 votes vote down vote up
@PostConstruct
public void postConstuct() {
	setSizeFull();
	eventBus.subscribe(this);
	
	navbar = new HorizontalLayout();
	navbar.setWidth("100%");
	navbar.setMargin(true);
	navbar.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT);
	addComponent(navbar);
	
	final Label brand = new Label("Vaadin4Spring Security Demo");
	brand.addStyleName(ValoTheme.LABEL_H2);
	brand.addStyleName(ValoTheme.LABEL_NO_MARGIN);
	navbar.addComponent(brand);
	navbar.setComponentAlignment(brand, Alignment.MIDDLE_LEFT);
	navbar.setExpandRatio(brand, 1);
	
	btnHome = new Button("Home", FontAwesome.HOME);
	btnHome.addStyleName(ValoTheme.BUTTON_BORDERLESS);
	btnHome.setData(ViewToken.HOME);
	btnHome.addClickListener(this);
	navbar.addComponent(btnHome);
	
	btnUser = new Button("User home", FontAwesome.USER);
	btnUser.addStyleName(ValoTheme.BUTTON_BORDERLESS);
	btnUser.setData(ViewToken.USER);
	btnUser.addClickListener(this);
	navbar.addComponent(btnUser);
	
	btnAdmin = new Button("Admin home", FontAwesome.USER_MD);
	btnAdmin.addStyleName(ValoTheme.BUTTON_BORDERLESS);
	btnAdmin.setData(ViewToken.ADMIN);
	btnAdmin.addClickListener(this);
	navbar.addComponent(btnAdmin);
	
	btnAdminHidden = new Button("Admin secret", FontAwesome.EYE_SLASH);
	btnAdminHidden.addStyleName(ValoTheme.BUTTON_BORDERLESS);
	btnAdminHidden.setData(ViewToken.ADMIN_HIDDEN);
	btnAdminHidden.addClickListener(this);
	navbar.addComponent(btnAdminHidden);
	
	btnSignIn = new Button("Sign in", FontAwesome.SIGN_IN);
	btnSignIn.addStyleName(ValoTheme.BUTTON_BORDERLESS);
	btnSignIn.setData(ViewToken.SIGNIN);
	btnSignIn.addClickListener(this);
	navbar.addComponent(btnSignIn);
	
	btnSignUp = new Button("Sign up", FontAwesome.PENCIL_SQUARE_O);
	btnSignUp.addStyleName(ValoTheme.BUTTON_BORDERLESS);
	btnSignUp.setData(ViewToken.SIGNUP);
	btnSignUp.addClickListener(this);
	navbar.addComponent(btnSignUp);
					
	btnLogout = new Button("Logout", FontAwesome.SIGN_OUT);
	btnLogout.setData("-");
	btnLogout.addStyleName(ValoTheme.BUTTON_BORDERLESS);
	navbar.addComponent(btnLogout);
	btnLogout.addClickListener(new ClickListener() {
		
		@Override
		public void buttonClick(ClickEvent event) {
			logout();			
		}
	});
	
	viewContainer = new Panel();
	viewContainer.setSizeFull();
	addComponent(viewContainer);
	setExpandRatio(viewContainer, 1);				
}