📄 simplebasisams.java
字号:
Thread launchThread = new LaunchThread(app); launchThread.start(); } } class SwitchToActionListener implements ActionListener { JUMPApplicationProxy app; public SwitchToActionListener(JUMPApplicationProxy app) { this.app = app; } public void actionPerformed(ActionEvent e) { switchToApp(app); } } class KillActionListener implements ActionListener { JUMPApplicationProxy app; public KillActionListener(JUMPApplicationProxy app) { this.app = app; } public void actionPerformed(ActionEvent e) { killApp(app); doKillScreen(); } } class ExitActionListener implements ActionListener { public void actionPerformed(ActionEvent e) { killAllApps(); // shut down the server new com.sun.jumpimpl.os.JUMPOSInterfaceImpl().shutdownServer(); try { md.cancelRegistration(isolateWindowHandler); md.cancelRegistration(lifecycleHandler); } catch (Exception ex) { System.out.println("ERROR: " + ex.getMessage()); ex.printStackTrace(); } finally { } System.exit(0); } } private Image getIconImage(JUMPApplication app) { URL iconPath = app.getIconPath(); if (iconPath != null) { return Toolkit.getDefaultToolkit().createImage(iconPath); } else { return null; } } private SimpleBasisAMSImageButton addCommandButton(String label, Container container, ActionListener action) { SimpleBasisAMSImageButton button = new SimpleBasisAMSImageButton(); if (button == null) { return null; } button.addActionListener(action); button.setEnabled(true); button.setForeground(BUTTON_BLUE_COLOR); button.setTextShadow(false); button.setPaintBorders(true); button.setLabel(label); button.setFont(new Font("Monospaced", Font.PLAIN, 12)); CommandButtonsKeyListener keyListener = new CommandButtonsKeyListener(button); button.addKeyListener(keyListener); container.add(button); return button; } private SimpleBasisAMSImageButton addDialogButton(String label, Container container, 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); container.add(button); return button; } private void clearCommandScreen() { commandContainer.removeAll(); } private void refreshCommandScreen() { commandContainer.validate(); commandContainer.repaint(); } public void clearScreen() { screenContainer.removeAll(); } public void showScreen(Container container) { clearScreen(); screenContainer.add(container, BorderLayout.CENTER); refreshScreen(); } public void refreshScreen() { screenContainer.validate(); screenContainer.repaint(); } SimpleBasisAMSImageButton createScreenButton(JUMPApplication app, ActionListener action, Color color) { SimpleBasisAMSImageButton button = null; // When app is null, create an empty button if (app != null) { Image image = getIconImage(app); if (image != null) { button = new SimpleBasisAMSImageButton(getIconImage(app)); } else { button = new SimpleBasisAMSImageButton(); } if (button == null) { return null; } button.setLabel(app.getTitle().trim()); button.setTextShadow(true); button.addActionListener(action); } else { button = new SimpleBasisAMSImageButton(); if (button == null) { return null; } button.setEnabled(true); button.setForeground(color); button.setPaintBorders(true); button.setFocusable(false); } button.setEnabled(true); button.setForeground(color); button.setPaintBorders(true); ScreenButtonsKeyListener keyListener = new ScreenButtonsKeyListener(button); button.addKeyListener(keyListener); return button; } SimpleBasisAMSImageButton createScreenButton(String title, ActionListener action, Color color) { SimpleBasisAMSImageButton button = null; // Create an empty button button = new SimpleBasisAMSImageButton(); if (button == null) { return null; } button.setEnabled(true); button.setForeground(color); button.setPaintBorders(true); button.setLabel(title); button.setTextShadow(true); button.addActionListener(action); ScreenButtonsKeyListener keyListener = new ScreenButtonsKeyListener(button); button.addKeyListener(keyListener); return button; } SimpleBasisAMSImageButton createScreenButton(ActionListener action, Color color) { SimpleBasisAMSImageButton button = null; // Create an empty button button = new SimpleBasisAMSImageButton(); if (button == null) { return null; } button.setEnabled(true); button.setForeground(color); button.setPaintBorders(true); button.addActionListener(action); ScreenButtonsKeyListener keyListener = new ScreenButtonsKeyListener(button); button.addKeyListener(keyListener); return button; } private JUMPApplicationProxy launchApp(JUMPApplication app) { // There currently isn't a way to extract application arguments. // Will use null for now. JUMPApplicationProxy appProxy = null; synchronized(timeoutObject) { appProxy = alm.launchApplication(app, null); try { // Use a timeout to detect whether or not a JUMPWindow is created // after launching the application. The detection is done in // handleMessage(). If a JUMPWindow isn't detected during the // timeout, it is assumed that there is a problem. timeoutObject.wait(TIMEOUT_VAL); } catch (InterruptedException ex) { ex.printStackTrace(); } } if (appWindowDisplayState) { bringWindowToFront(appProxy); currentApp = appProxy; } refreshCommandScreen(); return appProxy; } private void killAllApps() { JUMPApplicationProxy apps[] = getRunningApps(); for (int i = 0; i < apps.length; i++) { killApp(apps[i]); } } private void killApp(JUMPApplicationProxy app) { destroyApp(app); currentApp = null; } private void bringWindowToFront(JUMPApplicationProxy app) { if (app == null) { trace("ERROR: Cannot do a bringWindowToFront... app is null."); return; } JUMPWindow[] windows = app.getIsolateProxy().getWindows(); if(windows != null) { for (int i = 0; i < windows.length; i++) { wm.setForeground(windows[i]); } } } private void bringWindowToBack(JUMPApplicationProxy app) { if (app == null) { trace("ERROR: Cannot do a bringWindowToBack... app is null."); return; } JUMPWindow[] windows = app.getIsolateProxy().getWindows(); if(windows != null) { for (int i = 0; i < windows.length; i++) { wm.setBackground(windows[i]); } } } private void switchToApp(JUMPApplicationProxy app) { resumeApp(app); bringWindowToFront(app); currentApp = app; } private void resumeApp(JUMPApplicationProxy app) { if (app == null) { return; } trace("*** Trying to resume: " + app.getApplication().getTitle()); app.resumeApp(); } private void destroyApp(JUMPApplicationProxy app) { if (app == null) { return; } trace("*** Trying to kill: " + app.getApplication().getTitle()); app.destroyApp(); } private void pauseApp(JUMPApplicationProxy app) { if (app == null) { return; } trace("*** Trying to pause: " + app.getApplication().getTitle()); app.pauseApp(); } boolean isRunningApp(JUMPApplication app) { JUMPApplicationProxy proxy[] = getRunningApps(); for (int i = 0; i < proxy.length; i++) { if (proxy[i].getApplication().equals(app)) { return true; } } return false; } private JUMPApplicationProxy[] getRunningApps() { JUMPIsolateProxy[] ips = lcm.getActiveIsolates(); Vector appsVector = new Vector(); for (int i = 0; i < ips.length; i++) { JUMPIsolateProxy ip = ips[i]; JUMPApplicationProxy appProxy[] = ip.getApps(); if (appProxy != null) { for (int j = 0; j < appProxy.length; j++) { appsVector.add(appProxy[j]); } } } return (JUMPApplicationProxy[]) appsVector.toArray(new JUMPApplicationProxy[]{}); } private JUMPApplication[] getInstalledApps() { JUMPInstallerModule installers[] = JUMPInstallerModuleFactory.getInstance().getAllInstallers(); Vector appsVector = new Vector(); if (installers == null) { return null; } for (int i = 0; i < installers.length; i++) { JUMPContent[] content = installers[i].getInstalled(); if (content != null) { for(int j = 0; j < content.length; j++) { appsVector.add((JUMPApplication)content[j]); } } } return (JUMPApplication[]) appsVector.toArray(new JUMPApplication[]{}); } static void trace(String str) { if (verbose) { System.out.println(str); } } class DisplayLayout extends GridLayout { public DisplayLayout() { super(SCREEN_ROWS, SCREEN_COLUMNS); } } /** * Implementation of the interface's start() method. */ public void start() { System.err.println("*** Starting SimpleBasisAMS ***"); if (setup()) { if (frame != null) { frame.setVisible(true); } doApplicationsScreen(); } else { System.err.println("*** Setup of SimpleBasisAMS failed. ***"); } } void setCurrentScreen(int screen) { CURRENT_SCREEN = screen; } int getCurrentScreen() { return CURRENT_SCREEN; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -