@@ -225,7 +225,7 @@ public FileNode addTreeElement(FileContainer container, FileNode parent) {
225225 if (parent == null )
226226 parent = treeRoot ;
227227
228- FileNode root = new FileNode (container );
228+ FileNode root = new FileNode (container , isJava ( container ) );
229229 parent .add (root );
230230 JDATreeCellRenderer renderer = new JDATreeCellRenderer ();
231231 tree .setCellRenderer (renderer );
@@ -234,10 +234,10 @@ public FileNode addTreeElement(FileContainer container, FileNode parent) {
234234 for (final Entry <String , byte []> entry : container .files .entrySet ()) {
235235 String name = entry .getKey ();
236236 final String [] spl = name .split ("/" );
237+ FileNode parentNode = root ;
237238 if (spl .length <= 1 ) {
238- root .add (new FileNode (name ));
239+ root .add (new FileNode (name , parentNode . isJava ));
239240 } else {
240- FileNode parentNode = root ;
241241 for (final String s : spl ) {
242242 FileNode child = null ;
243243 for (int i = 0 ; i < parentNode .getChildCount (); i ++) {
@@ -247,7 +247,7 @@ public FileNode addTreeElement(FileContainer container, FileNode parent) {
247247 }
248248 }
249249 if (child == null ) {
250- child = new FileNode (s );
250+ child = new FileNode (s , parentNode . isJava );
251251 parentNode .add (child );
252252 }
253253 parentNode = child ;
@@ -263,6 +263,10 @@ public FileNode addTreeElement(FileContainer container, FileNode parent) {
263263 return root ;
264264 }
265265
266+ private boolean isJava (FileContainer container ) {
267+ return container .name .endsWith (".java" ) || container .name .endsWith (".jar" ) || container .name .endsWith (".class" );
268+ }
269+
266270 @ SuppressWarnings ("rawtypes" )
267271 void treeDfs (final TreePath parent , Consumer <TreePath > onPreOrder , Consumer <TreePath > onPostOrder ) {
268272 if (onPreOrder != null )
@@ -314,12 +318,17 @@ public void paint(final Graphics g) {
314318
315319 public class FileNode extends DefaultMutableTreeNode {
316320
317- public final boolean isJava = false ;
321+ public final boolean isJava ;
318322
319323 private static final long serialVersionUID = -8817777566176729571L ;
320324
321- public FileNode (final Object o ) {
325+ public FileNode (final Object o , boolean isJava ) {
322326 super (o );
327+ this .isJava = isJava ;
328+ }
329+
330+ public FileNode (final Object o ) {
331+ this (o , false );
323332 }
324333
325334 @ Override
0 commit comments