/** * Sets the list button's list data. * * @param listData * The list data to be presented by the list button as a JSON array. */ public final void setListData(String listData) { if (listData == null) { throw new IllegalArgumentException("listData is null."); } try { setListData(JSONSerializer.parseList(listData)); } catch (SerializationException exception) { throw new IllegalArgumentException(exception); } }
/** * Sets the list button's list data. * * @param listData * The list data to be presented by the list button as a JSON array. */ public final void setListData(String listData) { if (listData == null) { throw new IllegalArgumentException("listData is null."); } try { setListData(JSONSerializer.parseList(listData)); } catch (SerializationException exception) { throw new IllegalArgumentException(exception); } }
/** * Sets the list button's list data. * * @param listData * A URL referring to a JSON file containing the data to be presented by * the list button. */ public void setListData(URL listData) { if (listData == null) { throw new IllegalArgumentException("listData is null."); } JSONSerializer jsonSerializer = new JSONSerializer(); try { setListData((List<?>)jsonSerializer.readObject(listData.openStream())); } catch (SerializationException exception) { throw new IllegalArgumentException(exception); } catch (IOException exception) { throw new IllegalArgumentException(exception); } }
/** * Sets the list button's list data. * * @param listData * A URL referring to a JSON file containing the data to be presented by * the list button. */ public void setListData(URL listData) { if (listData == null) { throw new IllegalArgumentException("listData is null."); } JSONSerializer jsonSerializer = new JSONSerializer(); try { setListData((List<?>)jsonSerializer.readObject(listData.openStream())); } catch (SerializationException exception) { throw new IllegalArgumentException(exception); } catch (IOException exception) { throw new IllegalArgumentException(exception); } }
@Override public void clear() { if (listDataKey != null) { setListData(new ArrayList<Object>()); } if (selectedItemKey != null) { setSelectedItem(null); } }
@Override public void clear() { if (listDataKey != null) { setListData(new ArrayList<Object>()); } if (selectedItemKey != null) { setSelectedItem(null); } }
/** * Creates a list button with the given button and list data. * * @param buttonData * @param listData */ public ListButton(Object buttonData, List<?> listData) { super(buttonData); setDataRenderer(DEFAULT_DATA_RENDERER); setItemRenderer(DEFAULT_ITEM_RENDERER); setListData(listData); installSkin(ListButton.class); }
/** * Creates a list button with the given button and list data. * <p> * Note that the default renderer uses (as last option) the toString method on list elements, * so override it to return whatever you want to display in the ListView, * or implement your own custom renderer. * * @param buttonData * The button data. * * @param listData * The data to set. * * @see ListButtonDataRenderer * @see ListViewItemRenderer */ public ListButton(Object buttonData, List<?> listData) { super(buttonData); setDataRenderer(DEFAULT_DATA_RENDERER); setItemRenderer(DEFAULT_ITEM_RENDERER); setListData(listData); installSkin(ListButton.class); }
@Override @SuppressWarnings("unchecked") public void load(Object context) { // Bind to list data if (listDataKey != null && listDataBindType != BindType.STORE && JSON.containsKey(context, listDataKey)) { Object value = JSON.get(context, listDataKey); List<?> listDataLocal; if (listDataBindMapping == null) { listDataLocal = (List<?>)value; } else { listDataLocal = listDataBindMapping.toListData(value); } setListData(listDataLocal); } // Bind to selected item if (selectedItemKey != null && selectedItemBindType != BindType.STORE && JSON.containsKey(context, selectedItemKey)) { Object item = JSON.get(context, selectedItemKey); int index; if (selectedItemBindMapping == null) { index = ((List<Object>)listData).indexOf(item); } else { index = selectedItemBindMapping.indexOf(listData, item); } setSelectedIndex(index); } }
@Override @SuppressWarnings("unchecked") public void load(Object context) { // Bind to list data if (listDataKey != null && listDataBindType != BindType.STORE && JSON.containsKey(context, listDataKey)) { Object value = JSON.get(context, listDataKey); List<?> listData; if (listDataBindMapping == null) { listData = (List<?>)value; } else { listData = listDataBindMapping.toListData(value); } setListData(listData); } // Bind to selected item if (selectedItemKey != null && selectedItemBindType != BindType.STORE && JSON.containsKey(context, selectedItemKey)) { Object item = JSON.get(context, selectedItemKey); int index; if (selectedItemBindMapping == null) { index = ((List<Object>)listData).indexOf(item); } else { index = selectedItemBindMapping.indexOf(listData, item); } setSelectedIndex(index); } }