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.modules.administration.VipListManager.java

License:Open Source License

private void showAddDialogOrCancel(final DoneListener lis) {
    dialog = new Window("Add to VIP list");
    dialog.setModal(true);/*from ww  w  . j  a  v a 2 s . c  o m*/
    dialog.setWidth("400px");
    dialog.setHeight("350px");

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

    List<String> rtypes = Arrays.asList(new String[] { EMAILTYPE, DOMAINTYPE });
    radios = new OptionGroup("Select type", rtypes);

    radios.setNullSelectionAllowed(false); // user can not 'unselect'
    radios.select("Emails"); // select this by default
    radios.setImmediate(false); // don't send the change to the server at once
    layout.addComponent(radios);

    final TextArea ta = new TextArea();
    //ta.setColumns(40);
    ta.setSizeFull();
    ta.setInputPrompt(
            "Type or paste a tab-, comma- or space-separated list of emails or domains.  For domains, "
                    + "use forms such as \"army.mil\", \"nmci.navy.mil\", \"ucla.edu\", \"gov\", etc.");
    layout.addComponent(ta);

    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 addButt = new Button("Add", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            String[] returnArr = null;
            String result = ta.getValue().toString();
            if (result == null || result.length() <= 0)
                returnArr = null;
            else if ((returnArr = parseIt(result)) == null)
                return;

            dialog.close();
            lis.continueOrCancel(returnArr);
        }
    });

    hl.addComponent(cancelButt);
    hl.addComponent(addButt);
    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);

    hl.setWidth("100%");
    ta.setWidth("100%");
    ta.setHeight("100%");
    layout.setExpandRatio(ta, 1.0f);

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

From source file:edu.nps.moves.mmowgli.modules.cards.EditCardTextWindow.java

License:Open Source License

public EditCardTextWindow(String text, Integer charLim) {
    super("Edit card text");

    if (charLim != null)
        characterLimit = charLim;/* w  w w .j a  v a 2s.c  o  m*/

    setModal(true);
    VerticalLayout layout = new VerticalLayout();
    setContent(layout);
    layout.setMargin(true);
    layout.setSpacing(true);
    ta = new TextArea();
    ta.setRows(10);
    ta.setColumns(50);
    if (text != null) {
        ta.setValue(text);
        ta.selectAll();
    } else
        ta.setInputPrompt("Type card text here");
    layout.addComponent(ta);

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

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

    saveButt = new Button("Save", closeListener);
    saveButt.addClickListener(closeListener);
    buttHL.addComponent(saveButt);

    layout.addComponent(buttHL);

    layout.setSizeUndefined(); // does a "pack"
    UI.getCurrent().addWindow(this);
    ta.focus();
}

From source file:edu.nps.moves.mmowgli.modules.gamemaster.EventMonitorPanel.java

License:Open Source License

@Override
public void initGui() {
    setWidth("950px");
    addStyleName("m-greyborder");
    addStyleName("m-background-lightgrey");
    addStyleName("m-marginleft-25");
    setMargin(true);//ww w . j  a v  a  2 s  .c  o  m
    setSpacing(false);

    buildTopInfo(this);

    pan = new Panel();
    addComponent(pan);
    pan.setWidth("99%");
    pan.setHeight(PANEL_HEIGHT);
    vLay = new VerticalLayout();
    vLay.setMargin(true);
    pan.setContent(vLay);

    setComponentAlignment(pan, Alignment.TOP_CENTER);
    pan.addStyleName("m-greyborder");

    NativeButton moreButt = new NativeButton("Get another page of prior events", this);
    addComponent(moreButt);
    setComponentAlignment(moreButt, Alignment.TOP_RIGHT);

    Label lab;
    addComponent(lab = new Label());
    lab.setHeight("10px");

    addComponent(new Label("Broadcast message to game masters"));

    messageTA = new TextArea();
    messageTA.setRows(2);
    messageTA.setWidth("100%");

    addComponent(messageTA);

    NativeButton sendButt = new NativeButton("Send", new SendListener());
    addComponent(sendButt);

    loadEvents();
}

From source file:edu.nps.moves.mmowgli.modules.userprofile.DefineAwardsDialog.java

License:Open Source License

private TextArea makeTa(String val) {
    TextArea tf = new TextArea();
    tf.setRows(2);/*from w  w w. j  a  va2s.co m*/
    tf.setValue(val);
    tf.setWidth("100%");
    return tf;
}

