コード例 #1
0
  /** Creates a new instance of AccountPicker */
  public AccountSelect(Display display, boolean enableQuit) {
    super();
    // this.display=display;

    setTitleItem(new Title(SR.MS_ACCOUNTS));

    accountList = new Vector();
    Account a;

    int index = 0;
    activeAccount = Config.getInstance().accountIndex;
    do {
      a = Account.createFromStorage(index);
      if (a != null) {
        accountList.addElement(a);
        a.active = (activeAccount == index);
        index++;
      }
    } while (a != null);
    if (accountList.isEmpty()) {
      a = Account.createFromJad();
      if (a != null) {
        // a.updateJidCache();
        accountList.addElement(a);
        rmsUpdate();
      }
    }
    attachDisplay(display);
    addCommand(cmdAdd);

    if (enableQuit) addCommand(cmdQuit);

    commandState();
    setCommandListener(this);
  }
コード例 #2
0
 void commandState() {
   if (accountList.isEmpty()) {
     removeCommand(cmdEdit);
     removeCommand(cmdDel);
     removeCommand(cmdSelect);
     removeCommand(cmdLogin);
     removeCommand(cmdCancel);
   } else {
     addCommand(cmdEdit);
     addCommand(cmdDel);
     addCommand(cmdLogin);
     addCommand(cmdSelect);
     if (activeAccount >= 0) addCommand(cmdCancel); // нельзя выйти без активного аккаунта
   }
 }
コード例 #3
0
 public void commandAction(Command c, Displayable d) {
   if (c == cmdQuit) {
     destroyView();
     Bombus.getInstance().notifyDestroyed();
   }
   if (c == cmdCancel) {
     destroyView();
     // Account.launchAccount();
     // StaticData.getInstance().account_index=0;
   }
   if (c == cmdLogin) switchAccount(true);
   if (c == cmdSelect) switchAccount(false);
   if (c == cmdEdit) new AccountForm(this, display, (Account) getFocusedObject());
   if (c == cmdAdd) {
     new AccountForm(this, display, null);
   }
   if (c == cmdDel) {
     accountList.removeElement(getFocusedObject());
     rmsUpdate();
     moveCursorHome();
     commandState();
     redraw();
   }
 }
コード例 #4
0
 void rmsUpdate() {
   DataOutputStream outputStream = NvStorage.CreateDataOutputStream();
   for (int i = 0; i < accountList.size(); i++)
     ((Account) accountList.elementAt(i)).saveToDataOutputStream(outputStream);
   NvStorage.writeFileRecord(outputStream, Account.storage, 0, true);
 }
コード例 #5
0
 protected int getItemCount() {
   return accountList.size();
 }
コード例 #6
0
 public VirtualElement getItemRef(int Index) {
   return (VirtualElement) accountList.elementAt(Index);
 }