This is an automated email from the git hooks/post-receive script. New commit to annotated tag v2.0.0-beta-1 in repository jaxx. See https://gitlab.nuiton.org/nuiton/jaxx.git commit 7711568c4363aa8135cfd415ccd264b9d9a98852 Author: Tony Chemit <chemit@codelutin.com> Date: Wed Nov 4 20:35:40 2009 +0000 add fillList + deprecated some code --- .../src/main/java/jaxx/runtime/SwingUtil.java | 79 ++++++++++++++-------- .../main/java/jaxx/runtime/swing/JAXXComboBox.java | 28 ++++++-- 2 files changed, 71 insertions(+), 36 deletions(-) diff --git a/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java b/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java index e6ea4d9..adfefa7 100644 --- a/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java +++ b/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java @@ -35,10 +35,7 @@ import java.beans.PropertyDescriptor; import java.io.IOException; import java.io.InputStream; import java.util.List; -import javax.swing.DefaultComboBoxModel; -import javax.swing.JComboBox; -import javax.swing.JTable; -import javax.swing.SwingUtilities; +import javax.swing.*; import javax.swing.event.TreeSelectionEvent; import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; @@ -58,21 +55,12 @@ import java.util.Map; import java.util.Map.Entry; import java.util.NoSuchElementException; import java.util.Properties; -import javax.swing.Icon; -import javax.swing.ImageIcon; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.JLayeredPane; -import javax.swing.JRootPane; -import javax.swing.JTabbedPane; -import javax.swing.JTree; -import javax.swing.UIManager; -import javax.swing.UnsupportedLookAndFeelException; import javax.swing.event.HyperlinkEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; + import jaxx.runtime.swing.renderer.BooleanCellRenderer; import jaxx.runtime.swing.renderer.EmptyNumberTableCellRenderer; import jaxx.runtime.swing.renderer.EnumTableCellRenderer; @@ -85,15 +73,17 @@ import org.jdesktop.jxlayer.JXLayer; /** * The runtime swing util class with some nice stuff. - * + * <p/> * Note : Replace previous class jaxx.runtime.swing.Utils in previous versions. - * + * * @author tony * @since 1.2 */ public class SwingUtil extends Util { - /** to use log facility, just put in your code: log.info(\"...\"); */ + /** + * to use log facility, just put in your code: log.info(\"...\"); + */ static private final Log log = LogFactory.getLog(SwingUtil.class); private static Field numReaders; private static Field notifyingListeners; @@ -188,15 +178,42 @@ public class SwingUtil extends Util { } /** + * Fill a list model with some datas, and select after all the given object + * + * @param list the list to fill + * @param data data ot inject in combo + * @param select the object to select in combo after reflling his model + */ + public static void fillList(JList list, Collection<?> data, Object select) { + if (!(list.getModel() instanceof DefaultListModel)) { + throw new IllegalArgumentException("this method need a DefaultComboBoxModel for this model but was " + list.getModel().getClass()); + } + DefaultListModel model = (DefaultListModel) list.getModel(); + // evince the model +// model.removeListDataListener(combo); + model.removeAllElements(); + if (data != null) { + for (Object o : data) { + model.addElement(o); + } + } + // attach the model +// model.addListDataListener(combo); + list.setSelectedValue(select, true); + } + + /** * TODO move this to JAXXComboBox. - * + * <p/> * Fill a combo box model with some datas, and select after all the given object * * @param combo the combo to fill * @param data data ot inject in combo * @param select the object to select in combo after reflling his model * @param firstNull add a first null element + * @deprecated since 1.7.XXX this code is moved to JAXXComboBox */ + @Deprecated public static void fillComboBox(JAXXComboBox combo, Collection<?> data, Object select, boolean firstNull) { List<Item> items = new ArrayList<Item>(); if (firstNull) { @@ -385,10 +402,10 @@ public class SwingUtil extends Util { /** * Centrer un component graphique au center d'un autre component. - * + * <p/> * <b>Note:</b> si le parent est null, alors on ne fait rien. * - * @param parent le component parent + * @param parent le component parent * @param component le component à centrer */ public static void center(Component parent, Component component) { @@ -404,6 +421,7 @@ public class SwingUtil extends Util { /** * Try to load the Nimbus look and feel. * <p/> + * * @throws UnsupportedLookAndFeelException * if nimbus is not applicable * @throws ClassNotFoundException @@ -423,9 +441,8 @@ public class SwingUtil extends Util { * Load the ui.properties file and set in {@link UIManager} colors and icons found. * * @param defaultUIConfig le path vers le fichier de la config d'ui par défaut (doit etre dansle class-path) - * @param extraUIConfig le path vers une surcharge de la config d'ui (doit etre dans le class-path) - * - * @throws IOException if could not load the ui.properties file + * @param extraUIConfig le path vers une surcharge de la config d'ui (doit etre dans le class-path) + * @throws IOException if could not load the ui.properties file */ public static void loadUIConfig(String defaultUIConfig, String extraUIConfig) throws IOException { @@ -471,8 +488,9 @@ public class SwingUtil extends Util { /** * Iterate the components of a {@link JTabbedPane} in natural order. - * + * <p/> * Says using method {@link JTabbedPane#getComponent(int)} + * * @param tabs the * @return the iterator * @since 1.4 @@ -489,15 +507,15 @@ public class SwingUtil extends Util { /** * A simple iterator on a {@link JTabbedPane}. - * + * <p/> * Implements the method {@link #get(int, java.awt.Component)} to obtain * the data required given the component (or index). - * + * <p/> * You can also inverse the order by usin the method {@link #reverse()}. - * + * <p/> * Note: After the use of the method {@link #reverse()} the iterator returns * to the first element. - * + * * @param <O> the type of return elements. * @since 1.4 */ @@ -589,6 +607,7 @@ public class SwingUtil extends Util { /** * Gets the higest visible component in a ancestor hierarchy at * specific x,y coordinates + * * @param parent * @param x * @param y @@ -702,9 +721,9 @@ public class SwingUtil extends Util { /** * Open a link coming from a {@link HyperlinkEvent}. - * + * <p/> * And try to open the link if an url in a browser. - * + * * @param he the event to treate * @since 1.6.0 */ diff --git a/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java b/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java index 48a4e8a..a32b2b2 100644 --- a/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java +++ b/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java @@ -20,12 +20,7 @@ */ package jaxx.runtime.swing; -import javax.swing.AbstractListModel; -import javax.swing.ComboBoxModel; -import javax.swing.DefaultListCellRenderer; -import javax.swing.JComboBox; -import javax.swing.JList; -import javax.swing.ListModel; +import javax.swing.*; import java.awt.Component; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; @@ -221,6 +216,27 @@ public class JAXXComboBox extends JComboBox { setItems(items); } + /** + * Fill the model with some datas, and select after all the given object + * + * @param data data ot inject in combo + * @param select the object to select in combo after reflling his model + * @param firstNull add a first null element + * @deprecated since 1.7.XXX this code is moved to JAXXComboBox + */ + public void fillComboBox(Collection<?> data, Object select, boolean firstNull) { + List<Item> items = new ArrayList<Item>(); + if (firstNull) { + items.add(new Item("null", " ", null, false)); + } + if (data != null) { + for (Object d : data) { + items.add(new Item(d.toString(), d.toString(), d, d.equals(select))); + } + } + this.setItems(items); + } + // this way we can keep it marked protected and still allow code in this file to call it @Override protected void fireItemStateChanged(ItemEvent e) { -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.