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

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

Introduction

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

Prototype

public URL getURL() throws FileSystemException;

Source Link

Document

Returns a URL representing this file.

Usage

From source file:org.pentaho.di.trans.steps.mail.Mail.java

private void addAttachedFilePart(FileObject file) throws Exception {
    // create a data source

    MimeBodyPart files = new MimeBodyPart();
    // create a data source
    URLDataSource fds = new URLDataSource(file.getURL());
    // get a data Handler to manipulate this file type;
    files.setDataHandler(new DataHandler(fds));
    // include the file in the data source
    files.setFileName(file.getName().getBaseName());
    // insist on base64 to preserve line endings
    files.addHeader("Content-Transfer-Encoding", "base64");
    // add the part with the file in the BodyPart();
    data.parts.addBodyPart(files);//  ww w . j  av a  2 s .co m
    if (isDetailed()) {
        logDetailed(BaseMessages.getString(PKG, "Mail.Log.AttachedFile", fds.getName()));
    }

}

From source file:org.pentaho.di.trans.TransMeta.java

/**
 * Exports the specified objects to a flat-file system, adding content with filename keys to a set of definitions. The
 * supplied resource naming interface allows the object to name appropriately without worrying about those parts of
 * the implementation specific details./*from www  . ja v  a 2 s. c  o m*/
 *
 * @param space
 *          the variable space to use
 * @param definitions
 * @param resourceNamingInterface
 * @param repository
 *          The repository to optionally load other resources from (to be converted to XML)
 * @param metaStore
 *          the metaStore in which non-kettle metadata could reside.
 *
 * @return the filename of the exported resource
 */
public String exportResources(VariableSpace space, Map<String, ResourceDefinition> definitions,
        ResourceNamingInterface resourceNamingInterface, Repository repository, IMetaStore metaStore)
        throws KettleException {

    try {
        // Handle naming for both repository and XML bases resources...
        //
        String baseName;
        String originalPath;
        String fullname;
        String extension = "ktr";
        if (Const.isEmpty(getFilename())) {
            // Assume repository...
            //
            originalPath = directory.getPath();
            baseName = getName();
            fullname = directory.getPath()
                    + (directory.getPath().endsWith(RepositoryDirectory.DIRECTORY_SEPARATOR) ? ""
                            : RepositoryDirectory.DIRECTORY_SEPARATOR)
                    + getName() + "." + extension; //
        } else {
            // Assume file
            //
            FileObject fileObject = KettleVFS.getFileObject(space.environmentSubstitute(getFilename()), space);
            originalPath = fileObject.getParent().getURL().toString();
            baseName = fileObject.getName().getBaseName();
            fullname = fileObject.getURL().toString();
        }

        String exportFileName = resourceNamingInterface.nameResource(baseName, originalPath, extension,
                ResourceNamingInterface.FileNamingType.TRANSFORMATION);
        ResourceDefinition definition = definitions.get(exportFileName);
        if (definition == null) {
            // If we do this once, it will be plenty :-)
            //
            TransMeta transMeta = (TransMeta) this.realClone(false);
            // transMeta.copyVariablesFrom(space);

            // Add used resources, modify transMeta accordingly
            // Go through the list of steps, etc.
            // These critters change the steps in the cloned TransMeta
            // At the end we make a new XML version of it in "exported"
            // format...

            // loop over steps, databases will be exported to XML anyway.
            //
            for (StepMeta stepMeta : transMeta.getSteps()) {
                stepMeta.exportResources(space, definitions, resourceNamingInterface, repository, metaStore);
            }

            // Change the filename, calling this sets internal variables
            // inside of the transformation.
            //
            transMeta.setFilename(exportFileName);

            // All objects get re-located to the root folder
            //
            transMeta.setRepositoryDirectory(new RepositoryDirectory());

            // Set a number of parameters for all the data files referenced so far...
            //
            Map<String, String> directoryMap = resourceNamingInterface.getDirectoryMap();
            if (directoryMap != null) {
                for (String directory : directoryMap.keySet()) {
                    String parameterName = directoryMap.get(directory);
                    transMeta.addParameterDefinition(parameterName, directory,
                            "Data file path discovered during export");
                }
            }

            // At the end, add ourselves to the map...
            //
            String transMetaContent = transMeta.getXML();

            definition = new ResourceDefinition(exportFileName, transMetaContent);

            // Also remember the original filename (if any), including variables etc.
            //
            if (Const.isEmpty(this.getFilename())) { // Repository
                definition.setOrigin(fullname);
            } else {
                definition.setOrigin(this.getFilename());
            }

            definitions.put(fullname, definition);
        }
        return exportFileName;
    } catch (FileSystemException e) {
        throw new KettleException(BaseMessages.getString(PKG,
                "TransMeta.Exception.ErrorOpeningOrValidatingTheXMLFile", getFilename()), e);
    } catch (KettleFileException e) {
        throw new KettleException(BaseMessages.getString(PKG,
                "TransMeta.Exception.ErrorOpeningOrValidatingTheXMLFile", getFilename()), e);
    }
}

From source file:org.pentaho.di.ui.job.entries.fileexists.JobEntryFileExistsDialog.java

public JobEntryInterface open() {
    Shell parent = getParent();//from   w w w.  j  ava2 s  . c  o m
    Display display = parent.getDisplay();

    shell = new Shell(parent, props.getJobsDialogStyle());
    props.setLook(shell);
    JobDialog.setShellImage(shell, jobEntry);

    ModifyListener lsMod = new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            jobEntry.setChanged();
        }
    };
    changed = jobEntry.hasChanged();

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "JobFileExists.Title"));

    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    // Filename line
    wlName = new Label(shell, SWT.RIGHT);
    wlName.setText(BaseMessages.getString(PKG, "JobFileExists.Name.Label"));
    props.setLook(wlName);
    fdlName = new FormData();
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, -margin);
    fdlName.top = new FormAttachment(0, margin);
    wlName.setLayoutData(fdlName);
    wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wName);
    wName.addModifyListener(lsMod);
    fdName = new FormData();
    fdName.left = new FormAttachment(middle, 0);
    fdName.top = new FormAttachment(0, margin);
    fdName.right = new FormAttachment(100, 0);
    wName.setLayoutData(fdName);

    // Filename line
    wlFilename = new Label(shell, SWT.RIGHT);
    wlFilename.setText(BaseMessages.getString(PKG, "JobFileExists.Filename.Label"));
    props.setLook(wlFilename);
    fdlFilename = new FormData();
    fdlFilename.left = new FormAttachment(0, 0);
    fdlFilename.top = new FormAttachment(wName, margin);
    fdlFilename.right = new FormAttachment(middle, -margin);
    wlFilename.setLayoutData(fdlFilename);

    wbFilename = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbFilename);
    wbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
    fdbFilename = new FormData();
    fdbFilename.right = new FormAttachment(100, 0);
    fdbFilename.top = new FormAttachment(wName, 0);
    // fdbFilename.height = 22;
    wbFilename.setLayoutData(fdbFilename);

    wFilename = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wFilename);
    wFilename.addModifyListener(lsMod);
    fdFilename = new FormData();
    fdFilename.left = new FormAttachment(middle, 0);
    fdFilename.top = new FormAttachment(wName, margin);
    fdFilename.right = new FormAttachment(wbFilename, -margin);
    wFilename.setLayoutData(fdFilename);

    // Whenever something changes, set the tooltip to the expanded version:
    wFilename.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            wFilename.setToolTipText(jobMeta.environmentSubstitute(wFilename.getText()));
        }
    });

    wbFilename.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            try {
                FileObject fileName = null;

                try {
                    String curFile = wFilename.getText();

                    if (curFile.trim().length() > 0) {
                        fileName = KettleVFS.getInstance().getFileSystemManager()
                                .resolveFile(jobMeta.environmentSubstitute(wFilename.getText()));
                    } else {
                        fileName = KettleVFS.getInstance().getFileSystemManager()
                                .resolveFile(Const.getUserHomeDirectory());
                    }

                } catch (FileSystemException ex) {
                    fileName = KettleVFS.getInstance().getFileSystemManager()
                            .resolveFile(Const.getUserHomeDirectory());
                }

                VfsFileChooserDialog vfsFileChooser = Spoon.getInstance()
                        .getVfsFileChooserDialog(fileName.getParent(), fileName);

                FileObject selected = vfsFileChooser.open(shell, null, EXTENSIONS, FILETYPES,
                        VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE);
                wFilename.setText(selected != null ? selected.getURL().toString() : Const.EMPTY_STRING);
            } catch (FileSystemException ex) {
                ex.printStackTrace();
            }
        }
    });

    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    FormData fd = new FormData();
    fd.right = new FormAttachment(50, -10);
    fd.bottom = new FormAttachment(100, 0);
    fd.width = 100;
    wOK.setLayoutData(fd);

    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    fd = new FormData();
    fd.left = new FormAttachment(50, 10);
    fd.bottom = new FormAttachment(100, 0);
    fd.width = 100;
    wCancel.setLayoutData(fd);

    BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, wFilename);
    // Add listeners
    lsCancel = new Listener() {
        public void handleEvent(Event e) {
            cancel();
        }
    };
    lsOK = new Listener() {
        public void handleEvent(Event e) {
            ok();
        }
    };

    wCancel.addListener(SWT.Selection, lsCancel);
    wOK.addListener(SWT.Selection, lsOK);

    lsDef = new SelectionAdapter() {
        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };

    wName.addSelectionListener(lsDef);
    wFilename.addSelectionListener(lsDef);

    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {
        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });

    getData();

    BaseStepDialog.setSize(shell);

    shell.open();
    props.setDialogSize(shell, "JobFileExistsDialogSize");
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return jobEntry;
}

From source file:org.pentaho.di.ui.job.entries.hadoopcopyfiles.JobEntryHadoopCopyFilesDialog.java

