Example #1
0
  private SettingsWindow() {
    this.settings = Settings.getInstance();

    setAlwaysOnTop(true);
    setDefaultCloseOperation(HIDE_ON_CLOSE);
    setIconImage(new ImageIcon("img/settings-icon.png").getImage());
    setResizable(false);
    setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
    setTitle("Osobní nastavení");

    createMainPanel();
    createTabs();
    reloadSettings();

    addWindowListener(this);
  }
Example #2
0
  public static Logger initLogger() {
    Logger initlogger = Logger.getLogger(settings.getMainClass());
    initlogger.setLevel(settings.getLogLevel());
    boolean addconsole = false;
    if (settings.getLogToFile()) {
      try {
        Handler handler = new FileHandler(settings.getLogFile(), true);
        handler.setFormatter(new SimpleFormatter());
        initlogger.addHandler(handler);
      } catch (Exception e) {
        Logger().warning("Could not set logfile " + settings.getLogFile() + ": " + e.getMessage());
        addconsole = true;
      }
    }
    addconsole = settings.getLogToConsole() || addconsole;
    if (addconsole) {
      initlogger.addHandler(new ConsoleHandler());
    }
    // restore original log state
    logger.setLevel(templevel);
    templevel = null;

    return initlogger;
  }
Example #3
0
 private static void saveUpdateSettings() {
   settings.setAutoUpdate(autoupdate.getCheckForUpdates());
   settings.setExperimental(autoupdate.getIncludeExperiemental());
   settings.setMinor(autoupdate.getIncludeMinor());
   settings.saveSettings();
 }
Example #4
0
  public Main(
      String args[],
      String cmd_name,
      OSSpecific os_name,
      String settings_name,
      final String window_name,
      String logger_name,
      String about_name,
      String pref_name) {
    if (cmd == null) {
      cmd = new CommandLine(args);
    }

    if (!cmd.getHelp()) {
      if (os_name == null) {
        os = OSSpecific.getInstance();
      } else {
        os = (OSSpecific) newInstance(cmd_name);
      }
      if (settings_name == null) {
        settings = new Settings();
      } else {
        settings = (Settings) newInstance(settings_name);
      }
      settings.loadSettings();
      if (logger_name == null) {
        logger = initLogger();
      } else {
        logger = (Logger) newInstance(logger_name);
      }
      Logger().info("Custom logger now in use.");

      aboutclass = about_name;
      prefclass = pref_name;

      ActionListener update =
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              saveUpdateSettings();
            }
          };
      ActionListener cancel =
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              cancelUpdate(window_name);
            }
          };
      WindowListener closewindow =
          new WindowListener() {
            public void windowClosing(WindowEvent e) {
              cancelUpdate(window_name);
            }

            public void windowClosed(WindowEvent e) {}

            public void windowOpened(WindowEvent e) {}

            public void windowIconified(WindowEvent e) {}

            public void windowDeiconified(WindowEvent e) {}

            public void windowActivated(WindowEvent e) {}

            public void windowDeactivated(WindowEvent e) {}

            public void windowGainedFocus(WindowEvent e) {}

            public void windowLostFocus(WindowEvent e) {}

            public void windowStateChanged(WindowEvent e) {}
          };
      autoupdate = new AutoUpdate();
      autoupdate.checkForUpdates(
          settings.getTitle(),
          settings.getUpdateUrl(),
          settings.getVersion(),
          settings.getBuild(),
          settings.getAllowMinor(),
          settings.getAllowExperimental(),
          settings.getAllowAutoUpdate(),
          settings.getMinor(),
          settings.getExperimental(),
          settings.getAutoUpdate(),
          update,
          cancel,
          closewindow);
    }
  }
Example #5
0
  private void saveSettings() throws InvalidAttributeValueException {
    if (userForm.getNickname().isEmpty())
      throw new InvalidAttributeValueException("Přezdívka musí být vyplněna");
    else if (userForm.getUsername().isEmpty())
      throw new InvalidAttributeValueException("Uživatelské jméno musí být vyplněno");

    settings.setUserProperty("nickname", userForm.getNickname());
    settings.setUserProperty("altnickname", userForm.getAltNickname());
    settings.setUserProperty("username", userForm.getUsername());
    settings.setUserProperty("realname", userForm.getRealname());
    settings.setUserProperty("email", userForm.getEmail());

    settings.setEventEnabled("log-chat", eventsForm.isLogChatChecked());
    settings.setEventEnabled("rejoin-after-kick", eventsForm.isRejoinChecked());
    settings.setEventEnabled("clickable-links", eventsForm.isClickableLinksChecked());
    settings.setEventEnabled("ask-for-quit", eventsForm.isAskForQuitChecked());

    settings.setViewEnabled("display-topic", viewForm.isDisplayTopicChecked());
    settings.setViewEnabled("timestamp-enabled", viewForm.isTimestampEnabled());
    settings.setViewTimestampFormat(viewForm.getTimestampFormat());

    settings.setBlockedNicknames(blockedForm.getBlockedNicknames());

    settings.store();
  }
Example #6
0
  private void reloadSettings() {
    userForm.setNickname(settings.getUserProperty("nickname"));
    userForm.setAltNickname(settings.getUserProperty("altnickname"));
    userForm.setUsername(settings.getUserProperty("username"));
    userForm.setRealname(settings.getUserProperty("realname"));
    userForm.setEmail(settings.getUserProperty("email"));

    eventsForm.setLogChatChecked(settings.isEventEnabled("log-chat"));
    eventsForm.setRejoinChecked(settings.isEventEnabled("rejoin-after-kick"));
    eventsForm.setClickableLinksChecked(settings.isEventEnabled("clickable-links"));
    eventsForm.setAskForQuitChecked(settings.isEventEnabled("ask-for-quit"));

    viewForm.setDisplayTopicChecked(settings.isViewEnabled("display-topic"));
    viewForm.setTimestampEnabled(settings.isViewEnabled("timestamp-enabled"));
    viewForm.setTimestampFormat(settings.getViewTimestampFormat());

    blockedForm.setBlockedNicknames(settings.getBlockedNicknames());
  }