Skip to content

Commit

Permalink
Update tree node selectors for multi-release JAR (MRJAR)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanue1 committed Jun 12, 2019
1 parent b71cc56 commit 515fca8
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 15 deletions.
4 changes: 2 additions & 2 deletions api/src/main/java/org/jd/gui/spi/TreeNodeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import java.util.regex.Pattern;

public interface TreeNodeFactory {
String[] getSelectors();
String[] getSelectors();

Pattern getPathPattern();

<T extends DefaultMutableTreeNode & ContainerEntryGettable & UriGettable> T make(API api, Container.Entry entry);
<T extends DefaultMutableTreeNode & ContainerEntryGettable & UriGettable> T make(API api, Container.Entry entry);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,23 @@
public class ClassesDirectoryTreeNodeFactoryProvider extends DirectoryTreeNodeFactoryProvider {
protected static final ImageIcon ICON = new ImageIcon(ClassesDirectoryTreeNodeFactoryProvider.class.getClassLoader().getResource("org/jd/gui/images/packagefolder_obj.png"));

@Override public String[] getSelectors() { return appendSelectors("war:dir:WEB-INF/classes", "jmod:dir:classes"); }
@Override public String[] getSelectors() {
return appendSelectors(
"jar:dir:META-INF/versions",
"jar:dir:META-INF/versions/5",
"jar:dir:META-INF/versions/6",
"jar:dir:META-INF/versions/7",
"jar:dir:META-INF/versions/8",
"jar:dir:META-INF/versions/9",
"jar:dir:META-INF/versions/10",
"jar:dir:META-INF/versions/11",
"jar:dir:META-INF/versions/12",
"jar:dir:META-INF/versions/13",
"jar:dir:META-INF/versions/14",
"war:dir:WEB-INF/classes",
"jmod:dir:classes");
}

@Override public ImageIcon getIcon() { return ICON; }
@Override public ImageIcon getOpenIcon() { return null; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.Collection;

public class DirectoryTreeNodeFactoryProvider extends AbstractTreeNodeFactoryProvider {
protected static final ImageIcon ICON = new ImageIcon(DirectoryTreeNodeFactoryProvider.class.getClassLoader().getResource("org/jd/gui/images/folder.gif"));
protected static final ImageIcon ICON = new ImageIcon(DirectoryTreeNodeFactoryProvider.class.getClassLoader().getResource("org/jd/gui/images/folder.gif"));
protected static final ImageIcon OPEN_ICON = new ImageIcon(DirectoryTreeNodeFactoryProvider.class.getClassLoader().getResource("org/jd/gui/images/folder_open.png"));

@Override public String[] getSelectors() { return appendSelectors("*:dir:*"); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class JavaModulePackageTreeNodeFactoryProvider extends PackageTreeNodeFac
@Override
public Pattern getPathPattern() {
if (externalPathPattern == null) {
return Pattern.compile("classes\\/.*");
return Pattern.compile("classes\\/(?!META-INF)..*");
} else {
return externalPathPattern;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
public class MetainfDirectoryTreeNodeFactoryProvider extends DirectoryTreeNodeFactoryProvider {
protected static final ImageIcon ICON = new ImageIcon(MetainfDirectoryTreeNodeFactoryProvider.class.getClassLoader().getResource("org/jd/gui/images/inf_obj.png"));

@Override public String[] getSelectors() { return appendSelectors("jar:dir:*", "war:dir:*", "ear:dir:*"); }

@Override
public Pattern getPathPattern() {
if (externalPathPattern == null) {
return Pattern.compile("(WEB-INF|(WEB-INF\\/classes\\/)?META-IN(F|F\\/.*))");
} else {
return externalPathPattern;
}
@Override public String[] getSelectors() {
return appendSelectors(
"jar:dir:META-INF",
"war:dir:WEB-INF",
"war:dir:WEB-INF/classes/META-INF",
"ear:dir:META-INF",
"jmod:dir:classes/META-INF");
}

@Override public ImageIcon getIcon() { return ICON; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,22 @@
import javax.swing.tree.DefaultMutableTreeNode;
import java.io.File;
import java.util.Collection;
import java.util.regex.Pattern;

public class PackageTreeNodeFactoryProvider extends DirectoryTreeNodeFactoryProvider {
protected static final ImageIcon ICON = new ImageIcon(PackageTreeNodeFactoryProvider.class.getClassLoader().getResource("org/jd/gui/images/package_obj.png"));

@Override public String[] getSelectors() { return appendSelectors("jar:dir:*"); }

@Override
public Pattern getPathPattern() {
if (externalPathPattern == null) {
return Pattern.compile("(META-INF\\/versions\\/.*)|(?!META-INF)..*");
} else {
return externalPathPattern;
}
}

@Override
@SuppressWarnings("unchecked")
public <T extends DefaultMutableTreeNode & ContainerEntryGettable & UriGettable> T make(API api, Container.Entry entry) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2008-2019 Emmanuel Dupuy.
* This project is distributed under the GPLv3 license.
* This is a Copyleft license that gives the user the right to use,
* copy and modify the code freely for non-commercial purposes.
*/

package org.jd.gui.service.treenode;

import java.util.regex.Pattern;

public class SpiFileTreeNodeFactoryProvider extends TextFileTreeNodeFactoryProvider {
@Override public String[] getSelectors() {
return appendSelectors("*:file:*");
}

@Override
public Pattern getPathPattern() {
if (externalPathPattern == null) {
return Pattern.compile("(.*\\/)?META-INF\\/services\\/.*");
} else {
return externalPathPattern;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class WarPackageTreeNodeFactoryProvider extends PackageTreeNodeFactoryPro
@Override
public Pattern getPathPattern() {
if (externalPathPattern == null) {
return Pattern.compile("WEB-INF\\/classes\\/.*");
return Pattern.compile("WEB-INF\\/classes\\/(?!META-INF)..*");
} else {
return externalPathPattern;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ org.jd.gui.service.treenode.ModuleInfoFileTreeNodeFactoryProvider
org.jd.gui.service.treenode.PackageTreeNodeFactoryProvider
org.jd.gui.service.treenode.PropertiesFileTreeNodeFactoryProvider
org.jd.gui.service.treenode.SqlFileTreeNodeFactoryProvider
org.jd.gui.service.treenode.SpiFileTreeNodeFactoryProvider
org.jd.gui.service.treenode.TextFileTreeNodeFactoryProvider
org.jd.gui.service.treenode.WarFileTreeNodeFactoryProvider
org.jd.gui.service.treenode.WarPackageTreeNodeFactoryProvider
Expand Down

0 comments on commit 515fca8

Please sign in to comment.