示例#1
0
  private Component createCurrentDirectoryPanel() {
    currentDirectoryTextField = new JTextField();
    currentDirectoryTextField.setEditable(false);

    String currentDirectory = settingsNode.getValueOfChild(CURRENT_DIRECTORY, null);
    if (currentDirectory == null || "".equals(currentDirectory.trim())) {
      currentDirectory = gradlePluginLord.getCurrentDirectory().getAbsolutePath();
    }

    currentDirectoryTextField.setText(currentDirectory);
    gradlePluginLord.setCurrentDirectory(new File(currentDirectory));

    JButton browseButton =
        new JButton(
            new AbstractAction("Browse...") {
              public void actionPerformed(ActionEvent e) {
                File file = browseForDirectory(gradlePluginLord.getCurrentDirectory());
                if (file != null) {
                  setCurrentDirectory(file);
                }
              }
            });

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    panel.add(Utility.addLeftJustifiedComponent(new JLabel("Current Directory")));
    panel.add(createSideBySideComponent(currentDirectoryTextField, browseButton));

    return panel;
  }
示例#2
0
  private Component createCustomExecutorPanel() {
    useCustomGradleExecutorCheckBox = new JCheckBox("Use Custom Gradle Executor");

    customGradleExecutorField = new JTextField();
    customGradleExecutorField.setEditable(false);

    browseForCustomGradleExecutorButton =
        new JButton(
            new AbstractAction("Browse...") {
              public void actionPerformed(ActionEvent e) {
                browseForCustomGradleExecutor();
              }
            });

    String customExecutorPath = settingsNode.getValueOfChild(CUSTOM_GRADLE_EXECUTOR, null);
    if (customExecutorPath == null) {
      setCustomGradleExecutor(null);
    } else {
      setCustomGradleExecutor(new File(customExecutorPath));
    }

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    panel.add(Utility.addLeftJustifiedComponent(useCustomGradleExecutorCheckBox));
    JComponent sideBySideComponent =
        createSideBySideComponent(customGradleExecutorField, browseForCustomGradleExecutorButton);
    sideBySideComponent.setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 0)); // indent it
    panel.add(sideBySideComponent);

    useCustomGradleExecutorCheckBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (useCustomGradleExecutorCheckBox
                .isSelected()) { // if they checked it, browse for a custom executor immediately
              browseForCustomGradleExecutor();
            } else {
              setCustomGradleExecutor(null);
            }
          }
        });

    return panel;
  }
示例#3
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;
  }
示例#4
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;
  }