appmanageruiimpl.java

来自「This is a resource based on j2me embedde」· Java 代码 · 共 1,791 行 · 第 1/5 页

JAVA
1,791
字号
/* * * * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER *  * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. *  * 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 version 2 for more details (a copy is * included at /legal/license.txt). *  * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA *  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. */                         package com.sun.midp.appmanager;import javax.microedition.lcdui.*;import com.sun.midp.configurator.Constants;import com.sun.midp.installer.*;import com.sun.midp.main.*;import com.sun.midp.midletsuite.*;import com.sun.midp.i18n.Resource;import com.sun.midp.i18n.ResourceConstants;import com.sun.midp.log.Logging;import com.sun.midp.log.LogChannels;import com.sun.midp.payment.PAPICleanUp;import com.sun.midp.midlet.MIDletSuite;import java.util.*;/** * The Graphical MIDlet selector Screen. * <p> * It displays a list (or grid to be exact) of currently installed * MIDlets/MIDlet suites (including the Installer MIDlet). Each MIDlet or * MIDlet suite is represented by an icon with a name under it. * An icon from a jad file for the MIDlet/MIDlet suite representation * is used if possible, otherwise a default icon is used. * * There is a a set of commands per MIDlet/MIDlet suite. Note that * the set of commands can change depending on the corresponding MIDlet state. * For MIDlets/MIDlet suites that are not running the following commands are * available: * <ul> * <li><b>Launch</b>: Launch the MIDlet or the MIDlet Selector *      if it is a suite. * <li><b>Remove</b>: Remove the MIDlet/MIDlet suite teh user selected *      (with confirmation). </li> * <li><b>Update</b>: Update the MIDlet/MIDlet suite the user selected.</li> * <li><b>Info</b>: Show the user general information *    of the selected MIDlet/MIdlet suite. </li> * <li><b>Settings</b>: Let the user change the manager's settings. * </ul> * * For MIDlets/MIDlet suites that are running the following commands are * available: * <ul> * <li><b>Bring to foreground</b>: Bring the running MIDlet to foreground * <li><b>End</b>: Terminate the running MIDlet * <li><b>Remove</b>: Remove the MIDlet/MIDlet suite teh user selected *      (with confirmation). </li> * <li><b>Update</b>: Update the MIDlet/MIDlet suite the user selected.</li> * <li><b>Info</b>: Show the user general information *    of the selected MIDlet/MIdlet suite. </li> * <li><b>Settings</b>: Let the user change the manager's settings. * </ul> * * Exactly one MIDlet from a MIDlet suite could be run at the same time. * Each MIDlet/MIDlet suite representation corresponds to an instance of * MidletCustomItem which in turn maintains a reference to a MIDletSuiteInfo * object (that contains info about this MIDlet/MIDlet suite). * When a MIDlet is launched or a MIDlet form a MIDlet suite is launched * the proxy instance in the corresponding MidletCustomItem is set to * a running MIDletProxy value. It is set back to null when MIDlet exits. * * Running midlets can be distinguished from non-running MIdlets/MIDlet suites * by the color of their name. */class AppManagerUIImpl extends Form    implements AppManagerUI, ItemCommandListener, CommandListener {    /**     * The font used to paint midlet names in the AppSelector.     * Inner class cannot have static variables thus it has to be here.     */    private static final Font ICON_FONT = Font.getFont(Font.FACE_SYSTEM,                                                         Font.STYLE_BOLD,                                                         Font.SIZE_SMALL);    /**     * The font used to paint midlet names in the AppSelector.     * Inner class cannot have static variables thus it has to be here.     */    private static final Font ICON_FONT_UL = Font.getFont(Font.FACE_SYSTEM,                            Font.STYLE_BOLD | Font.STYLE_UNDERLINED,                            Font.SIZE_SMALL);    /**     * The image used to draw background for the midlet representation.     * IMPL NOTE: it is assumed that background image is larger or equal     * than all other images that are painted over it     */    private static final Image ICON_BG =        GraphicalInstaller.getImageFromInternalStorage("_ch_hilight_bg");    /**     * Cashed background image width.     */    private static final int bgIconW = ICON_BG.getWidth();    /**     * Cashed background image height.     */    private static final int bgIconH = ICON_BG.getHeight();    /**     * The icon used to display that user attention is requested     * and that midlet needs to brought into foreground.     */    private static final Image FG_REQUESTED =        GraphicalInstaller.getImageFromInternalStorage("_ch_fg_requested");    /**     * The image used to draw disable midlet representation.     */    private static final Image DISABLED_IMAGE =        GraphicalInstaller.getImageFromInternalStorage("_ch_disabled");    /**     * The color used to draw midlet name     * for the hilighted non-running running midlet representation.     */    private static final int ICON_HL_TEXT = 0x000B2876;    /**     * The color used to draw the shadow of the midlet name     * for the non hilighted non-running midlet representation.     */    private static final int ICON_TEXT = 0x003177E2;    /**     * The color used to draw the midlet name     * for the non hilighted running midlet representation.     */    private static final int ICON_RUNNING_TEXT = 0xbb0000;    /**     * The color used to draw the midlet name     * for the hilighted running midlet representation.     */    private static final int ICON_RUNNING_HL_TEXT = 0xff0000;    /**     * Tha pad between custom item's icon and text     */    private static final int ITEM_PAD = 2;    /**     * Cashed truncation mark     */    private static final char truncationMark =        Resource.getString(ResourceConstants.TRUNCATION_MARK).charAt(0);    /** Command object for "Exit" command for splash screen. */    private Command exitCmd =        new Command(Resource.getString(ResourceConstants.EXIT),                    Command.BACK, 1);    /** Command object for "Launch" install app. */    private Command launchInstallCmd =        new Command(Resource.getString(ResourceConstants.LAUNCH),                    Command.ITEM, 1);    /** Command object for "Launch" CA manager app. */    private Command launchCaManagerCmd =        new Command(Resource.getString(ResourceConstants.LAUNCH),                    Command.ITEM, 1);    /** Command object for "Launch" CA manager app. */    private Command launchCompManagerCmd =        new Command(Resource.getString(ResourceConstants.LAUNCH),                    Command.ITEM, 1);    /** Command object for "Launch" ODT Agent app. */    private Command launchODTAgentCmd =        new Command(Resource.getString(ResourceConstants.LAUNCH),                    Command.ITEM, 1);    /** Command object for "Launch". */    private Command openCmd =        new Command(Resource.getString(ResourceConstants.OPEN),                    Command.ITEM, 1);    /** Command object for "Info". */    private Command infoCmd =        new Command(Resource.getString(ResourceConstants.INFO),                    Command.ITEM, 2);    /** Command object for "Remove". */    private Command removeCmd =        new Command(Resource.getString(ResourceConstants.REMOVE),                    Command.ITEM, 3);    /** Command object for "Update". */    private Command updateCmd =        new Command(Resource.getString(ResourceConstants.UPDATE),                    Command.ITEM, 4);    /** Command object for "Application settings". */    private Command appSettingsCmd =        new Command(Resource.                    getString(ResourceConstants.APPLICATION_SETTINGS),                    Command.ITEM, 5);    /** Command object for moving to internal storage. */    private Command moveToInternalStorageCmd =        new Command(Resource.                    getString(ResourceConstants.AMS_MOVE_TO_INTERNAL_STORAGE),                    Command.ITEM, 6);    /** Command object for "view components". */    private Command viewCompCmd =        new Command(Resource.getString(ResourceConstants.VIEW_COMP),                    Command.ITEM, 7);    /** Command object for "Cancel" command for the remove form. */    private Command cancelCmd =        new Command(Resource.getString(ResourceConstants.CANCEL),                    Command.CANCEL, 1);    /** Command object for "Remove" command for the remove form. */    private Command removeOkCmd =        new Command(Resource.getString(ResourceConstants.REMOVE),                    Command.SCREEN, 1);    /** Command object for "Back" command for back to the AppSelector. */    Command backCmd =        new Command(Resource.getString(ResourceConstants.BACK),                    Command.BACK, 1);    /** Command object for "Bring to foreground". */    private Command fgCmd = new Command(Resource.getString                                        (ResourceConstants.FOREGROUND),                                        Command.ITEM, 1);    /** Command object for "End" midlet. */    private Command endCmd = new Command(Resource.getString                                         (ResourceConstants.END),                                         Command.ITEM, 1);    /** Command object for "Yes" command. */    private Command runYesCmd = new Command(Resource.getString                                            (ResourceConstants.YES),                                            Command.OK, 1);    /** Command object for "No" command. */    private Command runNoCmd = new Command(Resource.getString                                           (ResourceConstants.NO),                                           Command.BACK, 1);    /** Command object for "Select" command in folder list. */    private Command selectFolderCmd = new Command(Resource.getString                                           (ResourceConstants.SELECT),                                           Command.OK, 1);    /** Command object for "Select" command in folder list. */    private Command selectItemFolderCmd = new Command(Resource.getString                                           (ResourceConstants.SELECT),                                           Command.OK, 1);    /** Command object for "Change folder" command. */    private Command changeFolderCmd = new Command(Resource.getString                                           (ResourceConstants.AMS_CHANGE_FOLDER),                                           Command.ITEM, 1);    // Current locale    private String locale;    // Layout direction. True if direction is right-to-left    private boolean RL_DIRECTION;    // Orientation of text, can be Graphics.RIGHT or Graphics.Left    private int TEXT_ORIENT;    /** Display for the Manager MIDlet. */    ApplicationManager manager;    /** task manager */    AppManagerPeer appManager;    /** MIDlet Suite storage object. */    private MIDletSuiteStorage midletSuiteStorage;    /** Display for the Manager MIDlet. */    Display display; // = null    /** Keeps track of when the display last changed, in milliseconds. */    private long lastDisplayChange;    /** MIDlet to be removed after confirmation screen was accepted */    private RunningMIDletSuiteInfo removeMsi;    /** last Item that was selected */    private RunningMIDletSuiteInfo lastSelectedMsi;   /** vector of existing MidletCustomItems */    private Vector mciVector;    /** UI used to display error messages. */    private DisplayError displayError;    private MIDletSwitcher midletSwitcher;    /** List of available folders */    private FolderList folderList;    /** currently selected folder' id */    private int currentFolderId;    /** If there are folders */    private boolean foldersOn;    /** custom item for which command to change folder was activated */    private MidletCustomItem mciToChangeFolder;    /** running MIDlet selectors */    private Vector midletSelectors;        /** suite id of midlet exiting from AMS menu */    int exitingMidletSuiteId;    /** class name of midlet exiting from AMS menu */    String exitingMidletClassName;        private void init(ApplicationManager manager, AppManagerPeer appManager,                 Display display, DisplayError displayError, boolean foldersOn) {        mciToChangeFolder = null;        this.foldersOn = foldersOn;        if (foldersOn) {            folderList = new FolderList();            folderList.addCommand(exitCmd);            folderList.addCommand(selectFolderCmd);            folderList.setSelectCommand(selectFolderCmd);            folderList.setCommandListener(this);        }

⌨️ 快捷键说明

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