Example usage for com.vaadin.ui TextArea TextArea

List of usage examples for com.vaadin.ui TextArea TextArea

Introduction

In this page you can find the example usage for com.vaadin.ui TextArea TextArea.

Prototype

public TextArea() 

Source Link

Document

Constructs an empty TextArea.

Usage

From source file:edu.nps.moves.mmowgli.components.SendMessageWindow.java

License:Open Source License

@HibernateSessionThreadLocalConstructor
public SendMessageWindow(List<String> emails) {
    super("A message to mmowgli followers");

    this.emails = emails;

    setModal(true);/*w  w  w .  j a v  a2 s. com*/
    VerticalLayout layout = new VerticalLayout();
    setContent(layout);
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setWidth("100%");
    layout.setHeight("100%");

    Label lab = new Label(makeString(emails));
    lab.setCaption("To: (other addresses hidden from each recipient)");
    lab.setDescription(lab.getValue().toString());
    lab.addStyleName("m-nowrap");
    //   lab.setHeight("100%"); // makes label clip
    lab.addStyleName("m-greyborder");
    layout.addComponent(lab);

    subjTf = new TextField();
    subjTf.setCaption("Subject:");
    subjTf.setWidth("100%");

    Game game = Game.getTL();
    String acronym = game.getAcronym();
    acronym = acronym == null ? "" : acronym + " ";
    subjTf.setValue("Message from " + acronym + "Mmowgli");
    layout.addComponent(subjTf);

    ta = new TextArea();
    ta.setCaption("Content: (may include HTML tags)");
    ta.setRows(10);
    ta.setColumns(50);
    ta.setWidth("100%");
    ta.setHeight("100%");
    ta.setInputPrompt("Type message here");
    layout.addComponent(ta);
    layout.setExpandRatio(ta, 1.0f);
    HorizontalLayout buttHL = new HorizontalLayout();
    buttHL.setSpacing(true);

    ClickListener closeListener = new SignupsWindowCloser(this);
    cancelButt = new Button("Cancel", closeListener);
    buttHL.addComponent(cancelButt);

    sendButt = new Button("Send", closeListener);
    sendButt.addClickListener(closeListener);
    buttHL.addComponent(sendButt);

    layout.addComponent(buttHL);
    layout.setComponentAlignment(buttHL, Alignment.MIDDLE_RIGHT);
    setWidth("650px");
    setHeight("500px");
    UI.getCurrent().addWindow(this);
    ta.focus();
}

From source file:edu.nps.moves.mmowgli.components.SendMessageWindow.java

License:Open Source License

public SendMessageWindow(User user, boolean ccSelf, MailManager.Channel channel, boolean showCcTroubleList) {
    super("A message to " + user.getUserName());

    this.usr = user;
    this.ccSelf = ccSelf;
    this.channel = channel;

    setModal(true);/*from   w  w w. j  a v  a2s .  co m*/
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    setContent(layout);

    subjTf = new TextField();
    subjTf.setCaption("Subject");
    subjTf.setWidth("100%");

    User me = Mmowgli2UI.getGlobals().getUserTL();
    Game game = Game.getTL();
    String acronym = game.getAcronym();
    acronym = acronym == null ? "" : acronym + " ";
    subjTf.setValue(acronym + "Mmowgli message to " + usr.getUserName() + " from " + me.getUserName());
    layout.addComponent(subjTf);
    if (showCcTroubleList) {
        layout.addComponent(ccTroubleListCB = new CheckBox("CC mmowgli trouble list"));
        ccTroubleListCB.setValue(false);
    }
    ta = new TextArea();
    ta.setCaption("Content");
    ta.setRows(10);
    ta.setColumns(50);
    ta.setInputPrompt("Type message here");
    layout.addComponent(ta);

    HorizontalLayout buttHL = new HorizontalLayout();
    buttHL.setSpacing(true);

    WindowCloser closeListener = new WindowCloser(this);
    cancelButt = new Button("Cancel", closeListener);
    buttHL.addComponent(cancelButt);

    sendButt = new Button("Send", closeListener);//new IDButton("Send", SENDPRIVATEMESSAGECLICK, user);
    sendButt.addClickListener(closeListener);
    buttHL.addComponent(sendButt);

    layout.addComponent(buttHL);
    layout.setComponentAlignment(buttHL, Alignment.MIDDLE_RIGHT);
    layout.setSizeUndefined(); // does a "pack"

    UI.getCurrent().addWindow(this);
    ta.focus();
}

