From d11849bebb57e151681652ba5fdfedf1069a47e4 Mon Sep 17 00:00:00 2001 From: Jeroen Ketelaar Date: Fri, 14 Feb 2014 03:39:54 +0100 Subject: [PATCH] Fixed imports --- .../src/org/parabot/core/Directories.java | 263 +++++++++--------- 1 file changed, 128 insertions(+), 135 deletions(-) diff --git a/parabotv2/src/org/parabot/core/Directories.java b/parabotv2/src/org/parabot/core/Directories.java index 61934e0..b835945 100644 --- a/parabotv2/src/org/parabot/core/Directories.java +++ b/parabotv2/src/org/parabot/core/Directories.java @@ -1,161 +1,154 @@ package org.parabot.core; -import java.io.File; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.Queue; -import java.util.Random; - -import javax.swing.JFileChooser; - import org.parabot.environment.OperatingSystem; +import javax.swing.*; +import java.io.File; +import java.util.*; + /** - * * Holds parabot's used directories - * + * * @author Everel * @author Matt - * */ public class Directories { - private static Map cached = new HashMap(); + private static Map cached = new HashMap(); - static { + static { - switch (OperatingSystem.getOS()) { - case WINDOWS: - cached.put("Root", new JFileChooser().getFileSystemView().getDefaultDirectory()); - break; - default: - cached.put("Root", new File(System.getProperty("user.home"))); - } + switch (OperatingSystem.getOS()) { + case WINDOWS: + cached.put("Root", new JFileChooser().getFileSystemView().getDefaultDirectory()); + break; + default: + cached.put("Root", new File(System.getProperty("user.home"))); + } - Core.verbose("Caching directories..."); - cached.put("Root", getDefaultDirectory()); - cached.put("Workspace", new File(cached.get("Root"), "/Parabot/")); - cached.put("Sources", new File(cached.get("Root"), "/Parabot/scripts/sources/")); - cached.put("Compiled", new File(cached.get("Root"), "/Parabot/scripts/compiled/")); - cached.put("Resources", new File(cached.get("Root"), "/Parabot/scripts/resources/")); - cached.put("Settings", new File(cached.get("Root"), "/Parabot/settings/")); - cached.put("Servers", new File(cached.get("Root"), "/Parabot/servers/")); - cached.put("Cache", new File(cached.get("Root"), "/Parabot/cache/")); - Core.verbose("Directories cached."); - } + Core.verbose("Caching directories..."); + cached.put("Root", getDefaultDirectory()); + cached.put("Workspace", new File(cached.get("Root"), "/Parabot/")); + cached.put("Sources", new File(cached.get("Root"), "/Parabot/scripts/sources/")); + cached.put("Compiled", new File(cached.get("Root"), "/Parabot/scripts/compiled/")); + cached.put("Resources", new File(cached.get("Root"), "/Parabot/scripts/resources/")); + cached.put("Settings", new File(cached.get("Root"), "/Parabot/settings/")); + cached.put("Servers", new File(cached.get("Root"), "/Parabot/servers/")); + cached.put("Cache", new File(cached.get("Root"), "/Parabot/cache/")); + Core.verbose("Directories cached."); + } - /** - * Returns the root directory outside of the main Parabot folder. - * - * @return - */ - public static File getDefaultDirectory() { - return cached.get("Root"); - } + /** + * Returns the root directory outside of the main Parabot folder. + * + * @return + */ + public static File getDefaultDirectory() { + return cached.get("Root"); + } - /** - * Returns the Parabot folder. - * - * @return - */ - public static File getWorkspace() { - return cached.get("Workspace"); - } + /** + * Returns the Parabot folder. + * + * @return + */ + public static File getWorkspace() { + return cached.get("Workspace"); + } - /** - * Returns the script sources folder. - * - * @return - */ - public static File getScriptSourcesPath() { - return cached.get("Sources"); - } + /** + * Returns the script sources folder. + * + * @return + */ + public static File getScriptSourcesPath() { + return cached.get("Sources"); + } - /** - * Returns the compiled scripts folder. - * - * @return - */ - public static File getScriptCompiledPath() { - return cached.get("Compiled"); - } + /** + * Returns the compiled scripts folder. + * + * @return + */ + public static File getScriptCompiledPath() { + return cached.get("Compiled"); + } - /** - * Returns the scripts resources folder. - * - * @return - */ - public static File getResourcesPath() { - return cached.get("Resources"); - } + /** + * Returns the scripts resources folder. + * + * @return + */ + public static File getResourcesPath() { + return cached.get("Resources"); + } - /** - * Returns the Parabot settings folder. - * - * @return - */ - public static File getSettingsPath() { - return cached.get("Settings"); - } + /** + * Returns the Parabot settings folder. + * + * @return + */ + public static File getSettingsPath() { + return cached.get("Settings"); + } - /** - * Returns the Parabot servers folder. - * - * @return - */ - public static File getServerPath() { - return cached.get("Servers"); - } - - /** - * Returns the Parabot cache folder. - * - * @return - */ - public static File getCachePath() { - return cached.get("Cache"); - } + /** + * Returns the Parabot servers folder. + * + * @return + */ + public static File getServerPath() { + return cached.get("Servers"); + } - /** - * Validates all directories and makes them if necessary - */ - public static void validate() { - final File defaultPath = getDefaultDirectory(); - if (defaultPath == null || !defaultPath.exists()) { - throw new RuntimeException("Default path not found"); - } - final Queue files = new LinkedList(); - files.add(getWorkspace()); - files.add(getServerPath()); - files.add(getSettingsPath()); - files.add(getScriptSourcesPath()); - files.add(getScriptCompiledPath()); - files.add(getResourcesPath()); - files.add(getCachePath()); - while (files.size() > 0) { - final File file = files.poll(); - if (!file.exists()) { - Core.verbose("Generating directory: " + file.getAbsolutePath()); - file.mkdirs(); - if(!file.exists()) { - System.err.println("Failed to make directory: " + file.getAbsolutePath()); - } - } - } - } + /** + * Returns the Parabot cache folder. + * + * @return + */ + public static File getCachePath() { + return cached.get("Cache"); + } - private static File temp = null; + /** + * Validates all directories and makes them if necessary + */ + public static void validate() { + final File defaultPath = getDefaultDirectory(); + if (defaultPath == null || !defaultPath.exists()) { + throw new RuntimeException("Default path not found"); + } + final Queue files = new LinkedList(); + files.add(getWorkspace()); + files.add(getServerPath()); + files.add(getSettingsPath()); + files.add(getScriptSourcesPath()); + files.add(getScriptCompiledPath()); + files.add(getResourcesPath()); + files.add(getCachePath()); + while (files.size() > 0) { + final File file = files.poll(); + if (!file.exists()) { + Core.verbose("Generating directory: " + file.getAbsolutePath()); + file.mkdirs(); + if (!file.exists()) { + System.err.println("Failed to make directory: " + file.getAbsolutePath()); + } + } + } + } - public static File getTempDirectory() { - if (temp != null) { - return temp; - } - int randomNum = new Random().nextInt(999999999); - temp = new File(getResourcesPath(), randomNum + "/"); - temp.mkdirs(); - temp.deleteOnExit(); - return temp; - } + private static File temp = null; + + public static File getTempDirectory() { + if (temp != null) { + return temp; + } + int randomNum = new Random().nextInt(999999999); + temp = new File(getResourcesPath(), randomNum + "/"); + temp.mkdirs(); + temp.deleteOnExit(); + return temp; + } }