List of usage examples for com.vaadin.ui TextArea setValue
@Override public void setValue(String value)
From source file:org.opennms.features.topology.app.internal.TopologyUI.java
License:Open Source License
@Override public void menuBarUpdated(CommandManager commandManager) { if (m_menuBar != null) { m_rootLayout.removeComponent(m_menuBar); }/*from ww w . j a va 2 s . co m*/ if (m_contextMenu != null) { m_contextMenu.detach(); } m_menuBar = commandManager.getMenuBar(m_graphContainer, this); m_menuBar.setWidth(100, Unit.PERCENTAGE); // Set expand ratio so that extra space is not allocated to this vertical component if (m_showHeader) { m_rootLayout.addComponent(m_menuBar, 1); } else { m_rootLayout.addComponent(m_menuBar, 0); } m_contextMenu = commandManager .getContextMenu(new DefaultOperationContext(this, m_graphContainer, DisplayLocation.CONTEXTMENU)); m_contextMenu.setAsContextMenuOf(this); // Add Menu Item to share the View with others m_menuBar.addItem("Share", FontAwesome.SHARE, new MenuBar.Command() { @Override public void menuSelected(MenuItem selectedItem) { // create the share link String fragment = getPage().getLocation().getFragment(); String url = getPage().getLocation().toString().replace("#" + getPage().getLocation().getFragment(), ""); String shareLink = String.format("%s?%s=%s", url, TopologyUIRequestHandler.PARAMETER_HISTORY_FRAGMENT, fragment); // Create the Window Window shareWindow = new Window(); shareWindow.setCaption("Share Link"); shareWindow.setModal(true); shareWindow.setClosable(true); shareWindow.setResizable(false); shareWindow.setWidth(400, Unit.PIXELS); TextArea shareLinkField = new TextArea(); shareLinkField.setValue(shareLink); shareLinkField.setReadOnly(true); shareLinkField.setRows(3); shareLinkField.setWidth(100, Unit.PERCENTAGE); // Close Button Button close = new Button("Close"); close.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); close.addClickListener(event -> shareWindow.close()); // Layout for Buttons HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(true); buttonLayout.setSpacing(true); buttonLayout.setWidth("100%"); buttonLayout.addComponent(close); buttonLayout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT); // Content Layout VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setMargin(true); verticalLayout.setSpacing(true); verticalLayout.addComponent( new Label("Please use the following link to share the current view with others.")); verticalLayout.addComponent(shareLinkField); verticalLayout.addComponent(buttonLayout); shareWindow.setContent(verticalLayout); getUI().addWindow(shareWindow); } }); updateMenuItems(); }
From source file:org.opennms.features.topology.app.internal.ui.ToolbarPanel.java
License:Open Source License
public ToolbarPanel(final ToolbarPanelController controller) { addStyleName(Styles.TOOLBAR);/* w w w .ja v a 2s .c om*/ this.layoutManager = controller.getLayoutManager(); final Property<Double> scale = controller.getScaleProperty(); final Boolean[] eyeClosed = new Boolean[] { false }; final Button showFocusVerticesBtn = new Button(); showFocusVerticesBtn.setIcon(FontAwesome.EYE); showFocusVerticesBtn.setDescription("Toggle Highlight Focus Nodes"); showFocusVerticesBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (eyeClosed[0]) { showFocusVerticesBtn.setIcon(FontAwesome.EYE); } else { showFocusVerticesBtn.setIcon(FontAwesome.EYE_SLASH); } eyeClosed[0] = !eyeClosed[0]; // toggle controller.toggleHighlightFocus(); } }); final Button magnifyBtn = new Button(); magnifyBtn.setIcon(FontAwesome.PLUS); magnifyBtn.setDescription("Magnify"); magnifyBtn.addClickListener( (Button.ClickListener) event -> scale.setValue(Math.min(1, scale.getValue() + 0.25))); final Button demagnifyBtn = new Button(); demagnifyBtn.setIcon(FontAwesome.MINUS); demagnifyBtn.setDescription("Demagnify"); demagnifyBtn.addClickListener( (Button.ClickListener) event -> scale.setValue(Math.max(0, scale.getValue() - 0.25))); m_szlOutBtn = new Button(); m_szlOutBtn.setId("szlOutBtn"); m_szlOutBtn.setIcon(FontAwesome.ANGLE_DOWN); m_szlOutBtn.setDescription("Decrease Semantic Zoom Level"); m_szlOutBtn.setEnabled(controller.getSemanticZoomLevel() > 0); m_szlOutBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { int szl = controller.getSemanticZoomLevel(); if (szl > 0) { setSemanticZoomLevel(controller, szl - 1); controller.saveHistory(); } } }); final Button szlInBtn = new Button(); szlInBtn.setId("szlInBtn"); szlInBtn.setIcon(FontAwesome.ANGLE_UP); szlInBtn.setDescription("Increase Semantic Zoom Level"); szlInBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { setSemanticZoomLevel(controller, controller.getSemanticZoomLevel() + 1); controller.saveHistory(); } }); m_zoomLevelLabel.setId("szlInputLabel"); m_panBtn = new Button(); m_panBtn.setIcon(FontAwesome.ARROWS); m_panBtn.setDescription("Pan Tool"); m_panBtn.addStyleName(Styles.SELECTED); m_selectBtn = new Button(); m_selectBtn.setIcon(IonicIcons.ANDROID_EXPAND); m_selectBtn.setDescription("Selection Tool"); m_selectBtn.setStyleName("toolbar-button"); m_selectBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { m_selectBtn.addStyleName(Styles.SELECTED); m_panBtn.removeStyleName(Styles.SELECTED); controller.setActiveTool(ActiveTool.select); } }); m_panBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { m_panBtn.addStyleName(Styles.SELECTED); m_selectBtn.removeStyleName(Styles.SELECTED); controller.setActiveTool(ActiveTool.pan); } }); Button showAllMapBtn = new Button(); showAllMapBtn.setId("showEntireMapBtn"); showAllMapBtn.setIcon(FontAwesome.GLOBE); showAllMapBtn.setDescription("Show Entire Map"); showAllMapBtn.addClickListener((Button.ClickListener) event -> controller.showAllMap()); Button centerSelectionBtn = new Button(); centerSelectionBtn.setIcon(FontAwesome.LOCATION_ARROW); centerSelectionBtn.setDescription("Center On Selection"); centerSelectionBtn.addClickListener((Button.ClickListener) event -> controller.centerMapOnSelection()); Button shareButton = new Button("", FontAwesome.SHARE_SQUARE_O); shareButton.setDescription("Share"); shareButton.addClickListener((x) -> { // Create the share link String fragment = getUI().getPage().getLocation().getFragment(); String url = getUI().getPage().getLocation().toString().replace("#" + fragment, ""); String shareLink = String.format("%s?%s=%s", url, PARAMETER_HISTORY_FRAGMENT, fragment); // Create the Window Window shareWindow = new Window(); shareWindow.setCaption("Share Link"); shareWindow.setModal(true); shareWindow.setClosable(true); shareWindow.setResizable(false); shareWindow.setWidth(400, Sizeable.Unit.PIXELS); TextArea shareLinkField = new TextArea(); shareLinkField.setValue(shareLink); shareLinkField.setReadOnly(true); shareLinkField.setRows(3); shareLinkField.setWidth(100, Sizeable.Unit.PERCENTAGE); // Close Button Button close = new Button("Close"); close.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); close.addClickListener(event -> shareWindow.close()); // Layout for Buttons HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(true); buttonLayout.setSpacing(true); buttonLayout.setWidth("100%"); buttonLayout.addComponent(close); buttonLayout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT); // Content Layout VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setMargin(true); verticalLayout.setSpacing(true); verticalLayout.addComponent( new Label("Please use the following link to share the current view with others.")); verticalLayout.addComponent(shareLinkField); verticalLayout.addComponent(buttonLayout); shareWindow.setContent(verticalLayout); getUI().addWindow(shareWindow); }); // Refresh Button Button refreshButton = new Button(); refreshButton.setId("refreshNow"); refreshButton.setIcon(FontAwesome.REFRESH); refreshButton.setDescription("Refresh Now"); refreshButton.addClickListener((event) -> controller.refreshUI()); // Layer Layout layerLayout = new VerticalLayout(); layerLayout.setId("layerComponent"); layerLayout.setSpacing(true); layerLayout.setMargin(true); // Layer Button layerButton = new Button(); layerButton.setId("layerToggleButton"); layerButton.setIcon(FontAwesome.BARS); layerButton.setDescription("Layers"); layerButton.addClickListener((event) -> { boolean isCollapsed = layerButton.getStyleName().contains(Styles.EXPANDED); setLayerLayoutVisible(!isCollapsed); }); // Save button layerSaveButton = new Button(); layerSaveButton.setId("saveLayerButton"); layerSaveButton.setIcon(FontAwesome.FLOPPY_O); layerSaveButton.addClickListener((event) -> controller.saveLayout()); // Actual Layout for the Toolbar CssLayout contentLayout = new CssLayout(); contentLayout.addStyleName("toolbar-component"); contentLayout.addComponent(createGroup(szlInBtn, m_zoomLevelLabel, m_szlOutBtn)); contentLayout.addComponent( createGroup(refreshButton, centerSelectionBtn, showAllMapBtn, layerButton, showFocusVerticesBtn)); contentLayout.addComponent(createGroup(m_panBtn, m_selectBtn)); contentLayout.addComponent(createGroup(magnifyBtn, demagnifyBtn)); contentLayout.addComponent(createGroup(shareButton)); contentLayout.addComponent(createGroup(layerSaveButton)); // Toolbar addComponent(contentLayout); }
From source file:org.opennms.features.topology.netutils.internal.ping.PingWindow.java
License:Open Source License
/** * Creates the PingWindow to make ping requests. * * @param locations All available locations to ping from. Must not be null. * @param defaultLocation The location to pre-select from the locations. Ensure <code>defaultLocation</code> is also available in the <code>locations</code> list. * @param ipAddresses All available ipAddresses. Must not be null or empty. * @param defaultIp The default ip to pre-select from the ip addresses. Ensure <code>defaultIp</code> is also available in the <code>ipAddresses</code> list. * @param pingClient The LocationAwarePingClient to ping. Must not be null. *///from ww w . ja va2s . c o m public PingWindow(LocationAwarePingClient pingClient, List<String> locations, List<InetAddress> ipAddresses, String defaultLocation, InetAddress defaultIp, String caption) { Objects.requireNonNull(pingClient); Objects.requireNonNull(ipAddresses); Objects.requireNonNull(defaultIp); Objects.requireNonNull(locations); Objects.requireNonNull(defaultLocation); Objects.requireNonNull(caption); // Remember initial poll interval, as we poll as soon as we start pinging final int initialPollInterval = UI.getCurrent().getPollInterval(); // Ping Form pingForm = new PingForm(locations, defaultLocation, ipAddresses, defaultIp); // Result final TextArea resultArea = new TextArea(); resultArea.setRows(15); resultArea.setSizeFull(); // Progress Indicator progressIndicator = new ProgressBar(); progressIndicator.setIndeterminate(true); // Buttons cancelButton = new Button("Cancel"); cancelButton.addClickListener((event) -> { cancel(pingFuture); resultArea.setValue(resultArea.getValue() + "\n" + "Ping cancelled by user"); getUI().setPollInterval(initialPollInterval); setRunning(false); }); pingButton = new Button("Ping"); pingButton.addClickListener((event) -> { try { final PingRequest pingRequest = pingForm.getPingRequest(); resultArea.setValue(""); // Clear setRunning(true); getUI().setPollInterval(POLL_INTERVAL); pingFuture = pingClient.ping(pingRequest.getInetAddress()).withRetries(pingRequest.getRetries()) .withPacketSize(pingRequest.getPacketSize()) .withTimeout(pingRequest.getTimeout(), TimeUnit.MILLISECONDS) .withLocation(pingRequest.getLocation()) .withNumberOfRequests(pingRequest.getNumberRequests()) .withProgressCallback((newSequence, summary) -> { getUI().accessSynchronously(() -> { if (pingFuture != null && !pingFuture.isCancelled()) { setRunning(!summary.isComplete()); resultArea.setValue(PingStringUtils.renderAll(summary)); if (summary.isComplete()) { getUI().setPollInterval(initialPollInterval); } } }); }).execute(); } catch (FieldGroup.CommitException e) { Notification.show("Validation errors", "Please correct them. Make sure all required fields are set.", Notification.Type.ERROR_MESSAGE); } }); // Button Layout final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.addComponent(pingButton); buttonLayout.addComponent(cancelButton); buttonLayout.addComponent(progressIndicator); // Root Layout final VerticalLayout rootLayout = new VerticalLayout(); rootLayout.setSpacing(true); rootLayout.setMargin(true); rootLayout.addComponent(pingForm); rootLayout.addComponent(buttonLayout); rootLayout.addComponent(new Label("<b>Results</b>", ContentMode.HTML)); rootLayout.addComponent(resultArea); rootLayout.setExpandRatio(resultArea, 1.0f); // Window Config setCaption(caption); setResizable(false); setModal(true); setWidth(800, Unit.PIXELS); setHeight(600, Unit.PIXELS); setContent(rootLayout); center(); setRunning(false); // Set back to default, when closing addCloseListener((CloseListener) e -> { cancel(pingFuture); getUI().setPollInterval(initialPollInterval); }); }
From source file:org.opennms.features.topology.netutils.internal.PingWindow.java
License:Open Source License
/** * Creates the PingWindow to make ping requests. * * @param vertex The vertex which IP Address is pinged. * It is expected that the IP Address os not null and parseable. * @param pingService The {@link PingService} to actually make the ping request. *//*from w ww. j av a2 s. c o m*/ public PingWindow(Vertex vertex, PingService pingService) { Objects.requireNonNull(vertex); Objects.requireNonNull(pingService); // Remember initial poll interval, as we poll as soon as we start pinging final int initialPollInterval = UI.getCurrent().getPollInterval(); // Ping Form pingForm = new PingForm(InetAddressUtils.getInetAddress(vertex.getIpAddress())); // Result final TextArea resultArea = new TextArea(); resultArea.setRows(15); resultArea.setSizeFull(); // Progress Indicator progressIndicator = new ProgressBar(); progressIndicator.setIndeterminate(true); // Buttons cancelButton = new Button("Cancel"); cancelButton.addClickListener((event) -> { pingService.cancel(); resultArea.setValue(resultArea.getValue() + "\n" + "Ping cancelled by user"); getUI().setPollInterval(initialPollInterval); setRunning(false); }); pingButton = new Button("Ping"); pingButton.addClickListener((event) -> { try { final PingRequest pingRequest = pingForm.getPingRequest(); setRunning(true); getUI().setPollInterval(POLL_INTERVAL); resultArea.setValue(""); // Clear pingService.ping(pingRequest, (result) -> { setRunning(!result.isComplete()); resultArea.setValue(result.toDetailString()); if (result.isComplete()) { getUI().setPollInterval(initialPollInterval); } }); } catch (FieldGroup.CommitException e) { Notification.show("Validation errors", "Please correct them. Make sure all required fields are set.", Notification.Type.ERROR_MESSAGE); } }); // Button Layout final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.addComponent(pingButton); buttonLayout.addComponent(cancelButton); buttonLayout.addComponent(progressIndicator); // Root Layout final VerticalLayout rootLayout = new VerticalLayout(); rootLayout.setSpacing(true); rootLayout.setMargin(true); rootLayout.addComponent(pingForm); rootLayout.addComponent(buttonLayout); rootLayout.addComponent(new Label("<b>Results</b>", ContentMode.HTML)); rootLayout.addComponent(resultArea); rootLayout.setExpandRatio(resultArea, 1.0f); // Window Config setCaption(String.format("Ping - %s (%s)", vertex.getLabel(), vertex.getIpAddress())); setResizable(false); setModal(true); setWidth(800, Unit.PIXELS); setHeight(550, Unit.PIXELS); setContent(rootLayout); center(); setRunning(false); // Set back to default, when closing addCloseListener((CloseListener) e -> { pingService.cancel(); getUI().setPollInterval(initialPollInterval); }); }
From source file:org.vaadin.addons.serverpush.samples.chat.ChatLayout.java
License:Apache License
public ChatLayout(final User user, final User from) { setSizeFull();/*from w w w. j a va 2 s . c om*/ Table table = new Table(); table.setSizeFull(); table.setContainerDataSource(new MessageContainer(user, from)); table.addListener(new Container.ItemSetChangeListener() { public void containerItemSetChange(Container.ItemSetChangeEvent event) { ((Pushable) getApplication()).push(); } }); table.setVisibleColumns(new String[] { "from", "to", "received", "message" }); addComponent(table); HorizontalLayout hl = new HorizontalLayout(); hl.setWidth("100%"); final TextArea textArea = new TextArea(); textArea.setRows(5); textArea.setSizeFull(); textArea.setWordwrap(true); textArea.setValue(""); hl.addComponent(textArea); Button sendButton = new Button("Send"); sendButton.setWidth("120px"); sendButton.setImmediate(true); sendButton.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { Message msg = new Message(); msg.setFrom(from); msg.setTo(user); msg.setMessage(textArea.getValue().toString()); MessageManager.getInstance().addMessage(msg); textArea.setValue(""); } }); hl.addComponent(sendButton); hl.setComponentAlignment(sendButton, Alignment.BOTTOM_RIGHT); hl.setExpandRatio(textArea, 1); addComponent(hl); setExpandRatio(table, 1); }
From source file:rs.pupin.jpo.validation.gui.constraints.FailedQueryWindow.java
@Override public void attach() { super.attach(); String message = (query2 == null) ? messageSingleQuery : messageDoubleQuery; Label lbl = new Label(message); lbl.setWidth("95%"); layout.addComponent(lbl);/*w w w . ja v a2 s .c om*/ layout.setExpandRatio(lbl, 0.0f); String textAreaCaption = (query2 != null) ? "First Query" : "Query"; TextArea textArea = new TextArea(textAreaCaption); textArea.setValue(query1); textArea.setReadOnly(true); textArea.setSizeFull(); layout.addComponent(textArea); layout.setExpandRatio(textArea, 2.0f); if (query2 != null) { TextArea textArea2 = new TextArea("Second Query"); textArea2.setValue(query2); textArea2.setReadOnly(true); textArea2.setSizeFull(); layout.addComponent(textArea2); layout.setExpandRatio(textArea2, 2.0f); } center(); }
From source file:ru.codeinside.gses.activiti.ReadOnly.java
License:Mozilla Public License
public ReadOnly(String labelValue, String value, boolean valid) { this.valid = valid; if (value == null || value.length() < 4000) { setSizeFull();/*w ww . jav a 2s .c om*/ Label label = new Label(labelValue); label.setSizeFull(); label.setStyleName("left"); HorizontalLayout layout = new HorizontalLayout(); // GridLayout layout.setSizeFull(); layout.addComponent(label); layout.setExpandRatio(label, 1f); setCompositionRoot(layout); } else { setSizeFull(); TextArea area = new TextArea(); area.setValue(value); area.setReadOnly(true); area.setSizeFull(); area.setRows(25); setCompositionRoot(area); } if (valid) { setValue(value); } }
From source file:ru.codeinside.gses.webui.form.JsonForm.java
License:Mozilla Public License
@Override public Field getField(Object propertyId) { if (valueId.equals(propertyId)) { TextArea field = new TextArea(); field.setNullRepresentation(""); field.setValue(formField.getValue()); return field; }/* ww w .jav a2s . c om*/ if (API.JSON_FORM.equals(propertyId)) { ReadOnly field = new ReadOnly(templateRef); field.setCaption(""); return field; } return null; }
From source file:views.MetadataUploadView.java
License:Open Source License
private void showStatus() { boolean ready = true; for (Object colName : getActiveTable().getContainerPropertyIds()) { String selected = getSelectedProperty(colName); ready &= selected != null && !selected.isEmpty(); }/*from ww w . j a v a2 s. c om*/ if (ready) { fillCollisionsList(); if (collisions.size() > 0) { Window subWindow = new Window(" Collisions found!"); subWindow.setWidth("400px"); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); Label preInfo = new Label("The following entries exist and would need to be overwritten:"); layout.addComponent(preInfo); TextArea tf = new TextArea(); tf.setWidth("350px"); tf.setValue(StringUtils.join(collisions, "")); tf.setStyleName(Styles.areaTheme); layout.addComponent(tf); String overwriteInfo = "In order to keep your data safe, you are not allowed to overwrite existing information by default. " + "You can either remove the columns in question (choose 'ignore column') or contact QBiC."; if (overWriteAllowed) overwriteInfo = "You can either remove the columns in question (choose 'ignore column') " + "before sending it to the Database or overwrite the metadata."; Label info = new Label(overwriteInfo); Button ok = new Button("Got it!"); ok.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { subWindow.close(); } }); layout.addComponent(info); layout.addComponent(ok); subWindow.setContent(layout); // Center it in the browser window subWindow.center(); subWindow.setModal(true); subWindow.setIcon(FontAwesome.BOLT); subWindow.setResizable(false); ProjectwizardUI ui = (ProjectwizardUI) UI.getCurrent(); ui.addWindow(subWindow); } else { Styles.notification("No collisions found!", "You can update the metadata in our database without overwriting something. To do so press 'Send to Database'", NotificationType.DEFAULT); } send.setEnabled(collisions.isEmpty() || overWriteAllowed); } else send.setEnabled(false); }