Codebase list jd-gui / 63bafdc
Fix problem on "Select Location" popup emmanue1 5 years ago
3 changed file(s) with 31 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
6868 filteredContainerWrappers.add(new FilteredContainerWrapper(container, getOuterEntries(mapEntry.getValue())));
6969 }
7070
71 selectLocationView.show(
72 location, filteredContainerWrappers, entries.size(),
73 new Consumer<URI>() {
74 @Override public void accept(URI uri) { onLocationSelected(filteredContainerWrappers, uri, selectedLocationCallback); }
75 },
76 closeCallback);
71 Consumer<URI> selectedEntryCallback = uri -> onLocationSelected(filteredContainerWrappers, uri, selectedLocationCallback);
72
73 selectLocationView.show(location, filteredContainerWrappers, entries.size(), selectedEntryCallback, closeCallback);
7774 }
7875
7976 protected Collection<Container.Entry> getOuterEntries(Collection<Container.Entry> entries) {
1313 import java.util.*;
1414
1515 public class FilteredContainerWrapper implements Container {
16 protected static final URI DEFAULT_ROOT_URI = URI.create("file:.");
17
1618 protected Container container;
1719 protected EntryWrapper root;
1820
4749 return entryWrapper;
4850 }
4951
50 protected ContainerWrapper getContainerWrapper(Container.Entry entry) {
51 URI uri = entry.getContainer().getRoot().getUri();
52 protected ContainerWrapper getContainerWrapper(Container container) {
53 Entry root = container.getRoot();
54 URI uri = (root == null) ? DEFAULT_ROOT_URI : root.getUri();
5255 ContainerWrapper containerWrapper = uriToContainerWrapper.get(uri);
5356 if (containerWrapper == null) {
54 uriToContainerWrapper.put(uri, containerWrapper=new ContainerWrapper(entry.getContainer()));
57 uriToContainerWrapper.put(uri, containerWrapper=new ContainerWrapper(container));
5558 }
5659 return containerWrapper;
5760 }
6467 this.entry = entry;
6568 }
6669
67 @Override public Container getContainer() { return getContainerWrapper(entry.getContainer().getRoot()); }
70 @Override public Container getContainer() { return getContainerWrapper(entry.getContainer()); }
6871 @Override public Entry getParent() { return getEntryWrapper(entry.getParent()); }
6972 @Override public URI getUri() { return entry.getUri(); }
7073 @Override public String getPath() { return entry.getPath(); }
2323 import java.util.Iterator;
2424
2525 public class GenericContainer implements Container {
26 protected static final long TIMESTAMP = System.currentTimeMillis();
27
28 protected static long tmpFileCounter = 0;
29
2630 protected API api;
2731 protected int rootNameCount;
2832 protected Container.Entry root;
2933
3034 public GenericContainer(API api, Container.Entry parentEntry, Path rootPath) {
31 this.api = api;
32 this.rootNameCount = rootPath.getNameCount();
33 this.root = new Entry(parentEntry, rootPath, parentEntry.getUri()) {
34 public Entry newChildEntry(Path fsPath) {
35 return new Entry(parent, fsPath, null);
36 }
37 };
35 try {
36 URI uri = parentEntry.getUri();
37
38 this.api = api;
39 this.rootNameCount = rootPath.getNameCount();
40 this.root = new Entry(parentEntry, rootPath, new URI(uri.getScheme(), uri.getHost(), uri.getPath() + "!/", null)) {
41 public Entry newChildEntry(Path fsPath) {
42 return new Entry(parent, fsPath, null);
43 }
44 };
45 } catch (URISyntaxException e) {
46 assert ExceptionUtil.printStackTrace(e);
47 }
3848 }
3949
4050 public String getType() { return "generic"; }
6575 public URI getUri() {
6676 if (uri == null) {
6777 try {
68 uri = new URI(root.getUri().getScheme(), root.getUri().getHost(), root.getUri().getPath() + "!/" + getPath(), null);
78 URI rootUri = root.getUri();
79 uri = new URI(rootUri.getScheme(), rootUri.getHost(), rootUri.getPath() + getPath(), null);
6980 } catch (URISyntaxException e) {
7081 assert ExceptionUtil.printStackTrace(e);
7182 }
145156 }
146157
147158 protected Collection<Container.Entry> loadChildrenFromFileEntry() throws IOException {
148 File tmpFile = File.createTempFile("jd-gui.", "." + fsPath.getFileName().toString());
159 StringBuilder suffix = new StringBuilder(".").append(TIMESTAMP).append('.').append(tmpFileCounter++).append('.').append(fsPath.getFileName().toString());
160 File tmpFile = File.createTempFile("jd-gui.tmp.", suffix.toString());
149161 Path tmpPath = Paths.get(tmpFile.toURI());
150162
151163 tmpFile.delete();
165177 Container container = containerFactory.make(api, this, rootPath);
166178
167179 if (container != null) {
168 tmpFile.delete();
169180 return container.getRoot().getChildren();
170181 }
171182 }