Package xplanetconfigurator.util

Examples of xplanetconfigurator.util.XPlanetRessourceFinder


        if (fileName == null) {
            // If the combo box is empty take the name of the body, e.g. 'earth', 'moon',...
            fileName = this.getMarkerName();
            this.logger.finer("Take the name of the panel (body) as file name: " + fileName);
        }
        XPlanetRessourceFinder rf = new XPlanetRessourceFinder();
        String downloaderRootDir = rf.getRootDirectoryForDownloads();
        String dir = downloaderRootDir + File.separator + "images";
        String path = dir + File.separator + fileName;
        File f = new File(path);
        if (f.exists()) {
            this.logger.finer("The map for '" + fileName + "' does exist on local drive.");
View Full Code Here


        }
    }//GEN-LAST:event_jCheckBoxMenuItemAllowInternetConnectionActionPerformed

    private void jMenuItemGuessRessourcesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemGuessRessourcesActionPerformed
        this.stopXPlanet();
        XPlanetRessourceFinder rf = new XPlanetRessourceFinder();
        rf.resetXPlanetDirs();
        this.checkWetherXPlanetRessourcesAreKnown();
    }//GEN-LAST:event_jMenuItemGuessRessourcesActionPerformed
View Full Code Here

        // Do not warn the user if he starts the application
        logger = Logger.getLogger(this.getClass().getName());
        initComponents();
        new LoggingBoard(this.jTextAreaXPlanetMessages, this.jTextAreaDownloaderMessages);
        // Inits the -searchdir if known
        XPlanetRessourceFinder rf = new XPlanetRessourceFinder(true);
        this.checkWetherXPlanetRessourcesAreKnown();
        this.guessXPlanetExecutable();
        this.loadUserPrefs();
        this.fillComponents();
        // this.board = new LoggingBoard(this.jTextAreaMessages);
