Java Code Examples for com.codename1.ui.Display#PICKER_TYPE_STRINGS
The following examples show how to use
com.codename1.ui.Display#PICKER_TYPE_STRINGS .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UiBinding.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
@Override public void assignTo(PropertyType value, Picker cmp) { switch(cmp.getType()) { case Display.PICKER_TYPE_DATE: case Display.PICKER_TYPE_DATE_AND_TIME: cmp.setDate((Date)toComponentType.convert(value)); break; case Display.PICKER_TYPE_TIME: cmp.setTime((Integer)toComponentType.convert(value)); break; case Display.PICKER_TYPE_STRINGS: if(value instanceof Integer) { cmp.setSelectedStringIndex((Integer)toComponentType.convert(value)); } else { cmp.setSelectedString((String)toComponentType.convert(value)); } break; } }
Example 2
Source File: UiBinding.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
@Override public PropertyType getFrom(Picker cmp) { switch(cmp.getType()) { case Display.PICKER_TYPE_DATE: case Display.PICKER_TYPE_DATE_AND_TIME: return (PropertyType)toPropertyType.convert(cmp.getDate()); case Display.PICKER_TYPE_TIME: return (PropertyType)toPropertyType.convert(cmp.getTime()); case Display.PICKER_TYPE_STRINGS: if(toPropertyType instanceof IntegerConverter) { return (PropertyType)new Integer(cmp.getSelectedStringIndex()); } return (PropertyType)toPropertyType.convert(cmp.getSelectedString()); } throw new RuntimeException("Illegal state for picker binding"); }
Example 3
Source File: UiBinding.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
private static ObjectConverter pickerTypeToConverter(int type) { switch(type) { case Display.PICKER_TYPE_DATE: case Display.PICKER_TYPE_DATE_AND_TIME: return new DateConverter(); case Display.PICKER_TYPE_TIME: return new IntegerConverter(); case Display.PICKER_TYPE_STRINGS: return new StringConverter(); } throw new IllegalArgumentException("Unsupported picker type: " + type); }
Example 4
Source File: Picker.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** * Checks if the given type is supported in LightWeight mode. * @param type The type. Expects one of the Display.PICKER_XXX constants. * @return True if the given type is supported in lightweight mode. */ private static boolean isLightweightModeSupportedForType(int type) { switch (type) { case Display.PICKER_TYPE_STRINGS: case Display.PICKER_TYPE_DATE: case Display.PICKER_TYPE_TIME: case Display.PICKER_TYPE_DATE_AND_TIME: case Display.PICKER_TYPE_DURATION: case Display.PICKER_TYPE_DURATION_HOURS: case Display.PICKER_TYPE_DURATION_MINUTES: case Display.PICKER_TYPE_CALENDAR: return true; } return false; }
Example 5
Source File: Picker.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** * <p>Sets the string entries for the string picker. <br> * sample usage for this method below:</p> * * <script src="https://gist.github.com/codenameone/47602e679f61712693bd.js"></script> * @param strs string array */ public void setStrings(String... strs) { this.type = Display.PICKER_TYPE_STRINGS; int slen = strs.length; for (int i = 0; i < slen; i++) { String str = strs[i]; strs[i] = getUIManager().localize(str, str); } metaData = strs; if(!(value instanceof String)) { value = null; } updateValue(); }
Example 6
Source File: Table.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
public void actionPerformed(ActionEvent evt) { Component c = (Component)evt.getSource(); int row = getCellRow(c); int column = getCellColumn(c); if(c instanceof TextArea) { TextArea t = (TextArea)c; editingColumn = column; editingRow = row; if(isAbstractTableModel()) { Class type = ((AbstractTableModel)model).getCellType(row, column); if(type == Integer.class) { model.setValueAt(row, column, t.getAsInt(0)); return; } if(type == Long.class) { model.setValueAt(row, column, t.getAsLong(0)); return; } if(type == Short.class) { model.setValueAt(row, column, (short)t.getAsInt(0)); return; } if(type == Byte.class) { model.setValueAt(row, column, (byte)t.getAsInt(0)); return; } if(type == Float.class) { model.setValueAt(row, column, (float)t.getAsDouble(0)); return; } if(type == Double.class) { model.setValueAt(row, column, t.getAsDouble(0)); return; } if(type == Character.class) { if(t.getText().length() > 0) { model.setValueAt(row, column, t.getText().charAt(0)); } return; } } model.setValueAt(row, column, t.getText()); } else { if(c instanceof Picker) { switch(((Picker)c).getType()) { case Display.PICKER_TYPE_DATE: model.setValueAt(row, column, ((Picker)c).getDate()); break; case Display.PICKER_TYPE_STRINGS: model.setValueAt(row, column, ((Picker)c).getSelectedString()); break; } } else { if(c instanceof CheckBox) { model.setValueAt(row, column, ((CheckBox)c).isSelected()); } } } }