/** * Installs the searchable function onto a JComboBox. * * @param combobox the combo box to install searchable * @return A ComboBoxSearchable */ public static ComboBoxSearchable installSearchable(JComboBox combobox) { return new ComboBoxSearchable(combobox); }
public void intervalRemoved(ListDataEvent e) { if (!isProcessModelChangeEvent()) { return; } hidePopup(); fireSearchableEvent(new SearchableEvent(this, SearchableEvent.SEARCHABLE_MODEL_CHANGE)); }
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { if (isHideSearchPopupOnEvent()) { hidePopup(); } }
public static AutoCompletion installSearchable(final JComboBox combo) { boolean wasEditable = combo.isEditable(); combo.setEditable(false); ComboBoxSearchable searchable = SearchableUtils.installSearchable(combo); searchable.setCaseSensitive(false); searchable.setWildcardEnabled(true); searchable.setCountMatch(true); searchable.setShowPopupDuringSearching(true); searchable.setRefreshPopupDuringSearching(true); AutoCompletion autoCompletion = new AutoCompletion(combo, searchable) { @Override protected AutoCompletionDocument createDocument() { return super.createDocument(); } }; autoCompletion.setStrict(false); autoCompletion.setStrictCompletion(false); autoCompletion.installListeners(); combo.setEditable(wasEditable); return autoCompletion; }
@Override protected void setSelectedIndex(int index, boolean incremental) { if (((JComboBox) _component).getSelectedIndex() != index) { ((JComboBox) _component).setSelectedIndex(index); } if (isShowPopupDuringSearching() || isRefreshPopupDuringSearching()) { if (_component.getClientProperty("ShrinkSearchableSupport") != null && ((JComboBox) _component).isPopupVisible()) { boolean old = isHideSearchPopupOnEvent(); setHideSearchPopupOnEvent(false); ((JComboBox) _component).hidePopup(); setHideSearchPopupOnEvent(old); } try { if (!((JComboBox) _component).isPopupVisible() && KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != null && SwingUtilities.isDescendingFrom(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(), _component)) { ((JComboBox) _component).showPopup(); } } catch (IllegalComponentStateException e) { //null } } }
@Override protected String convertElementToString(Object o) { if (o instanceof AbstractCrsProvider) { AbstractCrsProvider wrapper = (AbstractCrsProvider) o; return wrapper.getName(); } else { return super.convertElementToString(o); } } }
public void propertyChange(PropertyChangeEvent evt) { if ("model".equals(evt.getPropertyName())) { hidePopup(); if (evt.getOldValue() instanceof ComboBoxModel) { ((ComboBoxModel) evt.getOldValue()).removeListDataListener(this); } if (evt.getNewValue() instanceof ComboBoxModel) { ((ComboBoxModel) evt.getNewValue()).addListDataListener(this); } fireSearchableEvent(new SearchableEvent(this, SearchableEvent.SEARCHABLE_MODEL_CHANGE)); } }
textChanged(text); if (isShowPopupDuringSearching()) { if (!comboBox.getUI().getClass().getName().contains("ExComboBoxUI")) { // only cover the JComboBox for now but not the subclass of JComboBox because don't want dependency on ExComboBox in JCL comboBox.hidePopup();
public AutoCompletion(final JComboBox comboBox, Searchable searchable) { _searchable = searchable; _propertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if ("editor".equals(e.getPropertyName())) { if (e.getNewValue() != null) { _textComponent = (JTextComponent) ((ComboBoxEditor) e.getNewValue()).getEditorComponent(); configureEditor(getTextComponent()); } } } }; _comboBox = comboBox; _searchable.setWildcardEnabled(false); if (_searchable instanceof ComboBoxSearchable) { ((ComboBoxSearchable) _searchable).setShowPopupDuringSearching(false); } _textComponent = (JTextComponent) comboBox.getEditor().getEditorComponent(); installListeners(); }
projectionComboBox.setEditable(false); // combobox searchable only works when combobox is not editable. final ComboBoxSearchable methodSearchable = new CrsProviderSearchable(projectionComboBox); methodSearchable.installListeners(); projectionComboBox.setRenderer(new CrsProviderCellRenderer()); datumComboBox.setRenderer(new IdentifiedObjectCellRenderer()); final ComboBoxSearchable datumSearchable = new IdentifiedObjectSearchable(datumComboBox); datumSearchable.installListeners();
@Override protected String convertElementToString(Object o) { if (o instanceof AbstractCrsProvider) { AbstractCrsProvider wrapper = (AbstractCrsProvider) o; return wrapper.getName(); } else { return super.convertElementToString(o); } } }
projectionComboBox.setEditable(false); // combobox searchable only works when combobox is not editable. final ComboBoxSearchable methodSearchable = new CrsProviderSearchable(projectionComboBox); methodSearchable.installListeners(); projectionComboBox.setRenderer(new CrsProviderCellRenderer()); datumComboBox.setRenderer(new IdentifiedObjectCellRenderer()); final ComboBoxSearchable datumSearchable = new IdentifiedObjectSearchable(datumComboBox); datumSearchable.installListeners();
public void intervalAdded(ListDataEvent e) { if (!isProcessModelChangeEvent()) { return; } hidePopup(); fireSearchableEvent(new SearchableEvent(this, SearchableEvent.SEARCHABLE_MODEL_CHANGE)); }
@Override protected String convertElementToString(Object o) { if (o instanceof IdentifiedObject) { IdentifiedObject identifiedObject = (IdentifiedObject) o; return identifiedObject.getName().getCode(); } else { return super.convertElementToString(o); } } }
public AutoCompletion(final JComboBox comboBox) { this(comboBox, new ComboBoxSearchable(comboBox)); }
public void contentsChanged(ListDataEvent e) { if (!isProcessModelChangeEvent()) { return; } if (e.getIndex0() == -1 && e.getIndex1() == -1) { } else { hidePopup(); fireSearchableEvent(new SearchableEvent(this, SearchableEvent.SEARCHABLE_MODEL_CHANGE)); } }
@Override protected String convertElementToString(Object o) { if (o instanceof IdentifiedObject) { IdentifiedObject identifiedObject = (IdentifiedObject) o; return identifiedObject.getName().getCode(); } else { return super.convertElementToString(o); } } }