From source file:edu.nps.moves.mmowgli.export.BaseExporter.java

License:Open Source License

protected void getMetaStringOrCancel(final MetaListener lis, String title, final Map<String, String> params) {
    final Window dialog = new Window(title);
    final TextField[] parameterFields;

    dialog.setModal(true);//w w w . ja  va 2  s .  co m

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();
    dialog.setContent(layout);

    final TextArea ta = new TextArea();
    ta.setWidth("100%");
    ta.setInputPrompt("Type a description of this data, or the game which generated this data (optional)");

    ta.setImmediate(true);
    layout.addComponent(ta);

    Set<String> keySet = params.keySet();
    parameterFields = new TextField[keySet.size()];
    int i = 0;
    GridLayout pGL = new GridLayout();
    pGL.addStyleName("m-greyborder");
    pGL.setColumns(2);
    Label hdr = new HtmlLabel("<b>Parameters</b>");
    hdr.addStyleName("m-textaligncenter");
    pGL.addComponent(hdr, 0, 0, 1, 0); // top row
    pGL.setComponentAlignment(hdr, Alignment.MIDDLE_CENTER);
    pGL.setSpacing(false);
    for (String key : keySet) {
        pGL.addComponent(new HtmlLabel("&nbsp;" + key + "&nbsp;&nbsp;"));
        pGL.addComponent(parameterFields[i] = new TextField());
        parameterFields[i++].setValue(params.get(key));
    }
    if (i > 0) {
        layout.addComponent(pGL);
        layout.setComponentAlignment(pGL, Alignment.TOP_CENTER);
    }

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    @SuppressWarnings("serial")
    Button cancelButt = new Button("Cancel", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            dialog.close();
            lis.continueOrCancel(null);
        }
    });

    @SuppressWarnings("serial")
    Button exportButt = new Button("Export", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            dialog.close();

            Set<String> keySet = params.keySet();
            int i = 0;
            for (String key : keySet)
                params.put(key, parameterFields[i++].getValue().toString());

            lis.continueOrCancel(ta.getValue().toString());
        }
    });
    hl.addComponent(cancelButt);
    hl.addComponent(exportButt);
    hl.setComponentAlignment(cancelButt, Alignment.MIDDLE_RIGHT);
    hl.setExpandRatio(cancelButt, 1.0f);

    // The components added to the window are actually added to the window's
    // layout; you can use either. Alignments are set using the layout
    layout.addComponent(hl);
    dialog.setWidth("385px");
    dialog.setHeight("310px");
    hl.setWidth("100%");
    ta.setWidth("100%");
    ta.setHeight("100%");
    layout.setExpandRatio(ta, 1.0f);

    UI.getCurrent().addWindow(dialog);
}

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);//www .j  a v a 2 s .  c o  m

    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.ActionPlanPageTabTalk.java

License:Open Source License

private Component createChatEntryField() {
    HorizontalLayout hl = new HorizontalLayout();
    chatTextField = new TextArea();
    chatTextField.setRows(3);/*ww  w.  j a  v a 2  s.  c  o m*/
    chatTextField.setWordwrap(true);
    chatTextField.setInputPrompt("Type here to chat, RETURN submits");
    chatTextField.setId(ACTIONPLAN_TALK_IT_OVER_TEXT_BOX);
    hl.addComponent(chatTextField);
    chatTextField.setWidth("99%");
    hl.setExpandRatio(chatTextField, 1.0f);
    chatTextField.setReadOnly(isReadOnly);

    chatSubmitButt = new NativeButton();
    chatSubmitButt.setStyleName("m-submitButton");
    hl.addComponent(chatSubmitButt);
    chatSubmitButt.addClickListener(new ChatButtonListener());
    chatSubmitButt.setEnabled(!isReadOnly);
    chatSubmitButt.setId(ACTIONPLAN_TALK_IT_OVER_SUBMIT_BUTTON);
    return hl;
}

