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

The following examples show how to use com.vaadin.ui.Button#getData() . 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: TargetTable.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
private void checkifAlreadyPinned(final Button eventBtn) {
    final TargetIdName newPinnedTargetItemId = (TargetIdName) eventBtn.getData();
    final TargetIdName targetId = managementUIState.getDistributionTableFilters().getPinnedTarget().orElse(null);

    if (targetId == null) {
        targetPinned = !targetPinned;
        managementUIState.getDistributionTableFilters().setPinnedTarget(newPinnedTargetItemId);
    } else if (targetId.equals(newPinnedTargetItemId)) {
        targetPinned = Boolean.FALSE;
    } else {
        targetPinned = true;
        managementUIState.getDistributionTableFilters().setPinnedTarget(newPinnedTargetItemId);
        if (null != targetPinnedBtn) {
            resetPinStyle(targetPinnedBtn);
        }
    }
    targetPinnedBtn = eventBtn;
}
 
Example 2
Source File: MainLayout.java    From designer-tutorials with Apache License 2.0 6 votes vote down vote up
private void setMenuBadge(Component component) {
    if (component instanceof Button) {
        Button button = (Button) component;
        if (button.getData() != null
                && button.getData() instanceof String) {
            String folder = (String) button.getData();
            Long count = badgeSuppliers.containsKey(folder)
                    ? badgeSuppliers.get(folder).get() : 0L;
            String badgeText = (count != null && count > 0)
                    ? (count > 99) ? "99+" : count.toString() : "";
            String captionFormat = badgeText.isEmpty() ? ""
                    : "%s <span class=\"valo-menu-badge\">%s</span>";
            if (captionFormat.isEmpty()) {
                component.setCaption(folder);
            } else {
                component.setCaption(
                        String.format(captionFormat, folder, badgeText));
            }
        }
    }
}
 
Example 3
Source File: MainLayout.java    From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 6 votes vote down vote up
@Override
public void afterViewChange(ViewChangeEvent event) {
	for (int i=0; i<navbar.getComponentCount(); i++) {
		
		if (navbar.getComponent(i) instanceof Button) {
			final Button btn = (Button) navbar.getComponent(i);
			btn.removeStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
			
			String view = (String) btn.getData();
			
			if (event.getViewName().equals(view)) {
				btn.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
			}
		}
	}
					
}
 
Example 4
Source File: DistributionTable.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private void saveDistributionPinnedBtn(final Button pinBtn) {
    if (pinBtn.getData() == null) {
        return;
    }

    final Long pinnedId = ((DistributionSetIdName) pinBtn.getData()).getId();

    if (managementUIState.getTargetTableFilters().getPinnedDistId().map(pinnedId::equals).orElse(false)) {
        setDistributionPinnedBtn(pinBtn);
    }
}
 
Example 5
Source File: TargetTable.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
private void resetPinStyle(final Button pinBtn) {
    pinBtn.removeStyleName(TARGET_PINNED);
    pinBtn.addStyleName(SPUIStyleDefinitions.TARGET_STATUS_PIN_TOGGLE);
    final TargetIdName targetIdname = (TargetIdName) pinBtn.getData();
    HawkbitCommonUtil.applyStatusLblStyle(this, pinBtn, targetIdname.getTargetId());
}