Changeset 555


Ignore:
Timestamp:
11/22/09 15:47:25 (2 years ago)
Author:
octorian
Message:
 
Location:
trunk/LogicMail
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LogicMail/res/org/logicprobe/LogicMail/LogicMail.rrc

    r545 r555  
    4242CONFIG_GLOBAL_MESSAGE_ORDER#0="Message order:"; 
    4343CONFIG_GLOBAL_OVERRIDE_HOSTNAME#0="Override hostname"; 
     44CONFIG_GLOBAL_SECTION_MESSAGE_DISPLAY#0="Message display"; 
     45CONFIG_GLOBAL_SECTION_NETWORKING#0="Networking"; 
     46CONFIG_GLOBAL_SECTION_OTHER#0="Other"; 
    4447CONFIG_GLOBAL_SETTINGS#0="Global settings"; 
    4548CONFIG_GLOBAL_TITLE#0="Global"; 
  • trunk/LogicMail/res/org/logicprobe/LogicMail/LogicMail.rrh

    r545 r555  
    178178MENUITEM_SCROLL_DOWN#0=179; 
    179179MAILCONNECTION_REQUEST_MESSAGE_COPY#0=180; 
     180CONFIG_GLOBAL_SECTION_MESSAGE_DISPLAY#0=181; 
     181CONFIG_GLOBAL_SECTION_NETWORKING#0=182; 
     182CONFIG_GLOBAL_SECTION_OTHER#0=183; 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/ui/AccountConfigScreen.java

    r549 r555  
    6565 */ 
    6666public class AccountConfigScreen extends AbstractConfigScreen { 
    67         // Top-level fields 
     67    // Top-level fields 
    6868    private BasicEditField acctNameField; 
    69     private LabelField accountTypeLabel; 
    70         private ObjectChoiceField pageField; 
    71         private VerticalFieldManager contentFieldManager; 
    72          
    73         // Basic settings fields 
     69    private ObjectChoiceField pageField; 
     70    private VerticalFieldManager contentFieldManager; 
     71 
     72    // Basic settings fields 
    7473    private BasicEditField serverNameField; 
    7574    private ObjectChoiceField serverSecurityField; 
     
    8079    private ObjectChoiceField identityField; 
    8180    private ObjectChoiceField outgoingServerField; 
    82      
     81 
    8382    // Folder settings fields 
    8483    private LabelField sentFolderChoiceLabel; 
     
    8685    private LabelField draftFolderChoiceLabel; 
    8786    private LabelField draftFolderChoiceButtonLabel; 
    88      
     87 
    8988    // Advanced settings fields (IMAP) 
    9089    private BasicEditField imapFolderPrefixField; 
     
    9392    // Advanced settings fields (POP) 
    9493    private BasicEditField popMaxLinesEditField; 
    95      
    96         private Manager[] pageFieldManagers; 
     94 
     95    private Manager[] pageFieldManagers; 
    9796    private boolean acctSaved; 
    9897    private boolean createDefaultIdentity; 
     
    103102    private MailboxNode selectedDraftFolder; 
    104103    private FieldChangeListener fieldChangeListener; 
    105      
     104 
    106105    private class NullOutgoingConfig extends OutgoingConfig { 
    107106        public String toString() { 
     
    120119    public AccountConfigScreen(AccountConfig acctConfig) { 
    121120        super("LogicMail - " + resources.getString(LogicMailResource.CONFIG_ACCOUNT_TITLE)); 
    122          
     121 
    123122        this.acctConfig = acctConfig; 
    124123        this.acctSaved = false; 
    125          
     124 
    126125        MailSettings mailSettings = MailSettings.getInstance(); 
    127126 
     
    141140            this.setDirty(true); 
    142141        } 
    143          
     142 
    144143        int numOutgoing = mailSettings.getNumOutgoing(); 
    145144        outgoingConfigs = new OutgoingConfig[numOutgoing+1]; 
     
    148147            outgoingConfigs[i+1] = mailSettings.getOutgoingConfig(i); 
    149148        } 
    150          
     149 
    151150        fieldChangeListener = new FieldChangeListener() { 
    152151            public void fieldChanged(Field field, int context) { 
     
    154153            }}; 
    155154 
    156         initFields(); 
    157  
    158         IdentityConfig selectedIdentityConfig = acctConfig.getIdentityConfig(); 
    159         if(selectedIdentityConfig != null) { 
    160             identityField.setSelectedIndex(selectedIdentityConfig); 
    161         } 
    162  
    163         OutgoingConfig selectedOutgoingConfig = acctConfig.getOutgoingConfig(); 
    164         if(selectedOutgoingConfig != null) { 
    165             outgoingServerField.setSelectedIndex(selectedOutgoingConfig); 
    166         } 
     155            initFields(); 
     156 
     157            IdentityConfig selectedIdentityConfig = acctConfig.getIdentityConfig(); 
     158            if(selectedIdentityConfig != null) { 
     159                identityField.setSelectedIndex(selectedIdentityConfig); 
     160            } 
     161 
     162            OutgoingConfig selectedOutgoingConfig = acctConfig.getOutgoingConfig(); 
     163            if(selectedOutgoingConfig != null) { 
     164                outgoingServerField.setSelectedIndex(selectedOutgoingConfig); 
     165            } 
    167166    } 
    168167 
     
    171170     */ 
    172171    private void initFields() { 
    173         acctNameField = new BasicEditField(resources.getString(LogicMailResource.CONFIG_ACCOUNT_NAME) + ' ', acctConfig.getAcctName()); 
    174  
    175         String accountType = resources.getString(LogicMailResource.CONFIG_ACCOUNT_PROTOCOL); 
     172        String accountType; 
    176173        if(acctConfig instanceof ImapConfig) { 
    177                 accountType += " IMAP"; 
     174            accountType = "IMAP "; 
    178175        } 
    179176        else if(acctConfig instanceof PopConfig) { 
    180                 accountType += " POP"; 
    181         } 
    182         accountTypeLabel = new LabelField(accountType, Field.NON_FOCUSABLE); 
     177            accountType = "POP "; 
     178        } 
     179        else { 
     180            accountType = ""; 
     181        } 
    183182         
     183        acctNameField = new BasicEditField( 
     184                accountType 
     185                + resources.getString(LogicMailResource.CONFIG_ACCOUNT_NAME) 
     186                + ' ', 
     187                acctConfig.getAcctName()); 
     188 
    184189        pageField = new ObjectChoiceField( 
    185                         resources.getString(LogicMailResource.CONFIG_ACCOUNT_PAGE), 
    186                         new String[] { 
    187                                 resources.getString(LogicMailResource.CONFIG_ACCOUNT_PAGE_BASIC), 
    188                                 resources.getString(LogicMailResource.CONFIG_ACCOUNT_PAGE_FOLDER), 
    189                                 resources.getString(LogicMailResource.CONFIG_ACCOUNT_PAGE_ADVANCED) 
    190                         }); 
    191  
    192          
     190                resources.getString(LogicMailResource.CONFIG_ACCOUNT_PAGE), 
     191                new String[] { 
     192                    resources.getString(LogicMailResource.CONFIG_ACCOUNT_PAGE_BASIC), 
     193                    resources.getString(LogicMailResource.CONFIG_ACCOUNT_PAGE_FOLDER), 
     194                    resources.getString(LogicMailResource.CONFIG_ACCOUNT_PAGE_ADVANCED) 
     195                }); 
     196 
    193197        pageField.setChangeListener(fieldChangeListener); 
    194198 
    195         pageFieldManagers = new Manager[3]; 
    196         pageFieldManagers[0] = initFieldsBasic(); 
    197         pageFieldManagers[1] = initFieldsFolder(); 
    198         pageFieldManagers[2] = initFieldsAdvanced(); 
    199          
    200         // Container for the active settings page 
    201         contentFieldManager = new VerticalFieldManager(); 
    202         contentFieldManager.add(pageFieldManagers[0]); 
    203          
     199        pageFieldManagers = new Manager[3]; 
     200        pageFieldManagers[0] = initFieldsBasic(); 
     201        pageFieldManagers[1] = initFieldsFolder(); 
     202        pageFieldManagers[2] = initFieldsAdvanced(); 
     203 
     204        // Container for the active settings page 
     205        contentFieldManager = new VerticalFieldManager(); 
     206        contentFieldManager.add(pageFieldManagers[0]); 
     207 
    204208        add(acctNameField); 
    205         add(accountTypeLabel); 
    206209        add(pageField); 
    207210        add(new SeparatorField()); 
     
    209212        add(new LabelField()); 
    210213    } 
    211      
     214 
    212215    /** 
    213216     * Initializes the UI fields for the basic settings page. 
    214217     */ 
    215218    private Manager initFieldsBasic() { 
    216         Manager manager = new VerticalFieldManager(); 
     219        Manager manager = new VerticalFieldManager(); 
    217220        serverNameField = new BasicEditField(resources.getString(LogicMailResource.CONFIG_ACCOUNT_SERVER) + ' ', acctConfig.getServerName(), 
    218                         256, TextField.NO_NEWLINE); 
     221                256, TextField.NO_NEWLINE); 
    219222        serverSecurityField = new ObjectChoiceField( 
    220                         resources.getString(LogicMailResource.CONFIG_ACCOUNT_SECURITY), 
    221                         new Object[] { 
    222                                 resources.getString(LogicMailResource.CONFIG_ACCOUNT_SECURITY_NEVER), 
    223                                 resources.getString(LogicMailResource.CONFIG_ACCOUNT_SECURITY_TLS_IF_AVAILABLE), 
    224                                 resources.getString(LogicMailResource.CONFIG_ACCOUNT_SECURITY_TLS), 
    225                                 resources.getString(LogicMailResource.CONFIG_ACCOUNT_SECURITY_SSL)}, 
    226                         acctConfig.getServerSecurity()); 
     223                resources.getString(LogicMailResource.CONFIG_ACCOUNT_SECURITY), 
     224                new Object[] { 
     225                    resources.getString(LogicMailResource.CONFIG_ACCOUNT_SECURITY_NEVER), 
     226                    resources.getString(LogicMailResource.CONFIG_ACCOUNT_SECURITY_TLS_IF_AVAILABLE), 
     227                    resources.getString(LogicMailResource.CONFIG_ACCOUNT_SECURITY_TLS), 
     228                    resources.getString(LogicMailResource.CONFIG_ACCOUNT_SECURITY_SSL)}, 
     229                    acctConfig.getServerSecurity()); 
    227230        serverSecurityField.setChangeListener(fieldChangeListener); 
    228231        serverPortField = new BasicEditField(resources.getString(LogicMailResource.CONFIG_ACCOUNT_PORT) + ' ', Integer.toString(acctConfig.getServerPort()), 
    229                         5, TextField.NO_NEWLINE); 
     232                5, TextField.NO_NEWLINE); 
    230233        serverPortField.setFilter(TextFilter.get(TextFilter.NUMERIC)); 
    231234        serverUserField = new BasicEditField(resources.getString(LogicMailResource.CONFIG_ACCOUNT_USERNAME) + ' ', acctConfig.getServerUser(), 
    232                         256, TextField.NO_NEWLINE); 
     235                256, TextField.NO_NEWLINE); 
    233236        serverPassField = new PasswordEditField(resources.getString(LogicMailResource.CONFIG_ACCOUNT_PASSWORD) + ' ', acctConfig.getServerPass(), 
    234                         256, TextField.NO_NEWLINE); 
     237                256, TextField.NO_NEWLINE); 
    235238        useMdsField = new CheckboxField(resources.getString(LogicMailResource.CONFIG_ACCOUNT_USEMDSPROXY), !acctConfig.getDeviceSide()); 
    236239        identityField = new ObjectChoiceField(resources.getString(LogicMailResource.CONFIG_ACCOUNT_IDENTITY) + ' ', identityConfigs, 0); 
     
    247250        manager.add(identityField); 
    248251        manager.add(outgoingServerField); 
    249          
     252 
    250253        return manager; 
    251254    } 
    252      
     255 
    253256    /** 
    254257     * Initializes the UI fields for the folder settings page. 
    255258     */ 
    256259    private Manager initFieldsFolder() { 
    257         Manager manager = new VerticalFieldManager(); 
     260        Manager manager = new VerticalFieldManager(); 
    258261        selectedSentFolder = acctConfig.getSentMailbox(); 
    259262        selectedDraftFolder = acctConfig.getDraftMailbox(); 
    260          
     263 
    261264        sentFolderChoiceLabel = new LabelField(resources.getString(LogicMailResource.CONFIG_ACCOUNT_SENT_MESSAGE_FOLDER) + ' '); 
    262265        sentFolderChoiceButtonLabel = new LabelField(createSelectedMailboxString(selectedSentFolder), Field.FOCUSABLE | Field.HIGHLIGHT_FOCUS | Field.FIELD_RIGHT | LabelField.ELLIPSIS); 
     
    270273        return manager; 
    271274    } 
    272      
     275 
    273276    /** 
    274277     * Initializes the UI fields for the advanced settings page. 
    275278     */ 
    276279    private Manager initFieldsAdvanced() { 
    277         Manager manager = new VerticalFieldManager(); 
     280        Manager manager = new VerticalFieldManager(); 
    278281        if(acctConfig instanceof ImapConfig) { 
    279282            ImapConfig imapConfig = (ImapConfig)acctConfig; 
    280              
     283 
    281284            imapFolderPrefixField = new BasicEditField( 
    282                         resources.getString(LogicMailResource.CONFIG_ACCOUNT_IMAP_FOLDER_PREFIX) + ' ', 
    283                         imapConfig.getFolderPrefix()); 
    284  
    285             imapMaxMessageSizeEditField = new BasicEditField( 
    286                         resources.getString(LogicMailResource.CONFIG_ACCOUNT_IMAP_DOWNLOAD_LIMIT) + ' ', 
    287                     Integer.toString(imapConfig.getMaxMessageSize() / 1024)); 
    288             imapMaxMessageSizeEditField.setFilter(TextFilter.get(TextFilter.NUMERIC)); 
    289          
    290             imapMaxFolderDepthEditField = new BasicEditField( 
    291                         resources.getString(LogicMailResource.CONFIG_ACCOUNT_IMAP_FOLDER_LIMIT) + ' ', 
    292                     Integer.toString(imapConfig.getMaxFolderDepth())); 
    293             imapMaxFolderDepthEditField.setFilter(TextFilter.get(TextFilter.NUMERIC)); 
    294              
     285                    resources.getString(LogicMailResource.CONFIG_ACCOUNT_IMAP_FOLDER_PREFIX) + ' ', 
     286                    imapConfig.getFolderPrefix()); 
     287 
     288            imapMaxMessageSizeEditField = new BasicEditField( 
     289                    resources.getString(LogicMailResource.CONFIG_ACCOUNT_IMAP_DOWNLOAD_LIMIT) + ' ', 
     290                    Integer.toString(imapConfig.getMaxMessageSize() / 1024)); 
     291            imapMaxMessageSizeEditField.setFilter(TextFilter.get(TextFilter.NUMERIC)); 
     292 
     293            imapMaxFolderDepthEditField = new BasicEditField( 
     294                    resources.getString(LogicMailResource.CONFIG_ACCOUNT_IMAP_FOLDER_LIMIT) + ' ', 
     295                    Integer.toString(imapConfig.getMaxFolderDepth())); 
     296            imapMaxFolderDepthEditField.setFilter(TextFilter.get(TextFilter.NUMERIC)); 
     297 
    295298            manager.add(imapFolderPrefixField); 
    296299            manager.add(imapMaxMessageSizeEditField); 
     
    298301        } 
    299302        else if(acctConfig instanceof PopConfig) { 
    300                 PopConfig popConfig = (PopConfig)acctConfig; 
    301                  
    302             popMaxLinesEditField = new BasicEditField( 
    303                         resources.getString(LogicMailResource.CONFIG_ACCOUNT_POP_DOWNLOAD_LIMIT) + ' ', 
    304                     Integer.toString(popConfig.getMaxMessageLines())); 
    305             popMaxLinesEditField.setFilter(TextFilter.get(TextFilter.NUMERIC)); 
    306              
    307             manager.add(popMaxLinesEditField); 
    308         } 
    309         return manager; 
    310     } 
    311      
     303            PopConfig popConfig = (PopConfig)acctConfig; 
     304 
     305            popMaxLinesEditField = new BasicEditField( 
     306                    resources.getString(LogicMailResource.CONFIG_ACCOUNT_POP_DOWNLOAD_LIMIT) + ' ', 
     307                    Integer.toString(popConfig.getMaxMessageLines())); 
     308            popMaxLinesEditField.setFilter(TextFilter.get(TextFilter.NUMERIC)); 
     309 
     310            manager.add(popMaxLinesEditField); 
     311        } 
     312        return manager; 
     313    } 
     314 
    312315    public void AcctCfgScreen_fieldChanged(Field field, int context) { 
    313316        if(field == serverSecurityField) { 
     
    330333        } 
    331334        else if(field == pageField) { 
    332                 int index = pageField.getSelectedIndex(); 
    333                 if(contentFieldManager.getField(0) != pageFieldManagers[index]) { 
    334                         contentFieldManager.deleteAll(); 
    335                         contentFieldManager.add(pageFieldManagers[index]); 
    336                 } 
     335            int index = pageField.getSelectedIndex(); 
     336            if(contentFieldManager.getField(0) != pageFieldManagers[index]) { 
     337                contentFieldManager.deleteAll(); 
     338                contentFieldManager.add(pageFieldManagers[index]); 
     339            } 
    337340        } 
    338341    } 
     
    342345     */ 
    343346    protected boolean trackwheelUnclick(int status, int time) { 
    344         if(getFieldWithFocus() == contentFieldManager && contentFieldManager.getField(0) == pageFieldManagers[1]) { 
    345                 if(pageFieldManagers[1].getFieldWithFocus() == sentFolderChoiceButtonLabel) { 
    346                         showFolderSelection(sentFolderChoiceButtonLabel); 
    347                         return true; 
    348                 } 
    349                 else if(pageFieldManagers[1].getFieldWithFocus() == draftFolderChoiceButtonLabel) { 
    350                         showFolderSelection(draftFolderChoiceButtonLabel); 
    351                         return true; 
    352                 } 
    353                 else { 
    354                         return super.trackwheelUnclick(status, time); 
    355                 } 
    356         } 
    357         else { 
    358                 return super.trackwheelUnclick(status, time); 
    359         } 
    360     } 
    361      
     347        if(getFieldWithFocus() == contentFieldManager && contentFieldManager.getField(0) == pageFieldManagers[1]) { 
     348            if(pageFieldManagers[1].getFieldWithFocus() == sentFolderChoiceButtonLabel) { 
     349                showFolderSelection(sentFolderChoiceButtonLabel); 
     350                return true; 
     351            } 
     352            else if(pageFieldManagers[1].getFieldWithFocus() == draftFolderChoiceButtonLabel) { 
     353                showFolderSelection(draftFolderChoiceButtonLabel); 
     354                return true; 
     355            } 
     356            else { 
     357                return super.trackwheelUnclick(status, time); 
     358            } 
     359        } 
     360        else { 
     361            return super.trackwheelUnclick(status, time); 
     362        } 
     363    } 
     364 
    362365    private void showFolderSelection(LabelField choiceButtonLabel) { 
    363         String titleText; 
    364         if(choiceButtonLabel == sentFolderChoiceButtonLabel) { 
    365                 titleText = resources.getString(LogicMailResource.CONFIG_ACCOUNT_SENT_MESSAGE_FOLDER);  
    366         } 
    367         else if(choiceButtonLabel == draftFolderChoiceButtonLabel) { 
    368                 titleText = resources.getString(LogicMailResource.CONFIG_ACCOUNT_DRAFT_MESSAGE_FOLDER); 
    369         } 
    370         else { 
    371                 return; 
    372         } 
    373          
    374         // Build an array containing the current account node, if it already exists, 
    375         // and any local account nodes. 
    376         AccountNode[] accountNodes = MailManager.getInstance().getMailRootNode().getAccounts(); 
    377         Vector accountNodeVector = new Vector(); 
    378         for(int i=0; i<accountNodes.length; i++) { 
    379                 if(accountNodes[i].getStatus() == AccountNode.STATUS_LOCAL || 
    380                            accountNodes[i].getAccountConfig() == acctConfig) { 
    381                         accountNodeVector.addElement(accountNodes[i]); 
    382                 } 
    383         } 
    384         accountNodes = new AccountNode[accountNodeVector.size()]; 
    385         accountNodeVector.copyInto(accountNodes); 
    386          
    387         MailboxSelectionDialog dialog = new MailboxSelectionDialog(titleText, accountNodes); 
    388         if(choiceButtonLabel == sentFolderChoiceButtonLabel) { 
    389                 dialog.setSelectedMailboxNode(selectedSentFolder); 
    390         } 
    391         else if(choiceButtonLabel == draftFolderChoiceButtonLabel) { 
    392                 dialog.setSelectedMailboxNode(selectedDraftFolder); 
    393         } 
    394         dialog.doModal(); 
    395          
    396         MailboxNode selectedNode = dialog.getSelectedMailboxNode(); 
    397         if(selectedNode != null) { 
    398                 choiceButtonLabel.setText(createSelectedMailboxString(selectedNode)); 
    399                 if(choiceButtonLabel == sentFolderChoiceButtonLabel) { 
    400                         if(selectedSentFolder != selectedNode) { 
    401                                 selectedSentFolder = selectedNode; 
    402                                 this.setDirty(true); 
    403                         } 
    404                 } 
    405                 else if(choiceButtonLabel == draftFolderChoiceButtonLabel) { 
    406                         if(selectedDraftFolder != selectedNode) { 
    407                                 selectedDraftFolder = selectedNode; 
    408                                 this.setDirty(true); 
    409                         } 
    410                 } 
    411         } 
    412     } 
    413      
     366        String titleText; 
     367        if(choiceButtonLabel == sentFolderChoiceButtonLabel) { 
     368            titleText = resources.getString(LogicMailResource.CONFIG_ACCOUNT_SENT_MESSAGE_FOLDER);  
     369        } 
     370        else if(choiceButtonLabel == draftFolderChoiceButtonLabel) { 
     371            titleText = resources.getString(LogicMailResource.CONFIG_ACCOUNT_DRAFT_MESSAGE_FOLDER); 
     372        } 
     373        else { 
     374            return; 
     375        } 
     376 
     377        // Build an array containing the current account node, if it already exists, 
     378        // and any local account nodes. 
     379        AccountNode[] accountNodes = MailManager.getInstance().getMailRootNode().getAccounts(); 
     380        Vector accountNodeVector = new Vector(); 
     381        for(int i=0; i<accountNodes.length; i++) { 
     382            if(accountNodes[i].getStatus() == AccountNode.STATUS_LOCAL || 
     383                    accountNodes[i].getAccountConfig() == acctConfig) { 
     384                accountNodeVector.addElement(accountNodes[i]); 
     385            } 
     386        } 
     387        accountNodes = new AccountNode[accountNodeVector.size()]; 
     388        accountNodeVector.copyInto(accountNodes); 
     389 
     390        MailboxSelectionDialog dialog = new MailboxSelectionDialog(titleText, accountNodes); 
     391        if(choiceButtonLabel == sentFolderChoiceButtonLabel) { 
     392            dialog.setSelectedMailboxNode(selectedSentFolder); 
     393        } 
     394        else if(choiceButtonLabel == draftFolderChoiceButtonLabel) { 
     395            dialog.setSelectedMailboxNode(selectedDraftFolder); 
     396        } 
     397        dialog.doModal(); 
     398 
     399        MailboxNode selectedNode = dialog.getSelectedMailboxNode(); 
     400        if(selectedNode != null) { 
     401            choiceButtonLabel.setText(createSelectedMailboxString(selectedNode)); 
     402            if(choiceButtonLabel == sentFolderChoiceButtonLabel) { 
     403                if(selectedSentFolder != selectedNode) { 
     404                    selectedSentFolder = selectedNode; 
     405                    this.setDirty(true); 
     406                } 
     407            } 
     408            else if(choiceButtonLabel == draftFolderChoiceButtonLabel) { 
     409                if(selectedDraftFolder != selectedNode) { 
     410                    selectedDraftFolder = selectedNode; 
     411                    this.setDirty(true); 
     412                } 
     413            } 
     414        } 
     415    } 
     416 
    414417    private String createSelectedMailboxString(MailboxNode mailboxNode) { 
    415                 StringBuffer buf = new StringBuffer(); 
    416         if(mailboxNode != null) { 
    417                         buf.append(mailboxNode.getParentAccount().toString()); 
    418                         buf.append(": "); 
    419                         buf.append(mailboxNode.toString()); 
    420         } 
    421         else { 
    422                 buf.append('<' + resources.getString(LogicMailResource.CONFIG_ACCOUNT_NONE) + '>'); 
    423         } 
    424                 return buf.toString(); 
    425     } 
    426      
     418        StringBuffer buf = new StringBuffer(); 
     419        if(mailboxNode != null) { 
     420            buf.append(mailboxNode.getParentAccount().toString()); 
     421            buf.append(": "); 
     422            buf.append(mailboxNode.toString()); 
     423        } 
     424        else { 
     425            buf.append('<' + resources.getString(LogicMailResource.CONFIG_ACCOUNT_NONE) + '>'); 
     426        } 
     427        return buf.toString(); 
     428    } 
     429 
    427430    /** 
    428431     * Determines if this screen is dirty. 
     
    433436     */ 
    434437    public boolean isDirty() { 
    435         if(acctNameField.isDirty()) { return true; } 
    436          
    437         for(int i=0; i<pageFieldManagers.length; i++) { 
    438                 if(pageFieldManagers[i].isDirty()) { 
    439                         return true; 
    440                 } 
    441         } 
    442          
    443         return false; 
    444     } 
    445      
     438        if(acctNameField.isDirty()) { return true; } 
     439 
     440        for(int i=0; i<pageFieldManagers.length; i++) { 
     441            if(pageFieldManagers[i].isDirty()) { 
     442                return true; 
     443            } 
     444        } 
     445 
     446        return false; 
     447    } 
     448 
    446449    /* (non-Javadoc) 
    447450     * @see net.rim.device.api.ui.container.MainScreen#onSavePrompt() 
     
    449452    protected boolean onSavePrompt() { 
    450453        if(acctNameField.getText().length() > 0 && 
    451            serverNameField.getText().length() > 0 && 
    452            serverPortField.getText().length() > 0) { 
     454                serverNameField.getText().length() > 0 && 
     455                serverPortField.getText().length() > 0) { 
    453456            return super.onSavePrompt(); 
    454457        } 
    455458        else { 
    456459            int result = 
    457                 Dialog.ask(resources.getString(LogicMailResource.CONFIG_PROMPT_INCOMPLETE), 
    458                                 new String[] { 
    459                                         resources.getString(LogicMailResource.MENUITEM_DISCARD), 
    460                                         resources.getString(LogicMailResource.MENUITEM_CANCEL) }, 0); 
     460                Dialog.ask(resources.getString(LogicMailResource.CONFIG_PROMPT_INCOMPLETE), 
     461                        new String[] { 
     462                    resources.getString(LogicMailResource.MENUITEM_DISCARD), 
     463                    resources.getString(LogicMailResource.MENUITEM_CANCEL) }, 0); 
    461464            if(result == 0) { 
    462465                return true; 
     
    479482        this.acctConfig.setServerPass(serverPassField.getText()); 
    480483        this.acctConfig.setDeviceSide(!useMdsField.getChecked()); 
    481          
     484 
    482485        IdentityConfig selectedIdentityConfig = (IdentityConfig)identityField.getChoice(identityField.getSelectedIndex()); 
    483486        if(createDefaultIdentity) { 
     
    486489                userName = "user"; 
    487490            } 
    488             selectedIdentityConfig.setEmailAddress(userName + "@" + serverNameField.getText()); 
     491            selectedIdentityConfig.setEmailAddress(userName + '@' + serverNameField.getText()); 
    489492            MailSettings.getInstance().addIdentityConfig(selectedIdentityConfig); 
    490493            createDefaultIdentity = false; 
     
    505508        if(acctConfig instanceof ImapConfig) { 
    506509            ImapConfig imapConfig = (ImapConfig)acctConfig; 
    507              
     510 
    508511            String folderPrefix = imapFolderPrefixField.getText().trim(); 
    509512            if(folderPrefix.length() == 0) { 
     
    515518 
    516519            try { 
    517                 imapConfig.setMaxMessageSize(Integer.parseInt( 
     520                imapConfig.setMaxMessageSize(Integer.parseInt( 
    518521                        imapMaxMessageSizeEditField.getText()) * 1024); 
    519522            } catch (Exception e) { } 
    520523 
    521524            try { 
    522                 imapConfig.setMaxFolderDepth(Integer.parseInt( 
     525                imapConfig.setMaxFolderDepth(Integer.parseInt( 
    523526                        imapMaxFolderDepthEditField.getText())); 
    524527            } catch (Exception e) { } 
    525528        } 
    526529        else if(acctConfig instanceof PopConfig) { 
    527                 PopConfig popConfig = (PopConfig)acctConfig; 
    528                  
     530            PopConfig popConfig = (PopConfig)acctConfig; 
     531 
    529532            try { 
    530                 popConfig.setMaxMessageLines(Integer.parseInt(popMaxLinesEditField.getText())); 
     533                popConfig.setMaxMessageLines(Integer.parseInt(popMaxLinesEditField.getText())); 
    531534            } catch (Exception e) { } 
    532535        } 
    533          
     536 
    534537        acctSaved = true; 
    535538    } 
    536      
     539 
    537540    public boolean acctSaved() { 
    538541        return acctSaved; 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/ui/ConfigScreen.java

    r549 r555  
    7070    private Hashtable outgoingIndexMap; 
    7171    private boolean configurationChanged; 
    72      
     72 
    7373    /** 
    7474     * Instantiates a new configuration screen. 
     
    8080        accountIndexMap = new Hashtable(); 
    8181        outgoingIndexMap = new Hashtable(); 
    82          
     82 
    8383        initFields(); 
    84          
     84 
    8585        buildAccountsList(); 
    8686    } 
    87      
     87 
    8888    /** 
    8989     * Initializes the fields. 
     
    9191    private void initFields() { 
    9292        configTreeField = FieldFactory.getInstance().getScreenTreeField( 
    93             new TreeFieldCallback() { 
    94                 public void drawTreeItem(TreeField treeField, Graphics graphics, int node, int y, int width, int indent) { 
    95                     configTreeFieldDrawTreeItem(treeField, graphics, node, y, width, indent); 
    96                 } 
    97             }, 
    98             Field.FOCUSABLE); 
     93                new TreeFieldCallback() { 
     94                    public void drawTreeItem(TreeField treeField, Graphics graphics, int node, int y, int width, int indent) { 
     95                        configTreeFieldDrawTreeItem(treeField, graphics, node, y, width, indent); 
     96                    } 
     97                }, 
     98                Field.FOCUSABLE); 
    9999        configTreeField.setDefaultExpanded(true); 
    100100        configTreeField.setIndentWidth(20); 
    101          
     101 
    102102        globalId = configTreeField.addChildNode(0, new ConfigTreeNode(resources.getString(LogicMailResource.CONFIG_GLOBAL_SETTINGS))); 
    103103        identitiesId = configTreeField.addSiblingNode(globalId, new ConfigTreeNode(resources.getString(LogicMailResource.CONFIG_IDENTITIES))); 
     
    112112     */ 
    113113    protected void onDisplay() { 
    114                 configurationChanged = false; 
    115         super.onDisplay(); 
    116         } 
    117          
    118         /* (non-Javadoc) 
    119         * @see net.rim.device.api.ui.Screen#onUndisplay() 
    120         */ 
    121         protected void onUndisplay() { 
    122                 if(configurationChanged) { 
    123                         configurationChanged = false; 
    124                 } 
    125                 super.onUndisplay(); 
    126         } 
    127      
     114        configurationChanged = false; 
     115        super.onDisplay(); 
     116    } 
     117 
     118    /* (non-Javadoc) 
     119    * @see net.rim.device.api.ui.Screen#onUndisplay() 
     120    */ 
     121    protected void onUndisplay() { 
     122        if(configurationChanged) { 
     123            configurationChanged = false; 
     124        } 
     125        super.onUndisplay(); 
     126    } 
     127 
    128128    /** 
    129129     * Draws tree items in the TreeField 
     
    140140        graphics.drawText(cookie.toString(), indent + 2, y, Graphics.ELLIPSIS, width); 
    141141    } 
    142      
     142 
    143143    private MenuItem selectItem = new MenuItem(resources, LogicMailResource.MENUITEM_EDIT, 100, 10) { 
    144144        public void run() { 
     
    161161    private MenuItem newAccountWizardItem = new MenuItem(resources, LogicMailResource.MENUITEM_NEW_ACCOUNT_WIZARD, 110, 10) { 
    162162        public void run() { 
    163                 newAccountWizard(); 
    164         } 
    165     }; 
    166      
     163            newAccountWizard(); 
     164        } 
     165    }; 
     166 
    167167    private MenuItem addIdentityItem = new MenuItem(resources, LogicMailResource.MENUITEM_ADD_IDENTITY, 120, 10) { 
    168168        public void run() { 
     
    206206    protected void makeMenu(Menu menu, int instance) { 
    207207        int id = configTreeField.getCurrentNode(); 
    208          
     208 
    209209        Object cookie; 
    210210        Object rawCookie = configTreeField.getCookie(id); 
    211211        if(rawCookie instanceof ConfigTreeNode) { 
    212                 cookie = ((ConfigTreeNode)rawCookie).cookie; 
     212            cookie = ((ConfigTreeNode)rawCookie).cookie; 
    213213        } 
    214214        else { 
    215                 cookie = null; 
    216         } 
    217          
     215            cookie = null; 
     216        } 
     217 
    218218        if(id != identitiesId && id != accountsId && id != outgoingId) { 
    219219            menu.add(selectItem); 
    220220            if(cookie instanceof ConnectionConfig) { 
    221                     if(configTreeField.getPreviousSibling(id) != -1) { 
    222                         menu.add(moveUpItem); 
    223                     } 
    224                     if(configTreeField.getNextSibling(id) != -1) { 
    225                         menu.add(moveDownItem); 
    226                     } 
     221                if(configTreeField.getPreviousSibling(id) != -1) { 
     222                    menu.add(moveUpItem); 
     223                } 
     224                if(configTreeField.getNextSibling(id) != -1) { 
     225                    menu.add(moveDownItem); 
     226                } 
    227227            } 
    228228            menu.addSeparator(); 
    229229        } 
    230          
     230 
    231231        if(id == identitiesId) { 
    232232            menu.add(addIdentityItem); 
     
    237237        } 
    238238        else if(id == accountsId) { 
    239                 menu.add(newAccountWizardItem); 
     239            menu.add(newAccountWizardItem); 
    240240            menu.add(addAccountItem); 
    241241        } 
    242242        else if(cookie instanceof AccountConfig) { 
    243                 menu.add(newAccountWizardItem); 
     243            menu.add(newAccountWizardItem); 
    244244            menu.add(addAccountItem); 
    245245            menu.add(deleteAccountItem); 
     
    254254        super.makeMenu(menu, instance); 
    255255    } 
    256      
    257         /* (non-Javadoc) 
     256 
     257    /* (non-Javadoc) 
    258258     * @see net.rim.device.api.ui.Screen#keyChar(char, int, int) 
    259259     */ 
     
    261261        boolean retval = false; 
    262262        switch(key) { 
    263             case Keypad.KEY_SPACE: 
    264                 toggleSelectedNode(); 
    265                 retval = true; 
    266                 break; 
    267             case Keypad.KEY_ENTER: 
    268                 openSelectedNode(); 
    269                 retval = true; 
    270                 break; 
     263        case Keypad.KEY_SPACE: 
     264            toggleSelectedNode(); 
     265            retval = true; 
     266            break; 
     267        case Keypad.KEY_ENTER: 
     268            openSelectedNode(); 
     269            retval = true; 
     270            break; 
    271271        } 
    272272        return retval; 
    273273    } 
    274      
     274 
    275275    /* (non-Javadoc) 
    276276     * @see net.rim.device.api.ui.Screen#navigationClick(int, int) 
    277277     */ 
    278278    protected boolean navigationClick(int status, int time) { 
    279         return openSelectedNode(); 
    280     } 
    281      
     279        return openSelectedNode(); 
     280    } 
     281 
    282282    /** 
    283283     * Toggle selected node's expansion state 
     
    285285    private void toggleSelectedNode() { 
    286286        int curNode = configTreeField.getCurrentNode(); 
    287          
     287 
    288288        // Make sure a node is selected 
    289289        if(curNode == -1) { 
    290290            return; 
    291291        } 
    292          
     292 
    293293        // Make sure the selected node has children 
    294294        if(configTreeField.getFirstChild(curNode) == -1) { 
     
    299299        configTreeField.setExpanded(curNode, !configTreeField.getExpanded(curNode)); 
    300300    } 
    301      
     301 
    302302    /** 
    303303     * Open selected node. 
     
    306306     */ 
    307307    private boolean openSelectedNode() { 
    308         boolean result = false; 
     308        boolean result = false; 
    309309        int curNode = configTreeField.getCurrentNode(); 
    310310        if(curNode == globalId) { 
     
    347347        } 
    348348        if(result) { 
    349                 buildAccountsList(); 
     349            buildAccountsList(); 
    350350        } 
    351351        return result; 
    352352    } 
    353353 
    354         private void moveSelectedNodeUp() { 
     354    private void moveSelectedNodeUp() { 
    355355        int curNode = configTreeField.getCurrentNode(); 
    356356        if(curNode == -1) { return; } 
     
    360360        Object cookie = ((ConfigTreeNode)configTreeField.getCookie(curNode)).cookie; 
    361361        Object prevCookie = ((ConfigTreeNode)configTreeField.getCookie(prevNode)).cookie; 
    362          
     362 
    363363        boolean result = false; 
    364          
     364 
    365365        if(cookie instanceof IdentityConfig) { 
    366                 IdentityConfig curConfig = (IdentityConfig)cookie; 
    367                 IdentityConfig prevConfig = (IdentityConfig)prevCookie; 
    368                  
    369                 int curConfigIndex = mailSettings.indexOfIdentityConfig(curConfig); 
    370                 mailSettings.removeAccountConfig(curConfigIndex); 
    371  
    372                 int prevConfigIndex = mailSettings.indexOfIdentityConfig(prevConfig); 
    373                 mailSettings.insertIdentityConfigAt(curConfig, prevConfigIndex); 
    374                 result = true; 
     366            IdentityConfig curConfig = (IdentityConfig)cookie; 
     367            IdentityConfig prevConfig = (IdentityConfig)prevCookie; 
     368 
     369            int curConfigIndex = mailSettings.indexOfIdentityConfig(curConfig); 
     370            mailSettings.removeAccountConfig(curConfigIndex); 
     371 
     372            int prevConfigIndex = mailSettings.indexOfIdentityConfig(prevConfig); 
     373            mailSettings.insertIdentityConfigAt(curConfig, prevConfigIndex); 
     374            result = true; 
    375375        } 
    376376        else if(cookie instanceof AccountConfig) { 
    377                 AccountConfig curConfig = (AccountConfig)cookie; 
    378                 AccountConfig prevConfig = (AccountConfig)prevCookie; 
    379                  
    380                 int curConfigIndex = mailSettings.indexOfAccountConfig(curConfig); 
    381                 mailSettings.removeAccountConfig(curConfigIndex); 
    382  
    383                 int prevConfigIndex = mailSettings.indexOfAccountConfig(prevConfig); 
    384                 mailSettings.insertAccountConfigAt(curConfig, prevConfigIndex); 
    385                 result = true; 
     377            AccountConfig curConfig = (AccountConfig)cookie; 
     378            AccountConfig prevConfig = (AccountConfig)prevCookie; 
     379 
     380            int curConfigIndex = mailSettings.indexOfAccountConfig(curConfig); 
     381            mailSettings.removeAccountConfig(curConfigIndex); 
     382 
     383            int prevConfigIndex = mailSettings.indexOfAccountConfig(prevConfig); 
     384            mailSettings.insertAccountConfigAt(curConfig, prevConfigIndex); 
     385            result = true; 
    386386        } 
    387387        else if(cookie instanceof OutgoingConfig) { 
    388                 OutgoingConfig curConfig = (OutgoingConfig)cookie; 
    389                 OutgoingConfig prevConfig = (OutgoingConfig)prevCookie; 
    390                  
    391                 int curConfigIndex = mailSettings.indexOfOutgoingConfig(curConfig); 
    392                 mailSettings.removeAccountConfig(curConfigIndex); 
    393  
    394                 int prevConfigIndex = mailSettings.indexOfOutgoingConfig(prevConfig); 
    395                 mailSettings.insertOutgoingConfigAt(curConfig, prevConfigIndex); 
    396                 result = true; 
    397         } 
    398          
     388            OutgoingConfig curConfig = (OutgoingConfig)cookie; 
     389            OutgoingConfig prevConfig = (OutgoingConfig)prevCookie; 
     390 
     391            int curConfigIndex = mailSettings.indexOfOutgoingConfig(curConfig); 
     392            mailSettings.removeAccountConfig(curConfigIndex); 
     393 
     394            int prevConfigIndex = mailSettings.indexOfOutgoingConfig(prevConfig); 
     395            mailSettings.insertOutgoingConfigAt(curConfig, prevConfigIndex); 
     396            result = true; 
     397        } 
     398 
    399399        if(result) { 
    400400            mailSettings.saveSettings(); 
    401401            configurationChanged = true; 
    402                 buildAccountsList(); 
    403         } 
    404         } 
    405  
    406         private void moveSelectedNodeDown() { 
     402            buildAccountsList(); 
     403        } 
     404    } 
     405 
     406    private void moveSelectedNodeDown() { 
    407407        int curNode = configTreeField.getCurrentNode(); 
    408408        if(curNode == -1) { return; } 
     
    412412        Object cookie = ((ConfigTreeNode)configTreeField.getCookie(curNode)).cookie; 
    413413        Object nextCookie = ((ConfigTreeNode)configTreeField.getCookie(nextNode)).cookie; 
    414          
     414 
    415415        boolean result = false; 
    416416 
    417417        if(cookie instanceof IdentityConfig) { 
    418                 IdentityConfig curConfig = (IdentityConfig)cookie; 
    419                 IdentityConfig nextConfig = (IdentityConfig)nextCookie; 
    420                  
    421                 int curConfigIndex = mailSettings.indexOfIdentityConfig(curConfig); 
    422                 mailSettings.removeAccountConfig(curConfigIndex); 
    423  
    424                 int nextConfigIndex = mailSettings.indexOfIdentityConfig(nextConfig); 
    425                 mailSettings.insertIdentityConfigAt(curConfig, nextConfigIndex + 1); 
    426                 result = true; 
     418            IdentityConfig curConfig = (IdentityConfig)cookie; 
     419            IdentityConfig nextConfig = (IdentityConfig)nextCookie; 
     420 
     421            int curConfigIndex = mailSettings.indexOfIdentityConfig(curConfig); 
     422            mailSettings.removeAccountConfig(curConfigIndex); 
     423 
     424            int nextConfigIndex = mailSettings.indexOfIdentityConfig(nextConfig); 
     425            mailSettings.insertIdentityConfigAt(curConfig, nextConfigIndex + 1); 
     426            result = true; 
    427427        } 
    428428        else if(cookie instanceof AccountConfig) { 
    429                 AccountConfig curConfig = (AccountConfig)cookie; 
    430                 AccountConfig nextConfig = (AccountConfig)nextCookie; 
    431                  
    432                 int curConfigIndex = mailSettings.indexOfAccountConfig(curConfig); 
    433                 mailSettings.removeAccountConfig(curConfigIndex); 
    434  
    435                 int nextConfigIndex = mailSettings.indexOfAccountConfig(nextConfig); 
    436                 mailSettings.insertAccountConfigAt(curConfig, nextConfigIndex + 1); 
    437                 result = true; 
     429            AccountConfig curConfig = (AccountConfig)cookie; 
     430            AccountConfig nextConfig = (AccountConfig)nextCookie; 
     431 
     432            int curConfigIndex = mailSettings.indexOfAccountConfig(curConfig); 
     433            mailSettings.removeAccountConfig(curConfigIndex); 
     434 
     435            int nextConfigIndex = mailSettings.indexOfAccountConfig(nextConfig); 
     436            mailSettings.insertAccountConfigAt(curConfig, nextConfigIndex + 1); 
     437            result = true; 
    438438        } 
    439439        else if(cookie instanceof OutgoingConfig) { 
    440                 OutgoingConfig curConfig = (OutgoingConfig)cookie; 
    441                 OutgoingConfig nextConfig = (OutgoingConfig)nextCookie; 
    442                  
    443                 int curConfigIndex = mailSettings.indexOfOutgoingConfig(curConfig); 
    444                 mailSettings.removeAccountConfig(curConfigIndex); 
    445  
    446                 int nextConfigIndex = mailSettings.indexOfOutgoingConfig(nextConfig); 
    447                 mailSettings.insertOutgoingConfigAt(curConfig, nextConfigIndex + 1); 
    448                 result = true; 
    449         } 
    450          
     440            OutgoingConfig curConfig = (OutgoingConfig)cookie; 
     441            OutgoingConfig nextConfig = (OutgoingConfig)nextCookie; 
     442 
     443            int curConfigIndex = mailSettings.indexOfOutgoingConfig(curConfig); 
     444            mailSettings.removeAccountConfig(curConfigIndex); 
     445 
     446            int nextConfigIndex = mailSettings.indexOfOutgoingConfig(nextConfig); 
     447            mailSettings.insertOutgoingConfigAt(curConfig, nextConfigIndex + 1); 
     448            result = true; 
     449        } 
     450 
    451451        if(result) { 
    452452            mailSettings.saveSettings(); 
    453453            configurationChanged = true; 
    454                 buildAccountsList(); 
    455         } 
    456         } 
     454            buildAccountsList(); 
     455        } 
     456    } 
    457457 
    458458    /** 
     
    460460     */ 
    461461    private void buildAccountsList() { 
    462         Object curCookie; 
    463         int curNode = configTreeField.getCurrentNode(); 
    464         if(curNode != -1) { 
    465                 curCookie = ((ConfigTreeNode)configTreeField.getCookie(curNode)).cookie; 
    466         } 
    467         else { 
    468                 curCookie = null; 
    469         } 
    470          
     462        Object curCookie; 
     463        int curNode = configTreeField.getCurrentNode(); 
     464        if(curNode != -1) { 
     465            curCookie = ((ConfigTreeNode)configTreeField.getCookie(curNode)).cookie; 
     466        } 
     467        else { 
     468            curCookie = null; 
     469        } 
     470 
    471471        int numIdentities = mailSettings.getNumIdentities(); 
    472472        identityIndexMap.clear(); 
     
    485485            configTreeField.deleteSubtree(id); 
    486486        } 
    487          
     487 
    488488        IdentityConfig identityConfig; 
    489489        for(int i = numIdentities-1; i >= 0; i--) { 
     
    506506            outgoingIndexMap.put(outgoingConfig, new Integer(i)); 
    507507        } 
    508          
     508 
    509509        if(curCookie != null) { 
    510                 int node = configTreeField.nextNode(0, 0, true); 
    511                 while(node != -1) { 
    512                         if(((ConfigTreeNode)configTreeField.getCookie(node)).cookie == curCookie) { 
    513                                 configTreeField.setCurrentNode(node); 
    514                                 break; 
    515                         } 
    516                         else { 
    517                                 node = configTreeField.nextNode(node, 0, true); 
    518                         } 
    519                 } 
    520         } 
    521     } 
    522      
     510            int node = configTreeField.nextNode(0, 0, true); 
     511            while(node != -1) { 
     512                if(((ConfigTreeNode)configTreeField.getCookie(node)).cookie == curCookie) { 
     513                    configTreeField.setCurrentNode(node); 
     514                    break; 
     515                } 
     516                else { 
     517                    node = configTreeField.nextNode(node, 0, true); 
     518                } 
     519            } 
     520        } 
     521    } 
     522 
    523523    /** 
    524524     * Starts the new account wizard. 
    525525     */ 
    526526    private void newAccountWizard() { 
    527                 AccountConfigWizard wizard = new AccountConfigWizard(); 
    528                 if(wizard.start()) { 
    529                         AccountConfig newAccountConfig = wizard.getAccountConfig(); 
    530                          
    531                         // Find the newly created account, and trigger a folder refresh (if applicable) 
    532                         AccountNode[] accounts = MailManager.getInstance().getMailRootNode().getAccounts(); 
    533                         for(int i=0; i<accounts.length; i++) { 
    534                                 if(accounts[i].getAccountConfig() == newAccountConfig) { 
    535                                         if(accounts[i].hasFolders()) { 
    536                                                 accounts[i].refreshMailboxes(); 
    537                                         } 
    538                                         break; 
    539                                 } 
    540                         } 
    541                 } 
    542     } 
    543      
     527        AccountConfigWizard wizard = new AccountConfigWizard(); 
     528        if(wizard.start()) { 
     529            AccountConfig newAccountConfig = wizard.getAccountConfig(); 
     530 
     531            // Find the newly created account, and trigger a folder refresh (if applicable) 
     532            AccountNode[] accounts = MailManager.getInstance().getMailRootNode().getAccounts(); 
     533            for(int i=0; i<accounts.length; i++) { 
     534                if(accounts[i].getAccountConfig() == newAccountConfig) { 
     535                    if(accounts[i].hasFolders()) { 
     536                        accounts[i].refreshMailboxes(); 
     537                    } 
     538                    break; 
     539                } 
     540            } 
     541        } 
     542    } 
     543 
    544544    /** 
    545545     * Adds a new identity. 
     
    556556        } 
    557557    } 
    558      
     558 
    559559    /** 
    560560     * Delete the currently selected identity. 
     
    563563        IdentityConfig identityConfig = 
    564564            (IdentityConfig)((ConfigTreeNode)configTreeField.getCookie(configTreeField.getCurrentNode())).cookie; 
    565          
     565 
    566566        int index = ((Integer)identityIndexMap.get(identityConfig)).intValue(); 
    567567        int response = Dialog.ask(Dialog.D_DELETE); 
     
    606606        AccountConfig acctConfig = 
    607607            (AccountConfig)((ConfigTreeNode)configTreeField.getCookie(configTreeField.getCurrentNode())).cookie; 
    608          
     608 
    609609        int index = ((Integer)accountIndexMap.get(acctConfig)).intValue(); 
    610610        int response = Dialog.ask(Dialog.D_DELETE); 
     
    633633        } 
    634634    } 
    635      
     635 
    636636    /** 
    637637     * Delete the currently selected outgoing server. 
     
    640640        OutgoingConfig outgoingConfig = 
    641641            (OutgoingConfig)((ConfigTreeNode)configTreeField.getCookie(configTreeField.getCurrentNode())).cookie; 
    642          
     642 
    643643        int index = ((Integer)outgoingIndexMap.get(outgoingConfig)).intValue(); 
    644644        int response = Dialog.ask(Dialog.D_DELETE); 
     
    652652        } 
    653653    } 
    654      
    655         private static class ConfigTreeNode implements TreeFieldNode { 
    656                 public Object cookie; 
    657                  
    658                 public ConfigTreeNode(Object cookie) { 
    659                         this.cookie = cookie; 
    660                 } 
    661  
    662                 public String toString() { 
    663                         return cookie.toString(); 
    664                 } 
    665                  
    666                 public boolean isNodeSelectable() { 
    667                         if((cookie instanceof GlobalConfig) 
    668                         || (cookie instanceof IdentityConfig) 
    669                         || (cookie instanceof AccountConfig) 
    670                         || (cookie instanceof OutgoingConfig)) { 
    671                                 return true; 
    672                         } 
    673                         else { 
    674                                 return false; 
    675                         } 
    676                 } 
    677         } 
     654 
     655    private static class ConfigTreeNode implements TreeFieldNode { 
     656        public Object cookie; 
     657 
     658        public ConfigTreeNode(Object cookie) { 
     659            this.cookie = cookie; 
     660        } 
     661 
     662        public String toString() { 
     663            return cookie.toString(); 
     664        } 
     665 
     666        public boolean isNodeSelectable() { 
     667            if((cookie instanceof GlobalConfig) 
     668                    || (cookie instanceof IdentityConfig) 
     669                    || (cookie instanceof AccountConfig) 
     670                    || (cookie instanceof OutgoingConfig)) { 
     671                return true; 
     672            } 
     673            else { 
     674                return false; 
     675            } 
     676        } 
     677    } 
    678678} 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/ui/GlobalConfigScreen.java

    r549 r555  
    6161 
    6262    private static String LOCAL_FILE_BASE = "LogicMail/"; 
    63      
     63 
    6464    private ObjectChoiceField languageChoiceField; 
    6565    private CheckboxField unicodeNormalizationCheckboxField; 
    66      
     66 
    6767    private ObjectChoiceField messageDisplayChoiceField; 
    6868    private BasicEditField messageCountEditField; 
     
    7777    public GlobalConfigScreen() { 
    7878        super("LogicMail - " + 
    79             resources.getString(LogicMailResource.CONFIG_GLOBAL_TITLE)); 
     79                resources.getString(LogicMailResource.CONFIG_GLOBAL_TITLE)); 
    8080 
    8181        mailSettings = MailSettings.getInstance(); 
     
    115115        Enumeration e = FileSystemRegistry.listRoots(); 
    116116        while(e.hasMoreElements()) { 
    117                 String root = (String)e.nextElement(); 
    118                 if(selectedFileSystemRoot.endsWith(root + LOCAL_FILE_BASE)) { 
    119                         selectedFileSystemRootIndex = i; 
    120                 } 
    121                 resultsVector.addElement(root); 
    122                 i++; 
     117            String root = (String)e.nextElement(); 
     118            if(selectedFileSystemRoot.endsWith(root + LOCAL_FILE_BASE)) { 
     119                selectedFileSystemRootIndex = i; 
     120            } 
     121            resultsVector.addElement(root); 
     122            i++; 
    123123        } 
    124124        fileSystemRoots = new String[resultsVector.size()]; 
    125125        resultsVector.copyInto(fileSystemRoots); 
    126          
     126 
    127127        initFields(); 
    128128    } 
     
    140140        } 
    141141        languageChoiceField = new ObjectChoiceField( 
    142                         resources.getString(LogicMailResource.CONFIG_GLOBAL_LANGUAGE), 
    143                         languageChoices, 
    144                         languageIndex); 
    145          
    146                 unicodeNormalizationCheckboxField = new CheckboxField( 
    147                                 resources.getString(LogicMailResource.CONFIG_GLOBAL_UNICODE_NORMALIZATION), 
    148                                 existingConfig.getUnicodeNormalization()); 
    149  
    150                 messageDisplayChoiceField = new ObjectChoiceField( 
    151                                 resources.getString(LogicMailResource.CONFIG_GLOBAL_MESSAGE_FORMAT), 
    152                                 new String[] { 
    153                                         resources.getString(LogicMailResource.CONFIG_GLOBAL_MESSAGE_FORMAT_PLAIN_TEXT), 
    154                                         "HTML" }, 
    155                                 existingConfig.getMessageDisplayFormat()); 
    156                  
    157             messageCountEditField = new BasicEditField( 
    158                         resources.getString(LogicMailResource.CONFIG_GLOBAL_MESSAGE_COUNT) + ' ', 
    159                     Integer.toString(existingConfig.getRetMsgCount())); 
    160             messageCountEditField.setFilter(TextFilter.get(TextFilter.NUMERIC)); 
    161          
    162             String[] orderTypes = { 
    163                     resources.getString(LogicMailResource.MENUITEM_ORDER_ASCENDING), 
    164                     resources.getString(LogicMailResource.MENUITEM_ORDER_DESCENDING) 
    165                 }; 
    166          
    167             if (existingConfig.getDispOrder()) { 
    168                 displayOrderChoiceField = new ObjectChoiceField( 
    169                                 resources.getString(LogicMailResource.CONFIG_GLOBAL_MESSAGE_ORDER) + ' ', 
    170                         orderTypes, 0); 
    171             } else { 
    172                 displayOrderChoiceField = new ObjectChoiceField( 
    173                                 resources.getString(LogicMailResource.CONFIG_GLOBAL_MESSAGE_ORDER) + ' ', 
    174                         orderTypes, 1); 
    175             } 
    176          
    177             hideDeletedMessagesCheckboxField = new CheckboxField( 
    178                         resources.getString(LogicMailResource.CONFIG_GLOBAL_HIDE_DELETED_MESSAGES), 
     142                resources.getString(LogicMailResource.CONFIG_GLOBAL_LANGUAGE), 
     143                languageChoices, 
     144                languageIndex); 
     145 
     146        unicodeNormalizationCheckboxField = new CheckboxField( 
     147                resources.getString(LogicMailResource.CONFIG_GLOBAL_UNICODE_NORMALIZATION), 
     148                existingConfig.getUnicodeNormalization()); 
     149 
     150        messageDisplayChoiceField = new ObjectChoiceField( 
     151                resources.getString(LogicMailResource.CONFIG_GLOBAL_MESSAGE_FORMAT), 
     152                new String[] { 
     153                    resources.getString(LogicMailResource.CONFIG_GLOBAL_MESSAGE_FORMAT_PLAIN_TEXT), 
     154                "HTML" }, 
     155                existingConfig.getMessageDisplayFormat()); 
     156 
     157        messageCountEditField = new BasicEditField( 
     158                resources.getString(LogicMailResource.CONFIG_GLOBAL_MESSAGE_COUNT) + ' ', 
     159                Integer.toString(existingConfig.getRetMsgCount())); 
     160        messageCountEditField.setFilter(TextFilter.get(TextFilter.NUMERIC)); 
     161 
     162        String[] orderTypes = { 
     163                resources.getString(LogicMailResource.MENUITEM_ORDER_ASCENDING), 
     164                resources.getString(LogicMailResource.MENUITEM_ORDER_DESCENDING) 
     165        }; 
     166 
     167        if (existingConfig.getDispOrder()) { 
     168            displayOrderChoiceField = new ObjectChoiceField( 
     169                    resources.getString(LogicMailResource.CONFIG_GLOBAL_MESSAGE_ORDER) + ' ', 
     170                    orderTypes, 0); 
     171        } else { 
     172            displayOrderChoiceField = new ObjectChoiceField( 
     173                    resources.getString(LogicMailResource.CONFIG_GLOBAL_MESSAGE_ORDER) + ' ', 
     174                    orderTypes, 1); 
     175        } 
     176 
     177        hideDeletedMessagesCheckboxField = new CheckboxField( 
     178                resources.getString(LogicMailResource.CONFIG_GLOBAL_HIDE_DELETED_MESSAGES), 
    179179                existingConfig.getHideDeletedMsg()); 
    180          
    181             String[] wifiModes = { 
    182                     resources.getString(LogicMailResource.MENUITEM_DISABLED), 
    183                     resources.getString(LogicMailResource.MENUITEM_PROMPT), 
    184                     resources.getString(LogicMailResource.MENUITEM_ALWAYS) 
    185                 }; 
    186             wifiModeChoiceField = new ObjectChoiceField( 
    187                         resources.getString(LogicMailResource.CONFIG_GLOBAL_WIFI_MODE) + ' ', 
    188                         wifiModes, 
    189                         existingConfig.getWifiMode()); 
    190  
    191             localDataLocationChoiceLabel = new ObjectChoiceField( 
    192                         resources.getString(LogicMailResource.CONFIG_GLOBAL_LOCAL_DATA_LOCATION) + ' ', 
    193                         fileSystemRoots, 
    194                         selectedFileSystemRootIndex); 
    195          
    196             boolean overrideHostname = localHostname.length() > 0; 
    197             overrideHostnameCheckboxField = new CheckboxField( 
    198                         resources.getString(LogicMailResource.CONFIG_GLOBAL_OVERRIDE_HOSTNAME), 
    199                     overrideHostname); 
    200             overrideHostnameCheckboxField.setChangeListener(this); 
    201          
    202             if (overrideHostname) { 
    203                 localHostnameEditField = new BasicEditField( 
    204                                 resources.getString(LogicMailResource.CONFIG_GLOBAL_HOSTNAME) + ' ', 
    205                         localHostname); 
    206             } else { 
    207                 String hostname = System.getProperty("microedition.hostname"); 
    208                 localHostnameEditField = new BasicEditField( 
    209                                 resources.getString(LogicMailResource.CONFIG_GLOBAL_HOSTNAME) + ' ', 
    210                         ((hostname != null) ? hostname : "localhost")); 
    211                 localHostnameEditField.setEditable(false); 
    212             } 
    213          
    214             connectionDebuggingCheckboxField = new CheckboxField( 
    215                         resources.getString(LogicMailResource.CONFIG_GLOBAL_CONNECTION_DEBUGGING), 
     180 
     181        String[] wifiModes = { 
     182                resources.getString(LogicMailResource.MENUITEM_DISABLED), 
     183                resources.getString(LogicMailResource.MENUITEM_PROMPT), 
     184                resources.getString(LogicMailResource.MENUITEM_ALWAYS) 
     185        }; 
     186        wifiModeChoiceField = new ObjectChoiceField( 
     187                resources.getString(LogicMailResource.CONFIG_GLOBAL_WIFI_MODE) + ' ', 
     188                wifiModes, 
     189                existingConfig.getWifiMode()); 
     190 
     191        localDataLocationChoiceLabel = new ObjectChoiceField( 
     192                resources.getString(LogicMailResource.CONFIG_GLOBAL_LOCAL_DATA_LOCATION) + ' ', 
     193                fileSystemRoots, 
     194                selectedFileSystemRootIndex); 
     195 
     196        boolean overrideHostname = localHostname.length() > 0; 
     197        overrideHostnameCheckboxField = new CheckboxField( 
     198                resources.getString(LogicMailResource.CONFIG_GLOBAL_OVERRIDE_HOSTNAME), 
     199                overrideHostname); 
     200        overrideHostnameCheckboxField.setChangeListener(this); 
     201 
     202        if (overrideHostname) { 
     203            localHostnameEditField = new BasicEditField( 
     204                    resources.getString(LogicMailResource.CONFIG_GLOBAL_HOSTNAME) + ' ', 
     205                    localHostname); 
     206        } else { 
     207            String hostname = System.getProperty("microedition.hostname"); 
     208            localHostnameEditField = new BasicEditField( 
     209                    resources.getString(LogicMailResource.CONFIG_GLOBAL_HOSTNAME) + ' ', 
     210                    ((hostname != null) ? hostname : "localhost")); 
     211            localHostnameEditField.setEditable(false); 
     212        } 
     213 
     214        connectionDebuggingCheckboxField = new CheckboxField( 
     215                resources.getString(LogicMailResource.CONFIG_GLOBAL_CONNECTION_DEBUGGING), 
    216216                existingConfig.getConnDebug()); 
    217217 
    218218 
    219                 add(new LabeledSeparatorField("Message display", Field.NON_FOCUSABLE | LabeledSeparatorField.BOTTOM_BORDER)); 
    220                 add(messageDisplayChoiceField); 
    221             add(messageCountEditField); 
    222             add(displayOrderChoiceField); 
    223             add(hideDeletedMessagesCheckboxField); 
    224  
    225                 add(new LabeledSeparatorField("Networking", Field.NON_FOCUSABLE | LabeledSeparatorField.TOP_BORDER | LabeledSeparatorField.BOTTOM_BORDER)); 
    226             add(wifiModeChoiceField); 
    227             add(overrideHostnameCheckboxField); 
    228             add(localHostnameEditField); 
    229              
    230             add(new LabeledSeparatorField("Other", Field.NON_FOCUSABLE | LabeledSeparatorField.TOP_BORDER | LabeledSeparatorField.BOTTOM_BORDER)); 
    231             add(localDataLocationChoiceLabel); 
    232                 add(languageChoiceField); 
    233                 add(unicodeNormalizationCheckboxField); 
    234             add(connectionDebuggingCheckboxField); 
     219        add(new LabeledSeparatorField( 
     220                resources.getString(LogicMailResource.CONFIG_GLOBAL_SECTION_MESSAGE_DISPLAY), 
     221                Field.NON_FOCUSABLE | LabeledSeparatorField.BOTTOM_BORDER)); 
     222        add(messageDisplayChoiceField); 
     223        add(messageCountEditField); 
     224        add(displayOrderChoiceField); 
     225        add(hideDeletedMessagesCheckboxField); 
     226 
     227        add(new LabeledSeparatorField( 
     228                resources.getString(LogicMailResource.CONFIG_GLOBAL_SECTION_NETWORKING), 
     229                Field.NON_FOCUSABLE | LabeledSeparatorField.TOP_BORDER | LabeledSeparatorField.BOTTOM_BORDER)); 
     230        add(wifiModeChoiceField); 
     231        add(overrideHostnameCheckboxField); 
     232        add(localHostnameEditField); 
     233 
     234        add(new LabeledSeparatorField( 
     235                resources.getString(LogicMailResource.CONFIG_GLOBAL_SECTION_OTHER), 
     236                Field.NON_FOCUSABLE | LabeledSeparatorField.TOP_BORDER | LabeledSeparatorField.BOTTOM_BORDER)); 
     237        add(localDataLocationChoiceLabel); 
     238        add(languageChoiceField); 
     239        add(unicodeNormalizationCheckboxField); 
     240        add(connectionDebuggingCheckboxField); 
    235241    } 
    236      
     242 
    237243    public void fieldChanged(Field field, int context) { 
    238244        if (field == overrideHostnameCheckboxField) { 
     
    243249                String hostname = System.getProperty("microedition.hostname"); 
    244250                localHostnameEditField.setText((hostname != null) ? hostname 
    245                                                             : "localhost"); 
     251                        : "localhost"); 
    246252                localHostnameEditField.setEditable(false); 
    247253            } 
     
    263269            config.setLanguageCode(""); 
    264270        } 
    265          
     271 
    266272        config.setUnicodeNormalization(unicodeNormalizationCheckboxField.getChecked()); 
    267          
     273 
    268274        config.setMessageDisplayFormat(messageDisplayChoiceField.getSelectedIndex()); 
    269          
     275 
    270276        try { 
    271277            config.setRetMsgCount(Integer.parseInt(messageCountEditField.getText())); 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/ui/IdentityConfigScreen.java

    r459 r555  
    3333 
    3434import net.rim.device.api.ui.Field; 
    35 import net.rim.device.api.ui.FieldChangeListener; 
    3635import net.rim.device.api.ui.component.AutoTextEditField; 
    3736import net.rim.device.api.ui.component.BasicEditField; 
    38 import net.rim.device.api.ui.component.ButtonField; 
    3937import net.rim.device.api.ui.component.Dialog; 
    4038import net.rim.device.api.ui.component.EmailAddressEditField; 
     
    5755    private EmailAddressEditField replyToAddressField; 
    5856    private AutoTextEditField msgSignatureField; 
    59     private ButtonField saveButton; 
    60      
     57 
    6158    /** 
    6259     * Creates a new instance of IdentityConfigScreen 
     
    7774        msgSignatureField.setText(identityConfig.getMsgSignature()); 
    7875 
    79         saveButton = new ButtonField(resources.getString(LogicMailResource.MENUITEM_SAVE), Field.FIELD_HCENTER); 
    80         saveButton.setChangeListener(new FieldChangeListener() { 
    81             public void fieldChanged(Field field, int context) { 
    82                 saveButton_FieldChanged(field, context); 
    83             }}); 
    84  
    8576        add(identityNameField); 
    86         add(new SeparatorField()); 
    8777        add(fullNameField); 
    8878        add(emailAddressField); 
     
    9181        add(new RichTextField(resources.getString(LogicMailResource.CONFIG_IDENTITY_SIGNATURE), Field.NON_FOCUSABLE)); 
    9282        add(msgSignatureField); 
    93         add(new SeparatorField()); 
    94         add(saveButton); 
    95     } 
    96  
    97     private void saveButton_FieldChanged(Field field, int context) { 
    98         field.setDirty(false); 
    99         onClose(); 
    10083    } 
    10184 
    10285    protected boolean onSavePrompt() { 
    10386        if(identityNameField.getText().length() > 0 && 
    104            emailAddressField.getText().length() > 0) { 
     87                emailAddressField.getText().length() > 0) { 
    10588            return super.onSavePrompt(); 
    10689        } 
    10790        else { 
    10891            int result = Dialog.ask( 
    109                         resources.getString(LogicMailResource.CONFIG_PROMPT_INCOMPLETE), 
    110                         new String[] { 
    111                                 resources.getString(LogicMailResource.MENUITEM_DISCARD), 
    112                                 resources.getString(LogicMailResource.MENUITEM_CANCEL) }, 0); 
     92                    resources.getString(LogicMailResource.CONFIG_PROMPT_INCOMPLETE), 
     93                    new String[] { 
     94                        resources.getString(LogicMailResource.MENUITEM_DISCARD), 
     95                        resources.getString(LogicMailResource.MENUITEM_CANCEL) }, 0); 
    11396            if(result == 0) { 
    11497                return true; 
     
    119102        } 
    120103    } 
    121      
     104 
    122105    public void save() { 
    123106        identityConfig.setIdentityName(identityNameField.getText()); 
     
    128111        configSaved = true; 
    129112    } 
    130      
     113 
    131114    public boolean configSaved() { 
    132115        return configSaved; 
Note: See TracChangeset for help on using the changeset viewer.