From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfile3Top.java

License:Open Source License

@HibernateSessionThreadLocalConstructor
@HibernateUserRead//  ww  w.  j a va  2  s . c  o m
public UserProfile3Top(Object uid) {
    this.uid = uid;

    User u = User.getTL(uid);
    User me = Mmowgli2UI.getGlobals().getUserTL();
    itsSomebodyElse = (u.getId() != me.getId());
    imGuestAccount = me.isViewOnly();
    imAdmin = me.isAdministrator();
    imAdminOrGameMaster = me.isAdministrator() || me.isGameMaster();

    Game game = Game.getTL();
    gameReadOnly = game.isReadonly();

    scoresLab = new Label();
    exploreScoreLab = new Label();
    innovateScoreLab = new Label();

    if (game.isActionPlansEnabled()) {
        scoresLab.addStyleName("m-userProfile3-scores-label");

        exploreScoreLab.addStyleName("m-userProfile3-explorescore-label");
        exploreScoreLab.setValue(formatFloat(u.getCombinedBasicScore())); // u.getBasicScore()));
        exploreScoreLab.setDescription("rounds combined");

        innovateScoreLab.addStyleName("m-userProfile3-explorescore-label");
        innovateScoreLab.setValue(formatFloat(u.getCombinedInnovScore())); // u.getInnovationScore()));
        innovateScoreLab.setDescription("rounds combined");
    } else {
        scoresLab.addStyleName("m-userProfile3-exploreonlyscore-label");

        exploreScoreLab.addStyleName("m-userProfile3-explorescorebig-label");
        exploreScoreLab.setValue(formatFloat(u.getCombinedBasicScore())); // u.getBasicScore()));
        exploreScoreLab.setDescription("rounds combined");
    }

    avatarButt = new NativeButton();

    locationLab = new Label();
    locationLab.setDescription("Where are you from?");

    expertiseLab = new Label();
    expertiseLab.setDescription("Enter a short description of your pertinent expertise.");

    affiliationLab = new Label("AFFILIATION");
    affiliationLab.setDescription("Your professional affliation");
    affiliationLab.addStyleName("m-userProfile3-learn-label");

    coverUpChangePW = new Label();

    nameLab = new Label();
    nameLab.setValue(u.getUserName());

    learnLab = new Label();

    GameQuestion q = u.getQuestion();

    String questSumm = null;
    if (q != null)
        questSumm = q.getSummary();
    questSumm = questSumm == null ? "" : questSumm;
    learnLab.setValue(questSumm);

    String questDesc = null;
    if (q != null)
        questDesc = q.getQuestion();
    questDesc = questDesc == null ? "" : questDesc;
    learnLab.setDescription(questDesc);

    levelLab = new Label();
    Level lev = u.getLevel();
    if (u.isGameMaster()) {
        Level l = Level.getLevelByOrdinalTL(Level.GAME_MASTER_ORDINAL);
        if (l != null)
            lev = l;
    }
    levelLab.setValue(lev.getDescription());

    changePWButt = new NativeButton();

    externMailCB = new CheckBox();
    externMailCB.setValue(u.isOkEmail());
    ingameMailCB = new CheckBox();
    ingameMailCB.setValue(u.isOkGameMessages());

    String s;
    locationTF = new TextField();
    s = u.getLocation();
    locationTF.setValue(s == null ? "" : s);
    expertiseTA = new TextArea();
    s = u.getExpertise();
    expertiseTA.setValue(s == null ? "" : s);

    affiliationTA = new TextArea();
    affiliationTA.setInputPrompt("optional additional affiliations");
    affiliationCombo = new BoundAffiliationCombo();
    affiliationCombo.setInputPrompt("required"); // override "optional"
    affiliationCombo.setNewItemsAllowed(false);
    s = u.getAffiliation();
    fillAffiliation(s);

    learnTA = new TextArea();
    s = u.getAnswer();
    learnTA.setValue(s == null ? "" : s);
    badgeButts = new NativeButton[8];
    badgeLayout = new GridLayout(4, 3); //col,row
    if (itsSomebodyElse) {
        followCB = new CheckBox();
        followCB.setValue(amIFollowing(me));
        followCB.addValueChangeListener(new FollowListener());
    }

    if (imAdmin) {
        manageAwardsButt = new NativeButton("manage awards");
        manageAwardsButt.setDescription("<p>accessible to game administrators</p>");
        manageAwardsButt.addClickListener(new ManageAwardsListener());
    }
}

