List of usage examples for org.apache.commons.vfs FileObject close
public void close() throws FileSystemException;
From source file:org.pentaho.di.trans.steps.sqlfileoutput.SQLFileOutput.java
public boolean init(StepMetaInterface smi, StepDataInterface sdi) { meta = (SQLFileOutputMeta) smi;//from w w w .ja v a2s. co m data = (SQLFileOutputData) sdi; if (super.init(smi, sdi)) { try { if (meta.getDatabaseMeta() == null) { throw new KettleStepException("The connection is not defined (empty)"); } if (meta.getDatabaseMeta() == null) { logError(BaseMessages.getString(PKG, "SQLFileOutput.Init.ConnectionMissing", getStepname())); return false; } data.db = new Database(this, meta.getDatabaseMeta()); data.db.shareVariablesWith(this); logBasic("Connected to database [" + meta.getDatabaseMeta() + "]"); if (meta.isCreateParentFolder()) { // Check for parent folder FileObject parentfolder = null; try { // Get parent folder String filename = environmentSubstitute(meta.getFileName()); parentfolder = KettleVFS.getFileObject(filename, getTransMeta()).getParent(); if (!parentfolder.exists()) { log.logBasic("Folder parent", "Folder parent " + parentfolder.getName() + " does not exist !"); parentfolder.createFolder(); log.logBasic("Folder parent", "Folder parent was created."); } } catch (Exception e) { logError("Couldn't created parent folder " + parentfolder.getName()); setErrors(1L); stopAll(); } finally { if (parentfolder != null) { try { parentfolder.close(); } catch (Exception ex) { /* Ignore */ } } } } if (!meta.isDoNotOpenNewFileInit()) { if (!openNewFile()) { logError("Couldn't open file [" + buildFilename() + "]"); setErrors(1L); stopAll(); } } tableName = environmentSubstitute(meta.getTablename()); schemaName = environmentSubstitute(meta.getSchemaName()); if (Const.isEmpty(tableName)) { throw new KettleStepException("The tablename is not defined (empty)"); } schemaTable = data.db.getDatabaseMeta().getQuotedSchemaTableCombination(schemaName, tableName); } catch (Exception e) { logError("An error occurred intialising this step: " + e.getMessage()); stopAll(); setErrors(1); } return true; } return false; }
From source file:org.pentaho.di.trans.steps.symmetriccrypto.symmetricalgorithm.SymmetricCrypto.java
public void setSecretKeyFromFile(String filename) throws CryptoKeyException { FileObject file = null; try {/*from ww w.j ava2s .com*/ file = KettleVFS.getFileObject(filename); if (!file.exists()) { throw new CryptoException( BaseMessages.getString(PKG, "SymmetricCrypto.CanNotFindFile", file.getName())); } byte[] KeyBytes = new byte[(int) file.getContent().getSize()]; setSecretKey(KeyBytes); } catch (Exception e) { throw new CryptoKeyException(e); } finally { if (file != null) { try { file.close(); } catch (Exception e) { /* Ignore */ } } } }
From source file:org.pentaho.di.trans.steps.textfileoutput.TextFileOutput.java
private void createParentFolder(String filename) throws Exception { // Check for parent folder FileObject parentfolder = null; try {/*from w ww .j av a 2 s . com*/ // Get parent folder parentfolder = getFileObject(filename).getParent(); if (parentfolder.exists()) { if (isDetailed()) { logDetailed(BaseMessages.getString(PKG, "TextFileOutput.Log.ParentFolderExist", parentfolder.getName())); } } else { if (isDetailed()) { logDetailed(BaseMessages.getString(PKG, "TextFileOutput.Log.ParentFolderNotExist", parentfolder.getName())); } if (meta.isCreateParentFolder()) { parentfolder.createFolder(); if (isDetailed()) { logDetailed(BaseMessages.getString(PKG, "TextFileOutput.Log.ParentFolderCreated", parentfolder.getName())); } } else { throw new KettleException(BaseMessages.getString(PKG, "TextFileOutput.Log.ParentFolderNotExistCreateIt", parentfolder.getName(), filename)); } } } finally { if (parentfolder != null) { try { parentfolder.close(); } catch (Exception ex) { // Ignore } } } }
From source file:org.pentaho.di.trans.steps.xsdvalidator.XsdValidator.java
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException { meta = (XsdValidatorMeta) smi;//w ww. j a v a 2s . c o m data = (XsdValidatorData) sdi; Object[] row = getRow(); if (row == null) { // no more input to be expected... setOutputDone(); return false; } if (first) { first = false; data.outputRowMeta = getInputRowMeta().clone(); meta.getFields(data.outputRowMeta, getStepname(), null, null, this, repository, metaStore); // Check if XML stream is given if (meta.getXMLStream() != null) { // Try to get XML Field index data.xmlindex = getInputRowMeta().indexOfValue(meta.getXMLStream()); // Let's check the Field if (data.xmlindex < 0) { // The field is unreachable ! logError(BaseMessages.getString(PKG, "XsdValidator.Log.ErrorFindingField") + "[" + meta.getXMLStream() + "]"); throw new KettleStepException(BaseMessages.getString(PKG, "XsdValidator.Exception.CouldnotFindField", meta.getXMLStream())); } // Let's check that Result Field is given if (meta.getResultfieldname() == null) { // Result field is missing ! logError(BaseMessages.getString(PKG, "XsdValidator.Log.ErrorResultFieldMissing")); throw new KettleStepException( BaseMessages.getString(PKG, "XsdValidator.Exception.ErrorResultFieldMissing")); } // Is XSD file is provided? if (meta.getXSDSource().equals(meta.SPECIFY_FILENAME)) { if (meta.getXSDFilename() == null) { logError(BaseMessages.getString(PKG, "XsdValidator.Log.ErrorXSDFileMissing")); throw new KettleStepException( BaseMessages.getString(PKG, "XsdValidator.Exception.ErrorXSDFileMissing")); } else { // Is XSD file exists ? FileObject xsdfile = null; try { xsdfile = KettleVFS.getFileObject(environmentSubstitute(meta.getXSDFilename()), getTransMeta()); if (!xsdfile.exists()) { logError(BaseMessages.getString(PKG, "XsdValidator.Log.Error.XSDFileNotExists")); throw new KettleStepException( BaseMessages.getString(PKG, "XsdValidator.Exception.XSDFileNotExists")); } } catch (Exception e) { logError(BaseMessages.getString(PKG, "XsdValidator.Log.Error.GettingXSDFile")); throw new KettleStepException( BaseMessages.getString(PKG, "XsdValidator.Exception.GettingXSDFile")); } finally { try { if (xsdfile != null) { xsdfile.close(); } } catch (IOException e) { // Ignore errors } } } } // Is XSD field is provided? if (meta.getXSDSource().equals(meta.SPECIFY_FIELDNAME)) { if (meta.getXSDDefinedField() == null) { logError(BaseMessages.getString(PKG, "XsdValidator.Log.Error.XSDFieldMissing")); throw new KettleStepException( BaseMessages.getString(PKG, "XsdValidator.Exception.XSDFieldMissing")); } else { // Let's check if the XSD field exist // Try to get XML Field index data.xsdindex = getInputRowMeta().indexOfValue(meta.getXSDDefinedField()); if (data.xsdindex < 0) { // The field is unreachable ! logError(BaseMessages.getString(PKG, "XsdValidator.Log.ErrorFindingXSDField", meta.getXSDDefinedField())); throw new KettleStepException(BaseMessages.getString(PKG, "XsdValidator.Exception.ErrorFindingXSDField", meta.getXSDDefinedField())); } } } } else { // XML stream field is missing ! logError(BaseMessages.getString(PKG, "XsdValidator.Log.Error.XmlStreamFieldMissing")); throw new KettleStepException( BaseMessages.getString(PKG, "XsdValidator.Exception.XmlStreamFieldMissing")); } } try { // Get the XML field value String XMLFieldvalue = getInputRowMeta().getString(row, data.xmlindex); boolean isvalid = false; // XSD filename String xsdfilename = null; if (meta.getXSDSource().equals(meta.SPECIFY_FILENAME)) { xsdfilename = environmentSubstitute(meta.getXSDFilename()); } else if (meta.getXSDSource().equals(meta.SPECIFY_FIELDNAME)) { // Get the XSD field value xsdfilename = getInputRowMeta().getString(row, data.xsdindex); } // Get XSD filename FileObject xsdfile = null; String validationmsg = null; try { SchemaFactory factoryXSDValidator = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); xsdfile = KettleVFS.getFileObject(xsdfilename, getTransMeta()); // Get XML stream Source sourceXML = new StreamSource(new StringReader(XMLFieldvalue)); if (meta.getXMLSourceFile()) { // We deal with XML file // Get XML File File xmlfileValidator = new File(XMLFieldvalue); if (!xmlfileValidator.exists()) { logError(BaseMessages.getString(PKG, "XsdValidator.Log.Error.XMLfileMissing", XMLFieldvalue)); throw new KettleStepException(BaseMessages.getString(PKG, "XsdValidator.Exception.XMLfileMissing", XMLFieldvalue)); } sourceXML = new StreamSource(xmlfileValidator); } // create the schema Schema SchematXSD = null; if (xsdfile instanceof LocalFile) { SchematXSD = factoryXSDValidator.newSchema(new File(KettleVFS.getFilename(xsdfile))); } else if (xsdfile instanceof HttpFileObject) { SchematXSD = factoryXSDValidator.newSchema(new URL(KettleVFS.getFilename(xsdfile))); } else { // we should not get here as anything entered in that does not look like // a url should be made a FileObject. throw new KettleStepException(BaseMessages.getString(PKG, "XsdValidator.Exception.CannotCreateSchema", xsdfile.getClass().getName())); } if (meta.getXSDSource().equals(meta.NO_NEED)) { // ---Some documents specify the schema they expect to be validated against, // ---typically using xsi:noNamespaceSchemaLocation and/or xsi:schemaLocation attributes // ---Schema SchematXSD = factoryXSDValidator.newSchema(); SchematXSD = factoryXSDValidator.newSchema(); } // Create XSDValidator Validator XSDValidator = SchematXSD.newValidator(); // Validate XML / XSD XSDValidator.validate(sourceXML); isvalid = true; } catch (SAXException ex) { validationmsg = ex.getMessage(); } catch (IOException ex) { validationmsg = ex.getMessage(); } finally { try { if (xsdfile != null) { xsdfile.close(); } } catch (IOException e) { // Ignore errors } } Object[] outputRowData = null; Object[] outputRowData2 = null; if (meta.getOutputStringField()) { // Output type=String if (isvalid) { outputRowData = RowDataUtil.addValueData(row, getInputRowMeta().size(), environmentSubstitute(meta.getIfXmlValid())); } else { outputRowData = RowDataUtil.addValueData(row, getInputRowMeta().size(), environmentSubstitute(meta.getIfXmlInvalid())); } } else { outputRowData = RowDataUtil.addValueData(row, getInputRowMeta().size(), isvalid); } if (meta.useAddValidationMessage()) { outputRowData2 = RowDataUtil.addValueData(outputRowData, getInputRowMeta().size() + 1, validationmsg); } else { outputRowData2 = outputRowData; } if (log.isRowLevel()) { logRowlevel(BaseMessages.getString(PKG, "XsdValidator.Log.ReadRow") + " " + getInputRowMeta().getString(row)); } // add new values to the row. putRow(data.outputRowMeta, outputRowData2); // copy row to output rowset(s); } catch (KettleException e) { boolean sendToErrorRow = false; String errorMessage = null; if (getStepMeta().isDoingErrorHandling()) { sendToErrorRow = true; errorMessage = e.toString(); } if (sendToErrorRow) { // Simply add this row to the error row putError(getInputRowMeta(), row, 1, errorMessage, null, "XSD001"); } else { logError(BaseMessages.getString(PKG, "XsdValidator.ErrorProcesing" + " : " + e.getMessage())); throw new KettleStepException(BaseMessages.getString(PKG, "XsdValidator.ErrorProcesing"), e); } } return true; }
From source file:org.pentaho.di.trans.steps.xslt.Xslt.java
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException { meta = (XsltMeta) smi;/*from www. j av a 2 s. c om*/ data = (XsltData) sdi; Object[] row = getRow(); if (row == null) { // no more input to be expected... setOutputDone(); return false; } if (first) { first = false; data.outputRowMeta = getInputRowMeta().clone(); meta.getFields(data.outputRowMeta, getStepname(), null, null, this, repository, metaStore); // Check if The result field is given if (Const.isEmpty(meta.getResultfieldname())) { // Result Field is missing ! logError(BaseMessages.getString(PKG, "Xslt.Log.ErrorResultFieldMissing")); throw new KettleStepException( BaseMessages.getString(PKG, "Xslt.Exception.ErrorResultFieldMissing")); } // Check if The XML field is given if (Const.isEmpty(meta.getFieldname())) { // Result Field is missing ! logError(BaseMessages.getString(PKG, "Xslt.Exception.ErrorXMLFieldMissing")); throw new KettleStepException(BaseMessages.getString(PKG, "Xslt.Exception.ErrorXMLFieldMissing")); } // Try to get XML Field index data.fieldposition = getInputRowMeta().indexOfValue(meta.getFieldname()); // Let's check the Field if (data.fieldposition < 0) { // The field is unreachable ! logError(BaseMessages.getString(PKG, "Xslt.Log.ErrorFindingField") + "[" + meta.getFieldname() + "]"); throw new KettleStepException( BaseMessages.getString(PKG, "Xslt.Exception.CouldnotFindField", meta.getFieldname())); } // Check if the XSL Filename is contained in a column if (meta.useXSLField()) { if (Const.isEmpty(meta.getXSLFileField())) { // The field is missing // Result field is missing ! logError(BaseMessages.getString(PKG, "Xslt.Log.ErrorXSLFileFieldMissing")); throw new KettleStepException( BaseMessages.getString(PKG, "Xslt.Exception.ErrorXSLFileFieldMissing")); } // Try to get Field index data.fielxslfiledposition = getInputRowMeta().indexOfValue(meta.getXSLFileField()); // Let's check the Field if (data.fielxslfiledposition < 0) { // The field is unreachable ! logError(BaseMessages.getString(PKG, "Xslt.Log.ErrorXSLFileFieldFinding") + "[" + meta.getXSLFileField() + "]"); throw new KettleStepException(BaseMessages.getString(PKG, "Xslt.Exception.ErrorXSLFileFieldFinding", meta.getXSLFileField())); } } else { if (Const.isEmpty(meta.getXslFilename())) { logError(BaseMessages.getString(PKG, "Xslt.Log.ErrorXSLFile")); throw new KettleStepException(BaseMessages.getString(PKG, "Xslt.Exception.ErrorXSLFile")); } // Check if XSL File exists! data.xslfilename = environmentSubstitute(meta.getXslFilename()); FileObject file = null; try { file = KettleVFS.getFileObject(data.xslfilename); if (!file.exists()) { logError(BaseMessages.getString(PKG, "Xslt.Log.ErrorXSLFileNotExists", data.xslfilename)); throw new KettleStepException(BaseMessages.getString(PKG, "Xslt.Exception.ErrorXSLFileNotExists", data.xslfilename)); } if (file.getType() != FileType.FILE) { logError(BaseMessages.getString(PKG, "Xslt.Log.ErrorXSLNotAFile", data.xslfilename)); throw new KettleStepException( BaseMessages.getString(PKG, "Xslt.Exception.ErrorXSLNotAFile", data.xslfilename)); } } catch (Exception e) { throw new KettleStepException(e); } finally { try { if (file != null) { file.close(); } } catch (Exception e) { /* Ignore */ } } } // Check output parameters int nrOutputProps = meta.getOutputPropertyName() == null ? 0 : meta.getOutputPropertyName().length; if (nrOutputProps > 0) { data.outputProperties = new Properties(); for (int i = 0; i < nrOutputProps; i++) { data.outputProperties.put(meta.getOutputPropertyName()[i], environmentSubstitute(meta.getOutputPropertyValue()[i])); } data.setOutputProperties = true; } // Check parameters data.nrParams = meta.getParameterField() == null ? 0 : meta.getParameterField().length; if (data.nrParams > 0) { data.indexOfParams = new int[data.nrParams]; data.nameOfParams = new String[data.nrParams]; for (int i = 0; i < data.nrParams; i++) { String name = environmentSubstitute(meta.getParameterName()[i]); String field = environmentSubstitute(meta.getParameterField()[i]); if (Const.isEmpty(field)) { throw new KettleStepException( BaseMessages.getString(PKG, "Xslt.Exception.ParameterFieldMissing", name, i)); } data.indexOfParams[i] = getInputRowMeta().indexOfValue(field); if (data.indexOfParams[i] < 0) { throw new KettleStepException( BaseMessages.getString(PKG, "Xslt.Exception.ParameterFieldNotFound", name)); } data.nameOfParams[i] = name; } data.useParameters = true; } data.factory = TransformerFactory.newInstance(); if (meta.getXSLFactory().equals("SAXON")) { // Set the TransformerFactory to the SAXON implementation. data.factory = new net.sf.saxon.TransformerFactoryImpl(); } } // end if first // Get the field value String xmlValue = getInputRowMeta().getString(row, data.fieldposition); if (meta.useXSLField()) { // Get the value data.xslfilename = getInputRowMeta().getString(row, data.fielxslfiledposition); if (log.isDetailed()) { logDetailed(BaseMessages.getString(PKG, "Xslt.Log.XslfileNameFromFied", data.xslfilename, meta.getXSLFileField())); } } try { if (log.isDetailed()) { if (meta.isXSLFieldIsAFile()) { logDetailed(BaseMessages.getString(PKG, "Xslt.Log.Filexsl") + data.xslfilename); } else { logDetailed(BaseMessages.getString(PKG, "Xslt.Log.XslStream", data.xslfilename)); } } // Get the template from the cache Transformer transformer = data.getTemplate(data.xslfilename, data.xslIsAfile); // Do we need to set output properties? if (data.setOutputProperties) { transformer.setOutputProperties(data.outputProperties); } // Do we need to pass parameters? if (data.useParameters) { for (int i = 0; i < data.nrParams; i++) { transformer.setParameter(data.nameOfParams[i], row[data.indexOfParams[i]]); } } Source source = new StreamSource(new StringReader(xmlValue)); // Prepare output stream StreamResult result = new StreamResult(new StringWriter()); // transform xml source transformer.transform(source, result); String xmlString = result.getWriter().toString(); if (log.isDetailed()) { logDetailed(BaseMessages.getString(PKG, "Xslt.Log.FileResult")); logDetailed(xmlString); } Object[] outputRowData = RowDataUtil.addValueData(row, getInputRowMeta().size(), xmlString); if (log.isRowLevel()) { logRowlevel( BaseMessages.getString(PKG, "Xslt.Log.ReadRow") + " " + getInputRowMeta().getString(row)); } // add new values to the row. putRow(data.outputRowMeta, outputRowData); // copy row to output rowset(s); } catch (Exception e) { String errorMessage = e.getMessage(); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); DefaultErrorHandler.printLocation(pw, e); pw.close(); errorMessage = sw.toString() + "\n" + errorMessage; if (getStepMeta().isDoingErrorHandling()) { // Simply add this row to the error row putError(getInputRowMeta(), row, 1, errorMessage, meta.getResultfieldname(), "XSLT01"); } else { logError(BaseMessages.getString(PKG, "Xslt.ErrorProcesing" + " : " + errorMessage)); throw new KettleStepException(BaseMessages.getString(PKG, "Xslt.ErrorProcesing"), e); } } return true; }
From source file:org.pentaho.di.trans.steps.xslt.XsltData.java
private Transformer createNewTemplate(String xslSource, boolean isAfile) throws Exception { FileObject file = null; InputStream xslInputStream = null; Transformer transformer = null; try {//from w ww . j a v a 2s .c o m if (isAfile) { file = KettleVFS.getFileObject(xslSource); xslInputStream = KettleVFS.getInputStream(file); } else { xslInputStream = new ByteArrayInputStream(xslSource.getBytes("UTF-8")); } // Use the factory to create a template containing the xsl source transformer = factory.newTransformer(new StreamSource(xslInputStream)); // Add transformer to cache transformers.put(xslSource, transformer); return transformer; } finally { try { if (file != null) { file.close(); } if (xslInputStream != null) { xslInputStream.close(); } } catch (Exception e) { /* Ignore */ } } }
From source file:org.pentaho.di.trans.steps.zipfile.ZipFile.java
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException { meta = (ZipFileMeta) smi;//ww w . ja v a2 s . c o m data = (ZipFileData) sdi; Object[] r = getRow(); // Get row from input rowset & set row busy! if (r == null) { // no more input to be expected... setOutputDone(); return false; } if (first) { first = false; data.outputRowMeta = getInputRowMeta().clone(); meta.getFields(data.outputRowMeta, getStepname(), null, null, this, getTrans().getRepository(), getTrans().getMetaStore()); // Check is source filename field is provided if (Const.isEmpty(meta.getDynamicSourceFileNameField())) { throw new KettleException(BaseMessages.getString(PKG, "ZipFile.Error.SourceFilenameFieldMissing")); } // Check is target filename field is provided if (Const.isEmpty(meta.getDynamicTargetFileNameField())) { throw new KettleException(BaseMessages.getString(PKG, "ZipFile.Error.TargetFilenameFieldMissing")); } // cache the position of the source filename field if (data.indexOfSourceFilename < 0) { data.indexOfSourceFilename = getInputRowMeta().indexOfValue(meta.getDynamicSourceFileNameField()); if (data.indexOfSourceFilename < 0) { // The field is unreachable ! throw new KettleException(BaseMessages.getString(PKG, "ZipFile.Exception.CouldnotFindField", meta.getDynamicSourceFileNameField())); } } data.indexOfZipFilename = getInputRowMeta().indexOfValue(meta.getDynamicTargetFileNameField()); if (data.indexOfZipFilename < 0) { // The field is unreachable ! throw new KettleException(BaseMessages.getString(PKG, "ZipFile.Exception.CouldnotFindField", meta.getDynamicTargetFileNameField())); } if (meta.isKeepSouceFolder()) { if (!Const.isEmpty(meta.getBaseFolderField())) { // cache the position of the source filename field data.indexOfBaseFolder = getInputRowMeta().indexOfValue(meta.getBaseFolderField()); if (data.indexOfBaseFolder < 0) { // The field is unreachable ! throw new KettleException(BaseMessages.getString(PKG, "ZipFile.Exception.CouldnotFindField", meta.getBaseFolderField())); } } } // Move to folder if (meta.getOperationType() == ZipFileMeta.OPERATION_TYPE_MOVE) { if (Const.isEmpty(meta.getMoveToFolderField())) { throw new KettleException(BaseMessages.getString(PKG, "ZipFile.Exception.EmptyMovetoFolder")); } data.indexOfMoveToFolder = getInputRowMeta().indexOfValue(meta.getMoveToFolderField()); if (data.indexOfMoveToFolder < 0) { // The field is unreachable ! throw new KettleException(BaseMessages.getString(PKG, "ZipFile.Exception.CouldnotFindField", meta.getMoveToFolderField())); } } } // End If first boolean sendToErrorRow = false; String errorMessage = null; try { // get source filename String sourceFilename = getInputRowMeta().getString(r, data.indexOfSourceFilename); if (Const.isEmpty(sourceFilename)) { log.logError(toString(), BaseMessages.getString(PKG, "ZipFile.Error.SourceFileEmpty")); throw new KettleException(BaseMessages.getString(PKG, "ZipFile.Error.SourceFileEmpty")); } data.sourceFile = KettleVFS.getFileObject(sourceFilename); // Check sourcefile boolean skip = false; if (!data.sourceFile.exists()) { log.logError(toString(), BaseMessages.getString(PKG, "ZipFile.Error.SourceFileNotExist", sourceFilename)); throw new KettleException( BaseMessages.getString(PKG, "ZipFile.Error.SourceFileNotExist", sourceFilename)); } else { if (data.sourceFile.getType() != FileType.FILE) { log.logError(toString(), BaseMessages.getString(PKG, "ZipFile.Error.SourceFileNotFile", sourceFilename)); throw new KettleException( BaseMessages.getString(PKG, "ZipFile.Error.SourceFileNotFile", sourceFilename)); } } // get basefolder if (data.indexOfBaseFolder > -1) { data.baseFolder = getInputRowMeta().getString(r, data.indexOfBaseFolder); } // get destination folder String moveToFolder = null; if (data.indexOfMoveToFolder > -1) { moveToFolder = getInputRowMeta().getString(r, data.indexOfMoveToFolder); if (Const.isEmpty(moveToFolder)) { throw new KettleException(BaseMessages.getString(PKG, "ZipFile.Error.EmptyMoveToFolder")); } } if (!skip) { // get value for target filename String targetFilename = getInputRowMeta().getString(r, data.indexOfZipFilename); if (Const.isEmpty(targetFilename)) { log.logError(toString(), BaseMessages.getString(PKG, "ZipFile.Error.TargetFileEmpty")); throw new KettleException(BaseMessages.getString(PKG, "ZipFile.Error.TargetFileEmpty")); } data.zipFile = KettleVFS.getFileObject(targetFilename); if (data.zipFile.exists()) { if (log.isDetailed()) { log.logDetailed(toString(), BaseMessages.getString(PKG, "ZipFile.Log.TargetFileExists", targetFilename)); } } else { // let's check parent folder FileObject parentFolder = data.zipFile.getParent(); if (!parentFolder.exists()) { if (!meta.isCreateParentFolder()) { // Parent folder not exist // So we will fail throw new KettleException(BaseMessages.getString(PKG, "ZipFile.Error.TargetParentFolderNotExists", parentFolder.toString())); } else { // Create parent folder parentFolder.createFolder(); } } if (parentFolder != null) { parentFolder.close(); } } // Let's zip zipFile(); // file was zipped, let's see if we need to move or delete it processFile(moveToFolder); // add filename to result filenames? addFilenameToResult(); } getLinesInput(); putRow(data.outputRowMeta, r); // copy row to output rowset(s); if (checkFeedback(getLinesRead())) { if (log.isDetailed()) { logDetailed(BaseMessages.getString(PKG, "ZipFile.LineNumber", "" + getLinesRead())); } } } catch (Exception e) { if (getStepMeta().isDoingErrorHandling()) { sendToErrorRow = true; errorMessage = e.toString(); } else { logError(BaseMessages.getString(PKG, "ZipFile.ErrorInStepRunning") + e.getMessage()); setErrors(1); stopAll(); setOutputDone(); // signal end to receiver(s) return false; } if (sendToErrorRow) { // Simply add this row to the error row putError(getInputRowMeta(), r, 1, errorMessage, null, "ZipFile001"); } } finally { try { if (data.sourceFile != null) { data.sourceFile.close(); } if (data.zipFile != null) { data.zipFile.close(); } } catch (Exception e) { /* Ignore */ } } return true; }
From source file:org.pentaho.di.trans.steps.zipfile.ZipFile.java
private void processFile(String folder) throws Exception { switch (meta.getOperationType()) { case ZipFileMeta.OPERATION_TYPE_MOVE: FileObject file = null; FileObject moveToFolder = null; try {/*from w w w. j a va2s . c om*/ // Move to folder moveToFolder = KettleVFS.getFileObject(folder); if (moveToFolder.exists()) { if (moveToFolder.getType() != FileType.FOLDER) { throw new KettleException(BaseMessages.getString(PKG, "ZipFile.Error.NotAFolder", folder)); } } else { moveToFolder.createFolder(); } // get target filename String targetfilename = KettleVFS.getFilename(moveToFolder) + Const.FILE_SEPARATOR + data.sourceFile.getName().getBaseName(); file = KettleVFS.getFileObject(targetfilename); // Move file data.sourceFile.moveTo(file); } finally { if (file != null) { try { file.close(); } catch (Exception e) { /* Ignore */ } } if (moveToFolder != null) { try { moveToFolder.close(); } catch (Exception e) { /* Ignore */ } } } break; case ZipFileMeta.OPERATION_TYPE_DELETE: data.sourceFile.delete(); break; default: break; } }
From source file:org.pentaho.di.ui.job.entries.job.JobEntryJobDialog.java
public JobEntryInterface open() { Shell parent = getParent();/*from ww w . j av a2 s. co m*/ 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(); } }; backupChanged = jobEntry.hasChanged(); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = Const.FORM_MARGIN; formLayout.marginHeight = Const.FORM_MARGIN; shell.setLayout(formLayout); shell.setText(BaseMessages.getString(PKG, "JobJob.Title")); int middle = props.getMiddlePct(); int margin = Const.MARGIN; // Name line wlName = new Label(shell, SWT.RIGHT); wlName.setText(BaseMessages.getString(PKG, "JobJob.Name.Label")); props.setLook(wlName); FormData fdlName = new FormData(); fdlName.left = new FormAttachment(0, 0); fdlName.top = new FormAttachment(0, 0); fdlName.right = new FormAttachment(middle, -margin); wlName.setLayoutData(fdlName); wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER); props.setLook(wName); wName.addModifyListener(lsMod); FormData fdName = new FormData(); fdName.top = new FormAttachment(0, 0); fdName.left = new FormAttachment(middle, 0); fdName.right = new FormAttachment(100, 0); wName.setLayoutData(fdName); CTabFolder wTabFolder = new CTabFolder(shell, SWT.BORDER); props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB); // Specification // CTabItem wSpecTab = new CTabItem(wTabFolder, SWT.NONE); wSpecTab.setText(BaseMessages.getString(PKG, "JobJob.Specification.Group.Label")); ScrolledComposite wSSpec = new ScrolledComposite(wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL); wSSpec.setLayout(new FillLayout()); Composite wSpec = new Composite(wSSpec, SWT.SHADOW_NONE); props.setLook(wSpec); FormLayout specLayout = new FormLayout(); specLayout.marginWidth = Const.FORM_MARGIN; specLayout.marginHeight = Const.FORM_MARGIN; wSpec.setLayout(specLayout); // The specify by filename option... // Group gFilename = new Group(wSpec, SWT.SHADOW_ETCHED_IN); props.setLook(gFilename); FormLayout gFileLayout = new FormLayout(); gFileLayout.marginWidth = Const.FORM_MARGIN; gFileLayout.marginHeight = Const.FORM_MARGIN; gFilename.setLayout(gFileLayout); radioFilename = new Button(gFilename, SWT.RADIO); props.setLook(radioFilename); radioFilename.setText(BaseMessages.getString(PKG, "JobJob.JobFile.Label")); FormData fdRadioFilename = new FormData(); fdRadioFilename.top = new FormAttachment(0, 0); fdRadioFilename.left = new FormAttachment(0, 0); fdRadioFilename.right = new FormAttachment(middle, -margin); radioFilename.setLayoutData(fdRadioFilename); radioFilename.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { specificationMethod = ObjectLocationSpecificationMethod.FILENAME; setRadioButtons(); } }); wbFilename = new Button(gFilename, SWT.PUSH | SWT.CENTER); props.setLook(wbFilename); wbFilename.setImage(GUIResource.getInstance().getImageJobGraph()); wbFilename.setToolTipText(BaseMessages.getString(PKG, "JobJob.SelectJob.Tooltip")); FormData fdbFilename = new FormData(); fdbFilename.top = new FormAttachment(0, 0); fdbFilename.right = new FormAttachment(100, 0); wbFilename.setLayoutData(fdbFilename); wFilename = new TextVar(jobMeta, gFilename, SWT.SINGLE | SWT.LEFT | SWT.BORDER); props.setLook(wFilename); wFilename.addModifyListener(lsMod); FormData fdFilename = new FormData(); fdFilename.top = new FormAttachment(0, 0); fdFilename.left = new FormAttachment(middle, 0); fdFilename.right = new FormAttachment(wbFilename, -margin); wFilename.setLayoutData(fdFilename); wFilename.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent arg0) { specificationMethod = ObjectLocationSpecificationMethod.FILENAME; setRadioButtons(); } }); FormData fdgFilename = new FormData(); fdgFilename.top = new FormAttachment(0, 0); fdgFilename.left = new FormAttachment(0, 0); fdgFilename.right = new FormAttachment(100, 0); gFilename.setLayoutData(fdgFilename); // The repository : specify by name radio option... // Group gByName = new Group(wSpec, SWT.SHADOW_ETCHED_IN); props.setLook(gByName); FormLayout gByNameLayout = new FormLayout(); gByNameLayout.marginWidth = Const.FORM_MARGIN; gByNameLayout.marginHeight = Const.FORM_MARGIN; gByName.setLayout(gByNameLayout); radioByName = new Button(gByName, SWT.RADIO); props.setLook(radioByName); radioByName.setText(BaseMessages.getString(PKG, "JobJob.NameOfJob.Label")); FormData fdRadioByName = new FormData(); fdRadioByName.top = new FormAttachment(0, 0); fdRadioByName.left = new FormAttachment(0, 0); fdRadioByName.right = new FormAttachment(middle, -margin); radioByName.setLayoutData(fdRadioByName); radioByName.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { specificationMethod = ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME; setRadioButtons(); } }); wbJobname = new Button(gByName, SWT.PUSH | SWT.CENTER); props.setLook(wbJobname); wbJobname.setImage(GUIResource.getInstance().getImageJobGraph()); wbJobname.setToolTipText(BaseMessages.getString(PKG, "JobJob.SelectJobRep.Tooltip")); FormData fdbJobname = new FormData(); fdbJobname.top = new FormAttachment(0, 0); fdbJobname.right = new FormAttachment(100, 0); wbJobname.setLayoutData(fdbJobname); wJobname = new TextVar(jobMeta, gByName, SWT.SINGLE | SWT.LEFT | SWT.BORDER); props.setLook(wJobname); wJobname.addModifyListener(lsMod); FormData fdJobname = new FormData(); fdJobname.top = new FormAttachment(0, 0); fdJobname.left = new FormAttachment(middle, 0); fdJobname.right = new FormAttachment(wbJobname, -margin); wJobname.setLayoutData(fdJobname); wDirectory = new TextVar(jobMeta, gByName, SWT.SINGLE | SWT.LEFT | SWT.BORDER); props.setLook(wDirectory); wDirectory.addModifyListener(lsMod); FormData fdDirectory = new FormData(); fdDirectory.top = new FormAttachment(wJobname, margin * 2); fdDirectory.left = new FormAttachment(middle, 0); fdDirectory.right = new FormAttachment(100, 0); wDirectory.setLayoutData(fdDirectory); FormData fdgByName = new FormData(); fdgByName.top = new FormAttachment(gFilename, margin); fdgByName.left = new FormAttachment(0, 0); fdgByName.right = new FormAttachment(100, 0); gByName.setLayoutData(fdgByName); // The specify by filename option... // Group gByReference = new Group(wSpec, SWT.SHADOW_ETCHED_IN); props.setLook(gByReference); FormLayout gByReferenceLayout = new FormLayout(); gByReferenceLayout.marginWidth = Const.FORM_MARGIN; gByReferenceLayout.marginHeight = Const.FORM_MARGIN; gByReference.setLayout(gByReferenceLayout); radioByReference = new Button(gByReference, SWT.RADIO); props.setLook(radioByReference); radioByReference.setText(BaseMessages.getString(PKG, "JobJob.JobByReference.Label")); FormData fdRadioByReference = new FormData(); fdRadioByReference.top = new FormAttachment(0, 0); fdRadioByReference.left = new FormAttachment(0, 0); fdRadioByReference.right = new FormAttachment(middle, -margin); radioByReference.setLayoutData(fdRadioByReference); radioByReference.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { specificationMethod = ObjectLocationSpecificationMethod.REPOSITORY_BY_REFERENCE; setRadioButtons(); } }); wbByReference = new Button(gByReference, SWT.PUSH | SWT.CENTER); props.setLook(wbByReference); wbByReference.setImage(GUIResource.getInstance().getImageJobGraph()); wbByReference.setToolTipText(BaseMessages.getString(PKG, "JobJob.SelectJob.Tooltip")); FormData fdbByReference = new FormData(); fdbByReference.top = new FormAttachment(0, 0); fdbByReference.right = new FormAttachment(100, 0); wbByReference.setLayoutData(fdbByReference); wByReference = new Text(gByReference, SWT.SINGLE | SWT.LEFT | SWT.BORDER | SWT.READ_ONLY); props.setLook(wByReference); wByReference.addModifyListener(lsMod); FormData fdByReference = new FormData(); fdByReference.top = new FormAttachment(0, 0); fdByReference.left = new FormAttachment(middle, 0); fdByReference.right = new FormAttachment(wbByReference, -margin); wByReference.setLayoutData(fdByReference); FormData fdgByReference = new FormData(); fdgByReference.top = new FormAttachment(gByName, margin); fdgByReference.left = new FormAttachment(0, 0); fdgByReference.right = new FormAttachment(100, 0); gByReference.setLayoutData(fdgByReference); wNewJob = new Button(wSpec, SWT.PUSH); wNewJob.setText(BaseMessages.getString(PKG, "JobJob.NewJobButton.Label")); FormData fdNewJob = new FormData(); fdNewJob.bottom = new FormAttachment(100, -margin); fdNewJob.left = new FormAttachment(wByReference, 0, SWT.CENTER); wNewJob.setLayoutData(fdNewJob); wNewJob.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { newJob(); } }); wSpec.pack(); Rectangle bounds = wSpec.getBounds(); wSSpec.setContent(wSpec); wSSpec.setExpandHorizontal(true); wSSpec.setExpandVertical(true); wSSpec.setMinWidth(bounds.width); wSSpec.setMinHeight(bounds.height); wSpecTab.setControl(wSSpec); FormData fdSpec = new FormData(); fdSpec.left = new FormAttachment(0, 0); fdSpec.top = new FormAttachment(0, 0); fdSpec.right = new FormAttachment(100, 0); fdSpec.bottom = new FormAttachment(100, 0); wSpec.setLayoutData(fdSpec); // Advanced // CTabItem wAdvancedTab = new CTabItem(wTabFolder, SWT.NONE); wAdvancedTab.setText(BaseMessages.getString(PKG, "JobJob.Advanced.Group.Label")); ScrolledComposite wSAdvanced = new ScrolledComposite(wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL); wSAdvanced.setLayout(new FillLayout()); wAdvanced = new Composite(wSAdvanced, SWT.SHADOW_NONE); props.setLook(wAdvanced); FormLayout advancedLayout = new FormLayout(); advancedLayout.marginWidth = Const.FORM_MARGIN; advancedLayout.marginHeight = Const.FORM_MARGIN; wAdvanced.setLayout(advancedLayout); wlPrevious = new Label(wAdvanced, SWT.RIGHT); wlPrevious.setText(BaseMessages.getString(PKG, "JobJob.Previous.Label")); props.setLook(wlPrevious); fdlPrevious = new FormData(); fdlPrevious.left = new FormAttachment(0, 0); fdlPrevious.top = new FormAttachment(0, 0); fdlPrevious.right = new FormAttachment(middle, -margin); wlPrevious.setLayoutData(fdlPrevious); wPrevious = new Button(wAdvanced, SWT.CHECK); props.setLook(wPrevious); wPrevious.setSelection(jobEntry.argFromPrevious); wPrevious.setToolTipText(BaseMessages.getString(PKG, "JobJob.Previous.Tooltip")); fdPrevious = new FormData(); fdPrevious.left = new FormAttachment(middle, 0); fdPrevious.top = new FormAttachment(0, 0); fdPrevious.right = new FormAttachment(100, 0); wPrevious.setLayoutData(fdPrevious); wPrevious.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { jobEntry.setChanged(); } }); wlPrevToParams = new Label(wAdvanced, SWT.RIGHT); wlPrevToParams.setText(BaseMessages.getString(PKG, "JobJob.PrevToParams.Label")); props.setLook(wlPrevToParams); fdlPrevToParams = new FormData(); fdlPrevToParams.left = new FormAttachment(0, 0); fdlPrevToParams.top = new FormAttachment(wPrevious, margin * 3); fdlPrevToParams.right = new FormAttachment(middle, -margin); wlPrevToParams.setLayoutData(fdlPrevToParams); wPrevToParams = new Button(wAdvanced, SWT.CHECK); props.setLook(wPrevToParams); wPrevToParams.setSelection(jobEntry.paramsFromPrevious); wPrevToParams.setToolTipText(BaseMessages.getString(PKG, "JobJob.PrevToParams.Tooltip")); fdPrevToParams = new FormData(); fdPrevToParams.left = new FormAttachment(middle, 0); fdPrevToParams.top = new FormAttachment(wPrevious, margin * 3); fdPrevToParams.right = new FormAttachment(100, 0); wPrevToParams.setLayoutData(fdPrevToParams); wPrevToParams.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { jobEntry.setChanged(); } }); wlEveryRow = new Label(wAdvanced, SWT.RIGHT); wlEveryRow.setText(BaseMessages.getString(PKG, "JobJob.ExecForEveryInputRow.Label")); props.setLook(wlEveryRow); fdlEveryRow = new FormData(); fdlEveryRow.left = new FormAttachment(0, 0); fdlEveryRow.top = new FormAttachment(wPrevToParams, margin * 3); fdlEveryRow.right = new FormAttachment(middle, -margin); wlEveryRow.setLayoutData(fdlEveryRow); wEveryRow = new Button(wAdvanced, SWT.CHECK); props.setLook(wEveryRow); wEveryRow.setSelection(jobEntry.execPerRow); wEveryRow.setToolTipText(BaseMessages.getString(PKG, "JobJob.ExecForEveryInputRow.Tooltip")); fdEveryRow = new FormData(); fdEveryRow.left = new FormAttachment(middle, 0); fdEveryRow.top = new FormAttachment(wPrevToParams, margin * 3); fdEveryRow.right = new FormAttachment(100, 0); wEveryRow.setLayoutData(fdEveryRow); wEveryRow.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { jobEntry.execPerRow = !jobEntry.execPerRow; jobEntry.setChanged(); } }); // The remote slave server wlSlaveServer = new Label(wAdvanced, SWT.RIGHT); wlSlaveServer.setText(BaseMessages.getString(PKG, "JobJob.SlaveServer.Label")); wlSlaveServer.setToolTipText(BaseMessages.getString(PKG, "JobJob.SlaveServer.ToolTip")); props.setLook(wlSlaveServer); fdlSlaveServer = new FormData(); fdlSlaveServer.left = new FormAttachment(0, 0); fdlSlaveServer.right = new FormAttachment(middle, -margin); fdlSlaveServer.top = new FormAttachment(wEveryRow, margin); wlSlaveServer.setLayoutData(fdlSlaveServer); wSlaveServer = new ComboVar(jobMeta, wAdvanced, SWT.SINGLE | SWT.BORDER); wSlaveServer.setItems(SlaveServer.getSlaveServerNames(jobMeta.getSlaveServers())); wSlaveServer.setToolTipText(BaseMessages.getString(PKG, "JobJob.SlaveServer.ToolTip")); props.setLook(wSlaveServer); fdSlaveServer = new FormData(); fdSlaveServer.left = new FormAttachment(middle, 0); fdSlaveServer.top = new FormAttachment(wEveryRow, margin); fdSlaveServer.right = new FormAttachment(100, 0); wSlaveServer.setLayoutData(fdSlaveServer); wSlaveServer.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setActive(); } }); // Pass the export of this job as an export to the slave server // wlPassExport = new Label(wAdvanced, SWT.RIGHT); wlPassExport.setText(BaseMessages.getString(PKG, "JobJob.PassExportToSlave.Label")); props.setLook(wlPassExport); fdlPassExport = new FormData(); fdlPassExport.left = new FormAttachment(0, 0); fdlPassExport.top = new FormAttachment(wSlaveServer, margin); fdlPassExport.right = new FormAttachment(middle, -margin); wlPassExport.setLayoutData(fdlPassExport); wPassExport = new Button(wAdvanced, SWT.CHECK); props.setLook(wPassExport); fdPassExport = new FormData(); fdPassExport.left = new FormAttachment(middle, 0); fdPassExport.top = new FormAttachment(wSlaveServer, margin); fdPassExport.right = new FormAttachment(100, 0); wPassExport.setLayoutData(fdPassExport); // Wait for the remote transformation to finish? // wlWaitingToFinish = new Label(wAdvanced, SWT.RIGHT); wlWaitingToFinish.setText(BaseMessages.getString(PKG, "JobJob.WaitToFinish.Label")); props.setLook(wlWaitingToFinish); fdlWaitingToFinish = new FormData(); fdlWaitingToFinish.left = new FormAttachment(0, 0); fdlWaitingToFinish.top = new FormAttachment(wPassExport, margin); fdlWaitingToFinish.right = new FormAttachment(middle, -margin); wlWaitingToFinish.setLayoutData(fdlWaitingToFinish); wWaitingToFinish = new Button(wAdvanced, SWT.CHECK); props.setLook(wWaitingToFinish); fdWaitingToFinish = new FormData(); fdWaitingToFinish.left = new FormAttachment(middle, 0); fdWaitingToFinish.top = new FormAttachment(wPassExport, margin); fdWaitingToFinish.right = new FormAttachment(100, 0); wWaitingToFinish.setLayoutData(fdWaitingToFinish); wWaitingToFinish.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setActive(); } }); // Follow a local abort remotely? // wlFollowingAbortRemotely = new Label(wAdvanced, SWT.RIGHT); wlFollowingAbortRemotely.setText(BaseMessages.getString(PKG, "JobJob.AbortRemote.Label")); props.setLook(wlFollowingAbortRemotely); fdlFollowingAbortRemotely = new FormData(); fdlFollowingAbortRemotely.left = new FormAttachment(0, 0); fdlFollowingAbortRemotely.top = new FormAttachment(wWaitingToFinish, margin); fdlFollowingAbortRemotely.right = new FormAttachment(middle, -margin); wlFollowingAbortRemotely.setLayoutData(fdlFollowingAbortRemotely); wFollowingAbortRemotely = new Button(wAdvanced, SWT.CHECK); props.setLook(wFollowingAbortRemotely); fdFollowingAbortRemotely = new FormData(); fdFollowingAbortRemotely.left = new FormAttachment(middle, 0); fdFollowingAbortRemotely.top = new FormAttachment(wWaitingToFinish, margin); fdFollowingAbortRemotely.right = new FormAttachment(100, 0); wFollowingAbortRemotely.setLayoutData(fdFollowingAbortRemotely); // Expand the job on the remote server, make the sub-jobs and transformations visible // wlExpandRemote = new Label(wAdvanced, SWT.RIGHT); wlExpandRemote.setText(BaseMessages.getString(PKG, "JobEntryJobDialog.ExpandRemoteOnSlave.Label")); props.setLook(wlExpandRemote); fdlExpandRemote = new FormData(); fdlExpandRemote.left = new FormAttachment(0, 0); fdlExpandRemote.top = new FormAttachment(wFollowingAbortRemotely, margin); fdlExpandRemote.right = new FormAttachment(middle, -margin); wlExpandRemote.setLayoutData(fdlExpandRemote); wExpandRemote = new Button(wAdvanced, SWT.CHECK); props.setLook(wExpandRemote); fdExpandRemote = new FormData(); fdExpandRemote.left = new FormAttachment(middle, 0); fdExpandRemote.top = new FormAttachment(wFollowingAbortRemotely, margin); fdExpandRemote.right = new FormAttachment(100, 0); wExpandRemote.setLayoutData(fdExpandRemote); wAdvanced.pack(); bounds = wAdvanced.getBounds(); wSAdvanced.setContent(wAdvanced); wSAdvanced.setExpandHorizontal(true); wSAdvanced.setExpandVertical(true); wSAdvanced.setMinWidth(bounds.width); wSAdvanced.setMinHeight(bounds.height); wAdvancedTab.setControl(wSAdvanced); // Logging // CTabItem wLoggingTab = new CTabItem(wTabFolder, SWT.NONE); wLoggingTab.setText(BaseMessages.getString(PKG, "JobJob.LogSettings.Group.Label")); ScrolledComposite wSLogging = new ScrolledComposite(wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL); wSLogging.setLayout(new FillLayout()); wLogging = new Composite(wSLogging, SWT.SHADOW_NONE); props.setLook(wLogging); FormLayout groupLayout = new FormLayout(); groupLayout.marginWidth = Const.FORM_MARGIN; groupLayout.marginHeight = Const.FORM_MARGIN; wLogging.setLayout(groupLayout); Label wlForceSeparateLogging = new Label(wLogging, SWT.RIGHT); wlForceSeparateLogging.setText(BaseMessages.getString(PKG, "JobEntryJobDialog.ForceSeparateLogging.Label")); props.setLook(wlForceSeparateLogging); FormData fdlForceSeparateLogging = new FormData(); fdlForceSeparateLogging.left = new FormAttachment(0, 0); fdlForceSeparateLogging.top = new FormAttachment(0, margin); fdlForceSeparateLogging.right = new FormAttachment(middle, -margin); wlForceSeparateLogging.setLayoutData(fdlForceSeparateLogging); wForceSeparateLogging = new Button(wLogging, SWT.CHECK); props.setLook(wForceSeparateLogging); wForceSeparateLogging .setToolTipText(BaseMessages.getString(PKG, "JobEntryJobDialog.ForceSeparateLogging.Tooltip")); FormData fdForceSeparateLogging = new FormData(); fdForceSeparateLogging.left = new FormAttachment(middle, 0); fdForceSeparateLogging.top = new FormAttachment(0, margin); fdForceSeparateLogging.right = new FormAttachment(100, 0); wForceSeparateLogging.setLayoutData(fdForceSeparateLogging); // Set the logfile? // wlSetLogfile = new Label(wLogging, SWT.RIGHT); wlSetLogfile.setText(BaseMessages.getString(PKG, "JobJob.Specify.Logfile.Label")); props.setLook(wlSetLogfile); fdlSetLogfile = new FormData(); fdlSetLogfile.left = new FormAttachment(0, 0); fdlSetLogfile.top = new FormAttachment(wForceSeparateLogging, margin); fdlSetLogfile.right = new FormAttachment(middle, -margin); wlSetLogfile.setLayoutData(fdlSetLogfile); wSetLogfile = new Button(wLogging, SWT.CHECK); props.setLook(wSetLogfile); fdSetLogfile = new FormData(); fdSetLogfile.left = new FormAttachment(middle, 0); fdSetLogfile.top = new FormAttachment(wForceSeparateLogging, margin); fdSetLogfile.right = new FormAttachment(100, 0); wSetLogfile.setLayoutData(fdSetLogfile); wSetLogfile.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setActive(); } }); // Append logfile? wlAppendLogfile = new Label(wLogging, SWT.RIGHT); wlAppendLogfile.setText(BaseMessages.getString(PKG, "JobJob.Append.Logfile.Label")); props.setLook(wlAppendLogfile); fdlAppendLogfile = new FormData(); fdlAppendLogfile.left = new FormAttachment(0, 0); fdlAppendLogfile.top = new FormAttachment(wSetLogfile, margin); fdlAppendLogfile.right = new FormAttachment(middle, -margin); wlAppendLogfile.setLayoutData(fdlAppendLogfile); wAppendLogfile = new Button(wLogging, SWT.CHECK); wAppendLogfile.setToolTipText(BaseMessages.getString(PKG, "JobJob.Append.Logfile.Tooltip")); props.setLook(wAppendLogfile); fdAppendLogfile = new FormData(); fdAppendLogfile.left = new FormAttachment(middle, 0); fdAppendLogfile.top = new FormAttachment(wSetLogfile, margin); fdAppendLogfile.right = new FormAttachment(100, 0); wAppendLogfile.setLayoutData(fdAppendLogfile); wAppendLogfile.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { } }); // Set the logfile path + base-name wlLogfile = new Label(wLogging, SWT.RIGHT); wlLogfile.setText(BaseMessages.getString(PKG, "JobJob.NameOfLogfile.Label")); props.setLook(wlLogfile); fdlLogfile = new FormData(); fdlLogfile.left = new FormAttachment(0, 0); fdlLogfile.top = new FormAttachment(wAppendLogfile, margin); fdlLogfile.right = new FormAttachment(middle, -margin); wlLogfile.setLayoutData(fdlLogfile); wbLogFilename = new Button(wLogging, SWT.PUSH | SWT.CENTER); props.setLook(wbLogFilename); wbLogFilename.setText(BaseMessages.getString(PKG, "JobJob.Browse.Label")); fdbLogFilename = new FormData(); fdbLogFilename.top = new FormAttachment(wAppendLogfile, margin); fdbLogFilename.right = new FormAttachment(100, 0); wbLogFilename.setLayoutData(fdbLogFilename); wLogfile = new TextVar(jobMeta, wLogging, SWT.SINGLE | SWT.LEFT | SWT.BORDER); wLogfile.setText(""); props.setLook(wLogfile); fdLogfile = new FormData(); fdLogfile.left = new FormAttachment(middle, 0); fdLogfile.top = new FormAttachment(wAppendLogfile, margin); fdLogfile.right = new FormAttachment(wbLogFilename, -margin); wLogfile.setLayoutData(fdLogfile); // create parent folder? wlCreateParentFolder = new Label(wLogging, SWT.RIGHT); wlCreateParentFolder.setText(BaseMessages.getString(PKG, "JobJob.Logfile.CreateParentFolder.Label")); props.setLook(wlCreateParentFolder); fdlCreateParentFolder = new FormData(); fdlCreateParentFolder.left = new FormAttachment(0, 0); fdlCreateParentFolder.top = new FormAttachment(wLogfile, margin); fdlCreateParentFolder.right = new FormAttachment(middle, -margin); wlCreateParentFolder.setLayoutData(fdlCreateParentFolder); wCreateParentFolder = new Button(wLogging, SWT.CHECK); wCreateParentFolder .setToolTipText(BaseMessages.getString(PKG, "JobJob.Logfile.CreateParentFolder.Tooltip")); props.setLook(wCreateParentFolder); fdCreateParentFolder = new FormData(); fdCreateParentFolder.left = new FormAttachment(middle, 0); fdCreateParentFolder.top = new FormAttachment(wLogfile, margin); fdCreateParentFolder.right = new FormAttachment(100, 0); wCreateParentFolder.setLayoutData(fdCreateParentFolder); wCreateParentFolder.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { } }); // Set the logfile filename extention wlLogext = new Label(wLogging, SWT.RIGHT); wlLogext.setText(BaseMessages.getString(PKG, "JobJob.LogfileExtension.Label")); props.setLook(wlLogext); fdlLogext = new FormData(); fdlLogext.left = new FormAttachment(0, 0); fdlLogext.top = new FormAttachment(wCreateParentFolder, margin); fdlLogext.right = new FormAttachment(middle, -margin); wlLogext.setLayoutData(fdlLogext); wLogext = new TextVar(jobMeta, wLogging, SWT.SINGLE | SWT.LEFT | SWT.BORDER); wLogext.setText(""); props.setLook(wLogext); fdLogext = new FormData(); fdLogext.left = new FormAttachment(middle, 0); fdLogext.top = new FormAttachment(wCreateParentFolder, margin); fdLogext.right = new FormAttachment(100, 0); wLogext.setLayoutData(fdLogext); // Add date to logfile name? wlAddDate = new Label(wLogging, SWT.RIGHT); wlAddDate.setText(BaseMessages.getString(PKG, "JobJob.Logfile.IncludeDate.Label")); props.setLook(wlAddDate); fdlAddDate = new FormData(); fdlAddDate.left = new FormAttachment(0, 0); fdlAddDate.top = new FormAttachment(wLogext, margin); fdlAddDate.right = new FormAttachment(middle, -margin); wlAddDate.setLayoutData(fdlAddDate); wAddDate = new Button(wLogging, SWT.CHECK); props.setLook(wAddDate); fdAddDate = new FormData(); fdAddDate.left = new FormAttachment(middle, 0); fdAddDate.top = new FormAttachment(wLogext, margin); fdAddDate.right = new FormAttachment(100, 0); wAddDate.setLayoutData(fdAddDate); // Add time to logfile name? wlAddTime = new Label(wLogging, SWT.RIGHT); wlAddTime.setText(BaseMessages.getString(PKG, "JobJob.Logfile.IncludeTime.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(wLogging, 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); wlLoglevel = new Label(wLogging, SWT.RIGHT); wlLoglevel.setText(BaseMessages.getString(PKG, "JobJob.Loglevel.Label")); props.setLook(wlLoglevel); fdlLoglevel = new FormData(); fdlLoglevel.left = new FormAttachment(0, 0); fdlLoglevel.right = new FormAttachment(middle, -margin); fdlLoglevel.top = new FormAttachment(wAddTime, margin); wlLoglevel.setLayoutData(fdlLoglevel); wLoglevel = new CCombo(wLogging, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER); wLoglevel.setItems(LogLevel.getLogLevelDescriptions()); props.setLook(wLoglevel); fdLoglevel = new FormData(); fdLoglevel.left = new FormAttachment(middle, 0); fdLoglevel.top = new FormAttachment(wAddTime, margin); fdLoglevel.right = new FormAttachment(100, 0); wLoglevel.setLayoutData(fdLoglevel); fdLogging = new FormData(); fdLogging.left = new FormAttachment(0, margin); fdLogging.top = new FormAttachment(wbFilename, margin); fdLogging.right = new FormAttachment(100, -margin); wLogging.setLayoutData(fdLogging); wLogging.pack(); bounds = wLogging.getBounds(); wSLogging.setContent(wLogging); wSLogging.setExpandHorizontal(true); wSLogging.setExpandVertical(true); wSLogging.setMinWidth(bounds.width); wSLogging.setMinHeight(bounds.height); wLoggingTab.setControl(wSLogging); // Arguments // CTabItem wFieldTab = new CTabItem(wTabFolder, SWT.NONE); wFieldTab.setText(BaseMessages.getString(PKG, "JobJob.Fields.Argument.Label")); FormLayout fieldLayout = new FormLayout(); fieldLayout.marginWidth = Const.MARGIN; fieldLayout.marginHeight = Const.MARGIN; Composite wFieldComp = new Composite(wTabFolder, SWT.NONE); props.setLook(wFieldComp); wFieldComp.setLayout(fieldLayout); final int FieldsCols = 1; int rows = jobEntry.arguments == null ? 1 : (jobEntry.arguments.length == 0 ? 0 : jobEntry.arguments.length); final int FieldsRows = rows; ColumnInfo[] colinf = new ColumnInfo[FieldsCols]; colinf[0] = new ColumnInfo(BaseMessages.getString(PKG, "JobJob.Fields.Argument.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false); colinf[0].setUsingVariables(true); wFields = new TableView(jobMeta, wFieldComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod, props); FormData fdFields = new FormData(); fdFields.left = new FormAttachment(0, 0); fdFields.top = new FormAttachment(0, margin); fdFields.right = new FormAttachment(100, 0); fdFields.bottom = new FormAttachment(100, 0); wFields.setLayoutData(fdFields); FormData 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); wFieldComp.setLayoutData(fdFieldsComp); wFieldComp.layout(); wFieldTab.setControl(wFieldComp); // The parameters tab CTabItem wParametersTab = new CTabItem(wTabFolder, SWT.NONE); wParametersTab.setText(BaseMessages.getString(PKG, "JobJob.Fields.Parameters.Label")); fieldLayout = new FormLayout(); fieldLayout.marginWidth = Const.MARGIN; fieldLayout.marginHeight = Const.MARGIN; Composite wParameterComp = new Composite(wTabFolder, SWT.NONE); props.setLook(wParameterComp); wParameterComp.setLayout(fieldLayout); // Pass all parameters down // wlPassParams = new Label(wParameterComp, SWT.RIGHT); wlPassParams.setText(BaseMessages.getString(PKG, "JobJob.PassAllParameters.Label")); props.setLook(wlPassParams); fdlPassParams = new FormData(); fdlPassParams.left = new FormAttachment(0, 0); fdlPassParams.top = new FormAttachment(0, 0); fdlPassParams.right = new FormAttachment(middle, -margin); wlPassParams.setLayoutData(fdlPassParams); wPassParams = new Button(wParameterComp, SWT.CHECK); props.setLook(wPassParams); fdPassParams = new FormData(); fdPassParams.left = new FormAttachment(middle, 0); fdPassParams.top = new FormAttachment(0, 0); fdPassParams.right = new FormAttachment(100, 0); wPassParams.setLayoutData(fdPassParams); wbGetParams = new Button(wParameterComp, SWT.PUSH); wbGetParams.setText(BaseMessages.getString(PKG, "JobJob.GetParameters.Button.Label")); FormData fdGetParams = new FormData(); fdGetParams.top = new FormAttachment(wPassParams, margin); fdGetParams.right = new FormAttachment(100, 0); wbGetParams.setLayoutData(fdGetParams); wbGetParams.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { getParameters(null); // null: reload file from specification } }); final int parameterRows = jobEntry.parameters == null ? 0 : jobEntry.parameters.length; colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "JobJob.Parameters.Parameter.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "JobJob.Parameters.ColumnName.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "JobJob.Parameters.Value.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), }; colinf[2].setUsingVariables(true); wParameters = new TableView(jobMeta, wParameterComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, parameterRows, lsMod, props); FormData fdParameters = new FormData(); fdParameters.left = new FormAttachment(0, 0); fdParameters.top = new FormAttachment(wPassParams, margin); fdParameters.right = new FormAttachment(wbGetParams, -margin); fdParameters.bottom = new FormAttachment(100, 0); wParameters.setLayoutData(fdParameters); FormData fdParametersComp = new FormData(); fdParametersComp.left = new FormAttachment(0, 0); fdParametersComp.top = new FormAttachment(0, 0); fdParametersComp.right = new FormAttachment(100, 0); fdParametersComp.bottom = new FormAttachment(100, 0); wParameterComp.setLayoutData(fdParametersComp); wParameterComp.layout(); wParametersTab.setControl(wParameterComp); FormData fdTabFolder = new FormData(); fdTabFolder.left = new FormAttachment(0, 0); fdTabFolder.top = new FormAttachment(wName, margin * 3); fdTabFolder.right = new FormAttachment(100, 0); fdTabFolder.bottom = new FormAttachment(100, -50); wTabFolder.setLayoutData(fdTabFolder); wTabFolder.setSelection(0); // Some buttons wOK = new Button(shell, SWT.PUSH); wOK.setText(BaseMessages.getString(PKG, "System.Button.OK")); wCancel = new Button(shell, SWT.PUSH); wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel")); BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, wTabFolder); // Add listeners lsCancel = new Listener() { public void handleEvent(Event e) { cancel(); } }; lsOK = new Listener() { public void handleEvent(Event e) { ok(); } }; wOK.addListener(SWT.Selection, lsOK); wCancel.addListener(SWT.Selection, lsCancel); lsDef = new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { ok(); } }; wName.addSelectionListener(lsDef); wFilename.addSelectionListener(lsDef); wbJobname.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { selectJob(); } }); wbFilename.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { pickFileVFS(); } }); wbByReference.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { selectJobByReference(); } }); wbLogFilename.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(shell, SWT.SAVE); dialog.setFilterExtensions(new String[] { "*.txt", "*.log", "*" }); dialog.setFilterNames(FILE_FILTERLOGNAMES); if (wLogfile.getText() != null) { dialog.setFileName(jobMeta.environmentSubstitute(wLogfile.getText())); } if (dialog.open() != null) { wLogfile.setText(dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName()); String filename = dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName(); FileObject file = null; try { file = KettleVFS.getFileObject(filename); // Set file extension .. wLogext.setText(file.getName().getExtension()); // Set filename without extension ... wLogfile.setText(wLogfile.getText().substring(0, wLogfile.getText().length() - wLogext.getText().length() - 1)); } catch (Exception ex) { // Ignore } if (file != null) { try { file.close(); } catch (IOException ex) { /* Ignore */ } } } } }); // Detect [X] or ALT-F4 or something that kills this window... shell.addShellListener(new ShellAdapter() { public void shellClosed(ShellEvent e) { cancel(); } }); getData(); setActive(); BaseStepDialog.setSize(shell); shell.open(); props.setDialogSize(shell, "JobJobDialogSize"); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return jobEntry; }
From source file:org.pentaho.di.ui.job.entries.trans.JobEntryTransDialog.java
public JobEntryInterface open() { Shell parent = getParent();//from ww w . j av a 2 s. c om 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(); } }; backupChanged = jobEntry.hasChanged(); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = Const.FORM_MARGIN; formLayout.marginHeight = Const.FORM_MARGIN; shell.setLayout(formLayout); shell.setText(BaseMessages.getString(PKG, "JobTrans.Header")); int middle = props.getMiddlePct(); int margin = Const.MARGIN; // Name line wlName = new Label(shell, SWT.RIGHT); wlName.setText(BaseMessages.getString(PKG, "JobTrans.JobStep.Label")); props.setLook(wlName); fdlName = new FormData(); fdlName.left = new FormAttachment(0, 0); fdlName.top = new FormAttachment(0, 0); fdlName.right = new FormAttachment(middle, -margin); wlName.setLayoutData(fdlName); wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER); props.setLook(wName); wName.addModifyListener(lsMod); fdName = new FormData(); fdName.top = new FormAttachment(0, 0); fdName.left = new FormAttachment(middle, 0); fdName.right = new FormAttachment(100, 0); wName.setLayoutData(fdName); CTabFolder wTabFolder = new CTabFolder(shell, SWT.BORDER); props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB); // Specification // CTabItem wSpecTab = new CTabItem(wTabFolder, SWT.NONE); wSpecTab.setText(BaseMessages.getString(PKG, "JobTrans.Specification.Group.Label")); ScrolledComposite wSSpec = new ScrolledComposite(wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL); wSSpec.setLayout(new FillLayout()); wSpec = new Composite(wSSpec, SWT.SHADOW_NONE); props.setLook(wSpec); FormLayout specLayout = new FormLayout(); specLayout.marginWidth = Const.FORM_MARGIN; specLayout.marginHeight = Const.FORM_MARGIN; wSpec.setLayout(specLayout); // The specify by filename option... // Group gFilename = new Group(wSpec, SWT.SHADOW_ETCHED_IN); props.setLook(gFilename); FormLayout gFileLayout = new FormLayout(); gFileLayout.marginWidth = Const.FORM_MARGIN; gFileLayout.marginHeight = Const.FORM_MARGIN; gFilename.setLayout(gFileLayout); radioFilename = new Button(gFilename, SWT.RADIO); props.setLook(radioFilename); radioFilename.setText(BaseMessages.getString(PKG, "JobTrans.TransformationFile.Label")); FormData fdRadioFilename = new FormData(); fdRadioFilename.top = new FormAttachment(0, 0); fdRadioFilename.left = new FormAttachment(0, 0); fdRadioFilename.right = new FormAttachment(middle, -margin); radioFilename.setLayoutData(fdRadioFilename); radioFilename.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { specificationMethod = ObjectLocationSpecificationMethod.FILENAME; setRadioButtons(); } }); wbFilename = new Button(gFilename, SWT.PUSH | SWT.CENTER); props.setLook(wbFilename); wbFilename.setImage(GUIResource.getInstance().getImageTransGraph()); wbFilename.setToolTipText(BaseMessages.getString(PKG, "JobTrans.SelectTrans.Tooltip")); FormData fdbFilename = new FormData(); fdbFilename.top = new FormAttachment(0, 0); fdbFilename.right = new FormAttachment(100, 0); wbFilename.setLayoutData(fdbFilename); wFilename = new TextVar(jobMeta, gFilename, SWT.SINGLE | SWT.LEFT | SWT.BORDER); props.setLook(wFilename); wFilename.addModifyListener(lsMod); FormData fdFilename = new FormData(); fdFilename.top = new FormAttachment(0, 0); fdFilename.left = new FormAttachment(middle, 0); fdFilename.right = new FormAttachment(wbFilename, -margin); wFilename.setLayoutData(fdFilename); wFilename.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent arg0) { specificationMethod = ObjectLocationSpecificationMethod.FILENAME; setRadioButtons(); } }); FormData fdgFilename = new FormData(); fdgFilename.top = new FormAttachment(0, 0); fdgFilename.left = new FormAttachment(0, 0); fdgFilename.right = new FormAttachment(100, 0); gFilename.setLayoutData(fdgFilename); // The repository : specify by name radio option... // Group gByName = new Group(wSpec, SWT.SHADOW_ETCHED_IN); props.setLook(gByName); FormLayout gByNameLayout = new FormLayout(); gByNameLayout.marginWidth = Const.FORM_MARGIN; gByNameLayout.marginHeight = Const.FORM_MARGIN; gByName.setLayout(gByNameLayout); radioByName = new Button(gByName, SWT.RADIO); props.setLook(radioByName); radioByName.setText(BaseMessages.getString(PKG, "JobTrans.NameOfTransformation.Label")); FormData fdRadioByName = new FormData(); fdRadioByName.top = new FormAttachment(0, 0); fdRadioByName.left = new FormAttachment(0, 0); fdRadioByName.right = new FormAttachment(middle, -margin); radioByName.setLayoutData(fdRadioByName); radioByName.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { specificationMethod = ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME; setRadioButtons(); } }); wbTransname = new Button(gByName, SWT.PUSH | SWT.CENTER); props.setLook(wbTransname); wbTransname.setImage(GUIResource.getInstance().getImageTransGraph()); wbTransname.setToolTipText(BaseMessages.getString(PKG, "JobTrans.SelectTransRep.Tooltip")); FormData fdbTransname = new FormData(); fdbTransname.top = new FormAttachment(0, 0); fdbTransname.right = new FormAttachment(100, 0); wbTransname.setLayoutData(fdbTransname); wTransname = new TextVar(jobMeta, gByName, SWT.SINGLE | SWT.LEFT | SWT.BORDER); props.setLook(wTransname); wTransname.addModifyListener(lsMod); FormData fdTransname = new FormData(); fdTransname.top = new FormAttachment(0, 0); fdTransname.left = new FormAttachment(middle, 0); fdTransname.right = new FormAttachment(wbTransname, -margin); wTransname.setLayoutData(fdTransname); wDirectory = new TextVar(jobMeta, gByName, SWT.SINGLE | SWT.LEFT | SWT.BORDER); props.setLook(wDirectory); wDirectory.addModifyListener(lsMod); FormData fdDirectory = new FormData(); fdDirectory.top = new FormAttachment(wTransname, margin * 2); fdDirectory.left = new FormAttachment(middle, 0); fdDirectory.right = new FormAttachment(100, 0); wDirectory.setLayoutData(fdDirectory); FormData fdgByName = new FormData(); fdgByName.top = new FormAttachment(gFilename, margin); fdgByName.left = new FormAttachment(0, 0); fdgByName.right = new FormAttachment(100, 0); gByName.setLayoutData(fdgByName); // The specify by filename option... // Group gByReference = new Group(wSpec, SWT.SHADOW_ETCHED_IN); props.setLook(gByReference); FormLayout gByReferenceLayout = new FormLayout(); gByReferenceLayout.marginWidth = Const.FORM_MARGIN; gByReferenceLayout.marginHeight = Const.FORM_MARGIN; gByReference.setLayout(gByReferenceLayout); radioByReference = new Button(gByReference, SWT.RADIO); props.setLook(radioByReference); radioByReference.setText(BaseMessages.getString(PKG, "JobTrans.TransformationByReference.Label")); FormData fdRadioByReference = new FormData(); fdRadioByReference.top = new FormAttachment(0, 0); fdRadioByReference.left = new FormAttachment(0, 0); fdRadioByReference.right = new FormAttachment(middle, -margin); radioByReference.setLayoutData(fdRadioByReference); radioByReference.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { specificationMethod = ObjectLocationSpecificationMethod.REPOSITORY_BY_REFERENCE; setRadioButtons(); } }); wbByReference = new Button(gByReference, SWT.PUSH | SWT.CENTER); props.setLook(wbByReference); wbByReference.setImage(GUIResource.getInstance().getImageTransGraph()); wbByReference.setToolTipText(BaseMessages.getString(PKG, "JobTrans.SelectTrans.Tooltip")); FormData fdbByReference = new FormData(); fdbByReference.top = new FormAttachment(0, 0); fdbByReference.right = new FormAttachment(100, 0); wbByReference.setLayoutData(fdbByReference); wByReference = new Text(gByReference, SWT.SINGLE | SWT.LEFT | SWT.BORDER | SWT.READ_ONLY); props.setLook(wByReference); wByReference.addModifyListener(lsMod); FormData fdByReference = new FormData(); fdByReference.top = new FormAttachment(0, 0); fdByReference.left = new FormAttachment(middle, 0); fdByReference.right = new FormAttachment(wbByReference, -margin); wByReference.setLayoutData(fdByReference); FormData fdgByReference = new FormData(); fdgByReference.top = new FormAttachment(gByName, margin); fdgByReference.left = new FormAttachment(0, 0); fdgByReference.right = new FormAttachment(100, 0); gByReference.setLayoutData(fdgByReference); wNewTrans = new Button(wSpec, SWT.PUSH); wNewTrans.setText(BaseMessages.getString(PKG, "JobTrans.NewTransButton.Label")); FormData fdNewTrans = new FormData(); fdNewTrans.bottom = new FormAttachment(100, -margin); fdNewTrans.left = new FormAttachment(wByReference, 0, SWT.CENTER); wNewTrans.setLayoutData(fdNewTrans); wNewTrans.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { newTransformation(); } }); wSpec.pack(); Rectangle bounds = wSpec.getBounds(); wSSpec.setContent(wSpec); wSSpec.setExpandHorizontal(true); wSSpec.setExpandVertical(true); wSSpec.setMinWidth(bounds.width); wSSpec.setMinHeight(bounds.height); wSpecTab.setControl(wSSpec); fdSpec = new FormData(); fdSpec.left = new FormAttachment(0, 0); fdSpec.top = new FormAttachment(0, 0); fdSpec.right = new FormAttachment(100, 0); fdSpec.bottom = new FormAttachment(100, 0); wSpec.setLayoutData(fdSpec); // Advanced // CTabItem wAdvancedTab = new CTabItem(wTabFolder, SWT.NONE); wAdvancedTab.setText(BaseMessages.getString(PKG, "JobTrans.Advanced.Group.Label")); ScrolledComposite wSAdvanced = new ScrolledComposite(wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL); wSAdvanced.setLayout(new FillLayout()); wAdvanced = new Composite(wSAdvanced, SWT.SHADOW_NONE); props.setLook(wAdvanced); FormLayout advancedLayout = new FormLayout(); advancedLayout.marginWidth = Const.FORM_MARGIN; advancedLayout.marginHeight = Const.FORM_MARGIN; wAdvanced.setLayout(advancedLayout); wlPrevious = new Label(wAdvanced, SWT.RIGHT); wlPrevious.setText(BaseMessages.getString(PKG, "JobTrans.Previous.Label")); props.setLook(wlPrevious); FormData fdlPrevious = new FormData(); fdlPrevious.left = new FormAttachment(0, 0); fdlPrevious.top = new FormAttachment(0, 0); fdlPrevious.right = new FormAttachment(middle, -margin); wlPrevious.setLayoutData(fdlPrevious); wPrevious = new Button(wAdvanced, SWT.CHECK); props.setLook(wPrevious); wPrevious.setSelection(jobEntry.argFromPrevious); wPrevious.setToolTipText(BaseMessages.getString(PKG, "JobTrans.Previous.Tooltip")); FormData fdPrevious = new FormData(); fdPrevious.left = new FormAttachment(middle, 0); fdPrevious.top = new FormAttachment(0, 0); fdPrevious.right = new FormAttachment(100, 0); wPrevious.setLayoutData(fdPrevious); wPrevious.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { wFields.setEnabled(!jobEntry.argFromPrevious); } }); wlPrevToParams = new Label(wAdvanced, SWT.RIGHT); wlPrevToParams.setText(BaseMessages.getString(PKG, "JobTrans.PrevToParams.Label")); props.setLook(wlPrevToParams); FormData fdlPrevToParams = new FormData(); fdlPrevToParams.left = new FormAttachment(0, 0); fdlPrevToParams.top = new FormAttachment(wPrevious, margin * 3); fdlPrevToParams.right = new FormAttachment(middle, -margin); wlPrevToParams.setLayoutData(fdlPrevToParams); wPrevToParams = new Button(wAdvanced, SWT.CHECK); props.setLook(wPrevToParams); wPrevToParams.setSelection(jobEntry.paramsFromPrevious); wPrevToParams.setToolTipText(BaseMessages.getString(PKG, "JobTrans.PrevToParams.Tooltip")); FormData fdPrevToParams = new FormData(); fdPrevToParams.left = new FormAttachment(middle, 0); fdPrevToParams.top = new FormAttachment(wPrevious, margin * 3); fdPrevToParams.right = new FormAttachment(100, 0); wPrevToParams.setLayoutData(fdPrevToParams); wPrevToParams.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { jobEntry.setChanged(); } }); wlEveryRow = new Label(wAdvanced, SWT.RIGHT); wlEveryRow.setText(BaseMessages.getString(PKG, "JobTrans.ExecForEveryInputRow.Label")); props.setLook(wlEveryRow); FormData fdlEveryRow = new FormData(); fdlEveryRow.left = new FormAttachment(0, 0); fdlEveryRow.top = new FormAttachment(wPrevToParams, margin); fdlEveryRow.right = new FormAttachment(middle, -margin); wlEveryRow.setLayoutData(fdlEveryRow); wEveryRow = new Button(wAdvanced, SWT.CHECK); props.setLook(wEveryRow); wEveryRow.setToolTipText(BaseMessages.getString(PKG, "JobTrans.ExecForEveryInputRow.Tooltip")); FormData fdEveryRow = new FormData(); fdEveryRow.left = new FormAttachment(middle, 0); fdEveryRow.top = new FormAttachment(wPrevToParams, margin); fdEveryRow.right = new FormAttachment(100, 0); wEveryRow.setLayoutData(fdEveryRow); // Clear the result rows before executing the transformation? // wlClearRows = new Label(wAdvanced, SWT.RIGHT); wlClearRows.setText(BaseMessages.getString(PKG, "JobTrans.ClearResultList.Label")); props.setLook(wlClearRows); FormData fdlClearRows = new FormData(); fdlClearRows.left = new FormAttachment(0, 0); fdlClearRows.top = new FormAttachment(wEveryRow, margin); fdlClearRows.right = new FormAttachment(middle, -margin); wlClearRows.setLayoutData(fdlClearRows); wClearRows = new Button(wAdvanced, SWT.CHECK); props.setLook(wClearRows); FormData fdClearRows = new FormData(); fdClearRows.left = new FormAttachment(middle, 0); fdClearRows.top = new FormAttachment(wEveryRow, margin); fdClearRows.right = new FormAttachment(100, 0); wClearRows.setLayoutData(fdClearRows); // Clear the result files before executing the transformation? // wlClearFiles = new Label(wAdvanced, SWT.RIGHT); wlClearFiles.setText(BaseMessages.getString(PKG, "JobTrans.ClearResultFiles.Label")); props.setLook(wlClearFiles); FormData fdlClearFiles = new FormData(); fdlClearFiles.left = new FormAttachment(0, 0); fdlClearFiles.top = new FormAttachment(wClearRows, margin); fdlClearFiles.right = new FormAttachment(middle, -margin); wlClearFiles.setLayoutData(fdlClearFiles); wClearFiles = new Button(wAdvanced, SWT.CHECK); props.setLook(wClearFiles); FormData fdClearFiles = new FormData(); fdClearFiles.left = new FormAttachment(middle, 0); fdClearFiles.top = new FormAttachment(wClearRows, margin); fdClearFiles.right = new FormAttachment(100, 0); wClearFiles.setLayoutData(fdClearFiles); // Clear the result rows before executing the transformation? // wlCluster = new Label(wAdvanced, SWT.RIGHT); wlCluster.setText(BaseMessages.getString(PKG, "JobTrans.RunTransInCluster.Label")); props.setLook(wlCluster); FormData fdlCluster = new FormData(); fdlCluster.left = new FormAttachment(0, 0); fdlCluster.top = new FormAttachment(wClearFiles, margin); fdlCluster.right = new FormAttachment(middle, -margin); wlCluster.setLayoutData(fdlCluster); wCluster = new Button(wAdvanced, SWT.CHECK); props.setLook(wCluster); FormData fdCluster = new FormData(); fdCluster.left = new FormAttachment(middle, 0); fdCluster.top = new FormAttachment(wClearFiles, margin); fdCluster.right = new FormAttachment(100, 0); wCluster.setLayoutData(fdCluster); wCluster.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setActive(); } }); // Log clustering logging results locally? // wlLogRemoteWork = new Label(wAdvanced, SWT.RIGHT); wlLogRemoteWork.setText(BaseMessages.getString(PKG, "JobTrans.LogRemoteWork.Label")); props.setLook(wlLogRemoteWork); FormData fdlLogRemoteWork = new FormData(); fdlLogRemoteWork.left = new FormAttachment(0, 0); fdlLogRemoteWork.top = new FormAttachment(wCluster, margin); fdlLogRemoteWork.right = new FormAttachment(middle, -margin); wlLogRemoteWork.setLayoutData(fdlLogRemoteWork); wLogRemoteWork = new Button(wAdvanced, SWT.CHECK); props.setLook(wLogRemoteWork); FormData fdLogRemoteWork = new FormData(); fdLogRemoteWork.left = new FormAttachment(middle, 0); fdLogRemoteWork.top = new FormAttachment(wCluster, margin); fdLogRemoteWork.right = new FormAttachment(100, 0); wLogRemoteWork.setLayoutData(fdLogRemoteWork); // The remote slave server // wlSlaveServer = new Label(wAdvanced, SWT.RIGHT); wlSlaveServer.setText(BaseMessages.getString(PKG, "JobTrans.SlaveServer.Label")); wlSlaveServer.setToolTipText(BaseMessages.getString(PKG, "JobTrans.SlaveServer.ToolTip")); props.setLook(wlSlaveServer); FormData fdlSlaveServer = new FormData(); fdlSlaveServer.left = new FormAttachment(0, 0); fdlSlaveServer.right = new FormAttachment(middle, -margin); fdlSlaveServer.top = new FormAttachment(wLogRemoteWork, margin); wlSlaveServer.setLayoutData(fdlSlaveServer); wSlaveServer = new ComboVar(jobMeta, wAdvanced, SWT.SINGLE | SWT.BORDER); wSlaveServer.setItems(SlaveServer.getSlaveServerNames(jobMeta.getSlaveServers())); wSlaveServer.setToolTipText(BaseMessages.getString(PKG, "JobTrans.SlaveServer.ToolTip")); props.setLook(wSlaveServer); FormData fdSlaveServer = new FormData(); fdSlaveServer.left = new FormAttachment(middle, 0); fdSlaveServer.top = new FormAttachment(wLogRemoteWork, margin); fdSlaveServer.right = new FormAttachment(100, 0); wSlaveServer.setLayoutData(fdSlaveServer); wSlaveServer.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setActive(); } }); // Wait for the remote transformation to finish? // wlWaitingToFinish = new Label(wAdvanced, SWT.RIGHT); wlWaitingToFinish.setText(BaseMessages.getString(PKG, "JobTrans.WaitToFinish.Label")); props.setLook(wlWaitingToFinish); FormData fdlWaitingToFinish = new FormData(); fdlWaitingToFinish.left = new FormAttachment(0, 0); fdlWaitingToFinish.top = new FormAttachment(wSlaveServer, margin); fdlWaitingToFinish.right = new FormAttachment(middle, -margin); wlWaitingToFinish.setLayoutData(fdlWaitingToFinish); wWaitingToFinish = new Button(wAdvanced, SWT.CHECK); props.setLook(wWaitingToFinish); FormData fdWaitingToFinish = new FormData(); fdWaitingToFinish.left = new FormAttachment(middle, 0); fdWaitingToFinish.top = new FormAttachment(wSlaveServer, margin); fdWaitingToFinish.right = new FormAttachment(100, 0); wWaitingToFinish.setLayoutData(fdWaitingToFinish); wWaitingToFinish.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setActive(); } }); // Follow a local abort remotely? // wlFollowingAbortRemotely = new Label(wAdvanced, SWT.RIGHT); wlFollowingAbortRemotely.setText(BaseMessages.getString(PKG, "JobTrans.AbortRemote.Label")); props.setLook(wlFollowingAbortRemotely); FormData fdlFollowingAbortRemotely = new FormData(); fdlFollowingAbortRemotely.left = new FormAttachment(0, 0); fdlFollowingAbortRemotely.top = new FormAttachment(wWaitingToFinish, margin); fdlFollowingAbortRemotely.right = new FormAttachment(middle, -margin); wlFollowingAbortRemotely.setLayoutData(fdlFollowingAbortRemotely); wFollowingAbortRemotely = new Button(wAdvanced, SWT.CHECK); props.setLook(wFollowingAbortRemotely); FormData fdFollowingAbortRemotely = new FormData(); fdFollowingAbortRemotely.left = new FormAttachment(middle, 0); fdFollowingAbortRemotely.top = new FormAttachment(wWaitingToFinish, margin); fdFollowingAbortRemotely.right = new FormAttachment(100, 0); wFollowingAbortRemotely.setLayoutData(fdFollowingAbortRemotely); FormData fdAdvanced = new FormData(); fdAdvanced.left = new FormAttachment(0, 0); fdAdvanced.top = new FormAttachment(0, 0); fdAdvanced.right = new FormAttachment(100, 0); fdAdvanced.bottom = new FormAttachment(100, 0); wAdvanced.setLayoutData(fdAdvanced); wAdvanced.pack(); bounds = wAdvanced.getBounds(); wSAdvanced.setContent(wAdvanced); wSAdvanced.setExpandHorizontal(true); wSAdvanced.setExpandVertical(true); wSAdvanced.setMinWidth(bounds.width); wSAdvanced.setMinHeight(bounds.height); wAdvancedTab.setControl(wSAdvanced); // Logging // CTabItem wLoggingTab = new CTabItem(wTabFolder, SWT.NONE); wLoggingTab.setText(BaseMessages.getString(PKG, "JobTrans.LogSettings.Group.Label")); ScrolledComposite wSLogging = new ScrolledComposite(wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL); wSLogging.setLayout(new FillLayout()); wLogging = new Composite(wSLogging, SWT.SHADOW_NONE); props.setLook(wLogging); FormLayout groupLayout = new FormLayout(); groupLayout.marginWidth = Const.FORM_MARGIN; groupLayout.marginHeight = Const.FORM_MARGIN; wLogging.setLayout(groupLayout); // Set the logfile? wlSetLogfile = new Label(wLogging, SWT.RIGHT); wlSetLogfile.setText(BaseMessages.getString(PKG, "JobTrans.Specify.Logfile.Label")); props.setLook(wlSetLogfile); FormData fdlSetLogfile = new FormData(); fdlSetLogfile.left = new FormAttachment(0, 0); fdlSetLogfile.top = new FormAttachment(0, margin); fdlSetLogfile.right = new FormAttachment(middle, -margin); wlSetLogfile.setLayoutData(fdlSetLogfile); wSetLogfile = new Button(wLogging, SWT.CHECK); props.setLook(wSetLogfile); FormData fdSetLogfile = new FormData(); fdSetLogfile.left = new FormAttachment(middle, 0); fdSetLogfile.top = new FormAttachment(0, margin); fdSetLogfile.right = new FormAttachment(100, 0); wSetLogfile.setLayoutData(fdSetLogfile); wSetLogfile.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setActive(); } }); // Append the logfile? wlAppendLogfile = new Label(wLogging, SWT.RIGHT); wlAppendLogfile.setText(BaseMessages.getString(PKG, "JobTrans.Append.Logfile.Label")); props.setLook(wlAppendLogfile); FormData fdlAppendLogfile = new FormData(); fdlAppendLogfile.left = new FormAttachment(0, 0); fdlAppendLogfile.top = new FormAttachment(wSetLogfile, margin); fdlAppendLogfile.right = new FormAttachment(middle, -margin); wlAppendLogfile.setLayoutData(fdlAppendLogfile); wAppendLogfile = new Button(wLogging, SWT.CHECK); wAppendLogfile.setToolTipText(BaseMessages.getString(PKG, "JobTrans.Append.Logfile.Tooltip")); props.setLook(wAppendLogfile); FormData fdAppendLogfile = new FormData(); fdAppendLogfile.left = new FormAttachment(middle, 0); fdAppendLogfile.top = new FormAttachment(wSetLogfile, margin); fdAppendLogfile.right = new FormAttachment(100, 0); wAppendLogfile.setLayoutData(fdAppendLogfile); wAppendLogfile.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { } }); // Set the logfile path + base-name wlLogfile = new Label(wLogging, SWT.RIGHT); wlLogfile.setText(BaseMessages.getString(PKG, "JobTrans.NameOfLogfile.Label")); props.setLook(wlLogfile); FormData fdlLogfile = new FormData(); fdlLogfile.left = new FormAttachment(0, 0); fdlLogfile.top = new FormAttachment(wAppendLogfile, margin); fdlLogfile.right = new FormAttachment(middle, -margin); wlLogfile.setLayoutData(fdlLogfile); wbLogFilename = new Button(wLogging, SWT.PUSH | SWT.CENTER); props.setLook(wbLogFilename); wbLogFilename.setText(BaseMessages.getString(PKG, "JobTrans.Browse.Label")); fdbLogFilename = new FormData(); fdbLogFilename.top = new FormAttachment(wAppendLogfile, margin); fdbLogFilename.right = new FormAttachment(100, 0); wbLogFilename.setLayoutData(fdbLogFilename); wLogfile = new TextVar(jobMeta, wLogging, SWT.SINGLE | SWT.LEFT | SWT.BORDER); wLogfile.setText(""); props.setLook(wLogfile); FormData fdLogfile = new FormData(); fdLogfile.left = new FormAttachment(middle, 0); fdLogfile.top = new FormAttachment(wAppendLogfile, margin); fdLogfile.right = new FormAttachment(wbLogFilename, -margin); wLogfile.setLayoutData(fdLogfile); // create parent folder? wlCreateParentFolder = new Label(wLogging, SWT.RIGHT); wlCreateParentFolder.setText(BaseMessages.getString(PKG, "JobTrans.Logfile.CreateParentFolder.Label")); props.setLook(wlCreateParentFolder); fdlCreateParentFolder = new FormData(); fdlCreateParentFolder.left = new FormAttachment(0, 0); fdlCreateParentFolder.top = new FormAttachment(wLogfile, margin); fdlCreateParentFolder.right = new FormAttachment(middle, -margin); wlCreateParentFolder.setLayoutData(fdlCreateParentFolder); wCreateParentFolder = new Button(wLogging, SWT.CHECK); wCreateParentFolder .setToolTipText(BaseMessages.getString(PKG, "JobTrans.Logfile.CreateParentFolder.Tooltip")); props.setLook(wCreateParentFolder); fdCreateParentFolder = new FormData(); fdCreateParentFolder.left = new FormAttachment(middle, 0); fdCreateParentFolder.top = new FormAttachment(wLogfile, margin); fdCreateParentFolder.right = new FormAttachment(100, 0); wCreateParentFolder.setLayoutData(fdCreateParentFolder); wCreateParentFolder.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { } }); // Set the logfile filename extention wlLogext = new Label(wLogging, SWT.RIGHT); wlLogext.setText(BaseMessages.getString(PKG, "JobTrans.LogfileExtension.Label")); props.setLook(wlLogext); FormData fdlLogext = new FormData(); fdlLogext.left = new FormAttachment(0, 0); fdlLogext.top = new FormAttachment(wCreateParentFolder, margin); fdlLogext.right = new FormAttachment(middle, -margin); wlLogext.setLayoutData(fdlLogext); wLogext = new TextVar(jobMeta, wLogging, SWT.SINGLE | SWT.LEFT | SWT.BORDER); wLogext.setText(""); props.setLook(wLogext); FormData fdLogext = new FormData(); fdLogext.left = new FormAttachment(middle, 0); fdLogext.top = new FormAttachment(wCreateParentFolder, margin); fdLogext.right = new FormAttachment(100, 0); wLogext.setLayoutData(fdLogext); // Add date to logfile name? wlAddDate = new Label(wLogging, SWT.RIGHT); wlAddDate.setText(BaseMessages.getString(PKG, "JobTrans.Logfile.IncludeDate.Label")); props.setLook(wlAddDate); FormData fdlAddDate = new FormData(); fdlAddDate.left = new FormAttachment(0, 0); fdlAddDate.top = new FormAttachment(wLogext, margin); fdlAddDate.right = new FormAttachment(middle, -margin); wlAddDate.setLayoutData(fdlAddDate); wAddDate = new Button(wLogging, SWT.CHECK); props.setLook(wAddDate); FormData fdAddDate = new FormData(); fdAddDate.left = new FormAttachment(middle, 0); fdAddDate.top = new FormAttachment(wLogext, margin); fdAddDate.right = new FormAttachment(100, 0); wAddDate.setLayoutData(fdAddDate); // Add time to logfile name? wlAddTime = new Label(wLogging, SWT.RIGHT); wlAddTime.setText(BaseMessages.getString(PKG, "JobTrans.Logfile.IncludeTime.Label")); props.setLook(wlAddTime); FormData fdlAddTime = new FormData(); fdlAddTime.left = new FormAttachment(0, 0); fdlAddTime.top = new FormAttachment(wlAddDate, margin); fdlAddTime.right = new FormAttachment(middle, -margin); wlAddTime.setLayoutData(fdlAddTime); wAddTime = new Button(wLogging, SWT.CHECK); props.setLook(wAddTime); FormData fdAddTime = new FormData(); fdAddTime.left = new FormAttachment(middle, 0); fdAddTime.top = new FormAttachment(wlAddDate, margin); fdAddTime.right = new FormAttachment(100, 0); wAddTime.setLayoutData(fdAddTime); wlLoglevel = new Label(wLogging, SWT.RIGHT); wlLoglevel.setText(BaseMessages.getString(PKG, "JobTrans.Loglevel.Label")); props.setLook(wlLoglevel); FormData fdlLoglevel = new FormData(); fdlLoglevel.left = new FormAttachment(0, 0); fdlLoglevel.right = new FormAttachment(middle, -margin); fdlLoglevel.top = new FormAttachment(wAddTime, margin); wlLoglevel.setLayoutData(fdlLoglevel); wLoglevel = new CCombo(wLogging, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER); wLoglevel.setItems(LogLevel.getLogLevelDescriptions()); props.setLook(wLoglevel); FormData fdLoglevel = new FormData(); fdLoglevel.left = new FormAttachment(middle, 0); fdLoglevel.top = new FormAttachment(wAddTime, margin); fdLoglevel.right = new FormAttachment(100, 0); wLoglevel.setLayoutData(fdLoglevel); FormData fdLogging = new FormData(); fdLogging.left = new FormAttachment(0, 0); fdLogging.top = new FormAttachment(0, 0); fdLogging.right = new FormAttachment(100, 0); fdLogging.bottom = new FormAttachment(100, 0); wLogging.setLayoutData(fdLogging); wLogging.pack(); bounds = wLogging.getBounds(); wSLogging.setContent(wLogging); wSLogging.setExpandHorizontal(true); wSLogging.setExpandVertical(true); wSLogging.setMinWidth(bounds.width); wSLogging.setMinHeight(bounds.height); wLoggingTab.setControl(wSLogging); // Arguments // CTabItem wFieldTab = new CTabItem(wTabFolder, SWT.NONE); wFieldTab.setText(BaseMessages.getString(PKG, "JobTrans.Fields.Argument.Label")); FormLayout fieldLayout = new FormLayout(); fieldLayout.marginWidth = Const.MARGIN; fieldLayout.marginHeight = Const.MARGIN; Composite wFieldComp = new Composite(wTabFolder, SWT.NONE); props.setLook(wFieldComp); wFieldComp.setLayout(fieldLayout); final int FieldsCols = 1; int rows = jobEntry.arguments == null ? 1 : (jobEntry.arguments.length == 0 ? 0 : jobEntry.arguments.length); final int FieldsRows = rows; ColumnInfo[] colinf = new ColumnInfo[FieldsCols]; colinf[0] = new ColumnInfo(BaseMessages.getString(PKG, "JobTrans.Fields.Argument.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false); colinf[0].setUsingVariables(true); wFields = new TableView(jobMeta, wFieldComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod, props); FormData fdFields = new FormData(); fdFields.left = new FormAttachment(0, 0); fdFields.top = new FormAttachment(0, margin); fdFields.right = new FormAttachment(100, 0); fdFields.bottom = new FormAttachment(100, 0); wFields.setLayoutData(fdFields); FormData 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); wFieldComp.setLayoutData(fdFieldsComp); wFieldComp.layout(); wFieldTab.setControl(wFieldComp); // The parameters tab CTabItem wParametersTab = new CTabItem(wTabFolder, SWT.NONE); wParametersTab.setText(BaseMessages.getString(PKG, "JobTrans.Fields.Parameters.Label")); fieldLayout = new FormLayout(); fieldLayout.marginWidth = Const.MARGIN; fieldLayout.marginHeight = Const.MARGIN; Composite wParameterComp = new Composite(wTabFolder, SWT.NONE); props.setLook(wParameterComp); wParameterComp.setLayout(fieldLayout); // Pass all parameters down // wlPassParams = new Label(wParameterComp, SWT.RIGHT); wlPassParams.setText(BaseMessages.getString(PKG, "JobTrans.PassAllParameters.Label")); props.setLook(wlPassParams); FormData fdlPassParams = new FormData(); fdlPassParams.left = new FormAttachment(0, 0); fdlPassParams.top = new FormAttachment(0, 0); fdlPassParams.right = new FormAttachment(middle, -margin); wlPassParams.setLayoutData(fdlPassParams); wPassParams = new Button(wParameterComp, SWT.CHECK); props.setLook(wPassParams); FormData fdPassParams = new FormData(); fdPassParams.left = new FormAttachment(middle, 0); fdPassParams.top = new FormAttachment(0, 0); fdPassParams.right = new FormAttachment(100, 0); wPassParams.setLayoutData(fdPassParams); wbGetParams = new Button(wParameterComp, SWT.PUSH); wbGetParams.setText(BaseMessages.getString(PKG, "JobTrans.GetParameters.Button.Label")); FormData fdGetParams = new FormData(); fdGetParams.top = new FormAttachment(wPassParams, margin); fdGetParams.right = new FormAttachment(100, 0); wbGetParams.setLayoutData(fdGetParams); wbGetParams.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { getParameters(null); // force reload from file specification } }); final int parameterRows = jobEntry.parameters != null ? jobEntry.parameters.length : 0; colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "JobTrans.Parameters.Parameter.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "JobTrans.Parameters.ColumnName.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "JobTrans.Parameters.Value.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), }; colinf[2].setUsingVariables(true); wParameters = new TableView(jobMeta, wParameterComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, parameterRows, lsMod, props); FormData fdParameters = new FormData(); fdParameters.left = new FormAttachment(0, 0); fdParameters.top = new FormAttachment(wPassParams, margin); fdParameters.right = new FormAttachment(wbGetParams, -margin); fdParameters.bottom = new FormAttachment(100, 0); wParameters.setLayoutData(fdParameters); FormData fdParametersComp = new FormData(); fdParametersComp.left = new FormAttachment(0, 0); fdParametersComp.top = new FormAttachment(0, 0); fdParametersComp.right = new FormAttachment(100, 0); fdParametersComp.bottom = new FormAttachment(100, 0); wParameterComp.setLayoutData(fdParametersComp); wParameterComp.layout(); wParametersTab.setControl(wParameterComp); FormData fdTabFolder = new FormData(); fdTabFolder.left = new FormAttachment(0, 0); fdTabFolder.top = new FormAttachment(wName, margin * 3); fdTabFolder.right = new FormAttachment(100, 0); fdTabFolder.bottom = new FormAttachment(100, -50); wTabFolder.setLayoutData(fdTabFolder); wTabFolder.setSelection(0); // Some buttons wOK = new Button(shell, SWT.PUSH); wOK.setText(BaseMessages.getString(PKG, "System.Button.OK")); wCancel = new Button(shell, SWT.PUSH); wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel")); BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, wTabFolder); // Add listeners lsCancel = new Listener() { public void handleEvent(Event e) { cancel(); } }; lsOK = new Listener() { public void handleEvent(Event e) { ok(); } }; wOK.addListener(SWT.Selection, lsOK); wCancel.addListener(SWT.Selection, lsCancel); lsDef = new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { ok(); } }; wName.addSelectionListener(lsDef); wFilename.addSelectionListener(lsDef); wbTransname.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { selectTransformation(); } }); wbFilename.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { pickFileVFS(); } }); wbByReference.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { selectTransformationByReference(); } }); wbLogFilename.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(shell, SWT.SAVE); dialog.setFilterExtensions(new String[] { "*.txt", "*'.log", "*" }); dialog.setFilterNames(FILE_FILTERLOGNAMES); if (wLogfile.getText() != null) { dialog.setFileName(jobMeta.environmentSubstitute(wLogfile.getText())); } if (dialog.open() != null) { wLogfile.setText(dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName()); String filename = dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName(); FileObject file = null; try { file = KettleVFS.getFileObject(filename); // Set file extension .. wLogext.setText(file.getName().getExtension()); // Set filename without extension ... wLogfile.setText(wLogfile.getText().substring(0, wLogfile.getText().length() - wLogext.getText().length() - 1)); } catch (Exception ex) { // Ignore } if (file != null) { try { file.close(); } catch (IOException ex) { /* Ignore */ } } } } }); // Detect [X] or ALT-F4 or something that kills this window... shell.addShellListener(new ShellAdapter() { public void shellClosed(ShellEvent e) { cancel(); } }); getData(); setActive(); BaseStepDialog.setSize(shell); shell.open(); props.setDialogSize(shell, "JobTransDialogSize"); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return jobEntry; }