< 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,176 ****
private void initGUI() {
setName("path");
setFocusable(false);
setLayout(new BorderLayout());
pathList = new 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);
--- 166,176 ----
private void initGUI() {
setName("path");
setFocusable(false);
setLayout(new BorderLayout());
pathList = new 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,254 ****
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
implements ActionListener, AncestorListener,
! ListCellRenderer, ListSelectionListener,
MouseListener,
Interview.Observer
{
//----- navigation support for WizPane -----------------------
--- 242,254 ----
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<Object>
implements ActionListener, AncestorListener,
! ListCellRenderer<Object>, ListSelectionListener,
MouseListener,
Interview.Observer
{
//----- navigation support for WizPane -----------------------
*** 283,293 ****
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))
return false;
}
return false;
}
--- 283,293 ----
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))
return false;
}
return false;
}
*** 304,314 ****
autoOpened = autoOpenSet.contains(qe);
}
else if (qe == q)
return autoOpened;
}
! else if (e instanceof List && ((List) e).contains(q))
return false;
}
return false;
}
--- 304,314 ----
autoOpened = autoOpenSet.contains(qe);
}
else if (qe == q)
return autoOpened;
}
! else if (e instanceof List && ((List<?>) e).contains(q))
return false;
}
return false;
}
*** 406,416 ****
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) {
if (o instanceof Question) {
Question q = (Question)o;
Font f;
String s;
Color c;
--- 406,416 ----
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) {
if (o instanceof Question) {
Question q = (Question)o;
Font f;
String s;
Color c;
*** 506,516 ****
//----- from ActionListener -----------
// invoked by keyboard "enter"
public void actionPerformed(ActionEvent e) {
//System.err.println("PP.actionPerformed");
! JList list = (JList)(e.getSource());
Object o = list.getSelectedValue();
if (o != null && o instanceof Question) {
Question q = (Question)o;
if (q == interview.getCurrentQuestion())
return;
--- 506,516 ----
//----- from ActionListener -----------
// invoked by keyboard "enter"
public void actionPerformed(ActionEvent e) {
//System.err.println("PP.actionPerformed");
! 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,540 ****
//----- from ListSelectionListener -----------
// invoked by mouse selection (or by list.setSelectedXXX ??)
public void valueChanged(ListSelectionEvent e) {
! JList list = (JList) (e.getSource());
Object o = list.getSelectedValue();
if (o == null)
return;
// make sure the interview's current question is synchronized with
--- 530,540 ----
//----- from ListSelectionListener -----------
// invoked by mouse selection (or by list.setSelectedXXX ??)
public void valueChanged(ListSelectionEvent e) {
! JList<?> list = (JList<?>) (e.getSource());
Object o = list.getSelectedValue();
if (o == null)
return;
// make sure the interview's current question is synchronized with
*** 552,562 ****
catch (Interview.Fault ex) {
// ignore, should never happen; FLW
}
}
else if (o instanceof List) {
! List l = (List) o;
if (l.contains(interview.getCurrentQuestion()))
return;
questionPanel.saveCurrentResponse();
--- 552,562 ----
catch (Interview.Fault ex) {
// ignore, should never happen; FLW
}
}
else if (o instanceof List) {
! List<?> l = (List<?>) o;
if (l.contains(interview.getCurrentQuestion()))
return;
questionPanel.saveCurrentResponse();
*** 604,614 ****
if (markersEnabled && e.isPopupTrigger() && isOverSelection(e))
showPopupMenu(e);
}
private boolean isOverSelection(MouseEvent e) {
! JList l = (JList) (e.getComponent());
Rectangle r = l.getCellBounds(currIndex, currIndex);
return (r.contains(e.getX(), e.getY()));
}
private void showPopupMenu(MouseEvent e) {
--- 604,614 ----
if (markersEnabled && e.isPopupTrigger() && isOverSelection(e))
showPopupMenu(e);
}
private boolean isOverSelection(MouseEvent e) {
! JList<?> l = (JList<?>) (e.getComponent());
Rectangle r = l.getCellBounds(currIndex, currIndex);
return (r.contains(e.getX(), e.getY()));
}
private void showPopupMenu(MouseEvent e) {
*** 657,667 ****
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))) {
currIndex = i;
break;
}
}
fireContentsChanged(this, prevIndex, currIndex);
--- 657,667 ----
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))) {
currIndex = i;
break;
}
}
fireContentsChanged(this, prevIndex, currIndex);
*** 752,762 ****
currQuestion = newCurrQuestion;
for (int i = 0; i < currEntries.length; i++) {
Object o = currEntries[i];
if (o == currQuestion
! || (o instanceof List && ((List) o).contains(currQuestion))) {
currIndex = i;
break;
}
}
--- 752,762 ----
currQuestion = newCurrQuestion;
for (int i = 0; i < currEntries.length; i++) {
Object o = currEntries[i];
if (o == currQuestion
! || (o instanceof List && ((List<?>) o).contains(currQuestion))) {
currIndex = i;
break;
}
}
*** 804,814 ****
}
}
// 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());
v.setSize(v.size() - 1);
v.addAll(l);
}
if (needMore)
--- 804,814 ----
}
}
// 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());
v.setSize(v.size() - 1);
v.addAll(l);
}
if (needMore)
< prev index next >