Update AAR and JMOD files support
emmanue1
4 years ago
18 | 18 | |
19 | 19 | public static TreeNodeFactoryService getInstance() { return TREE_NODE_FACTORY_SERVICE; } |
20 | 20 | |
21 | protected HashMap<String, TreeNodeFactories> mapProviders = new HashMap<>(); | |
21 | protected HashMap<String, TreeNodeFactories> mapProviders = new HashMap<>(); | |
22 | 22 | |
23 | 23 | protected TreeNodeFactoryService() { |
24 | 24 | Collection<TreeNodeFactory> providers = ExtensionService.getInstance().load(TreeNodeFactory.class); |
151 | 151 | |
152 | 152 | for (Path subPath : stream) { |
153 | 153 | 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)); | |
168 | 155 | } |
169 | 156 | } |
170 | 157 |
+0
-21
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
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 | } |
+43
-0
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 | } |
+18
-0
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 | } |
+1
-1
27 | 27 | int lastSlashIndex = entry.getPath().lastIndexOf("/"); |
28 | 28 | String label = entry.getPath().substring(lastSlashIndex+1); |
29 | 29 | 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)); | |
31 | 31 | // Add dummy node |
32 | 32 | node.add(new DefaultMutableTreeNode()); |
33 | 33 | return node; |
+3
-3
31 | 31 | String label = entry.getPath().substring(lastSlashIndex+1); |
32 | 32 | String location = new File(entry.getUri()).getPath(); |
33 | 33 | 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)); | |
35 | 35 | // Add dummy node |
36 | 36 | node.add(new DefaultMutableTreeNode()); |
37 | 37 | return node; |
65 | 65 | } |
66 | 66 | |
67 | 67 | 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); | |
70 | 70 | } |
71 | 71 | |
72 | 72 | @Override |
+1
-1
24 | 24 | int lastSlashIndex = entry.getPath().lastIndexOf("/"); |
25 | 25 | String label = entry.getPath().substring(lastSlashIndex+1); |
26 | 26 | 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)); | |
28 | 28 | // Add dummy node |
29 | 29 | node.add(new DefaultMutableTreeNode()); |
30 | 30 | return node; |
+24
-0
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 | } |
+1
-1
27 | 27 | int lastSlashIndex = entry.getPath().lastIndexOf("/"); |
28 | 28 | String label = entry.getPath().substring(lastSlashIndex+1); |
29 | 29 | 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)); | |
31 | 31 | // Add dummy node |
32 | 32 | node.add(new DefaultMutableTreeNode()); |
33 | 33 | return node; |
+0
-18
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 | } |
+2
-5
28 | 28 | int lastSlashIndex = entry.getPath().lastIndexOf("/"); |
29 | 29 | String label = entry.getPath().substring(lastSlashIndex+1); |
30 | 30 | 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)); | |
32 | 32 | // Add dummy node |
33 | 33 | node.add(new DefaultMutableTreeNode()); |
34 | 34 | return node; |
35 | 35 | } |
36 | 36 | |
37 | 37 | 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) { | |
41 | 39 | super(entry, userObject); |
42 | ct = containerType; | |
43 | 40 | } |
44 | 41 | |
45 | 42 | // --- TreeNodeExpandable --- // |
0 | 0 | # Order is important : 'GenericContainerFactoryProvider' must be the last |
1 | org.jd.gui.service.container.JmodClassesDirectoryContainerFactoryProvider | |
1 | org.jd.gui.service.container.JmodContainerFactoryProvider | |
2 | 2 | org.jd.gui.service.container.EarContainerFactoryProvider |
3 | 3 | org.jd.gui.service.container.WarContainerFactoryProvider |
4 | 4 | org.jd.gui.service.container.JarContainerFactoryProvider |
0 | org.jd.gui.service.treenode.ClassesDirectoryTreeNodeFactoryProvider | |
0 | 1 | org.jd.gui.service.treenode.ClassFileTreeNodeFactoryProvider |
1 | 2 | org.jd.gui.service.treenode.CssFileTreeNodeFactoryProvider |
2 | 3 | org.jd.gui.service.treenode.DirectoryTreeNodeFactoryProvider |
9 | 10 | org.jd.gui.service.treenode.JavaFileTreeNodeFactoryProvider |
10 | 11 | org.jd.gui.service.treenode.JavascriptFileTreeNodeFactoryProvider |
11 | 12 | org.jd.gui.service.treenode.JmodFileTreeNodeFactoryProvider |
13 | org.jd.gui.service.treenode.JmodPackageTreeNodeFactoryProvider | |
12 | 14 | org.jd.gui.service.treenode.JsonFileTreeNodeFactoryProvider |
13 | 15 | org.jd.gui.service.treenode.JspFileTreeNodeFactoryProvider |
14 | 16 | org.jd.gui.service.treenode.ManifestFileTreeNodeFactoryProvider |
20 | 22 | org.jd.gui.service.treenode.TextFileTreeNodeFactoryProvider |
21 | 23 | org.jd.gui.service.treenode.WarFileTreeNodeFactoryProvider |
22 | 24 | org.jd.gui.service.treenode.WarPackageTreeNodeFactoryProvider |
23 | org.jd.gui.service.treenode.WebinfClassesDirectoryTreeNodeFactoryProvider | |
24 | 25 | org.jd.gui.service.treenode.WebinfLibDirectoryTreeNodeFactoryProvider |
25 | 26 | org.jd.gui.service.treenode.WebXmlFileTreeNodeFactoryProvider |
26 | 27 | org.jd.gui.service.treenode.XmlBasedFileTreeNodeFactoryProvider |