< prev index next >

src/com/sun/interview/wizard/PathPanel.java

Print this page
rev 145 : 7902237: Fixing raw use of parameterized class
Reviewed-by: jjg

@@ -166,11 +166,11 @@
     private void initGUI() {
         setName("path");
         setFocusable(false);
         setLayout(new BorderLayout());
         pathList = new PathList();
-        list = new JList(pathList);
+        list = new JList<>(pathList);
         setInfo(list, "path.list", true);
         list.setCellRenderer(pathList);
         KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
         list.registerKeyboardAction(pathList, enterKey, JComponent.WHEN_FOCUSED);
         list.addListSelectionListener(pathList);

@@ -242,13 +242,13 @@
     private static final I18NResourceBundle i18n = I18NResourceBundle.getDefaultBundle();
     private static Color INVALID_VALUE_COLOR = i18n.getErrorColor();
     private static final int DOTS_PER_INCH = Toolkit.getDefaultToolkit().getScreenResolution();
 
     private class PathList
-                extends AbstractListModel
+                extends AbstractListModel<Object>
                 implements ActionListener, AncestorListener,
-                           ListCellRenderer, ListSelectionListener,
+                           ListCellRenderer<Object>, ListSelectionListener,
                            MouseListener,
                            Interview.Observer
     {
         //----- navigation support for WizPane -----------------------
 

@@ -283,11 +283,11 @@
 
         boolean isQuestionVisible(Question q) {
             for (Object e : currEntries) {
                 if (e instanceof Question && e == q)
                     return true;
-                else if (e instanceof List && ((List) e).contains(q))
+                else if (e instanceof List && ((List<?>) e).contains(q))
                     return false;
             }
             return false;
         }
 

@@ -304,11 +304,11 @@
                         autoOpened = autoOpenSet.contains(qe);
                     }
                     else if (qe == q)
                         return autoOpened;
                 }
-                else if (e instanceof List && ((List) e).contains(q))
+                else if (e instanceof List && ((List<?>) e).contains(q))
                     return false;
             }
             return false;
         }
 

@@ -406,11 +406,11 @@
             public Dimension getMaximumSize() {
                 return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
             }
         };
 
-        public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
+        public Component getListCellRendererComponent(JList<?> list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
             if (o instanceof Question) {
                 Question q = (Question)o;
                 Font f;
                 String s;
                 Color c;

@@ -506,11 +506,11 @@
         //----- from ActionListener -----------
 
         // invoked by keyboard "enter"
         public void actionPerformed(ActionEvent e) {
             //System.err.println("PP.actionPerformed");
-            JList list = (JList)(e.getSource());
+            JList<?> list = (JList<?>)(e.getSource());
             Object o = list.getSelectedValue();
             if (o != null && o instanceof Question) {
                 Question q = (Question)o;
                 if (q == interview.getCurrentQuestion())
                     return;

@@ -530,11 +530,11 @@
 
         //----- from ListSelectionListener -----------
 
         // invoked by mouse selection (or by list.setSelectedXXX ??)
         public void valueChanged(ListSelectionEvent e) {
-            JList list = (JList) (e.getSource());
+            JList<?> list = (JList<?>) (e.getSource());
             Object o = list.getSelectedValue();
             if (o == null)
                 return;
 
             // make sure the interview's current question is synchronized with

@@ -552,11 +552,11 @@
                 catch (Interview.Fault ex) {
                     // ignore, should never happen; FLW
                 }
             }
             else if (o instanceof List) {
-                List l = (List) o;
+                List<?> l = (List<?>) o;
                 if (l.contains(interview.getCurrentQuestion()))
                     return;
 
                 questionPanel.saveCurrentResponse();
 

@@ -604,11 +604,11 @@
             if (markersEnabled && e.isPopupTrigger() && isOverSelection(e))
                 showPopupMenu(e);
         }
 
         private boolean isOverSelection(MouseEvent e) {
-            JList l = (JList) (e.getComponent());
+            JList<?> l = (JList<?>) (e.getComponent());
             Rectangle r = l.getCellBounds(currIndex, currIndex);
             return (r.contains(e.getX(), e.getY()));
         }
 
         private void showPopupMenu(MouseEvent e) {

@@ -657,11 +657,11 @@
         public void currentQuestionChanged(Question q) {
             int prevIndex = currIndex;
             currQuestion = q;
             for (int i = 0; i < currEntries.length; i++) {
                 Object o = currEntries[i];
-                if (o == q || (o instanceof List && ((List) o).contains(q))) {
+                if (o == q || (o instanceof List && ((List<?>) o).contains(q))) {
                     currIndex = i;
                     break;
                 }
             }
             fireContentsChanged(this, prevIndex, currIndex);

@@ -752,11 +752,11 @@
 
             currQuestion = newCurrQuestion;
             for (int i = 0; i < currEntries.length; i++) {
                 Object o = currEntries[i];
                 if (o == currQuestion
-                    || (o instanceof List && ((List) o).contains(currQuestion))) {
+                    || (o instanceof List && ((List<?>) o).contains(currQuestion))) {
                     currIndex = i;
                     break;
                 }
             }
 

@@ -804,11 +804,11 @@
                 }
             }
 
             // auto-expand the final section if it doesn't end in FinalQuestion
             if (!(last instanceof FinalQuestion) && v.lastElement() instanceof List) {
-                List l = (List) (v.lastElement());
+                List<?> l = (List<?>) (v.lastElement());
                 v.setSize(v.size() - 1);
                 v.addAll(l);
             }
 
             if (needMore)
< prev index next >