List of usage examples for com.vaadin.ui TextArea setRows
public void setRows(int rows)
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 {/* w w w . jav a 2s.c o 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.unioninvestment.eai.portal.portlet.crud.mvp.views.ui.DefaultCrudFieldFactory.java
License:Apache License
private void applyCommonFieldSettings(Field<?> field, Object propertyId, Target target) { setCaptionAndTooltipIfGiven(field, propertyId, target); field.setWidth(HUNDRED, Unit.PERCENTAGE); field.setBuffered(true);//from www . java 2 s . c o m passThroughConversionExceptionMessage(field); if (field instanceof TextArea) { TextArea area = (TextArea) field; if (isEditForm()) { area.setRows(getRows(propertyId)); } else { area.setHeight(getRows(propertyId), Unit.EM); } } }
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 v a2 s . c om*/ 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.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 w ww . j av a 2s . c om // 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); }
From source file:edu.nps.moves.mmowgli.MmowgliMessageBroadcaster.java
License:Open Source License
private static void _postGameEvent(String title, final GameEvent.EventType typ, String buttName, boolean doWarning) { // Create the window... final Window bcastWindow = new Window(title); bcastWindow.setModal(true);// w w w.j av a 2 s .c om VerticalLayout layout = new VerticalLayout(); bcastWindow.setContent(layout); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("99%"); 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); 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 @HibernateUserRead 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. HSess.init(); String msg = ta.getValue().toString().trim(); if (msg.length() > 0) { if (msg.length() > 255) // clamp to 255 to avoid db exception msg = msg.substring(0, 254); Serializable uid = Mmowgli2UI.getGlobals().getUserID(); User u = User.getTL(uid); if (typ == GameEvent.EventType.GAMEMASTERNOTE) GameEventLogger.logGameMasterCommentTL(msg, u); else GameEventLogger.logGameMasterBroadcastTL(typ, msg, u); // GameEvent.save(new GameEvent(typ,msg)); HSess.close(); } } bcastWindow.close(); } }; bcancelButt.addClickListener(lis); bokButt.addClickListener(lis); }
From source file:edu.nps.moves.mmowgli.modules.actionplans.HelpWantedDialog.java
License:Open Source License
@SuppressWarnings("serial") @HibernateSessionThreadLocalConstructor//ww w.ja v a2 s . c o m public HelpWantedDialog(final Object aplnId, boolean interested) { setCaption(interested ? "Express Interest in Action Plan" : "Offer Assistance with Action Plan"); setModal(true); setSizeUndefined(); setWidth("500px"); setHeight("550px"); VerticalLayout vLay = new VerticalLayout(); setContent(vLay); vLay.setMargin(true); vLay.setSpacing(true); vLay.setSizeFull(); StringBuilder sb = new StringBuilder(); ActionPlan ap = ActionPlan.getTL(aplnId); String s = ap.getHelpWanted(); if (s != null) { vLay.addComponent(new Label(msg1)); Label helpWantedLab = new Label(s); helpWantedLab.addStyleName("m-helpWantedLabel"); helpWantedLab.setWidth("100%"); vLay.addComponent(helpWantedLab); } vLay.addComponent(new Label(msg2)); final TextArea toTA = new TextArea("To"); toTA.addStyleName("m-textareaboldcaption"); toTA.setWidth("100%"); toTA.setRows(1); toTA.setNullRepresentation(""); toTA.setValue(getAuthors(sb, ap)); vLay.addComponent(toTA); final TextArea ccTA = new TextArea("CC"); ccTA.addStyleName("m-textareaboldcaption"); ccTA.setWidth("100%"); ccTA.setRows(1); ccTA.setNullRepresentation(""); PagesData pd = new PagesData(); ccTA.setValue(pd.gettroubleMailto()); vLay.addComponent(ccTA); final TextArea subjTA = new TextArea("Subject"); subjTA.addStyleName("m-textareaboldcaption"); subjTA.setWidth("100%"); subjTA.setRows(2); subjTA.setNullRepresentation(""); sb.setLength(0); sb.append("My interest in Action Plan "); sb.append(ap.getId()); sb.append(", \""); sb.append(ap.getTitle()); sb.append('"'); subjTA.setValue(sb.toString()); vLay.addComponent(subjTA); final TextArea msgTA = new TextArea("Message"); msgTA.addStyleName("m-textareaboldcaption"); msgTA.setWidth("100%"); msgTA.setHeight("100%"); msgTA.setNullRepresentation(""); vLay.addComponent(msgTA); vLay.setExpandRatio(msgTA, 1.0f); HorizontalLayout buttLay = new HorizontalLayout(); vLay.addComponent(buttLay); buttLay.setSpacing(true); buttLay.setWidth("100%"); Label sp; buttLay.addComponent(sp = new Label()); sp.setHeight("1px"); buttLay.setExpandRatio(sp, 1.0f); Button canButt = new Button("Cancel"); buttLay.addComponent(canButt); Button sendButt = new Button("Send to authors"); buttLay.addComponent(sendButt); canButt.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { UI.getCurrent().removeWindow(HelpWantedDialog.this); } }); sendButt.addClickListener(new ClickListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void buttonClick(ClickEvent event) { Object tos = toTA.getValue(); if (tos == null || tos.toString().length() <= 0) { Notification.show("No recipients", Notification.Type.ERROR_MESSAGE); return; } Object cc = ccTA.getValue(); if (cc == null || cc.toString().length() <= 0) cc = null; Object msg = msgTA.getValue(); if (msg == null || msg.toString().length() <= 0) { Notification.show("No Message", Notification.Type.ERROR_MESSAGE); return; } Object subj = subjTA.getValue(); if (subj == null) subj = ""; HSess.init(); List<User> authors = parseAuthorsTL(tos.toString().trim()); MmowgliSessionGlobals globs = Mmowgli2UI.getGlobals(); MailManager mmgr = AppMaster.instance().getMailManager(); User me = globs.getUserTL(); for (User u : authors) { mmgr.mailToUserTL(me.getId(), u.getId(), subj.toString(), msg.toString()); } if (cc == null) mmgr.mailToUserTL(me.getId(), me.getId(), "(CC:)" + subj.toString(), msg.toString()); else mmgr.mailToUserTL(me.getId(), me.getId(), subj.toString(), msg.toString(), cc.toString(), MailManager.Channel.BOTH); // the cc is an email, not a user name UI.getCurrent().removeWindow(HelpWantedDialog.this); Notification.show("Message(s) sent", Notification.Type.HUMANIZED_MESSAGE); // fixed 21 Jan 2015 HSess.close(); } }); }
From source file:edu.nps.moves.mmowgli.modules.administration.AbstractGameBuilderPanel.java
License:Open Source License
protected TextArea addEditLine(String name, String info) { TextArea ta = new TextArea(); ta.setRows(2); ta.setReadOnly(globals.readOnlyCheck(false)); lines.add(new EditLine(name, info, ta, null, null, null)); return ta;/* w w w. ja v a 2 s . c o m*/ }
From source file:edu.nps.moves.mmowgli.modules.administration.AbstractGameBuilderPanel.java
License:Open Source License
protected EditLine addEditLine(String name, String info, Object dbObj, Object dbObjId, String dbObjFieldName, MoveListener lis, Class<?> fieldClass, String tooltip) { TextArea ta = new TextArea(); ta.setRows(2); ta.setReadOnly(globals.readOnlyCheck(false)); EditLine edLine = getLineData(dbObj); edLine.name = name;/*from www . ja v a2 s . c o m*/ edLine.info = info; edLine.ta = ta; edLine.fieldName = dbObjFieldName; edLine.objId = dbObjId; edLine.listener = lis; edLine.fieldClass = fieldClass; edLine.setTooltip(tooltip); lines.add(edLine); populateEditLine(edLine); return edLine; }
From source file:edu.nps.moves.mmowgli.modules.administration.ActionPlansGameDesignPanel.java
License:Open Source License
@HibernateSessionThreadLocalConstructor public ActionPlansGameDesignPanel(GameDesignGlobals globs) { super(false, globs); Game game = Game.getTL(1L);/*from w ww.j av a 2s . com*/ String thePlanTxt = game.getDefaultActionPlanThePlanText(); String talkTxt = game.getDefaultActionPlanTalkText(); String imagesTxt = game.getDefaultActionPlanImagesText(); String videosTxt = game.getDefaultActionPlanVideosText(); String mapTxt = game.getDefaultActionPlanMapText(); TextArea ta; ta = (TextArea) addEditLine("1 \"The Plan\" Tab Instructions", "Game.defaultActionPlanThePlanText", game, game.getId(), "DefaultActionPlanThePlanText").ta; ta.setValue(thePlanTxt); ta.setRows(5); ta = (TextArea) addEditLine("2 \"Talk it Over\" Tab Instructions", "Game.defaultActionPlanTalkText", game, game.getId(), "DefaultActionPlanTalkText").ta; ta.setValue(talkTxt); ta.setRows(5); ta = (TextArea) addEditLine("3 Images Tab Instructions", "Game.defaultActionPlanImagesText", game, game.getId(), "DefaultActionPlanImagesText").ta; ta.setValue(imagesTxt); ta.setRows(5); ta = (TextArea) addEditLine("4 Videos Tab Instructions", "Game.defaultActionPlanVideosText", game, game.getId(), "DefaultActionPlanVideosText").ta; ta.setValue(videosTxt); ta.setRows(5); ta = (TextArea) addEditLine("5 Map Tab Instructions", "Game.defaultActionPlanMapText", game, game.getId(), "DefaultActionPlanMapText").ta; ta.setValue(mapTxt); ta.setRows(5); }
From source file:edu.nps.moves.mmowgli.modules.administration.BooleansGameDesignPanel.java
License:Open Source License
@HibernateSessionThreadLocalConstructor public BooleansGameDesignPanel(GameDesignGlobals globs) { super(false, globs); Game g = Game.getTL(dbObjId);//from w w w. jav a 2 s . c o m TextArea ta = (TextArea) addEditLine("Game title", "Game.title", g, dbObjId, "Title", null, String.class, "Used in game reports").ta; ta.setRows(1); addSeparator(); //@formatter:off addEditBoolean("Set entire game read-only", "Game.readonly", g, dbObjId, "Readonly"); addEditBoolean("Require email confirmation", "Game.emailConfirmation", g, dbObjId, "EmailConfirmation"); addEditBoolean("Show 2nd login permission page", "Game.secondLoginPermissionPage", g, dbObjId, "SecondLoginPermissionPage"); addSeparator(); addEditBoolean("Set all cards read-only", "Game.cardsReadonly", g, dbObjId, "CardsReadonly"); addEditBoolean("Set top cards read-only", "Game.topCardsReadonly", g, dbObjId, "TopCardsReadonly"); addEditBoolean("Show cards from prior rounds", "Game.showPriorMovesCards", g, dbObjId, "ShowPriorMovesCards"); addEditBoolean("Allow play on cards from prior rounds", "Game.playOnPriorMovesCards", g, dbObjId, "PlayOnPriorMovesCards"); addSeparator(); addEditBoolean("Enable action plans for this game", "Game.isActionPlansEnabled", g, dbObjId, "ActionPlansEnabled", "For specific game requirements where Action Plans are desired"); addEditBoolean("Show action plans from prior rounds", "Game.showPriorMovesActionPlans", g, dbObjId, "ShowPriorMovesActionPlans"); addEditBoolean("Allow edits on action plans from prior rounds", "Game.editPriorMovesActionPlans", g, dbObjId, "EditPriorMovesActionPlans"); //@formatter:on }