private FileObject setSelectedFile(TextVar textVar) {

    FileObject selectedFile = null;

    try {//from w  w  w  . j a va 2  s  .co m
        // Get current file
        FileObject rootFile = null;
        FileObject initialFile = null;
        FileObject defaultInitialFile = null;

        if (textVar.getText() != null) {

            String fileName = jobMeta.environmentSubstitute(textVar.getText());

            if (fileName != null && !fileName.equals("")) {
                initialFile = KettleVFS.getFileObject(fileName);
                defaultInitialFile = KettleVFS.getFileObject("file:///c:/");
                rootFile = initialFile.getFileSystem().getRoot();
            } else {
                defaultInitialFile = KettleVFS.getFileObject(Spoon.getInstance().getLastFileOpened());
            }
        }

        if (rootFile == null) {
            rootFile = defaultInitialFile.getFileSystem().getRoot();
            initialFile = defaultInitialFile;
        }
        VfsFileChooserDialog fileChooserDialog = Spoon.getInstance().getVfsFileChooserDialog(rootFile,
                initialFile);
        fileChooserDialog.defaultInitialFile = defaultInitialFile;
        selectedFile = fileChooserDialog.open(shell, null, HadoopSpoonPlugin.HDFS_SCHEME, true, null,
                new String[] { "*.*" }, FILETYPES, VfsFileChooserDialog.VFS_DIALOG_OPEN_DIRECTORY);

        if (selectedFile != null) {
            textVar.setText(selectedFile.getURL().toString());
        }

        return selectedFile;

    } catch (KettleFileException ex) {
        log.logError(BaseMessages.getString(PKG, "HadoopFileInputDialog.FileBrowser.KettleFileException"));
        return selectedFile;
    } catch (FileSystemException ex) {
        log.logError(BaseMessages.getString(PKG, "HadoopFileInputDialog.FileBrowser.FileSystemException"));
        return selectedFile;
    }
}

From source file:org.pentaho.di.ui.job.entries.pgpverify.JobEntryPGPVerifyDialog.java

public JobEntryInterface open() {
    Shell parent = getParent();//from w  ww.ja v  a  2 s  .  co  m
    Display display = parent.getDisplay();

    shell = new Shell(parent, props.getJobsDialogStyle());
    props.setLook(shell);
    JobDialog.setShellImage(shell, jobEntry);

    ModifyListener lsMod = new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            jobEntry.setChanged();
        }
    };
    changed = jobEntry.hasChanged();

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "JobPGPVerify.Title"));

    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    // GPGLocation line
    wlName = new Label(shell, SWT.RIGHT);
    wlName.setText(BaseMessages.getString(PKG, "JobPGPVerify.Name.Label"));
    props.setLook(wlName);
    fdlName = new FormData();
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, -margin);
    fdlName.top = new FormAttachment(0, margin);
    wlName.setLayoutData(fdlName);
    wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wName);
    wName.addModifyListener(lsMod);
    fdName = new FormData();
    fdName.left = new FormAttachment(middle, 0);
    fdName.top = new FormAttachment(0, margin);
    fdName.right = new FormAttachment(100, 0);
    wName.setLayoutData(fdName);

    // ////////////////////////
    // START OF SERVER SETTINGS GROUP///
    // /
    wSettings = new Group(shell, SWT.SHADOW_NONE);
    props.setLook(wSettings);
    wSettings.setText(BaseMessages.getString(PKG, "JobPGPVerify.Settings.Group.Label"));

    FormLayout SettingsgroupLayout = new FormLayout();
    SettingsgroupLayout.marginWidth = 10;
    SettingsgroupLayout.marginHeight = 10;

    wSettings.setLayout(SettingsgroupLayout);

    // GPGLocation line
    wlGPGLocation = new Label(wSettings, SWT.RIGHT);
    wlGPGLocation.setText(BaseMessages.getString(PKG, "JobPGPVerify.GPGLocation.Label"));
    props.setLook(wlGPGLocation);
    fdlGPGLocation = new FormData();
    fdlGPGLocation.left = new FormAttachment(0, 0);
    fdlGPGLocation.top = new FormAttachment(wName, margin);
    fdlGPGLocation.right = new FormAttachment(middle, -margin);
    wlGPGLocation.setLayoutData(fdlGPGLocation);

    wbGPGLocation = new Button(wSettings, SWT.PUSH | SWT.CENTER);
    props.setLook(wbGPGLocation);
    wbGPGLocation.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
    fdbGPGLocation = new FormData();
    fdbGPGLocation.right = new FormAttachment(100, 0);
    fdbGPGLocation.top = new FormAttachment(wName, 0);
    wbGPGLocation.setLayoutData(fdbGPGLocation);

    wGPGLocation = new TextVar(jobMeta, wSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wGPGLocation);
    wGPGLocation.addModifyListener(lsMod);
    fdGPGLocation = new FormData();
    fdGPGLocation.left = new FormAttachment(middle, 0);
    fdGPGLocation.top = new FormAttachment(wName, margin);
    fdGPGLocation.right = new FormAttachment(wbGPGLocation, -margin);
    wGPGLocation.setLayoutData(fdGPGLocation);

    // Filename line
    wlFilename = new Label(wSettings, SWT.RIGHT);
    wlFilename.setText(BaseMessages.getString(PKG, "JobPGPVerify.Filename.Label"));
    props.setLook(wlFilename);
    fdlFilename = new FormData();
    fdlFilename.left = new FormAttachment(0, 0);
    fdlFilename.top = new FormAttachment(wGPGLocation, margin);
    fdlFilename.right = new FormAttachment(middle, -margin);
    wlFilename.setLayoutData(fdlFilename);

    wbFilename = new Button(wSettings, SWT.PUSH | SWT.CENTER);
    props.setLook(wbFilename);
    wbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
    fdbFilename = new FormData();
    fdbFilename.right = new FormAttachment(100, 0);
    fdbFilename.top = new FormAttachment(wGPGLocation, 0);
    wbFilename.setLayoutData(fdbFilename);

    wFilename = new TextVar(jobMeta, wSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wFilename);
    wFilename.addModifyListener(lsMod);
    fdFilename = new FormData();
    fdFilename.left = new FormAttachment(middle, 0);
    fdFilename.top = new FormAttachment(wGPGLocation, margin);
    fdFilename.right = new FormAttachment(wbFilename, -margin);
    wFilename.setLayoutData(fdFilename);

    wluseDetachedSignature = new Label(wSettings, SWT.RIGHT);
    wluseDetachedSignature.setText(BaseMessages.getString(PKG, "JobPGPVerify.useDetachedSignature.Label"));
    props.setLook(wluseDetachedSignature);
    fdluseDetachedSignature = new FormData();
    fdluseDetachedSignature.left = new FormAttachment(0, 0);
    fdluseDetachedSignature.top = new FormAttachment(wFilename, margin);
    fdluseDetachedSignature.right = new FormAttachment(middle, -margin);
    wluseDetachedSignature.setLayoutData(fdluseDetachedSignature);
    wuseDetachedSignature = new Button(wSettings, SWT.CHECK);
    props.setLook(wuseDetachedSignature);
    wuseDetachedSignature
            .setToolTipText(BaseMessages.getString(PKG, "JobPGPVerify.useDetachedSignature.Tooltip"));
    fduseDetachedSignature = new FormData();
    fduseDetachedSignature.left = new FormAttachment(middle, 0);
    fduseDetachedSignature.top = new FormAttachment(wFilename, margin);
    fduseDetachedSignature.right = new FormAttachment(100, -margin);
    wuseDetachedSignature.setLayoutData(fduseDetachedSignature);
    wuseDetachedSignature.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {

            enableDetachedSignature();

        }
    });

    // DetachedFilename line
    wlDetachedFilename = new Label(wSettings, SWT.RIGHT);
    wlDetachedFilename.setText(BaseMessages.getString(PKG, "JobPGPVerify.DetachedFilename.Label"));
    props.setLook(wlDetachedFilename);
    fdlDetachedFilename = new FormData();
    fdlDetachedFilename.left = new FormAttachment(0, 0);
    fdlDetachedFilename.top = new FormAttachment(wuseDetachedSignature, margin);
    fdlDetachedFilename.right = new FormAttachment(middle, -margin);
    wlDetachedFilename.setLayoutData(fdlDetachedFilename);

    wbDetachedFilename = new Button(wSettings, SWT.PUSH | SWT.CENTER);
    props.setLook(wbDetachedFilename);
    wbDetachedFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
    fdbDetachedFilename = new FormData();
    fdbDetachedFilename.right = new FormAttachment(100, 0);
    fdbDetachedFilename.top = new FormAttachment(wuseDetachedSignature, 0);
    wbDetachedFilename.setLayoutData(fdbDetachedFilename);

    wDetachedFilename = new TextVar(jobMeta, wSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wDetachedFilename);
    wDetachedFilename.addModifyListener(lsMod);
    fdDetachedFilename = new FormData();
    fdDetachedFilename.left = new FormAttachment(middle, 0);
    fdDetachedFilename.top = new FormAttachment(wuseDetachedSignature, margin);
    fdDetachedFilename.right = new FormAttachment(wbDetachedFilename, -margin);
    wDetachedFilename.setLayoutData(fdDetachedFilename);

    // Whenever something changes, set the tooltip to the expanded version:
    wDetachedFilename.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            wDetachedFilename.setToolTipText(jobMeta.environmentSubstitute(wDetachedFilename.getText()));
        }
    });

    wbDetachedFilename.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            try {
                FileObject DetachedFilename = null;

                try {
                    String curFile = wDetachedFilename.getText();

                    if (curFile.trim().length() > 0) {
                        DetachedFilename = KettleVFS.getInstance().getFileSystemManager()
                                .resolveFile(jobMeta.environmentSubstitute(wDetachedFilename.getText()));
                    } else {
                        DetachedFilename = KettleVFS.getInstance().getFileSystemManager()
                                .resolveFile(Const.getUserHomeDirectory());
                    }

                } catch (FileSystemException ex) {
                    DetachedFilename = KettleVFS.getInstance().getFileSystemManager()
                            .resolveFile(Const.getUserHomeDirectory());
                }

                VfsFileChooserDialog vfsFileChooser = Spoon.getInstance()
                        .getVfsFileChooserDialog(DetachedFilename.getParent(), DetachedFilename);

                FileObject selected = vfsFileChooser.open(shell, null, EXTENSIONS, FILETYPES,
                        VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE);
                wDetachedFilename.setText(selected != null ? selected.getURL().toString() : Const.EMPTY_STRING);
            } catch (FileSystemException ex) {
                ex.printStackTrace();
            }
        }
    });

    // Whenever something changes, set the tooltip to the expanded version:
    wFilename.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            wFilename.setToolTipText(jobMeta.environmentSubstitute(wFilename.getText()));
        }
    });

    wbFilename.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            try {
                FileObject fileName = null;

                try {
                    String curFile = wFilename.getText();

                    if (curFile.trim().length() > 0) {
                        fileName = KettleVFS.getInstance().getFileSystemManager()
                                .resolveFile(jobMeta.environmentSubstitute(wFilename.getText()));
                    } else {
                        fileName = KettleVFS.getInstance().getFileSystemManager()
                                .resolveFile(Const.getUserHomeDirectory());
                    }

                } catch (FileSystemException ex) {
                    fileName = KettleVFS.getInstance().getFileSystemManager()
                            .resolveFile(Const.getUserHomeDirectory());
                }

                VfsFileChooserDialog vfsFileChooser = Spoon.getInstance()
                        .getVfsFileChooserDialog(fileName.getParent(), fileName);

                FileObject selected = vfsFileChooser.open(shell, null, EXTENSIONS, FILETYPES,
                        VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE);
                wFilename.setText(selected != null ? selected.getURL().toString() : Const.EMPTY_STRING);
            } catch (FileSystemException ex) {
                ex.printStackTrace();
            }
        }
    });
    // Whenever something changes, set the tooltip to the expanded version:
    wGPGLocation.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            wGPGLocation.setToolTipText(jobMeta.environmentSubstitute(wGPGLocation.getText()));
        }
    });

    wbGPGLocation.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            try {
                FileObject fileName = null;

                try {
                    String curFile = wGPGLocation.getText();

                    if (curFile.trim().length() > 0) {
                        fileName = KettleVFS.getInstance().getFileSystemManager()
                                .resolveFile(jobMeta.environmentSubstitute(wGPGLocation.getText()));
                    } else {
                        fileName = KettleVFS.getInstance().getFileSystemManager()
                                .resolveFile(Const.getUserHomeDirectory());
                    }

                } catch (FileSystemException ex) {
                    fileName = KettleVFS.getInstance().getFileSystemManager()
                            .resolveFile(Const.getUserHomeDirectory());
                }

                VfsFileChooserDialog vfsFileChooser = Spoon.getInstance()
                        .getVfsFileChooserDialog(fileName.getParent(), fileName);

                FileObject selected = vfsFileChooser.open(shell, null, EXTENSIONS, FILETYPES,
                        VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE);
                wGPGLocation.setText(selected != null ? selected.getURL().toString() : Const.EMPTY_STRING);
            } catch (FileSystemException ex) {
                ex.printStackTrace();
            }
        }
    });
    fdSettings = new FormData();
    fdSettings.left = new FormAttachment(0, margin);
    fdSettings.top = new FormAttachment(wName, margin);
    fdSettings.right = new FormAttachment(100, -margin);
    wSettings.setLayoutData(fdSettings);
    // ///////////////////////////////////////////////////////////
    // / END OF Advanced SETTINGS GROUP
    // ///////////////////////////////////////////////////////////

    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    FormData fd = new FormData();
    fd.right = new FormAttachment(50, -10);
    fd.bottom = new FormAttachment(100, 0);
    fd.width = 100;
    wOK.setLayoutData(fd);

    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    fd = new FormData();
    fd.left = new FormAttachment(50, 10);
    fd.bottom = new FormAttachment(100, 0);
    fd.width = 100;
    wCancel.setLayoutData(fd);

    BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, wSettings);
    // Add listeners
    lsCancel = new Listener() {
        public void handleEvent(Event e) {
            cancel();
        }
    };
    lsOK = new Listener() {
        public void handleEvent(Event e) {
            ok();
        }
    };

    wCancel.addListener(SWT.Selection, lsCancel);
    wOK.addListener(SWT.Selection, lsOK);

    lsDef = new SelectionAdapter() {
        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };

    wName.addSelectionListener(lsDef);
    wGPGLocation.addSelectionListener(lsDef);

    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {
        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });

    getData();
    enableDetachedSignature();
    BaseStepDialog.setSize(shell);

    shell.open();
    props.setDialogSize(shell, "JobPGPVerifyDialogSize");
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return jobEntry;
}

