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