View Full Code Here

        }
        return false;
    }

    private void checkWetherXPlanetRessourcesAreKnown() {
        XPlanetRessourceFinder rf = new XPlanetRessourceFinder();
        String dir = rf.getXPlanetDirUsed();
        if (dir == null || "".equals(dir)) {
            String msg =
                    "Now starting XPlanet to analyse its output\n" +
                    "to guess the directory it uses for ressources.";
            this.popInfo(msg);
View Full Code Here

        }
    }

    private void testForXPlanetRessources() {
        String executable = this.getOrGuessXPlanetExecutable();
        XPlanetRessourceFinder rf = new XPlanetRessourceFinder();
        String command = executable + " -config shouldNotExist -verbosity 4" + " -num_times 1";
        String searchdir = rf.getXPlanetSearchDir();
        if (!"".equals(searchdir)) {
            command = command + " -searchdir " + searchdir;
        }
        XPlanetTimer timer = new XPlanetTimer(this, 0, command);
        // Wait for the command. It will write its system.out and system.err
        // into the text area of 'XPlanet Messages'.
        this.jTextAreaXPlanetMessages.setText("");
        timer.exec();
        String messages = this.jTextAreaXPlanetMessages.getText();
        // if a dir was found it a stored automatically
        String dir = rf.getXPlanetDirTested(messages);
        if (dir != null) {
            String msg =
                    "Found the directory XPlanet uses\n" +
                    "to read the config file from. It is:\n" +
                    dir + "\n\n" +
View Full Code Here

     * <br>Fill the text areas for the command line and config file.
     * <br>Fill all Controls all over the GUI.
     */
    private void readConfigFile() {
        // Find the config directory XPlanet would probably use.
        XPlanetRessourceFinder f = new XPlanetRessourceFinder();
        // Do not use the -searchdir.
        // Use the -searchdir from the moment on it is known from the current
        // command line (that is unknowd at this moment, because it is still
        // not loaded from file).
        String configDir = f.getRessourceDirectory("config");
        // Now use the directory
        File cfg = new File(configDir + File.separator + MainFrame.getCONFIG_NAME());
        if (!cfg.exists()) {
            this.logger.fine("Found no config file " + cfg.getAbsolutePath());
            this.selectControlPanel("-config");
            return;
        }
        if (!cfg.isFile()) {
            this.logger.fine("Config file is not a file: " + cfg.getAbsolutePath());
            this.selectControlPanel("-config");
            return;
        }
        FileUtil util = new FileUtil();
        String configParameters = null;
        try {
            configParameters = util.getFileAsString(cfg);
        } catch (Exception ex) {
            this.logger.log(Level.SEVERE, null, ex);
            this.popError("Failed to read config file:\n" + cfg.getAbsolutePath() + "\n\n" + ex.getLocalizedMessage());
            return;
        }
        this.logger.config("Read config file: " + cfg.getAbsolutePath());

        // Read the command line parameters from the config file
        Pattern p = Pattern.compile(MainFrame.COMMENT_COMMAND_LINE_PARAMETERS_REG_EXPR);
        Matcher m = p.matcher(configParameters);
        if (m.find()) {
            String commandLineParameters = m.group(2);
            // Allays let the GUI set the -searchdir
            commandLineParameters = f.replaceSearchDir(commandLineParameters);
            this.jTextAreaCommandLineParameters.setText(commandLineParameters.trim());
            this.logger.finer("Setting command line parameters found in config file: " + cfg.toString());
            configParameters = configParameters.replaceAll(COMMENT_COMMAND_LINE_PARAMETERS_REG_EXPR, "");
            configParameters = COMMENT_COMMAND_LINE_PARAMETERS + commandLineParameters + "\n" + configParameters;
        }
View Full Code Here

     * to fill the control panels. The user can configure the downloader via
     * the control panels of the downloader.
     */
    private DownloadTimer initDownloader() {
        this.cleanUpDownloadStarter();
        XPlanetRessourceFinder f = new XPlanetRessourceFinder();
        String dirOnDisc = f.getRessourceDirectory("downloader");
        String cfgFileDownload = dirOnDisc + File.separator + MainFrame.FILE_NAME_DOWNLOADER_CONFIG;
        DownloadTimer downloadTimer = new DownloadTimer(cfgFileDownload);
        this.downloadStarter = new DownloadStarter();
        this.downloadStarter.setTimer(downloadTimer);
        // Fill the text area
View Full Code Here

    }

    private void saveWindowsCommandFile() {
        // Command file ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        // Find the config directory XPlanet would probably use.
        XPlanetRessourceFinder rf = new XPlanetRessourceFinder();
        // Do not use the -searchdir.
        // The Configurator will be confused when loading a config from the
        // drow downlist. -searchdir is a command line parameter. And the
        // command line parameters are a commented line in the config file.
        // Therefor it is not possible for the Configurator to know the correct
        // -searchdir in befor loading the configuration or put it the other way
        // around. -searchdir will lead to a storage of the configuration file
        // under some directory and not in the directory the Configurator will
        // know of. It will never find and load the configuration... The GUI
        // warns the user of this fact.
        String configDir = rf.getRootDirectoryForDownloads();
        if (MainFrame.getCONFIG_NAME().equals("")) {
            this.logger.fine("Found no config name.");
            // this might not be an error if the configuration is empty
            String parameters = this.getConfigParameters();
            // Check if only comments are in it
View Full Code Here

        }
    }

    private void saveConfigFile() {
        // Config file +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        XPlanetRessourceFinder rf = new XPlanetRessourceFinder();
        String configDir = rf.getRessourceDirectory("config");
        String filename = MainFrame.getCONFIG_NAME();
        if (filename != null && !filename.equals("")) {
            // do nothing
        } else {
            this.logger.fine("No file name for the config file is given. No config file will be written.");
View Full Code Here

    private void hidePreviewPanel() {
        if (this.jPanelPreview != null) {
            this.jPanelMainControlsCommand.remove(this.jPanelPreview);
            this.jPanelPreview = null;
            XPlanetRessourceFinder rf = new XPlanetRessourceFinder();
            String previewImage = rf.getPreviewImage();
            File f = new File(previewImage);
            if (!f.delete()) {
                this.logger.fine("Failed to delete preview file.");
            }
        }
View Full Code Here

TOP

Related Classes of xplanetconfigurator.util.XPlanetRessourceFinder

Copyright © 2018 www.massapicom. 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.