Search in sources :

Example 6 with List

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

the class LazyValueC method setContainerStateImpl.

private void setContainerStateImpl(Container cnt, Hashtable state) {
    if (state != null) {
        restoreComponentState(cnt, state);
        String cmpName = (String) state.get(FORM_STATE_KEY_FOCUS);
        if (cmpName == null) {
            return;
        }
        Component c = findByName(cmpName, cnt);
        if (c != null) {
            c.requestFocus();
            if (c instanceof List) {
                Integer i = (Integer) state.get(FORM_STATE_KEY_SELECTION);
                if (i != null) {
                    ((List) c).setSelectedIndex(i.intValue());
                }
            }
        }
    }
}
Also used : List(com.codename1.ui.List) ContainerList(com.codename1.ui.list.ContainerList) Component(com.codename1.ui.Component)

Example 7 with List

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

the class LazyValueC method getContainerState.

/**
 * This method is the container navigation equivalent of getFormState() see
 * that method for details.
 * @param cnt the container
 * @return the state
 */
protected Hashtable getContainerState(Container cnt) {
    Component c = null;
    Form parentForm = cnt.getComponentForm();
    if (parentForm != null) {
        c = parentForm.getFocused();
    }
    Hashtable h = new Hashtable();
    h.put(FORM_STATE_KEY_NAME, cnt.getName());
    h.put(FORM_STATE_KEY_CONTAINER, "");
    if (c != null && isParentOf(cnt, c)) {
        if (c instanceof List) {
            h.put(FORM_STATE_KEY_SELECTION, new Integer(((List) c).getSelectedIndex()));
        }
        if (c.getName() != null) {
            h.put(FORM_STATE_KEY_FOCUS, c.getName());
        }
        return h;
    }
    storeComponentState(cnt, h);
    return h;
}
Also used : Form(com.codename1.ui.Form) Hashtable(java.util.Hashtable) List(com.codename1.ui.List) ContainerList(com.codename1.ui.list.ContainerList) Component(com.codename1.ui.Component)

Example 8 with List

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

the class StyleParser method getBackgroundTypes.

/**
 * Gets the available background type strings (which can be passed to {@link StyleInfo#setBgType(java.lang.String) }
 * @return
 */
public static List<String> getBackgroundTypes() {
    ArrayList<String> out = new ArrayList<String>();
    out.addAll(bgTypes().keySet());
    Collections.sort(out, new CaseInsensitiveOrder());
    return out;
}
Also used : ArrayList(java.util.ArrayList) CaseInsensitiveOrder(com.codename1.util.CaseInsensitiveOrder)

Example 9 with List

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

the class DefaultListCellRenderer method getCellRendererComponent.

/**
 * {@inheritDoc}
 */
public Component getCellRendererComponent(Component list, Object model, T value, int index, boolean isSelected) {
    if (!alwaysRenderSelection && !Display.getInstance().shouldRenderSelection(list)) {
        isSelected = false;
    }
    setFocus(isSelected);
    if (showNumbers) {
        String text = "" + value;
        Map<String, String> t = UIManager.getInstance().getBundle();
        if (t != null && value != null) {
            Object o = t.get(value.toString());
            if (o != null) {
                text = (String) o;
            }
        }
        if (isRTL()) {
            setText(text + " ." + (index + 1));
        } else {
            setText("" + (index + 1) + ". " + text);
        }
    } else {
        if (value != null) {
            String v = value.toString();
            setText(v);
            if (isRightAlignNumbers()) {
                char c = v.charAt(0);
                Style s = getStyle();
                if (c >= '0' && c <= '9') {
                    s.setAlignment(RIGHT);
                } else {
                    s.setAlignment(LEFT);
                }
            }
        } else {
            setText("null");
        }
    }
    if (value instanceof Command) {
        setIcon(((Command) value).getIcon());
        setEnabled(((Command) value).isEnabled());
    }
    return this;
}
Also used : Command(com.codename1.ui.Command) Style(com.codename1.ui.plaf.Style)

Example 10 with List

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

the class Purchase method removePendingPurchase.

/**
 * Removes a receipt from pending purchases.
 * @param transactionId
 * @return
 */
private Receipt removePendingPurchase(String transactionId) {
    synchronized (PENDING_PURCHASE_KEY) {
        Storage s = Storage.getInstance();
        List<Receipt> pendingPurchases = getPendingPurchases();
        Receipt found = null;
        for (Receipt r : pendingPurchases) {
            if (r.getTransactionId() != null && r.getTransactionId().equals(transactionId)) {
                found = r;
                break;
            }
        }
        if (found != null) {
            pendingPurchases.remove(found);
            s.writeObject(PENDING_PURCHASE_KEY, pendingPurchases);
            return found;
        } else {
            return null;
        }
    }
}
Also used : Storage(com.codename1.io.Storage)

Aggregations

Paint (com.codename1.charts.compat.Paint)26 ArrayList (java.util.ArrayList)24 Component (com.codename1.ui.Component)16 List (com.codename1.ui.List)13 Point (com.codename1.charts.models.Point)11 BorderLayout (com.codename1.ui.layouts.BorderLayout)11 Hashtable (java.util.Hashtable)11 Container (com.codename1.ui.Container)9 ContainerList (com.codename1.ui.list.ContainerList)9 Button (com.codename1.ui.Button)8 List (java.util.List)8 TextArea (com.codename1.ui.TextArea)7 Dimension (com.codename1.ui.geom.Dimension)7 EncodedImage (com.codename1.ui.EncodedImage)6 Label (com.codename1.ui.Label)6 RadioButton (com.codename1.ui.RadioButton)5 ActionListener (com.codename1.ui.events.ActionListener)5 JList (javax.swing.JList)4 FileEncodedImage (com.codename1.components.FileEncodedImage)3 StorageImage (com.codename1.components.StorageImage)3