Examples of JXAenvUtils


Examples of net.sf.jiga.xtended.kernel.JXAenvUtils

     * net.sf.jiga.xtended.ui.DisplayInterface, java.util.Map, java.util.List)
     * @see #_uninstallExtensions(net.sf.jiga.xtended.kernel.JXAenvUtils,
     * java.util.Map, boolean, java.io.File)
     */
    public static <U> JXAenvUtils _installExtensions(Map<String, Map<String, U>> map, boolean libpath, File backupDirectory) throws MalformedURLException {
        JXAenvUtils env = new JXAenvUtils();
        env.setJXAenvPath(_findExtPath(libpath));
        env.setBigBuffer(true);
        return _installExtensions(env, map, libpath, backupDirectory);

    }

Examples of net.sf.jiga.xtended.kernel.JXAenvUtils

     *
     * @param backupDirectory if set it is where the removed files will be
     * backed up
     */
    public static <U> JXAenvUtils _uninstallExtensions(Map<String, Map<String, U>> map, boolean libpath, File backupDirectory) {
        JXAenvUtils env = new JXAenvUtils();
        env.setJXAenvPath(_findExtPath(libpath));
        return _uninstallExtensions(env, map, libpath, backupDirectory);
    }

Examples of net.sf.jiga.xtended.kernel.JXAenvUtils

    public static <U> JXAenvUtils _installExtensions(final JXAenvUtils env, final Map<String, Map<String, U>> map, final boolean libpath, final File backupDirectory) throws MalformedURLException {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<JXAenvUtils>() {
                public JXAenvUtils run() throws MalformedURLException, CloneNotSupportedException {
                    if (backupDirectory instanceof File) {
                        JXAenvUtils backenv = (JXAenvUtils) env.clone();
                        backenv.silent = true;
                        System.out.println(log("Loading backup " + (libpath ? "natives" : "extensions") + " (if available)...", LVL.SYS_NOT));
                        if (libpath) {
                            __installExtensions(backenv, __baseFileMapNat(map, backupDirectory.toURI().toURL(), false), libpath);
                        } else {

Examples of net.sf.jiga.xtended.kernel.JXAenvUtils

        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
            public void uncaughtException(Thread t, Throwable e) {
                ThreadWorks._uncaughtException(true, t, e);
            }
        });
        JXAenvUtils env = new JXAenvUtils();
        if (!ExtensionsClassLoader.isResourceLoaded()) {
            ExtensionsClassLoader._load(env);
        }
        if ((params & _DO) == 0) {
            String[] options = new String[]{"Java SE Installer", "Java Applet Installer", "Java SE Installer w/ Log"};
            Object res = null;
            while (res == null) {
                int set = params & bits._getMask(_SET);
                res = UIMessage.showSelectDialog(null, new JLabel("<html><center>Please choose the setup mode : <ol>"
                        + "<li>Java SE Installer;</li>"
                        + "<li>Java Applet Installer;</li>"
                        + "</ol>(w/ Log means that debugging may be enabled <br>by launching a <b>Jconsole</b> to monitor)</center></html>"), "Setup", options, options[0]);
                if (options[1].equals(res)) {
                    params |= DO_APPLET;
                }
                if (options[0].equals(res)) {
                    params |= DO_APPLICATION;
                }
                if (options[2].equals(res)) {
                    params |= DO_APPLICATION | SET_LOGTRACE;
                }
                if (res == null) {
                    if (JOptionPane.YES_OPTION == UIMessage.showConfirmDialog(null, "Are your sure to cancel the setup process ?", "Cancel setup ?", JOptionPane.YES_NO_OPTION)) {
                        if ((set & SET_KEEPALIVE) == 0) {
                            System.exit(0);
                        } else {
                            return;
                        }
                    }
                }
            }
        }
        int doIt = params & bits._getMask(_DO);
        int setIt = params & bits._getMask(_SET);
        try {
            if ((setIt & SET_LOGTRACE) != 0) {
                _debugSys = true;
            }
            if ((doIt & DO_APPLET) != 0) {
                JPanel panel = _goWeb(new URL(rb.getString("appletInstallerURL")));
                UIMessage.showConfirmDialog(null, panel, "Load Applet", JOptionPane.DEFAULT_OPTION);
                if ((setIt & SET_KEEPALIVE) == 0) {
                    System.exit(0);
                } else {
                    return;
                }
            }
            if ((doIt & DO_APPLICATION) != 0) {
                /*
                 * "\"" + _getJavaExecutablePath() + "\""
                 */
                String[] options = new String[]{"Update", "Uninstall", "Update w/ Log"};
                Object res = null;
                while (res == null) {
                    res = UIMessage.showSelectDialog(null, new JLabel("<html><center>Please choose : <ol>"
                            + "<li>Update;</li>"
                            + "<li>Uninstall;</li>"
                            + "</ol>(w/ Log means that debugging may be enabled <br>by launching a <b>JConsole</b> to monitor)</center></html>"), "Setup", options, options[0]);
                    if (options[1].equals(res)) {
                        params |= DO_UNINSTALL;
                    }
                    if (options[0].equals(res)) {
                        params |= DO_INSTALL;
                    }
                    if (options[2].equals(res)) {
                        params |= DO_INSTALL | SET_LOGTRACE;
                    }
                    if (res == null) {
                        if (JOptionPane.YES_OPTION == UIMessage.showConfirmDialog(null, "Are your sure to cancel the setup process ?", "Cancel setup ?", JOptionPane.YES_NO_OPTION)) {
                            break;
                        }
                    }
                }
                if (res == null) {
                    if ((setIt & SET_KEEPALIVE) == 0) {
                        System.exit(0);
                    } else {
                        return;
                    }
                } else {

                    doIt = params & bits._getMask(_DO);
                    setIt = params & bits._getMask(_SET);

                }
            }
            final LinkedList<String> envPaths = new LinkedList<String>();
            String installerPath = new File(FileHelper._USERHOMEDIRECTORY, "Desktop" + File.separator + "JXA Manager").getAbsolutePath();
            if ((doIt & DO_UNINSTALL) != 0) {
                ExtensionsInstaller.showSplash = (setIt & SET_SPLASH) != 0 && ThreadWorks.Swing.isEventDispatchThread();
                env = _uninstallExtensions(_getJXANatenvFiles(null, (setIt & SET_LOCAL) != 0), true, null);
                env = new JXAenvUtils();
                env.setJXAenvPath(FileHelper._USERHOMESTOREDIRECTORY.getPath());
                env = _uninstallExtensions(_getJXANatenvFiles(null, (setIt & SET_LOCAL) != 0), true, null);
                if (env.isResourceLoaded() || env.hasLoadErrors()) {
                    throw new Exception("JXANat env failed.");
                }
                envPaths.add(env.getJXAenvPath());
                env = _uninstallExtensions(_getJXAExtenvFiles(null, (setIt & SET_LOCAL) != 0, true), false, null);
                env = new JXAenvUtils();
                env.setJXAenvPath(FileHelper._USERHOMESTOREDIRECTORY.getPath());
                env = _uninstallExtensions(_getJXAExtenvFiles(null, (setIt & SET_LOCAL) != 0, true), false, null);
                if (env.isResourceLoaded() || env.hasLoadErrors()) {
                    throw new Exception("JXA env failed.");
                }
                envPaths.add(env.getJXAenvPath());
                File installer = new File(installerPath);
                _erase(installer);
            }
            if ((doIt & DO_INSTALL) != 0) {
                ExtensionsInstaller.showSplash = (setIt & SET_SPLASH) != 0 && ThreadWorks.Swing.isEventDispatchThread();
                env = _installExtensions(_getJXAExtenvFiles(null, (setIt & SET_LOCAL) != 0, true), false, FileHelper._USERHOMESTOREDIRECTORY);
                if (!env.isResourceLoaded() || env.hasLoadErrors()) {
                    throw new Exception("JXA env failed.");
                } else {
                    /**
                     * backup new installed files
                     */
                    env.setJXAenvPath(FileHelper._USERHOMESTOREDIRECTORY.getPath());
                    env.loadResource();
                }
                envPaths.add(env.getJXAenvPath());
                env = _installExtensions(_getJXANatenvFiles(null, (setIt & SET_LOCAL) != 0), true, FileHelper._USERHOMESTOREDIRECTORY);
                if (!env.isResourceLoaded() || env.hasLoadErrors()) {
                    throw new Exception("JXANat env failed.");
                } else {
                    /**
                     * backup new installed files
                     */
                    env.setJXAenvPath(FileHelper._USERHOMESTOREDIRECTORY.getPath());
                    env.loadResource();
                }
                envPaths.add(env.getJXAenvPath());
                InputStream inAppInstaller = ExtensionsInstaller.class.getResourceAsStream("/setup.zip");
                if (inAppInstaller != null) {
                    String message = "<html>installing " + installerPath + "...</html>";
                    long wait = UIMessage.displayProgress(message, env.getUIMessageProgressBar(), 0, 100, null);
                    ZipInputStream unzip = new ZipInputStream(inAppInstaller);
                    ZipEntry ze = null;
                    while ((ze = unzip.getNextEntry()) != null) {
                        File newFile = new File(installerPath, ze.getName());
                        if (ze.isDirectory()) {
                            newFile.mkdirs();
                        } else {
                            _fileCopy(unzip, newFile, false, true);
                        }
                        unzip.closeEntry();
                    }
                    unzip.close();
                    inAppInstaller.close();
                    UIMessage.updateProgress(wait, 50, 100);
                    Map<String, Map<String, URL>> map = new LinkedHashMap<String, Map<String, URL>>();
                    URL url = new URL(rb.getString("extPathURL") + rb.getString("extInstallerJar"));
                    map.put(_getSysValue("os.name"), Collections.singletonMap(url.getPath(), url));
                    env = new JXAenvUtils();
                    if (OS_MAC.isEnv()) {
                        env.setJXAenvPath(installerPath + File.separator + rb.getString("installerAppName") + File.separator + "Contents" + File.separator + "Resources" + File.separator + "Java");
                    } else {
                        env.setJXAenvPath(installerPath);
                    }
                    env.setBigBuffer(true);
                    env = _installExtensions(env, map, false, new File(_findExtPath(false)));
                    if (OS_MAC.isEnv()) {
                        _runShell(new String[]{"/bin/chmod", "755", "\"" + installerPath + File.separator + rb.getString("installerAppName") + File.separator + "Contents" + File.separator + "MacOS" + File.separator + "sf3jswing-jxakernel\""}, false, true, false);
                    }
                    if (OS_LINUX.isEnv()) {
                        _runShell(new String[]{"/bin/chmod", "755", "\"" + installerPath + File.separator + rb.getString("installerAppName") + "\""}, false, true, false);
                    }
                    UIMessage.updateProgress(wait, 100, 100);
                    UIMessage.hideProgress(wait);
                }
            }
            String paths = "", sep = "";
            for (String path : envPaths) {
                paths += sep + path;
                sep = File.pathSeparator;
            }
            final String myPaths = paths;
            final String[] installFinishedTxt = new String[]{"<html><b>Successfully " + ((doIt & DO_UNINSTALL) != 0 ? "uninstalled" : "installed") + "</b> Java Extension(s) into ",
                ((doIt & DO_INSTALL) != 0 ? "<br><b>You need to <u>restart your browser</u> and the applet you were starting.</b><br>Notice : To uninstall, open a terminal/shell and run : <pre>java " + ExtensionsInstaller.class.getCanonicalName() + " -uninstall</pre> !" : "") + "</html>"
            };
            final JLabel installFinished = new JLabel(installFinishedTxt[0] + paths
                    + installFinishedTxt[1]);
            installFinished.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseExited(MouseEvent e) {
                    super.mouseExited(e);
                    installFinished.setText(installFinishedTxt[0] + myPaths + installFinishedTxt[1]);
                    installFinished.repaint();
                }

                @Override
                public void mouseEntered(MouseEvent e) {
                    super.mouseEntered(e);
                    installFinished.setText(installFinishedTxt[0] + "<u>" + myPaths + "</u>" + installFinishedTxt[1]);
                    installFinished.repaint();
                }

                @Override
                public void mouseClicked(MouseEvent e) {
                    super.mouseClicked(e);
                    for (String p : envPaths) {
                        try {
                            _goWeb(new File(p).toURI().toURL());
                        } catch (MalformedURLException ex) {
                            if (_debugSys) {
                                ex.printStackTrace();
                            }
                        }
                    }
                }
            });
            new UIMessage(true, installFinished, null, UIMessage.ENABLED_TYPE);
            if (OS_MAC.isEnv()) {
                InputStream inScript = ExtensionsInstaller.class.getResourceAsStream("/net/sf/jiga/xtended/kernel/restartSafari.applescript");
                File tmpScript = _createTempFile("appleScript_", _TMPDIRECTORY);
                _fileCopy(inScript, tmpScript, false, true);
                inScript.close();
                _runShell(new String[]{"osascript", tmpScript.getAbsolutePath()}, false, true, (setIt & SET_LOGTRACE) != 0);
            }
            if ((setIt & SET_KEEPALIVE) == 0) {
                System.exit(0);
            }
        } catch (Exception ex) {
            if (_debugSys) {
                ex.printStackTrace();
            }
            new UIMessage(true, new JLabel("<html><b>Failed to " + ((doIt & DO_UNINSTALL) != 0 ? "uninstall" : "install") + "</b> Java Extension(s) into " + env.getJXAenvPath() + " .<br>Click ok to see the stack trace ! <br> You may CAREFULLY delete recently modified files from " + _findExtPath(false) + " and " + _findExtPath(true) + ".</html>"), null, UIMessage.ERROR_TYPE);
            _popExceptionToUser(true, Thread.currentThread(), ex);
            if ((setIt & SET_KEEPALIVE) == 0) {
                System.exit(1);
            }
        }

Examples of net.sf.jiga.xtended.kernel.JXAenvUtils

     * <li>for mac systems there's no native support with JMF</li>
     * </ul>
     * @param cpDir must be a writable directory and found in the classPath
    @return true if the registry file's been successfully found and installed*/
    public static boolean _installJMFRegistry(File cpDir) {
        JXAenvUtils env = new JXAenvUtils(ExtensionsClassLoader.getInstance().getClassLoader());
        env.addEnvFile("jmfRegistry", env.getEnvClassLoader().getResource("jmf.properties"));
        env.setJXAenvPath(cpDir.getPath());
        env.loadResource();
        return env.isResourceLoaded();
    }

Examples of net.sf.jiga.xtended.kernel.JXAenvUtils

    }
    JXAenvUtils env;

    private JFCFrame() {
        super(JXAenvUtils._defaultGC);
        env = new JXAenvUtils(Thread.currentThread().getContextClassLoader());
        LogManager.getLogManager().addLogger(env);
    }

Examples of net.sf.jiga.xtended.kernel.JXAenvUtils

        env.antClassName = antapplet.getClass().getName();
    }

    public JFCApplet() {
        super();
        env = new JXAenvUtils(Thread.currentThread().getContextClassLoader());
        LogManager.getLogManager().addLogger(env);
    }
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.