Пример #1
0
  /** This stores the current stack trace setting (based on the UI controls) in the plugin. */
  private void updateStackTraceSetting(boolean saveSetting) {
    ShowStacktrace stackTraceLevel = getSelectedStackTraceLevel();
    gradlePluginLord.setStackTraceLevel(stackTraceLevel);

    if (saveSetting) {
      settingsNode.setValueOfChild(STACK_TRACE_LEVEL, stackTraceLevel.name());
    }
  }
Пример #2
0
  /**
   * Creates a panel with stack trace level radio buttons that allow you to specify how much info is
   * given when an error occurs.
   */
  private Component createStackTracePanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    panel.setBorder(BorderFactory.createTitledBorder("Stack Trace Output"));

    showNoStackTraceRadioButton = new JRadioButton("Exceptions Only");
    showStackTrackRadioButton =
        new JRadioButton(
            "Standard Stack Trace (-"
                + LoggingCommandLineConverter.STACKTRACE
                + ")"); // add the command line character to the end (so if an error message says
                        // use a stack trace level, you can easily translate)
    showFullStackTrackRadioButton =
        new JRadioButton("Full Stack Trace (-" + LoggingCommandLineConverter.FULL_STACKTRACE + ")");

    showNoStackTraceRadioButton.putClientProperty(
        STACK_TRACE_LEVEL_CLIENT_PROPERTY, ShowStacktrace.INTERNAL_EXCEPTIONS);
    showStackTrackRadioButton.putClientProperty(
        STACK_TRACE_LEVEL_CLIENT_PROPERTY, ShowStacktrace.ALWAYS);
    showFullStackTrackRadioButton.putClientProperty(
        STACK_TRACE_LEVEL_CLIENT_PROPERTY, ShowStacktrace.ALWAYS_FULL);

    stackTraceButtonGroup = new ButtonGroup();
    stackTraceButtonGroup.add(showNoStackTraceRadioButton);
    stackTraceButtonGroup.add(showStackTrackRadioButton);
    stackTraceButtonGroup.add(showFullStackTrackRadioButton);

    showNoStackTraceRadioButton.setSelected(true);

    ActionListener radioButtonListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            updateStackTraceSetting(true);
          }
        };

    showNoStackTraceRadioButton.addActionListener(radioButtonListener);
    showStackTrackRadioButton.addActionListener(radioButtonListener);
    showFullStackTrackRadioButton.addActionListener(radioButtonListener);

    panel.add(Utility.addLeftJustifiedComponent(showNoStackTraceRadioButton));
    panel.add(Utility.addLeftJustifiedComponent(showStackTrackRadioButton));
    panel.add(Utility.addLeftJustifiedComponent(showFullStackTrackRadioButton));

    String stackTraceLevel =
        settingsNode.getValueOfChild(STACK_TRACE_LEVEL, getSelectedStackTraceLevel().name());
    if (stackTraceLevel != null) {
      try {
        setSelectedStackTraceLevel(ShowStacktrace.valueOf(stackTraceLevel));
        updateStackTraceSetting(false); // false because we're serializing this in
      } catch (
          Exception
              e) { // this can happen if the stack trace levels change because you're moving between
                   // versions.
        logger.error(
            "Converting stack trace level text to stack trace level enum '" + stackTraceLevel + "'",
            e);
      }
    }

    return panel;
  }