List of usage examples for com.vaadin.ui TextArea setRows
public void setRows(int rows)
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. *///www .j a v a2 s .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. *///from www . ja v a2 s.c om 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.events.EventFormFieldFactory.java
License:Open Source License
public Field createField(Item item, Object propertyId, Component uiContext) { if ("logMsgDest".equals(propertyId)) { final ComboBox dest = new ComboBox("Destination"); dest.addItem("logndisplay"); dest.addItem("logonly"); dest.addItem("suppress"); dest.addItem("donotpersist"); dest.addItem("discardtraps"); dest.setNullSelectionAllowed(false); dest.setRequired(true);//ww w .j a va 2 s . com return dest; } if ("logMsgContent".equals(propertyId)) { final TextArea content = new TextArea("Log Message"); content.setWidth("100%"); content.setRows(10); content.setRequired(true); content.setNullRepresentation(""); return content; } if ("alarmDataAlarmType".equals(propertyId)) { final ComboBox f = new ComboBox("Alarm Type"); f.addItem(new Integer(1)); f.addItem(new Integer(2)); f.addItem(new Integer(3)); f.setNewItemHandler(new NewItemHandler() { @Override public void addNewItem(String newItemCaption) { try { f.addItem(new Integer(newItemCaption)); } catch (Exception e) { } } }); f.setDescription( "<b>1</b> to be a problem that has a possible resolution, alarm-type set to <b>2</b> to be a resolution event, and alarm-type set to <b>3</b> for events that have no possible resolution"); f.setNullSelectionAllowed(false); return f; } if ("alarmDataAutoClean".equals(propertyId)) { final CheckBox f = new CheckBox("Auto Clean"); f.setWidth("100%"); return f; } if ("alarmDataReductionKey".equals(propertyId)) { final TextField f = new TextField("Reduction Key"); f.setWidth("100%"); f.setNullRepresentation(""); return f; } if ("alarmDataClearKey".equals(propertyId)) { final TextField f = new TextField("Clear Key"); f.setWidth("100%"); f.setNullRepresentation(""); return f; } if ("severity".equals(propertyId)) { final ComboBox severity = new ComboBox("Severity"); for (String sev : OnmsSeverity.names()) { severity.addItem(sev.substring(0, 1).toUpperCase() + sev.substring(1).toLowerCase()); } severity.setNullSelectionAllowed(false); severity.setRequired(true); return severity; } if ("descr".equals(propertyId)) { final TextArea descr = new TextArea("Description"); descr.setWidth("100%"); descr.setRows(10); descr.setRequired(true); descr.setNullRepresentation(""); return descr; } if ("operinstruct".equals(propertyId)) { final TextArea oper = new TextArea("Operator Instructions") { @Override public Object getValue() { // This is because of the intern usage on Event.setOperInstruct() return super.getValue() == null ? "" : super.getValue(); } }; oper.setWidth("100%"); oper.setRows(10); oper.setNullRepresentation(""); return oper; } if ("maskElements".equals(propertyId)) { final MaskElementField field = new MaskElementField(); field.setCaption("Mask Elements"); return field; } if ("maskVarbinds".equals(propertyId)) { final MaskVarbindField field = new MaskVarbindField(); field.setCaption("Mask Varbinds"); return field; } if ("varbindsdecodeCollection".equals(propertyId)) { final VarbindsDecodeField field = new VarbindsDecodeField(); field.setCaption("Varbind Decodes"); return field; } if ("uei".equals(propertyId)) { final TextField f = new TextField("Event UEI"); f.setRequired(true); f.setWidth("100%"); return f; } if ("eventLabel".equals(propertyId)) { final TextField f = new TextField("Event Label"); f.setRequired(true); f.setWidth("100%"); return f; } final Field f = DefaultFieldFactory.get().createField(item, propertyId, uiContext); f.setWidth("100%"); return f; }
From source file:org.ripla.web.demo.widgets.views.InputWidgetsView.java
License:Open Source License
public InputWidgetsView() { super();/* w w w . j a v a 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.addons.javaee.fields.factory.TextFieldCreator.java
License:Apache License
@Override protected void initializeField(FIELD field) { field.setNullRepresentation(""); Size size = container.getAnnotation(fieldSpec.getName(), Size.class); if (size != null && size.max() < Integer.MAX_VALUE) { int maxSize = Math.min(size.max(), MAX_SIZE); field.setWidth(maxSize, Unit.EM); }// ww w .j a va 2 s .c om if (field instanceof TextArea) { TextArea textArea = (TextArea) field; if (fieldSpec.getRows() > 1) { textArea.setRows(fieldSpec.getRows()); } else { textArea.setRows(2); } } }
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 ww. java 2 s . c o m 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.tori.view.thread.ReportComponent.java
License:Apache License
private static TextArea createReasonTextArea() { final TextArea area = new TextArea(); area.setWidth("100%"); area.setRows(4); return area;/* w ww . ja v a 2 s . c o m*/ }
From source file:pt.ist.vaadinframework.data.hints.TextSize.java
License:Open Source License
@Override public Field applyHint(Field field) { if (field instanceof TextArea) { TextArea area = (TextArea) field; if (rows > 1) { area.setRows(rows); } else {/*from ww w .j a v a2 s. c o m*/ TextField newField = new TextField(); newField.setCaption(area.getCaption()); newField.setDescription(area.getDescription()); newField.setImmediate(area.isImmediate()); newField.setInvalidAllowed(area.isInvalidAllowed()); newField.setInvalidCommitted(area.isInvalidCommitted()); newField.setNullRepresentation(area.getNullRepresentation()); newField.setReadThrough(area.isReadThrough()); newField.setReadOnly(area.isReadOnly()); newField.setRequired(area.isRequired()); newField.setWidth(area.getWidth(), area.getWidthUnits()); return newField; } } return field; }
From source file:ru.codeinside.gses.activiti.ftarchive.JsonFFT.java
License:Mozilla Public License
@Override public Field createField(String taskId, String fieldId, String name, byte[] value, PropertyNode node, boolean archive) { TMP.remove();/*from w w w. ja v a 2 s . com*/ Field result; String stringValue = ""; try { if (value != null) { stringValue = new String(value, "UTF-8"); } } catch (UnsupportedEncodingException e) { Logger.getAnonymousLogger().info("can't decode model!"); } if (!node.isFieldWritable() || archive) { result = new ReadOnly(stringValue); } else { TextArea json = new TextArea(); // json.setColumns(10); json.setSizeFull(); json.setRows(50); json.setImmediate(true); String defaultValue = StringUtils.trimToEmpty(stringValue); FieldHelper.setTextBufferSink(taskId, fieldId, json, true, defaultValue); result = json; } FieldHelper.setCommonFieldProperty(result, node.isFieldWritable() && !archive, name, node.isFieldRequired()); return result; }
From source file:ru.codeinside.gses.activiti.ftarchive.MultilineFFT.java
License:Mozilla Public License
@Override public Field createField(String taskId, String fieldId, String name, String value, PropertyNode node, boolean archive) { TextArea textField = new TextArea(); String rows = node.getParams().get("rows"); String columns = node.getParams().get("columns"); textField.setRows(countOf(rows)); textField.setColumns(countOf(columns)); textField.setMaxLength(3995);// w ww . j a v a 2 s . com FieldHelper.setTextBufferSink(taskId, fieldId, textField, node.isFieldWritable() && !archive, StringUtils.trimToEmpty(value)); FieldHelper.setCommonFieldProperty(textField, node.isFieldWritable() && !archive, name, node.isFieldRequired()); return textField; }