コード例 #1
0
  public boolean createLogDirectory() {
    if (settings.logDirectoryName.length() == 0) {
      return true;
    }

    File logDirectory = new File(settings.logDirectoryName);

    if (!logDirectory.exists()) {
      try {
        return logDirectory.mkdirs();
      } catch (SecurityException e) {
        console.writeLine("Failed to create log directory, check read / write permissions.");
        return false;
      }
    }

    return true;
  }
コード例 #2
0
  public boolean initialize(String[] args) {
    if (m_initialized) {
      return false;
    }

    if (args != null && args.length > 0 && args[0] != null) {
      String temp = args[0].trim();
      if (temp.length() > 0) {
        settings.settingsFileName = temp;
      }
    }

    if (settings.load()) {
      console.writeLine("Settings successfully loaded from file: " + settings.settingsFileName);
    } else {
      console.writeLine("Failed to load settings from file: " + settings.settingsFileName);

      if (settings.settingsFileName != null
          && !SettingsManager.defaultSettingsFileName.equalsIgnoreCase(settings.settingsFileName)) {
        boolean loaded = false;

        while (!loaded) {
          int choice =
              JOptionPane.showConfirmDialog(
                  null,
                  "Unable to load settings from custom settings file. Use alternate settings file?\nNote that when the program is closed, this settings file will be generated if it does not exist.",
                  "Settings Loading Failed",
                  JOptionPane.YES_NO_CANCEL_OPTION);
          if (choice == JOptionPane.YES_OPTION) {
            String newSettingsFileName =
                JOptionPane.showInputDialog(
                    null, "Enter a settings file name:", SettingsManager.defaultSettingsFileName);
            if (newSettingsFileName != null) {
              settings.settingsFileName = newSettingsFileName;
              loaded = settings.load();

              if (loaded) {
                console.writeLine(
                    "Settings successfully loaded from file: " + settings.settingsFileName);
              }
            } else {
              break;
            }
          } else {
            break;
          }
        }
      }
    }

    if (!pluginManager.initialize(paletteEditorWindow.getFrame())) {
      JOptionPane.showMessageDialog(
          paletteEditorWindow.getFrame(),
          "Failed to initialize plugin manager!",
          "Initialization Failed",
          JOptionPane.ERROR_MESSAGE);

      return false;
    }

    if (settings.autoLoadPlugins) {
      pluginManager.loadPlugins();
    }

    m_initialized = true;

    boolean error = false;

    console.addTarget(paletteEditorWindow);

    if (!paletteEditorWindow.initialize()) {
      JOptionPane.showMessageDialog(
          paletteEditorWindow.getFrame(),
          "Failed to initialize palette editor window!",
          "Palette Editor Init Failed",
          JOptionPane.ERROR_MESSAGE);

      return false;
    }

    if (!error) {
      console.writeLine("Palette Editor initialized successfully!");
    }

    VersionChecker.checkVersion(false);

    return true;
  }