Search in sources :

Example 46 with TextArea

use of com.vaadin.v7.ui.TextArea in project CodenameOne by codenameone.

the class TestUtils method assertTextAreaEndingWith.

/**
 * Asserts that we have a TextArea with the a text ending with the given text and with the given name
 * @param name the name of the TextArea
 * @param text the suffix to search for in the TextArea
 */
public static void assertTextAreaEndingWith(String name, String text) {
    if (verbose) {
        log("assertTextAreaEndingWith(" + name + ", " + text + ")");
    }
    TextArea l = (TextArea) findByName(name);
    assertBool(l != null, "Null area " + text);
    assertBool(l.getText().endsWith(text), "assertTextArea: \"" + l.getText() + "\" is not ending with: \"" + text + "\"");
}
Also used : TextArea(com.codename1.ui.TextArea)

Example 47 with TextArea

use of com.vaadin.v7.ui.TextArea in project CodenameOne by codenameone.

the class TestUtils method assertTextAreaStartingWith.

/**
 * Asserts that we have a TextArea with the a text starting with the given text and with the given name
 * @param name the name of the TextArea
 * @param text the prefix to search for in the TextArea
 */
public static void assertTextAreaStartingWith(String name, String text) {
    if (verbose) {
        log("assertTextAreaStartingWith(" + name + ", " + text + ")");
    }
    TextArea l = (TextArea) findByName(name);
    assertBool(l != null, "Null area " + text);
    assertBool(l.getText().startsWith(text), "assertTextArea: \"" + l.getText() + "\" is not starting with: \"" + text + "\"");
}
Also used : TextArea(com.codename1.ui.TextArea)

Example 48 with TextArea

use of com.vaadin.v7.ui.TextArea in project CodenameOne by codenameone.

the class TextSelectionSample method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    hi.setScrollableY(false);
    TextSelection sel = hi.getTextSelection();
    sel.addTextSelectionListener(e -> {
    // System.out.println("Text selection has changed");
    });
    sel.setEnabled(true);
    Label label = new Label("This label should be selectable");
    label.setTextSelectionEnabled(true);
    Label label2 = new Label("Some more text");
    label2.setTextSelectionEnabled(true);
    hi.add(label);
    hi.add(new TextField("Hello Universe"));
    hi.add(label2);
    hi.add(new Label("Hi World"));
    Container cnt = new Container(BoxLayout.x());
    cnt.setScrollableX(true);
    cnt.getStyle().setBorder(Border.createLineBorder(1, 0x0));
    cnt.setPreferredH(CN.convertToPixels(5));
    cnt.setPreferredW(CN.convertToPixels(20));
    TextArea ta = new TextArea();
    ta.setText("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.");
    ta.setEnabled(false);
    ta.setRows(6);
    hi.add(ta);
    SpanLabel sl = new SpanLabel();
    sl.setText(ta.getText());
    sl.setTextSelectionEnabled(true);
    hi.add(sl);
    TextField tf = new TextField();
    tf.setText("Hello World.  This is a test field");
    tf.setEnabled(false);
    hi.add(tf);
    Label l = new Label("This is a test with some long text to see if this works.  It should just flow when it runs out of space");
    l.setTextSelectionEnabled(true);
    cnt.add(l);
    Container cntY = new Container(BoxLayout.y());
    cntY.setScrollableY(true);
    cntY.getStyle().setBorder(Border.createLineBorder(1, 0x0));
    for (int i = 0; i < 50; i++) {
        Label li = new Label("List item " + i);
        li.setTextSelectionEnabled(true);
        cntY.add(li);
    }
    hi.add(cnt);
    hi.add(cntY);
    $(cnt, cntY).selectAllStyles().setMarginMillimeters(4);
    hi.show();
}
Also used : Container(com.codename1.ui.Container) Form(com.codename1.ui.Form) TextArea(com.codename1.ui.TextArea) TextSelection(com.codename1.ui.TextSelection) SpanLabel(com.codename1.components.SpanLabel) Label(com.codename1.ui.Label) TextField(com.codename1.ui.TextField) SpanLabel(com.codename1.components.SpanLabel)

Example 49 with TextArea

use of com.vaadin.v7.ui.TextArea in project CodenameOne by codenameone.

the class UIFragmentSample method testUIFragment.

