/** Creates a filter with the current settings and adds it to the applied filters. */ private void addToAppliedFilters() { RegisteredFilters selectedFilter = (RegisteredFilters) comboAvailableFilters.getSelectedItem(); String filterShort = selectedFilter.getShortName(); if (selectedFilter.equals(RegisteredFilters.PSM_SCORE_FILTER)) { filterShort = PSMScoreFilter.prefix + comboAvailableFilterScores.getSelectedItem(); } else if (selectedFilter.equals(RegisteredFilters.PSM_TOP_IDENTIFICATION_FILTER)) { filterShort = PSMTopIdentificationFilter.prefix + comboAvailableFilterScores.getSelectedItem(); } else if (selectedFilter.equals(RegisteredFilters.PEPTIDE_SCORE_FILTER)) { filterShort = PeptideScoreFilter.prefix + comboAvailableFilterScores.getSelectedItem(); } FilterComparator comparator = (FilterComparator) comboAvailableFilterComparators.getSelectedItem(); String argument = fieldFilterArgument.getText(); Boolean negate = checkNegateFilter.isSelected(); StringBuilder messageBuffer = new StringBuilder(); /// we have a valid value, so go on AbstractFilter newFilter = FilterFactory.newInstanceOf(filterShort, comparator, argument, negate, messageBuffer); if (newFilter != null) { ((DefaultListModel<AbstractFilter>) listAppliedFilters.getModel()).addElement(newFilter); messageBuffer.append("new filter added"); } else { messageBuffer.insert(0, "Error adding filter: "); logger.error(messageBuffer.toString()); } }
/** * Updates the shown options for the available filter comparators. These are based on the * currently selected filter and whether this is a score filter or a basic filter. * * @param selectedFilter */ private void updateSelectedAvailableFilters(RegisteredFilters selectedFilter) { // set the available filter comparators if (selectedFilter != null) { if (comboAvailableFilterComparators != null) { comboAvailableFilterComparators.removeAllItems(); for (FilterComparator comparator : selectedFilter.getFilterType().getAvailableComparators()) { comboAvailableFilterComparators.addItem(comparator); } } if (comboAvailableFilterScores != null) { comboAvailableFilterScores.setEnabled( selectedFilter.equals(RegisteredFilters.PSM_SCORE_FILTER) || selectedFilter.equals(RegisteredFilters.PSM_TOP_IDENTIFICATION_FILTER) || selectedFilter.equals(RegisteredFilters.PEPTIDE_SCORE_FILTER) || selectedFilter.equals(RegisteredFilters.PROTEIN_SCORE_FILTER)); } } }
@Override public Component getListCellRendererComponent( JList<? extends RegisteredFilters> list, RegisteredFilters value, int index, boolean isSelected, boolean cellHasFocus) { if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } setText(value.getFilteringListName()); return this; }