From source file:eu.lod2.EXMLExtended.java

License:Apache License

public EXMLExtended(LOD2DemoState state) {
    this();/*from  www.j  a v a  2  s.c  o  m*/
    this.state = state;

    // The internal state and

    panel = new VerticalLayout();
    panel.setSpacing(true);

    Label desc = new Label("This page aids the extraction of RDF out of an XML document.<br/>"
            + "This is done by defining an XSLT transformation which transforms the XML document into a set of RDF triples.<br/>"
            + "The resulting triples are uploaded in the share RDF store.", Label.CONTENT_XHTML);

    uploadXMLFile = new FileUpload("Upload the XML file here", "The XML file ", xmlFile);
    uploadXMLFile.setDebugId(this.getClass().getSimpleName() + "_uploadXMLFile");
    uploadXSLTFile = new FileUpload("Upload the XLST file here", "The XSLT file ", xsltFile);
    uploadXSLTFile.setDebugId(this.getClass().getSimpleName() + "_uploadXSLTFile");
    uploadCatalogFile = new FileUpload("Upload the XML Catalog file here", "The XML Catalog file ",
            catalogFile);
    uploadCatalogFile.setDebugId(this.getClass().getSimpleName() + "_uploadCatalogFile");
    uploadXSLTFile.setDescription("This file must be named catalog.xml. "
            + "The references can be to files on the local system or web reachable resources.");

    errorMsg = new Label("");

    exportGraph = new ExportSelector(state, true);
    exportGraph.setDebugId(this.getClass().getSimpleName() + "_exportGraph");
    uploadButton = new Button("Upload result to RDF Store", (Button.ClickListener) this);
    uploadButton.setDebugId(this.getClass().getSimpleName() + "_uploadButton");

    transformButton = new Button("transform XML to RDF", (Button.ClickListener) this);
    transformButton.setDebugId(this.getClass().getSimpleName() + "_transformButton");

    panel.addComponent(desc);
    panel.addComponent(uploadXMLFile);
    panel.addComponent(uploadXSLTFile);
    panel.addComponent(uploadCatalogFile);
    panel.addComponent(exportGraph);
    panel.addComponent(uploadButton);
    panel.addComponent(transformButton);
    panel.addComponent(errorMsg);

    errorMsg.setVisible(false);

    t2f = new Form();
    t2f.setDebugId(this.getClass().getSimpleName() + "_t2f");
    t2f.setCaption("");

    annotatedTextField = new Label("Extracted RDF", Label.CONTENT_XHTML);
    t2f.getLayout().addComponent(annotatedTextField);

    textToAnnotateField = new TextArea();
    textToAnnotateField.setDebugId(this.getClass().getSimpleName() + "_textToAnnotateField");
    textToAnnotateField.setImmediate(false);
    textToAnnotateField.setColumns(100);
    textToAnnotateField.setRows(25);

    t2f.getLayout().addComponent(textToAnnotateField);

    panel.addComponent(t2f);
    t2f.setVisible(false);

    downloadForm = new Form();
    downloadForm.setDebugId(this.getClass().getSimpleName() + "_downloadForm");
    downloadForm.setCaption("Download file.");
    dlFileName = new TextField();
    dlFileName.setDebugId(this.getClass().getSimpleName() + "_dlFileName");
    dlFileName.setRequired(true);
    //dlFileName.setCaption("Give a filename. (Required)");
    downloadForm.getLayout().addComponent(new Label("Give a filename."));
    downloadForm.getLayout().addComponent(dlFileName);
    dlPath = new TextField();
    dlPath.setDebugId(this.getClass().getSimpleName() + "_dlPath");
    dlPath.setRequired(true);
    //dlPath.setCaption("Specify a path. (Required for downloading)");
    downloadForm.getLayout().addComponent(new Label("Specify a path."));
    downloadForm.getLayout().addComponent(dlPath);
    downloadButton = new Button("Download file", (Button.ClickListener) this);
    downloadButton.setDebugId(this.getClass().getSimpleName() + "_downloadButton");
    downloadForm.getLayout().addComponent(downloadButton);

    panel.addComponent(downloadForm);
    downloadForm.setVisible(false);

    // The composition root MUST be set
    setCompositionRoot(panel);

}

From source file:facs.components.Settings.java

License:Open Source License

private void addNewDevice() {
    final Window subWindow = new Window("Add Device");
    FormLayout form = new FormLayout();
    form.setMargin(true);//from ww  w  .  ja v  a2s.c o  m
    final TextField name = new TextField();
    name.setImmediate(true);
    name.addValidator(new StringLengthValidator("The name must be 1-85 letters long (Was {0}).", 1, 85, true));
    name.setCaption("Name of new device");
    form.addComponent(name);
    final TextArea description = new TextArea();
    description.setImmediate(true);
    description.addValidator(
            new StringLengthValidator("The name must be 1-255 letters long (Was {0}).", 1, 255, true));
    description.setCaption("Description");
    form.addComponent(description);
    final OptionGroup restricted = new OptionGroup("Is Device restricted by operators?");
    restricted.addItem("yes");
    restricted.setMultiSelect(true);
    form.addComponent(restricted);
    HorizontalLayout buttons = new HorizontalLayout();
    Button save = new Button("save");
    buttons.addComponent(save);
    Button discard = new Button("discard");
    discard.setDescription("discarding will abort the process of adding a new device into the databse.");
    buttons.addComponent(discard);
    buttons.setSpacing(true);
    form.addComponent(buttons);
    subWindow.setContent(form);

    form.setMargin(true);
    form.setSpacing(true);
    buttons.setMargin(true);
    buttons.setSpacing(true);

    // Center it in the browser window
    subWindow.center();
    subWindow.setModal(true);
    subWindow.setWidth("50%");
    // Open it in the UI
    UI.getCurrent().addWindow(subWindow);

    discard.addClickListener(new ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = -5808910314649620731L;

        @Override
        public void buttonClick(ClickEvent event) {
            subWindow.close();
        }
    });
    save.addClickListener(new ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 3748395242651585005L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (name.isValid() && description.isValid()) {
                Set<String> restr = (Set<String>) restricted.getValue();
                int deviceId = DBManager.getDatabaseInstance().addDevice(name.getValue(),
                        description.getValue(), (restr.size() == 1));
                DeviceBean bean = new DeviceBean(deviceId, name.getValue(), description.getValue(),
                        (restr.size() == 1));
                devicesGrid.addRow(bean);
            } else {
                Notification.show("Failed to add device to database.");
            }
        }
    });

    // DeviceBean db = new DeviceBean(0, "Device 1","some description1", false);
    // TODO
    // add to database
    /*
     * boolean added = false;//DBManager.getDatabaseInstance().addDevice(db); //TODO test //add to
     * grid if(added){ devicesGrid.addRow(db); }else{ //TODO log failed operation
     * Notification.show("Failed to add device to database.", Type.ERROR_MESSAGE); }
     */
}

From source file:fi.hip.sicx.vaadin.GUIComponent.java

License:Open Source License

@AutoGenerated
private VerticalSplitPanel buildConsoleSplit() {
    // common part: create layout
    consoleSplit = new VerticalSplitPanel();
    consoleSplit.setImmediate(false);/*from  w ww  . j  av  a2s .  co m*/
    consoleSplit.setWidth("100.0%");
    consoleSplit.setHeight("100.0%");
    consoleSplit.setMargin(false);

    // HorizontalSplitPanel
    HorizontalSplitPanel = buildHorizontalSplitPanel();
    consoleSplit.addComponent(HorizontalSplitPanel);

    // consoleWindow
    consoleWindow = new TextArea();
    consoleWindow.setImmediate(false);
    consoleWindow.setWidth("100.0%");
    consoleWindow.setHeight("100.0%");
    consoleSplit.addComponent(consoleWindow);

    return consoleSplit;
}

From source file:fi.jasoft.remoteconnection.ServerExampleUI.java

License:Apache License

private void buildUI() {
    FormLayout vl = new FormLayout();
    setContent(vl);/*from w  w  w. j  a v  a  2s.c  o  m*/

    // Our id
    myId = new Label("Connecting...");
    myId.setCaption("My id:");
    vl.addComponent(myId);

    // Remote id
    final TextField remoteId = new TextField();
    remoteId.setWidth("100%");
    NativeButton connectToRemote = new NativeButton("Connect", new Button.ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            final RemoteChannel channel = peer.openChannel(remoteId.getValue());
            channel.addConnectedListener(new ConnectedListener() {

                @Override
                public void connected(String channelId) {
                    remoteId.setReadOnly(true);
                    event.getButton().setVisible(false);
                    Notification.show("Connected to " + channelId, Type.TRAY_NOTIFICATION);
                }
            });
        }
    });

    HorizontalLayout hl = new HorizontalLayout(remoteId, connectToRemote);
    hl.setExpandRatio(remoteId, 1);
    hl.setWidth("100%");
    hl.setCaption("Remote id: ");
    vl.addComponent(hl);

    // Message display where messages are displayed
    messages = new TextArea();
    messages.setWidth("100%");
    vl.addComponent(messages);

    // Message field
    final TextField message = new TextField();
    message.setWidth("100%");
    NativeButton send = new NativeButton("Send", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {

            // Show message in message window
            messages.setValue(
                    messages.getValue() + peer.getConfiguration().getId() + " >> " + message.getValue() + "\n");

            // Broadcast the message to all connected peers
            peer.broadcast(message.getValue());

            message.setValue("");
        }
    });

    hl = new HorizontalLayout(message, send);
    hl.setExpandRatio(message, 1);
    hl.setWidth("100%");
    hl.setCaption("Send message: ");
    vl.addComponent(hl);
}

From source file:fi.semantum.strategia.Utils.java

License:Open Source License

public static void editTextAndId(final Main main, String title, final Base container) {

    final Database database = main.getDatabase();

    final Window subwindow = new Window(title, new VerticalLayout());
    subwindow.setModal(true);//from  w ww  . j a va 2s .  com
    subwindow.setWidth("400px");
    subwindow.setHeight("500px");
    subwindow.setResizable(false);

    VerticalLayout winLayout = (VerticalLayout) subwindow.getContent();
    winLayout.setMargin(true);
    winLayout.setSpacing(true);

    final TextField tf = new TextField();
    tf.setCaption("Lyhytnimi:");
    tf.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    tf.setValue(container.getId(database));
    tf.setWidth("100%");
    winLayout.addComponent(tf);

    final TextArea ta = new TextArea();
    ta.setCaption("Teksti:");
    ta.setValue(container.getText(database));
    ta.setWidth("100%");
    ta.setHeight("290px");
    winLayout.addComponent(ta);

    Button save = new Button("Tallenna", new Button.ClickListener() {

        private static final long serialVersionUID = 6641880870005364983L;

        public void buttonClick(ClickEvent event) {
            String idValue = tf.getValue();
            String value = ta.getValue();
            main.removeWindow(subwindow);
            container.modifyId(main, idValue);
            container.modifyText(main, value);
            Collection<String> tags = Tag.extractTags(value);
            database.assertTags(tags);
            ArrayList<Tag> tagObjects = new ArrayList<Tag>();
            for (String s : tags)
                tagObjects.add(database.getOrCreateTag(s));
            container.assertRelatedTags(database, tagObjects);
            Updates.update(main, true);
            Property emails = Property.find(database, Property.EMAIL);
            String addr = emails.getPropertyValue(container);
            if (addr != null && !addr.isEmpty()) {
                String[] addrs = addr.split(",");
                if (addrs.length > 0) {
                    try {
                        Email.send(addrs, "Muutos strategiakartassa: " + container.getId(database),
                                "Kyttj " + main.account.getId(database)
                                        + " on muuttanut strategiakarttaa.<br/><br/>Lyhytnimi: "
                                        + container.getId(database) + "<br/><br/>Teksti: "
                                        + container.getText(database));
                    } catch (MessagingException e) {
                        e.printStackTrace();
                    }
                }
            }
        }

    });

    Button discard = new Button("Peru muutokset", new Button.ClickListener() {

        private static final long serialVersionUID = -784522457615993823L;

        public void buttonClick(ClickEvent event) {
            Updates.update(main, true);
            main.removeWindow(subwindow);
        }

    });

    HorizontalLayout hl2 = new HorizontalLayout();
    hl2.setSpacing(true);
    hl2.addComponent(save);
    hl2.addComponent(discard);
    winLayout.addComponent(hl2);
    winLayout.setComponentAlignment(hl2, Alignment.MIDDLE_CENTER);
    main.addWindow(subwindow);

    ta.setCursorPosition(ta.getValue().length());

}