コード例 #1
0
  @Override
  public JComponent createComponent() {
    if (myMainComponent == null) {
      myMainComponent = new JPanel(new BorderLayout());
      myCbUseSoftWrapsAtConsole =
          new JCheckBox(ApplicationBundle.message("checkbox.use.soft.wraps.at.console"), false);
      myCommandsHistoryLimitField = new JTextField(3);
      myCbOverrideConsoleCycleBufferSize =
          new JCheckBox(
              ApplicationBundle.message(
                  "checkbox.override.console.cycle.buffer.size",
                  String.valueOf(ConsoleBuffer.getLegacyCycleBufferSize() / 1024)),
              false);
      myCbOverrideConsoleCycleBufferSize.addChangeListener(
          new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
              myConsoleCycleBufferSizeField.setEnabled(
                  myCbOverrideConsoleCycleBufferSize.isSelected());
            }
          });
      myConsoleCycleBufferSizeField = new JTextField(3);

      JPanel northPanel = new JPanel(new GridBagLayout());
      GridBag gridBag = new GridBag();
      gridBag.anchor(GridBagConstraints.WEST).setDefaultAnchor(GridBagConstraints.WEST);
      northPanel.add(myCbUseSoftWrapsAtConsole, gridBag.nextLine().next());
      northPanel.add(Box.createHorizontalGlue(), gridBag.next().coverLine());
      northPanel.add(
          new JLabel(ApplicationBundle.message("editbox.console.history.limit")),
          gridBag.nextLine().next());
      northPanel.add(myCommandsHistoryLimitField, gridBag.next());
      if (ConsoleBuffer.useCycleBuffer()) {
        northPanel.add(myCbOverrideConsoleCycleBufferSize, gridBag.nextLine().next());
        northPanel.add(myConsoleCycleBufferSizeField, gridBag.next());
      }
      if (!editFoldingsOnly()) {
        JPanel wrapper = new JPanel(new BorderLayout());
        wrapper.add(northPanel, BorderLayout.WEST);
        myMainComponent.add(wrapper, BorderLayout.NORTH);
      }
      Splitter splitter = new Splitter(true);
      myMainComponent.add(splitter, BorderLayout.CENTER);
      myPositivePanel =
          new MyAddDeleteListPanel(
              "Fold console lines that contain",
              "Enter a substring of a console line you'd like to see folded:");
      myNegativePanel =
          new MyAddDeleteListPanel(
              "Exceptions", "Enter a substring of a console line you don't want to fold:");
      splitter.setFirstComponent(myPositivePanel);
      splitter.setSecondComponent(myNegativePanel);

      myPositivePanel.getEmptyText().setText("Fold nothing");
      myNegativePanel.getEmptyText().setText("No exceptions");
    }
    return myMainComponent;
  }
コード例 #2
0
  @Override
  public boolean isModified() {
    EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
    boolean isModified =
        !Arrays.asList(myNegativePanel.getListItems()).equals(mySettings.getNegativePatterns());
    isModified |=
        !Arrays.asList(myPositivePanel.getListItems()).equals(mySettings.getPositivePatterns());
    isModified |=
        isModified(
            myCbUseSoftWrapsAtConsole,
            editorSettings.isUseSoftWraps(SoftWrapAppliancePlaces.CONSOLE));
    isModified |=
        isModified(
            myCommandsHistoryLimitField, UISettings.getInstance().CONSOLE_COMMAND_HISTORY_LIMIT);
    if (ConsoleBuffer.useCycleBuffer()) {
      isModified |=
          isModified(
              myCbOverrideConsoleCycleBufferSize,
              UISettings.getInstance().OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE);
      isModified |=
          isModified(
              myConsoleCycleBufferSizeField, UISettings.getInstance().CONSOLE_CYCLE_BUFFER_SIZE_KB);
    }

    return isModified;
  }
コード例 #3
0
  @Override
  public void reset() {
    EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
    UISettings uiSettings = UISettings.getInstance();

    myCbUseSoftWrapsAtConsole.setSelected(
        editorSettings.isUseSoftWraps(SoftWrapAppliancePlaces.CONSOLE));
    myCommandsHistoryLimitField.setText(Integer.toString(uiSettings.CONSOLE_COMMAND_HISTORY_LIMIT));

    myCbOverrideConsoleCycleBufferSize.setEnabled(ConsoleBuffer.useCycleBuffer());
    myCbOverrideConsoleCycleBufferSize.setSelected(uiSettings.OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE);
    myConsoleCycleBufferSizeField.setEnabled(
        ConsoleBuffer.useCycleBuffer() && uiSettings.OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE);
    myConsoleCycleBufferSizeField.setText(
        Integer.toString(uiSettings.CONSOLE_CYCLE_BUFFER_SIZE_KB));

    myNegativePanel.resetFrom(mySettings.getNegativePatterns());
    myPositivePanel.resetFrom(mySettings.getPositivePatterns());
  }
コード例 #4
0
  @Override
  public void apply() throws ConfigurationException {
    EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
    UISettings uiSettings = UISettings.getInstance();

    editorSettings.setUseSoftWraps(
        myCbUseSoftWrapsAtConsole.isSelected(), SoftWrapAppliancePlaces.CONSOLE);
    boolean uiSettingsChanged = false;
    if (isModified(myCommandsHistoryLimitField, uiSettings.CONSOLE_COMMAND_HISTORY_LIMIT)) {
      uiSettings.CONSOLE_COMMAND_HISTORY_LIMIT =
          Math.max(
              0, Math.min(1000, Integer.parseInt(myCommandsHistoryLimitField.getText().trim())));
      uiSettingsChanged = true;
    }
    if (ConsoleBuffer.useCycleBuffer()) {
      if (isModified(
          myCbOverrideConsoleCycleBufferSize, uiSettings.OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE)) {
        uiSettings.OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE =
            myCbOverrideConsoleCycleBufferSize.isSelected();
        uiSettingsChanged = true;
      }
      if (isModified(myConsoleCycleBufferSizeField, uiSettings.CONSOLE_CYCLE_BUFFER_SIZE_KB)) {
        uiSettings.CONSOLE_CYCLE_BUFFER_SIZE_KB =
            Math.max(
                0,
                Math.min(
                    1024 * 100, Integer.parseInt(myConsoleCycleBufferSizeField.getText().trim())));
        uiSettingsChanged = true;
      }
    }
    if (uiSettingsChanged) {
      uiSettings.fireUISettingsChanged();
    }

    myNegativePanel.applyTo(mySettings.getNegativePatterns());
    myPositivePanel.applyTo(mySettings.getPositivePatterns());
  }