From source file:org.pentaho.di.ui.job.entries.talendjobexec.JobEntryTalendJobExecDialog.java

public JobEntryInterface open() {
    Shell parent = getParent();/*from   w ww .  j  ava2 s. c o m*/
    Display display = parent.getDisplay();

    shell = new Shell(parent, props.getJobsDialogStyle());
    props.setLook(shell);
    JobDialog.setShellImage(shell, jobEntry);

    ModifyListener lsMod = new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            jobEntry.setChanged();
        }
    };
    changed = jobEntry.hasChanged();

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "JobEntryTalendJobExec.Title"));

    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    // Filename line
    wlName = new Label(shell, SWT.RIGHT);
    wlName.setText(BaseMessages.getString(PKG, "JobEntryTalendJobExec.Name.Label"));
    props.setLook(wlName);
    fdlName = new FormData();
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, -margin);
    fdlName.top = new FormAttachment(0, margin);
    wlName.setLayoutData(fdlName);
    wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wName);
    wName.addModifyListener(lsMod);
    fdName = new FormData();
    fdName.left = new FormAttachment(middle, 0);
    fdName.top = new FormAttachment(0, margin);
    fdName.right = new FormAttachment(100, 0);
    wName.setLayoutData(fdName);
    Control lastControl = wName;

    // Filename line
    wlFilename = new Label(shell, SWT.RIGHT);
    wlFilename.setText(BaseMessages.getString(PKG, "JobEntryTalendJobExec.Filename.Label"));
    props.setLook(wlFilename);
    fdlFilename = new FormData();
    fdlFilename.left = new FormAttachment(0, 0);
    fdlFilename.top = new FormAttachment(lastControl, margin);
    fdlFilename.right = new FormAttachment(middle, -margin);
    wlFilename.setLayoutData(fdlFilename);

    wbFilename = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbFilename);
    wbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
    fdbFilename = new FormData();
    fdbFilename.right = new FormAttachment(100, 0);
    fdbFilename.top = new FormAttachment(lastControl, 0);
    // fdbFilename.height = 22;
    wbFilename.setLayoutData(fdbFilename);

    wFilename = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wFilename);
    wFilename.addModifyListener(lsMod);
    fdFilename = new FormData();
    fdFilename.left = new FormAttachment(middle, 0);
    fdFilename.top = new FormAttachment(lastControl, margin);
    fdFilename.right = new FormAttachment(wbFilename, -margin);
    wFilename.setLayoutData(fdFilename);

    // Whenever something changes, set the tooltip to the expanded version:
    wFilename.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            wFilename.setToolTipText(jobMeta.environmentSubstitute(wFilename.getText()));
        }
    });

    wbFilename.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            try {
                FileObject fileName = null;

                try {
                    String curFile = wFilename.getText();

                    if (curFile.trim().length() > 0) {
                        fileName = KettleVFS.getInstance().getFileSystemManager()
                                .resolveFile(jobMeta.environmentSubstitute(wFilename.getText()));
                    } else {
                        fileName = KettleVFS.getInstance().getFileSystemManager()
                                .resolveFile(Const.getUserHomeDirectory());
                    }

                } catch (FileSystemException ex) {
                    fileName = KettleVFS.getInstance().getFileSystemManager()
                            .resolveFile(Const.getUserHomeDirectory());
                }

                VfsFileChooserDialog vfsFileChooser = Spoon.getInstance()
                        .getVfsFileChooserDialog(fileName.getParent(), fileName);

                FileObject selected = vfsFileChooser.open(shell, null, EXTENSIONS, FILETYPES,
                        VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE);
                wFilename.setText(selected != null ? selected.getURL().toString() : Const.EMPTY_STRING);
            } catch (FileSystemException ex) {
                ex.printStackTrace();
            }
        }
    });
    lastControl = wFilename;

    // Filename line
    Label wlClassName = new Label(shell, SWT.RIGHT);
    wlClassName.setText(BaseMessages.getString(PKG, "JobEntryTalendJobExec.ClassName.Label"));
    props.setLook(wlClassName);
    FormData fdlClassName = new FormData();
    fdlClassName.left = new FormAttachment(0, 0);
    fdlClassName.right = new FormAttachment(middle, -margin);
    fdlClassName.top = new FormAttachment(lastControl, margin);
    wlClassName.setLayoutData(fdlClassName);
    wClassName = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wClassName.setToolTipText(BaseMessages.getString(PKG, "JobEntryTalendJobExec.ClassName.Tooltip"));
    props.setLook(wClassName);
    wClassName.addModifyListener(lsMod);
    FormData fdClassName = new FormData();
    fdClassName.left = new FormAttachment(middle, 0);
    fdClassName.top = new FormAttachment(lastControl, margin);
    fdClassName.right = new FormAttachment(100, 0);
    wClassName.setLayoutData(fdClassName);
    lastControl = wClassName;

    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    FormData fd = new FormData();
    fd.right = new FormAttachment(50, -10);
    fd.bottom = new FormAttachment(100, 0);
    fd.width = 100;
    wOK.setLayoutData(fd);

    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    fd = new FormData();
    fd.left = new FormAttachment(50, 10);
    fd.bottom = new FormAttachment(100, 0);
    fd.width = 100;
    wCancel.setLayoutData(fd);

    BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, wClassName);
    // Add listeners
    lsCancel = new Listener() {
        public void handleEvent(Event e) {
            cancel();
        }
    };
    lsOK = new Listener() {
        public void handleEvent(Event e) {
            ok();
        }
    };

    wCancel.addListener(SWT.Selection, lsCancel);
    wOK.addListener(SWT.Selection, lsOK);

    lsDef = new SelectionAdapter() {
        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };

    wName.addSelectionListener(lsDef);
    wFilename.addSelectionListener(lsDef);

    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {
        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });

    getData();

    BaseStepDialog.setSize(shell);

    shell.open();
    props.setDialogSize(shell, "JobEntryTalendJobExec.DialogSize");
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return jobEntry;
}

From source file:org.pentaho.di.ui.trans.steps.accessoutput.AccessOutputDialog.java

