mirror of
https://github.com/java-decompiler/jd-gui.git
synced 2024-11-27 06:20:31 +00:00
Fix problem on "Select Location" popup
This commit is contained in:
parent
15c2f61a73
commit
63bafdc938
@ -69,12 +69,9 @@ public class SelectLocationController {
|
||||
filteredContainerWrappers.add(new FilteredContainerWrapper(container, getOuterEntries(mapEntry.getValue())));
|
||||
}
|
||||
|
||||
selectLocationView.show(
|
||||
location, filteredContainerWrappers, entries.size(),
|
||||
new Consumer<URI>() {
|
||||
@Override public void accept(URI uri) { onLocationSelected(filteredContainerWrappers, uri, selectedLocationCallback); }
|
||||
},
|
||||
closeCallback);
|
||||
Consumer<URI> selectedEntryCallback = uri -> onLocationSelected(filteredContainerWrappers, uri, selectedLocationCallback);
|
||||
|
||||
selectLocationView.show(location, filteredContainerWrappers, entries.size(), selectedEntryCallback, closeCallback);
|
||||
}
|
||||
|
||||
protected Collection<Container.Entry> getOuterEntries(Collection<Container.Entry> entries) {
|
||||
|
@ -14,6 +14,8 @@ import java.net.URI;
|
||||
import java.util.*;
|
||||
|
||||
public class FilteredContainerWrapper implements Container {
|
||||
protected static final URI DEFAULT_ROOT_URI = URI.create("file:.");
|
||||
|
||||
protected Container container;
|
||||
protected EntryWrapper root;
|
||||
|
||||
@ -48,11 +50,12 @@ public class FilteredContainerWrapper implements Container {
|
||||
return entryWrapper;
|
||||
}
|
||||
|
||||
protected ContainerWrapper getContainerWrapper(Container.Entry entry) {
|
||||
URI uri = entry.getContainer().getRoot().getUri();
|
||||
protected ContainerWrapper getContainerWrapper(Container container) {
|
||||
Entry root = container.getRoot();
|
||||
URI uri = (root == null) ? DEFAULT_ROOT_URI : root.getUri();
|
||||
ContainerWrapper containerWrapper = uriToContainerWrapper.get(uri);
|
||||
if (containerWrapper == null) {
|
||||
uriToContainerWrapper.put(uri, containerWrapper=new ContainerWrapper(entry.getContainer()));
|
||||
uriToContainerWrapper.put(uri, containerWrapper=new ContainerWrapper(container));
|
||||
}
|
||||
return containerWrapper;
|
||||
}
|
||||
@ -65,7 +68,7 @@ public class FilteredContainerWrapper implements Container {
|
||||
this.entry = entry;
|
||||
}
|
||||
|
||||
@Override public Container getContainer() { return getContainerWrapper(entry.getContainer().getRoot()); }
|
||||
@Override public Container getContainer() { return getContainerWrapper(entry.getContainer()); }
|
||||
@Override public Entry getParent() { return getEntryWrapper(entry.getParent()); }
|
||||
@Override public URI getUri() { return entry.getUri(); }
|
||||
@Override public String getPath() { return entry.getPath(); }
|
||||
|
@ -24,18 +24,28 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class GenericContainer implements Container {
|
||||
protected static final long TIMESTAMP = System.currentTimeMillis();
|
||||
|
||||
protected static long tmpFileCounter = 0;
|
||||
|
||||
protected API api;
|
||||
protected int rootNameCount;
|
||||
protected Container.Entry root;
|
||||
|
||||
public GenericContainer(API api, Container.Entry parentEntry, Path rootPath) {
|
||||
this.api = api;
|
||||
this.rootNameCount = rootPath.getNameCount();
|
||||
this.root = new Entry(parentEntry, rootPath, parentEntry.getUri()) {
|
||||
public Entry newChildEntry(Path fsPath) {
|
||||
return new Entry(parent, fsPath, null);
|
||||
}
|
||||
};
|
||||
try {
|
||||
URI uri = parentEntry.getUri();
|
||||
|
||||
this.api = api;
|
||||
this.rootNameCount = rootPath.getNameCount();
|
||||
this.root = new Entry(parentEntry, rootPath, new URI(uri.getScheme(), uri.getHost(), uri.getPath() + "!/", null)) {
|
||||
public Entry newChildEntry(Path fsPath) {
|
||||
return new Entry(parent, fsPath, null);
|
||||
}
|
||||
};
|
||||
} catch (URISyntaxException e) {
|
||||
assert ExceptionUtil.printStackTrace(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getType() { return "generic"; }
|
||||
@ -66,7 +76,8 @@ public class GenericContainer implements Container {
|
||||
public URI getUri() {
|
||||
if (uri == null) {
|
||||
try {
|
||||
uri = new URI(root.getUri().getScheme(), root.getUri().getHost(), root.getUri().getPath() + "!/" + getPath(), null);
|
||||
URI rootUri = root.getUri();
|
||||
uri = new URI(rootUri.getScheme(), rootUri.getHost(), rootUri.getPath() + getPath(), null);
|
||||
} catch (URISyntaxException e) {
|
||||
assert ExceptionUtil.printStackTrace(e);
|
||||
}
|
||||
@ -146,7 +157,8 @@ public class GenericContainer implements Container {
|
||||
}
|
||||
|
||||
protected Collection<Container.Entry> loadChildrenFromFileEntry() throws IOException {
|
||||
File tmpFile = File.createTempFile("jd-gui.", "." + fsPath.getFileName().toString());
|
||||
StringBuilder suffix = new StringBuilder(".").append(TIMESTAMP).append('.').append(tmpFileCounter++).append('.').append(fsPath.getFileName().toString());
|
||||
File tmpFile = File.createTempFile("jd-gui.tmp.", suffix.toString());
|
||||
Path tmpPath = Paths.get(tmpFile.toURI());
|
||||
|
||||
tmpFile.delete();
|
||||
@ -166,7 +178,6 @@ public class GenericContainer implements Container {
|
||||
Container container = containerFactory.make(api, this, rootPath);
|
||||
|
||||
if (container != null) {
|
||||
tmpFile.delete();
|
||||
return container.getRoot().getChildren();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user