Author: rwhitcomb
Date: Sun Jan 31 23:45:36 2016
New Revision: 1727872
URL: http://svn.apache.org/viewvc?rev=1727872&view=rev
Log:
PIVOT-982: Any file name typed into the Save As mode file name input
for a VFS Browser Sheet would reject it with the field flagged as an
error. This was bascially because code ported from the regular file
browser didn't do the right thing to resolve the file and ended up
with a "file://" URL (for a local file) rather than a URL on the
remote host. Using the current base directory to resolve the name
results in correct behavior for at least the normal cases.
This hasn't really been tested yet with other edge cases.
Modified:
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin.java
Modified:
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin.java?rev=1727872&r1=1727871&r2=1727872&view=diff
==============================================================================
---
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin.java
(original)
+++
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSheetSkin.java
Sun Jan 31 23:45:36 2016
@@ -371,39 +371,21 @@ public class TerraVFSBrowserSheetSkin ex
String fileName = saveAsTextInput.getText();
// Contents of the entry field could be:
// 1. Just a new file name in the current root
directory
- // 2. A relative or absolute path that is an existing
- // directory
- // to navigate to
- // 3. A relative or absolute path including the new
file
- // name
- // in an existing directory
- // So, first make it an absolute path
- // TODO: all this logic needs changing (not sure how)
- // with VFS
- // because you could type in a whole new URI and have
to
- // change
- // managers
+ // 2. A relative or absolute path that is an existing
directory
+ // to navigate to
+ // 3. A relative or absolute path including the new
file name
+ // in an existing directory
+ // But, almost none of this is easy to do in the VFS
realm,
+ // so, we are just going to assume that it is relative
to the
+ // current location and let the chips fall ...
try {
- FileObject selectedFile =
manager.resolveFile(fileName);
+ FileObject selectedFile =
manager.resolveFile(fileBrowser.getRootDirectory(), fileName);
// if (!selectedFile.isAbsolute() &&
// !fileName.startsWith(File.separator)) {
- if (baseFileName == null
- ||
!baseFileName.isAncestor(selectedFile.getName())) {
- selectedFile =
manager.resolveFile(fileBrowser.getRootDirectory(),
- fileName);
- } else {
- // TODO: is there really anything to do here?
- // selectedFile =
- // selectedFile.getAbsoluteFile();
- }
if (selectedFile.exists() &&
selectedFile.getType() == FileType.FOLDER) {
try {
- // TODO: what to do about canonical file
- // representations?
- FileObject root = /*
- * selectedFile.
- * getCanonicalFile();
- */selectedFile;
+ // TODO: what to do about canonical file
representations?
+ FileObject root = /*
selectedFile.getCanonicalFile(); */ selectedFile;
fileBrowserSheet.setRootDirectory(root);
fileBrowser.setRootDirectory(root);
setHostLabel(root);
@@ -415,8 +397,7 @@ public class TerraVFSBrowserSheetSkin ex
vote = Vote.DENY;
} else {
FileObject root = selectedFile.getParent();
- if (root != null && root.exists()
- && root.getType() == FileType.FOLDER) {
+ if (root != null && root.exists() &&
root.getType() == FileType.FOLDER) {
try {
// TODO: canonical file again
//
fileBrowserSheet.setRootDirectory(root.getCanonicalFile());