After you design a Device Application Designer application, and generate the device application from that document, each screen is generated into a class that extends BaseBOBScreen, and each tab panel is generated into a class that extends LayoutManager, where various controls are defined, as well as actions and menus.
An additional BOBCUIDefinition is generated to keep track of user defined variables, styles, MBOs, screens, and so on. The BOBCUIDefinition as well as the screen classes are compiled against the Device Framework and the BOBUIController to produce the final client application. BOBCOptionsDefinition is generated to keep track of settings screens, MBO packages, profiles, and so on. The class and OptionsMain and generated object API code are compiled into options module. The generated client code serves as good sample code to illustrate the usage of the Device Framework.
protected Object createControlById(int ID) { switch (ID) { ...... case CELLTABLE1: CellTable localcellTable1 = new CellTable(Field.FIELD_LEFT); return localcellTable1; ......
protected Object createControlById(int ID) { switch (ID) { case CELLTABLE1: CellTable localcellTable1 = new CellTable(Field.FIELD_LEFT) { public boolean keyChar(char key, int status, int time) { // TODO sym key seems ignored boolean retval = false; switch (key) { case Characters.ENTER: case Characters.NULL: case Characters.CONTROL_SYMBOL: case Characters.CONTROL_UP: case Characters.CONTROL_VOLUME_DOWN: case Characters.CONTROL_VOLUME_UP: case Characters.TAB: retval = super.keyChar(key, status, time); break; case Characters.DELETE: case Characters.BACKSPACE: String text = customNaviBar.getFindText(); if (text.length() > 0) { customNaviBar.setFindText(text.substring(0, text .length() - 1)); } else { customNaviBar.setFindText(""); } break; default: customNaviBar.setFindText(customNaviBar.getFindText() + key); break; } return retval; } }; return localcellTable1; default: return super.createControlById(ID);
protected void configureObjectMetaDataById(int ID, Object object) { switch (ID) { ...... case CELLTABLE1: if (object instanceof CellTable) { CellTable localcellTable1 = (CellTable) object; //Create set of submit elements Vector submit1 = new Vector(); submit1.addElement(new SubmitElement("parameter1", "2010-06-07", VariableProperties.SUBMIT_USER_TYPE, null, false, null, -1, "startDate", MBOAttribute.SCHEMA_TYPE_DATE, false, null, false)); localcellTable1.setColumnPercentage(new int[] { 10, 60, 30 }); localcellTable1.setSortingColumn("Sort on column"); localcellTable1.setMboId(BOBCUIDefinition.MBO_POC_ACTIVITY); localcellTable1.setNamedQuerySubmitElements(submit1); localcellTable1.setNamedQuery("findByDate"); localcellTable1.setFocusFontStyle(styleCell_Table_Focus_Style); localcellTable1.setNumberOfColumns(3); localcellTable1.setColumnConfig(new String[] { "description", "status", "actType" }); localcellTable1 .setUnfocusFontStyle(styleCell_Table_Unfocus_Style); } break; ......
protected void configureObjectMetaDataById(int ID, Object object) { switch (ID) { case CELLTABLE1: super.configureObjectMetaDataById(ID, object); if (object instanceof CellTable) { CellTable localcellTable1 = (CellTable) object; localcellTable1.setNamedQuery(null); } break; default: super.configureObjectMetaDataById(ID, object); } }
protected void configureObjectHandlersById(int ID, Object object) { switch (ID) { ...... case MENU8: if (object instanceof MenuAction) { MenuAction menu8 = (MenuAction) object; //Create list of actions ActionList actionList17 = new ActionList(); IBOBAction connectionAction7 = new ScreenAction(UIDefinition .getScreen("screen34"), false, null); menu8.setAction(actionList17); IBOBAction contextAction7 = new SaveMobileDataContextAction( cellTable1); actionList17.addAction(contextAction7); actionList17.addAction(connectionAction7); } break; ..... }
protected void configureObjectHandlersById(int ID, Object object) { switch (ID) { case MENU8: if (object instanceof MenuAction) { MenuAction menu8 = (MenuAction) object; //Create list of actions ActionList actionList17 = new ActionList(); menu8.setAction(actionList17); IBOBAction contextAction7 = new SaveMobileDataContextAction( cellTable1); actionList17.addAction(contextAction7); actionList17.addAction(new Action() { public void run() { if (UIDefinition.getScreen("screen34") instanceof BOBScreenUpdate_Activities_Custom){ BOBScreenUpdate_Activities_Custom screen = (BOBScreenUpdate_Activities_Custom)UIDefinition.getScreen("screen34"); UiApplication.getUiApplication().pushScreen(screen); } } }); } break; default: super.configureObjectHandlersById(ID, object); } }
protected void configureObjectHandlersById(int ID, Object object) { switch (ID) { ...... case SELECTBOX31: if (object instanceof SelectBox) { SelectBox localselectBox31 = (SelectBox) object; localselectBox31.setControlID(SELECTBOX31); localselectBox31.setCustomEventsDelegate( new BOBScreenUpdate_Activities_SelectBoxDelegate(), Literals.CUSTOM_EVENT_ON_DRAW); } break; ......
/** * (non-Javadoc) * * @see com.sybase.uep.bobclient.controls.ICustomEventsDelegate#paint(Object field, int controlID, Graphics g) */ public void paint(Object field, int controlID, Graphics g) { // custom code switch (controlID) { case BOBScreenUpdate_Activities_.SELECTBOX31: g.clear(); SelectBox selectBox = (SelectBox)field; int currentSelect = selectBox.getSelectedIndex(); if(currentSelect>-1) { SelectBoxChoice choice = (SelectBoxChoice)selectBox.getChoice(currentSelect); String choiceLabel = choice.getLabel(); g.setColor(Color.BLACK); g.drawText( choiceLabel, H_PADDING, (selectBox.getPreferredHeight()-selectBox.getFontStyle().getFont().getHeight())/2, DrawStyle.ELLIPSIS, selectBox.getPreferredWidth() - DROPDOWN_HINT_AREA_WIDTH-H_PADDING); } break; default: break; } } /** * (non-Javadoc) * * @see com.sybase.uep.bobclient.controls.ICustomEventsDelegate#drawFocus * (Object field, int controlID, Graphics g, boolean on) */ public void drawFocus(Object field, int controlID, Graphics g, boolean on) { // custom code switch (controlID) { case BOBScreenUpdate_Activities_.SELECTBOX31: g.clear(); SelectBox selectBox = (SelectBox)field; int oldColor = g.getColor(); int oldBgColor = g.getBackgroundColor(); int currentSelect = selectBox.getSelectedIndex(); if(currentSelect>-1) { SelectBoxChoice choice = (SelectBoxChoice)selectBox.getChoice(currentSelect); String choiceLabel = choice.getLabel(); int y = (selectBox.getPreferredHeight()-selectBox.getFontStyle().getFont(). getHeight())/2; int height = selectBox.getPreferredHeight(); int width = selectBox.getPreferredWidth() - DROPDOWN_HINT_AREA_WIDTH-H_PADDING; g.setColor(0x00FFFFFF); int actualWidth = g.drawText( choiceLabel, H_PADDING, y, DrawStyle.ELLIPSIS, width); g.setColor(0x00185AB5); g.fillRect(H_PADDING, y, actualWidth, height); g.setColor(0x00FFFFFF); g.drawText( choiceLabel, H_PADDING, y, DrawStyle.ELLIPSIS, width); } g.setColor(oldColor); g.setBackgroundColor(oldBgColor); break; default: break; } } ......