1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | public class TextField extends Field { /** * @param control * @param id */ public TextField(Control control, int id) { super(control, id); } /* Based on the ID of the widget, values retrieved from * the content provider are set. */ public void readFromContent(IExampleContentProvider content) { String newText = (String )content.getElement(getId()); if (newText != null) ((Text )_control).setText(newText); } /* Based on the ID of the widget, values retrieved from widget are * sent back to the content provider. */ public void writeToContent(IExampleContentProvider content) { String newText = ((Text )_control).getText(); content.setElement(getId(), newText); } } |
1 2 3 4 5 6 7 8 9 10 | public Object getElement(int iIndex) { switch (iIndex) { case FIRST_INDEX: return "developer@ibm.com"; case SECOND_INDEX : return new Integer(1); case FOURTH_INDEX : return new Boolean(true); case THIRD_INDEX: return new Boolean(false); case FIFTH_INDEX: return new Boolean(false); } return null; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | public Form (Composite parent, int style, FieldMode mode, ExampleViewContentProvider content) { super(parent, style); _content = content; _style = style; setMode(mode); init(style); } private void init(int style) { createControls(style); controlsCreated(); } protected void controlsCreated() { readFromContent(); } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |