List of usage examples for com.vaadin.ui Button setHtmlContentAllowed
@Deprecated public void setHtmlContentAllowed(boolean htmlContentAllowed)
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;/* w w w. j a v a 2 s . com*/ 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.jumpmind.metl.ui.common.TopBar.java
License:Open Source License
public TopBar(ViewManager vm, ApplicationContext context) { setWidth(100, Unit.PERCENTAGE);/* w w w . j a v a 2 s .c o m*/ this.context = context; this.viewManager = vm; this.viewManager.addViewChangeListener(this); viewToButtonMapping = new HashMap<String, MenuItem>(); menuBar = new MenuBar(); menuBar.setWidth(100, Unit.PERCENTAGE); addComponent(menuBar); setExpandRatio(menuBar, 1.0f); String systemText = getGlobalSetting(GlobalSetting.SYSTEM_TEXT, "").getValue(); if (isNotBlank(systemText)) { Button systemLabel = new Button(systemText, FontAwesome.WARNING); systemLabel.setHtmlContentAllowed(true); addComponent(systemLabel); } Button helpButton = new Button("Help", FontAwesome.QUESTION_CIRCLE); helpButton.addClickListener(event -> openHelp(event)); addComponent(helpButton); Button settingsButton = new Button(context.getUser().getLoginId(), FontAwesome.GEAR); settingsButton.addClickListener((event) -> { }); addComponent(settingsButton); Button logoutButton = new Button("Logout", FontAwesome.SIGN_OUT); logoutButton.addClickListener(event -> logout()); addComponent(logoutButton); Map<Category, List<TopBarLink>> menuItemsByCategory = viewManager.getMenuItemsByCategory(); Set<Category> categories = menuItemsByCategory.keySet(); for (Category category : categories) { if (!context.getUser().hasPrivilege(category.name())) { log.info("'{}' does not have access to the {} menu tab", context.getUser(), category.name()); continue; } List<TopBarLink> links = menuItemsByCategory.get(category); boolean needDefaultView = viewManager.getDefaultView() == null && links.size() > 0; MenuItem categoryItem = null; if (links.size() > 1) { categoryItem = menuBar.addItem(category.name(), null); categoryItems.add(categoryItem); } if (needDefaultView) { viewManager.setDefaultView(links.get(0).id()); } for (final TopBarLink menuLink : links) { Command command = new Command() { private static final long serialVersionUID = 1L; @Override public void menuSelected(MenuItem selectedItem) { uncheckAll(); selectedItem.setChecked(true); viewManager.navigateTo(menuLink.id()); } }; MenuItem menuItem = null; if (categoryItem == null) { menuItem = menuBar.addItem(menuLink.name(), command); } else { menuItem = categoryItem.addItem(menuLink.name(), command); } menuItem.setCheckable(true); viewToButtonMapping.put(menuLink.id(), menuItem); } } viewManager.navigateTo(viewManager.getDefaultView()); }
From source file:org.lucidj.browser.BrowserView.java
License:Apache License
private void build_toolbar() { current_toolbar = new CssLayout(); CssLayout local_toolbar = new CssLayout(); current_toolbar.addComponent(local_toolbar); CssLayout navigation = new CssLayout(); navigation.addStyleName("v-component-group"); navigation.addStyleName("ui-toolbar-spacer"); createButton(navigation, "prev-smartbox", FontAwesome.CHEVRON_LEFT, null, ShortcutAction.KeyCode.ARROW_UP, ShortcutAction.ModifierKey.CTRL); createButton(navigation, "next-smartbox", FontAwesome.CHEVRON_RIGHT, null, ShortcutAction.KeyCode.ARROW_DOWN, ShortcutAction.ModifierKey.CTRL); local_toolbar.addComponent(navigation); createButton(local_toolbar, "save", FontAwesome.SAVE).addStyleName("ui-toolbar-spacer"); // createButton (local_toolbar, "test", FontAwesome.MAGIC) // .addStyleName("ui-toolbar-spacer"); // createButton (local_toolbar, "test2", FontAwesome.FLASK) // .addStyleName("ui-toolbar-spacer"); CssLayout edition = new CssLayout(); edition.addStyleName("v-component-group"); edition.addStyleName("ui-toolbar-spacer"); createButton(edition, "undo-cell-edit", FontAwesome.UNDO, "Undo"); createButton(edition, "redo-cell-edit", FontAwesome.REPEAT, null); createButton(edition, "delete-cell", FontAwesome.TRASH_O, null); local_toolbar.addComponent(edition); CssLayout view_controls = new CssLayout(); view_controls.addStyleName("v-component-group"); view_controls.addStyleName("ui-toolbar-spacer"); createButton(view_controls, VM_NOTEBOOK, new ExternalResource("vaadin://~/Browser_libraries/notebook-view.png")); createButton(view_controls, VM_SINGLE, new ExternalResource("vaadin://~/Browser_libraries/single-view.png"), null, ShortcutAction.KeyCode.INSERT, ShortcutAction.ModifierKey.CTRL); local_toolbar.addComponent(view_controls); // TODO: CTRL+ENTER => RUN AND SKIP TO NEXT // TODO: SELECTION + SHIFT+ENTER => RUN ONLY SELECTED STATEMENTS final Button source_view = new Button(); source_view.setId("output"); source_view.addStyleName("ui-toolbar-spacer"); source_view.setHtmlContentAllowed(true); String ico = "<path class=\"path1\" d=\"M1088 128h-64v-64c0-35.2-28.8-64-64-64h-896c-35.2 0-64 28.8-64 64v768c0 35.2 28.8 64 64 64h64v64c0 35.2 28.8 64 64 64h896c35.2 0 64-28.8 64-64v-768c0-35.2-28.8-64-64-64zM128 192v640h-63.886c-0.040-0.034-0.082-0.076-0.114-0.116v-767.77c0.034-0.040 0.076-0.082 0.114-0.114h895.77c0.040 0.034 0.082 0.076 0.116 0.116v63.884h-768c-35.2 0-64 28.8-64 64v0zM1088 959.884c-0.034 0.040-0.076 0.082-0.116 0.116h-895.77c-0.040-0.034-0.082-0.076-0.114-0.116v-767.77c0.034-0.040 0.076-0.082 0.114-0.114h895.77c0.040 0.034 0.082 0.076 0.116 0.116v767.768z\"></path>\n" + "<path class=\"path2\" d=\"M960 352c0 53.020-42.98 96-96 96s-96-42.98-96-96 42.98-96 96-96 96 42.98 96 96z\"></path>\n" + "<path class=\"path3\" d=\"M1024 896h-768v-128l224-384 256 320h64l224-192z\"></path>"; source_view.setCaption(//from w ww . j av a2 s. c om "<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1152 1024\">" + ico + "</svg>"); source_view.addStyleName("tiny"); source_view.addStyleName("toolbar"); source_view.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { handle_button_click(source_view); } }); local_toolbar.addComponent(source_view); // Button output_view = new Button (); // output_view.setHtmlContentAllowed(true); // String ico2 = "<path d=\"M249.649 792.806l-107.776 166.4 11.469 54.426 54.272-11.622 107.725-166.298c-11.469-6.144-22.835-12.698-33.843-19.968-11.162-7.219-21.811-14.95-31.846-22.938zM705.943 734.694c0.717-1.485 1.178-3.123 1.843-4.71 2.714-5.99 5.12-11.981 7.066-18.278 0.307-1.126 0.461-2.253 0.819-3.277 1.997-6.963 3.686-13.824 5.018-20.89 0-0.358 0-0.614 0-1.075 9.984-59.853-7.424-126.618-47.258-186.931l56.832-87.757c65.485 8.346 122.112-8.141 149.35-50.278 47.258-72.858-10.24-194.15-128.256-271.002-118.118-76.902-252.058-80.128-299.213-7.373-27.341 42.189-19.354 100.71 15.002 157.338l-56.934 87.757c-71.117-11.93-139.059-0.819-189.594 32.768-0.307 0.102-0.666 0.205-0.87 0.41-5.888 3.994-11.622 8.397-16.998 13.005-0.87 0.717-1.894 1.382-2.611 2.099-5.018 4.301-9.523 9.114-13.875 13.926-1.024 1.229-2.458 2.304-3.43 3.584-5.427 6.195-10.445 12.749-14.848 19.712-70.861 109.21-10.394 274.483 134.81 369.101 145.306 94.618 320.512 82.637 391.219-26.573 4.454-6.912 8.55-14.131 11.93-21.555zM664.215 224.845c-45.414-29.542-67.584-76.134-49.408-104.243 18.125-28.006 69.683-26.726 114.995 2.816 45.517 29.542 67.482 76.237 49.408 104.243s-69.53 26.726-114.995-2.816z\"></path>"; // output_view.setCaption("<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">" + ico2 + "</svg>"); // output_view.addStyleName("tiny"); // view_controls.addComponent (output_view); // // Button run = new Button (); // run.setHtmlContentAllowed(true); // String ico3 = "<path class=\"path1\" d=\"M192 128l640 384-640 384z\"></path>"; // run.setCaption("<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">" + ico3 + "</svg>"); // run.addStyleName("tiny"); // view_controls.addComponent (run); }
From source file:org.lucidj.html_renderer.HtmlRenderer.java
License:Apache License
private void init_toolbar() { editor_toolbar = new CssLayout(); CssLayout group = new CssLayout(); group.addStyleName("v-component-group"); Button output_view = new Button(); output_view.setHtmlContentAllowed(true); String ico2 = "<path d=\"M249.649 792.806l-107.776 166.4 11.469 54.426 54.272-11.622 107.725-166.298c-11.469-6.144-22.835-12.698-33.843-19.968-11.162-7.219-21.811-14.95-31.846-22.938zM705.943 734.694c0.717-1.485 1.178-3.123 1.843-4.71 2.714-5.99 5.12-11.981 7.066-18.278 0.307-1.126 0.461-2.253 0.819-3.277 1.997-6.963 3.686-13.824 5.018-20.89 0-0.358 0-0.614 0-1.075 9.984-59.853-7.424-126.618-47.258-186.931l56.832-87.757c65.485 8.346 122.112-8.141 149.35-50.278 47.258-72.858-10.24-194.15-128.256-271.002-118.118-76.902-252.058-80.128-299.213-7.373-27.341 42.189-19.354 100.71 15.002 157.338l-56.934 87.757c-71.117-11.93-139.059-0.819-189.594 32.768-0.307 0.102-0.666 0.205-0.87 0.41-5.888 3.994-11.622 8.397-16.998 13.005-0.87 0.717-1.894 1.382-2.611 2.099-5.018 4.301-9.523 9.114-13.875 13.926-1.024 1.229-2.458 2.304-3.43 3.584-5.427 6.195-10.445 12.749-14.848 19.712-70.861 109.21-10.394 274.483 134.81 369.101 145.306 94.618 320.512 82.637 391.219-26.573 4.454-6.912 8.55-14.131 11.93-21.555zM664.215 224.845c-45.414-29.542-67.584-76.134-49.408-104.243 18.125-28.006 69.683-26.726 114.995 2.816 45.517 29.542 67.482 76.237 49.408 104.243s-69.53 26.726-114.995-2.816z\"></path>"; output_view.setCaption(//from w ww .j av a2 s. c om "<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">" + ico2 + "</svg>"); output_view.addStyleName("tiny"); group.addComponent(output_view); output_view.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { show_hide_rich_text(); } }); Button run = new Button(); run.setHtmlContentAllowed(true); String ico3 = "<path class=\"path1\" d=\"M192 128l640 384-640 384z\"></path>"; run.setCaption( "<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">" + ico3 + "</svg>"); run.addStyleName("tiny"); group.addComponent(run); run.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { render_html_from_rich_text(); } }); run.addShortcutListener(new AbstractField.FocusShortcut(run, ShortcutAction.KeyCode.ENTER, ShortcutAction.ModifierKey.SHIFT) { @Override public void handleAction(Object sender, Object target) { render_html_from_rich_text(); } }); editor_toolbar.addComponent(group); }
From source file:org.lucidj.markdown_renderer.MarkdownRenderer.java
License:Apache License
private void init_toolbar() { editor_toolbar = new CssLayout(); CssLayout group = new CssLayout(); group.addStyleName("v-component-group"); Button output_view = new Button(); output_view.setHtmlContentAllowed(true); String ico2 = "<path d=\"M249.649 792.806l-107.776 166.4 11.469 54.426 54.272-11.622 107.725-166.298c-11.469-6.144-22.835-12.698-33.843-19.968-11.162-7.219-21.811-14.95-31.846-22.938zM705.943 734.694c0.717-1.485 1.178-3.123 1.843-4.71 2.714-5.99 5.12-11.981 7.066-18.278 0.307-1.126 0.461-2.253 0.819-3.277 1.997-6.963 3.686-13.824 5.018-20.89 0-0.358 0-0.614 0-1.075 9.984-59.853-7.424-126.618-47.258-186.931l56.832-87.757c65.485 8.346 122.112-8.141 149.35-50.278 47.258-72.858-10.24-194.15-128.256-271.002-118.118-76.902-252.058-80.128-299.213-7.373-27.341 42.189-19.354 100.71 15.002 157.338l-56.934 87.757c-71.117-11.93-139.059-0.819-189.594 32.768-0.307 0.102-0.666 0.205-0.87 0.41-5.888 3.994-11.622 8.397-16.998 13.005-0.87 0.717-1.894 1.382-2.611 2.099-5.018 4.301-9.523 9.114-13.875 13.926-1.024 1.229-2.458 2.304-3.43 3.584-5.427 6.195-10.445 12.749-14.848 19.712-70.861 109.21-10.394 274.483 134.81 369.101 145.306 94.618 320.512 82.637 391.219-26.573 4.454-6.912 8.55-14.131 11.93-21.555zM664.215 224.845c-45.414-29.542-67.584-76.134-49.408-104.243 18.125-28.006 69.683-26.726 114.995 2.816 45.517 29.542 67.482 76.237 49.408 104.243s-69.53 26.726-114.995-2.816z\"></path>"; output_view.setCaption(/*ww w. ja v a2 s . c om*/ "<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">" + ico2 + "</svg>"); output_view.addStyleName("tiny"); group.addComponent(output_view); output_view.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { show_hide_rich_text(); } }); Button run = new Button(); run.setHtmlContentAllowed(true); String ico3 = "<path class=\"path1\" d=\"M192 128l640 384-640 384z\"></path>"; run.setCaption( "<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">" + ico3 + "</svg>"); run.addStyleName("tiny"); group.addComponent(run); run.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { render_html_from_markdown(); } }); run.addShortcutListener(new AbstractField.FocusShortcut(run, ShortcutAction.KeyCode.ENTER, ShortcutAction.ModifierKey.SHIFT) { @Override public void handleAction(Object sender, Object target) { render_html_from_markdown(); } }); editor_toolbar.addComponent(group); }
From source file:org.lucidj.smartbox_renderer.SmartBoxRenderer.java
License:Apache License
private void init_toolbar() { cell_toolbar = new CssLayout(); CssLayout group = new CssLayout(); group.addStyleName("v-component-group"); group.addStyleName("ui-toolbar-spacer"); Button run = new Button(); run.setHtmlContentAllowed(true); String ico3 = "<path class=\"path1\" d=\"M192 128l640 384-640 384z\"></path>"; run.setCaption(// w w w. j a v a2s . c om "<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">" + ico3 + "</svg>"); run.addStyleName("tiny"); group.addComponent(run); run.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { source.fireEvent(this, "run"); } }); run.addShortcutListener(new ShortcutListener("Run", ShortcutAction.KeyCode.ENTER, new int[] { ShortcutAction.ModifierKey.CTRL }) { @Override public void handleAction(Object sender, Object target) { // The shortcuts (while active on toolbar) are global, however for // Ctrl+Enter this becomes counter-intuitive. This way, we filter // it to avoid running things from outside the edition field. if (target == commands) { source.fireEvent(this, "run"); } } }); Button stop = new Button(); stop.setIcon(FontAwesome.STOP); stop.addStyleName("tiny"); group.addComponent(stop); stop.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { source.fireEvent(this, "stop"); } }); cell_toolbar.addComponent(group); }
From source file:org.opennms.features.topology.app.internal.TopologyUI.java
License:Open Source License
private Component createMapLayout() { final Property<Double> scale = m_graphContainer.getScaleProperty(); m_lastUpdatedTimeLabel = new LastUpdatedLabel(); m_lastUpdatedTimeLabel.setImmediate(true); m_zoomLevelLabel.setHeight(20, Unit.PIXELS); m_zoomLevelLabel.setWidth(22, Unit.PIXELS); m_zoomLevelLabel.addStyleName("center-text"); m_zoomLevelLabel.addTextChangeListener(new FieldEvents.TextChangeListener() { @Override/*from ww w.ja v a 2 s. c o m*/ public void textChange(FieldEvents.TextChangeEvent event) { try { int zoomLevel = Integer.parseInt(event.getText()); setSemanticZoomLevel(zoomLevel); } catch (NumberFormatException e) { setSemanticZoomLevel(m_graphContainer.getSemanticZoomLevel()); } } }); m_topologyComponent = new TopologyComponent(m_graphContainer, m_iconRepositoryManager, this); m_topologyComponent.setSizeFull(); m_topologyComponent.addMenuItemStateListener(this); m_topologyComponent.addVertexUpdateListener(this); final Slider slider = new Slider(0, 1); slider.setPropertyDataSource(scale); slider.setResolution(1); slider.setHeight("200px"); slider.setOrientation(SliderOrientation.VERTICAL); slider.setImmediate(true); final NativeButton showFocusVerticesBtn = new NativeButton(FontAwesomeIcons.Icon.eye_open.variant()); showFocusVerticesBtn.setDescription("Toggle Highlight Focus Nodes"); showFocusVerticesBtn.setHtmlContentAllowed(true); showFocusVerticesBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (showFocusVerticesBtn.getCaption().equals(FontAwesomeIcons.Icon.eye_close.variant())) { showFocusVerticesBtn.setCaption(FontAwesomeIcons.Icon.eye_open.variant()); } else { showFocusVerticesBtn.setCaption(FontAwesomeIcons.Icon.eye_close.variant()); } m_topologyComponent.getState() .setHighlightFocus(!m_topologyComponent.getState().isHighlightFocus()); m_topologyComponent.updateGraph(); } }); final NativeButton magnifyBtn = new NativeButton(); magnifyBtn.setHtmlContentAllowed(true); magnifyBtn.setCaption("<i class=\"" + FontAwesomeIcons.Icon.zoom_in.stylename() + "\" ></i>"); magnifyBtn.setStyleName("icon-button"); magnifyBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (slider.getValue() < 1) { slider.setValue(Math.min(1, slider.getValue() + 0.25)); } } }); final NativeButton demagnifyBtn = new NativeButton(); demagnifyBtn.setHtmlContentAllowed(true); demagnifyBtn.setCaption("<i class=\"" + FontAwesomeIcons.Icon.zoom_out.stylename() + "\" ></i>"); demagnifyBtn.setStyleName("icon-button"); demagnifyBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (slider.getValue() != 0) { slider.setValue(Math.max(0, slider.getValue() - 0.25)); } } }); VerticalLayout sliderLayout = new VerticalLayout(); sliderLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); sliderLayout.addComponent(magnifyBtn); sliderLayout.addComponent(slider); sliderLayout.addComponent(demagnifyBtn); m_szlOutBtn = new Button(); m_szlOutBtn.setHtmlContentAllowed(true); m_szlOutBtn.setCaption(FontAwesomeIcons.Icon.arrow_down.variant()); m_szlOutBtn.setDescription("Collapse Semantic Zoom Level"); m_szlOutBtn.setEnabled(m_graphContainer.getSemanticZoomLevel() > 0); m_szlOutBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { int szl = m_graphContainer.getSemanticZoomLevel(); if (szl > 0) { szl--; setSemanticZoomLevel(szl); saveHistory(); } } }); final Button szlInBtn = new Button(); szlInBtn.setHtmlContentAllowed(true); szlInBtn.setCaption(FontAwesomeIcons.Icon.arrow_up.variant()); szlInBtn.setDescription("Expand Semantic Zoom Level"); szlInBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { int szl = m_graphContainer.getSemanticZoomLevel(); szl++; setSemanticZoomLevel(szl); saveHistory(); } }); m_panBtn = new Button(); m_panBtn.setIcon(FontAwesome.ARROWS); m_panBtn.setDescription("Pan Tool"); m_panBtn.setStyleName("toolbar-button down"); m_selectBtn = new Button(); m_selectBtn.setIcon(new ThemeResource("images/selection.png")); m_selectBtn.setDescription("Selection Tool"); m_selectBtn.setStyleName("toolbar-button"); m_selectBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { m_selectBtn.setStyleName("toolbar-button down"); m_panBtn.setStyleName("toolbar-button"); m_topologyComponent.setActiveTool("select"); } }); m_panBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { m_panBtn.setStyleName("toolbar-button down"); m_selectBtn.setStyleName("toolbar-button"); m_topologyComponent.setActiveTool("pan"); } }); final Button historyBackBtn = new Button(FontAwesomeIcons.Icon.arrow_left.variant()); historyBackBtn.setHtmlContentAllowed(true); historyBackBtn.setDescription("Click to go back"); historyBackBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { com.vaadin.ui.JavaScript.getCurrent().execute("window.history.back()"); } }); final Button historyForwardBtn = new Button(FontAwesomeIcons.Icon.arrow_right.variant()); historyForwardBtn.setHtmlContentAllowed(true); historyForwardBtn.setDescription("Click to go forward"); historyForwardBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { com.vaadin.ui.JavaScript.getCurrent().execute("window.history.forward()"); } }); m_searchBox = new SearchBox(m_serviceManager, new CommandManager.DefaultOperationContext(this, m_graphContainer, OperationContext.DisplayLocation.SEARCH)); //History Button Layout HorizontalLayout historyButtonLayout = new HorizontalLayout(); historyButtonLayout.setSpacing(true); historyButtonLayout.addComponent(historyBackBtn); historyButtonLayout.addComponent(historyForwardBtn); //Semantic Controls Layout HorizontalLayout semanticLayout = new HorizontalLayout(); semanticLayout.setSpacing(true); semanticLayout.addComponent(szlInBtn); semanticLayout.addComponent(m_zoomLevelLabel); semanticLayout.addComponent(m_szlOutBtn); semanticLayout.setComponentAlignment(m_zoomLevelLabel, Alignment.MIDDLE_CENTER); VerticalLayout historyCtrlLayout = new VerticalLayout(); historyCtrlLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); historyCtrlLayout.addComponent(historyButtonLayout); HorizontalLayout controlLayout = new HorizontalLayout(); controlLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); controlLayout.addComponent(m_panBtn); controlLayout.addComponent(m_selectBtn); VerticalLayout semanticCtrlLayout = new VerticalLayout(); semanticCtrlLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); semanticCtrlLayout.addComponent(semanticLayout); HorizontalLayout locationToolLayout = createLocationToolLayout(); //Vertical Layout for all tools on right side VerticalLayout toollayout = new VerticalLayout(); toollayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); toollayout.setSpacing(true); toollayout.addComponent(historyCtrlLayout); toollayout.addComponent(locationToolLayout); toollayout.addComponent(showFocusVerticesBtn); toollayout.addComponent(sliderLayout); toollayout.addComponent(controlLayout); toollayout.addComponent(semanticCtrlLayout); AbsoluteLayout mapLayout = new AbsoluteLayout(); mapLayout.addComponent(m_topologyComponent, "top:0px; left: 0px; right: 0px; bottom: 0px;"); mapLayout.addComponent(m_lastUpdatedTimeLabel, "top: 5px; right: 10px;"); mapLayout.addComponent(toollayout, "top: 25px; right: 10px;"); mapLayout.setSizeFull(); m_infoPanel = new InfoPanel(m_searchBox, mapLayout); return m_infoPanel; }
From source file:org.opennms.features.topology.app.internal.TopologyUI.java
License:Open Source License
private HorizontalLayout createLocationToolLayout() { HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true);// ww w .ja va2 s .c om layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); Button showAllMapBtn = new Button(FontAwesomeIcons.Icon.globe.variant()); showAllMapBtn.setHtmlContentAllowed(true); showAllMapBtn.setDescription("Show Entire Map"); showAllMapBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { m_topologyComponent.showAllMap(); } }); Button centerSelectionBtn = new Button(FontAwesomeIcons.Icon.location_arrow.variant()); centerSelectionBtn.setHtmlContentAllowed(true); centerSelectionBtn.setDescription("Center On Selection"); centerSelectionBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { m_topologyComponent.centerMapOnSelection(); } }); layout.addComponent(centerSelectionBtn); layout.addComponent(showAllMapBtn); return layout; }
From source file:org.opennms.features.vaadin.surveillanceviews.ui.dashboard.SurveillanceViewDetailTable.java
License:Open Source License
/** * Returns a clickable glyph icon with the given {@link com.vaadin.ui.Button.ClickListener}. * * @param glyphIcon the icon to be used * @param clickListener the listener/* w w w . j a v a 2 s. c o m*/ * @return the button instance */ protected Button getClickableIcon(String glyphIcon, Button.ClickListener clickListener) { Button button = new Button("<span class=\"" + glyphIcon + "\" aria-hidden=\"true\"></span>"); button.setHtmlContentAllowed(true); button.setStyleName(BaseTheme.BUTTON_LINK); button.addStyleName("icon"); button.setEnabled(m_enabled); button.addClickListener(clickListener); return button; }
From source file:roart.client.MyVaadinUI.java
private Button getSimilar(String text, final String md5) { Button button = new Button(text); button.setHtmlContentAllowed(true); button.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { SearchService maininst = new SearchService(); maininst.searchsimilar(md5); Notification.show("Request sent"); }//from w ww . ja v a 2 s. c om }); return button; }