List of usage examples for com.vaadin.ui Button setPrimaryStyleName
@Override public void setPrimaryStyleName(String style)
From source file:org.bubblecloud.ilves.site.view.valo.DefaultValoView.java
License:Apache License
private void addMenuLink(final NavigationVersion navigationVersion, final String pageName) { final Site site = Site.getCurrent(); final ViewVersion pageVersion = site.getCurrentViewVersion(pageName); if (pageVersion == null) { throw new SiteException("Unknown page: " + pageName); }/* w ww.j av a 2s . c o m*/ if (pageVersion.getViewerRoles().length > 0) { boolean roleMatch = false; for (final String role : pageVersion.getViewerRoles()) { if (site.getSecurityProvider().getRoles().contains(role)) { roleMatch = true; break; } } if (!roleMatch) { return; } } final String localizedPageName = pageVersion.isDynamic() ? pageName : site.localize("page-link-" + pageName); final Resource iconResource = pageVersion.isDynamic() ? navigationVersion.hasChildPages(pageName) ? site.getIcon("page-icon-folder") : site.getIcon("page-icon-page") : site.getIcon("page-icon-" + pageName); Button b = new Button(localizedPageName, new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { UI.getCurrent().getNavigator().navigateTo(pageName); } }); b.setHtmlContentAllowed(true); b.setPrimaryStyleName("valo-menu-item"); b.setIcon(iconResource); menuItemsLayout.addComponent(b); }
From source file:org.geant.sat.ui.MainView.java
License:BSD License
/** * Create button for menu./*w ww .ja va 2 s . c o m*/ * * @param caption * for the button. * @param menuListenerName * listener for button. * @return Button as Component. */ private Component createMenuButton(String caption, String menuListenerName) { Button button = new Button(caption, new ButtonListener(menuListenerName)); button.setPrimaryStyleName(ValoTheme.MENU_ITEM); return (Component) button; }
From source file:org.geant.sat.ui.StartView.java
License:BSD License
/** * Constructor. Creates start button to direct user to main view. * //w ww . j av a2 s . c o m * @param ui * Main ui instance to access shared data. */ public StartView(MainUI ui) { super(ui); setSizeFull(); Button button = new Button(getString("lang.startview.forward"), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { getUI().getNavigator().navigateTo(MainUI.MAINVIEW); } }); button.setPrimaryStyleName(ValoTheme.BUTTON_BORDERLESS); addComponent(button); setComponentAlignment(button, Alignment.MIDDLE_CENTER); }
From source file:org.ikasan.dashboard.ui.Menu.java
License:BSD License
protected void buildMenu() { menuItemsLayout.setPrimaryStyleName("valo-menuitems"); this.addComponent(menuItemsLayout); Label label = null;//from w w w . j a va 2 s . c o m label = new Label("General", ContentMode.HTML); label.setPrimaryStyleName("valo-menu-subtitle"); label.addStyleName("h4"); label.setSizeUndefined(); menuItemsLayout.addComponent(label); final Button dashboardMenuItem = new Button("Dashboard", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("landingView"); } }); dashboardMenuItem.setHtmlContentAllowed(true); dashboardMenuItem.setPrimaryStyleName("valo-menu-item"); dashboardMenuItem.setIcon(VaadinIcons.DASHBOARD); menuItemsLayout.addComponent(dashboardMenuItem); label = null; final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); if (authentication != null && (authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) || authentication.hasGrantedAuthority(SecurityConstants.VIEW_TOPOLOGY_AUTHORITY) || authentication.hasGrantedAuthority(SecurityConstants.VIEW_MAPPING_AUTHORITY))) { label = new Label("Services", ContentMode.HTML); label.setPrimaryStyleName("valo-menu-subtitle"); label.addStyleName("h4"); label.setSizeUndefined(); menuItemsLayout.addComponent(label); } label = new Label("Services", ContentMode.HTML); label.setPrimaryStyleName("valo-menu-subtitle"); label.addStyleName("h4"); label.setSizeUndefined(); menuItemsLayout.addComponent(label); this.menuComponents.put(label, SecurityConstants.ALL_AUTHORITY); this.menuComponents.put(label, SecurityConstants.VIEW_TOPOLOGY_AUTHORITY); this.menuComponents.put(label, SecurityConstants.VIEW_MAPPING_AUTHORITY); final Button topologyMenuItem = new Button("Topology", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("topologyView"); } }); topologyMenuItem.setHtmlContentAllowed(true); topologyMenuItem.setPrimaryStyleName("valo-menu-item"); topologyMenuItem.setIcon(VaadinIcons.CONNECT_O); menuItemsLayout.addComponent(topologyMenuItem); this.menuComponents.put(topologyMenuItem, SecurityConstants.VIEW_TOPOLOGY_AUTHORITY); final Button mappingMenuItem = new Button("Mapping", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("mappingView"); loadNavigator("mapping"); } }); mappingMenuItem.setHtmlContentAllowed(true); mappingMenuItem.setPrimaryStyleName("valo-menu-item"); mappingMenuItem.setIcon(VaadinIcons.COPY_O); menuItemsLayout.addComponent(mappingMenuItem); this.menuComponents.put(mappingMenuItem, SecurityConstants.VIEW_MAPPING_AUTHORITY); final Button monitoringMenuItem = new Button("Monitoring", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("monitorView"); } }); monitoringMenuItem.setHtmlContentAllowed(true); monitoringMenuItem.setPrimaryStyleName("valo-menu-item"); monitoringMenuItem.setIcon(VaadinIcons.DESKTOP); menuItemsLayout.addComponent(monitoringMenuItem); this.menuComponents.put(monitoringMenuItem, SecurityConstants.VIEW_MONITORING_AUTHORITY); label = new Label("Administration", ContentMode.HTML); label.setPrimaryStyleName("valo-menu-subtitle"); label.addStyleName("h4"); label.setSizeUndefined(); menuItemsLayout.addComponent(label); this.menuComponents.put(label, SecurityConstants.ALL_AUTHORITY); final Button usersItem = new Button("Users", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("userPanel"); } }); usersItem.setHtmlContentAllowed(true); usersItem.setPrimaryStyleName("valo-menu-item"); usersItem.setIcon(VaadinIcons.USER); menuItemsLayout.addComponent(usersItem); this.menuComponents.put(usersItem, SecurityConstants.ALL_AUTHORITY); final Button groupsItem = new Button("Groups", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("principalManagementPanel"); } }); groupsItem.setHtmlContentAllowed(true); groupsItem.setPrimaryStyleName("valo-menu-item"); groupsItem.setIcon(VaadinIcons.USERS); menuItemsLayout.addComponent(groupsItem); this.menuComponents.put(groupsItem, SecurityConstants.ALL_AUTHORITY); final Button rolesItem = new Button("Roles", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("roleManagementPanel"); } }); rolesItem.setHtmlContentAllowed(true); rolesItem.setPrimaryStyleName("valo-menu-item"); rolesItem.setIcon(VaadinIcons.SPECIALIST); menuItemsLayout.addComponent(rolesItem); this.menuComponents.put(rolesItem, SecurityConstants.ALL_AUTHORITY); final Button policyItem = new Button("Policies", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("policyManagementPanel"); } }); policyItem.setHtmlContentAllowed(true); policyItem.setPrimaryStyleName("valo-menu-item"); policyItem.setIcon(VaadinIcons.SAFE); menuItemsLayout.addComponent(policyItem); this.menuComponents.put(policyItem, SecurityConstants.ALL_AUTHORITY); final Button authItem = new Button("User Directories", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("authenticationMethodView"); } }); authItem.setHtmlContentAllowed(true); authItem.setPrimaryStyleName("valo-menu-item"); authItem.setIcon(VaadinIcons.COG); menuItemsLayout.addComponent(authItem); this.menuComponents.put(authItem, SecurityConstants.ALL_AUTHORITY); final Button platformConfigItem = new Button("Platform Configuration", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("platformConfigurationView"); } }); platformConfigItem.setHtmlContentAllowed(true); platformConfigItem.setPrimaryStyleName("valo-menu-item"); platformConfigItem.setIcon(VaadinIcons.LIST); menuItemsLayout.addComponent(platformConfigItem); this.menuComponents.put(platformConfigItem, SecurityConstants.ALL_AUTHORITY); }
From source file:org.jpos.qi.Sidebar.java
License:Open Source License
@SuppressWarnings("unchecked") private void loadSideBarOptions(String id) { if (id != null && id.equals(currentSidebarId)) return;//from w ww. j a va2s .c o m options = new LinkedHashMap<>(); if (menuItems != null) removeComponent(menuItems); currentSidebarId = id; menuItems = new CssLayout(); menuItems.setPrimaryStyleName("valo-menuitems"); Element cfg = app.getXmlConfiguration(); for (Element sb : cfg.getChildren("sidebar")) { String eid = sb.getAttributeValue("id"); if (id == eid || (eid != null && eid.equals(id))) { for (Element e : sb.getChildren()) { if ("section".equals(e.getName())) { Label l = new Label(e.getAttributeValue("name")); l.setStyleName(ValoTheme.MENU_SUBTITLE); l.setSizeUndefined(); menuItems.addComponent(l); } else if ("option".equals(e.getName())) { if (((QINavigator) QI.getQI().getNavigator()) .hasAccessToRoute(e.getAttributeValue("action"))) { Button b = new Button(e.getAttributeValue("name")); b.setPrimaryStyleName(ValoTheme.MENU_ITEM); String iconName = e.getAttributeValue("icon"); if (iconName != null) { try { b.setIcon(FontAwesome.valueOf(iconName)); } catch (IllegalArgumentException ex) { b.setIcon(FontAwesome.EXCLAMATION_TRIANGLE); b.setEnabled(false); } } String action = e.getAttributeValue("action"); options.put(action, b); if (action != null) b.addClickListener((Button.ClickListener) event -> app.getNavigator() .navigateTo("/" + action)); menuItems.addComponent(b); } } } addComponent(menuItems); } } }
From source file:org.opencms.ui.components.CmsVerticalMenu.java
License:Open Source License
/** * Adds a menu entry button.<p>//from w w w . j a v a 2s . c om * * @param entryButton the entry button */ public void addMenuEntry(Button entryButton) { entryButton.setPrimaryStyleName(OpenCmsTheme.VERTICAL_MENU_ITEM); addComponent(entryButton); }
From source file:org.opencms.ui.components.CmsVerticalMenu.java
License:Open Source License
/** * Adds an entry to the menu, returns the entry button.<p> * * @param label the label//from w ww. j a v a2 s .c o m * @param icon the icon * * @return the entry button */ public Button addMenuEntry(String label, Resource icon) { Button button = new Button(label, icon); button.setPrimaryStyleName(OpenCmsTheme.VERTICAL_MENU_ITEM); addComponent(button); return button; }
From source file:org.opennms.features.vaadin.surveillanceviews.ui.dashboard.SurveillanceViewAlarmTable.java
License:Open Source License
/** * Constructor for instantiating this component. * * @param surveillanceViewService the surveillance view service to be used * @param enabled the flag should links be enabled? *//*from ww w. j a v a 2 s . c om*/ public SurveillanceViewAlarmTable(SurveillanceViewService surveillanceViewService, boolean enabled) { /** * calling the super constructor */ super("Alarms", surveillanceViewService, enabled); /** * set the datasource */ setContainerDataSource(m_beanItemContainer); /** * the base stylename */ addStyleName("surveillance-view"); /** * add node column */ addGeneratedColumn("nodeLabel", new ColumnGenerator() { @Override public Object generateCell(final Table table, final Object itemId, final Object propertyId) { final Alarm alarm = (Alarm) itemId; Button icon = getClickableIcon("glyphicon glyphicon-warning-sign", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { final URI currentLocation = Page.getCurrent().getLocation(); final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath(); final String redirectFragment = contextRoot + "/alarm/detail.htm?quiet=true&id=" + alarm.getId(); LOG.debug("alarm {} clicked, current location = {}, uri = {}", alarm.getId(), currentLocation, redirectFragment); try { SurveillanceViewAlarmTable.this.getUI() .addWindow(new InfoWindow(new URL(currentLocation.toURL(), redirectFragment), new InfoWindow.LabelCreator() { @Override public String getLabel() { return "Alarm Info " + alarm.getId(); } })); } catch (MalformedURLException e) { LOG.error(e.getMessage(), e); } } }); Button button = new Button(alarm.getNodeLabel()); button.setPrimaryStyleName(BaseTheme.BUTTON_LINK); button.setEnabled(m_enabled); button.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { final URI currentLocation = Page.getCurrent().getLocation(); final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath(); final String redirectFragment = contextRoot + "/element/node.jsp?quiet=true&node=" + alarm.getNodeId(); LOG.debug("node {} clicked, current location = {}, uri = {}", alarm.getNodeId(), currentLocation, redirectFragment); try { SurveillanceViewAlarmTable.this.getUI() .addWindow(new InfoWindow(new URL(currentLocation.toURL(), redirectFragment), new InfoWindow.LabelCreator() { @Override public String getLabel() { return "Node Info " + alarm.getNodeId(); } })); } catch (MalformedURLException e) { LOG.error(e.getMessage(), e); } } }); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.addComponent(icon); horizontalLayout.addComponent(button); horizontalLayout.setSpacing(true); return horizontalLayout; } }); /** * add severity column */ addGeneratedColumn("severity", new ColumnGenerator() { @Override public Object generateCell(Table table, Object itemId, Object propertyId) { Alarm alarm = (Alarm) itemId; return getImageSeverityLayout(alarm.getSeverity()); } }); /** * set a cell style generator that handles the severity column */ setCellStyleGenerator(new CellStyleGenerator() { @Override public String getStyle(final Table source, final Object itemId, final Object propertyId) { Alarm alarm = ((Alarm) itemId); String style = alarm.getSeverity().toLowerCase(); if ("severity".equals(propertyId)) { style += "-image"; } return style; } }); /** * set column headers */ setColumnHeader("nodeLabel", "Node"); setColumnHeader("severity", "Severity"); setColumnHeader("uei", "UEI"); setColumnHeader("counter", "Count"); setColumnHeader("lastEventTime", "Last Time"); setColumnHeader("logMsg", "Log Msg"); setColumnExpandRatio("nodeLabel", 2.25f); setColumnExpandRatio("severity", 1.0f); setColumnExpandRatio("uei", 3.0f); setColumnExpandRatio("counter", 0.5f); setColumnExpandRatio("lastEventTime", 1.5f); setColumnExpandRatio("logMsg", 4.0f); /** * set visible columns */ setVisibleColumns("nodeLabel", "severity", "uei", "counter", "lastEventTime", "logMsg"); }
From source file:org.opennms.features.vaadin.surveillanceviews.ui.dashboard.SurveillanceViewNodeRtcTable.java
License:Open Source License
/** * Constructor for instantiating this component. * * @param surveillanceViewService the surveillance view service to be used * @param enabled the flag should links be enabled? *///from www . ja va 2 s . co m public SurveillanceViewNodeRtcTable(SurveillanceViewService surveillanceViewService, boolean enabled) { /** * call the super constructor */ super("Outages", surveillanceViewService, enabled); /** * set the datasource */ setContainerDataSource(m_beanItemContainer); /** * set the base style name */ addStyleName("surveillance-view"); /** * add node column */ addGeneratedColumn("node", new ColumnGenerator() { @Override public Object generateCell(Table table, Object itemId, Object propertyId) { final SurveillanceViewService.NodeRtc nodeRtc = (SurveillanceViewService.NodeRtc) itemId; Button button = new Button(nodeRtc.getNode().getLabel()); button.setPrimaryStyleName(BaseTheme.BUTTON_LINK); button.setEnabled(m_enabled); button.addStyleName("white"); button.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { final URI currentLocation = Page.getCurrent().getLocation(); final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath(); final String redirectFragment = contextRoot + "/element/node.jsp?quiet=true&node=" + nodeRtc.getNode().getId(); LOG.debug("node {} clicked, current location = {}, uri = {}", nodeRtc.getNode().getId(), currentLocation, redirectFragment); try { SurveillanceViewNodeRtcTable.this.getUI() .addWindow(new InfoWindow(new URL(currentLocation.toURL(), redirectFragment), new InfoWindow.LabelCreator() { @Override public String getLabel() { return "Node Info " + nodeRtc.getNode().getId(); } })); } catch (MalformedURLException e) { LOG.error(e.getMessage(), e); } } }); return button; } }); /** * add currentOutages column */ addGeneratedColumn("currentOutages", new ColumnGenerator() { @Override public Object generateCell(Table table, final Object itemId, Object columnId) { SurveillanceViewService.NodeRtc nodeRtc = (SurveillanceViewService.NodeRtc) itemId; return getImageSeverityLayout(nodeRtc.getDownServiceCount() + " of " + nodeRtc.getServiceCount()); } }); /** * add availability column */ addGeneratedColumn("availability", new ColumnGenerator() { @Override public Object generateCell(Table table, final Object itemId, Object propertyId) { SurveillanceViewService.NodeRtc nodeRtc = (SurveillanceViewService.NodeRtc) itemId; return getImageSeverityLayout(nodeRtc.getAvailabilityAsString()); } }); /** * set cell style generator that handles the two severities for RTC calculations */ setCellStyleGenerator(new CellStyleGenerator() { @Override public String getStyle(Table table, Object itemId, Object propertyId) { String style = null; SurveillanceViewService.NodeRtc nodeRtc = (SurveillanceViewService.NodeRtc) itemId; if (!"node".equals(propertyId)) { if (nodeRtc.getAvailability() == 1.0) { style = "rtc-normal"; } else { style = "rtc-critical"; } } return style; } }); /** * set the column headers */ setColumnHeader("node", "Node"); setColumnHeader("currentOutages", "Current Outages"); setColumnHeader("availability", "24 Hour Availability"); setColumnExpandRatio("node", 1.0f); setColumnExpandRatio("currentOutages", 1.0f); setColumnExpandRatio("availability", 1.0f); /** * define the visible columns */ setVisibleColumns(new Object[] { "node", "currentOutages", "availability" }); }
From source file:org.opennms.features.vaadin.surveillanceviews.ui.dashboard.SurveillanceViewNotificationTable.java
License:Open Source License
/** * Constructor for instantiating this component. * * @param surveillanceViewService the surveillance view service to be used * @param enabled the flag should links be enabled? */// ww w. j av a2 s .c om public SurveillanceViewNotificationTable(SurveillanceViewService surveillanceViewService, boolean enabled) { /** * calling the super constructor */ super("Notifications", surveillanceViewService, enabled); /** * set the datasource */ setContainerDataSource(m_beanItemContainer); /** * set the base style name */ addStyleName("surveillance-view"); /** * add node column */ addGeneratedColumn("nodeLabel", new ColumnGenerator() { @Override public Object generateCell(final Table table, final Object itemId, final Object propertyId) { final Notification notification = (Notification) itemId; Button icon = getClickableIcon("glyphicon glyphicon-bell", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { final URI currentLocation = Page.getCurrent().getLocation(); final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath(); final String redirectFragment = contextRoot + "/notification/detail.jsp?quiet=true¬ice=" + notification.getId(); LOG.debug("notification {} clicked, current location = {}, uri = {}", notification.getId(), currentLocation, redirectFragment); try { SurveillanceViewNotificationTable.this.getUI() .addWindow(new InfoWindow(new URL(currentLocation.toURL(), redirectFragment), new InfoWindow.LabelCreator() { @Override public String getLabel() { return "Notification Info " + notification.getId(); } })); } catch (MalformedURLException e) { LOG.error(e.getMessage(), e); } } }); Button button = new Button(notification.getNodeLabel()); button.setPrimaryStyleName(BaseTheme.BUTTON_LINK); button.setEnabled(m_enabled); button.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { final URI currentLocation = Page.getCurrent().getLocation(); final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath(); final String redirectFragment = contextRoot + "/element/node.jsp?quiet=true&node=" + notification.getNodeId(); ; LOG.debug("node {} clicked, current location = {}, uri = {}", notification.getNodeId(), currentLocation, redirectFragment); try { SurveillanceViewNotificationTable.this.getUI() .addWindow(new InfoWindow(new URL(currentLocation.toURL(), redirectFragment), new InfoWindow.LabelCreator() { @Override public String getLabel() { return "Node Info " + notification.getNodeId(); } })); } catch (MalformedURLException e) { LOG.error(e.getMessage(), e); } } }); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.addComponent(icon); horizontalLayout.addComponent(button); horizontalLayout.setSpacing(true); return horizontalLayout; } }); /** * set the cell style generator */ setCellStyleGenerator(new CellStyleGenerator() { @Override public String getStyle(final Table source, final Object itemId, final Object propertyId) { Notification notification = ((Notification) itemId); return notification.getSeverity().toLowerCase(); } }); /** * set column headers */ setColumnHeader("nodeLabel", "Node"); setColumnHeader("serviceType", "Service"); setColumnHeader("textMsg", "Message"); setColumnHeader("pageTime", "Sent Time"); setColumnHeader("answeredBy", "Responder"); setColumnHeader("respondTime", "Respond Time"); setColumnExpandRatio("nodeLabel", 2.0f); setColumnExpandRatio("serviceType", 1.0f); setColumnExpandRatio("textMsg", 4.0f); setColumnExpandRatio("pageTime", 2.0f); setColumnExpandRatio("answeredBy", 1.0f); setColumnExpandRatio("respondTime", 2.0f); /** * define visible columns */ setVisibleColumns("nodeLabel", "serviceType", "textMsg", "pageTime", "answeredBy", "respondTime"); }