List of usage examples for com.vaadin.ui Button setCaption
@Override public void setCaption(String caption)
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( "<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);// w ww . ja va2 s . c o m 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.newview.NewView.java
License:Apache License
private Layout form_location_panel() { VerticalLayout rolldown = new VerticalLayout(); rolldown.setCaption("Location"); rolldown.setSpacing(true);/*from w ww . j av a 2 s . c om*/ HorizontalLayout directory_and_browse = new HorizontalLayout(); directory_and_browse.setSpacing(true); directory_and_browse.setWidth(100, Unit.PERCENTAGE); frm_directory = new TextField(); frm_directory.setValue(projects_dir.toString()); frm_directory.setWidth(100, Unit.PERCENTAGE); directory_and_browse.addComponent(frm_directory); Button confirm = new Button("Save"); confirm.addStyleName(ValoTheme.BUTTON_PRIMARY); confirm.setVisible(false); directory_and_browse.addComponent(confirm); Button change_directory = new Button("Change location..."); directory_and_browse.addComponent(change_directory); directory_and_browse.setExpandRatio(frm_directory, 1.0f); rolldown.addComponent(directory_and_browse); Path projects_home = securityEngine.getSubject().getDefaultUserDir(); frm_directories = rendererFactory.newRenderer(projects_home); frm_directories.setVisible(false); rolldown.addComponent(frm_directories); change_directory.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { if (frm_directories.isVisible()) { change_directory.setCaption("Change location..."); frm_directories.setVisible(false); confirm.setVisible(false); } else { change_directory.setCaption("Cancel change"); frm_directories.setVisible(true); confirm.setVisible(true); } } }); frm_directories.addListener(new Listener() { @Override public void componentEvent(Event event) { if (event instanceof ItemClickEvent) { ItemClickEvent itemClickEvent = (ItemClickEvent) event; File item_id = ((File) itemClickEvent.getItemId()); log.info("CLICK item_path={}", item_id); frm_directory.setValue(item_id.getPath()); } } }); return (rolldown); }
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);/* w w w .j av a 2 s.c o m*/ 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) { 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.lunifera.examples.ecview.model.ui.PersonUI.java
License:Apache License
@SuppressWarnings("restriction") @Override// www.ja v a 2s. c o m protected void init(VaadinRequest request) { VerticalLayout spanningLayout = new VerticalLayout(); spanningLayout.setSizeFull(); setContent(spanningLayout); dtoService = DtoServiceAccess.getService(PersonDto.class); VerticalLayout layout = new VerticalLayout(); spanningLayout.addComponent(layout); layout.setSizeUndefined(); layout.setWidth("100%"); HorizontalLayout buttonBar = new HorizontalLayout(); layout.addComponent(buttonBar); buttonBar.setMargin(true); buttonBar.setSpacing(true); NativeButton setupDB = new NativeButton("Setup DB"); setupDB.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Activator.INSTANCE.setupDB(); } }); buttonBar.addComponent(setupDB); YView yView = findViewModel("org.lunifera.examples.ecview.model.jpa.services.PersonView"); if (yView == null) { Notification.show("PersonView could not be found!", Type.ERROR_MESSAGE); return; } // render the Vaadin UI VaadinRenderer renderer = new VaadinRenderer(); try { viewContext = renderer.render(layout, yView, null); } catch (ContextException e) { e.printStackTrace(); } II18nService service = viewContext.getService(II18nService.ID); for (YExposedAction action : yView.getExposedActions()) { Button temp = new Button(); buttonBar.addComponent(temp); temp.setCaption(service.getValue(action.getLabelI18nKey(), getLocale())); temp.setIcon(new ThemeResource(action.getIcon())); if (action.getId().equals("org.lunifera.actions.load")) { reloadAction = temp; reloadAction.setEnabled(false); temp.addClickListener(new LoadHandler()); } else if (action.getId().equals("org.lunifera.actions.save")) { saveAction = temp; saveAction.setEnabled(false); temp.addClickListener(new SaveHandler()); } else if (action.getId().equals("org.lunifera.actions.delete")) { deleteAction = temp; deleteAction.setEnabled(false); temp.addClickListener(new DeleteHandler()); } else if (action.getId().equals("org.lunifera.actions.find")) { searchAction = temp; temp.addClickListener(new SearchHandler()); } } }
From source file:org.opencms.ui.CmsVaadinUtils.java
License:Open Source License
/** * Shows an alert box to the user with the given information, which will perform the given action after the user clicks on OK.<p> * * @param title the title/* w ww. ja v a 2s . com*/ * @param message the message * * @param callback the callback to execute after clicking OK */ public static void showAlert(String title, String message, final Runnable callback) { final Window window = new Window(); window.setModal(true); Panel panel = new Panel(); panel.setCaption(title); panel.setWidth("500px"); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); panel.setContent(layout); layout.addComponent(new Label(message)); Button okButton = new Button(); okButton.addClickListener(new ClickListener() { /** The serial version id. */ private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { window.close(); if (callback != null) { callback.run(); } } }); layout.addComponent(okButton); layout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT); okButton.setCaption(org.opencms.workplace.Messages.get().getBundle(A_CmsUI.get().getLocale()) .key(org.opencms.workplace.Messages.GUI_DIALOG_BUTTON_OK_0)); window.setContent(panel); window.setClosable(false); window.setResizable(false); A_CmsUI.get().addWindow(window); }
From source file:org.opencms.ui.dialogs.history.diff.CmsValueCompareBean.java
License:Open Source License
/** * Creates a new instance.<p>/*www. jav a 2s .c o m*/ * * @param cms the CMS context * @param elemComp the element comparison bean */ public CmsValueCompareBean(CmsObject cms, CmsElementComparison elemComp) { m_cms = cms; m_elemComp = elemComp; String changeType = m_elemComp.getStatus(); String key = null; String style = null; if (CmsResourceComparison.TYPE_ADDED.equals(changeType)) { key = org.opencms.workplace.comparison.Messages.GUI_COMPARE_ADDED_0; style = OpenCmsTheme.DIFF_TYPE_ADDED; } else if (CmsResourceComparison.TYPE_REMOVED.equals(changeType)) { key = org.opencms.workplace.comparison.Messages.GUI_COMPARE_REMOVED_0; style = OpenCmsTheme.DIFF_TYPE_DELETED; } else if (CmsResourceComparison.TYPE_CHANGED.equals(changeType)) { key = org.opencms.workplace.comparison.Messages.GUI_COMPARE_CHANGED_0; style = OpenCmsTheme.DIFF_TYPE_CHANGED; } else { key = org.opencms.workplace.comparison.Messages.GUI_COMPARE_UNCHANGED_0; style = OpenCmsTheme.DIFF_TYPE_UNCHANGED; } Button result = new Button(); result.setCaption(CmsVaadinUtils.getMessageText(key)); result.addStyleName(ValoTheme.BUTTON_LINK); result.addStyleName(style); m_getChangeTypeButton = result; }
From source file:org.openeos.erp.sales.ui.VaadinPrintDocumentUsertaskUI.java
License:Apache License
@SuppressWarnings("unchecked") @Override// w w w . j a v a2s.co m protected VerticalLayout createVaadinComponent(UserTask userTask, UIApplication<IUnoVaadinApplication> application) { EntityInfo info = extractEntity(userTask); String documentName = userTask.getMetaData(METADATA_PRINT_DOCUMENT_NAME); if (documentName == null || documentName.trim().length() == 0) { throw new IllegalArgumentException("The user task has not document meta data"); } System.out.print(info.classDefinition); final EntityDocument document = entityDocumentService .findDocument((Class<Object>) info.classDefinition.getClassDefined(), info.entity, documentName); if (document == null) { throw new RuntimeException("Document not found"); } final StreamSource streamSource = new StreamSource() { @Override public InputStream getStream() { try { return document.openInputStream(); } catch (IOException e) { throw new RuntimeException(e); } } }; final StreamResource resource = new StreamResource(streamSource, document.getName(), application.getConcreteApplication().getMainWindow().getApplication()); VerticalLayout layout = super.createVaadinComponent(userTask, application); Panel panel = createPanel("Documents"); panel.setWidth("100%"); Button buttonDocument = new Button(); buttonDocument.setStyleName(Reindeer.BUTTON_LINK); buttonDocument.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { event.getButton().getWindow().open(resource, document.getName()); } }); buttonDocument.setCaption(documentName); panel.addComponent(buttonDocument); layout.addComponent(panel); return layout; }
From source file:org.openeos.services.ui.vaadin.internal.DefaultVaadinERPWindowFactory.java
License:Apache License
protected Component createToolBarButton(final WindowAction action, final IWindow window) { final Button button = new Button(); button.setCaption(action.getCaption()); button.addListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override/*from ww w . j a va 2s . c om*/ public void buttonClick(ClickEvent event) { action.run(window); } }); button.setEnabled(action.isEnabledForWindow(window)); window.addSelectionChangeListener(new SelectionChangeListener() { @Override public void selectionChange(SelectionChangeEvent selectionChangeEvent) { button.setEnabled(action.isEnabledForWindow(window)); } }); window.addTabChangeListener(new TabChangeListener() { @Override public void tabChange(TabChangeEvent tabChangeEvent) { button.setEnabled(action.isEnabledForWindow(window)); } }); window.addViewChangeListener(new ViewChangeListener() { @Override public void viewChange(ViewChangeEvent viewChangeEvent) { button.setEnabled(action.isEnabledForWindow(window)); } }); return button; }
From source file:org.opennms.features.jmxconfiggenerator.webui.ui.UIHelper.java
License:Open Source License
public static Button createButton(final String buttonCaption, final String iconName, final ClickListener clickListener) { Button button = new Button(); button.setCaption(buttonCaption); button.setIcon(IconProvider.getIcon(iconName)); if (clickListener != null) button.addListener(clickListener); return button; }
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// www. 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; }