use of javax.swing.RowFilter in project megameklab by MegaMek.
the class SpecializationView method filterSpecializations.
private void filterSpecializations() {
RowFilter<SpecializationModel, Integer> filter = new RowFilter<SpecializationModel, Integer>() {
@Override
public boolean include(Entry<? extends SpecializationModel, ? extends Integer> entry) {
SpecializationModel specModel = entry.getModel();
TechAdvancement techAdvancement = specModel.getTechAdvancement(entry.getIdentifier());
if ((1 << entry.getIdentifier() == Infantry.TAG_TROOPS) && TestInfantry.maxSecondaryWeapons(getInfantry()) < 2) {
return false;
}
return (null != eSource.getTechManager()) && eSource.getTechManager().isLegal(techAdvancement);
}
};
sorter.setRowFilter(filter);
}
use of javax.swing.RowFilter in project wekapar by gems-uff.
the class PostprocessAssociationsPanel method buildMetricsFilter.
/**
* Builds a {@link RowFilter} according to selected metrics minimum values.
*
* @return the row filter object
*/
private static RowFilter<? super TableModel, ? super Integer> buildMetricsFilter() {
RowFilter<Object, Object> rowFilter = RowFilter.regexFilter(".*");
List<RowFilter<Object, Object>> metricFilters = new ArrayList<RowFilter<Object, Object>>();
List<RowFilter<Object, Object>> metricFilter;
RowFilter<Object, Object> filterEqual;
RowFilter<Object, Object> filterAfter;
RulesTableColumnModel columnModel = (RulesTableColumnModel) table.getColumnModel();
MetricSpinner spinner;
String key;
double value;
int columnIndex;
for (Map.Entry<String, JSpinner> entry : metricSpinnerMap.entrySet()) {
metricFilter = new ArrayList<RowFilter<Object, Object>>();
key = entry.getKey();
spinner = (MetricSpinner) entry.getValue();
value = (Double) spinner.getValue();
if (columnModel.hasColumn(key)) {
if (!spinner.isMinimumSelected()) {
columnIndex = table.getColumnModel().getColumnIndex(key);
filterEqual = RowFilter.numberFilter(ComparisonType.EQUAL, value, table.convertColumnIndexToModel(columnIndex));
filterAfter = RowFilter.numberFilter(ComparisonType.AFTER, value, table.convertColumnIndexToModel(columnIndex));
metricFilter.add(filterEqual);
metricFilter.add(filterAfter);
metricFilters.add(RowFilter.orFilter(metricFilter));
}
}
}
rowFilter = RowFilter.andFilter(metricFilters);
return rowFilter;
}
use of javax.swing.RowFilter in project dna by leifeld.
the class DocumentPanel method documentFilter.
public void documentFilter() {
RowFilter<DocumentTableModel, Integer> documentFilter = new RowFilter<DocumentTableModel, Integer>() {
public boolean include(Entry<? extends DocumentTableModel, ? extends Integer> entry) {
DocumentTableModel dtm = entry.getModel();
Document d = dtm.get(entry.getIdentifier());
int documentId = d.getId();
boolean[] b = Dna.data.getActiveDocumentPermissions(documentId);
if (b[0] == true) {
return true;
}
return false;
}
};
sorter.setRowFilter(documentFilter);
}
use of javax.swing.RowFilter in project gitblit by gitblit.
the class GitblitAuthority method filterUsers.
private void filterUsers(final String fragment) {
table.clearSelection();
userCertificatePanel.setUserCertificateModel(null);
if (StringUtils.isEmpty(fragment)) {
table.setRowSorter(defaultSorter);
return;
}
RowFilter<UserCertificateTableModel, Object> containsFilter = new RowFilter<UserCertificateTableModel, Object>() {
@Override
public boolean include(Entry<? extends UserCertificateTableModel, ? extends Object> entry) {
for (int i = entry.getValueCount() - 1; i >= 0; i--) {
if (entry.getStringValue(i).toLowerCase().contains(fragment.toLowerCase())) {
return true;
}
}
return false;
}
};
TableRowSorter<UserCertificateTableModel> sorter = new TableRowSorter<UserCertificateTableModel>(tableModel);
sorter.setRowFilter(containsFilter);
table.setRowSorter(sorter);
}
use of javax.swing.RowFilter in project megameklab by MegaMek.
the class CISpecializationView method filterSpecializations.
private void filterSpecializations() {
RowFilter<SpecializationModel, Integer> filter = new RowFilter<SpecializationModel, Integer>() {
@Override
public boolean include(Entry<? extends SpecializationModel, ? extends Integer> entry) {
SpecializationModel specModel = entry.getModel();
TechAdvancement techAdvancement = specModel.getTechAdvancement(entry.getIdentifier());
if ((1 << entry.getIdentifier() == Infantry.TAG_TROOPS) && TestInfantry.maxSecondaryWeapons(getInfantry()) < 2) {
return false;
}
return (null != eSource.getTechManager()) && eSource.getTechManager().isLegal(techAdvancement);
}
};
sorter.setRowFilter(filter);
}
Aggregations