Skip to content

Commit 43a72be

Browse files
author
rcartwright
committed
This revision generifies the code base with respect to the Java 7 libraries. Compilation
with the Java 7 compiler no longer generates any warnings. The following files were modified: M src/edu/rice/cs/util/text/SwingDocument.java M src/edu/rice/cs/drjava/model/JarJDKToolsLibrary.java M src/edu/rice/cs/drjava/ui/AutoCompletePopup.java M src/edu/rice/cs/drjava/ui/predictive/PredictiveInputFrame.java M src/edu/rice/cs/drjava/ui/NewVersionPopup.java M src/edu/rice/cs/drjava/ui/config/ForcedChoiceOptionComponent.java M src/edu/rice/cs/drjava/ui/CompilerErrorPanel.java M src/edu/rice/cs/drjava/ui/EditExternalDialog.java M src/edu/rice/cs/drjava/ui/AboutDialog.java M src/edu/rice/cs/drjava/ui/AbortablePanel.java M src/edu/rice/cs/drjava/ui/AbstractDJPane.java M src/edu/rice/cs/drjava/ui/ClipboardHistoryFrame.java M src/edu/rice/cs/drjava/ui/RegionsTreePanel.java M src/edu/rice/cs/drjava/ui/DefinitionsPane.java M src/edu/rice/cs/drjava/ui/RegionsListPanel.java M src/edu/rice/cs/drjava/ui/FindResultsPanel.java git-svn-id: file:///tmp/test-svn/trunk@5548 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent 37449cb commit 43a72be

16 files changed

+173
-146
lines changed

drjava/src/edu/rice/cs/drjava/model/JarJDKToolsLibrary.java

Lines changed: 102 additions & 73 deletions
Large diffs are not rendered by default.

