Example usage for org.apache.commons.vfs FileObject getParent

List of usage examples for org.apache.commons.vfs FileObject getParent

Introduction

In this page you can find the example usage for org.apache.commons.vfs FileObject getParent.

Prototype

public FileObject getParent() throws FileSystemException;

Source Link

Document

Returns the folder that contains this file.

Usage

From source file:org.pentaho.di.ui.trans.steps.metainject.MetaInjectDialog.java

private void selectFileTrans(boolean useVfs) {
    String curFile = wFilename.getText();

    if (useVfs) {
        FileObject root = null;

        try {/*from ww  w .j  a  va  2s.  c  o m*/
            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 fname = null;

            fname = file.getURL().getFile();

            if (fname != null) {

                loadFileTrans(fname);
                wFilename.setText(injectTransMeta.getFilename());
                wTransname.setText(Const.NVL(injectTransMeta.getName(), ""));
                wDirectory.setText("");
                specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
                setRadioButtons();
            }
        } catch (IOException e) {
            new ErrorDialog(shell,
                    BaseMessages.getString(PKG, "MetaInjectDialog.ErrorLoadingTransformation.DialogTitle"),
                    BaseMessages.getString(PKG, "MetaInjectDialog.ErrorLoadingTransformation.DialogMessage"),
                    e);
        } catch (KettleException e) {
            new ErrorDialog(shell,
                    BaseMessages.getString(PKG, "MetaInjectDialog.ErrorLoadingTransformation.DialogTitle"),
                    BaseMessages.getString(PKG, "MetaInjectDialog.ErrorLoadingTransformation.DialogMessage"),
                    e);
        }
    }

    // else: Local file open dialog, ask for .ktr & xml files...

}

From source file:org.pentaho.di.ui.trans.steps.simplemapping.SimpleMappingDialog.java

private void selectFileTrans() {
    String curFile = wFilename.getText();
    FileObject root = null;

    try {//from ww  w  .  j a va2  s .  c om
        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 fname = null;

        fname = file.getURL().getFile();

        if (fname != null) {

            loadFileTrans(fname);
            wFilename.setText(mappingTransMeta.getFilename());
            wTransname.setText(Const.NVL(mappingTransMeta.getName(), ""));
            wDirectory.setText("");
            setSpecificationMethod(ObjectLocationSpecificationMethod.FILENAME);
            setRadioButtons();
        }
    } catch (IOException e) {
        new ErrorDialog(shell,
                BaseMessages.getString(PKG, "SimpleMappingDialog.ErrorLoadingTransformation.DialogTitle"),
                BaseMessages.getString(PKG, "SimpleMappingDialog.ErrorLoadingTransformation.DialogMessage"), e);
    } catch (KettleException e) {
        new ErrorDialog(shell,
                BaseMessages.getString(PKG, "SimpleMappingDialog.ErrorLoadingTransformation.DialogTitle"),
                BaseMessages.getString(PKG, "SimpleMappingDialog.ErrorLoadingTransformation.DialogMessage"), e);
    }
}

From source file:org.pentaho.di.ui.trans.steps.singlethreader.SingleThreaderDialog.java

private void selectFileTrans() {
    String curFile = wFilename.getText();
    FileObject root = null;

    try {/*from   w  ww .j  a  va  2 s .c om*/
        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 fname = null;

        fname = file.getURL().getFile();

        if (fname != null) {

            loadFileTrans(fname);
            wFilename.setText(mappingTransMeta.getFilename());
            wTransname.setText(Const.NVL(mappingTransMeta.getName(), ""));
            wDirectory.setText("");
            specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
            setRadioButtons();
        }
    } catch (IOException e) {
        new ErrorDialog(shell,
                BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorLoadingTransformation.DialogTitle"),
                BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorLoadingTransformation.DialogMessage"),
                e);
    } catch (KettleException e) {
        new ErrorDialog(shell,
                BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorLoadingTransformation.DialogTitle"),
                BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorLoadingTransformation.DialogMessage"),
                e);
    }
}

From source file:org.pentaho.di.ui.trans.steps.transexecutor.TransExecutorDialog.java

private void selectFileTrans() {
    String curFile = wFilename.getText();
    FileObject root = null;

    try {//from   w ww . j  a va2  s  . c o  m
        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 fname = null;

        fname = file.getURL().getFile();

        if (fname != null) {

            loadFileTrans(fname);
            wFilename.setText(fname);
            wTransname.setText(Const.NVL(executorTransMeta.getName(), ""));
            wDirectory.setText("");
            specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
            setRadioButtons();
        }
    } catch (IOException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "TransExecutorDialog.ErrorLoadingTrans.DialogTitle"),
                BaseMessages.getString(PKG, "TransExecutorDialog.ErrorLoadingTrans.DialogMessage"), e);
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "TransExecutorDialog.ErrorLoadingTrans.DialogTitle"),
                BaseMessages.getString(PKG, "TransExecutorDialog.ErrorLoadingTrans.DialogMessage"), e);
    }
}