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

📄 simplebasisamsinstall.java

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            ams.doApplicationsScreen();        }    }        class ShowInstallApplistScreenActionListener implements ActionListener {        public void actionPerformed(ActionEvent e) {            showInstallAppListScreen();        }    }            /*         * This is the screen the user sees when selecting the Install command button         */    class InstallScreen extends Container {        private static final String message1 = "Choose All to install all apps.";        private static final String message2 = "Choose One to install from a list of apps.";        private static final String message3 = "Choose Cancel to exit without installing.";                public InstallScreen() {                        setLayout(new BorderLayout());            Container buttonContainer = new Container();            if (provisionURL != null) {                buttonContainer.setLayout(new GridLayout(1, 3));                buttonContainer.add(createButton("All", new DiscoveryInstallAllActionListener()));                buttonContainer.add(createButton("One", new DiscoveryInstall1ActionListener()));                buttonContainer.add(createButton("Cancel", new ApplicationsScreenActionListener()));            }                        Container textContainer = new Container() {                public void paint(Graphics g) {                    super.paint(g);                    Dimension d = getSize();                    g.setColor(INSTALL_SCREEN_COLOR);                    g.fillRect(0, 0, d.width, d.height);                    g.setColor(Color.black);                    g.fillRect(0, 0, d.width, d.height / 4);                    g.setColor(Color.white);                    g.setFont(HEADER_FONT);                    FontMetrics fm = getFontMetrics(HEADER_FONT);                    int fheight = (int)fm.getHeight();                    g.drawString("Install Applications", 5, ((d.height / 4) / 2) + (fheight / 2));                    g.setColor(Color.black);                    g.setFont(new Font("Helvetica", Font.PLAIN, 20));                    g.drawString("Discover URL:", 5, 80);                    g.setFont(new Font("Monospaced", Font.PLAIN, 12));                    if (provisionURL != null) {                        g.drawString(provisionURL, 5, 100);                        g.setFont(new Font("Helvetica", Font.PLAIN, 12));                        g.drawString(message1, 5, 140);                        g.drawString(message2, 5, 160);                        g.drawString(message3, 5, 180);                    } else {                        g.drawString("No Provisioning URL provided.", 5, 100);                        g.drawString("The property jump.installer.provisionURL", 5, 140);                        g.drawString("must be provided to the JUMP executive", 5, 160);                        g.drawString("with a valid provisioning server URL.", 5, 180);                    }                                    }            };            textContainer.setBackground(INSTALL_SCREEN_COLOR);            add(textContainer, BorderLayout.CENTER);            add(buttonContainer, BorderLayout.SOUTH);        }                private SimpleBasisAMSImageButton createButton(String label, ActionListener action) {            SimpleBasisAMSImageButton button = new SimpleBasisAMSImageButton();            if (button == null) {                return null;            }            button.addActionListener(action);            button.setEnabled(true);            button.setForeground(BUTTON_BLUE_COLOR);            button.setTextShadow(true);            button.setPaintBorders(true);            button.setLabel(label);            return button;        }    }        private void showInstallAppListScreen() {        Container installAppsListScreen = createInstallAppsListScreen();        ams.showScreen(installAppsListScreen);        ams.setCurrentScreen(INSTALL_APPS_LIST_SCREEN);    }            private SimpleBasisAMSImageButton installAppsListScreenButtons[] = null;    Container createInstallAppsListScreen() {        Container appsListScreen = new Container();        appsListScreen.setLayout(new GridLayout(APPS_LIST_SCREEN_ROWS, APPS_LIST_SCREEN_COLUMNS));        installAppsListScreenButtons = new SimpleBasisAMSImageButton[downloadNames.length];        for (int i = 0; i < downloadNames.length; i++) {            installAppsListScreenButtons[i] = ams.createScreenButton(downloadNames[i], new InstallOneActionListener(i), BUTTON_YELLOW_COLOR);        }        int firstPositionIndex = installAppsListScreenPageNumber * APPS_LIST_SCREEN_NUM_ENTRIES;        for (int i = firstPositionIndex;        i < (installAppsListScreenPageNumber * APPS_LIST_SCREEN_NUM_ENTRIES + APPS_LIST_SCREEN_NUM_ENTRIES); i++) {            if (i < installAppsListScreenButtons.length) {                appsListScreen.add(installAppsListScreenButtons[i]);            } else {                appsListScreen.add(ams.createScreenButton(null, BUTTON_YELLOW_COLOR));            }        }        return appsListScreen;    }        class InstallOneActionListener            implements ActionListener {        int index;                public InstallOneActionListener(int i) {            this.index = i;        }                public void actionPerformed(ActionEvent e) {            new Thread() {                public void run() {                    try {                        showInstallationStatusScreen();                        installationStatusScreen.drawStatusString("Attempting to install: ", downloadNames[index], "INSTALLING");                        Thread.sleep(100);                        JUMPContent content[] = tool.doInstall(downloadNames[index], downloadURIs[index]);                        if (content == null || content.length == 0) {                            installationStatusScreen.drawStatusString("Installing Application: ", downloadNames[index], "PROCESSING...");                        } else {                            installationStatusScreen.drawStatusString("Installing Application: ", downloadNames[index], "DONE");                        }                        Thread.sleep(100);                    } catch (InterruptedException ex) {                        ex.printStackTrace();                    }                    installationStatusScreen.drawStatusDone("Finished installing: " + downloadNames[index],                            new ShowInstallApplistScreenActionListener(), new ApplicationsScreenActionListener());                    try {                        Thread.sleep(100);                    } catch (Exception e) {                        e.printStackTrace();                    }                    ams.refreshApplicationsScreen();                }            }.start();        }    }        /****************************** REMOVE SCREEN ****************************/        public void showRemoveScreen() {        ams.showScreen(createRemoveScreen());        ams.setCurrentScreen(REMOVE_SCREEN);    }        Container createRemoveScreen() {        Container removeContainer = new RemoveScreen();        return removeContainer;    }        /*     * This the screen the user sees after selecting the Remove command button     */    class RemoveScreen extends Container {                public RemoveScreen() {                        setLayout(new BorderLayout());            Container buttonContainer = new Container();            buttonContainer.setLayout(new GridLayout(1, 3));            buttonContainer.add(createButton("All", new RemoveAllActionListener()));            buttonContainer.add(createButton("One", new Remove1ScreenActionListener()));            buttonContainer.add(createButton("Cancel", new ApplicationsScreenActionListener()));                        Container textContainer = new Container() {                public void paint(Graphics g) {                    super.paint(g);                    Dimension d = getSize();                    g.setColor(REMOVE_SCREEN_COLOR);                    g.fillRect(0, 0, d.width, d.height);                    g.setColor(Color.black);                    g.fillRect(0, 0, d.width, d.height / 4);                    g.setColor(Color.white);                    g.setFont(HEADER_FONT);                    FontMetrics fm = getFontMetrics(HEADER_FONT);                    int fheight = (int)fm.getHeight();                    g.drawString("Remove Applications", 5, ((d.height / 4) / 2) + (fheight / 2));                    g.setColor(Color.black);                    g.setFont(new Font("Helvetica", Font.PLAIN, 12));                    g.drawString("Remove Applications Screen:", 5, 110);                    g.drawString("Remove all, Remove 1, or Cancel?", 5, 130);                }            };            textContainer.setBackground(REMOVE_SCREEN_COLOR);            add(textContainer, BorderLayout.CENTER);            add(buttonContainer, BorderLayout.SOUTH);        }                private SimpleBasisAMSImageButton createButton(String label, ActionListener action) {            SimpleBasisAMSImageButton button = new SimpleBasisAMSImageButton();            if (button == null) {                return null;            }            button.addActionListener(action);            button.setEnabled(true);            button.setForeground(BUTTON_BLUE_COLOR);            button.setTextShadow(true);            button.setPaintBorders(true);            button.setLabel(label);            return button;        }    }        class Remove1ScreenActionListener implements ActionListener {        public void actionPerformed(ActionEvent e) {            showRemoveAppListScreen();        }    }        class ShowRemoveApplistScreenActionListener implements ActionListener {        public void actionPerformed(ActionEvent e) {            showRemoveAppListScreen();        }    }        class ShowRemoveScreenActionListener implements ActionListener {        public void actionPerformed(ActionEvent e) {            showRemoveScreen();        }    }        class RemoveOneActionListener implements ActionListener {        JUMPApplication app = null;        public RemoveOneActionListener(JUMPApplication app) {            this.app = app;        }                /* Because this actionPeformed() will be run within the AWT thread,         * we need to run the following in a different thread as it is         * not a good idea to draw within the AWT thread.         */        public void actionPerformed(ActionEvent e) {            new Thread() {                public void run() {                    try {                        showInstallationStatusScreen();                        installationStatusScreen.drawStatusString("Removing Application: ", app.getTitle(), "PROCESSING...");                        Thread.sleep(100);                        if (!ams.isRunningApp(app)) {                            tool.doUninstall(app);                            installationStatusScreen.drawStatusString("Removing Application: ", app.getTitle(), "DONE");                        } else {                            installationStatusScreen.drawStatusString("Removing Application: ", app.getTitle(), "ERROR - application running");                        }                        Thread.sleep(100);                    } catch (InterruptedException ex) {                        ex.printStackTrace();                    }                    installationStatusScreen.drawStatusDone("Finished removing application: " + app.getTitle(),                            new ShowRemoveApplistScreenActionListener(), new ApplicationsScreenActionListener());                    try {                        Thread.sleep(100);                    } catch (Exception e) {                        e.printStackTrace();                    }                    ams.refreshApplicationsScreen();                }            }.start();        }    }        class RemoveAllActionListener implements ActionListener {        public void actionPerformed(ActionEvent e) {        /* Because this actionPeformed() will be run within the AWT thread,         * we need to run the following in a different thread as it is         * not a good idea to draw within the AWT thread.         */            new Thread() {                public void run() {                    try {                        showInstallationStatusScreen();                        JUMPInstallerModule installers[] = JUMPInstallerModuleFactory.getInstance().getAllInstallers();                        for (int i = 0; i < installers.length; i++) {                            JUMPContent[] content = installers[i].getInstalled();                            while (content != null && content.length > 0) {                                if (content[0] != null) {                                    JUMPApplication app = (JUMPApplication)content[0];                                    installationStatusScreen.drawStatusString("Removing Application: ", app.getTitle(), "PROCESSING...");                                    Thread.sleep(100);                                    if (!ams.isRunningApp(app)) {                                        tool.doUninstall(app);                                        installationStatusScreen.drawStatusString("Removing Application: ", app.getTitle(), "DONE");                                    } else {                                        installationStatusScreen.drawStatusString("Removing Application: ", app.getTitle(), "ERROR - application running");                                    }                                    Thread.sleep(100);                                }                                content = installers[i].getInstalled();                            }                        }                    } catch (InterruptedException ex) {                        ex.printStackTrace();                    }                    installationStatusScreen.drawStatusDone("Remove completed.",                            new ShowRemoveScreenActionListener(), new ApplicationsScreenActionListener());                    try {                        Thread.sleep(100);                    } catch (Exception e) {                        e.printStackTrace();                    }                    ams.refreshApplicationsScreen();                }            }.start();        }    }        private void showRemoveAppListScreen() {        Container removeAppsListScreen = createRemoveAppsListScreen();        ams.showScreen(removeAppsListScreen);        ams.setCurrentScreen(REMOVE_APPS_LIST_SCREEN);    }        private SimpleBasisAMSImageButton removeAppsListScreenButtons[] = null;    Container createRemoveAppsListScreen() {        Container removeAppsListScreen = new Container();        removeAppsListScreen.setLayout(new GridLayout(ams.SCREEN_ROWS, ams.SCREEN_COLUMNS));                JUMPInstallerModule installers[] = JUMPInstallerModuleFactory.getInstance().getAllInstallers();        Vector allApps = new Vector();        for (int i = 0; i < installers.length; i++) {            JUMPContent[] apps = installers[i].getInstalled();            for (int j = 0; j < apps.length; j++) {                allApps.add(apps[j]);            }        }        JUMPContent content[] = (JUMPContent[])allApps.toArray(new JUMPContent[]{});        removeAppsListScreenButtons = new SimpleBasisAMSImageButton[content.length];        for (int i = 0; i < content.length; i++) {            JUMPApplication app = (JUMPApplication)content[i];            removeAppsListScreenButtons[i] = ams.createScreenButton(app, new RemoveOneActionListener(app), BUTTON_RED_COLOR);        }        int firstPositionIndex = removeAppsListScreenPageNumber * ams.SCREEN_DISPLAY_ICONS;        for (int i = firstPositionIndex;        i < (removeAppsListScreenPageNumber * ams.SCREEN_DISPLAY_ICONS + ams.SCREEN_DISPLAY_ICONS); i++) {            if (i < removeAppsListScreenButtons.length) {                removeAppsListScreen.add(removeAppsListScreenButtons[i]);            } else {                removeAppsListScreen.add(ams.createScreenButton(null, BUTTON_RED_COLOR));            }        }        return removeAppsListScreen;    }    }

⌨️ 快捷键说明

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