use of org.pentaho.vfs.ui.VfsFileChooserDialog in project pentaho-kettle by pentaho.
the class VfsFileChooserControls method browseForFileInputPath.
protected void browseForFileInputPath() {
try {
String path = space.environmentSubstitute(wPath.getText());
VfsFileChooserDialog fileChooserDialog;
String fileName;
if (path == null || path.length() == 0) {
fileChooserDialog = getVfsFileChooserDialog(null, null);
fileName = selectedVFSScheme.scheme + "://";
} else {
FileObject initialFile = getInitialFile(wPath.getText());
FileObject rootFile = initialFile.getFileSystem().getRoot();
fileChooserDialog = getVfsFileChooserDialog(rootFile, initialFile);
fileName = null;
}
FileObject selectedFile = fileChooserDialog.open(getParent().getShell(), null, selectedVFSScheme.scheme, true, fileName, FILES_FILTERS, fileFilterNames, true, VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE_OR_DIRECTORY, true, true);
if (selectedFile != null) {
String filePath = selectedFile.getURL().toString();
if (!DEFAULT_LOCAL_PATH.equals(filePath)) {
wPath.setText(filePath);
updateLocation();
}
}
} catch (KettleFileException | FileSystemException ex) {
log.logError(ex.getMessage());
}
}
use of org.pentaho.vfs.ui.VfsFileChooserDialog in project pentaho-kettle by pentaho.
the class SimpleMappingDialog method selectFileTrans.
private void selectFileTrans() {
String curFile = transMeta.environmentSubstitute(wPath.getText());
FileObject root = null;
String parentFolder = null;
try {
parentFolder = KettleVFS.getFileObject(transMeta.environmentSubstitute(transMeta.getFilename())).getParent().toString();
} catch (Exception e) {
// Take no action
}
try {
root = KettleVFS.getFileObject(curFile != null ? curFile : Const.getUserHomeDirectory());
VfsFileChooserDialog vfsFileChooser = Spoon.getInstance().getVfsFileChooserDialog(root.getParent(), root);
FileObject file = vfsFileChooser.open(shell, null, Const.STRING_TRANS_FILTER_EXT, Const.getTransformationFilterNames(), VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE);
if (file == null) {
return;
}
String fileName = file.getName().toString();
if (fileName != null) {
loadFileTrans(fileName);
if (parentFolder != null && fileName.startsWith(parentFolder)) {
fileName = fileName.replace(parentFolder, "${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}");
}
wPath.setText(fileName);
specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
}
} catch (IOException | KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "SimpleMappingDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "SimpleMappingDialog.ErrorLoadingTransformation.DialogMessage"), e);
}
}
Aggregations