List of usage examples for com.vaadin.ui TextArea TextArea
public TextArea()
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. *//* w w w. j av a 2s.c om*/ 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. *//* w ww.ja v a 2s . 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.opennms.features.vaadin.mibcompiler.FileEditorWindow.java
License:Open Source License
/** * Instantiates a new file editor window. * * @param file the file/*from w w w .jav a 2 s . c o m*/ * @param logger the logger * @param readOnly true, if you want to display a read only window. */ public FileEditorWindow(final File file, final Logger logger, boolean readOnly) { this.file = file; this.logger = logger; setCaption((readOnly ? "View" : "Edit") + " MIB"); addStyleName("dialog"); setModal(true); setClosable(false); setWidth("800px"); setHeight("540px"); editor = new TextArea(); editor.setPropertyDataSource(new TextFileProperty(file)); editor.setImmediate(false); editor.setSizeFull(); editor.setRows(30); editor.setReadOnly(readOnly); cancel = new Button(readOnly ? "Close" : "Cancel"); cancel.setImmediate(false); cancel.addClickListener(this); save = new Button("Save"); save.setImmediate(false); save.addClickListener(this); HorizontalLayout toolbar = new HorizontalLayout(); toolbar.addComponent(cancel); if (!readOnly) toolbar.addComponent(save); VerticalLayout layout = new VerticalLayout(); layout.addComponent(editor); layout.addComponent(toolbar); layout.setExpandRatio(editor, 1.0f); layout.setComponentAlignment(toolbar, Alignment.BOTTOM_RIGHT); setContent(layout); }
From source file:org.ripla.web.demo.widgets.views.InputWidgetsView.java
License:Open Source License
public InputWidgetsView() { super();// ww w . j a va 2 s.c o m final IMessages lMessages = Activator.getMessages(); final VerticalLayout lLayout = initLayout(lMessages, "widgets.title.page.input"); //$NON-NLS-1$ final HorizontalLayout lColumns = new HorizontalLayout(); lColumns.setSpacing(true); lLayout.addComponent(lColumns); final VerticalLayout lCol1 = new VerticalLayout(); lCol1.setSizeUndefined(); lColumns.addComponent(lCol1); final VerticalLayout lCol2 = new VerticalLayout(); lCol2.setSizeUndefined(); lColumns.addComponent(lCol2); final VerticalLayout lCol3 = new VerticalLayout(); lCol3.setSizeUndefined(); lColumns.addComponent(lCol3); lColumns.setExpandRatio(lCol3, 1); // classic input fields lCol1.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.input.normal"))); //$NON-NLS-1$ final TextField lTextField = new TextField(); lTextField.setColumns(WIDTH_FIELD); lCol1.addComponent(lTextField); lCol1.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.input.prompt"))); //$NON-NLS-1$ final TextField lTextField2 = new TextField(); lTextField2.setInputPrompt(lMessages.getMessage("widgets.input.input.prompt")); //$NON-NLS-1$ lTextField2.setColumns(WIDTH_FIELD); lCol1.addComponent(lTextField2); lCol1.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.input.password"))); //$NON-NLS-1$ final PasswordField lPassword = new PasswordField(); lPassword.setColumns(WIDTH_FIELD); lCol1.addComponent(lPassword); lCol1.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.date"))); //$NON-NLS-1$ final PopupDateField lDate1 = new PopupDateField(lMessages.getMessage("widgets.input.popup.date")); //$NON-NLS-1$ lDate1.setResolution(Resolution.DAY); lDate1.setDateFormat("dd. MMMM yyyy"); //$NON-NLS-1$ lDate1.setWidth(160, Unit.PIXELS); lDate1.setValue(new java.util.Date()); lCol1.addComponent(lDate1); // text areas lCol2.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.text.area"))); //$NON-NLS-1$ final TextArea lArea = new TextArea(); lArea.setColumns(WIDTH_AREA); lArea.setRows(7); lCol2.addComponent(lArea); lCol2.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.rich.text"))); //$NON-NLS-1$ final RichTextArea lRichText = new RichTextArea(); lRichText.setWidth(WIDTH_AREA, Unit.EM); lRichText.setHeight(15, Unit.EM); lCol2.addComponent(lRichText); // text input with filter final CountryContainer lCountries = new CountryContainer(); lCol3.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.input.filter"))); //$NON-NLS-1$ final TextField lFilter = new TextField(); lFilter.setTextChangeEventMode(TextChangeEventMode.LAZY); lFilter.setTextChangeTimeout(200); lFilter.addTextChangeListener(new FieldEvents.TextChangeListener() { @Override public void textChange(final TextChangeEvent inEvent) { lCountries.removeAllContainerFilters(); lCountries.addContainerFilter( new SimpleStringFilter(CountryContainer.PROPERTY_NAME, inEvent.getText(), true, true)); } }); lFilter.setWidth(FILTER_WIDTH, Unit.PIXELS); final Table lTable = new Table(null, lCountries); lTable.setColumnHeaderMode(ColumnHeaderMode.HIDDEN); lTable.setWidth(FILTER_WIDTH, Unit.PIXELS); lTable.setPageLength(18); lCol3.addComponent(lFilter); lCol3.addComponent(lTable); }
From source file:org.vaadin.addon.borderlayout.BorderlayoutUI.java
private Component getSimpleExamle() { VerticalLayout vlo = new VerticalLayout(); vlo.setHeight("100%"); vlo.setWidth("100%"); vlo.setSpacing(true);// w ww . j a v a2 s.c om vlo.addComponent(getTestButtons()); for (int i = 0; i < components.length; i++) { components[i] = new TextArea(); ((TextArea) components[i]).setValue(texts[i]); components[i].setSizeFull(); } bl = new BorderLayout(); vlo.addComponent(bl); vlo.setExpandRatio(bl, 1); bl.addComponent(components[0], BorderLayout.Constraint.NORTH); bl.addComponent(components[1], BorderLayout.Constraint.SOUTH); bl.addComponent(components[2], BorderLayout.Constraint.CENTER); bl.addComponent(components[3], BorderLayout.Constraint.EAST); bl.addComponent(components[4], BorderLayout.Constraint.WEST); return vlo; }
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 v a2 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:org.vaadin.artur.declarative.DeclarativeEditor.java
License:Apache License
@Override protected void init(VaadinRequest request) { main = new HorizontalSplitPanel(); editor = new TextArea(); editor.setSizeFull();//from w w w.j a v a 2 s. co m getPage().addUriFragmentChangedListener(new UriFragmentChangedListener() { @Override public void uriFragmentChanged(UriFragmentChangedEvent event) { loadFile(getPage().getUriFragment()); editorChanged(editor.getValue()); } }); loadFile(getPage().getUriFragment()); editor.addTextChangeListener(new TextChangeListener() { @Override public void textChange(TextChangeEvent event) { editorChanged(event.getText()); } }); Panel editorPanel = new Panel(editor); editorPanel.setSizeFull(); treeHolder = new VerticalLayout(); treeHolder.setSizeFull(); main.addComponents(editorPanel, treeHolder); main.setSizeFull(); setContent(main); updateTree(editor.getValue()); }
From source file:org.vaadin.tori.component.AuthoringComponent.java
License:Apache License
private AbstractField<String> buildEditor() { AbstractField<String> result = null; if (Page.getCurrent().getWebBrowser().isAndroid()) { result = new TextArea(); } else {//from w w w. j ava 2 s . c o m result = new BBCodeWysiwygEditor(true, true); result.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { if (!ignoreInputChanges) { listener.inputValueChanged(editor.getValue()); } } }); ((BBCodeWysiwygEditor) result).addBlurListener(new BlurListener() { @Override public void blur(final BlurEvent event) { UI.getCurrent().setPollInterval(ToriUI.DEFAULT_POLL_INTERVAL); } }); ((BBCodeWysiwygEditor) result).addFocusListener(new FocusListener() { @Override public void focus(final FocusEvent event) { UI.getCurrent().setPollInterval(3000); } }); } result.setSizeFull(); return result; }
From source file:org.vaadin.tori.view.listing.category.EditCategoryForm.java
License:Apache License
public EditCategoryForm(final EditCategoryListener listener, final CategoryData categoryToEdit) { this.categoryToEdit = categoryToEdit; setData(categoryToEdit);/* w w w. j a va2s.c o m*/ final VerticalLayout newCategoryLayout = new VerticalLayout(); newCategoryLayout.setSpacing(true); newCategoryLayout.setMargin(true); newCategoryLayout.setWidth("100%"); nameField = new TextField(); nameField.setInputPrompt("Category name"); nameField.setWidth("100%"); if (categoryToEdit != null) { nameField.setValue(categoryToEdit.getName()); } newCategoryLayout.addComponent(nameField); descriptionField = new TextArea(); descriptionField.setInputPrompt("Description"); descriptionField.setRows(3); descriptionField.setWidth("100%"); if (categoryToEdit != null) { descriptionField.setValue(categoryToEdit.getDescription()); } newCategoryLayout.addComponent(descriptionField); final Button saveButton = new Button((categoryToEdit == null ? "Create Category" : "Save"), new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { listener.commit(nameField.getValue(), descriptionField.getValue()); resetForm(); } }); final Button cancelButton = ComponentUtil.getSecondaryButton(("Cancel"), new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { listener.cancel(); resetForm(); } }); HorizontalLayout buttonsLayout = new HorizontalLayout(cancelButton, saveButton); buttonsLayout.setWidth(100.0f, Unit.PERCENTAGE); buttonsLayout.setSpacing(true); buttonsLayout.setExpandRatio(cancelButton, 1.0f); buttonsLayout.setComponentAlignment(cancelButton, Alignment.BOTTOM_RIGHT); newCategoryLayout.addComponent(buttonsLayout); setWidth("300px"); setCompositionRoot(newCategoryLayout); }
From source file:org.vaadin.tori.view.thread.PostEditor.java
License:Apache License
private AbstractField<String> buildEditor(final boolean bbcode) { if (Page.getCurrent().getWebBrowser().isAndroid()) { editor = new TextArea(); } else {// ww w. ja v a2 s . c om editor = new BBCodeWysiwygEditor(false, bbcode); } editor.setSizeFull(); return editor; }