[Schmitzm-commits] r2228 - in trunk/schmitzm-core/src/main/java: de/schmitzm/swing javax/swing

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Thu Feb 14 17:22:37 CET 2013


Author: mojays
Date: 2013-02-14 17:22:37 +0100 (Thu, 14 Feb 2013)
New Revision: 2228

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ListMaintainancePanel.java
   trunk/schmitzm-core/src/main/java/javax/swing/ReferencedListModel.java
Log:
Umstellung auf JList mit Java 1.7 feature

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ListMaintainancePanel.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ListMaintainancePanel.java	2013-02-14 16:13:04 UTC (rev 2227)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ListMaintainancePanel.java	2013-02-14 16:22:37 UTC (rev 2228)
@@ -6,14 +6,11 @@
 import java.awt.event.ActionListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 
 import javax.swing.Action;
-import javax.swing.DefaultListModel;
 import javax.swing.JButton;
 import javax.swing.JList;
 import javax.swing.JScrollPane;
@@ -29,8 +26,7 @@
  * @author Martin O.J. Schmitz
  */
 public class ListMaintainancePanel<T> extends JPanel implements ActionListener, ListSelectionListener {
-//  protected JList<T> list; // TODO: Java 1.7
-  protected JList list;
+  protected JList<T> list;
 
   protected Action addAction;
   protected Action removeAction;
@@ -70,8 +66,7 @@
   public ListMaintainancePanel(final boolean addAction, final boolean removeAction, final boolean editAction, final boolean orderable, List<T> data) {
     super( new BorderLayout() );
 
-//    list = new JList<T>( new ListModel<T>() ); // TODO: Java 1.7
-    list = new JList( new ListModel<T>() );
+    list = new JList<T>( new ListModel<T>() );
     list.addListSelectionListener(this);
     // add MouseListener to edit list item on double click
     list.addMouseListener( new MouseAdapter() {
@@ -130,8 +125,7 @@
   /**
    * Returns the {@link JList}.
    */
-//  public JList<T> getList() { // TODO: Java 1.7
-  public JList getList() {
+  public JList<T> getList() {
     return list;
   }
   
@@ -265,8 +259,7 @@
    * Returns the selected list elements as {@link List}.
    */
   public List<T> getSelectedElements() {
-//    List<T> selectedValues = list.getSelectedValuesList(); // TODO: Java 1.7
-    List<T> selectedValues = Arrays.asList((T[])list.getSelectedValues());
+    List<T> selectedValues = list.getSelectedValuesList();
     return selectedValues;
   }
 
@@ -274,8 +267,7 @@
    * Returns the one selected element from list.
    */
   public T getSelectedElement() {
-//    T elem = list.getSelectedValue(); // TODO: Java 1.7
-    T elem = (T)list.getSelectedValue();
+    T elem = list.getSelectedValue();
     return elem;
   }
   
@@ -343,8 +335,8 @@
    * simply removed all selected elements from the list by calling {@link #removeElement(Object)}
    */
   protected void performRemoveElementsAction() {
-    for ( Object elem : getSelectedElements() )
-      removeElement((T)elem);
+    for ( T elem : getSelectedElements() )
+      removeElement(elem);
   }
 
   /**

Modified: trunk/schmitzm-core/src/main/java/javax/swing/ReferencedListModel.java
===================================================================
--- trunk/schmitzm-core/src/main/java/javax/swing/ReferencedListModel.java	2013-02-14 16:13:04 UTC (rev 2227)
+++ trunk/schmitzm-core/src/main/java/javax/swing/ReferencedListModel.java	2013-02-14 16:22:37 UTC (rev 2228)
@@ -44,8 +44,7 @@
  * @author Martin O.J. Schmitz
  *
  */
-//public class ReferencedListModel<E> extends AbstractListModel<E> TODO: Java 1.7
-public class ReferencedListModel<E> extends AbstractListModel 
+public class ReferencedListModel<E> extends AbstractListModel<E>
 {
     /** Hold the list data. */
     protected List<E> delegate;



More information about the Schmitzm-commits mailing list