@Nullable
 private Pair<BeforeRunTask, BeforeRunTaskProvider<BeforeRunTask>> getSelection() {
   final int index = myList.getSelectedIndex();
   if (index == -1) return null;
   BeforeRunTask task = myModel.getElementAt(index);
   Key providerId = task.getProviderId();
   BeforeRunTaskProvider<BeforeRunTask> provider =
       BeforeRunTaskProvider.getProvider(myRunConfiguration.getProject(), providerId);
   return provider != null ? Pair.create(task, provider) : null;
 }
 private void updateCurrentRule() {
   if (myLastSelected >= 0 && myLastSelected < myRulesModel.getSize()) {
     LibraryBundlificationRule newRule = new LibraryBundlificationRule();
     newRule.setRuleRegex(myLibraryRegex.getText().trim());
     newRule.setAdditionalProperties(myManifestEditor.getText().trim());
     newRule.setDoNotBundle(myNeverBundle.isSelected());
     newRule.setStopAfterThisRule(myStopAfterThisRule.isSelected());
     if (!newRule.equals(myRulesModel.getElementAt(myLastSelected))) {
       myRulesModel.setElementAt(newRule, myLastSelected);
     }
   }
 }
 public boolean isModified(ApplicationSettings settings) {
   updateCurrentRule();
   List<LibraryBundlificationRule> rules = settings.getLibraryBundlificationRules();
   if (myRulesModel.getSize() != rules.size()) {
     return true;
   }
   for (int i = 0; i < rules.size(); i++) {
     if (!rules.get(i).equals(myRulesModel.getElementAt(i))) {
       return true;
     }
   }
   return false;
 }
  public void applyTo(ApplicationSettings settings) throws ConfigurationException {
    updateCurrentRule();

    for (int i = 0; i < myRulesModel.getSize(); i++) {
      try {
        myRulesModel.getElementAt(i).validate();
      } catch (IllegalArgumentException e) {
        myRulesList.setSelectedIndex(i);
        throw new ConfigurationException(e.getMessage());
      }
    }

    settings.setLibraryBundlificationRules(ContainerUtil.newArrayList(myRulesModel.getItems()));
  }
 private void updateFields() {
   int index = myRulesList.getSelectedIndex();
   if (index >= 0 && index != myLastSelected) {
     final LibraryBundlificationRule rule = myRulesModel.getElementAt(index);
     myLibraryRegex.setText(rule.getRuleRegex());
     UIUtil.invokeLaterIfNeeded(() -> myManifestEditor.setText(rule.getAdditionalProperties()));
     myNeverBundle.setSelected(rule.isDoNotBundle());
     myStopAfterThisRule.setSelected(rule.isStopAfterThisRule());
     myLastSelected = index;
   }
   myLibraryRegex.setEnabled(index >= 0);
   myManifestEditor.setEnabled(index >= 0);
   myNeverBundle.setEnabled(index >= 0);
   myStopAfterThisRule.setEnabled(index >= 0);
 }