drjava/src/edu/rice/cs/drjava/ui/AbortablePanel.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@
4848
* @version $Id$
4949
*/
5050
public abstract class AbortablePanel extends TabbedPanel {
51-
protected JPanel _leftPane;
52-
protected JScrollPane _scrollPane;
51+
protected volatile JPanel _leftPane;
52+
protected volatile JScrollPane _scrollPane;
5353

5454
protected final SingleDisplayModel _model;
5555
protected final MainFrame _frame;
5656

57-
protected String _title;
58-
protected JPanel _buttonPanel;
57+
protected volatile String _title;
58+
protected volatile JPanel _buttonPanel;
5959

60-
protected JButton _abortButton;
60+
protected volatile JButton _abortButton;
6161

6262
/** Constructs a new abortable panel.
6363
* This is swing view class and hence should only be accessed from the event thread.

drjava/src/edu/rice/cs/drjava/ui/AboutDialog.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ public class AboutDialog extends JDialog implements ActionListener {
7070
private final JButton _okButton = new JButton("OK");
7171

7272
/** the button that copies the system properties to the clipboard */
73-
private JButton _copyButton;
73+
private volatile JButton _copyButton;
7474

7575
/** the table with the System Properties information */
76-
private JTable _propertiesTable;
76+
private volatile JTable _propertiesTable;
7777

7878
/** index the System Properties tab, one of the tabs in _tabs */
79-
private int _propertiesTabIndex;
79+
private volatile int _propertiesTabIndex;
8080

8181
/** the pane with tabs to select */
8282
private final JTabbedPane _tabs = new JTabbedPane();
@@ -358,8 +358,8 @@ public void actionPerformed(ActionEvent e) {
358358
"SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n" +
359359
"This software is Open Source Initiative approved Open Source Software.\n" +
360360
"Open Source Initative Approved is a trademark of the Open Source Initiative.\n";
361-
private static String LICENSE;
362-
private static boolean initLicense = false;
361+
private static volatile String LICENSE;
362+
private static volatile boolean initLicense = false;
363363
public static final String DYADE_LICENSE =
364364
"DynamicJava - Copyright \u00a9 1999 Dyade\n\nPermission is hereby granted," +
365365
" free of charge, to any person obtaining a copy of this software and associated" +

drjava/src/edu/rice/cs/drjava/ui/AbstractDJPane.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,23 @@
5656
import edu.rice.cs.drjava.DrJavaRoot;
5757

5858
/** This pane class for a SwingDocument. */
59-
public abstract class AbstractDJPane extends JTextPane
60-
implements OptionConstants, DropTargetListener {
59+
public abstract class AbstractDJPane extends JTextPane implements OptionConstants, DropTargetListener {
6160

6261
// ------------ FIELDS -----------
6362

6463
/* The amount of the visible pane to scroll on a single click (Swing's default is .1) */
6564
private static final double SCROLL_UNIT = .05;
66-
67-
65+
6866
/** Paren/brace/bracket matching highlight color. */
69-
static ReverseHighlighter.DrJavaHighlightPainter MATCH_PAINTER;
67+
static volatile ReverseHighlighter.DrJavaHighlightPainter MATCH_PAINTER;
7068

7169
static {
7270
Color highColor = DrJava.getConfig().getSetting(DEFINITIONS_MATCH_COLOR);
7371
MATCH_PAINTER = new ReverseHighlighter.DrJavaHighlightPainter(highColor);
7472
}
7573

7674
/** Highlight painter for selected errors in the defs doc. */
77-
static ReverseHighlighter.DrJavaHighlightPainter ERROR_PAINTER =
75+
static volatile ReverseHighlighter.DrJavaHighlightPainter ERROR_PAINTER =
7876
new ReverseHighlighter.DrJavaHighlightPainter(DrJava.getConfig().getSetting(COMPILER_ERROR_COLOR));
7977

8078
private static final int ALT_CTRL_META_MASK = Event.ALT_MASK | Event.CTRL_MASK | Event.META_MASK;
@@ -260,7 +258,7 @@ public void indent(final Indenter.IndentReason reason) {
260258
public abstract DJDocument getDJDocument();
261259

262260
/** Drag and drop target. */
263-
DropTarget dropTarget = new DropTarget(this, this);
261+
volatile DropTarget dropTarget = new DropTarget(this, this);
264262

265263
/** User dragged something into the component. */
266264
public void dragEnter(DropTargetDragEvent dropTargetDragEvent) {

drjava/src/edu/rice/cs/drjava/ui/AutoCompletePopup.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,22 @@
8080
*/
8181
public class AutoCompletePopup {
8282
/** Main frame. */
83-
final protected MainFrame _mainFrame;
83+
protected final MainFrame _mainFrame;
8484

8585
/** Checkbox that controls whether Java API classes are included. */
8686
JCheckBox _completeJavaAPICheckbox = new JCheckBox("Java API");
8787

8888
/** Frame state. */
89-
protected FrameState _lastState = null;
89+
protected volatile FrameState _lastState = null;
9090

9191
/** Complete set of entries. */
92-
final protected Set<AutoCompletePopupEntry> _allEntries;
92+
protected final Set<AutoCompletePopupEntry> _allEntries;
9393

9494
/** Set of the document entries. */
95-
final protected Set<AutoCompletePopupEntry> _docEntries;
95+
protected final Set<AutoCompletePopupEntry> _docEntries;
9696

9797
/** Set of all the Java API classes. */
98-
final protected Set<AutoCompletePopupEntry> _apiEntries;
98+
protected final Set<AutoCompletePopupEntry> _apiEntries;
9999

100100
/** Constructor for an auto-complete popup that uses the MainFrame for information.
101101
* @param mf main frame of DrJava */
@@ -306,9 +306,7 @@ public void run() {
306306
/** Sets state of the frame, i.e. the location and dimension of the frame for the next use.
307307
* @param ds State to update to, or {@code null} to reset
308308
*/
309-
public void setFrameState(FrameState ds) {
310-
_lastState = ds;
311-
}
309+
public void setFrameState(FrameState ds) { _lastState = ds; }
312310

313311
/** Sets state of the frame, i.e. the location and dimension of the frame for the next use.
314312
* @param s State to update to, or {@code null} to reset

drjava/src/edu/rice/cs/drjava/ui/ClipboardHistoryFrame.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public String toString() {
116116
private JButton _cancelButton;
117117

118118
/** List with history. */
119-
private JList _historyList;
119+
private JList<HistoryString> _historyList;
120120

121121
/** Text area for that previews the history content. */
122122
private JTextArea _previewArea;
@@ -213,7 +213,7 @@ public void actionPerformed(ActionEvent e) {
213213
}
214214
});
215215

216-
_historyList = new JList();
216+
_historyList = new JList<HistoryString>();
217217
_historyList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
218218
_historyList.addListSelectionListener(new ListSelectionListener() {
219219
public void valueChanged(ListSelectionEvent e) {
@@ -223,7 +223,7 @@ public void valueChanged(ListSelectionEvent e) {
223223
_historyList.setFont(DrJava.getConfig().getSetting(OptionConstants.FONT_MAIN));
224224
_historyList.setCellRenderer(new DefaultListCellRenderer() {
225225
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
226-
Component c = super.getListCellRendererComponent(list,value,index,isSelected,cellHasFocus);
226+
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
227227
c.setForeground(DrJava.getConfig().getSetting(OptionConstants.DEFINITIONS_NORMAL_COLOR));
228228
return c;
229229
}
@@ -340,8 +340,8 @@ public void setVisible(boolean vis) {
340340
/** Update the displays based on the model. */
341341
private void updateView() {
342342
List<String> strs = _chm.getStrings();
343-
ListItem[] arr = new ListItem[strs.size()];
344-
for(int i = 0; i < strs.size(); ++i) arr[strs.size()-i-1] = new ListItem(strs.get(i));
343+
HistoryString[] arr = new HistoryString[strs.size()];
344+
for(int i = 0; i < strs.size(); ++i) arr[strs.size()-i-1] = new HistoryString(strs.get(i));
345345
_historyList.setListData(arr);
346346
if (_historyList.getModel().getSize() > 0) {
347347
_historyList.setSelectedIndex(0);
@@ -361,7 +361,7 @@ private void updatePreview() {
361361
if (_historyList.getModel().getSize() > 0) {
362362
int index = _historyList.getSelectedIndex();
363363
if (index != -1) {
364-
text = ((ListItem)_historyList.getModel().getElementAt(_historyList.getSelectedIndex())).getFull();
364+
text = _historyList.getModel().getElementAt(_historyList.getSelectedIndex()).getFull();
365365
}
366366
}
367367

@@ -375,7 +375,7 @@ private void okButtonPressed() {
375375
setVisible(false);
376376
if (_historyList.getModel().getSize() > 0) {
377377
_buttonPressed = JOptionPane.OK_OPTION;
378-
String s = ((ListItem)_historyList.getModel().getElementAt(_historyList.getSelectedIndex())).getFull();
378+
String s = _historyList.getModel().getElementAt(_historyList.getSelectedIndex()).getFull();
379379
_chm.put(s);
380380
_okAction.value(s);
381381
}
@@ -395,9 +395,9 @@ private void cancelButtonPressed() {
395395
}
396396

397397
/** Keeps a full string, but toString is only the first line. */
398-
private static class ListItem {
398+
private static class HistoryString {
399399
private String full, display;
400-
public ListItem(String s) {
400+
public HistoryString(String s) {
401401
full = s;
402402
int index1 = s.indexOf('\n');
403403
if (index1 == -1) index1 = s.length();

drjava/src/edu/rice/cs/drjava/ui/CompilerErrorPanel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class CompilerErrorPanel extends ErrorPanel {
6666
/** Whether a compile has occurred since the last compiler change. */
6767
private volatile boolean _compileHasOccurred;
6868
private volatile CompilerErrorListPane _errorListPane;
69-
private final JComboBox _compilerChoiceBox;
69+
private final JComboBox<CompilerInterface> _compilerChoiceBox;
7070

7171
/** The list of files from the last compilation unit that were not compiled because they were not source files. */
7272
private volatile File[] _excludedFiles = new File[0];
@@ -92,7 +92,7 @@ public CompilerErrorPanel(SingleDisplayModel model, MainFrame frame) {
9292
// to listen on the active compiler.
9393
final CompilerModel compilerModel = getModel().getCompilerModel();
9494
Iterable<CompilerInterface> iter = getModel().getCompilerModel().getAvailableCompilers();
95-
_compilerChoiceBox = new JComboBox(IterUtil.toArray(iter, CompilerInterface.class));
95+
_compilerChoiceBox = new JComboBox<CompilerInterface>(IterUtil.toArray(iter, CompilerInterface.class));
9696
_compilerChoiceBox.setEditable(false);
9797
_compilerChoiceBox.setSelectedItem(compilerModel.getActiveCompiler());
9898
_compilerChoiceBox.addItemListener(new ItemListener() {

drjava/src/edu/rice/cs/drjava/ui/DefinitionsPane.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public class DefinitionsPane extends AbstractDJPane implements Finalizable<Defin
8484
private volatile RedoAction _redoAction;
8585

8686
private volatile boolean testVariable; //For Tests ONLY
87-
// private Document _defdoc;
87+
// private volatile Document _defdoc;
8888

8989
/** Flag used to determine if the user has already been warned about debugging when the document within
9090
* this defpane has been modified since its last save.
@@ -100,7 +100,7 @@ public class DefinitionsPane extends AbstractDJPane implements Finalizable<Defin
100100
private volatile boolean _isCtrlShiftBracketDown = false;
101101

102102
// /** Used by the centering source mechanism to ensure paints */
103-
// private boolean _updatePending = false;
103+
// private volatile boolean _updatePending = false;
104104

105105
/** Whether to draw text as antialiased. */
106106
private volatile boolean _antiAliasText = false;
@@ -270,7 +270,7 @@ public void optionChanged(OptionEvent<Color> oce) {
270270

271271
/** The OptionListener for FIND_RESULTS_COLOR. */
272272
private static class FindResultsColorOptionListener implements OptionListener<Color> {
273-
private int _index;
273+
private volatile int _index;
274274
public FindResultsColorOptionListener(int i) { _index = i; }
275275
public void optionChanged(OptionEvent<Color> oce) {
276276
synchronized(FIND_RESULTS_PAINTERS) {

drjava/src/edu/rice/cs/drjava/ui/EditExternalDialog.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public String toString() {
120120
/** Ok button. */
121121
private JButton _okButton;
122122
/** List of commands. */
123-
private JList _list;
123+
private JList<String> _list;
124124
/** Completion monitor to simulate modal behavior. */
125125
protected CompletionMonitor _editExternalDialogMonitor = new CompletionMonitor();
126126

@@ -268,7 +268,7 @@ public void actionPerformed(ActionEvent e) {
268268
bottom.add(Box.createHorizontalGlue());
269269
mainPanel.add(bottom, BorderLayout.SOUTH);
270270

271-
_list = new JList();
271+
_list = new JList<String>();
272272
_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
273273
_list.addListSelectionListener(new ListSelectionListener() {
274274
public void valueChanged(ListSelectionEvent e) {

drjava/src/edu/rice/cs/drjava/ui/FindResultsPanel.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class FindResultsPanel extends RegionsTreePanel<MovingDocumentRegion> {
8282
protected JButton _goToButton;
8383
protected JButton _bookmarkButton;
8484
protected JButton _removeButton;
85-
protected JComboBox _colorBox;
85+
protected JComboBox<Color> _colorBox;
8686
protected int _lastIndex;
8787

8888
/** Saved option listeners kept in this field so they can be removed for garbage collection */
@@ -151,7 +151,7 @@ public void regionChanged(MovingDocumentRegion r) {
151151
}
152152
}
153153

154-
class ColorComboRenderer extends JPanel implements ListCellRenderer {
154+
class ColorComboRenderer extends JPanel implements ListCellRenderer<Color> {
155155
private Color _color = DrJava.getConfig().getSetting(OptionConstants.FIND_RESULTS_COLORS[_colorBox.getSelectedIndex()]);
156156
private DefaultListCellRenderer _defaultRenderer = new DefaultListCellRenderer();
157157
private final Dimension _size = new Dimension(0, 20);
@@ -164,14 +164,14 @@ public ColorComboRenderer() {
164164
setBorder(_compoundBorder);
165165
}
166166

167-
public Component getListCellRendererComponent(JList list, Object value, int row, boolean sel, boolean hasFocus) {
167+
public Component getListCellRendererComponent(JList<? extends Color> list, Color color, int row, boolean sel, boolean hasFocus) {
168168
JComponent renderer;
169-
if (value instanceof Color) {
170-
_color = (Color) value;
169+
if (color != null) {
170+
_color = color;
171171
renderer = this;
172172
}
173173
else {
174-
JLabel l = (JLabel) _defaultRenderer.getListCellRendererComponent(list, value, row, sel, hasFocus);
174+
JLabel l = (JLabel) _defaultRenderer.getListCellRendererComponent(list, color, row, sel, hasFocus);
175175
l.setHorizontalAlignment(JLabel.CENTER);
176176
renderer = l;
177177
}
@@ -225,11 +225,11 @@ protected JComponent[] makeButtons() {
225225
}
226226
_lastIndex = smallestIndex;
227227
++DefinitionsPane.FIND_RESULTS_PAINTERS_USAGE[_lastIndex];
228-
_colorBox = new JComboBox();
228+
_colorBox = new JComboBox<Color>();
229229
for (int i = 0; i < OptionConstants.FIND_RESULTS_COLORS.length; ++i) {
230230
_colorBox.addItem(DrJava.getConfig().getSetting(OptionConstants.FIND_RESULTS_COLORS[i]));
231231
}
232-
_colorBox.addItem("None");
232+
_colorBox.addItem(null); // formerly "None"
233233
_colorBox.setRenderer(new ColorComboRenderer());
234234
_colorBox.addActionListener(new ActionListener() {
235235
public void actionPerformed(ActionEvent e) {

0 commit comments

Comments
 (0)