Exemplo n.º 1
0
  /** Applies the proxy configuration from the {@link Settings}. */
  public static void applyProxyConfig() {
    // Proxy guide:
    // http://download.oracle.com/javase/6/docs/technotes/guides/net/proxies.html
    if (Settings.getBoolean(Settings.KEY_SETTINGS_MISC_ENABLE_PROXY_CONFIG)) {
      System.setProperty(
          "http.proxyHost", Settings.getString(Settings.KEY_SETTINGS_MISC_HTTP_PROXY_HOST));
      System.setProperty(
          "http.proxyPort", Settings.getString(Settings.KEY_SETTINGS_MISC_HTTP_PROXY_PORT));

      System.setProperty(
          "https.proxyHost", Settings.getString(Settings.KEY_SETTINGS_MISC_HTTPS_PROXY_HOST));
      System.setProperty(
          "https.proxyPort", Settings.getString(Settings.KEY_SETTINGS_MISC_HTTPS_PROXY_PORT));

      System.setProperty(
          "socksProxyHost", Settings.getString(Settings.KEY_SETTINGS_MISC_SOCKS_PROXY_HOST));
      System.setProperty(
          "socksProxyPort", Settings.getString(Settings.KEY_SETTINGS_MISC_SOCKS_PROXY_PORT));
    } else {
      System.setProperty("http.proxyHost", "");
      System.setProperty("http.proxyPort", "");

      System.setProperty("https.proxyHost", "");
      System.setProperty("https.proxyPort", "");

      System.setProperty("socksProxyHost", "");
      System.setProperty("socksProxyPort", "");
    }
  }
Exemplo n.º 2
0
  /** Cancels the language selection. */
  private void cancel() {
    dispose();
    // Cancel was pressed, revert to the default language
    Language.loadAndActivateLanguage(Settings.DEFAULT_APP_LANGUAGE);
    Settings.remove(Settings.KEY_SETTINGS_VOICE);

    synchronized (WelcomeFrame.this) {
      Sounds.playSoundSample(Sounds.SAMPLE_THANK_YOU, false);
      WelcomeFrame.this.notify(); // Notify the main thread to continue starting the application
    }
  }
Exemplo n.º 3
0
  /**
   * The entry point of the program.
   *
   * <p>Checks for running instances, and passes arguments if have to. Else loads the settings,
   * language files etc. and then instantiates the main frame.
   *
   * @param arguments if command line mode is desired, they will be handled by the {@link
   *     CliHandler}; else they will be treated as files (like replays, replay lists, replay
   *     sources) and will be opened properly
   * @throws MalformedURLException
   */
  public static void main(final String[] arguments) {
    // Add Sc2gears version and OS info to the User-Agent HTTP request property.
    // The final user agent string will be the value of this property + the default (which is the
    // Java version).
    System.setProperty(
        "http.agent",
        Consts.APPLICATION_NAME
            + "/"
            + Consts.APPLICATION_VERSION
            + " ("
            + System.getProperty("os.name")
            + "; "
            + System.getProperty("os.version")
            + "; "
            + System.getProperty("os.arch")
            + ")");

    checkFolders();

    Settings.loadProperties();

    final boolean cliMode = CliHandler.checkCliMode(arguments);

    if (!cliMode) {
      InstanceMonitor.checkRunningInstance(arguments);
      Log.init();
    }

    if (!cliMode) {
      installExtraLAFs();
      GuiUtils.setLAF(Settings.getString(Settings.KEY_SETTINGS_LAF));
    }

    if (Settings.doesSettingsFileExist()) {
      Language.loadAndActivateLanguage(Settings.getString(Settings.KEY_SETTINGS_LANGUAGE));
    } else {
      // Only show the welcome frame if we're not in CLI mode
      if (!cliMode) {
        final WelcomeFrame welcomeFrame = new WelcomeFrame();
        synchronized (welcomeFrame) {
          try {
            welcomeFrame.wait(); // Wait until the welcome frame is closed.
          } catch (final InterruptedException ie) {
            // This should never happen.
          }
        }
      }
    }

    // Now language is loaded, initialize codes that build on it.
    Language.applyDateTimeFormats();
    Settings.completeDefaultPropertiesInitialization();
    GuiUtils.initFileFilters();

    // Must be after completeDefaultPropertiesInitialization()!
    checkAndPerformPostUpdate();

    // Ensure ReplayUtils and AbilityCodesRepository is initialized
    // (else opening a replay from the file menu or by the CilHandler would fail!)
    try {
      Class.forName(ReplayUtils.class.getName());
    } catch (final ClassNotFoundException cfe) {
      // Never to happen
      cfe.printStackTrace();
    }

    if (cliMode) System.exit(CliHandler.handleArguments(arguments));
    else {
      // Load the Native class now, else later it might hang (dead lock?)
      if (GeneralUtils.isWindows()) // Currently JNA is only used on windows
      try {
          Class.forName(Native.class.getName());
        } catch (final ClassNotFoundException cfe) {
          // Never to happen
          cfe.printStackTrace();
        }

      // Apply proxy config
      applyProxyConfig();

      // Load plugins
      PluginManager.loadPlugins();

      // Now instantiate the main frame
      new MainFrame(arguments);
    }
  }