private void getTableName() {
    AccessOutputMeta meta = new AccessOutputMeta();
    getInfo(meta);/*from   w  w w .  j  a  v  a  2 s . c  o m*/

    Database database = null;
    // New class: SelectTableDialog
    try {
        String realFilename = transMeta.environmentSubstitute(meta.getFilename());
        FileObject fileObject = KettleVFS.getFileObject(realFilename, transMeta);
        File file = FileUtils.toFile(fileObject.getURL());

        if (!file.exists() || !file.isFile()) {
            throw new KettleException(
                    BaseMessages.getString(PKG, "AccessOutputMeta.Exception.FileDoesNotExist", realFilename));
        }

        database = Database.open(file);
        Set<String> set = database.getTableNames();
        String[] tablenames = set.toArray(new String[set.size()]);
        EnterSelectionDialog dialog = new EnterSelectionDialog(shell, tablenames,
                BaseMessages.getString(PKG, "AccessOutputDialog.Dialog.SelectATable.Title"),
                BaseMessages.getString(PKG, "AccessOutputDialog.Dialog.SelectATable.Message"));
        String tablename = dialog.open();
        if (tablename != null) {
            wTablename.setText(tablename);
        }
    } catch (Throwable e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "AccessOutputDialog.UnableToGetListOfTables.Title"),
                BaseMessages.getString(PKG, "AccessOutputDialog.UnableToGetListOfTables.Message"), e);
    } finally {
        // Don't forget to close the bugger.
        try {
            if (database != null) {
                database.close();
            }
        } catch (Exception e) {
            // Ignore close errors
        }
    }
}

From source file:org.pentaho.di.ui.trans.steps.hadoopfileinput.HadoopFileInputDialog.java

public String open() {
    Shell parent = getParent();//from  www  .  j  a  va 2 s. co m
    Display display = parent.getDisplay();

    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
    props.setLook(shell);
    setShellImage(shell, input);

    lsMod = new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            input.setChanged();
        }
    };
    changed = input.hasChanged();

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "HadoopFileInputDialog.DialogTitle"));

    middle = props.getMiddlePct();
    margin = Const.MARGIN;

    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(BASE_PKG, "System.Label.StepName"));
    props.setLook(wlStepname);
    fdlStepname = new FormData();
    fdlStepname.left = new FormAttachment(0, 0);
    fdlStepname.top = new FormAttachment(0, margin);
    fdlStepname.right = new FormAttachment(middle, -margin);
    wlStepname.setLayoutData(fdlStepname);
    wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wStepname.setText(stepname);
    props.setLook(wStepname);
    wStepname.addModifyListener(lsMod);
    fdStepname = new FormData();
    fdStepname.left = new FormAttachment(middle, 0);
    fdStepname.top = new FormAttachment(0, margin);
    fdStepname.right = new FormAttachment(100, 0);
    wStepname.setLayoutData(fdStepname);

    wTabFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
    wTabFolder.setSimple(false);

    addFilesTab();
    addContentTab();
    addErrorTab();
    addFiltersTabs();
    addFieldsTabs();

    fdTabFolder = new FormData();
    fdTabFolder.left = new FormAttachment(0, 0);
    fdTabFolder.top = new FormAttachment(wStepname, margin);
    fdTabFolder.right = new FormAttachment(100, 0);
    fdTabFolder.bottom = new FormAttachment(100, -50);
    wTabFolder.setLayoutData(fdTabFolder);

    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(BASE_PKG, "System.Button.OK"));

    wPreview = new Button(shell, SWT.PUSH);
    wPreview.setText(BaseMessages.getString(BASE_PKG, "TextFileInputDialog.Preview.Button"));

    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(BASE_PKG, "System.Button.Cancel"));

    setButtonPositions(new Button[] { wOK, wPreview, wCancel }, margin, wTabFolder);

    // Add listeners
    lsOK = new Listener() {
        public void handleEvent(Event e) {
            ok();
        }
    };
    lsFirst = new Listener() {
        public void handleEvent(Event e) {
            first(false);
        }
    };
    lsFirstHeader = new Listener() {
        public void handleEvent(Event e) {
            first(true);
        }
    };
    lsGet = new Listener() {
        public void handleEvent(Event e) {
            get();
        }
    };
    lsPreview = new Listener() {
        public void handleEvent(Event e) {
            preview();
        }
    };
    lsCancel = new Listener() {
        public void handleEvent(Event e) {
            cancel();
        }
    };

    wOK.addListener(SWT.Selection, lsOK);
    wFirst.addListener(SWT.Selection, lsFirst);
    wFirstHeader.addListener(SWT.Selection, lsFirstHeader);
    wGet.addListener(SWT.Selection, lsGet);
    wPreview.addListener(SWT.Selection, lsPreview);
    wCancel.addListener(SWT.Selection, lsCancel);

    lsDef = new SelectionAdapter() {
        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };

    wAccFilenames.addSelectionListener(lsDef);
    wStepname.addSelectionListener(lsDef);
    // wFilename.addSelectionListener( lsDef );
    wSeparator.addSelectionListener(lsDef);
    wLimit.addSelectionListener(lsDef);
    wInclRownumField.addSelectionListener(lsDef);
    wInclFilenameField.addSelectionListener(lsDef);
    wNrHeader.addSelectionListener(lsDef);
    wNrFooter.addSelectionListener(lsDef);
    wNrWraps.addSelectionListener(lsDef);
    wWarnDestDir.addSelectionListener(lsDef);
    wWarnExt.addSelectionListener(lsDef);
    wErrorDestDir.addSelectionListener(lsDef);
    wErrorExt.addSelectionListener(lsDef);
    wLineNrDestDir.addSelectionListener(lsDef);
    wLineNrExt.addSelectionListener(lsDef);
    wAccField.addSelectionListener(lsDef);

    // Add the file to the list of files...
    SelectionAdapter selA = new SelectionAdapter() {
        public void widgetSelected(SelectionEvent arg0) {
            wFilenameList.add(new String[] { wFilename.getText(), wFilemask.getText(),
                    TextFileInputMeta.RequiredFilesCode[0], TextFileInputMeta.RequiredFilesCode[0] });
            wFilename.setText("");
            wFilemask.setText("");
            wFilenameList.removeEmptyRows();
            wFilenameList.setRowNums();
            wFilenameList.optWidth(true);
        }
    };
    wbaFilename.addSelectionListener(selA);
    wFilename.addSelectionListener(selA);

    // Delete files from the list of files...
    wbdFilename.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent arg0) {
            int[] idx = wFilenameList.getSelectionIndices();
            wFilenameList.remove(idx);
            wFilenameList.removeEmptyRows();
            wFilenameList.setRowNums();
        }
    });

    // Edit the selected file & remove from the list...
    wbeFilename.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent arg0) {
            int idx = wFilenameList.getSelectionIndex();
            if (idx >= 0) {
                String[] string = wFilenameList.getItem(idx);
                wFilename.setText(string[0]);
                wFilemask.setText(string[1]);
                wFilenameList.remove(idx);
            }
            wFilenameList.removeEmptyRows();
            wFilenameList.setRowNums();
        }
    });

    // Show the files that are selected at this time...
    wbShowFiles.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            showFiles();
        }
    });

    // Allow the insertion of tabs as separator...
    wbSeparator.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent se) {
            wSeparator.getTextWidget().insert("\t");
        }
    });

    SelectionAdapter lsFlags = new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            setFlags();
        }
    };

    // Enable/disable the right fields...
    wInclFilename.addSelectionListener(lsFlags);
    wInclRownum.addSelectionListener(lsFlags);
    wRownumByFile.addSelectionListener(lsFlags);
    wErrorIgnored.addSelectionListener(lsFlags);
    wHeader.addSelectionListener(lsFlags);
    wFooter.addSelectionListener(lsFlags);
    wWraps.addSelectionListener(lsFlags);
    wLayoutPaged.addSelectionListener(lsFlags);
    wAccFilenames.addSelectionListener(lsFlags);

    // Listen to the Browse... button
    wbbFilename.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            try {
                // Setup file type filtering
                String[] fileFilters = null;
                String[] fileFilterNames = null;
                if (!wCompression.getText().equals("None")) {
                    fileFilters = new String[] { "*.zip;*.gz", "*.txt;*.csv", "*.csv", "*.txt", "*" };
                    fileFilterNames = new String[] {
                            BaseMessages.getString(BASE_PKG, "System.FileType.ZIPFiles"),
                            BaseMessages.getString(BASE_PKG, "TextFileInputDialog.FileType.TextAndCSVFiles"),
                            BaseMessages.getString(BASE_PKG, "System.FileType.CSVFiles"),
                            BaseMessages.getString(BASE_PKG, "System.FileType.TextFiles"),
                            BaseMessages.getString(BASE_PKG, "System.FileType.AllFiles") };
                } else {
                    fileFilters = new String[] { "*", "*.txt;*.csv", "*.csv", "*.txt" };
                    fileFilterNames = new String[] {
                            BaseMessages.getString(BASE_PKG, "System.FileType.AllFiles"),
                            BaseMessages.getString(BASE_PKG, "TextFileInputDialog.FileType.TextAndCSVFiles"),
                            BaseMessages.getString(BASE_PKG, "System.FileType.CSVFiles"),
                            BaseMessages.getString(BASE_PKG, "System.FileType.TextFiles") };
                }

                // Get current file
                FileObject rootFile = null;
                FileObject initialFile = null;
                FileObject defaultInitialFile = null;

                if (wFilename.getText() != null) {
                    String fileName = transMeta.environmentSubstitute(wFilename.getText());

                    if (fileName != null && !fileName.equals("")) {
                        try {
                            initialFile = KettleVFS.getFileObject(fileName);
                            rootFile = initialFile.getFileSystem().getRoot();
                            defaultInitialFile = initialFile;
                        } catch (KettleFileException ex) {
                            // Ignore, unable to obtain initial file, use default
                        }
                    }
                }

                if (rootFile == null) {
                    defaultInitialFile = KettleVFS.getFileObject(Spoon.getInstance().getLastFileOpened());
                    rootFile = defaultInitialFile.getFileSystem().getRoot();
                    initialFile = defaultInitialFile;
                }

                VfsFileChooserDialog fileChooserDialog = Spoon.getInstance().getVfsFileChooserDialog(rootFile,
                        initialFile);
                fileChooserDialog.defaultInitialFile = defaultInitialFile;
                FileObject selectedFile = fileChooserDialog.open(shell, null, HadoopSpoonPlugin.HDFS_SCHEME,
                        true, null, fileFilters, fileFilterNames,
                        VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE_OR_DIRECTORY);
                if (selectedFile != null) {
                    wFilename.setText(selectedFile.getURL().toString());
                }
            } catch (KettleFileException ex) {
                log.logError(
                        BaseMessages.getString(PKG, "HadoopFileInputDialog.FileBrowser.KettleFileException"));
            } catch (FileSystemException ex) {
                log.logError(
                        BaseMessages.getString(PKG, "HadoopFileInputDialog.FileBrowser.FileSystemException"));
            }
        }
    });

    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {
        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });

    wTabFolder.setSelection(0);

    // Set the shell size, based upon previous time...
    getData(input);

    setSize();

    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}

