UserFilter[] userFilterArr = mFilterList.getUserFilterArr();
FilterComponent fc = mComponentTableModel.getElement(mRuleTableBox.getSelectedRow());
// Create the Filter based on the new Rule and check if the FC exists
// there
UserFilter testFilter = new UserFilter("test");
try {
testFilter.setRule(mFilterRuleTF.getText());
if (testFilter.containsRuleComponent(fc.getName())) {
allowRemove = false;
JOptionPane.showMessageDialog(this, mLocalizer.msg("usedByAnotherFilter",
"This filter component is used by filter '{0}'\nRemove the filter first.", mFilterNameTF.getText()));
}
} catch (Exception ex) {
// Filter creation failed, assume the old one is correct
if ((mFilter != null) && (mFilter.containsRuleComponent(fc.getName()))) {
allowRemove = false;
JOptionPane.showMessageDialog(this, mLocalizer.msg("usedByAnotherFilter",
"This filter component is used by filter '{0}'\nRemove the filter first.", mFilterNameTF.getText()));
}
}
for (int i = 0; i < userFilterArr.length && allowRemove; i++) {
if ((userFilterArr[i] != mFilter) && userFilterArr[i].containsRuleComponent(fc.getName())) {
allowRemove = false;
JOptionPane.showMessageDialog(this, mLocalizer.msg("usedByAnotherFilter",
"This filter component is used by filter '{0}'\nRemove the filter first.", userFilterArr[i].toString()));
}
}
if (allowRemove) {
FilterComponentList.getInstance().remove(fc.getName());
mComponentTableModel.removeElement(mRuleTableBox.getSelectedRow());
updateBtns();
}
} else if (o == mOkBtn) {
String filterName = mFilterNameTF.getText();
if (!filterName.equalsIgnoreCase(mFilterName) && mFilterList.containsFilter(filterName)) {
JOptionPane
.showMessageDialog(this, mLocalizer.msg("alreadyExists", "Filter '{0}' already exists.", filterName));
} else {
if (mFilter == null) {
mFilter = new UserFilter(mFilterNameTF.getText());
} else {
mFilter.setName(mFilterNameTF.getText());
}
try {