コード例 #1
0
ファイル: SetupTab.java プロジェクト: gmercer/gradle
  private void setCurrentDirectory(File file) {

    if (file == null) {
      currentDirectoryTextField.setText("");
      settingsNode.setValueOfChild(CURRENT_DIRECTORY, "");
    } else {
      currentDirectoryTextField.setText(file.getAbsolutePath());
      settingsNode.setValueOfChild(CURRENT_DIRECTORY, file.getAbsolutePath());
    }

    if (gradlePluginLord.setCurrentDirectory(file)) {
      // refresh the tasks only if we actually changed the current directory
      gradlePluginLord.addRefreshRequestToQueue();
    }
  }
コード例 #2
0
ファイル: SetupTab.java プロジェクト: gmercer/gradle
  /**
   * Call this to set a custom gradle executor. We'll enable all fields appropriately and setup the
   * foundation settings. We'll also fire off a refresh.
   *
   * @param file the file to use as a custom executor. Null not to use one.
   */
  private void setCustomGradleExecutor(File file) {
    String storagePath;
    boolean isUsingCustom = false;
    if (file == null) {
      isUsingCustom = false;
      storagePath = null;
    } else {
      isUsingCustom = true;
      storagePath = file.getAbsolutePath();
    }

    // set the executor in the foundation
    if (gradlePluginLord.setCustomGradleExecutor(file)) {
      // refresh the tasks only if we actually changed the executor
      gradlePluginLord.addRefreshRequestToQueue();
    }

    // set the UI values
    useCustomGradleExecutorCheckBox.setSelected(isUsingCustom);
    customGradleExecutorField.setText(storagePath);

    // enable the UI appropriately.
    browseForCustomGradleExecutorButton.setEnabled(isUsingCustom);
    customGradleExecutorField.setEnabled(isUsingCustom);

    // store the settings
    settingsNode.setValueOfChild(CUSTOM_GRADLE_EXECUTOR, storagePath);
  }
コード例 #3
0
ファイル: SetupTab.java プロジェクト: gmercer/gradle
  private Component createOptionsPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    onlyShowOutputOnErrorCheckBox = new JCheckBox("Only Show Output When Errors Occur");

    onlyShowOutputOnErrorCheckBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            updateShowOutputOnErrorsSetting();
            settingsNode.setValueOfChildAsBoolean(
                SHOW_OUTPUT_ON_ERROR, onlyShowOutputOnErrorCheckBox.isSelected());
          }
        });

    // initialize its default value
    boolean valueAsBoolean =
        settingsNode.getValueOfChildAsBoolean(
            SHOW_OUTPUT_ON_ERROR, onlyShowOutputOnErrorCheckBox.isSelected());
    onlyShowOutputOnErrorCheckBox.setSelected(valueAsBoolean);

    updateShowOutputOnErrorsSetting();

    panel.add(Utility.addLeftJustifiedComponent(onlyShowOutputOnErrorCheckBox));

    return panel;
  }
コード例 #4
0
ファイル: SetupTab.java プロジェクト: gmercer/gradle
  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;
  }
コード例 #5
0
ファイル: SetupTab.java プロジェクト: gmercer/gradle
  /** 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());
    }
  }
コード例 #6
0
ファイル: SetupTab.java プロジェクト: gmercer/gradle
  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;
  }
コード例 #7
0
ファイル: SetupTab.java プロジェクト: gmercer/gradle
  /** 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;
  }
コード例 #8
0
ファイル: SetupTab.java プロジェクト: gmercer/gradle
 public SetupTab(
     GradlePluginLord gradlePluginLord, OutputUILord outputUILord, SettingsNode settingsNode) {
   this.gradlePluginLord = gradlePluginLord;
   this.outputUILord = outputUILord;
   this.settingsNode = settingsNode.addChildIfNotPresent(SETUP);
 }
コード例 #9
0
ファイル: SetupTab.java プロジェクト: gmercer/gradle
  /**
   * 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;
  }