From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPageTabThePlan2.java

License:Open Source License

@HibernateSessionThreadLocalConstructor
public ActionPlanPageTabThePlan2(ActionPlanPage2 mother, Object apId, boolean isMockup, boolean readonly) {
    super(apId, isMockup, readonly);
    whatTA = new TextArea();
    whatTA.addStyleName(ACTIONPLAN_TAB_THEPLAN_WHAT);
    whatWillItTakeTA = new TextArea();
    whatTA.addStyleName(ACTIONPLAN_TAB_THEPLAN_TAKE);
    howWorkTA = new TextArea();
    whatTA.addStyleName(ACTIONPLAN_TAB_THEPLAN_WORK);
    howChangeTA = new TextArea();
    whatTA.addStyleName(ACTIONPLAN_TAB_THEPLAN_CHANGE);
    whoTA = new TextArea();
    whatTA.addStyleName(ACTIONPLAN_TAB_THEPLAN_WHO);
}

From source file:edu.nps.moves.mmowgli.modules.actionplans.MediaPanel.java

License:Open Source License

MediaPanel(Media m, Object apId, int idx, ClickListener replaceListener) {
    this.idx = idx;
    this.m = m;//from  w w  w. j  a  va2  s .  co  m

    zoom = new NativeButton();
    caption = new TextArea();
    caption.setInputPrompt("Description");
    title = new TextField();
    title.setInputPrompt("Title");
    titleHL = new HorizontalLayout();
    indexLab = new HtmlLabel("");

    FocusHandler fHandler = new FocusHandler();
    caption.addFocusListener((FocusListener) fHandler);
    title.addFocusListener((FocusListener) fHandler);

    captionSavePan = new HorizontalLayout();
    captionSavePan.setSpacing(true);
    captionSavePan.setMargin(false);
    Label lab;
    captionSavePan.addComponent(lab = new Label());
    lab.setWidth("1px");
    captionSavePan.setExpandRatio(lab, 1.0f);
    canButt = new Button("Cancel");
    captionSavePan.addComponent(canButt);
    canButt.setStyleName(Reindeer.BUTTON_SMALL);
    canButt.addClickListener((ClickListener) fHandler);
    saveButt = new Button("Save");
    captionSavePan.addComponent(saveButt);
    saveButt.setStyleName(Reindeer.BUTTON_SMALL);
    saveButt.addStyleName("m-redbutton");
    saveButt.addClickListener((ClickListener) fHandler);
    captionSavePan.addComponent(lab = new Label());
    lab.setWidth("5px");
}

From source file:edu.nps.moves.mmowgli.modules.actionplans.TextAreaLabelUnion.java

License:Open Source License

TextAreaLabelUnion(TextArea taParam, Label labParam, FocusListener fLis, String componentStyle) {
    this.fLis = fLis;

    if (taParam != null)
        ta = taParam;/* w  w w.j  a va2 s.  c  o  m*/
    else
        ta = new TextArea();
    if (labParam != null)
        lab = labParam;
    else {
        lab = new HtmlLabel();
    }
    vl = new VerticalLayout();
    vl.setSizeFull();

    if (componentStyle == null)
        componentStyle = "m-actionplan-theplan-fields";
    addStyleToComponents(componentStyle);
}

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);/*from w  w w .ja v  a 2s  . com*/
    ta.setReadOnly(globals.readOnlyCheck(false));
    lines.add(new EditLine(name, info, ta, null, null, null));
    return ta;
}

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);/*from   ww  w .  j a  va2 s  .c  o  m*/
    ta.setReadOnly(globals.readOnlyCheck(false));

    EditLine edLine = getLineData(dbObj);
    edLine.name = name;
    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;
}