/** * Find the class for the projection * * @param proj projection * @return corresponding ProjectionClass (or null if not found) */ private ProjectionClass findProjectionClass(Projection proj) { Class want = proj.getClass(); ComboBoxModel projClassList = projClassCB.getModel(); for (int i = 0; i < projClassList.getSize(); i++) { ProjectionClass pc = (ProjectionClass) projClassList.getElementAt(i); if (want.equals(pc.projClass)) { return pc; } } return null; }
private Object lookupItem(String pattern) { Object selectedItem = model.getSelectedItem(); // only search for a different item if the currently selected does not match if (selectedItem != null && startsWithIgnoreCase(selectedItem.toString(), pattern)) { return selectedItem; } else { // iterate over all items for (int i = 0, n = model.getSize(); i < n; i++) { Object currentItem = model.getElementAt(i); // current item starts with the pattern? if (currentItem != null && startsWithIgnoreCase(currentItem.toString(), pattern)) { return currentItem; } } } // no item starts with the pattern => return null return null; }