Search in sources :

Example 31 with Label

use of com.codename1.ui.Label in project CodenameOne by codenameone.

the class EmailShare method share.

/**
 * {@inheritDoc}
 */
public void share(final String toShare, final String image, final String mimeType) {
    final Form currentForm = Display.getInstance().getCurrent();
    final Form contactsForm = new Form("Contacts");
    contactsForm.setLayout(new BorderLayout());
    contactsForm.setScrollable(false);
    contactsForm.addComponent(BorderLayout.CENTER, new Label("Please wait..."));
    contactsForm.show();
    Display.getInstance().startThread(new Runnable() {

        public void run() {
            String[] ids = ContactsManager.getAllContacts();
            if (ids == null || ids.length == 0) {
                Display.getInstance().callSerially(new Runnable() {

                    public void run() {
                        Dialog.show("Failed to Share", "No Contacts Found", "Ok", null);
                        currentForm.showBack();
                    }
                });
                return;
            }
            ContactsModel model = new ContactsModel(ids);
            final List contacts = new List(model);
            contacts.setRenderer(createListRenderer());
            Display.getInstance().callSerially(new Runnable() {

                public void run() {
                    contacts.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent evt) {
                            final ShareForm[] f = new ShareForm[1];
                            Hashtable contact = (Hashtable) contacts.getSelectedItem();
                            if (image == null) {
                                f[0] = new ShareForm(contactsForm, "Send Email", (String) contact.get("email"), toShare, new ActionListener() {

                                    public void actionPerformed(ActionEvent evt) {
                                        String[] recieptents = new String[1];
                                        recieptents[0] = f[0].getTo();
                                        Message msg = new Message(toShare);
                                        Message.sendMessage(recieptents, "share", msg);
                                        finish();
                                    }
                                });
                                f[0].show();
                            } else {
                                f[0] = new ShareForm(contactsForm, "Send Email", (String) contact.get("email"), toShare, image, new ActionListener() {

                                    public void actionPerformed(ActionEvent evt) {
                                        String[] recieptents = new String[1];
                                        recieptents[0] = f[0].getTo();
                                        Message msg = new Message(toShare);
                                        msg.setAttachment(image);
                                        msg.setMimeType(mimeType);
                                        Message.sendMessage(recieptents, "share", msg);
                                        finish();
                                    }
                                });
                                f[0].show();
                            }
                        }
                    });
                    contactsForm.addComponent(BorderLayout.CENTER, contacts);
                    Command back = new Command("Back") {

                        public void actionPerformed(ActionEvent evt) {
                            currentForm.showBack();
                        }
                    };
                    contactsForm.addCommand(back);
                    contactsForm.setBackCommand(back);
                    contactsForm.revalidate();
                }
            });
        }
    }, "Email Thread").start();
}
Also used : Message(com.codename1.messaging.Message) ActionEvent(com.codename1.ui.events.ActionEvent) Hashtable(java.util.Hashtable) BorderLayout(com.codename1.ui.layouts.BorderLayout) ActionListener(com.codename1.ui.events.ActionListener) ContactsModel(com.codename1.contacts.ContactsModel)

Example 32 with Label

use of com.codename1.ui.Label in project CodenameOne by codenameone.

the class SMSShare method createRendererMultiButton.

private MultiButton createRendererMultiButton() {
    MultiButton b = new MultiButton();
    b.setIconName("icon");
    b.setNameLine1("fname");
    b.setNameLine2("phone");
    b.setUIID("Label");
    return b;
}
Also used : MultiButton(com.codename1.components.MultiButton)

Example 33 with Label

use of com.codename1.ui.Label in project CodenameOne by codenameone.

the class TestUtils method setText.

/**
 * Sets the text for the given component
 * @param name the name of the component
 * @param text the text to set
 */
public static void setText(String name, String text) {
    if (verbose) {
        log("setText(" + name + ", " + text + ")");
    }
    Component c = findByName(name);
    if (c instanceof Label) {
        ((Label) c).setText(text);
        return;
    }
    ((TextArea) c).setText(text);
    Display.getInstance().onEditingComplete(c, text);
}
Also used : TextArea(com.codename1.ui.TextArea) Label(com.codename1.ui.Label) Component(com.codename1.ui.Component)

Example 34 with Label

use of com.codename1.ui.Label in project CodenameOne by codenameone.

the class TestUtils method assertTextArea.

/**
 * Asserts that we have a label with the given text baring the given name
 * @param text the text of the label
 */
public static void assertTextArea(String text) {
    if (verbose) {
        log("assertTextArea(" + text + ")");
    }
    TextArea l = findTextAreaText(text);
    assertBool(l != null, "Null text " + text);
}
Also used : TextArea(com.codename1.ui.TextArea)

Example 35 with Label

use of com.codename1.ui.Label in project CodenameOne by codenameone.

the class TestUtils method assertTextArea.

/**
 * Asserts that we have a label with the given text baring the given name
 * @param path the path to the text area
 * @param text the text of the label
 */
public static void assertTextArea(int[] path, String text) {
    if (verbose) {
        log("assertTextArea(" + toString(path) + ", " + text + ")");
    }
    TextArea l = (TextArea) getComponentByPath(path);
    assertBool(l != null, "Null area " + text);
    assertBool(l.getText().equals(text), "assertTextArea: " + l.getText() + " != " + text);
}
Also used : TextArea(com.codename1.ui.TextArea)

Aggregations

Label (com.codename1.ui.Label)41 BorderLayout (com.codename1.ui.layouts.BorderLayout)22 Container (com.codename1.ui.Container)21 Component (com.codename1.ui.Component)16 Form (com.codename1.ui.Form)15 Button (com.codename1.ui.Button)14 TextArea (com.codename1.ui.TextArea)14 Style (com.codename1.ui.plaf.Style)13 ActionListener (com.codename1.ui.events.ActionListener)12 ActionEvent (com.codename1.ui.events.ActionEvent)11 Image (com.codename1.ui.Image)10 Dimension (com.codename1.ui.geom.Dimension)10 Vector (java.util.Vector)10 BoxLayout (com.codename1.ui.layouts.BoxLayout)9 EncodedImage (com.codename1.ui.EncodedImage)8 RadioButton (com.codename1.ui.RadioButton)7 LayeredLayout (com.codename1.ui.layouts.LayeredLayout)6 Hashtable (java.util.Hashtable)6 Paint (com.codename1.charts.compat.Paint)5 Font (com.codename1.ui.Font)5