Changeset 555
- Timestamp:
- 11/22/09 15:47:25 (2 years ago)
- Location:
- trunk/LogicMail
- Files:
-
- 6 edited
-
res/org/logicprobe/LogicMail/LogicMail.rrc (modified) (1 diff)
-
res/org/logicprobe/LogicMail/LogicMail.rrh (modified) (1 diff)
-
src/org/logicprobe/LogicMail/ui/AccountConfigScreen.java (modified) (22 diffs)
-
src/org/logicprobe/LogicMail/ui/ConfigScreen.java (modified) (25 diffs)
-
src/org/logicprobe/LogicMail/ui/GlobalConfigScreen.java (modified) (6 diffs)
-
src/org/logicprobe/LogicMail/ui/IdentityConfigScreen.java (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LogicMail/res/org/logicprobe/LogicMail/LogicMail.rrc
r545 r555 42 42 CONFIG_GLOBAL_MESSAGE_ORDER#0="Message order:"; 43 43 CONFIG_GLOBAL_OVERRIDE_HOSTNAME#0="Override hostname"; 44 CONFIG_GLOBAL_SECTION_MESSAGE_DISPLAY#0="Message display"; 45 CONFIG_GLOBAL_SECTION_NETWORKING#0="Networking"; 46 CONFIG_GLOBAL_SECTION_OTHER#0="Other"; 44 47 CONFIG_GLOBAL_SETTINGS#0="Global settings"; 45 48 CONFIG_GLOBAL_TITLE#0="Global"; -
trunk/LogicMail/res/org/logicprobe/LogicMail/LogicMail.rrh
r545 r555 178 178 MENUITEM_SCROLL_DOWN#0=179; 179 179 MAILCONNECTION_REQUEST_MESSAGE_COPY#0=180; 180 CONFIG_GLOBAL_SECTION_MESSAGE_DISPLAY#0=181; 181 CONFIG_GLOBAL_SECTION_NETWORKING#0=182; 182 CONFIG_GLOBAL_SECTION_OTHER#0=183; -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/AccountConfigScreen.java
r549 r555 65 65 */ 66 66 public class AccountConfigScreen extends AbstractConfigScreen { 67 // Top-level fields67 // Top-level fields 68 68 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 74 73 private BasicEditField serverNameField; 75 74 private ObjectChoiceField serverSecurityField; … … 80 79 private ObjectChoiceField identityField; 81 80 private ObjectChoiceField outgoingServerField; 82 81 83 82 // Folder settings fields 84 83 private LabelField sentFolderChoiceLabel; … … 86 85 private LabelField draftFolderChoiceLabel; 87 86 private LabelField draftFolderChoiceButtonLabel; 88 87 89 88 // Advanced settings fields (IMAP) 90 89 private BasicEditField imapFolderPrefixField; … … 93 92 // Advanced settings fields (POP) 94 93 private BasicEditField popMaxLinesEditField; 95 96 private Manager[] pageFieldManagers;94 95 private Manager[] pageFieldManagers; 97 96 private boolean acctSaved; 98 97 private boolean createDefaultIdentity; … … 103 102 private MailboxNode selectedDraftFolder; 104 103 private FieldChangeListener fieldChangeListener; 105 104 106 105 private class NullOutgoingConfig extends OutgoingConfig { 107 106 public String toString() { … … 120 119 public AccountConfigScreen(AccountConfig acctConfig) { 121 120 super("LogicMail - " + resources.getString(LogicMailResource.CONFIG_ACCOUNT_TITLE)); 122 121 123 122 this.acctConfig = acctConfig; 124 123 this.acctSaved = false; 125 124 126 125 MailSettings mailSettings = MailSettings.getInstance(); 127 126 … … 141 140 this.setDirty(true); 142 141 } 143 142 144 143 int numOutgoing = mailSettings.getNumOutgoing(); 145 144 outgoingConfigs = new OutgoingConfig[numOutgoing+1]; … … 148 147 outgoingConfigs[i+1] = mailSettings.getOutgoingConfig(i); 149 148 } 150 149 151 150 fieldChangeListener = new FieldChangeListener() { 152 151 public void fieldChanged(Field field, int context) { … … 154 153 }}; 155 154 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 } 167 166 } 168 167 … … 171 170 */ 172 171 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; 176 173 if(acctConfig instanceof ImapConfig) { 177 accountType += " IMAP";174 accountType = "IMAP "; 178 175 } 179 176 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 } 183 182 183 acctNameField = new BasicEditField( 184 accountType 185 + resources.getString(LogicMailResource.CONFIG_ACCOUNT_NAME) 186 + ' ', 187 acctConfig.getAcctName()); 188 184 189 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 193 197 pageField.setChangeListener(fieldChangeListener); 194 198 195 pageFieldManagers = new Manager[3];196 pageFieldManagers[0] = initFieldsBasic();197 pageFieldManagers[1] = initFieldsFolder();198 pageFieldManagers[2] = initFieldsAdvanced();199 200 // Container for the active settings page201 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 204 208 add(acctNameField); 205 add(accountTypeLabel);206 209 add(pageField); 207 210 add(new SeparatorField()); … … 209 212 add(new LabelField()); 210 213 } 211 214 212 215 /** 213 216 * Initializes the UI fields for the basic settings page. 214 217 */ 215 218 private Manager initFieldsBasic() { 216 Manager manager = new VerticalFieldManager();219 Manager manager = new VerticalFieldManager(); 217 220 serverNameField = new BasicEditField(resources.getString(LogicMailResource.CONFIG_ACCOUNT_SERVER) + ' ', acctConfig.getServerName(), 218 256, TextField.NO_NEWLINE);221 256, TextField.NO_NEWLINE); 219 222 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()); 227 230 serverSecurityField.setChangeListener(fieldChangeListener); 228 231 serverPortField = new BasicEditField(resources.getString(LogicMailResource.CONFIG_ACCOUNT_PORT) + ' ', Integer.toString(acctConfig.getServerPort()), 229 5, TextField.NO_NEWLINE);232 5, TextField.NO_NEWLINE); 230 233 serverPortField.setFilter(TextFilter.get(TextFilter.NUMERIC)); 231 234 serverUserField = new BasicEditField(resources.getString(LogicMailResource.CONFIG_ACCOUNT_USERNAME) + ' ', acctConfig.getServerUser(), 232 256, TextField.NO_NEWLINE);235 256, TextField.NO_NEWLINE); 233 236 serverPassField = new PasswordEditField(resources.getString(LogicMailResource.CONFIG_ACCOUNT_PASSWORD) + ' ', acctConfig.getServerPass(), 234 256, TextField.NO_NEWLINE);237 256, TextField.NO_NEWLINE); 235 238 useMdsField = new CheckboxField(resources.getString(LogicMailResource.CONFIG_ACCOUNT_USEMDSPROXY), !acctConfig.getDeviceSide()); 236 239 identityField = new ObjectChoiceField(resources.getString(LogicMailResource.CONFIG_ACCOUNT_IDENTITY) + ' ', identityConfigs, 0); … … 247 250 manager.add(identityField); 248 251 manager.add(outgoingServerField); 249 252 250 253 return manager; 251 254 } 252 255 253 256 /** 254 257 * Initializes the UI fields for the folder settings page. 255 258 */ 256 259 private Manager initFieldsFolder() { 257 Manager manager = new VerticalFieldManager();260 Manager manager = new VerticalFieldManager(); 258 261 selectedSentFolder = acctConfig.getSentMailbox(); 259 262 selectedDraftFolder = acctConfig.getDraftMailbox(); 260 263 261 264 sentFolderChoiceLabel = new LabelField(resources.getString(LogicMailResource.CONFIG_ACCOUNT_SENT_MESSAGE_FOLDER) + ' '); 262 265 sentFolderChoiceButtonLabel = new LabelField(createSelectedMailboxString(selectedSentFolder), Field.FOCUSABLE | Field.HIGHLIGHT_FOCUS | Field.FIELD_RIGHT | LabelField.ELLIPSIS); … … 270 273 return manager; 271 274 } 272 275 273 276 /** 274 277 * Initializes the UI fields for the advanced settings page. 275 278 */ 276 279 private Manager initFieldsAdvanced() { 277 Manager manager = new VerticalFieldManager();280 Manager manager = new VerticalFieldManager(); 278 281 if(acctConfig instanceof ImapConfig) { 279 282 ImapConfig imapConfig = (ImapConfig)acctConfig; 280 283 281 284 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 295 298 manager.add(imapFolderPrefixField); 296 299 manager.add(imapMaxMessageSizeEditField); … … 298 301 } 299 302 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 312 315 public void AcctCfgScreen_fieldChanged(Field field, int context) { 313 316 if(field == serverSecurityField) { … … 330 333 } 331 334 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 } 337 340 } 338 341 } … … 342 345 */ 343 346 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 362 365 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 414 417 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 427 430 /** 428 431 * Determines if this screen is dirty. … … 433 436 */ 434 437 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 446 449 /* (non-Javadoc) 447 450 * @see net.rim.device.api.ui.container.MainScreen#onSavePrompt() … … 449 452 protected boolean onSavePrompt() { 450 453 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) { 453 456 return super.onSavePrompt(); 454 457 } 455 458 else { 456 459 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); 461 464 if(result == 0) { 462 465 return true; … … 479 482 this.acctConfig.setServerPass(serverPassField.getText()); 480 483 this.acctConfig.setDeviceSide(!useMdsField.getChecked()); 481 484 482 485 IdentityConfig selectedIdentityConfig = (IdentityConfig)identityField.getChoice(identityField.getSelectedIndex()); 483 486 if(createDefaultIdentity) { … … 486 489 userName = "user"; 487 490 } 488 selectedIdentityConfig.setEmailAddress(userName + "@"+ serverNameField.getText());491 selectedIdentityConfig.setEmailAddress(userName + '@' + serverNameField.getText()); 489 492 MailSettings.getInstance().addIdentityConfig(selectedIdentityConfig); 490 493 createDefaultIdentity = false; … … 505 508 if(acctConfig instanceof ImapConfig) { 506 509 ImapConfig imapConfig = (ImapConfig)acctConfig; 507 510 508 511 String folderPrefix = imapFolderPrefixField.getText().trim(); 509 512 if(folderPrefix.length() == 0) { … … 515 518 516 519 try { 517 imapConfig.setMaxMessageSize(Integer.parseInt(520 imapConfig.setMaxMessageSize(Integer.parseInt( 518 521 imapMaxMessageSizeEditField.getText()) * 1024); 519 522 } catch (Exception e) { } 520 523 521 524 try { 522 imapConfig.setMaxFolderDepth(Integer.parseInt(525 imapConfig.setMaxFolderDepth(Integer.parseInt( 523 526 imapMaxFolderDepthEditField.getText())); 524 527 } catch (Exception e) { } 525 528 } 526 529 else if(acctConfig instanceof PopConfig) { 527 PopConfig popConfig = (PopConfig)acctConfig;528 530 PopConfig popConfig = (PopConfig)acctConfig; 531 529 532 try { 530 popConfig.setMaxMessageLines(Integer.parseInt(popMaxLinesEditField.getText()));533 popConfig.setMaxMessageLines(Integer.parseInt(popMaxLinesEditField.getText())); 531 534 } catch (Exception e) { } 532 535 } 533 536 534 537 acctSaved = true; 535 538 } 536 539 537 540 public boolean acctSaved() { 538 541 return acctSaved; -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/ConfigScreen.java
r549 r555 70 70 private Hashtable outgoingIndexMap; 71 71 private boolean configurationChanged; 72 72 73 73 /** 74 74 * Instantiates a new configuration screen. … … 80 80 accountIndexMap = new Hashtable(); 81 81 outgoingIndexMap = new Hashtable(); 82 82 83 83 initFields(); 84 84 85 85 buildAccountsList(); 86 86 } 87 87 88 88 /** 89 89 * Initializes the fields. … … 91 91 private void initFields() { 92 92 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); 99 99 configTreeField.setDefaultExpanded(true); 100 100 configTreeField.setIndentWidth(20); 101 101 102 102 globalId = configTreeField.addChildNode(0, new ConfigTreeNode(resources.getString(LogicMailResource.CONFIG_GLOBAL_SETTINGS))); 103 103 identitiesId = configTreeField.addSiblingNode(globalId, new ConfigTreeNode(resources.getString(LogicMailResource.CONFIG_IDENTITIES))); … … 112 112 */ 113 113 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 128 128 /** 129 129 * Draws tree items in the TreeField … … 140 140 graphics.drawText(cookie.toString(), indent + 2, y, Graphics.ELLIPSIS, width); 141 141 } 142 142 143 143 private MenuItem selectItem = new MenuItem(resources, LogicMailResource.MENUITEM_EDIT, 100, 10) { 144 144 public void run() { … … 161 161 private MenuItem newAccountWizardItem = new MenuItem(resources, LogicMailResource.MENUITEM_NEW_ACCOUNT_WIZARD, 110, 10) { 162 162 public void run() { 163 newAccountWizard();164 } 165 }; 166 163 newAccountWizard(); 164 } 165 }; 166 167 167 private MenuItem addIdentityItem = new MenuItem(resources, LogicMailResource.MENUITEM_ADD_IDENTITY, 120, 10) { 168 168 public void run() { … … 206 206 protected void makeMenu(Menu menu, int instance) { 207 207 int id = configTreeField.getCurrentNode(); 208 208 209 209 Object cookie; 210 210 Object rawCookie = configTreeField.getCookie(id); 211 211 if(rawCookie instanceof ConfigTreeNode) { 212 cookie = ((ConfigTreeNode)rawCookie).cookie;212 cookie = ((ConfigTreeNode)rawCookie).cookie; 213 213 } 214 214 else { 215 cookie = null;216 } 217 215 cookie = null; 216 } 217 218 218 if(id != identitiesId && id != accountsId && id != outgoingId) { 219 219 menu.add(selectItem); 220 220 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 } 227 227 } 228 228 menu.addSeparator(); 229 229 } 230 230 231 231 if(id == identitiesId) { 232 232 menu.add(addIdentityItem); … … 237 237 } 238 238 else if(id == accountsId) { 239 menu.add(newAccountWizardItem);239 menu.add(newAccountWizardItem); 240 240 menu.add(addAccountItem); 241 241 } 242 242 else if(cookie instanceof AccountConfig) { 243 menu.add(newAccountWizardItem);243 menu.add(newAccountWizardItem); 244 244 menu.add(addAccountItem); 245 245 menu.add(deleteAccountItem); … … 254 254 super.makeMenu(menu, instance); 255 255 } 256 257 /* (non-Javadoc)256 257 /* (non-Javadoc) 258 258 * @see net.rim.device.api.ui.Screen#keyChar(char, int, int) 259 259 */ … … 261 261 boolean retval = false; 262 262 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; 271 271 } 272 272 return retval; 273 273 } 274 274 275 275 /* (non-Javadoc) 276 276 * @see net.rim.device.api.ui.Screen#navigationClick(int, int) 277 277 */ 278 278 protected boolean navigationClick(int status, int time) { 279 return openSelectedNode();280 } 281 279 return openSelectedNode(); 280 } 281 282 282 /** 283 283 * Toggle selected node's expansion state … … 285 285 private void toggleSelectedNode() { 286 286 int curNode = configTreeField.getCurrentNode(); 287 287 288 288 // Make sure a node is selected 289 289 if(curNode == -1) { 290 290 return; 291 291 } 292 292 293 293 // Make sure the selected node has children 294 294 if(configTreeField.getFirstChild(curNode) == -1) { … … 299 299 configTreeField.setExpanded(curNode, !configTreeField.getExpanded(curNode)); 300 300 } 301 301 302 302 /** 303 303 * Open selected node. … … 306 306 */ 307 307 private boolean openSelectedNode() { 308 boolean result = false;308 boolean result = false; 309 309 int curNode = configTreeField.getCurrentNode(); 310 310 if(curNode == globalId) { … … 347 347 } 348 348 if(result) { 349 buildAccountsList();349 buildAccountsList(); 350 350 } 351 351 return result; 352 352 } 353 353 354 private void moveSelectedNodeUp() {354 private void moveSelectedNodeUp() { 355 355 int curNode = configTreeField.getCurrentNode(); 356 356 if(curNode == -1) { return; } … … 360 360 Object cookie = ((ConfigTreeNode)configTreeField.getCookie(curNode)).cookie; 361 361 Object prevCookie = ((ConfigTreeNode)configTreeField.getCookie(prevNode)).cookie; 362 362 363 363 boolean result = false; 364 364 365 365 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; 375 375 } 376 376 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; 386 386 } 387 387 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 399 399 if(result) { 400 400 mailSettings.saveSettings(); 401 401 configurationChanged = true; 402 buildAccountsList();403 } 404 }405 406 private void moveSelectedNodeDown() {402 buildAccountsList(); 403 } 404 } 405 406 private void moveSelectedNodeDown() { 407 407 int curNode = configTreeField.getCurrentNode(); 408 408 if(curNode == -1) { return; } … … 412 412 Object cookie = ((ConfigTreeNode)configTreeField.getCookie(curNode)).cookie; 413 413 Object nextCookie = ((ConfigTreeNode)configTreeField.getCookie(nextNode)).cookie; 414 414 415 415 boolean result = false; 416 416 417 417 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; 427 427 } 428 428 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; 438 438 } 439 439 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 451 451 if(result) { 452 452 mailSettings.saveSettings(); 453 453 configurationChanged = true; 454 buildAccountsList();455 } 456 }454 buildAccountsList(); 455 } 456 } 457 457 458 458 /** … … 460 460 */ 461 461 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 471 471 int numIdentities = mailSettings.getNumIdentities(); 472 472 identityIndexMap.clear(); … … 485 485 configTreeField.deleteSubtree(id); 486 486 } 487 487 488 488 IdentityConfig identityConfig; 489 489 for(int i = numIdentities-1; i >= 0; i--) { … … 506 506 outgoingIndexMap.put(outgoingConfig, new Integer(i)); 507 507 } 508 508 509 509 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 523 523 /** 524 524 * Starts the new account wizard. 525 525 */ 526 526 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 544 544 /** 545 545 * Adds a new identity. … … 556 556 } 557 557 } 558 558 559 559 /** 560 560 * Delete the currently selected identity. … … 563 563 IdentityConfig identityConfig = 564 564 (IdentityConfig)((ConfigTreeNode)configTreeField.getCookie(configTreeField.getCurrentNode())).cookie; 565 565 566 566 int index = ((Integer)identityIndexMap.get(identityConfig)).intValue(); 567 567 int response = Dialog.ask(Dialog.D_DELETE); … … 606 606 AccountConfig acctConfig = 607 607 (AccountConfig)((ConfigTreeNode)configTreeField.getCookie(configTreeField.getCurrentNode())).cookie; 608 608 609 609 int index = ((Integer)accountIndexMap.get(acctConfig)).intValue(); 610 610 int response = Dialog.ask(Dialog.D_DELETE); … … 633 633 } 634 634 } 635 635 636 636 /** 637 637 * Delete the currently selected outgoing server. … … 640 640 OutgoingConfig outgoingConfig = 641 641 (OutgoingConfig)((ConfigTreeNode)configTreeField.getCookie(configTreeField.getCurrentNode())).cookie; 642 642 643 643 int index = ((Integer)outgoingIndexMap.get(outgoingConfig)).intValue(); 644 644 int response = Dialog.ask(Dialog.D_DELETE); … … 652 652 } 653 653 } 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 } 678 678 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/GlobalConfigScreen.java
r549 r555 61 61 62 62 private static String LOCAL_FILE_BASE = "LogicMail/"; 63 63 64 64 private ObjectChoiceField languageChoiceField; 65 65 private CheckboxField unicodeNormalizationCheckboxField; 66 66 67 67 private ObjectChoiceField messageDisplayChoiceField; 68 68 private BasicEditField messageCountEditField; … … 77 77 public GlobalConfigScreen() { 78 78 super("LogicMail - " + 79 resources.getString(LogicMailResource.CONFIG_GLOBAL_TITLE));79 resources.getString(LogicMailResource.CONFIG_GLOBAL_TITLE)); 80 80 81 81 mailSettings = MailSettings.getInstance(); … … 115 115 Enumeration e = FileSystemRegistry.listRoots(); 116 116 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++; 123 123 } 124 124 fileSystemRoots = new String[resultsVector.size()]; 125 125 resultsVector.copyInto(fileSystemRoots); 126 126 127 127 initFields(); 128 128 } … … 140 140 } 141 141 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), 179 179 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), 216 216 existingConfig.getConnDebug()); 217 217 218 218 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); 235 241 } 236 242 237 243 public void fieldChanged(Field field, int context) { 238 244 if (field == overrideHostnameCheckboxField) { … … 243 249 String hostname = System.getProperty("microedition.hostname"); 244 250 localHostnameEditField.setText((hostname != null) ? hostname 245 : "localhost");251 : "localhost"); 246 252 localHostnameEditField.setEditable(false); 247 253 } … … 263 269 config.setLanguageCode(""); 264 270 } 265 271 266 272 config.setUnicodeNormalization(unicodeNormalizationCheckboxField.getChecked()); 267 273 268 274 config.setMessageDisplayFormat(messageDisplayChoiceField.getSelectedIndex()); 269 275 270 276 try { 271 277 config.setRetMsgCount(Integer.parseInt(messageCountEditField.getText())); -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/IdentityConfigScreen.java
r459 r555 33 33 34 34 import net.rim.device.api.ui.Field; 35 import net.rim.device.api.ui.FieldChangeListener;36 35 import net.rim.device.api.ui.component.AutoTextEditField; 37 36 import net.rim.device.api.ui.component.BasicEditField; 38 import net.rim.device.api.ui.component.ButtonField;39 37 import net.rim.device.api.ui.component.Dialog; 40 38 import net.rim.device.api.ui.component.EmailAddressEditField; … … 57 55 private EmailAddressEditField replyToAddressField; 58 56 private AutoTextEditField msgSignatureField; 59 private ButtonField saveButton; 60 57 61 58 /** 62 59 * Creates a new instance of IdentityConfigScreen … … 77 74 msgSignatureField.setText(identityConfig.getMsgSignature()); 78 75 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 85 76 add(identityNameField); 86 add(new SeparatorField());87 77 add(fullNameField); 88 78 add(emailAddressField); … … 91 81 add(new RichTextField(resources.getString(LogicMailResource.CONFIG_IDENTITY_SIGNATURE), Field.NON_FOCUSABLE)); 92 82 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();100 83 } 101 84 102 85 protected boolean onSavePrompt() { 103 86 if(identityNameField.getText().length() > 0 && 104 emailAddressField.getText().length() > 0) {87 emailAddressField.getText().length() > 0) { 105 88 return super.onSavePrompt(); 106 89 } 107 90 else { 108 91 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); 113 96 if(result == 0) { 114 97 return true; … … 119 102 } 120 103 } 121 104 122 105 public void save() { 123 106 identityConfig.setIdentityName(identityNameField.getText()); … … 128 111 configSaved = true; 129 112 } 130 113 131 114 public boolean configSaved() { 132 115 return configSaved;
Note: See TracChangeset
for help on using the changeset viewer.
