Codebase list jd-gui / b4b8ec8
Update AAR and JMOD files support emmanue1 4 years ago
16 changed file(s) with 119 addition(s) and 107 deletion(s). Raw diff Collapse all Expand all
1818
1919 public static TreeNodeFactoryService getInstance() { return TREE_NODE_FACTORY_SERVICE; }
2020
21 protected HashMap<String, TreeNodeFactories> mapProviders = new HashMap<>();
21 protected HashMap<String, TreeNodeFactories> mapProviders = new HashMap<>();
2222
2323 protected TreeNodeFactoryService() {
2424 Collection<TreeNodeFactory> providers = ExtensionService.getInstance().load(TreeNodeFactory.class);
151151
152152 for (Path subPath : stream) {
153153 if (subPath.getNameCount() > parentNameCount) {
154 ContainerFactory containerFactory = api.getContainerFactory(subPath);
155
156 if ((containerFactory == null) || "generic".equals(containerFactory.getType())) {
157 children.add(newChildEntry(subPath));
158 } else {
159 Entry childEntry = newChildEntry(subPath);
160 Container container = containerFactory.make(api, childEntry, subPath);
161
162 if (container != null) {
163 childEntry.children = container.getRoot().getChildren();
164 }
165
166 children.add(childEntry);
167 }
154 children.add(newChildEntry(subPath));
168155 }
169156 }
170157
+0
-21
services/src/main/java/org/jd/gui/model/container/JmodClassesDirectoryContainer.java less more
0 /*
1 * Copyright (c) 2008-2019 Emmanuel Dupuy.
2 * This project is distributed under the GPLv3 license.
3 * This is a Copyleft license that gives the user the right to use,
4 * copy and modify the code freely for non-commercial purposes.
5 */
6
7 package org.jd.gui.model.container;
8
9 import org.jd.gui.api.API;
10 import org.jd.gui.api.model.Container;
11
12 import java.nio.file.Path;
13
14 public class JmodClassesDirectoryContainer extends GenericContainer {
15 public JmodClassesDirectoryContainer(API api, Container.Entry parentEntry, Path rootPath) {
16 super(api, parentEntry, rootPath);
17 }
18
19 public String getType() { return "jmodClassesDirectory"; }
20 }
0 /*
1 * Copyright (c) 2008-2019 Emmanuel Dupuy.
2 * This project is distributed under the GPLv3 license.
3 * This is a Copyleft license that gives the user the right to use,
4 * copy and modify the code freely for non-commercial purposes.
5 */
6
7 package org.jd.gui.model.container;
8
9 import org.jd.gui.api.API;
10 import org.jd.gui.api.model.Container;
11
12 import java.nio.file.Path;
13
14 public class JmodContainer extends GenericContainer {
15 public JmodContainer(API api, Container.Entry parentEntry, Path rootPath) {
16 super(api, parentEntry, rootPath);
17 }
18
19 public String getType() { return "jmod"; }
20 }
+0
-40
services/src/main/java/org/jd/gui/service/container/JmodClassesDirectoryContainerFactoryProvider.java less more
0 /*
1 * Copyright (c) 2008-2019 Emmanuel Dupuy.
2 * This project is distributed under the GPLv3 license.
3 * This is a Copyleft license that gives the user the right to use,
4 * copy and modify the code freely for non-commercial purposes.
5 */
6
7 package org.jd.gui.service.container;
8
9 import org.jd.gui.api.API;
10 import org.jd.gui.api.model.Container;
11 import org.jd.gui.model.container.JmodClassesDirectoryContainer;
12 import org.jd.gui.spi.ContainerFactory;
13
14 import java.nio.file.Files;
15 import java.nio.file.Path;
16
17 public class JmodClassesDirectoryContainerFactoryProvider implements ContainerFactory {
18 @Override
19 public String getType() { return "jmodClassesDirectory"; }
20
21 @Override
22 public boolean accept(API api, Path rootPath) {
23 if (Files.isDirectory(rootPath)) {
24 Path fileName = rootPath.getFileName();
25
26 if ((fileName != null) && "classes".equals(rootPath.getFileName().toString())) {
27 String fileStoreName = rootPath.getFileSystem().getFileStores().iterator().next().name();
28 return fileStoreName.endsWith(".jmod/");
29 }
30 }
31
32 return false;
33 }
34
35 @Override
36 public Container make(API api, Container.Entry parentEntry, Path rootPath) {
37 return new JmodClassesDirectoryContainer(api, parentEntry, rootPath);
38 }
39 }
0 /*
1 * Copyright (c) 2008-2019 Emmanuel Dupuy.
2 * This project is distributed under the GPLv3 license.
3 * This is a Copyleft license that gives the user the right to use,
4 * copy and modify the code freely for non-commercial purposes.
5 */
6
7 package org.jd.gui.service.container;
8
9 import org.jd.gui.api.API;
10 import org.jd.gui.api.model.Container;
11 import org.jd.gui.model.container.JmodContainer;
12 import org.jd.gui.spi.ContainerFactory;
13 import org.jd.gui.util.exception.ExceptionUtil;
14
15 import java.nio.file.Files;
16 import java.nio.file.InvalidPathException;
17 import java.nio.file.Path;
18
19 public class JmodContainerFactoryProvider implements ContainerFactory {
20 @Override
21 public String getType() { return "jmod"; }
22
23 @Override
24 public boolean accept(API api, Path rootPath) {
25 if (rootPath.toUri().toString().toLowerCase().endsWith(".jmod!/")) {
26 return true;
27 } else {
28 // Extension: accept uncompressed WAR file containing a folder 'WEB-INF'
29 try {
30 return rootPath.getFileSystem().provider().getScheme().equals("file") && Files.exists(rootPath.resolve("classes"));
31 } catch (InvalidPathException e) {
32 assert ExceptionUtil.printStackTrace(e);
33 return false;
34 }
35 }
36 }
37
38 @Override
39 public Container make(API api, Container.Entry parentEntry, Path rootPath) {
40 return new JmodContainer(api, parentEntry, rootPath);
41 }
42 }
0 /*
1 * Copyright (c) 2008-2019 Emmanuel Dupuy.
2 * This project is distributed under the GPLv3 license.
3 * This is a Copyleft license that gives the user the right to use,
4 * copy and modify the code freely for non-commercial purposes.
5 */
6
7 package org.jd.gui.service.treenode;
8
9 import javax.swing.*;
10
11 public class ClassesDirectoryTreeNodeFactoryProvider extends DirectoryTreeNodeFactoryProvider {
12 protected static final ImageIcon ICON = new ImageIcon(ClassesDirectoryTreeNodeFactoryProvider.class.getClassLoader().getResource("org/jd/gui/images/packagefolder_obj.png"));
13
14 @Override public String[] getSelectors() { return appendSelectors("war:dir:WEB-INF/classes", "jmod:dir:classes"); }
15 @Override public ImageIcon getIcon() { return ICON; }
16 @Override public ImageIcon getOpenIcon() { return null; }
17 }
2727 int lastSlashIndex = entry.getPath().lastIndexOf("/");
2828 String label = entry.getPath().substring(lastSlashIndex+1);
2929 String location = new File(entry.getUri()).getPath();
30 T node = (T)new TreeNode(entry, "ear", new TreeNodeBean(label, "Location: " + location, ICON));
30 T node = (T)new TreeNode(entry, new TreeNodeBean(label, "Location: " + location, ICON));
3131 // Add dummy node
3232 node.add(new DefaultMutableTreeNode());
3333 return node;
3131 String label = entry.getPath().substring(lastSlashIndex+1);
3232 String location = new File(entry.getUri()).getPath();
3333 ImageIcon icon = isAEjbModule(entry) ? EJB_FILE_ICON : JAR_FILE_ICON;
34 T node = (T)new TreeNode(entry, "jar", new TreeNodeBean(label, "Location: " + location, icon));
34 T node = (T)new TreeNode(entry, new TreeNodeBean(label, "Location: " + location, icon));
3535 // Add dummy node
3636 node.add(new DefaultMutableTreeNode());
3737 return node;
6565 }
6666
6767 protected static class TreeNode extends ZipFileTreeNodeFactoryProvider.TreeNode {
68 public TreeNode(Container.Entry entry, String containerType, Object userObject) {
69 super(entry, containerType, userObject);
68 public TreeNode(Container.Entry entry, Object userObject) {
69 super(entry, userObject);
7070 }
7171
7272 @Override
2424 int lastSlashIndex = entry.getPath().lastIndexOf("/");
2525 String label = entry.getPath().substring(lastSlashIndex+1);
2626 String location = new File(entry.getUri()).getPath();
27 T node = (T)new TreeNode(entry, "generic", new TreeNodeBean(label, "Location: " + location, ICON));
27 T node = (T)new TreeNode(entry, new TreeNodeBean(label, "Location: " + location, ICON));
2828 // Add dummy node
2929 node.add(new DefaultMutableTreeNode());
3030 return node;
0 /*
1 * Copyright (c) 2008-2019 Emmanuel Dupuy.
2 * This project is distributed under the GPLv3 license.
3 * This is a Copyleft license that gives the user the right to use,
4 * copy and modify the code freely for non-commercial purposes.
5 */
6
7 package org.jd.gui.service.treenode;
8
9 import java.util.regex.Pattern;
10
11 public class JmodPackageTreeNodeFactoryProvider extends PackageTreeNodeFactoryProvider {
12
13 @Override public String[] getSelectors() { return appendSelectors("jmod:dir:*"); }
14
15 @Override
16 public Pattern getPathPattern() {
17 if (externalPathPattern == null) {
18 return Pattern.compile("classes\\/.*");
19 } else {
20 return externalPathPattern;
21 }
22 }
23 }
2727 int lastSlashIndex = entry.getPath().lastIndexOf("/");
2828 String label = entry.getPath().substring(lastSlashIndex+1);
2929 String location = new File(entry.getUri()).getPath();
30 T node = (T)new TreeNode(entry, "war", new TreeNodeBean(label, "Location: " + location, ICON));
30 T node = (T)new TreeNode(entry, new TreeNodeBean(label, "Location: " + location, ICON));
3131 // Add dummy node
3232 node.add(new DefaultMutableTreeNode());
3333 return node;
+0
-18
services/src/main/java/org/jd/gui/service/treenode/WebinfClassesDirectoryTreeNodeFactoryProvider.java less more
0 /*
1 * Copyright (c) 2008-2019 Emmanuel Dupuy.
2 * This project is distributed under the GPLv3 license.
3 * This is a Copyleft license that gives the user the right to use,
4 * copy and modify the code freely for non-commercial purposes.
5 */
6
7 package org.jd.gui.service.treenode;
8
9 import javax.swing.*;
10
11 public class WebinfClassesDirectoryTreeNodeFactoryProvider extends DirectoryTreeNodeFactoryProvider {
12 protected static final ImageIcon ICON = new ImageIcon(WebinfClassesDirectoryTreeNodeFactoryProvider.class.getClassLoader().getResource("org/jd/gui/images/packagefolder_obj.png"));
13
14 @Override public String[] getSelectors() { return appendSelectors("war:dir:WEB-INF/classes"); }
15 @Override public ImageIcon getIcon() { return ICON; }
16 @Override public ImageIcon getOpenIcon() { return null; }
17 }
2828 int lastSlashIndex = entry.getPath().lastIndexOf("/");
2929 String label = entry.getPath().substring(lastSlashIndex+1);
3030 String location = new File(entry.getUri()).getPath();
31 T node = (T)new TreeNode(entry, "generic", new TreeNodeBean(label, "Location: " + location, ICON));
31 T node = (T)new TreeNode(entry, new TreeNodeBean(label, "Location: " + location, ICON));
3232 // Add dummy node
3333 node.add(new DefaultMutableTreeNode());
3434 return node;
3535 }
3636
3737 protected static class TreeNode extends DirectoryTreeNodeFactoryProvider.TreeNode {
38 protected String ct;
39
40 public TreeNode(Container.Entry entry, String containerType, Object userObject) {
38 public TreeNode(Container.Entry entry, Object userObject) {
4139 super(entry, userObject);
42 ct = containerType;
4340 }
4441
4542 // --- TreeNodeExpandable --- //
00 # Order is important : 'GenericContainerFactoryProvider' must be the last
1 org.jd.gui.service.container.JmodClassesDirectoryContainerFactoryProvider
1 org.jd.gui.service.container.JmodContainerFactoryProvider
22 org.jd.gui.service.container.EarContainerFactoryProvider
33 org.jd.gui.service.container.WarContainerFactoryProvider
44 org.jd.gui.service.container.JarContainerFactoryProvider
0 org.jd.gui.service.treenode.ClassesDirectoryTreeNodeFactoryProvider
01 org.jd.gui.service.treenode.ClassFileTreeNodeFactoryProvider
12 org.jd.gui.service.treenode.CssFileTreeNodeFactoryProvider
23 org.jd.gui.service.treenode.DirectoryTreeNodeFactoryProvider
910 org.jd.gui.service.treenode.JavaFileTreeNodeFactoryProvider
1011 org.jd.gui.service.treenode.JavascriptFileTreeNodeFactoryProvider
1112 org.jd.gui.service.treenode.JmodFileTreeNodeFactoryProvider
13 org.jd.gui.service.treenode.JmodPackageTreeNodeFactoryProvider
1214 org.jd.gui.service.treenode.JsonFileTreeNodeFactoryProvider
1315 org.jd.gui.service.treenode.JspFileTreeNodeFactoryProvider
1416 org.jd.gui.service.treenode.ManifestFileTreeNodeFactoryProvider
2022 org.jd.gui.service.treenode.TextFileTreeNodeFactoryProvider
2123 org.jd.gui.service.treenode.WarFileTreeNodeFactoryProvider
2224 org.jd.gui.service.treenode.WarPackageTreeNodeFactoryProvider
23 org.jd.gui.service.treenode.WebinfClassesDirectoryTreeNodeFactoryProvider
2425 org.jd.gui.service.treenode.WebinfLibDirectoryTreeNodeFactoryProvider
2526 org.jd.gui.service.treenode.WebXmlFileTreeNodeFactoryProvider
2627 org.jd.gui.service.treenode.XmlBasedFileTreeNodeFactoryProvider