public int compare(Presentation p1, Presentation p2) { final Agent p1Owner = p1.getOwner(); final Agent p2Owner = p2.getOwner(); if (p1Owner == null) { if (p2Owner == null) { return 0; } else { return -1; } } else if (p2Owner == null) { return 1; } else { // get the sort names String name1 = p1Owner.getDisplayName(); String name2 = p2Owner.getDisplayName(); try { name1 = UserDirectoryService.getUserByEid(p1Owner.getEid().getValue()).getSortName(); } catch (Exception e) { // nothing to do } try { name2 = UserDirectoryService.getUserByEid(p2Owner.getEid().getValue()).getSortName(); } catch (Exception e) { // nothing to do } int result = stringComparator.compare(name1, name2); if (result == 0) { result = nameComparator.compare(p1, p2); } return result; } }
/** * Finds an item between list items. * * @param item a text pattern. * @param comparator a searching criteria. * @return an item index. */ public int findItemIndex(String item, StringComparator comparator) { ComboBoxModel<?> model = getModel(); for (int i = 0; i < model.getSize(); i++) { if (comparator.equals(model.getElementAt(i).toString(), item)) { return i; } } return -1; }
@Override public boolean checkComponent(Component comp) { if (comp instanceof JComboBox) { if (label == null) { return true; } if (((JComboBox) comp).getModel().getSize() > itemIndex) { int ii = itemIndex; if (ii == -1) { ii = ((JComboBox) comp).getSelectedIndex(); if (ii == -1) { return false; } } return (comparator.equals( ((JComboBox) comp).getModel().getElementAt(ii).toString(), label)); } } return false; }
public int compare(DataCount<String> c1, DataCount<String> c2) { if (c1.count != c2.count) return c2.count - c1.count; return alphabetical.compare(c1.data, c2.data); }
public final int compare(Presentation p1, Presentation p2) { return stringComparator.compare(p1.getName(), p2.getName()); }