Skip to content

Commit

Permalink
MoleculeArchiveOpenDialog: fix url path formation bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
karlduderstadt committed Aug 3, 2023
1 parent a1549fe commit cd4b3c4
Showing 1 changed file with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,18 @@ public void clearRecent() {
}

public void ok() {
String url;
// check if we can skip explicit dataset detection
if (containerTree.getSelectionCount() == 0) {
containerPathUpdateCallback.accept(getPath());
url = getPath();
} else {
// archive was selected by the user
String fullPath = ((MoleculeArchiveSwingTreeNode)containerTree.getLastSelectedPathComponent()).getPath();
if (fullPath.startsWith("//")) fullPath = fullPath.substring(1, fullPath.length());
String url = getPath();
containerPathUpdateCallback.accept(getPath());

if (fullPath.startsWith(getPath())) url = fullPath;
else {
String uri = (getPath().endsWith(source.getGroupSeparator())) ? getPath().substring(0, getPath().length()-1) : getPath();
if (uri.endsWith("." + MoleculeArchiveSource.MOLECULE_ARCHIVE_ENDING) || uri.endsWith("." + MoleculeArchiveSource.MOLECULE_ARCHIVE_STORE_ENDING))
url = uri;
else
url = uri + fullPath;
}
if (!url.endsWith("." + MoleculeArchiveSource.MOLECULE_ARCHIVE_ENDING)
&& !url.endsWith("." + MoleculeArchiveSource.MOLECULE_ARCHIVE_STORE_ENDING) && containerTree.getSelectionCount() != 0) {
String nodeName = ((MoleculeArchiveSwingTreeNode)containerTree.getLastSelectedPathComponent()).getNodeName();
if (!url.endsWith("/")) url = url + "/";
url = url + nodeName;
}

if (url.endsWith("." + MoleculeArchiveSource.MOLECULE_ARCHIVE_ENDING) || url.endsWith("." + MoleculeArchiveSource.MOLECULE_ARCHIVE_STORE_ENDING)) {
System.out.println(url);
okCallback.accept(new MoleculeArchiveSelection(url));

if (recentURLs.contains(url))
Expand Down

0 comments on commit cd4b3c4

Please sign in to comment.