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

📄 logviewermidlet.java

📁 利用SyncML开发客户端程序的中间件
💻 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.tools;

import com.funambol.util.*;
import com.funambol.util.LogViewer;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.MIDlet;

public class LogViewerMidlet extends MIDlet implements CommandListener {
    //------------------------------------------------------------- Private Data
    private Form logRecordList;
    private Command exit;
    private String[] result;
    
    //------------------------------------------------------------- Constructors
    /** Creates a new instance of VisualMidlet */
    public LogViewerMidlet() {
        getDisplay().setCurrent(getLogRecordList());
    }
    
    //----------------------------------------------------------- Public Methods
    /**
     * This method should return an instance of the display.
     */
    public Display getDisplay() {
        return Display.getDisplay(this);
    }
    
    /**
     * This method exit the midlet.
     */
    public void exitMIDlet() {
        getDisplay().setCurrent(null);
        destroyApp(true);
        notifyDestroyed();
    }
    
    /**
     * This method returns instance for logRecordList and must
     * be called instead of accessing logRecordList field directly.
     *
     * @return Instance for logRecordList component
     */
    public Form getLogRecordList() {
        LogViewer lv = new LogViewer();
        result = lv.getLogEntries(lv.RMSLOG);
        
        if (logRecordList == null) {
            logRecordList = new Form("LOG");
            logRecordList.addCommand(getExitCommand());
            logRecordList.setCommandListener(this);
            //logRecordList.setSelectedFlags(new boolean[0]);
        }
        
        for (int i=0; i<result.length; i++) {
            logRecordList.append(new String(result[i]));
        }
        return logRecordList;
    }
    
    /**
     * This method returns instance for exit component and must be called 
     * instead of accessing exit field directly.
     *
     * @return Instance for exit component
     */
    public Command getExitCommand() {
        if (exit == null) {
            exit = new Command("Exit", Command.EXIT, 1);
        }
        return exit;
    }
    
    /** Called by the system to indicate that a command has been invoked
     * on a particular displayable.
     * @param command the Command that ws invoked
     * @param displayable the Displayable on which the command was invoked
     */
    public void commandAction(Command command, Displayable displayable) {
        if (command == exit) {
            exitMIDlet();
        }
    }
    
    /**
     * Life Cicle Related Midlet's method.
     */
    public void startApp() {
    }
    
    /**
     * Life Cicle Related Midlet's method.
     */
    public void pauseApp() {
    }
    
    /**
     * Life Cicle Related Midlet's method.
     */
    public void destroyApp(boolean unconditional) {
    }
}

⌨️ 快捷键说明

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