private void testUIFragment() {
    Form f = new Form("Test Fragments", BoxLayout.y());
    TextArea ta = new TextArea();
    ta.setMaxSize(5000);
    String[] examples = new String[] { "<borderAbs><$button1 constraint='center'/><xng constraint='south'><$button2/><$button3/><$button4/></xng></borderAbs>", "{centerAbs:$button1, south:{xng:[$button2, $button3, $button4]}}", "{cs:$button1, south:{xng:[$button2, $button3, $button4]}}", "{ca:$button1, south:{xng:[$button2, $button3, $button4]}}", "{centerScale:$button1, south:{xng:[$button2, $button3, $button4]}}", "{ctb:$button1, south:{xng:[$button2, $button3, $button4]}}", "{centerTotalBelow:$button1, south:{xng:[$button2, $button3, $button4]}}", "{s:$button1, c:{xng:[$button2, $button3, $button4]}}", "{s:$button1, c:{x:[$button2, $button3, $button4]}}", "{s:$button1, c:{y:[$button2, $button3, $button4]}}", "{s:$button1, c:{yBottomLast:[$button2, $button3, $button4]}}", "{s:$button1, c:{ybl:[$button2, $button3, $button4]}}" };
    ComboBox cb = new ComboBox(examples);
    cb.addActionListener(e -> {
        ta.setText(examples[cb.getSelectedIndex()]);
    });
    ta.setText("<borderAbs><$button1 constraint='center'/><xng constraint='south'><$button2/><$button3/><$button4/></xng></borderAbs>");
    Button b = new Button("Compile");
    b.addActionListener(e -> {
        Form f2 = new Form("Result", new BorderLayout());
        f2.setToolbar(new Toolbar());
        f2.setTitle("Result");
        f2.setBackCommand("Back", null, evt -> {
            f.showBack();
        });
        f2.getToolbar().addCommandToLeftBar("Back", null, evt -> {
            f.showBack();
        });
        Button b1 = new Button("Button 1");
        Button b2 = new Button("Button 2");
        Button b3 = new Button("Button 3");
        Button b4 = new Button("Button 4");
        $(b1, b2, b3, b4).selectAllStyles().setBorder(RoundRectBorder.create().cornerRadius(2)).setBgColor(0x003399).setBgTransparency(0xff);
        UIFragment frag;
        if (ta.getText().charAt(0) == '<') {
            frag = UIFragment.parseXML(ta.getText());
        } else {
            System.out.println("Parsing " + ta.getText());
            frag = UIFragment.parseJSON(ta.getText());
        }
        f2.add(BorderLayout.CENTER, frag.set("button1", b1).set("button2", b2).set("button3", b3).set("button4", b4).getView());
        f2.show();
    });
    ta.setRows(5);
    f.addAll(cb, ta, b);
    f.show();
}
Also used : BorderLayout(com.codename1.ui.layouts.BorderLayout) Form(com.codename1.ui.Form) TextArea(com.codename1.ui.TextArea) Button(com.codename1.ui.Button) ComboBox(com.codename1.ui.ComboBox) UIFragment(com.codename1.ui.UIFragment) Toolbar(com.codename1.ui.Toolbar)

Example 50 with TextArea

use of com.vaadin.v7.ui.TextArea in project CodenameOne by codenameone.

the class UpdateTextAreaWhileEditingTest method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    TextArea ta = new TextArea();
    Button reset = new Button("Reset");
    Button setToDate = new Button("Set to date");
    reset.addActionListener(e -> {
        ta.setText("");
    });
    setToDate.addActionListener(e -> {
        ta.setText(L10NManager.getInstance().formatDateTime(new Date()));
    });
    hi.add(GridLayout.encloseIn(2, reset, setToDate));
    hi.add(ta);
    hi.show();
}
Also used : Form(com.codename1.ui.Form) TextArea(com.codename1.ui.TextArea) Button(com.codename1.ui.Button) Date(java.util.Date)

Aggregations

TextArea (com.codename1.ui.TextArea)60 Form (com.codename1.ui.Form)23 Component (com.codename1.ui.Component)21 Button (com.codename1.ui.Button)16 Label (com.codename1.ui.Label)16 TextArea (com.vaadin.v7.ui.TextArea)15 Container (com.codename1.ui.Container)13 BorderLayout (com.codename1.ui.layouts.BorderLayout)12 Label (com.vaadin.ui.Label)11 ComboBox (com.vaadin.v7.ui.ComboBox)10 TextField (com.codename1.ui.TextField)9 DateComparisonValidator (de.symeda.sormas.ui.utils.DateComparisonValidator)9 DateField (com.vaadin.v7.ui.DateField)8 TextField (com.vaadin.v7.ui.TextField)8 NullableOptionGroup (de.symeda.sormas.ui.utils.NullableOptionGroup)7 RadioButton (com.codename1.ui.RadioButton)6 Field (com.vaadin.v7.ui.Field)6 BoxLayout (com.codename1.ui.layouts.BoxLayout)5 Paint (android.graphics.Paint)4 CheckBox (com.codename1.ui.CheckBox)4