Author: kmorin Date: 2013-03-07 11:24:17 +0100 (Thu, 07 Mar 2013) New Revision: 2593 Url: http://nuiton.org/projects/jaxx/repository/revisions/2593 Log: add public method to refilter the elements Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleListHandler.java Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleListHandler.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleListHandler.java 2013-03-07 10:23:58 UTC (rev 2592) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleListHandler.java 2013-03-07 10:24:17 UTC (rev 2593) @@ -9,16 +9,16 @@ * Copyright (C) 2008 - 2012 CodeLutin * %% * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public + * + * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. * #L% @@ -71,10 +71,10 @@ /** ui of the handler */ protected BeanDoubleList<O> ui; - + /** the decorator of data */ protected MultiJXPathDecorator<O> decorator; - + public BeanDoubleListHandler(BeanDoubleList<O> ui) { this.ui = ui; } @@ -91,7 +91,7 @@ return ui.getChangeDecorator(); } }; - + /** * Initializes the handler of the UI * @@ -101,14 +101,14 @@ */ public void init(JXPathDecorator<O> decorator, List<O> universe, List<O> selected) { this.decorator = BeanUIUtil.createDecorator(decorator); - + ui.getModel().setUniverse(universe); ui.getModel().setSelected(selected); JList universeList = ui.getUniverseList(); JList selectedList = ui.getSelectedList(); - final FilteredDecoratorListCellRenderer universeListCellRenderer + final FilteredDecoratorListCellRenderer universeListCellRenderer = new FilteredDecoratorListCellRenderer(this.decorator); universeList.setCellRenderer(universeListCellRenderer); selectedList.setCellRenderer(new DecoratorListCellRenderer(this.decorator)); @@ -145,9 +145,9 @@ fireSelectionUpdate(); } }); - + JAXXButtonGroup indexes = ui.getIndexes(); - + // build popup popupHandler.preparePopup(null, null, @@ -159,14 +159,14 @@ ui.getSortUp(), ui.getSortDown(), this.decorator); - + ui.addPropertyChangeListener(this); - - final JaxxFilterableListModel<O> filterModel = + + final JaxxFilterableListModel<O> filterModel = (JaxxFilterableListModel) ui.getModel().getUniverseModel(); - + filterModel.setDecorator(this.decorator); - + ui.getFilterField().getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { @@ -187,10 +187,10 @@ filterModel.setFilterText(text); } }); - + // select sort button indexes.setSelectedButton(ui.getIndex()); - + sortData(); } @@ -198,17 +198,17 @@ ui.getModel().setUniverse(selection); sortData(); } - + public void setSelected(List<O> selection) { ui.getModel().setSelected(selection); sortData(); } - + /** Toggle the popup visible state. */ public void togglePopup() { popupHandler.togglePopup(); } - + /** * Sort data of the model. * @@ -219,7 +219,7 @@ // just update UI should do the math of this updateUI(ui.getIndex(), ui.isReverseSort()); } - + /** * Modifie l'index du décorateur * @@ -235,7 +235,7 @@ } updateUI(newValue, ui.isReverseSort()); } - + /** * Modifie l'index du décorateur * @@ -256,14 +256,14 @@ } protected void setHighlightFilterText(Boolean newValue) { - FilteredDecoratorListCellRenderer universeListCellRenderer = + FilteredDecoratorListCellRenderer universeListCellRenderer = (FilteredDecoratorListCellRenderer) ui.getUniverseList().getCellRenderer(); universeListCellRenderer.setHighlightFilterText(newValue); ui.getUniverseList().repaint(); } - + protected void updateUI(int index, boolean reversesort) { - + // change decorator context decorator.setContextIndex(index); @@ -285,7 +285,7 @@ ui.getUniverseList().requestFocus(); } - + /** * When universe list was double clicked, move selected items to selected list. * @@ -297,7 +297,7 @@ int index = universeList.locationToIndex(event.getPoint()); O item = (O) universeList.getModel().getElementAt(index); ui.getModel().addToSelected(item); - + updateUI(ui.getIndex(), ui.isReverseSort()); } } @@ -315,7 +315,7 @@ int index = selectedList.locationToIndex(event.getPoint()); O item = (O) selectedList.getModel().getElementAt(index); ui.getModel().removeFromSelected(item); - + updateUI(ui.getIndex(), ui.isReverseSort()); } } @@ -350,11 +350,11 @@ } return mutator; } - + public MultiJXPathDecorator<O> getDecorator() { return decorator; } - + /** * @return get the type of objects contained in the comboBox model. * @since 2.5.9 @@ -366,7 +366,7 @@ } return result; } - + @Override public void propertyChange(PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); @@ -376,29 +376,33 @@ // decorator index has changed, force reload of data in ui setIndex((Integer) evt.getOldValue(), (Integer) evt.getNewValue()); - + } else if (BeanDoubleList.PROPERTY_REVERSE_SORT.equals(propertyName)) { // sort order has changed, force reload of data in ui setSortOrder((Boolean) evt.getOldValue(), (Boolean) evt.getNewValue()); - + } else if (BeanDoubleList.PROPERTY_HIGHLIGHT_FILTER_TEXT.equals(propertyName)) { - + setHighlightFilterText((Boolean) evt.getNewValue()); } } - + public void addFilter(Predicate<O> filter) { ((JaxxFilterableListModel) ui.getModel().getUniverseModel()).addFilter(filter); } - + public void removeFilter(Predicate<O> filter) { ((JaxxFilterableListModel) ui.getModel().getUniverseModel()).removeFilter(filter); } - + public void clearFilters() { ((JaxxFilterableListModel) ui.getModel().getUniverseModel()).clearFilters(); } - + + public void refreshFilteredElements() { + ((JaxxFilterableListModel) ui.getModel().getUniverseModel()).refreshFilteredElements(); + } + }