Package com.santiagolizardo.beobachter.config

Examples of com.santiagolizardo.beobachter.config.ConfigData


      LogManager.getLogManager().readConfiguration();
    } catch (IOException ex) {
      System.err.println(ex.getMessage());
    }

    final ConfigData configData = new ConfigData();
    ConfigPersistence configPersistence = new ConfigPersistence();
    try {
      configData.setConfiguration(configPersistence
          .loadProperties());
    } catch (IOException ex) {
      System.err.println(ex.getMessage());
    }

    Translator.start(configData.getLanguage());

    SwingUtilities.invokeLater(new Runnable() {

      @Override
      public void run() {
        SwingUtil.setLookAndFeel(configData.getWindowLAF());

        MainWindow mainWindow = new MainWindow(configData);
        mainWindow.setVisible(true);
      }
    });
View Full Code Here


  private JButton cancelButton;

  public FontChooserDialog(final MainWindow mainWindow) {
    super(mainWindow);

    final ConfigData configManager = mainWindow.getConfigData();

    setTitle(Translator.tr("Font settings"));
    setResizable(false);
    setModal(true);

    String[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment()
        .getAvailableFontFamilyNames();
    fontFamilyCombo = new JComboBox<>(fonts);
    fontFamilyCombo.addItemListener(new ItemListener() {

      @Override
      public void itemStateChanged(ItemEvent e) {
        if (e.getStateChange() == ItemEvent.SELECTED) {
          updatePreview();
        }
      }
    });

    fontSizeCombo = new JSpinner(new SpinnerNumberModel(10,
        8, 72, 1));
    fontSizeCombo.addChangeListener(new ChangeListener() {

      @Override
      public void stateChanged(ChangeEvent e) {
        updatePreview();
      }
    });

    previewTextField = new JTextField("[INFO] Log line example");

    okButton = new JButton(Translator.tr("Save"));
    okButton.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent event) {
        setVisible(false);

        Font font = getSelectedFont();

        configManager.setFontFamily(fontFamilyCombo.getSelectedItem()
            .toString());
        configManager.setFontSize(Integer.parseInt(fontSizeCombo.getValue()
            .toString()));

        ConfigPersistence configPersistence = new ConfigPersistence();
        configPersistence.saveProperties(mainWindow,
            configManager.getConfiguration());

        JInternalFrame[] internalFrames = mainWindow.getDesktop().getAllFrames();
        for (JInternalFrame internalFrame : internalFrames) {
          LogWindow logWindow = (LogWindow) internalFrame;
          logWindow.updateFont(font);
        }

        dispose();
      }
    });

    cancelButton = new JButton(Translator.tr("Cancel"));
    cancelButton.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent event) {
        setVisible(false);
        dispose();
      }
    });

    fontFamilyCombo.setSelectedItem(configManager.getFontFamily());
    fontSizeCombo.setValue(configManager.getFontSize());
    updatePreview();

    defineLayout();
  }
View Full Code Here

  private JButton cancelButton;

  public PreferencesDialog(final MainWindow mainWindow) {
    super(mainWindow);

    final ConfigData configManager = mainWindow.getConfigData();

    setTitle(Translator.tr("Preferences"));
    setResizable(false);
    setModal(true);

    LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels();
    SwingLookAndFeel[] lafs = new SwingLookAndFeel[infos.length];
    for (int i = 0; i < infos.length; i++) {
      LookAndFeelInfo info = infos[i];
      lafs[i] = new SwingLookAndFeel(info.getName(), info.getClassName());
    }
    lookAndFeelComboBox = new JComboBox<>(lafs);
    lookAndFeelComboBox.setRenderer(new SwingLAFRenderer());
    try {
      SwingLookAndFeel look = SwingLookAndFeel.forName(configManager
          .getWindowLAF());
      lookAndFeelComboBox.setSelectedItem(look);
    } catch (Exception e) {
      logger.warning("Unable to set the selected look&feel.");
    }

    String[] languages = LocaleUtil.getAvailableLocales();

    languageComboBox = new JComboBox<>(languages);
    languageComboBox.setSelectedItem(configManager.getLanguage());
    languageComboBox.setRenderer(new LocaleRender());

    okButton = new JButton(Translator.tr("Save"));
    okButton.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent event) {
        setVisible(false);

        SwingLookAndFeel laf = ((SwingLookAndFeel) lookAndFeelComboBox
            .getSelectedItem());
        configManager.setWindowLAF(laf.getClassName());
        SwingUtil.setLookAndFeel(laf.getClassName());
        SwingUtilities.updateComponentTreeUI(mainWindow);

        Object selectedLanguage = languageComboBox.getSelectedItem();
        if (null != selectedLanguage) {
          configManager.setLanguage(selectedLanguage.toString());
        }

        ConfigPersistence configPersistence = new ConfigPersistence();
        configPersistence.saveProperties(mainWindow,
            configManager.getConfiguration());

        dispose();
      }
    });
View Full Code Here

TOP

Related Classes of com.santiagolizardo.beobachter.config.ConfigData

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.