r2535 - in trunk: . jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean jaxx-widgets/src/main/resources/icons
Author: tchemit Date: 2012-12-13 16:37:20 +0100 (Thu, 13 Dec 2012) New Revision: 2535 Url: http://nuiton.org/projects/jaxx/repository/revisions/2535 Log: refs #2474: Create a double list widget (improve it but still not perfect :() fixes #2479: Updates mavenpom to 3.4.6 fixes #2480: Updates to nuiton-utils 2.6.5 fixes #2481: Updates Eugene to 2.6 fixes #2482: Updates plexus-utils to 3.0.10 Added: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleList.css trunk/jaxx-widgets/src/main/resources/icons/action-bean-doublelist-select.png trunk/jaxx-widgets/src/main/resources/icons/action-bean-doublelist-unselect.png Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/BeanDoubleListDemo.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/BeanDoubleListDemoHandler.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleList.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleListHandler.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleListModel.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanListHeaderHandler.java trunk/pom.xml Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/BeanDoubleListDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/BeanDoubleListDemo.jaxx 2012-12-13 09:20:39 UTC (rev 2534) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/BeanDoubleListDemo.jaxx 2012-12-13 15:37:20 UTC (rev 2535) @@ -2,20 +2,20 @@ <import> jaxx.demo.entities.People + jaxx.runtime.swing.editor.bean.BeanDoubleList </import> <BeanDoubleListDemoHandler id='handler' constructorParams='this'/> - + <Table fill='both'> <row> <cell weighty='1' weightx='1'> - <jaxx.runtime.swing.editor.bean.BeanDoubleList id='doubleList' - beanType='{People.class}'/> + <BeanDoubleList id='doubleList' beanType='{People.class}'/> </cell> </row> </Table> - -<script><![CDATA[ + + <script><![CDATA[ protected void $afterCompleteSetup() { handler.init(); Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/BeanDoubleListDemo.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/BeanDoubleListDemoHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleList.css =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleList.css (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleList.css 2012-12-13 15:37:20 UTC (rev 2535) @@ -0,0 +1,47 @@ +/* + * #%L + * JAXX :: Widgets + * $Id$ + * $HeadURL$ + * %% + * 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 + * 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 + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +#model { + universeModel:{universeList.getModel()}; + selectedModel:{selectedList.getModel()}; +} + +#universeList { + model:{new DefaultListModel()}; +} + +#addButton { + toolTipText:"beandoublelist.button.add"; + actionIcon:"bean-doublelist-select"; + enabled:{model.isAddEnabled()}; +} + +#selectedList { + model:{new DefaultListModel()}; +} + +#removeButton { + toolTipText:"beandoublelist.button.remove"; + actionIcon:"bean-doublelist-unselect"; + enabled:{model.isRemoveEnabled()}; +} \ No newline at end of file Property changes on: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleList.css ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleList.jaxx =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleList.jaxx 2012-12-13 09:20:39 UTC (rev 2534) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleList.jaxx 2012-12-13 15:37:20 UTC (rev 2535) @@ -1,59 +1,96 @@ +<!-- + #%L + JAXX :: Widgets + $Id$ + $HeadURL$ + %% + 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 + 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 + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> <Table genericType='O'> -<import> + <import> org.nuiton.util.decorator.JXPathDecorator javax.swing.DefaultListModel -</import> + </import> - <!-- bean property --> + <!-- bean type --> <Class genericType='O' id='beanType' javaBean='null'/> <!-- label --> <String id='labelText' javaBean='null'/> - + <!-- bean property linked state --> <String id='property' javaBean='""'/> <!-- bean property --> <Object id='bean' javaBean='null'/> - + + <!-- show reset property --> + <Boolean id='showReset' javaBean='false'/> + + <!-- show decorator property --> + <!--Boolean id='showDecorator' javaBean='true'/--> + + <!--String id='i18nPrefix' javaBean='"beanlist.common."'/--> + <!-- model --> - <BeanDoubleListModel id='model' genericType='O' - universeModel='{universeList.getModel()}' - selectedModel='{selectedList.getModel()}'/> - + <BeanDoubleListModel id='model' genericType='O'/> + <!-- handler --> <BeanDoubleListHandler id='handler' genericType='O' constructorParams='this'/> - + <row> - <cell weightx='1' weighty='1' fill='both' rows='2'> - <JScrollPane> + <cell weightx='0.5' weighty='1' fill='both'> + <JScrollPane onFocusGained='universeList.requestFocus()'> + <!--columnHeaderView='{universeListHeader}'--> <!-- List of all the remaining available elements --> - <JList id='universeList' model='{new DefaultListModel()}'/> -<!-- <BeanListHeader id='universeListHeader' genericType='O' list='{universeList}'/>--> + <JList id='universeList' + onMouseClicked='handler.onUniverseListClicked(event)'/> + <!--BeanListHeader id='universeListHeader' genericType='O' + list='{universeList}' i18nPrefix="{getI18nPrefix()}" + showReset="{isShowReset()}" + showDecorator="{isShowDecorator()}"/--> </JScrollPane> </cell> + <cell anchor='north'> - <JButton id='addButton' toolTipText="beandoublelist.button.add" - actionIcon='select'/> + <JPanel layout='{new GridLayout(0,1)}'> + <JButton id='addButton' onActionPerformed='handler.select()'/> + <JButton id='removeButton' onActionPerformed='handler.unselect()'/> + </JPanel> </cell> - <cell weightx='1' weighty='1' fill='both' rows='2'> - <JScrollPane> + + <cell weightx='0.5' weighty='1' fill='both'> + <JScrollPane onFocusGained='selectedList.requestFocus()'> + <!--columnHeaderView='{selectedListHeader}'--> <!-- List of the selected elements --> - <JList id='selectedList' model='{new DefaultListModel()}'/> -<!-- <BeanListHeader id='selectedListHeader' genericType='O' list='{selectedList}'/>--> + <JList id='selectedList' + onMouseClicked='handler.onSelectedListClicked(event)'/> + <!--BeanListHeader id='selectedListHeader' genericType='O' + list='{selectedList}' i18nPrefix="{getI18nPrefix()}" + showReset="{isShowReset()}" + showDecorator="{isShowDecorator()}"/--> </JScrollPane> </cell> </row> - <row> - <cell anchor='north'> - <JButton id='removeButton' toolTipText="beandoublelist.button.remove" - actionIcon='unselect'/> - </cell> - </row> + + <script><![CDATA[ -<script><![CDATA[ - public void init(JXPathDecorator<O> decorator, List<O> universe, List<O> selected) { handler.init(decorator, universe, selected); } Property changes on: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleList.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native 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 2012-12-13 09:20:39 UTC (rev 2534) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleListHandler.java 2012-12-13 15:37:20 UTC (rev 2535) @@ -1,147 +1,136 @@ package jaxx.runtime.swing.editor.bean; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import javax.swing.event.ListDataEvent; -import org.nuiton.util.decorator.JXPathDecorator; -import org.nuiton.util.decorator.MultiJXPathDecorator; +/* + * #%L + * JAXX :: Widgets + * $Id$ + * $HeadURL$ + * %% + * 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 + * 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 + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + import jaxx.runtime.swing.renderer.DecoratorListCellRenderer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.nuiton.util.decorator.JXPathDecorator; +import org.nuiton.util.decorator.MultiJXPathDecorator; import javax.swing.JList; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.beans.PropertyDescriptor; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import java.awt.event.MouseEvent; import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; -import javax.swing.event.ListDataListener; -import javax.swing.plaf.basic.BasicComboBoxUI.ListDataHandler; -import org.apache.commons.beanutils.PropertyUtils; /** * The handler of a {@link BeanDoubleList}. * <p/> * - * @author kmorin <morin@codelutin.com> * @param <O> the type of the objects contained in the list. + * @author kmorin <morin@codelutin.com> * @see BeanDoubleList * @since 2.5.8 */ -public class BeanDoubleListHandler<O> implements PropertyChangeListener { - +public class BeanDoubleListHandler<O> { + private static final Log log = LogFactory.getLog(BeanDoubleListHandler.class); - + /** the mutator method on the property of boxed bean in the ui */ protected Method mutator; - + /** ui of the handler */ protected BeanDoubleList<O> ui; - + /** the decorator of data */ protected MultiJXPathDecorator<O> decorator; - + public BeanDoubleListHandler(BeanDoubleList<O> ui) { this.ui = ui; } /** * Initializes the handler of the UI + * * @param decorator the decorator to use to display the data nicely - * @param universe the list of all the available items - * @param selected the list of selected items + * @param universe the list of all the available items + * @param selected the list of selected items */ public void init(JXPathDecorator<O> decorator, List<O> universe, List<O> selected) { this.decorator = BeanUIUtil.createDecorator(decorator); - - initModel(universe, selected); - - final JList universeList = ui.getUniverseList(); - universeList.setCellRenderer(new DecoratorListCellRenderer(this.decorator)); - final JList selectedList = ui.getSelectedList(); - selectedList.setCellRenderer(new DecoratorListCellRenderer(this.decorator)); - initListeners(); - - ui.addPropertyChangeListener(this); - - } - - /** - * Initialize the model of the {@link BeanDoubleList} - * @param universe the list of all the available items - * @param selected the selected items - */ - protected void initModel(List<O> universe, List<O> selected) { ui.getModel().setUniverse(universe); ui.getModel().setSelected(selected); - } - - /** - * Initializes the listeners. - */ - protected void initListeners() { - final JList universeList = ui.getUniverseList(); - final JList selectedList = ui.getSelectedList(); - - universeList.addMouseListener(new MouseAdapter() { - - public void mouseClicked(MouseEvent event) { - if (event.getClickCount() == 2) { - int index = universeList.locationToIndex(event.getPoint()); - O item = (O) universeList.getModel().getElementAt(index); - ui.getModel().addToSelected(item); - } - } - }); - - selectedList.addMouseListener(new MouseAdapter() { - - public void mouseClicked(MouseEvent event) { - if (event.getClickCount() == 2) { - int index = selectedList.locationToIndex(event.getPoint()); - O item = (O) selectedList.getModel().getElementAt(index); - ui.getModel().removeFromSelected(item); - } - } - }); - - selectedList.getModel().addListDataListener(new ListDataListener() { - public void intervalAdded(ListDataEvent e) { - fireSelectionUpdate(); - } + JList universeList = ui.getUniverseList(); + JList selectedList = ui.getSelectedList(); - public void intervalRemoved(ListDataEvent e) { - fireSelectionUpdate(); - } + universeList.setCellRenderer(new DecoratorListCellRenderer(this.decorator)); + selectedList.setCellRenderer(new DecoratorListCellRenderer(this.decorator)); - public void contentsChanged(ListDataEvent e) { - fireSelectionUpdate(); + universeList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent e) { + ListSelectionModel source = (ListSelectionModel) e.getSource(); + ui.getModel().setAddEnabled(!source.isSelectionEmpty()); } }); - - ui.getAddButton().addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - List<O> selection = (List<O>) Arrays.asList(universeList.getSelectedValues()); - ui.getModel().addToSelected(selection); + selectedList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent e) { + ListSelectionModel source = (ListSelectionModel) e.getSource(); + ui.getModel().setRemoveEnabled(!source.isSelectionEmpty()); } }); - - ui.getRemoveButton().addActionListener(new ActionListener() { + } - public void actionPerformed(ActionEvent e) { - List<O> selection = (List<O>) Arrays.asList(selectedList.getSelectedValues()); - ui.getModel().removeFromSelected(selection); - } - }); - + public void onUniverseListClicked(MouseEvent event) { + JList universeList = ui.getUniverseList(); + if (event.getClickCount() == 2) { + int index = universeList.locationToIndex(event.getPoint()); + O item = (O) universeList.getModel().getElementAt(index); + ui.getModel().addToSelected(item); + } } - + + public void onSelectedListClicked(MouseEvent event) { + + JList selectedList = ui.getSelectedList(); + + if (event.getClickCount() == 2) { + int index = selectedList.locationToIndex(event.getPoint()); + O item = (O) selectedList.getModel().getElementAt(index); + ui.getModel().removeFromSelected(item); + } + } + + public void select() { + List<O> selection = (List<O>) Arrays.asList(ui.getUniverseList().getSelectedValues()); + ui.getModel().addToSelected(selection); + } + + public void unselect() { + List<O> selection = (List<O>) Arrays.asList(ui.getSelectedList().getSelectedValues()); + ui.getModel().removeFromSelected(selection); + } + protected void fireSelectionUpdate() { if (ui.getBean() == null) { return; @@ -155,7 +144,7 @@ throw new RuntimeException(e); } } - + /** @return le mutateur a utiliser pour modifier le bean associé. */ protected Method getMutator() { if (mutator == null) { @@ -163,9 +152,4 @@ } return mutator; } - - @Override - public void propertyChange(PropertyChangeEvent evt) { - } - } Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleListModel.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleListModel.java 2012-12-13 09:20:39 UTC (rev 2534) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleListModel.java 2012-12-13 15:37:20 UTC (rev 2535) @@ -1,38 +1,78 @@ package jaxx.runtime.swing.editor.bean; +/* + * #%L + * JAXX :: Widgets + * $Id$ + * $HeadURL$ + * %% + * 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 + * 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 + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + import com.google.common.collect.Lists; -import java.util.ArrayList; -import java.util.List; -import javax.swing.DefaultListModel; -import javax.swing.ListModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.jdesktop.beans.AbstractSerializableBean; +import javax.swing.DefaultListModel; +import javax.swing.ListModel; +import java.util.ArrayList; +import java.util.List; + /** * The model of the {@link BeanDoubleList} widget + * * @param <O> the type of the object in the list * @author kmorin <morin@codelutin.com> * @see BeanDoubleList - * @since 2.5.8 + * @since 2.5.8 */ -public class BeanDoubleListModel<O> { - +public class BeanDoubleListModel<O> extends AbstractSerializableBean { + private static final Log log = LogFactory.getLog(BeanDoubleListModel.class); - + + + public static final String PROPERTY_ADD_ENABLED = "addEnabled"; + + public static final String PROPERTY_REMOVE_ENABLED = "removeEnabled"; + + private static final long serialVersionUID = 1L; + /** List of all the available items */ protected List<O> universe = new ArrayList<O>(); - + /** Model containing the remaining available items */ protected ListModel universeModel = new DefaultListModel(); - + /** List of the selected items */ protected List<O> selected = new ArrayList<O>(); - + /** Model containing the selected items */ protected ListModel selectedModel = new DefaultListModel(); - + + + protected boolean addEnabled; + + protected boolean removeEnabled; + /** * To get the selected items. + * * @return a list of O */ public List<O> getSelected() { @@ -40,25 +80,27 @@ } /** - * Sets the list of selected items. + * Sets the list of selected items. * It fills the model of the list of the selected items with these items * and removes them from the model of list of the universe. + * * @param selected a list of O */ public void setSelected(List<O> selected) { //reset all the universe in the universe list resetUniverse(); - + if (selected == null) { selected = Lists.newArrayList(); } this.selected.clear(); - ((DefaultListModel)selectedModel).clear(); + ((DefaultListModel) selectedModel).clear(); addToSelected(selected); } /** * To get all the available items. + * * @return a list of O */ public List<O> getUniverse() { @@ -66,8 +108,9 @@ } /** - * Sets the list of the available items. + * Sets the list of the available items. * It fills the model of the universe list with these items. + * * @param universe a list of O */ public void setUniverse(List<O> universe) { @@ -77,11 +120,11 @@ this.universe = Lists.newArrayList(universe); resetUniverse(); } - + protected void resetUniverse() { - ((DefaultListModel)universeModel).clear(); + ((DefaultListModel) universeModel).clear(); for (O item : universe) { - ((DefaultListModel)universeModel).addElement(item); + ((DefaultListModel) universeModel).addElement(item); } } @@ -100,77 +143,103 @@ public void setUniverseModel(ListModel universeModel) { this.universeModel = universeModel; } - + /** * Adds an item to the selected items. + * * @param item the item to select */ public void addToSelected(O item) { selected.add(item); - ((DefaultListModel)selectedModel).addElement(item); - ((DefaultListModel)universeModel).removeElement(item); + ((DefaultListModel) selectedModel).addElement(item); + ((DefaultListModel) universeModel).removeElement(item); } - + /** * Adds a list of items to the selected items. + * * @param items the list of the items to select */ public void addToSelected(List<O> items) { selected.addAll(items); for (O item : items) { - ((DefaultListModel)selectedModel).addElement(item); - ((DefaultListModel)universeModel).removeElement(item); + ((DefaultListModel) selectedModel).addElement(item); + ((DefaultListModel) universeModel).removeElement(item); } } - + /** * Removes an item from the selected items. + * * @param item the item to unselect */ public void removeFromSelected(O item) { selected.remove(item); - ((DefaultListModel)selectedModel).removeElement(item); + ((DefaultListModel) selectedModel).removeElement(item); addToUniverseList(item); } - + /** * Removes a list of items from the list of selected items. + * * @param items the list of the items to unselect */ public void removeFromSelected(List<O> items) { selected.removeAll(items); for (O item : items) { - ((DefaultListModel)selectedModel).removeElement(item); + ((DefaultListModel) selectedModel).removeElement(item); addToUniverseList(item); } } - + + public boolean isAddEnabled() { + return addEnabled; + } + + public void setAddEnabled(boolean addEnabled) { + boolean oldValue = isAddEnabled(); + this.addEnabled = addEnabled; + firePropertyChange(PROPERTY_ADD_ENABLED, oldValue, addEnabled); + } + + public boolean isRemoveEnabled() { + return removeEnabled; + } + + public void setRemoveEnabled(boolean removeEnabled) { + boolean oldValue = isRemoveEnabled(); + this.removeEnabled = removeEnabled; + firePropertyChange(PROPERTY_REMOVE_ENABLED, oldValue, removeEnabled); + } + /** * Adds an item to the available items list at the right index * to keep always the same order. + * * @param item the item to add to the universe list */ protected void addToUniverseList(O item) { - DefaultListModel universeDefaultListModel = (DefaultListModel)universeModel; + DefaultListModel universeDefaultListModel = (DefaultListModel) universeModel; // the maximum index where we should insert the item is its index // in the list of all the available items int index = universe.indexOf(item); // if the index is upper than the size of the list of the remaining available items, // get the size of this list int insertionIndex = Math.min(index, universeDefaultListModel.getSize()); - + // we decrease the index to insert until we meet an item whose index // in the list of all the available index is lower than the one of the item // we want to insert while (insertionIndex > 0) { - O o = (O)universeDefaultListModel.get(--insertionIndex); + O o = (O) universeDefaultListModel.get(--insertionIndex); int oIndex = universe.indexOf(o); if (oIndex < index) { insertionIndex++; break; } - }; - + } + ; + universeDefaultListModel.add(insertionIndex, item); } } Property changes on: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanDoubleListModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanListHeaderHandler.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanListHeaderHandler.java 2012-12-13 09:20:39 UTC (rev 2534) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanListHeaderHandler.java 2012-12-13 15:37:20 UTC (rev 2535) @@ -35,9 +35,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import javax.swing.DefaultListModel; import javax.swing.JComponent; import javax.swing.JList; import javax.swing.JPopupMenu; +import javax.swing.ListModel; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.List; @@ -199,8 +201,20 @@ try { // reload the model - ui.getList().setListData(datas.toArray(new Object[datas.size()])); + ListModel listModel = ui.getList().getModel(); + if( listModel instanceof DefaultListModel) { + DefaultListModel model = (DefaultListModel) listModel; + model.removeAllElements(); + for (O data : datas) { + model.addElement(data); + } + + } else { + + ui.getList().setListData(datas.toArray(new Object[datas.size()])); + } + // re-apply selection if (selection.length > 0) { Added: trunk/jaxx-widgets/src/main/resources/icons/action-bean-doublelist-select.png =================================================================== (Binary files differ) Property changes on: trunk/jaxx-widgets/src/main/resources/icons/action-bean-doublelist-select.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/jaxx-widgets/src/main/resources/icons/action-bean-doublelist-unselect.png =================================================================== (Binary files differ) Property changes on: trunk/jaxx-widgets/src/main/resources/icons/action-bean-doublelist-unselect.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-12-13 09:20:39 UTC (rev 2534) +++ trunk/pom.xml 2012-12-13 15:37:20 UTC (rev 2535) @@ -30,7 +30,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>mavenpom4redmineAndCentral</artifactId> - <version>3.4.4</version> + <version>3.4.6</version> </parent> <artifactId>jaxx</artifactId> @@ -111,13 +111,13 @@ <!-- pour un muli module on doit fixer le projectId --> <projectId>jaxx</projectId> - <nuitonUtilsVersion>2.6.4</nuitonUtilsVersion> + <nuitonUtilsVersion>2.6.5</nuitonUtilsVersion> <nuitonI18nVersion>2.5</nuitonI18nVersion> - <eugeneVersion>2.5.6</eugeneVersion> + <eugeneVersion>2.6</eugeneVersion> <jxLayerVersion>3.0.4</jxLayerVersion> <javaHelpVersion>2.0.05</javaHelpVersion> <swingXVersion>1.6.4</swingXVersion> - <plexusUtilVersion>3.0.9</plexusUtilVersion> + <plexusUtilVersion>3.0.10</plexusUtilVersion> <!-- i18n configuration --> <i18n.bundles>fr_FR,en_GB,es_ES</i18n.bundles>
participants (1)
-
tchemit@users.nuiton.org