⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recipientsstringitem.java

📁 The Funambol J2ME Mail Client aims to be a light, easy to use, free email client for J2ME devices.
💻 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.ui.controller.UIController;
import com.funambol.mailclient.loc.Localization;
import com.funambol.util.Log;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Vector;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Item;

import javax.microedition.lcdui.StringItem;
//import com.funambol.mailclient.ui.mvc.view.AddressList;


public class RecipientsStringItem extends StringItem {
    
    public Command addRecipientsCommand;
    
    // private AddressList addressList;
    private Vector addressVector;
    
    private final String ADD_RECIPIENTS=Localization.getMessages().ADD_RECIPIENTS_COMMAND;
    private final String TO=Localization.getMessages().TO_LABEL;
    private final String CC=Localization.getMessages().CC_LABEL;
    private final String BCC=Localization.getMessages().BCC_LABEL;
    private Message message;
    
    /**
     * Creates a new instance of RecipientsStringItem
     */
    public RecipientsStringItem(Message message) {
        // TODO: use preprocessing here to avoid Motorola Gray Skin issue
        // For Motorola phones use Item.Button apperance mode
        super(null,Localization.getMessages().SELECT_RECIPIENTS, Item.HYPERLINK);
        addRecipientsCommand=new Command(ADD_RECIPIENTS,UIController.COMMAND_TYPE,0);
        this.setDefaultCommand(addRecipientsCommand);
        //this.setItemCommandListener(this);
        
        //TODO: add addresses from the message
        this.setMessage(message);
    }
    
    /**
     * commandlistener implementation
     */
    
    public void update(){
        //TODO: should we use just addressvector  to
        //fill the content of the recipient StringItem?
        //it's slower but more clean...
        //String s=Localization.getMessages("RSIPleaseAddRecipientsMsg");
        String s="";
        Address[] list=new Address[0];
        try {
            list = message.getTo();
        } catch (Exception ex) {
            ex.printStackTrace();
            Log.error(this, "exception parsing to message addresses");
        }
        //Log.debug(this, "to list created, "+list.length+" elements");
        if (list.length>0) {
            s=TO;
            for(int i=0;i<list.length;i++) {
                s+= i > 0 ? ", ":"";
                s+=list[i].getVisibleName();
                // Log.debug(this, "addedd " + list[i].getVisibleName());
            }
            s+="\n";
        }
        list=new Address[0];
        try {
            list=message.getCc();
        } catch (Exception ex) {
            Log.error(this, "exception parsing cc message addresses");
            ex.printStackTrace();
        }
        //Log.debug(this, "cc list created, "+list.length+" elements");
        if (list.length>0) {
            //  Log.debug("cc list length > 0");
            s+=CC;
            for(int i=0;i<list.length;i++) {
                s+= i > 0 ? ", ":"";
                s+=list[i].getVisibleName();
            }
            s+="\n";
        }
        
        list=new Address[0];
        try {
            list=message.getBcc();
        } catch (Exception ex) {
            ex.printStackTrace();
            Log.error(this, "exception parsing Bcc message addresses");
        }
        //Log.debug(this, "bcc list created, "+list.length+" elements");
        
        if (list.length>0) {
            s+=BCC;
            for(int i=0;i<list.length;i++) {
                s+= i > 0 ? ", ":"";
                s+=list[i].getVisibleName();
            }
        }
        if (s.equals(""))
            s=Localization.getMessages().SELECT_RECIPIENTS;
        this.setText(s);
    }
    
    void setMessage(Message message) {
        this.message=message;
        update();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -