public void commandAction(Command command, Item item) { if (recentList.isEmpty()) return; parentView = display.getCurrent(); cmdBack = new Command(SR.MS_BACK, Command.BACK, 99); cmdSelect = new Command(SR.MS_SELECT, Command.OK, 1); cmdClear = new Command(SR.MS_CLEAR, command.SCREEN, 2); list = new List(label, List.IMPLICIT); list.addCommand(cmdBack); list.addCommand(cmdClear); list.setSelectCommand(cmdSelect); for (Enumeration e = recentList.elements(); e.hasMoreElements(); ) list.append((String) e.nextElement(), null); list.setCommandListener(this); display.setCurrent(list); }
public void commandAction(Command c, Displayable d) { if (c == List.SELECT_COMMAND) { List down = (List) dsp.getCurrent(); String title = down.getTitle(); if (title.equals("Menu:")) { switch (down.getSelectedIndex()) { case 0: { System.out.println("Stisknul jsi " + down.getString(down.getSelectedIndex())); addRecordForm(); break; } case 1: { System.out.println("Stisknul jsi " + down.getString(down.getSelectedIndex())); showAllRecordForm(); break; } case 2: { System.out.println("Stisknul jsi " + down.getString(down.getSelectedIndex())); showFirstRecord(); break; } case 3: { System.out.println("Stisknul jsi " + down.getString(down.getSelectedIndex())); getNumberRecord(); break; } case 4: { System.out.println("Stisknul jsi " + down.getString(down.getSelectedIndex())); editRecord(1); break; } } } } if (c == cmdExit) { // rs.closeRecordStore(); notifyDestroyed(); } if (c == cmdMenu) { dsp.setCurrent(listMenu); } if (c == cmdEdit) { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); // filtr; filtr dostane pri vytvoreni stream jako parametr; // format dat nezavisly na platforme // definuje metodu write() pro vsechny primitivni typy DataOutputStream dout = new DataOutputStream(buffer); // byte [] data = txf.getString().getBytes(); try { dout.writeUTF(txfName.getString()); dout.writeInt(Integer.valueOf(txfNumber.getString()).intValue()); txfName.delete(0, txfName.size()); txfNumber.delete(0, txfNumber.size()); // zapise buffer do streamu dout.flush(); // prevod ByteArrayOutputStream na pole bytu; byte[] b = buffer.toByteArray(); rs.setRecord(1, b, 0, b.length); } catch (Exception e) { } finally { try { dout.close(); } catch (Exception e2) { } } } if (c == cmdAdd) { // vystupni stream; zapisuje do buferu v pamžti ByteArrayOutputStream buffer = new ByteArrayOutputStream(); // filtr; filtr dostane pri vytvoreni stream jako parametr; // format dat nezavisly na platforme // definuje metodu write() pro vsechny primitivni typy DataOutputStream dout = new DataOutputStream(buffer); // byte [] data = txf.getString().getBytes(); try { dout.writeUTF(txfName.getString()); dout.writeInt(Integer.valueOf(txfNumber.getString()).intValue()); txfName.delete(0, txfName.size()); txfNumber.delete(0, txfNumber.size()); // zapise buffer do streamu dout.flush(); // prevod ByteArrayOutputStream na pole bytu; byte[] b = buffer.toByteArray(); rs.addRecord(b, 0, b.length); } catch (Exception e) { } finally { try { dout.close(); } catch (Exception e2) { } } } }
private void showMessage(String msg) { Logger.debug(PanicConstants.TAG, "msg: " + msg); if (_display.getCurrent() == _tbMain) { try { _tbMain.setString(msg); } catch (Exception e) { e.printStackTrace(); } } else if (_display.getCurrent() == _lsCanvas) { _lsCanvas.setLargeString(msg); } }
/** Creates a new instance of PrivacyForm */ public PrivacyForm(Display display, PrivacyItem item, PrivacyList plist) { this.display = display; parentView = display.getCurrent(); this.item = item; targetList = plist; textValue = new TextField(null, item.value, 64, ConstMIDP.TEXTFIELD_URL); TextFieldCombo.setLowerCaseLatin(textValue); form.append(choiceAction); choiceAction.setSelectedIndex(item.action, true); form.append(choiseType); form.append(textValue); choiseType.setSelectedIndex(item.type, true); switchType(); form.append(choiseStanzas); choiseStanzas.setSelectedFlags(item.stanzasSet); // form.append("Order: "+item.order); form.setItemStateListener(this); form.setCommandListener(this); form.addCommand(cmdOk); form.addCommand(cmdCancel); display.setCurrent(form); }
private void createForm( final Display display, String room, String server, String nick, final String password) { this.display = display; parentView = display.getCurrent(); Form formJoin = new Form(SR.MS_JOIN_CONFERENCE); roomField = new TextField(SR.MS_ROOM, room, 64, ConstMIDP.TEXTFIELD_URL); TextFieldCombo.setLowerCaseLatin(roomField); formJoin.append(roomField); hostField = new TextField(SR.MS_AT_HOST, server, 64, ConstMIDP.TEXTFIELD_URL); TextFieldCombo.setLowerCaseLatin(hostField); formJoin.append(hostField); if (nick == null) nick = sd.account.getNickName(); nickField = new TextFieldCombo(SR.MS_NICKNAME, nick, 32, TextField.ANY, "roomnick", display); formJoin.append(nickField); passField = new TextField(SR.MS_PASSWORD, password, 32, TextField.ANY | ConstMIDP.TEXTFIELD_SENSITIVE); formJoin.append(passField); msgLimitField = new NumberField(SR.MS_MSG_LIMIT, 20, 0, 20); formJoin.append(msgLimitField); formJoin.addCommand(cmdJoin); // formJoin.addCommand(cmdBookmarks); formJoin.addCommand(cmdAdd); formJoin.addCommand(cmdCancel); formJoin.setCommandListener(this); display.setCurrent(formJoin); }
public void inquiryCompleted(int discType) { if (remote == null) { mDisplay.setCurrent(vorForm); // Wait until the canvas appears... // For Nokia it is not the same? while (mDisplay.getCurrent() != vorForm) ; messages.insert("No NXT Brick found", messages.size()); } else { try { remoteName = remote.getFriendlyName(false); messages.insert("Connecting to " + remoteName + "\n", messages.size()); } catch (IOException ioe) { System.out.println("error retrieving friendly name"); } try { // int[] attrs = {0x100}; // default attribute set plus service name UUID[] uuids = new UUID[] {new UUID(SERIALID)}; // Serial port service // agent.searchServices(attrs, uuids, remote, this); agent.searchServices(null, uuids, remote, this); } catch (BluetoothStateException bse) { System.out.println("service search failed"); } } }
/** * Creates an alert message on the phone. * * @param message The message to display. */ public void alertError(String message) { Alert alert = new Alert("Alert", message, null, AlertType.CONFIRMATION); Display display = Display.getDisplay(this.midlet); Displayable current = display.getCurrent(); if (!(current instanceof Alert)) { // This next call can't be done when current is an Alert display.setCurrent(alert, current); } try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } }
/** Creates a new instance of DiscoFeatures */ public DiscoFeatures(Display display, String entity, Vector features) { if (features.isEmpty()) return; list = new List(entity, List.IMPLICIT); for (Enumeration i = features.elements(); i.hasMoreElements(); ) { String feature = (String) (i.nextElement()); list.append(feature, null); } list.addCommand(cmdBack); list.addCommand(cmdOk); parentView = display.getCurrent(); this.display = display; list.setCommandListener(this); display.setCurrent(list); }
public void serviceSearchCompleted(int transID, int respCode) { if (respCode == DiscoveryListener.SERVICE_SEARCH_COMPLETED) { // !! This code must be divorced from NXTLocator canvas = new RemoteCanvas(remoteURL); mDisplay.setCurrent(canvas); } else { mDisplay.setCurrent(vorForm); while (mDisplay.getCurrent() != vorForm) ; switch (respCode) { case DiscoveryListener.SERVICE_SEARCH_TERMINATED: messages.insert("Error: Service search terminated", messages.size()); break; case DiscoveryListener.SERVICE_SEARCH_ERROR: messages.insert("Error: Service search error", messages.size()); break; case DiscoveryListener.SERVICE_SEARCH_NO_RECORDS: messages.insert("Error: Service search no records", messages.size()); break; case DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE: messages.insert("Error: Service search device not reachable", messages.size()); break; } } }
public ContactEdit(Display display, Contact c) { this.display = display; parentView = display.getCurrent(); StaticData sd = StaticData.getInstance(); roster = sd.roster; Vector groups = sd.roster.groups.getRosterGroupNames(); cf = Config.getInstance(); f = new Form(SR.MS_ADD_CONTACT); // locale tJid = new TextField(SR.MS_USER_JID, null, 150, TextField.EMAILADDR); tNick = new TextField("Name", null, 32, TextField.ANY); // locale tGroup = new TextField(SR.MS_GROUP, null, 32, TextField.ANY); // locale tGrpList = new ChoiceGroup(SR.MS_GROUP, ConstMIDP.CHOICE_POPUP); tTranspList = new ChoiceGroup(SR.MS_TRANSPORT, ConstMIDP.CHOICE_POPUP); tAskSubscrCheckBox = new ChoiceGroup(SR.MS_SUBSCRIPTION, ChoiceGroup.MULTIPLE); // locale tAskSubscrCheckBox.append(SR.MS_ASK_SUBSCRIPTION, null); // locale tGrpList.addCommand(cmdSet); tGrpList.setItemCommandListener(this); tTranspList.addCommand(cmdSet); tTranspList.setItemCommandListener(this); // Transport droplist tTranspList.append(sd.account.getServer(), null); for (Enumeration e = sd.roster.getHContacts().elements(); e.hasMoreElements(); ) { Contact ct = (Contact) e.nextElement(); Jid transpJid = ct.jid; if (transpJid.isTransport()) tTranspList.append(transpJid.getBareJid(), null); } tTranspList.append(SR.MS_OTHER, null); // locale try { String jid; if (c instanceof MucContact) { jid = Jid.toBareJid(((MucContact) c).realJid); } else { jid = c.getBareJid(); } // edit contact tJid.setString(jid); tNick.setString(c.nick); if (c instanceof MucContact) { c = null; throw new Exception(); } if (c.getGroupType() != Groups.TYPE_NOT_IN_LIST && c.getGroupType() != Groups.TYPE_SEARCH_RESULT) { // edit contact f.setTitle(jid); cmdOk = new Command("Update", Command.OK, 1); // locale newContact = false; } else c = null; // adding not-in-list } catch (Exception e) { c = null; } // if MucContact does not contains realJid int sel = -1; ngroups = 0; String grpName = ""; if (c != null) grpName = c.getGroup().name; if (groups != null) { ngroups = groups.size(); for (int i = 0; i < ngroups; i++) { String gn = (String) groups.elementAt(i); tGrpList.append(gn, null); if (gn.equals(grpName)) sel = i; } } // if (sel==-1) sel=groups.size()-1; if (sel < 0) sel = 0; // tGroup.setString(group(sel)); if (c == null) { f.append(tJid); f.append(tTranspList); } updateChoise(tJid.getString(), tTranspList); f.append(tNick); tGrpList.append(SR.MS_NEWGROUP, null); tGrpList.setSelectedIndex(sel, true); grpFIndex = f.append(tGrpList); if (newContact) { f.append(tAskSubscrCheckBox); tAskSubscrCheckBox.setSelectedIndex(0, true); } f.addCommand(cmdOk); f.addCommand(cmdCancel); f.setCommandListener(this); f.setItemStateListener(this); display.setCurrent(f); }
public boolean isCurrent(Display d) { return (d.getCurrent() == _f); }