List of usage examples for com.vaadin.ui TextArea TextArea
public TextArea()
From source file:de.fatalix.timeline.web.root.block.TimelineEventLayout.java
public TimelineEventLayout() { headline = new TextField(); headline.setInputPrompt("Your event headline..."); headline.setColumns(31);//from w w w . j ava2s . c om headline.setNullRepresentation(""); text = new TextArea(); text.setInputPrompt("Your event description..."); text.setColumns(31); text.setRows(10); text.setNullRepresentation(""); startDate = new DateField(null, new Date()); startDate.setDateFormat("dd-MM-yyyy"); startDate.setResolution(Resolution.DAY); startDate.setDescription("Set the start date of an event."); endDate = new DateField(); endDate.setDateFormat("dd-MM-yyyy"); endDate.setResolution(Resolution.DAY); endDate.setDescription("Set the end date of an event. Optional!"); deleteButton = new VerticalLayout(); deleteButton.setWidth(16, Unit.PIXELS); deleteButton.setHeight(16, Unit.PIXELS); deleteButton.addStyleName("delete"); deleteButton.setDescription("Click to remove this event"); deleteButton.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { for (EventDeleteListener listener : listeners) { listener.deleteEvent(TimelineEventLayout.this); } } }); HorizontalLayout dateLayout = new HorizontalLayout(); dateLayout.setWidth(100, Unit.PERCENTAGE); dateLayout.addComponents(startDate, endDate, deleteButton); dateLayout.setComponentAlignment(deleteButton, Alignment.MIDDLE_RIGHT); this.setMargin(true); this.setSpacing(true); this.addComponent(headline); this.addComponent(text); this.addComponent(dateLayout); }
From source file:de.mendelson.comm.as2.webclient2.TransactionDetailsDialog.java
private TextArea createLogTab() { DateFormat format = SimpleDateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); TextArea textArea = new TextArea(); textArea.setRows(7);//from ww w . j a v a2s. co m textArea.setSizeFull(); List<LogEntry> entries = this.logAccess.getLog(this.messageId); StringBuilder log = new StringBuilder(); for (LogEntry entry : entries) { log.append("[").append(format.format(entry.getMillis())).append("] "); log.append(entry.getMessage()); log.append("\n"); } textArea.setValue(log.toString()); textArea.setReadOnly(true); return (textArea); }
From source file:de.metas.ui.web.vaadin.window.components.FieldEditorFactory.java
License:Open Source License
public Field<?> createEditor(final DataFieldPropertyDescriptor descriptor) { final int displayType = descriptor.getDisplayType(); final int adReferenceId = descriptor.getAD_Reference_Value_ID(); String caption = descriptor.getCaption(); final Field<?> field; if (displayType == DisplayType.List || displayType == DisplayType.Button && adReferenceId > 0) { field = createField_ComboBox(descriptor); } else if (displayType == DisplayType.TableDir || displayType == DisplayType.Table) { field = createField_ComboBox(descriptor); } else if (displayType == DisplayType.Search) { field = createField_LazyComboBox(descriptor); } else if (descriptor.isLongTextField()) { final TextArea textArefield = new TextArea(); field = textArefield;/* ww w.ja va2 s. c o m*/ } else if (DisplayType.isText(displayType)) { final TextField textField = new TextField(); field = textField; } else if (DisplayType.isDate(displayType)) { final DateField dateField = new DateField(); field = dateField; } else if (DisplayType.isNumeric(displayType)) { final TextField textField = new TextField(); field = textField; } else if (DisplayType.YesNo == displayType) { final CheckBox checkbox = new CheckBox(); if (gridMode) { caption = ""; } field = checkbox; } else { // final Class<?> type = DisplayType.getClass(displayType, true); // field = defaultFieldFactory.createField(type, Field.class); field = null; } if (field == null) { return null; } field.setCaption(caption); return field; }
From source file:de.metas.ui.web.vaadin.window.editor.LocationEditor.java
License:Open Source License
public LocationEditor(ViewPropertyDescriptor descriptor) { super(descriptor); this.valueField = new TextArea(); valueField.setSizeFull();//from ww w. java 2 s . c o m valueField.setReadOnly(true); valueField.addContextClickListener(event -> showPopup()); setCompositionRoot(valueField); }
From source file:de.metas.ui.web.vaadin.window.editor.TextEditor.java
License:Open Source License
@Override protected AbstractField<String> createValueField() { final AbstractTextField valueField; final ViewPropertyDescriptor descriptor = getPropertyDescriptor(); final PropertyDescriptorValueType valueType = descriptor == null ? PropertyDescriptorValueType.Text : descriptor.getValueType(); if (valueType == PropertyDescriptorValueType.TextLong) { valueField = new TextArea(); } else {/*from www . j av a2 s .co m*/ valueField = new TextField(); } valueField.setNullRepresentation(""); return valueField; }
From source file:de.unioninvestment.eai.portal.portlet.crud.datatypes.AbstractDataType.java
License:Apache License
@Override public Field<?> createField(Class<?> type, Object propertyId, boolean multiline, String inputPrompt, Format format) {/* w w w. j a v a 2s . co m*/ AbstractTextField textField; if (multiline) { TextArea textArea = new TextArea(); textArea.setRows(1); textField = textArea; } else { textField = new TextField(); } textField.setConverter(createFormatter(type, format)); textField.setReadOnly(isReadonly()); textField.setNullRepresentation(""); textField.setNullSettingAllowed(true); if (inputPrompt != null) { textField.setInputPrompt(inputPrompt); } return textField; }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultRowEditingFormView.java
License:Apache License
@Override public void addClobField(TableColumn tableColumn, boolean readOnly) { String columnName = tableColumn.getName(); TextArea area = new TextArea(); if (tableColumn.getTitle() != null) { area.setCaption(tableColumn.getTitle()); } else {// ww w . ja v a2 s. co m area.setCaption(columnName); } if (tableColumn.getWidth() != null) { area.setWidth(tableColumn.getWidth(), Unit.PIXELS); } if (tableColumn.getRows() != null) { area.setRows(tableColumn.getRows()); } area.setNullRepresentation(""); area.setReadOnly(readOnly || !tableColumn.getDefaultEditable()); area.setWidth(100.0f, Unit.PERCENTAGE); // see https://dev.vaadin.com/ticket/11753 boolean initiallyReadonly = area.isReadOnly(); if (initiallyReadonly) { area.setPropertyDataSource(binder.getItemDataSource().getItemProperty(columnName)); } else { // only bind if not readonly, so that readonly fields are not part // of the commit() binder.bind(area, columnName); } addFieldToLayout(area); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.MultiscaleComponent.java
License:Open Source License
void buildEmptyComments() { // add comments VerticalLayout addComment = new VerticalLayout(); addComment.setMargin(true);/*from w w w . ja va 2 s .co m*/ addComment.setWidth(100, Unit.PERCENTAGE); final TextArea comments = new TextArea(); comments.setInputPrompt("Write your comment here..."); comments.setWidth(100, Unit.PERCENTAGE); comments.setRows(2); Button commentsOk = new Button("Add Comment"); commentsOk.addStyleName(ValoTheme.BUTTON_FRIENDLY); commentsOk.addClickListener(new ClickListener() { /** * */ private static final long serialVersionUID = -5369241494545155677L; public void buttonClick(ClickEvent event) { if ("".equals(comments.getValue())) return; String newComment = comments.getValue(); // reset comments comments.setValue(""); // use some date format Date dNow = new Date(); SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); Note note = new Note(); note.setComment(newComment); note.setUsername(controller.getUser()); note.setTime(ft.format(dNow)); // show it now // pastcomments.getContainerDataSource().addItem(note); notes.add(note); // TODO write back Label commentsLabel = new Label(translateComments(notes), ContentMode.HTML); commentsPanel.setContent(commentsLabel); // write back to openbis if (!controller.addNote(note)) { Notification.show("Could not add comment to sample. How did you do that?"); } } }); HorizontalLayout inputPrompt = new HorizontalLayout(); inputPrompt.addComponent(comments); inputPrompt.addComponent(commentsOk); inputPrompt.setWidth(50, Unit.PERCENTAGE); inputPrompt.setComponentAlignment(commentsOk, Alignment.TOP_RIGHT); inputPrompt.setExpandRatio(comments, 1.0f); // addComment.addComponent(comments); // addComment.addComponent(commentsOk); addComment.addComponent(commentsPanel); addComment.addComponent(inputPrompt); // addComment.setComponentAlignment(comments, Alignment.TOP_CENTER); // addComment.setComponentAlignment(commentsOk, Alignment.MIDDLE_CENTER); addComment.setComponentAlignment(commentsPanel, Alignment.TOP_CENTER); addComment.setComponentAlignment(inputPrompt, Alignment.MIDDLE_CENTER); mainlayout.addComponent(addComment); // mainlayout.addComponent(pastcomments); Label commentsLabel = new Label("No comments added so far.", ContentMode.HTML); commentsPanel.setContent(commentsLabel); // mainlayout.addComponent(commentsPanel); // mainlayout.setComponentAlignment(commentsPanel, // Alignment.TOP_CENTER); }
From source file:edu.kit.dama.ui.commons.util.UIUtils7.java
License:Apache License
/** * Create a text area with the provided properties. The size is set to * SizeFull and the text area is set to 'immediate' (show changed immediately * to the user).//w w w . j a v a2 s. c om * * @param pCaption The caption * @param pInputPrompt The input prompt shown if no value is set * @param pMinLength The min. string length of the text area. The content can * be checked during validation. * @param pMaxLength The max. string length of the text area. The content can * be checked during validation. * * @return The text area */ public static TextArea factoryTextArea(String pCaption, String pInputPrompt, int pMinLength, int pMaxLength) { TextArea theArea = new TextArea(); theArea.setCaption(pCaption); theArea.setImmediate(true); theArea.setSizeFull(); theArea.setInputPrompt(pInputPrompt); theArea.setNullSettingAllowed(false); theArea.setNullRepresentation(""); StringLengthValidator val; if (pMinLength > 0) { val = new StringLengthValidator("The content length of this text area must be between " + pMinLength + " and " + pMaxLength + " characters."); val.setMinLength(pMinLength); } else { val = new StringLengthValidator( "The maximum content length of this text area is " + pMaxLength + " characters."); } val.setMaxLength(pMaxLength); theArea.addValidator(val); return theArea; }
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
private void _postGameEvent(String title, final GameEvent.EventType typ, String buttName, boolean doWarning, MenuBar mbar) {/*from ww w .j a v a2s . c o m*/ // Create the window... final Window bcastWindow = new Window(title); bcastWindow.setModal(true); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("99%"); bcastWindow.setContent(layout); layout.addComponent(new Label("Compose message (255 char limit):")); final TextArea ta = new TextArea(); ta.setRows(5); ta.setWidth("99%"); layout.addComponent(ta); HorizontalLayout buttHl = new HorizontalLayout(); final Button bcancelButt = new Button("Cancel"); buttHl.addComponent(bcancelButt); Button bokButt = new Button(buttName); bokButt.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); buttHl.addComponent(bokButt); layout.addComponent(buttHl); layout.setComponentAlignment(buttHl, Alignment.TOP_RIGHT); if (doWarning) layout.addComponent(new Label("Use with great deliberation!")); bcastWindow.setWidth("320px"); UI.getCurrent().addWindow(bcastWindow); bcastWindow.setPositionX(0); bcastWindow.setPositionY(0); ta.focus(); @SuppressWarnings("serial") ClickListener lis = new ClickListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void buttonClick(ClickEvent event) { if (event.getButton() == bcancelButt) ; // nothin else { // This check is now done in GameEvent.java, but should ideally prompt the user. String msg = ta.getValue().toString().trim(); if (msg.length() > 0) { HSess.init(); if (msg.length() > 255) // clamp to 255 to avoid db exception msg = msg.substring(0, 254); User u = Mmowgli2UI.getGlobals().getUserTL(); if (typ == GameEvent.EventType.GAMEMASTERNOTE) GameEventLogger.logGameMasterCommentTL(msg, u); else GameEventLogger.logGameMasterBroadcastTL(typ, msg, u); HSess.close(); } } bcastWindow.close(); } }; bcancelButt.addClickListener(lis); bokButt.addClickListener(lis); }