< prev index next >
src/com/sun/javatest/exec/NewReportDialog.java
Print this page
@@ -110,11 +110,11 @@
/**
* The dialog is done. Notify the observer to keep a snapshot of
* current state.
*/
- public void update(Map l);
+ public void update(Map<String, String> l);
// starting
public void writingReport();
// done
@@ -155,14 +155,14 @@
updateHtmlCheckboxStates();
updateCofCheckboxStates();
}
- Map getLastState() {
- String rd = (String) (dirField.getText());
+ Map<String, String> getLastState() {
+ String rd = dirField.getText();
String filter = filterHandler.getActiveFilter().getName();
- Map lastState = new HashMap();
+ Map<String, String> lastState = new HashMap<>();
if (rd != null && rd.length() > 0)
lastState.put(REPORT_DIR, rd);
if (filter != null && filter.length() > 0)
@@ -178,11 +178,11 @@
void removeObserver(Observer o) {
obs = (Observer[])DynamicArray.remove(obs, o);
}
// Notify the observers that a change has been made.
- private void notifyUpdate(Map s) {
+ private void notifyUpdate(Map<String, String> s) {
for (Observer o : obs) {
o.update(s);
}
}
@@ -297,11 +297,11 @@
tabs = uif.createTabbedPane("nrd.tabs", panes);
tabs.setTabPlacement(SwingConstants.TOP);
tabs.setBorder(BorderFactory.createEmptyBorder());
- listModel = new DefaultListModel();
+ listModel = new DefaultListModel<>();
// populate list and card panel
final CardLayout cards = new CardLayout();
final JPanel p = uif.createPanel("nrd.typecards", cards, false);
@@ -379,18 +379,18 @@
int itemCount = listModel.size();
if (itemCount > 9) itemCount = 9;
for (int i = 1; i <= itemCount; ++i) {
list.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(i + '0', InputEvent.ALT_DOWN_MASK), ACTION_MAP_KEY);
- JCheckBox box = ((JCheckBox)listModel.getElementAt(i - 1));
+ JCheckBox box = listModel.getElementAt(i - 1);
box.setMnemonic(i + '0');
box.setText(Character.toString((char)('0' + i)) + " " + box.getText());
}
if (listModel.size() == 10){
list.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('0', InputEvent.ALT_DOWN_MASK), ACTION_MAP_KEY);
- JCheckBox box = ((JCheckBox)listModel.getElementAt(9));
+ JCheckBox box = listModel.getElementAt(9);
box.setMnemonic('0');
box.setText("0 " + box.getText());
}
//-----------------------------------------------------------------
@@ -779,11 +779,11 @@
if (customReports == null || customReports.length == 0) {
customReports = null;
return 0;
}
- customBoxes = new HashMap();
+ customBoxes = new HashMap<>();
for (int i = 0; i < customReports.length; i++) {
JCheckBox cb = new JCheckBox(customReports[i].getName());
cb.setName(customReports[i].getReportId());
listModel.addElement(cb);
@@ -844,11 +844,11 @@
if(f.equals(new File(reportDir, Report.INDEX_FILE_NAME))) {
reportBrowser.show(f);
}
else {
String[] names = Report.getHtmlReportFilenames();
- ArrayList possible = new ArrayList();
+ ArrayList<File> possible = new ArrayList<>();
for (int i = 0; i < names.length; i++) {
File rpt = new File(reportDir, names[i]);
if (rpt.exists() && rpt.canRead())
possible.add(rpt);
@@ -897,11 +897,11 @@
}
}
private ArrayList<CustomReport> getActiveCustomReports() {
- ArrayList customReps = new ArrayList();
+ ArrayList<CustomReport> customReps = new ArrayList<>();
if (customBoxes != null && customBoxes.size() > 0) {
Iterator it = customBoxes.keySet().iterator();
while (it.hasNext()) {
JCheckBox box = (JCheckBox)(it.next());
if (box.isSelected()) {
@@ -1100,11 +1100,11 @@
while (it.hasNext()) {
CustomReport cr = (CustomReport) it.next();
String error = cr.validateOptions();
if (error != null) {
for (int i = 0; i < listModel.getSize(); i++ ) {
- JCheckBox cb = (JCheckBox)listModel.elementAt(i);
+ JCheckBox cb = listModel.elementAt(i);
if (cb.getName().equals(cr.getReportId())) {
list.setSelectedIndex(i);
}
}
uif.showError("nrd.optionsErr", new Object[] {error} );
@@ -1503,23 +1503,23 @@
if ("enabled".equals(evt.getPropertyName())) {
boolean oldV = ((Boolean) evt.getOldValue()).booleanValue();
boolean newV = ((Boolean) evt.getNewValue()).booleanValue();
if (oldV && !newV) {
// disable
- Iterator chIt = collectChildren(theContainer, new ArrayList()).iterator();
- enabledComp = new HashSet();
+ Iterator chIt = collectChildren(theContainer, new ArrayList<Component>()).iterator();
+ enabledComp = new HashSet<>();
while (chIt.hasNext()) {
Component c = (Component) chIt.next();
if (c.isEnabled()) {
enabledComp.add(c);
c.setEnabled(false);
}
}
} else if (!oldV && newV && enabledComp != null) {
// enable
- Iterator chIt = collectChildren(theContainer, new ArrayList()).iterator();
+ Iterator chIt = collectChildren(theContainer, new ArrayList<Component>()).iterator();
while (chIt.hasNext()) {
Component c = (Component) chIt.next();
if (enabledComp.contains(c)) {
c.setEnabled(true);
}
@@ -1529,11 +1529,11 @@
}
/**
* Recursively gathers all children components
*/
- private Collection collectChildren(Container comp, Collection c) {
+ private Collection collectChildren(Container comp, Collection<Component> c) {
Component [] ch = comp.getComponents();
for(int i = 0; i < ch.length; i++) {
c.add(ch[i]);
if (ch[i] instanceof Container) {
collectChildren((Container) ch[i], c);
@@ -1541,22 +1541,22 @@
}
return c;
}
private Container theContainer;
- private HashSet enabledComp;
+ private HashSet<Component> enabledComp;
}
- private class CheckBoxListCellRenderer implements ListCellRenderer {
+ private class CheckBoxListCellRenderer implements ListCellRenderer<JComponent> {
public Component getListCellRendererComponent(
- JList list,
- Object value,
+ JList<? extends JComponent> list,
+ JComponent value,
int index,
boolean isSelected,
boolean cellHasFocus) {
// assert: value is a JCheckBox
- JComponent comp = (JComponent)value;
+ JComponent comp = value;
if (isSelected) {
comp.setOpaque(true);
comp.setBackground(list.getSelectionBackground());
comp.setForeground(list.getSelectionForeground());
}
@@ -1572,15 +1572,15 @@
private Observer[] obs = new Observer[0];
private ExecModel model;
private ReportDirChooser reportDirChooser;
- private DefaultListModel listModel;
- private JList list;
+ private DefaultListModel<JCheckBox> listModel;
+ private JList<? extends JComponent> list;
private JTextArea infoArea;
private CustomReport[] customReports;
- private HashMap customBoxes;
+ private HashMap<JCheckBox, CustomReport> customBoxes;
private JComponent[] panes;
private JCheckBox cbHtml;
private JCheckBox cbPlain;
private JCheckBox cbXml;
@@ -1609,13 +1609,13 @@
private JCheckBox cbKflMissing;
private JCheckBox cbBak;
private JTextField numBak;
- private ArrayList htmlGroup = new ArrayList();
- private ArrayList configGroup = new ArrayList();
- private ArrayList kflGroup = new ArrayList();
+ private ArrayList<JCheckBox> htmlGroup = new ArrayList<>();
+ private ArrayList<JCheckBox> configGroup = new ArrayList<>();
+ private ArrayList<JCheckBox> kflGroup = new ArrayList<>();
private File reportDir;
private JButton browseBtn;
private JButton okBtn;
private JButton cancelBtn;
< prev index next >