1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
From bd03f07b5bcc5feb558caec4fbfd556947630fb9 Mon Sep 17 00:00:00 2001
From: Yuan Liao <liaoyuan@gmail.com>
Date: Sat, 19 Feb 2022 08:25:21 -0800
Subject: [PATCH] Update uses of javax.swing API members for Java 9+
These changes are backward compatible with Java 8.
Signed-off-by: Yuan Liao <liaoyuan@gmail.com>
---
.../sf/jabref/FindUnlinkedFilesDialog.java | 9 ++++-----
.../net/sf/jabref/collab/EntryChange.java | 6 +++---
.../sf/jabref/groups/AddToGroupAction.java | 5 +++--
.../net/sf/jabref/groups/GroupSelector.java | 9 +++++----
.../net/sf/jabref/groups/GroupTreeNode.java | 20 ++++++++-----------
src/java/net/sf/jabref/groups/GroupsTree.java | 17 ++++++++--------
.../jabref/imports/AppendDatabaseAction.java | 5 +++--
.../sf/jabref/sql/exporter/DBExporter.java | 9 +++++----
8 files changed, 40 insertions(+), 40 deletions(-)
diff --git a/src/java/net/sf/jabref/FindUnlinkedFilesDialog.java b/src/java/net/sf/jabref/FindUnlinkedFilesDialog.java
index 4bcbd73..5f7473d 100644
--- a/src/java/net/sf/jabref/FindUnlinkedFilesDialog.java
+++ b/src/java/net/sf/jabref/FindUnlinkedFilesDialog.java
@@ -669,13 +669,12 @@ public class FindUnlinkedFilesDialog extends JDialog {
* The root node representing a tree structure.
* @return A list of files of all checked leaf nodes.
*/
- @SuppressWarnings("unchecked")
private List<File> getFileListFromNode(CheckableTreeNode node) {
List<File> filesList = new ArrayList<File>();
- Enumeration<CheckableTreeNode> childs = node.depthFirstEnumeration();
+ Enumeration<TreeNode> childs = node.depthFirstEnumeration();
ArrayList<CheckableTreeNode> nodesToRemove = new ArrayList<FindUnlinkedFilesDialog.CheckableTreeNode>();
while (childs.hasMoreElements()) {
- CheckableTreeNode child = childs.nextElement();
+ CheckableTreeNode child = (CheckableTreeNode) childs.nextElement();
if (child.isLeaf() && child.getSelected()) {
File nodeFile = ((FileNodeWrapper) child.getUserObject()).file;
if (nodeFile != null && nodeFile.isFile()) {
@@ -1105,9 +1104,9 @@ public class FindUnlinkedFilesDialog extends JDialog {
@SuppressWarnings("unchecked")
public void setSelected(boolean bSelected) {
isSelected = bSelected;
- Enumeration<CheckableTreeNode> children = this.children();
+ Enumeration<TreeNode> children = this.children();
while (children.hasMoreElements()) {
- CheckableTreeNode child = children.nextElement();
+ CheckableTreeNode child = (CheckableTreeNode) children.nextElement();
child.setSelected(bSelected);
}
diff --git a/src/java/net/sf/jabref/collab/EntryChange.java b/src/java/net/sf/jabref/collab/EntryChange.java
index 924fd25..d479995 100644
--- a/src/java/net/sf/jabref/collab/EntryChange.java
+++ b/src/java/net/sf/jabref/collab/EntryChange.java
@@ -21,6 +21,7 @@ import java.util.TreeSet;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
+import javax.swing.tree.TreeNode;
import net.sf.jabref.*;
import net.sf.jabref.undo.NamedCompound;
@@ -83,11 +84,10 @@ public class EntryChange extends Change {
public boolean makeChange(BasePanel panel, BibtexDatabase secondary, NamedCompound undoEdit) {
- @SuppressWarnings("unchecked")
boolean allAccepted = true;
- Enumeration<Change> e = children();
+ Enumeration<TreeNode> e = children();
for (; e.hasMoreElements();) {
- Change c = e.nextElement();
+ Change c = (Change) e.nextElement();
if (c.isAcceptable() && c.isAccepted())
c.makeChange(panel, secondary, undoEdit);
else allAccepted = false;
diff --git a/src/java/net/sf/jabref/groups/AddToGroupAction.java b/src/java/net/sf/jabref/groups/AddToGroupAction.java
index 30d57c8..1840e32 100644
--- a/src/java/net/sf/jabref/groups/AddToGroupAction.java
+++ b/src/java/net/sf/jabref/groups/AddToGroupAction.java
@@ -20,6 +20,7 @@ import java.util.Enumeration;
import java.util.Vector;
import javax.swing.AbstractAction;
+import javax.swing.tree.TreeNode;
import javax.swing.undo.AbstractUndoableEdit;
import net.sf.jabref.BasePanel;
@@ -59,10 +60,10 @@ public class AddToGroupAction extends AbstractAction {
if (m_move) {
// collect warnings for removal
- Enumeration<GroupTreeNode> e = ((GroupTreeNode) m_node.getRoot()).preorderEnumeration();
+ Enumeration<TreeNode> e = ((GroupTreeNode) m_node.getRoot()).preorderEnumeration();
GroupTreeNode node;
while (e.hasMoreElements()) {
- node = e.nextElement();
+ node = (GroupTreeNode) e.nextElement();
if (!node.getGroup().supportsRemove())
continue;
for (int i = 0; i < entries.length; ++i) {
diff --git a/src/java/net/sf/jabref/groups/GroupSelector.java b/src/java/net/sf/jabref/groups/GroupSelector.java
index 4700d13..4813f12 100644
--- a/src/java/net/sf/jabref/groups/GroupSelector.java
+++ b/src/java/net/sf/jabref/groups/GroupSelector.java
@@ -60,6 +60,7 @@ import javax.swing.event.PopupMenuListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import javax.swing.undo.AbstractUndoableEdit;
import javax.swing.undo.CompoundEdit;
@@ -1498,8 +1499,8 @@ public class GroupSelector extends SidePaneComponent implements
GroupTreeNode node;
AbstractGroup group;
Vector<GroupTreeNode> vec = new Vector<GroupTreeNode>();
- for (Enumeration<GroupTreeNode> e = groupsRoot.preorderEnumeration(); e.hasMoreElements();) {
- node = e.nextElement();
+ for (Enumeration<TreeNode> e = groupsRoot.preorderEnumeration(); e.hasMoreElements();) {
+ node = (GroupTreeNode) e.nextElement();
group = node.getGroup();
int i;
for (i = 0; i < entries.length; ++i) {
@@ -1537,8 +1538,8 @@ public class GroupSelector extends SidePaneComponent implements
BibtexEntry entry;
Vector<GroupTreeNode> vec = new Vector<GroupTreeNode>();
Map<String, String> dummyMap = new HashMap<String, String>(); // just because I don't want to use null...
- for (Enumeration<GroupTreeNode> e = groupsRoot.depthFirstEnumeration(); e.hasMoreElements();) {
- node = e.nextElement();
+ for (Enumeration<TreeNode> e = groupsRoot.depthFirstEnumeration(); e.hasMoreElements();) {
+ node = (GroupTreeNode) e.nextElement();
rule = node.getSearchRule();
for (Iterator<BibtexEntry> it = matches.iterator(); it.hasNext();) {
entry = it.next();
diff --git a/src/java/net/sf/jabref/groups/GroupTreeNode.java b/src/java/net/sf/jabref/groups/GroupTreeNode.java
index 9013af4..c55c7cf 100644
--- a/src/java/net/sf/jabref/groups/GroupTreeNode.java
+++ b/src/java/net/sf/jabref/groups/GroupTreeNode.java
@@ -81,10 +81,10 @@ public class GroupTreeNode extends DefaultMutableTreeNode implements
*/
public String getTreeAsString() {
StringBuffer sb = new StringBuffer();
- Enumeration<GroupTreeNode> e = preorderEnumeration();
+ Enumeration<TreeNode> e = preorderEnumeration();
GroupTreeNode cursor;
while (e.hasMoreElements()) {
- cursor = e.nextElement();
+ cursor = (GroupTreeNode) e.nextElement();
sb.append(cursor.getLevel()).append(" ").append(cursor.getGroup().toString()).append("\n");
}
return sb.toString();
@@ -194,26 +194,22 @@ public class GroupTreeNode extends DefaultMutableTreeNode implements
}
@Override
- @SuppressWarnings("unchecked")
- public Enumeration<GroupTreeNode> preorderEnumeration(){
+ public Enumeration<TreeNode> preorderEnumeration(){
return super.preorderEnumeration();
}
@Override
- @SuppressWarnings("unchecked")
- public Enumeration<GroupTreeNode> depthFirstEnumeration(){
+ public Enumeration<TreeNode> depthFirstEnumeration(){
return super.depthFirstEnumeration();
}
@Override
- @SuppressWarnings("unchecked")
- public Enumeration<GroupTreeNode> breadthFirstEnumeration(){
+ public Enumeration<TreeNode> breadthFirstEnumeration(){
return super.breadthFirstEnumeration();
}
@Override
- @SuppressWarnings("unchecked")
- public Enumeration<GroupTreeNode> children(){
+ public Enumeration<TreeNode> children(){
return super.children();
}
@@ -224,10 +220,10 @@ public class GroupTreeNode extends DefaultMutableTreeNode implements
*/
public AbstractGroup[] getMatchingGroups(BibtexEntry entry) {
Vector<AbstractGroup> matchingGroups = new Vector<AbstractGroup>();
- Enumeration<GroupTreeNode> e = preorderEnumeration();
+ Enumeration<TreeNode> e = preorderEnumeration();
AbstractGroup group;
while (e.hasMoreElements()) {
- group = (e.nextElement()).getGroup();
+ group = ((GroupTreeNode) e.nextElement()).getGroup();
if (group.contains(null, entry)) // first argument is never used
matchingGroups.add(group);
}
diff --git a/src/java/net/sf/jabref/groups/GroupsTree.java b/src/java/net/sf/jabref/groups/GroupsTree.java
index e58a567..c3daf94 100644
--- a/src/java/net/sf/jabref/groups/GroupsTree.java
+++ b/src/java/net/sf/jabref/groups/GroupsTree.java
@@ -31,6 +31,7 @@ import javax.swing.JTree;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import javax.swing.undo.AbstractUndoableEdit;
@@ -415,14 +416,14 @@ public class GroupsTree extends JTree implements DragSourceListener,
/** Expand this node and all its children. */
public void expandSubtree(GroupTreeNode node) {
- for (Enumeration<GroupTreeNode> e = node.depthFirstEnumeration(); e.hasMoreElements();)
- expandPath(new TreePath(e.nextElement().getPath()));
+ for (Enumeration<TreeNode> e = node.depthFirstEnumeration(); e.hasMoreElements();)
+ expandPath(new TreePath(((GroupTreeNode) e.nextElement()).getPath()));
}
/** Collapse this node and all its children. */
public void collapseSubtree(GroupTreeNode node) {
- for (Enumeration<GroupTreeNode> e = node.depthFirstEnumeration(); e.hasMoreElements();)
- collapsePath(new TreePath((e.nextElement())
+ for (Enumeration<TreeNode> e = node.depthFirstEnumeration(); e.hasMoreElements();)
+ collapsePath(new TreePath(((GroupTreeNode) e.nextElement())
.getPath()));
}
@@ -432,8 +433,8 @@ public class GroupsTree extends JTree implements DragSourceListener,
*/
public boolean hasExpandedDescendant(TreePath path) {
GroupTreeNode node = (GroupTreeNode) path.getLastPathComponent();
- for (Enumeration<GroupTreeNode> e = node.children(); e.hasMoreElements();) {
- GroupTreeNode child = e.nextElement();
+ for (Enumeration<TreeNode> e = node.children(); e.hasMoreElements();) {
+ GroupTreeNode child = (GroupTreeNode) e.nextElement();
if (child.isLeaf())
continue; // don't care about this case
TreePath pathToChild = path.pathByAddingChild(child);
@@ -449,8 +450,8 @@ public class GroupsTree extends JTree implements DragSourceListener,
*/
public boolean hasCollapsedDescendant(TreePath path) {
GroupTreeNode node = (GroupTreeNode) path.getLastPathComponent();
- for (Enumeration<GroupTreeNode> e = node.children(); e.hasMoreElements();) {
- GroupTreeNode child = e.nextElement();
+ for (Enumeration<TreeNode> e = node.children(); e.hasMoreElements();) {
+ GroupTreeNode child = (GroupTreeNode) e.nextElement();
if (child.isLeaf())
continue; // don't care about this case
TreePath pathToChild = path.pathByAddingChild(child);
diff --git a/src/java/net/sf/jabref/imports/AppendDatabaseAction.java b/src/java/net/sf/jabref/imports/AppendDatabaseAction.java
index ad84bbc..5fdce20 100644
--- a/src/java/net/sf/jabref/imports/AppendDatabaseAction.java
+++ b/src/java/net/sf/jabref/imports/AppendDatabaseAction.java
@@ -22,6 +22,7 @@ import java.util.Iterator;
import java.util.List;
import javax.swing.JOptionPane;
+import javax.swing.tree.TreeNode;
import net.sf.jabref.BaseAction;
import net.sf.jabref.BasePanel;
@@ -175,9 +176,9 @@ public class AppendDatabaseAction extends BaseAction {
ExplicitGroup group;
BibtexEntry entry;
- for (Enumeration<GroupTreeNode> e = newGroups
+ for (Enumeration<TreeNode> e = newGroups
.preorderEnumeration(); e.hasMoreElements();) {
- node = e.nextElement();
+ node = (GroupTreeNode) e.nextElement();
if (!(node.getGroup() instanceof ExplicitGroup))
continue;
group = (ExplicitGroup) node.getGroup();
diff --git a/src/java/net/sf/jabref/sql/exporter/DBExporter.java b/src/java/net/sf/jabref/sql/exporter/DBExporter.java
index deb9126..1518e0b 100644
--- a/src/java/net/sf/jabref/sql/exporter/DBExporter.java
+++ b/src/java/net/sf/jabref/sql/exporter/DBExporter.java
@@ -32,6 +32,7 @@ import java.util.Set;
import java.util.Vector;
import javax.swing.JOptionPane;
+import javax.swing.tree.TreeNode;
import net.sf.jabref.BibtexDatabase;
import net.sf.jabref.BibtexEntry;
@@ -201,9 +202,9 @@ public abstract class DBExporter extends DBImporterExporter{
rs.next();
myID = rs.getInt("groups_id");
}
- for (Enumeration<GroupTreeNode> e = cursor.children(); e
+ for (Enumeration<TreeNode> e = cursor.children(); e
.hasMoreElements();)
- currentID = populateEntryGroupsTable(e.nextElement(), myID,
+ currentID = populateEntryGroupsTable((GroupTreeNode) e.nextElement(), myID,
currentID, out, database_id);
return currentID;
}
@@ -338,9 +339,9 @@ public abstract class DBExporter extends DBImporterExporter{
rs.next();
myID = rs.getInt("groups_id");
}
- for (Enumeration<GroupTreeNode> e = cursor.children(); e
+ for (Enumeration<TreeNode> e = cursor.children(); e
.hasMoreElements();)
- currentID = populateGroupsTable(e.nextElement(), myID, ++currentID,
+ currentID = populateGroupsTable((GroupTreeNode) e.nextElement(), myID, ++currentID,
out, database_id);
return currentID;
}
--
2.34.1
|