Exemplo n.º 4
0
  /** Performs post update tasks. */
  private static void performPostUpdateTasks() {
    // TODO review on each release!

    // Set default enabled plugins: add the Build Orders Table plugin (but does not disable other
    // ones...)
    final Set<String> enabledPluginSet = new HashSet<String>(Settings.getEnabledPluginSet());
    enabledPluginSet.add("hu.belicza.andras.buildorderstableplugin.BuildOrdersTablePlugin");
    Settings.setEnabledPluginSet(enabledPluginSet);

    // MD5 hash symbol has been introduced:
    {
      final String autoSaveNameTemplateSetting =
          Settings.getString(Settings.KEY_SETTINGS_MISC_REP_AUTO_SAVE_NAME_TEMPLATE);
      if ("/D./e".equals(autoSaveNameTemplateSetting)) // The old default value
      Settings.set(
            Settings.KEY_SETTINGS_MISC_REP_AUTO_SAVE_NAME_TEMPLATE,
            Settings.getDefaultString(
                Settings.KEY_SETTINGS_MISC_REP_AUTO_SAVE_NAME_TEMPLATE)); // Set the new default
    }

    // Player full name has been removed:
    {
      final String autoSaveNameTemplateSetting =
          Settings.getString(Settings.KEY_SETTINGS_MISC_REP_AUTO_SAVE_NAME_TEMPLATE);
      if (autoSaveNameTemplateSetting != null)
        Settings.set(
            Settings.KEY_SETTINGS_MISC_REP_AUTO_SAVE_NAME_TEMPLATE,
            autoSaveNameTemplateSetting.replace("/P", "/p").replace("/Q", "/q"));
      final String replayRenameTemplateSetting =
          Settings.getString(Settings.KEY_REP_SEARCH_RESULTS_RENAME_TEMPLATE);
      if (replayRenameTemplateSetting != null)
        Settings.set(
            Settings.KEY_REP_SEARCH_RESULTS_RENAME_TEMPLATE,
            replayRenameTemplateSetting.replace("/P", "/p").replace("/Q", "/q"));
      final String predefinedAutoSaveNameTemplatesSetting =
          Settings.getString(PredefinedList.REP_AUTO_SAVE_TEMPLATE.settingsKey);
      if (predefinedAutoSaveNameTemplatesSetting != null)
        Settings.set(
            PredefinedList.REP_AUTO_SAVE_TEMPLATE.settingsKey,
            predefinedAutoSaveNameTemplatesSetting.replace("/P", "/p").replace("/Q", "/q"));
      final String repRenameTemplatesSetting =
          Settings.getString(PredefinedList.REP_RENAME_TEMPLATE.settingsKey);
      if (repRenameTemplatesSetting != null)
        Settings.set(
            PredefinedList.REP_RENAME_TEMPLATE.settingsKey,
            repRenameTemplatesSetting.replace("/P", "/p").replace("/Q", "/q"));
      Settings.rebuildPredefinedLists();
    }

    // Remove keys of changed/removed settings
    Settings.remove("settings.misc.useInMemoryReplayCache");
    Settings.remove("module.repAnalyzer.charts.mapView.hotAreasCount");
    Settings.remove("module.repAnalyzer.charts.mapView.iconSizesCS");

    // If replay site list has changed/rearranged:
    Settings.remove(Settings.KEY_SHARE_REP_REPLAY_SITE);

    // The initial default value of the pre-defined replay list had a typo: "battlecuriser" instead
    // of "battlecruiser"
    final String repAnalFilterSetting =
        Settings.getString(PredefinedList.REP_ANAL_FILTER.settingsKey);
    if (repAnalFilterSetting != null) {
      if (repAnalFilterSetting.contains("battlecuriser"))
        Settings.set(
            PredefinedList.REP_ANAL_FILTER.settingsKey,
            repAnalFilterSetting.replace("battlecuriser", "battlecruiser"));
      Settings.rebuildPredefinedLists();
    }

    // Removed LaFs: Napkin and EaSynthLookAndFeel
    if ("Napkin".equals(Settings.getString(Settings.KEY_SETTINGS_LAF)))
      Settings.remove(Settings.KEY_SETTINGS_LAF);
    if ("EaSynthLookAndFeel".equals(Settings.getString(Settings.KEY_SETTINGS_LAF)))
      Settings.remove(Settings.KEY_SETTINGS_LAF);

    // Save changes
    Settings.saveProperties();

    // If profile cache version changed:
    hu.belicza.andras.sc2gears.util.ProfileCache.emptyCache(null);
  }