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();
}
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;
}
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);
}
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);
}
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);
}
Aggregations