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()));
  }
Ejemplo n.º 4
0
  private static void assertMerge(
      String[] items, int startSelection, int expectedSelection, String... newItems) {
    CollectionListModel<String> model = new CollectionListModel<String>();
    model.add(Arrays.asList(items));
    JBList list = new JBList(model);
    list.setSelectedIndex(startSelection);

    FinderRecursivePanel.mergeListItems(model, Arrays.asList(newItems));
    assertEquals(newItems.length, model.getSize());
    for (int i = 0; i < newItems.length; i++) {
      assertEquals(newItems[i], model.getElementAt(i));
    }
    assertEquals(expectedSelection, list.getSelectedIndex());
  }