コード例 #1
0
    public MyValidatableComponent() {
      myNameLabel.setLabelFor(myNameText);
      myNameText.setDocument(myNameDocument);

      getEditor()
          .addSettingsEditorListener(
              new SettingsEditorListener() {
                public void stateChanged(SettingsEditor settingsEditor) {
                  updateWarning();
                }
              });

      myWarningLabel.setIcon(IconLoader.getIcon("/runConfigurations/configurationWarning.png"));

      myComponentPlace.setLayout(new GridBagLayout());
      myComponentPlace.add(
          getEditorComponent(),
          new GridBagConstraints(
              0,
              0,
              1,
              1,
              1.0,
              1.0,
              GridBagConstraints.NORTHWEST,
              GridBagConstraints.BOTH,
              new Insets(0, 0, 0, 0),
              0,
              0));
      myComponentPlace.doLayout();
      myFixButton.setIcon(IconLoader.getIcon("/actions/quickfixBulb.png"));
      updateWarning();
      myFixButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
              if (myQuickFix == null) {
                return;
              }
              myQuickFix.run();
              myValidationResultValid = false;
              updateWarning();
            }
          });
    }
コード例 #2
0
    private void updateWarning() {
      final ValidationResult configurationException = getValidationResult();

      if (configurationException != null) {
        myOutlinePanel.setVisible(true);
        myWarningLabel.setVisible(true);
        myWarningLabel.setText(generateWarningLabelText(configurationException));
        final Runnable quickFix = configurationException.getQuickFix();
        if (quickFix == null) {
          myFixButton.setVisible(false);
        } else {
          myFixButton.setVisible(true);
          myQuickFix = quickFix;
        }

      } else {
        myOutlinePanel.setVisible(false);
        myWarningLabel.setVisible(false);
        myFixButton.setVisible(false);
      }
    }