📄 funcanvasrecipientlist.java
字号:
/*
* Copyright (C) 2006-2007 Funambol
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
*/
package com.funambol.mailclient.ui.view;
import com.funambol.mail.Address;
import com.funambol.mail.MailException;
import com.funambol.mail.Message;
import com.funambol.mailclient.cm.AlreadyExistentContactException;
import com.funambol.mailclient.cm.Contact;
import com.funambol.mailclient.cm.ContactListFullException;
import com.funambol.mailclient.cm.ContactManagerException;
import com.funambol.mailclient.ui.controller.UIController;
import com.funambol.mailclient.loc.Localization;
import com.funambol.util.Log;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.ItemCommandListener;
import javax.microedition.lcdui.TextField;
/**
* shows a list of the recipients of a given message.
* each recipient can be saved as a contact
**/
public class FunCanvasRecipientList extends FunCanvasContactList {
private Message message ;
private String OK= Localization.getMessages().AL_OK_COMMAND;
private Command saveContactCommand;
/**
* create a new instance of funRecipientlist with the given message
*/
public FunCanvasRecipientList(Message message) {
super(message);
}
public void addCommands() {
addCommand(saveContactCommand);
addCommand(UIController.cancelCommand);
}
/**
* nothing to do here
*/
public void removeItemCommands() {
;
}
/**
* nothing to be done here
*/
public void addItemCommands() {
;
}
void initCommands() {
saveContactCommand =
new Command(Localization.getMessages().SAVE_COMMAND, UIController.COMMAND_TYPE, 3);
}
/**
* add the commands the searchbox, and the contacts
*/
protected void initializeContactList() {
try {
/* Address[] to = message.getTo();
Address[] cc = message.getCc();
Address[] bcc = message.getBcc();
Address[] list = new Address[to.length+cc.length+bcc.length];
Log.debug( list.length + " recipients found");
System.arraycopy(to,0,list,0,to.length);
System.arraycopy(cc,0,list,to.length,cc.length);
System.arraycopy(bcc,0,list,to.length+cc.length,bcc.length);
*/
Address [] list = getMessageAddresses();
ContactItem[] contacts = new ContactItem[list.length];
Contact c ;
for (int i = 0; i<list.length; i++) {
c=new Contact(list[i]);
contacts[i] = new ContactItem(
c, i, list[i].getType(), Contact.DEFAULT_EMAIL);
}
setContactItemList(contacts);
} catch (ContactManagerException ex) {
Log.error("error creating contact from one of the recipients");
ex.printStackTrace();
}
}
public void commandAction(Command command, Displayable d) {
if (command == saveContactCommand) {
// try {
// UIController.saveContact(getActiveContact(), true );
UIController.showAddContactScreen(
UIController.display.getCurrent(),getActiveContact());
/**
* } catch (ContactListFullException clfe) {
Log.error("[RecipientsList] Address list is full: "
+ clfe.toString());
UIController.showErrorAlert(
Localization.getMessages().AB_LIMIT_ERROR_MSG);
return;
} catch (AlreadyExistentContactException ex) {
UIController.showAlert(
Localization.getMessages().CONTACT_ALREADY_EXISTS
// showEditContactScreen(null,ex.getExistentContact(),null)
);
ex.printStackTrace();
Log.error(this, "contact" + getActiveContact().getVisibleName()
+ " already exists!");
} catch (ContactManagerException cme) {
Log.error("Contact manager exception trying to save contact " +
getActiveContact().getVisibleName() );
cme.printStackTrace();
} */
}else if (command==UIController.cancelCommand) {
UIController.showBackScreen();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -