예제 #1
0
  /**
   * Called upon start up and whenever GradlePluginLord settings are changed. We'll update our
   * values. Note: this actually gets called several times in a row for each settings during
   * initialization. Its not optimal, but functional and I didn't want to deal with numerous,
   * specific-field notifications.
   */
  private void updatePluginLordSettings() {
    setCustomGradleExecutor(gradlePluginLord.getCustomGradleExecutor());

    setCurrentDirectory(gradlePluginLord.getCurrentDirectory());

    setSelectedStackTraceLevel(gradlePluginLord.getStackTraceLevel());

    setLogLevelComboBoxSetting(gradlePluginLord.getLogLevel());
  }
예제 #2
0
  /** Creates a panel that has a combo box to select a log level */
  private Component createLogLevelPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    logLevelComboBox = new JComboBox(getLogLevelWrappers());

    panel.add(Utility.addLeftJustifiedComponent(new JLabel("Log Level")));
    panel.add(Utility.addLeftJustifiedComponent(logLevelComboBox));

    // initialize our value
    String logLevelName = settingsNode.getValueOfChild(LOG_LEVEL, null);
    LogLevel logLevel = gradlePluginLord.getLogLevel();
    if (logLevelName != null) {
      try {
        logLevel = LogLevel.valueOf(logLevelName);
      } catch (
          IllegalArgumentException
              e) // this may happen if the enum changes. We don't want this to stop the whole UI
      {
        logger.error("Converting log level text to log level enum '" + logLevelName + "'", e);
      }
    }

    gradlePluginLord.setLogLevel(logLevel);
    setLogLevelComboBoxSetting(logLevel);

    logLevelComboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            LogLevelWrapper wrapper = (LogLevelWrapper) logLevelComboBox.getSelectedItem();
            if (wrapper != null) {
              gradlePluginLord.setLogLevel(wrapper.logLevel);
              settingsNode.setValueOfChild(LOG_LEVEL, wrapper.logLevel.name());
            }
          }
        });

    return panel;
  }