From source file:org.pentaho.di.ui.trans.steps.hadoopfileoutput.HadoopFileOutputDialog.java

public String open() {
    Shell parent = getParent();/*from w w w. ja  va  2 s .  c  o m*/
    Display display = parent.getDisplay();

    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
    props.setLook(shell);
    setShellImage(shell, input);

    ModifyListener lsMod = new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            input.setChanged();
        }
    };
    changed = input.hasChanged();

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "HadoopFileOutputDialog.DialogTitle"));

    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(BASE_PKG, "System.Label.StepName"));
    props.setLook(wlStepname);
    fdlStepname = new FormData();
    fdlStepname.left = new FormAttachment(0, 0);
    fdlStepname.top = new FormAttachment(0, margin);
    fdlStepname.right = new FormAttachment(middle, -margin);
    wlStepname.setLayoutData(fdlStepname);
    wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wStepname.setText(stepname);
    props.setLook(wStepname);
    wStepname.addModifyListener(lsMod);
    fdStepname = new FormData();
    fdStepname.left = new FormAttachment(middle, 0);
    fdStepname.top = new FormAttachment(0, margin);
    fdStepname.right = new FormAttachment(100, 0);
    wStepname.setLayoutData(fdStepname);

    wTabFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
    wTabFolder.setSimple(false);

    // ////////////////////////
    // START OF FILE TAB///
    // /
    wFileTab = new CTabItem(wTabFolder, SWT.NONE);
    wFileTab.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.FileTab.TabTitle"));

    Composite wFileComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wFileComp);

    FormLayout fileLayout = new FormLayout();
    fileLayout.marginWidth = 3;
    fileLayout.marginHeight = 3;
    wFileComp.setLayout(fileLayout);

    // Filename line
    wlFilename = new Label(wFileComp, SWT.RIGHT);
    wlFilename.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.Filename.Label"));
    props.setLook(wlFilename);
    fdlFilename = new FormData();
    fdlFilename.left = new FormAttachment(0, 0);
    fdlFilename.top = new FormAttachment(0, margin);
    fdlFilename.right = new FormAttachment(middle, -margin);
    wlFilename.setLayoutData(fdlFilename);

    wbFilename = new Button(wFileComp, SWT.PUSH | SWT.CENTER);
    props.setLook(wbFilename);
    wbFilename.setText(BaseMessages.getString(BASE_PKG, "System.Button.Browse"));
    fdbFilename = new FormData();
    fdbFilename.right = new FormAttachment(100, 0);
    fdbFilename.top = new FormAttachment(0, 0);
    wbFilename.setLayoutData(fdbFilename);

    wFilename = new TextVar(transMeta, wFileComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wFilename);
    wFilename.addModifyListener(lsMod);
    fdFilename = new FormData();
    fdFilename.left = new FormAttachment(middle, 0);
    fdFilename.top = new FormAttachment(0, margin);
    fdFilename.right = new FormAttachment(wbFilename, -margin);
    wFilename.setLayoutData(fdFilename);

    // Create Parent Folder
    wlCreateParentFolder = new Label(wFileComp, SWT.RIGHT);
    wlCreateParentFolder
            .setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.CreateParentFolder.Label"));
    props.setLook(wlCreateParentFolder);
    fdlCreateParentFolder = new FormData();
    fdlCreateParentFolder.left = new FormAttachment(0, 0);
    fdlCreateParentFolder.top = new FormAttachment(wFilename, margin);
    fdlCreateParentFolder.right = new FormAttachment(middle, -margin);
    wlCreateParentFolder.setLayoutData(fdlCreateParentFolder);
    wCreateParentFolder = new Button(wFileComp, SWT.CHECK);
    wCreateParentFolder.setToolTipText(
            BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.CreateParentFolder.Tooltip"));
    props.setLook(wCreateParentFolder);
    fdCreateParentFolder = new FormData();
    fdCreateParentFolder.left = new FormAttachment(middle, 0);
    fdCreateParentFolder.top = new FormAttachment(wFilename, margin);
    fdCreateParentFolder.right = new FormAttachment(100, 0);
    wCreateParentFolder.setLayoutData(fdCreateParentFolder);
    wCreateParentFolder.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });

    // Open new File at Init
    wlDoNotOpenNewFileInit = new Label(wFileComp, SWT.RIGHT);
    wlDoNotOpenNewFileInit
            .setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.DoNotOpenNewFileInit.Label"));
    props.setLook(wlDoNotOpenNewFileInit);
    fdlDoNotOpenNewFileInit = new FormData();
    fdlDoNotOpenNewFileInit.left = new FormAttachment(0, 0);
    fdlDoNotOpenNewFileInit.top = new FormAttachment(wCreateParentFolder, margin);
    fdlDoNotOpenNewFileInit.right = new FormAttachment(middle, -margin);
    wlDoNotOpenNewFileInit.setLayoutData(fdlDoNotOpenNewFileInit);
    wDoNotOpenNewFileInit = new Button(wFileComp, SWT.CHECK);
    wDoNotOpenNewFileInit.setToolTipText(
            BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.DoNotOpenNewFileInit.Tooltip"));
    props.setLook(wDoNotOpenNewFileInit);
    fdDoNotOpenNewFileInit = new FormData();
    fdDoNotOpenNewFileInit.left = new FormAttachment(middle, 0);
    fdDoNotOpenNewFileInit.top = new FormAttachment(wCreateParentFolder, margin);
    fdDoNotOpenNewFileInit.right = new FormAttachment(100, 0);
    wDoNotOpenNewFileInit.setLayoutData(fdDoNotOpenNewFileInit);
    wDoNotOpenNewFileInit.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });

    /* next Lines */
    // FileNameInField line
    wlFileNameInField = new Label(wFileComp, SWT.RIGHT);
    wlFileNameInField.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.FileNameInField.Label"));
    props.setLook(wlFileNameInField);
    fdlFileNameInField = new FormData();
    fdlFileNameInField.left = new FormAttachment(0, 0);
    fdlFileNameInField.top = new FormAttachment(wDoNotOpenNewFileInit, margin);
    fdlFileNameInField.right = new FormAttachment(middle, -margin);
    wlFileNameInField.setLayoutData(fdlFileNameInField);
    wFileNameInField = new Button(wFileComp, SWT.CHECK);
    props.setLook(wFileNameInField);
    fdFileNameInField = new FormData();
    fdFileNameInField.left = new FormAttachment(middle, 0);
    fdFileNameInField.top = new FormAttachment(wDoNotOpenNewFileInit, margin);
    fdFileNameInField.right = new FormAttachment(100, 0);
    wFileNameInField.setLayoutData(fdFileNameInField);
    wFileNameInField.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
            activeFileNameField();
        }
    });

    // FileNameField Line
    wlFileNameField = new Label(wFileComp, SWT.RIGHT);
    wlFileNameField.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.FileNameField.Label")); //$NON-NLS-1$
    props.setLook(wlFileNameField);
    fdlFileNameField = new FormData();
    fdlFileNameField.left = new FormAttachment(0, 0);
    fdlFileNameField.right = new FormAttachment(middle, -margin);
    fdlFileNameField.top = new FormAttachment(wFileNameInField, margin);
    wlFileNameField.setLayoutData(fdlFileNameField);

    wFileNameField = new ComboVar(transMeta, wFileComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wFileNameField);
    wFileNameField.addModifyListener(lsMod);
    fdFileNameField = new FormData();
    fdFileNameField.left = new FormAttachment(middle, 0);
    fdFileNameField.top = new FormAttachment(wFileNameInField, margin);
    fdFileNameField.right = new FormAttachment(100, 0);
    wFileNameField.setLayoutData(fdFileNameField);
    wFileNameField.setEnabled(false);
    wFileNameField.addFocusListener(new FocusListener() {
        public void focusLost(org.eclipse.swt.events.FocusEvent e) {
        }

        public void focusGained(org.eclipse.swt.events.FocusEvent e) {
            Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
            shell.setCursor(busy);
            getFields();
            shell.setCursor(null);
            busy.dispose();
        }
    });
    /* End */

    // Extension line
    wlExtension = new Label(wFileComp, SWT.RIGHT);
    wlExtension.setText(BaseMessages.getString(BASE_PKG, "System.Label.Extension"));
    props.setLook(wlExtension);
    fdlExtension = new FormData();
    fdlExtension.left = new FormAttachment(0, 0);
    fdlExtension.top = new FormAttachment(wFileNameField, margin);
    fdlExtension.right = new FormAttachment(middle, -margin);
    wlExtension.setLayoutData(fdlExtension);
    wExtension = new TextVar(transMeta, wFileComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wExtension.setText("");
    props.setLook(wExtension);
    wExtension.addModifyListener(lsMod);
    fdExtension = new FormData();
    fdExtension.left = new FormAttachment(middle, 0);
    fdExtension.top = new FormAttachment(wFileNameField, margin);
    fdExtension.right = new FormAttachment(100, 0);
    wExtension.setLayoutData(fdExtension);

    // Create multi-part file?
    wlAddStepnr = new Label(wFileComp, SWT.RIGHT);
    wlAddStepnr.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.AddStepnr.Label"));
    props.setLook(wlAddStepnr);
    fdlAddStepnr = new FormData();
    fdlAddStepnr.left = new FormAttachment(0, 0);
    fdlAddStepnr.top = new FormAttachment(wExtension, margin);
    fdlAddStepnr.right = new FormAttachment(middle, -margin);
    wlAddStepnr.setLayoutData(fdlAddStepnr);
    wAddStepnr = new Button(wFileComp, SWT.CHECK);
    props.setLook(wAddStepnr);
    fdAddStepnr = new FormData();
    fdAddStepnr.left = new FormAttachment(middle, 0);
    fdAddStepnr.top = new FormAttachment(wExtension, margin);
    fdAddStepnr.right = new FormAttachment(100, 0);
    wAddStepnr.setLayoutData(fdAddStepnr);
    wAddStepnr.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });

    // Create multi-part file?
    wlAddPartnr = new Label(wFileComp, SWT.RIGHT);
    wlAddPartnr.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.AddPartnr.Label"));
    props.setLook(wlAddPartnr);
    fdlAddPartnr = new FormData();
    fdlAddPartnr.left = new FormAttachment(0, 0);
    fdlAddPartnr.top = new FormAttachment(wAddStepnr, margin);
    fdlAddPartnr.right = new FormAttachment(middle, -margin);
    wlAddPartnr.setLayoutData(fdlAddPartnr);
    wAddPartnr = new Button(wFileComp, SWT.CHECK);
    props.setLook(wAddPartnr);
    fdAddPartnr = new FormData();
    fdAddPartnr.left = new FormAttachment(middle, 0);
    fdAddPartnr.top = new FormAttachment(wAddStepnr, margin);
    fdAddPartnr.right = new FormAttachment(100, 0);
    wAddPartnr.setLayoutData(fdAddPartnr);
    wAddPartnr.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });

    // Create multi-part file?
    wlAddDate = new Label(wFileComp, SWT.RIGHT);
    wlAddDate.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.AddDate.Label"));
    props.setLook(wlAddDate);
    fdlAddDate = new FormData();
    fdlAddDate.left = new FormAttachment(0, 0);
    fdlAddDate.top = new FormAttachment(wAddPartnr, margin);
    fdlAddDate.right = new FormAttachment(middle, -margin);
    wlAddDate.setLayoutData(fdlAddDate);
    wAddDate = new Button(wFileComp, SWT.CHECK);
    props.setLook(wAddDate);
    fdAddDate = new FormData();
    fdAddDate.left = new FormAttachment(middle, 0);
    fdAddDate.top = new FormAttachment(wAddPartnr, margin);
    fdAddDate.right = new FormAttachment(100, 0);
    wAddDate.setLayoutData(fdAddDate);
    wAddDate.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
            // System.out.println("wAddDate.getSelection()="+wAddDate.getSelection());
        }
    });
    // Create multi-part file?
    wlAddTime = new Label(wFileComp, SWT.RIGHT);
    wlAddTime.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.AddTime.Label"));
    props.setLook(wlAddTime);
    fdlAddTime = new FormData();
    fdlAddTime.left = new FormAttachment(0, 0);
    fdlAddTime.top = new FormAttachment(wAddDate, margin);
    fdlAddTime.right = new FormAttachment(middle, -margin);
    wlAddTime.setLayoutData(fdlAddTime);
    wAddTime = new Button(wFileComp, SWT.CHECK);
    props.setLook(wAddTime);
    fdAddTime = new FormData();
    fdAddTime.left = new FormAttachment(middle, 0);
    fdAddTime.top = new FormAttachment(wAddDate, margin);
    fdAddTime.right = new FormAttachment(100, 0);
    wAddTime.setLayoutData(fdAddTime);
    wAddTime.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });

    // Specify date time format?
    wlSpecifyFormat = new Label(wFileComp, SWT.RIGHT);
    wlSpecifyFormat.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.SpecifyFormat.Label"));
    props.setLook(wlSpecifyFormat);
    fdlSpecifyFormat = new FormData();
    fdlSpecifyFormat.left = new FormAttachment(0, 0);
    fdlSpecifyFormat.top = new FormAttachment(wAddTime, margin);
    fdlSpecifyFormat.right = new FormAttachment(middle, -margin);
    wlSpecifyFormat.setLayoutData(fdlSpecifyFormat);
    wSpecifyFormat = new Button(wFileComp, SWT.CHECK);
    props.setLook(wSpecifyFormat);
    wSpecifyFormat
            .setToolTipText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.SpecifyFormat.Tooltip"));
    fdSpecifyFormat = new FormData();
    fdSpecifyFormat.left = new FormAttachment(middle, 0);
    fdSpecifyFormat.top = new FormAttachment(wAddTime, margin);
    fdSpecifyFormat.right = new FormAttachment(100, 0);
    wSpecifyFormat.setLayoutData(fdSpecifyFormat);
    wSpecifyFormat.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
            setDateTimeFormat();
        }
    });

    // DateTimeFormat
    wlDateTimeFormat = new Label(wFileComp, SWT.RIGHT);
    wlDateTimeFormat.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.DateTimeFormat.Label"));
    props.setLook(wlDateTimeFormat);
    fdlDateTimeFormat = new FormData();
    fdlDateTimeFormat.left = new FormAttachment(0, 0);
    fdlDateTimeFormat.top = new FormAttachment(wSpecifyFormat, margin);
    fdlDateTimeFormat.right = new FormAttachment(middle, -margin);
    wlDateTimeFormat.setLayoutData(fdlDateTimeFormat);
    wDateTimeFormat = new CCombo(wFileComp, SWT.BORDER | SWT.READ_ONLY);
    wDateTimeFormat.setEditable(true);
    props.setLook(wDateTimeFormat);
    wDateTimeFormat.addModifyListener(lsMod);
    fdDateTimeFormat = new FormData();
    fdDateTimeFormat.left = new FormAttachment(middle, 0);
    fdDateTimeFormat.top = new FormAttachment(wSpecifyFormat, margin);
    fdDateTimeFormat.right = new FormAttachment(100, 0);
    wDateTimeFormat.setLayoutData(fdDateTimeFormat);
    String[] dates = Const.getDateFormats();
    for (int x = 0; x < dates.length; x++) {
        wDateTimeFormat.add(dates[x]);
    }
    wbShowFiles = new Button(wFileComp, SWT.PUSH | SWT.CENTER);
    props.setLook(wbShowFiles);
    wbShowFiles.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.ShowFiles.Button"));
    fdbShowFiles = new FormData();
    fdbShowFiles.left = new FormAttachment(middle, 0);
    fdbShowFiles.top = new FormAttachment(wDateTimeFormat, margin * 2);
    wbShowFiles.setLayoutData(fdbShowFiles);
    wbShowFiles.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            TextFileOutputMeta tfoi = new TextFileOutputMeta();
            getInfo(tfoi);
            String[] files = tfoi.getFiles(transMeta);
            if (files != null && files.length > 0) {
                EnterSelectionDialog esd = new EnterSelectionDialog(shell, files,
                        BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.SelectOutputFiles.DialogTitle"),
                        BaseMessages.getString(BASE_PKG,
                                "TextFileOutputDialog.SelectOutputFiles.DialogMessage"));
                esd.setViewOnly();
                esd.open();
            } else {
                MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
                mb.setMessage(
                        BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.NoFilesFound.DialogMessage"));
                mb.setText(BaseMessages.getString(BASE_PKG, "System.Dialog.Error.Title"));
                mb.open();
            }
        }
    });

    // Add File to the result files name
    wlAddToResult = new Label(wFileComp, SWT.RIGHT);
    wlAddToResult.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.AddFileToResult.Label"));
    props.setLook(wlAddToResult);
    fdlAddToResult = new FormData();
    fdlAddToResult.left = new FormAttachment(0, 0);
    fdlAddToResult.top = new FormAttachment(wbShowFiles, 2 * margin);
    fdlAddToResult.right = new FormAttachment(middle, -margin);
    wlAddToResult.setLayoutData(fdlAddToResult);
    wAddToResult = new Button(wFileComp, SWT.CHECK);
    wAddToResult
            .setToolTipText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.AddFileToResult.Tooltip"));
    props.setLook(wAddToResult);
    fdAddToResult = new FormData();
    fdAddToResult.left = new FormAttachment(middle, 0);
    fdAddToResult.top = new FormAttachment(wbShowFiles, 2 * margin);
    fdAddToResult.right = new FormAttachment(100, 0);
    wAddToResult.setLayoutData(fdAddToResult);
    SelectionAdapter lsSelR = new SelectionAdapter() {
        public void widgetSelected(SelectionEvent arg0) {
            input.setChanged();
        }
    };
    wAddToResult.addSelectionListener(lsSelR);

    fdFileComp = new FormData();
    fdFileComp.left = new FormAttachment(0, 0);
    fdFileComp.top = new FormAttachment(0, 0);
    fdFileComp.right = new FormAttachment(100, 0);
    fdFileComp.bottom = new FormAttachment(100, 0);
    wFileComp.setLayoutData(fdFileComp);

    wFileComp.layout();
    wFileTab.setControl(wFileComp);

    // ///////////////////////////////////////////////////////////
    // / END OF FILE TAB
    // ///////////////////////////////////////////////////////////

    // ////////////////////////
    // START OF CONTENT TAB///
    // /
    wContentTab = new CTabItem(wTabFolder, SWT.NONE);
    wContentTab.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.ContentTab.TabTitle"));

    FormLayout contentLayout = new FormLayout();
    contentLayout.marginWidth = 3;
    contentLayout.marginHeight = 3;

    Composite wContentComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wContentComp);
    wContentComp.setLayout(contentLayout);

    // Append to end of file?
    wlAppend = new Label(wContentComp, SWT.RIGHT);
    wlAppend.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.Append.Label"));
    props.setLook(wlAppend);
    fdlAppend = new FormData();
    fdlAppend.left = new FormAttachment(0, 0);
    fdlAppend.top = new FormAttachment(0, 0);
    fdlAppend.right = new FormAttachment(middle, -margin);
    wlAppend.setLayoutData(fdlAppend);
    wAppend = new Button(wContentComp, SWT.CHECK);
    props.setLook(wAppend);
    fdAppend = new FormData();
    fdAppend.left = new FormAttachment(middle, 0);
    fdAppend.top = new FormAttachment(0, 0);
    fdAppend.right = new FormAttachment(100, 0);
    wAppend.setLayoutData(fdAppend);
    wAppend.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });

    wlSeparator = new Label(wContentComp, SWT.RIGHT);
    wlSeparator.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.Separator.Label"));
    props.setLook(wlSeparator);
    fdlSeparator = new FormData();
    fdlSeparator.left = new FormAttachment(0, 0);
    fdlSeparator.top = new FormAttachment(wAppend, margin);
    fdlSeparator.right = new FormAttachment(middle, -margin);
    wlSeparator.setLayoutData(fdlSeparator);

    wbSeparator = new Button(wContentComp, SWT.PUSH | SWT.CENTER);
    props.setLook(wbSeparator);
    wbSeparator.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.Separator.Button"));
    fdbSeparator = new FormData();
    fdbSeparator.right = new FormAttachment(100, 0);
    fdbSeparator.top = new FormAttachment(wAppend, 0);
    wbSeparator.setLayoutData(fdbSeparator);
    wbSeparator.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent se) {
            // wSeparator.insert("\t");
            wSeparator.getTextWidget().insert("\t");
        }
    });

    wSeparator = new TextVar(transMeta, wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wSeparator);
    wSeparator.addModifyListener(lsMod);
    fdSeparator = new FormData();
    fdSeparator.left = new FormAttachment(middle, 0);
    fdSeparator.top = new FormAttachment(wAppend, margin);
    fdSeparator.right = new FormAttachment(wbSeparator, -margin);
    wSeparator.setLayoutData(fdSeparator);

    // Enclosure line...
    wlEnclosure = new Label(wContentComp, SWT.RIGHT);
    wlEnclosure.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.Enclosure.Label"));
    props.setLook(wlEnclosure);
    fdlEnclosure = new FormData();
    fdlEnclosure.left = new FormAttachment(0, 0);
    fdlEnclosure.top = new FormAttachment(wSeparator, margin);
    fdlEnclosure.right = new FormAttachment(middle, -margin);
    wlEnclosure.setLayoutData(fdlEnclosure);
    wEnclosure = new TextVar(transMeta, wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wEnclosure);
    wEnclosure.addModifyListener(lsMod);
    fdEnclosure = new FormData();
    fdEnclosure.left = new FormAttachment(middle, 0);
    fdEnclosure.top = new FormAttachment(wSeparator, margin);
    fdEnclosure.right = new FormAttachment(100, 0);
    wEnclosure.setLayoutData(fdEnclosure);

    wlEnclForced = new Label(wContentComp, SWT.RIGHT);
    wlEnclForced.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.EnclForced.Label"));
    props.setLook(wlEnclForced);
    fdlEnclForced = new FormData();
    fdlEnclForced.left = new FormAttachment(0, 0);
    fdlEnclForced.top = new FormAttachment(wEnclosure, margin);
    fdlEnclForced.right = new FormAttachment(middle, -margin);
    wlEnclForced.setLayoutData(fdlEnclForced);
    wEnclForced = new Button(wContentComp, SWT.CHECK);
    props.setLook(wEnclForced);
    fdEnclForced = new FormData();
    fdEnclForced.left = new FormAttachment(middle, 0);
    fdEnclForced.top = new FormAttachment(wEnclosure, margin);
    fdEnclForced.right = new FormAttachment(100, 0);
    wEnclForced.setLayoutData(fdEnclForced);
    wEnclForced.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });

    wlHeader = new Label(wContentComp, SWT.RIGHT);
    wlHeader.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.Header.Label"));
    props.setLook(wlHeader);
    fdlHeader = new FormData();
    fdlHeader.left = new FormAttachment(0, 0);
    fdlHeader.top = new FormAttachment(wEnclForced, margin);
    fdlHeader.right = new FormAttachment(middle, -margin);
    wlHeader.setLayoutData(fdlHeader);
    wHeader = new Button(wContentComp, SWT.CHECK);
    props.setLook(wHeader);
    fdHeader = new FormData();
    fdHeader.left = new FormAttachment(middle, 0);
    fdHeader.top = new FormAttachment(wEnclForced, margin);
    fdHeader.right = new FormAttachment(100, 0);
    wHeader.setLayoutData(fdHeader);
    wHeader.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });

    wlFooter = new Label(wContentComp, SWT.RIGHT);
    wlFooter.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.Footer.Label"));
    props.setLook(wlFooter);
    fdlFooter = new FormData();
    fdlFooter.left = new FormAttachment(0, 0);
    fdlFooter.top = new FormAttachment(wHeader, margin);
    fdlFooter.right = new FormAttachment(middle, -margin);
    wlFooter.setLayoutData(fdlFooter);
    wFooter = new Button(wContentComp, SWT.CHECK);
    props.setLook(wFooter);
    fdFooter = new FormData();
    fdFooter.left = new FormAttachment(middle, 0);
    fdFooter.top = new FormAttachment(wHeader, margin);
    fdFooter.right = new FormAttachment(100, 0);
    wFooter.setLayoutData(fdFooter);
    wFooter.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });

    wlFormat = new Label(wContentComp, SWT.RIGHT);
    wlFormat.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.Format.Label"));
    props.setLook(wlFormat);
    fdlFormat = new FormData();
    fdlFormat.left = new FormAttachment(0, 0);
    fdlFormat.top = new FormAttachment(wFooter, margin);
    fdlFormat.right = new FormAttachment(middle, -margin);
    wlFormat.setLayoutData(fdlFormat);
    wFormat = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
    wFormat.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.Format.Label"));
    props.setLook(wFormat);

    wFormat.add("DOS");
    wFormat.add("Unix");
    wFormat.select(0);
    wFormat.addModifyListener(lsMod);
    fdFormat = new FormData();
    fdFormat.left = new FormAttachment(middle, 0);
    fdFormat.top = new FormAttachment(wFooter, margin);
    fdFormat.right = new FormAttachment(100, 0);
    wFormat.setLayoutData(fdFormat);

    wlCompression = new Label(wContentComp, SWT.RIGHT);
    wlCompression.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.Compression.Label"));
    props.setLook(wlCompression);
    fdlCompression = new FormData();
    fdlCompression.left = new FormAttachment(0, 0);
    fdlCompression.top = new FormAttachment(wFormat, margin);
    fdlCompression.right = new FormAttachment(middle, -margin);
    wlCompression.setLayoutData(fdlCompression);
    wCompression = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
    wCompression.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.Compression.Label"));
    props.setLook(wCompression);

    wCompression.setItems(CompressionProviderFactory.getInstance().getCompressionProviderNames());
    wCompression.addModifyListener(lsMod);
    fdCompression = new FormData();
    fdCompression.left = new FormAttachment(middle, 0);
    fdCompression.top = new FormAttachment(wFormat, margin);
    fdCompression.right = new FormAttachment(100, 0);
    wCompression.setLayoutData(fdCompression);

    wlEncoding = new Label(wContentComp, SWT.RIGHT);
    wlEncoding.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.Encoding.Label"));
    props.setLook(wlEncoding);
    fdlEncoding = new FormData();
    fdlEncoding.left = new FormAttachment(0, 0);
    fdlEncoding.top = new FormAttachment(wCompression, margin);
    fdlEncoding.right = new FormAttachment(middle, -margin);
    wlEncoding.setLayoutData(fdlEncoding);
    wEncoding = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
    wEncoding.setEditable(true);
    props.setLook(wEncoding);
    wEncoding.addModifyListener(lsMod);
    fdEncoding = new FormData();
    fdEncoding.left = new FormAttachment(middle, 0);
    fdEncoding.top = new FormAttachment(wCompression, margin);
    fdEncoding.right = new FormAttachment(100, 0);
    wEncoding.setLayoutData(fdEncoding);
    wEncoding.addFocusListener(new FocusListener() {
        public void focusLost(org.eclipse.swt.events.FocusEvent e) {
        }

        public void focusGained(org.eclipse.swt.events.FocusEvent e) {
            Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
            shell.setCursor(busy);
            setEncodings();
            shell.setCursor(null);
            busy.dispose();
        }
    });

    wlPad = new Label(wContentComp, SWT.RIGHT);
    wlPad.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.Pad.Label"));
    props.setLook(wlPad);
    fdlPad = new FormData();
    fdlPad.left = new FormAttachment(0, 0);
    fdlPad.top = new FormAttachment(wEncoding, margin);
    fdlPad.right = new FormAttachment(middle, -margin);
    wlPad.setLayoutData(fdlPad);
    wPad = new Button(wContentComp, SWT.CHECK);
    props.setLook(wPad);
    fdPad = new FormData();
    fdPad.left = new FormAttachment(middle, 0);
    fdPad.top = new FormAttachment(wEncoding, margin);
    fdPad.right = new FormAttachment(100, 0);
    wPad.setLayoutData(fdPad);
    wPad.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });

    wlFastDump = new Label(wContentComp, SWT.RIGHT);
    wlFastDump.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.FastDump.Label"));
    props.setLook(wlFastDump);
    fdlFastDump = new FormData();
    fdlFastDump.left = new FormAttachment(0, 0);
    fdlFastDump.top = new FormAttachment(wPad, margin);
    fdlFastDump.right = new FormAttachment(middle, -margin);
    wlFastDump.setLayoutData(fdlFastDump);
    wFastDump = new Button(wContentComp, SWT.CHECK);
    props.setLook(wFastDump);
    fdFastDump = new FormData();
    fdFastDump.left = new FormAttachment(middle, 0);
    fdFastDump.top = new FormAttachment(wPad, margin);
    fdFastDump.right = new FormAttachment(100, 0);
    wFastDump.setLayoutData(fdFastDump);
    wFastDump.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });

    wlSplitEvery = new Label(wContentComp, SWT.RIGHT);
    wlSplitEvery.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.SplitEvery.Label"));
    props.setLook(wlSplitEvery);
    fdlSplitEvery = new FormData();
    fdlSplitEvery.left = new FormAttachment(0, 0);
    fdlSplitEvery.top = new FormAttachment(wFastDump, margin);
    fdlSplitEvery.right = new FormAttachment(middle, -margin);
    wlSplitEvery.setLayoutData(fdlSplitEvery);
    wSplitEvery = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wSplitEvery);
    wSplitEvery.addModifyListener(lsMod);
    fdSplitEvery = new FormData();
    fdSplitEvery.left = new FormAttachment(middle, 0);
    fdSplitEvery.top = new FormAttachment(wFastDump, margin);
    fdSplitEvery.right = new FormAttachment(100, 0);
    wSplitEvery.setLayoutData(fdSplitEvery);

    // Bruise:
    wlEndedLine = new Label(wContentComp, SWT.RIGHT);
    wlEndedLine.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.EndedLine.Label"));
    props.setLook(wlEndedLine);
    fdlEndedLine = new FormData();
    fdlEndedLine.left = new FormAttachment(0, 0);
    fdlEndedLine.top = new FormAttachment(wSplitEvery, margin);
    fdlEndedLine.right = new FormAttachment(middle, -margin);
    wlEndedLine.setLayoutData(fdlEndedLine);
    wEndedLine = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wEndedLine);
    wEndedLine.addModifyListener(lsMod);
    fdEndedLine = new FormData();
    fdEndedLine.left = new FormAttachment(middle, 0);
    fdEndedLine.top = new FormAttachment(wSplitEvery, margin);
    fdEndedLine.right = new FormAttachment(100, 0);
    wEndedLine.setLayoutData(fdEndedLine);

    fdContentComp = new FormData();
    fdContentComp.left = new FormAttachment(0, 0);
    fdContentComp.top = new FormAttachment(0, 0);
    fdContentComp.right = new FormAttachment(100, 0);
    fdContentComp.bottom = new FormAttachment(100, 0);
    wContentComp.setLayoutData(fdContentComp);

    wContentComp.layout();
    wContentTab.setControl(wContentComp);

    // ///////////////////////////////////////////////////////////
    // / END OF CONTENT TAB
    // ///////////////////////////////////////////////////////////

    // Fields tab...
    //
    wFieldsTab = new CTabItem(wTabFolder, SWT.NONE);
    wFieldsTab.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.FieldsTab.TabTitle"));

    FormLayout fieldsLayout = new FormLayout();
    fieldsLayout.marginWidth = Const.FORM_MARGIN;
    fieldsLayout.marginHeight = Const.FORM_MARGIN;

    Composite wFieldsComp = new Composite(wTabFolder, SWT.NONE);
    wFieldsComp.setLayout(fieldsLayout);
    props.setLook(wFieldsComp);

    wGet = new Button(wFieldsComp, SWT.PUSH);
    wGet.setText(BaseMessages.getString(BASE_PKG, "System.Button.GetFields"));
    wGet.setToolTipText(BaseMessages.getString(BASE_PKG, "System.Tooltip.GetFields"));

    wMinWidth = new Button(wFieldsComp, SWT.PUSH);
    wMinWidth.setText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.MinWidth.Button"));
    wMinWidth.setToolTipText(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.MinWidth.Tooltip"));

    setButtonPositions(new Button[] { wGet, wMinWidth }, margin, null);

    final int FieldsCols = 10;
    final int FieldsRows = input.getOutputFields().length;

    // Prepare a list of possible formats...
    String[] nums = Const.getNumberFormats();
    int totsize = dates.length + nums.length;
    String[] formats = new String[totsize];
    for (int x = 0; x < dates.length; x++) {
        formats[x] = dates[x];
    }
    for (int x = 0; x < nums.length; x++) {
        formats[dates.length + x] = nums[x];
    }
    colinf = new ColumnInfo[FieldsCols];
    colinf[0] = new ColumnInfo(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.NameColumn.Column"),
            ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
    colinf[1] = new ColumnInfo(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.TypeColumn.Column"),
            ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMeta.getTypes());
    colinf[2] = new ColumnInfo(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.FormatColumn.Column"),
            ColumnInfo.COLUMN_TYPE_CCOMBO, formats);
    colinf[3] = new ColumnInfo(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.LengthColumn.Column"),
            ColumnInfo.COLUMN_TYPE_TEXT, false);
    colinf[4] = new ColumnInfo(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.PrecisionColumn.Column"),
            ColumnInfo.COLUMN_TYPE_TEXT, false);
    colinf[5] = new ColumnInfo(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.CurrencyColumn.Column"),
            ColumnInfo.COLUMN_TYPE_TEXT, false);
    colinf[6] = new ColumnInfo(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.DecimalColumn.Column"),
            ColumnInfo.COLUMN_TYPE_TEXT, false);
    colinf[7] = new ColumnInfo(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.GroupColumn.Column"),
            ColumnInfo.COLUMN_TYPE_TEXT, false);
    colinf[8] = new ColumnInfo(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.TrimTypeColumn.Column"),
            ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMeta.trimTypeDesc, true);
    colinf[9] = new ColumnInfo(BaseMessages.getString(BASE_PKG, "TextFileOutputDialog.NullColumn.Column"),
            ColumnInfo.COLUMN_TYPE_TEXT, false);

    wFields = new TableView(transMeta, wFieldsComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf,
            FieldsRows, lsMod, props);

    fdFields = new FormData();
    fdFields.left = new FormAttachment(0, 0);
    fdFields.top = new FormAttachment(0, 0);
    fdFields.right = new FormAttachment(100, 0);
    fdFields.bottom = new FormAttachment(wGet, -margin);
    wFields.setLayoutData(fdFields);

    //
    // Search the fields in the background

    final Runnable runnable = new Runnable() {
        public void run() {
            StepMeta stepMeta = transMeta.findStep(stepname);
            if (stepMeta != null) {
                try {
                    RowMetaInterface row = transMeta.getPrevStepFields(stepMeta);

                    // Remember these fields...
                    for (int i = 0; i < row.size(); i++) {
                        inputFields.put(row.getValueMeta(i).getName(), Integer.valueOf(i));
                    }
                    setComboBoxes();
                } catch (KettleException e) {
                    logError(BaseMessages.getString(BASE_PKG, "System.Dialog.GetFieldsFailed.Message"));
                }
            }
        }
    };
    new Thread(runnable).start();

    fdFieldsComp = new FormData();
    fdFieldsComp.left = new FormAttachment(0, 0);
    fdFieldsComp.top = new FormAttachment(0, 0);
    fdFieldsComp.right = new FormAttachment(100, 0);
    fdFieldsComp.bottom = new FormAttachment(100, 0);
    wFieldsComp.setLayoutData(fdFieldsComp);

    wFieldsComp.layout();
    wFieldsTab.setControl(wFieldsComp);

    fdTabFolder = new FormData();
    fdTabFolder.left = new FormAttachment(0, 0);
    fdTabFolder.top = new FormAttachment(wStepname, margin);
    fdTabFolder.right = new FormAttachment(100, 0);
    fdTabFolder.bottom = new FormAttachment(100, -50);
    wTabFolder.setLayoutData(fdTabFolder);

    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(BASE_PKG, "System.Button.OK"));

    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(BASE_PKG, "System.Button.Cancel"));

    setButtonPositions(new Button[] { wOK, wCancel }, margin, wTabFolder);

    // Add listeners
    lsOK = new Listener() {
        public void handleEvent(Event e) {
            ok();
        }
    };
    lsGet = new Listener() {
        public void handleEvent(Event e) {
            get();
        }
    };
    lsMinWidth = new Listener() {
        public void handleEvent(Event e) {
            setMinimalWidth();
        }
    };
    lsCancel = new Listener() {
        public void handleEvent(Event e) {
            cancel();
        }
    };

    wOK.addListener(SWT.Selection, lsOK);
    wGet.addListener(SWT.Selection, lsGet);
    wMinWidth.addListener(SWT.Selection, lsMinWidth);
    wCancel.addListener(SWT.Selection, lsCancel);

    lsDef = new SelectionAdapter() {
        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };

    wStepname.addSelectionListener(lsDef);
    wFilename.addSelectionListener(lsDef);
    wSeparator.addSelectionListener(lsDef);

    // Whenever something changes, set the tooltip to the expanded version:
    wFilename.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            wFilename.setToolTipText(transMeta.environmentSubstitute(wFilename.getText()));
        }
    });

    // Listen to the Browse... button
    wbFilename.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            try {
                // Setup file type filtering
                String[] fileFilters = new String[] { "*.txt", "*.csv", "*" };
                String[] fileFilterNames = new String[] {
                        BaseMessages.getString(BASE_PKG, "System.FileType.TextFiles"),
                        BaseMessages.getString(BASE_PKG, "System.FileType.CSVFiles"),
                        BaseMessages.getString(BASE_PKG, "System.FileType.AllFiles") };

                // Get current file
                FileObject rootFile = null;
                FileObject initialFile = null;
                FileObject defaultInitialFile = null;

                if (wFilename.getText() != null) {
                    String fileName = transMeta.environmentSubstitute(wFilename.getText());
                    if (fileName != null && !fileName.equals("")) {
                        try {
                            initialFile = KettleVFS.getFileObject(fileName);
                            rootFile = initialFile.getFileSystem().getRoot();
                            defaultInitialFile = initialFile;
                        } catch (KettleFileException ex) {
                            // Ignore, unable to obtain initial file, use default
                        }
                    }
                }

                if (rootFile == null) {
                    defaultInitialFile = KettleVFS.getFileObject(Spoon.getInstance().getLastFileOpened());
                    rootFile = defaultInitialFile.getFileSystem().getRoot();
                    initialFile = defaultInitialFile;
                }

                VfsFileChooserDialog fileChooserDialog = Spoon.getInstance().getVfsFileChooserDialog(rootFile,
                        initialFile);
                fileChooserDialog.defaultInitialFile = defaultInitialFile;
                FileObject selectedFile = fileChooserDialog.open(shell, null, HadoopSpoonPlugin.HDFS_SCHEME,
                        true, null, fileFilters, fileFilterNames,
                        VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE_OR_DIRECTORY);

                if (selectedFile != null) {
                    String filename = selectedFile.getURL().toString();

                    String extension = wExtension.getText();
                    if (extension != null && filename.endsWith("." + extension)) {
                        // The extension is filled in and matches the end
                        // of the selected file => Strip off the extension.
                        wFilename.setText(filename.substring(0, filename.length() - (extension.length() + 1)));
                    } else {
                        wFilename.setText(filename);
                    }
                }
            } catch (KettleFileException ex) {
                log.logError(
                        BaseMessages.getString(PKG, "HadoopFileInputDialog.FileBrowser.KettleFileException"));
            } catch (FileSystemException ex) {
                log.logError(
                        BaseMessages.getString(PKG, "HadoopFileInputDialog.FileBrowser.FileSystemException"));
            }
        }
    });

    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {
        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });

    lsResize = new Listener() {
        public void handleEvent(Event event) {
            Point size = shell.getSize();
            wFields.setSize(size.x - 10, size.y - 50);
            wFields.table.setSize(size.x - 10, size.y - 50);
            wFields.redraw();
        }
    };
    shell.addListener(SWT.Resize, lsResize);

    wTabFolder.setSelection(0);

    // Set the shell size, based upon previous time...
    setSize();

    getData();
    activeFileNameField();
    enableParentFolder();
    input.setChanged(changed);

    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}

From source file:org.pentaho.di.ui.trans.steps.jobexecutor.JobExecutorDialog.java

private void selectFileJob() {
    String curFile = wFilename.getText();
    FileObject root = null;//from  w  w  w  .j av  a  2  s .co m

    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.getJobFilterNames(), VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE);
        if (file == null) {
            return;
        }
        String fname = null;

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

        if (fname != null) {

            loadFileJob(fname);
            // PDI-11985 set filename for UI edit field. This will be saved later in xml
            // as a filename for JobMeta.
            wFilename.setText(fname);
            wJobname.setText(Const.NVL(executorJobMeta.getName(), ""));
            wDirectory.setText("");
            specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
            setRadioButtons();
        }
    } catch (IOException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "JobExecutorDialog.ErrorLoadingJob.DialogTitle"),
                BaseMessages.getString(PKG, "JobExecutorDialog.ErrorLoadingJob.DialogMessage"), e);
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "JobExecutorDialog.ErrorLoadingJob.DialogTitle"),
                BaseMessages.getString(PKG, "JobExecutorDialog.ErrorLoadingJob.DialogMessage"), e);
    }
}