in plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/textfileoutput/TextFileOutputDialog.java [179:1257]
public String open() {
Shell parent = getParent();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
PropsUi.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = e -> input.setChanged();
changed = input.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = PropsUi.getFormMargin();
formLayout.marginHeight = PropsUi.getFormMargin();
shell.setLayout(formLayout);
shell.setText(getDialogTitle());
int middle = props.getMiddlePct();
int margin = PropsUi.getMargin();
// TransformName line
wlTransformName = new Label(shell, SWT.RIGHT);
wlTransformName.setText(BaseMessages.getString(PKG, "System.TransformName.Label"));
wlTransformName.setToolTipText(BaseMessages.getString(PKG, "System.TransformName.Tooltip"));
PropsUi.setLook(wlTransformName);
fdlTransformName = new FormData();
fdlTransformName.left = new FormAttachment(0, 0);
fdlTransformName.top = new FormAttachment(0, margin);
fdlTransformName.right = new FormAttachment(middle, -margin);
wlTransformName.setLayoutData(fdlTransformName);
wTransformName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wTransformName.setText(transformName);
PropsUi.setLook(wTransformName);
wTransformName.addModifyListener(lsMod);
fdTransformName = new FormData();
fdTransformName.left = new FormAttachment(middle, 0);
fdTransformName.top = new FormAttachment(0, margin);
fdTransformName.right = new FormAttachment(100, 0);
wTransformName.setLayoutData(fdTransformName);
// Buttons at the bottom first
//
wOk = new Button(shell, SWT.PUSH);
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOk.addListener(SWT.Selection, e -> ok());
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wCancel.addListener(SWT.Selection, e -> cancel());
setButtonPositions(new Button[] {wOk, wCancel}, margin, null);
CTabFolder wTabFolder = new CTabFolder(shell, SWT.BORDER);
PropsUi.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
// ////////////////////////
// START OF FILE TAB///
// /
CTabItem wFileTab = new CTabItem(wTabFolder, SWT.NONE);
wFileTab.setFont(GuiResource.getInstance().getFontDefault());
wFileTab.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.FileTab.TabTitle"));
Composite wFileComp = new Composite(wTabFolder, SWT.NONE);
PropsUi.setLook(wFileComp);
FormLayout fileLayout = new FormLayout();
fileLayout.marginWidth = 3;
fileLayout.marginHeight = 3;
wFileComp.setLayout(fileLayout);
// Filename line
wlFilename = new Label(wFileComp, SWT.RIGHT);
wlFilename.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.Filename.Label"));
PropsUi.setLook(wlFilename);
FormData fdlFilename = new FormData();
fdlFilename.left = new FormAttachment(0, 0);
fdlFilename.top = new FormAttachment(0, margin);
fdlFilename.right = new FormAttachment(middle, -margin);
wlFilename.setLayoutData(fdlFilename);
wbFilename = new Button(wFileComp, SWT.PUSH | SWT.CENTER);
PropsUi.setLook(wbFilename);
wbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
FormData fdbFilename = new FormData();
fdbFilename.right = new FormAttachment(100, 0);
fdbFilename.top = new FormAttachment(0, 0);
wbFilename.setLayoutData(fdbFilename);
wFilename = new TextVar(variables, wFileComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
PropsUi.setLook(wFilename);
wFilename.addModifyListener(lsMod);
FormData fdFilename = new FormData();
fdFilename.left = new FormAttachment(middle, 0);
fdFilename.top = new FormAttachment(0, margin);
fdFilename.right = new FormAttachment(wbFilename, -margin);
wFilename.setLayoutData(fdFilename);
Control topControl = addAdditionalComponentIfNeed(middle, margin, wFileComp, wFilename);
// Output to servlet (browser, ws)
//
Label wlServletOutput = new Label(wFileComp, SWT.RIGHT);
wlServletOutput.setText(
BaseMessages.getString(PKG, "TextFileOutputDialog.ServletOutput.Label"));
PropsUi.setLook(wlServletOutput);
FormData fdlServletOutput = new FormData();
fdlServletOutput.left = new FormAttachment(0, 0);
fdlServletOutput.top = new FormAttachment(topControl, margin);
fdlServletOutput.right = new FormAttachment(middle, -margin);
wlServletOutput.setLayoutData(fdlServletOutput);
wServletOutput = new Button(wFileComp, SWT.CHECK);
wServletOutput.setToolTipText(
BaseMessages.getString(PKG, "TextFileOutputDialog.ServletOutput.Tooltip"));
PropsUi.setLook(wServletOutput);
FormData fdServletOutput = new FormData();
fdServletOutput.left = new FormAttachment(middle, 0);
fdServletOutput.top = new FormAttachment(wlServletOutput, 0, SWT.CENTER);
fdServletOutput.right = new FormAttachment(100, 0);
wServletOutput.setLayoutData(fdServletOutput);
wServletOutput.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
setFlagsServletOption();
}
});
// Create Parent Folder
wlCreateParentFolder = new Label(wFileComp, SWT.RIGHT);
wlCreateParentFolder.setText(
BaseMessages.getString(PKG, "TextFileOutputDialog.CreateParentFolder.Label"));
PropsUi.setLook(wlCreateParentFolder);
FormData fdlCreateParentFolder = new FormData();
fdlCreateParentFolder.left = new FormAttachment(0, 0);
fdlCreateParentFolder.top = new FormAttachment(wServletOutput, margin);
fdlCreateParentFolder.right = new FormAttachment(middle, -margin);
wlCreateParentFolder.setLayoutData(fdlCreateParentFolder);
wCreateParentFolder = new Button(wFileComp, SWT.CHECK);
wCreateParentFolder.setToolTipText(
BaseMessages.getString(PKG, "TextFileOutputDialog.CreateParentFolder.Tooltip"));
PropsUi.setLook(wCreateParentFolder);
FormData fdCreateParentFolder = new FormData();
fdCreateParentFolder.left = new FormAttachment(middle, 0);
fdCreateParentFolder.top = new FormAttachment(wlCreateParentFolder, 0, SWT.CENTER);
fdCreateParentFolder.right = new FormAttachment(100, 0);
wCreateParentFolder.setLayoutData(fdCreateParentFolder);
wCreateParentFolder.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// Open new File at Init
wlDoNotOpenNewFileInit = new Label(wFileComp, SWT.RIGHT);
wlDoNotOpenNewFileInit.setText(
BaseMessages.getString(PKG, "TextFileOutputDialog.DoNotOpenNewFileInit.Label"));
PropsUi.setLook(wlDoNotOpenNewFileInit);
FormData fdlDoNotOpenNewFileInit = new FormData();
fdlDoNotOpenNewFileInit.left = new FormAttachment(0, 0);
fdlDoNotOpenNewFileInit.top = new FormAttachment(wCreateParentFolder, margin);
fdlDoNotOpenNewFileInit.right = new FormAttachment(middle, -margin);
wlDoNotOpenNewFileInit.setLayoutData(fdlDoNotOpenNewFileInit);
wDoNotOpenNewFileInit = new Button(wFileComp, SWT.CHECK);
wDoNotOpenNewFileInit.setToolTipText(
BaseMessages.getString(PKG, "TextFileOutputDialog.DoNotOpenNewFileInit.Tooltip"));
PropsUi.setLook(wDoNotOpenNewFileInit);
FormData fdDoNotOpenNewFileInit = new FormData();
fdDoNotOpenNewFileInit.left = new FormAttachment(middle, 0);
fdDoNotOpenNewFileInit.top = new FormAttachment(wlDoNotOpenNewFileInit, 0, SWT.CENTER);
fdDoNotOpenNewFileInit.right = new FormAttachment(100, 0);
wDoNotOpenNewFileInit.setLayoutData(fdDoNotOpenNewFileInit);
wDoNotOpenNewFileInit.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
/* next Lines */
// FileNameInField line
/* Additional fields */
Label wlFileNameInField = new Label(wFileComp, SWT.RIGHT);
wlFileNameInField.setText(
BaseMessages.getString(PKG, "TextFileOutputDialog.FileNameInField.Label"));
PropsUi.setLook(wlFileNameInField);
FormData fdlFileNameInField = new FormData();
fdlFileNameInField.left = new FormAttachment(0, 0);
fdlFileNameInField.top = new FormAttachment(wDoNotOpenNewFileInit, margin);
fdlFileNameInField.right = new FormAttachment(middle, -margin);
wlFileNameInField.setLayoutData(fdlFileNameInField);
wFileNameInField = new Button(wFileComp, SWT.CHECK);
PropsUi.setLook(wFileNameInField);
FormData fdFileNameInField = new FormData();
fdFileNameInField.left = new FormAttachment(middle, 0);
fdFileNameInField.top = new FormAttachment(wlFileNameInField, 0, SWT.CENTER);
fdFileNameInField.right = new FormAttachment(100, 0);
wFileNameInField.setLayoutData(fdFileNameInField);
wFileNameInField.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
activeFileNameField();
}
});
// FileNameField Line
wlFileNameField = new Label(wFileComp, SWT.RIGHT);
wlFileNameField.setText(
BaseMessages.getString(PKG, "TextFileOutputDialog.FileNameField.Label"));
PropsUi.setLook(wlFileNameField);
FormData fdlFileNameField = new FormData();
fdlFileNameField.left = new FormAttachment(0, 0);
fdlFileNameField.right = new FormAttachment(middle, -margin);
fdlFileNameField.top = new FormAttachment(wFileNameInField, margin);
wlFileNameField.setLayoutData(fdlFileNameField);
wFileNameField = new ComboVar(variables, wFileComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
PropsUi.setLook(wFileNameField);
wFileNameField.addModifyListener(lsMod);
FormData fdFileNameField = new FormData();
fdFileNameField.left = new FormAttachment(middle, 0);
fdFileNameField.top = new FormAttachment(wFileNameInField, margin);
fdFileNameField.right = new FormAttachment(100, 0);
wFileNameField.setLayoutData(fdFileNameField);
wFileNameField.setEnabled(false);
wFileNameField.addFocusListener(
new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
// Do nothing
}
@Override
public void focusGained(FocusEvent e) {
Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
shell.setCursor(busy);
getFields();
shell.setCursor(null);
busy.dispose();
}
});
/* End */
// Extension line
wlExtension = new Label(wFileComp, SWT.RIGHT);
wlExtension.setText(BaseMessages.getString(PKG, "System.Label.Extension"));
PropsUi.setLook(wlExtension);
FormData fdlExtension = new FormData();
fdlExtension.left = new FormAttachment(0, 0);
fdlExtension.top = new FormAttachment(wFileNameField, margin);
fdlExtension.right = new FormAttachment(middle, -margin);
wlExtension.setLayoutData(fdlExtension);
wExtension = new TextVar(variables, wFileComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wExtension.setText("");
PropsUi.setLook(wExtension);
wExtension.addModifyListener(lsMod);
FormData fdExtension = new FormData();
fdExtension.left = new FormAttachment(middle, 0);
fdExtension.top = new FormAttachment(wFileNameField, margin);
fdExtension.right = new FormAttachment(100, 0);
wExtension.setLayoutData(fdExtension);
// Create multi-part file?
wlAddTransformNr = new Label(wFileComp, SWT.RIGHT);
wlAddTransformNr.setText(
BaseMessages.getString(PKG, "TextFileOutputDialog.AddTransformnr.Label"));
PropsUi.setLook(wlAddTransformNr);
FormData fdlAddTransformNr = new FormData();
fdlAddTransformNr.left = new FormAttachment(0, 0);
fdlAddTransformNr.top = new FormAttachment(wExtension, margin);
fdlAddTransformNr.right = new FormAttachment(middle, -margin);
wlAddTransformNr.setLayoutData(fdlAddTransformNr);
wAddTransformNr = new Button(wFileComp, SWT.CHECK);
PropsUi.setLook(wAddTransformNr);
FormData fdAddTransformNr = new FormData();
fdAddTransformNr.left = new FormAttachment(middle, 0);
fdAddTransformNr.top = new FormAttachment(wlAddTransformNr, 0, SWT.CENTER);
fdAddTransformNr.right = new FormAttachment(100, 0);
wAddTransformNr.setLayoutData(fdAddTransformNr);
wAddTransformNr.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// Create multi-part file?
wlAddPartnr = new Label(wFileComp, SWT.RIGHT);
wlAddPartnr.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.AddPartnr.Label"));
PropsUi.setLook(wlAddPartnr);
FormData fdlAddPartnr = new FormData();
fdlAddPartnr.left = new FormAttachment(0, 0);
fdlAddPartnr.top = new FormAttachment(wAddTransformNr, margin);
fdlAddPartnr.right = new FormAttachment(middle, -margin);
wlAddPartnr.setLayoutData(fdlAddPartnr);
wAddPartnr = new Button(wFileComp, SWT.CHECK);
PropsUi.setLook(wAddPartnr);
FormData fdAddPartnr = new FormData();
fdAddPartnr.left = new FormAttachment(middle, 0);
fdAddPartnr.top = new FormAttachment(wlAddPartnr, 0, SWT.CENTER);
fdAddPartnr.right = new FormAttachment(100, 0);
wAddPartnr.setLayoutData(fdAddPartnr);
wAddPartnr.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// Create multi-part file?
wlAddDate = new Label(wFileComp, SWT.RIGHT);
wlAddDate.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.AddDate.Label"));
PropsUi.setLook(wlAddDate);
FormData fdlAddDate = new FormData();
fdlAddDate.left = new FormAttachment(0, 0);
fdlAddDate.top = new FormAttachment(wAddPartnr, margin);
fdlAddDate.right = new FormAttachment(middle, -margin);
wlAddDate.setLayoutData(fdlAddDate);
wAddDate = new Button(wFileComp, SWT.CHECK);
PropsUi.setLook(wAddDate);
FormData fdAddDate = new FormData();
fdAddDate.left = new FormAttachment(middle, 0);
fdAddDate.top = new FormAttachment(wlAddDate, 0, SWT.CENTER);
fdAddDate.right = new FormAttachment(100, 0);
wAddDate.setLayoutData(fdAddDate);
wAddDate.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// Create multi-part file?
wlAddTime = new Label(wFileComp, SWT.RIGHT);
wlAddTime.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.AddTime.Label"));
PropsUi.setLook(wlAddTime);
FormData fdlAddTime = new FormData();
fdlAddTime.left = new FormAttachment(0, 0);
fdlAddTime.top = new FormAttachment(wAddDate, margin);
fdlAddTime.right = new FormAttachment(middle, -margin);
wlAddTime.setLayoutData(fdlAddTime);
wAddTime = new Button(wFileComp, SWT.CHECK);
PropsUi.setLook(wAddTime);
FormData fdAddTime = new FormData();
fdAddTime.left = new FormAttachment(middle, 0);
fdAddTime.top = new FormAttachment(wlAddTime, 0, SWT.CENTER);
fdAddTime.right = new FormAttachment(100, 0);
wAddTime.setLayoutData(fdAddTime);
wAddTime.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// Specify date time format?
wlSpecifyFormat = new Label(wFileComp, SWT.RIGHT);
wlSpecifyFormat.setText(
BaseMessages.getString(PKG, "TextFileOutputDialog.SpecifyFormat.Label"));
PropsUi.setLook(wlSpecifyFormat);
FormData fdlSpecifyFormat = new FormData();
fdlSpecifyFormat.left = new FormAttachment(0, 0);
fdlSpecifyFormat.top = new FormAttachment(wAddTime, margin);
fdlSpecifyFormat.right = new FormAttachment(middle, -margin);
wlSpecifyFormat.setLayoutData(fdlSpecifyFormat);
wSpecifyFormat = new Button(wFileComp, SWT.CHECK);
PropsUi.setLook(wSpecifyFormat);
wSpecifyFormat.setToolTipText(
BaseMessages.getString(PKG, "TextFileOutputDialog.SpecifyFormat.Tooltip"));
FormData fdSpecifyFormat = new FormData();
fdSpecifyFormat.left = new FormAttachment(middle, 0);
fdSpecifyFormat.top = new FormAttachment(wlSpecifyFormat, 0, SWT.CENTER);
fdSpecifyFormat.right = new FormAttachment(100, 0);
wSpecifyFormat.setLayoutData(fdSpecifyFormat);
wSpecifyFormat.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
setDateTimeFormat();
}
});
// DateTimeFormat
wlDateTimeFormat = new Label(wFileComp, SWT.RIGHT);
wlDateTimeFormat.setText(
BaseMessages.getString(PKG, "TextFileOutputDialog.DateTimeFormat.Label"));
PropsUi.setLook(wlDateTimeFormat);
FormData fdlDateTimeFormat = new FormData();
fdlDateTimeFormat.left = new FormAttachment(0, 0);
fdlDateTimeFormat.top = new FormAttachment(wSpecifyFormat, margin);
fdlDateTimeFormat.right = new FormAttachment(middle, -margin);
wlDateTimeFormat.setLayoutData(fdlDateTimeFormat);
wDateTimeFormat = new CCombo(wFileComp, SWT.BORDER | SWT.READ_ONLY);
wDateTimeFormat.setEditable(true);
PropsUi.setLook(wDateTimeFormat);
wDateTimeFormat.addModifyListener(lsMod);
FormData fdDateTimeFormat = new FormData();
fdDateTimeFormat.left = new FormAttachment(middle, 0);
fdDateTimeFormat.top = new FormAttachment(wSpecifyFormat, margin);
fdDateTimeFormat.right = new FormAttachment(100, 0);
wDateTimeFormat.setLayoutData(fdDateTimeFormat);
String[] dats = Const.getDateFormats();
for (String dat : dats) {
wDateTimeFormat.add(dat);
}
wbShowFiles = new Button(wFileComp, SWT.PUSH | SWT.CENTER);
PropsUi.setLook(wbShowFiles);
wbShowFiles.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.ShowFiles.Button"));
FormData fdbShowFiles = new FormData();
fdbShowFiles.left = new FormAttachment(middle, 0);
fdbShowFiles.top = new FormAttachment(wDateTimeFormat, margin * 2);
wbShowFiles.setLayoutData(fdbShowFiles);
wbShowFiles.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TextFileOutputMeta tfoi = new TextFileOutputMeta();
saveInfoInMeta(tfoi);
String[] files = tfoi.getFiles(variables);
if (files != null && files.length > 0) {
EnterSelectionDialog esd =
new EnterSelectionDialog(
shell,
files,
BaseMessages.getString(
PKG, "TextFileOutputDialog.SelectOutputFiles.DialogTitle"),
BaseMessages.getString(
PKG, "TextFileOutputDialog.SelectOutputFiles.DialogMessage"));
esd.setViewOnly();
esd.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(
BaseMessages.getString(PKG, "TextFileOutputDialog.NoFilesFound.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "System.Dialog.Error.Title"));
mb.open();
}
}
});
// Add File to the result files name
wlAddToResult = new Label(wFileComp, SWT.RIGHT);
wlAddToResult.setText(
BaseMessages.getString(PKG, "TextFileOutputDialog.AddFileToResult.Label"));
PropsUi.setLook(wlAddToResult);
FormData fdlAddToResult = new FormData();
fdlAddToResult.left = new FormAttachment(0, 0);
fdlAddToResult.top = new FormAttachment(wbShowFiles, 2 * margin);
fdlAddToResult.right = new FormAttachment(middle, -margin);
wlAddToResult.setLayoutData(fdlAddToResult);
wAddToResult = new Button(wFileComp, SWT.CHECK);
wAddToResult.setToolTipText(
BaseMessages.getString(PKG, "TextFileOutputDialog.AddFileToResult.Tooltip"));
PropsUi.setLook(wAddToResult);
FormData fdAddToResult = new FormData();
fdAddToResult.left = new FormAttachment(middle, 0);
fdAddToResult.top = new FormAttachment(wlAddToResult, 0, SWT.CENTER);
fdAddToResult.right = new FormAttachment(100, 0);
wAddToResult.setLayoutData(fdAddToResult);
SelectionAdapter lsSelR =
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
input.setChanged();
}
};
wAddToResult.addSelectionListener(lsSelR);
FormData fdFileComp = new FormData();
fdFileComp.left = new FormAttachment(0, 0);
fdFileComp.top = new FormAttachment(0, 0);
fdFileComp.right = new FormAttachment(100, 0);
fdFileComp.bottom = new FormAttachment(100, 0);
wFileComp.setLayoutData(fdFileComp);
wFileComp.layout();
wFileTab.setControl(wFileComp);
// ///////////////////////////////////////////////////////////
// / END OF FILE TAB
// ///////////////////////////////////////////////////////////
// ////////////////////////
// START OF CONTENT TAB///
// /
CTabItem wContentTab = new CTabItem(wTabFolder, SWT.NONE);
wContentTab.setFont(GuiResource.getInstance().getFontDefault());
wContentTab.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.ContentTab.TabTitle"));
FormLayout contentLayout = new FormLayout();
contentLayout.marginWidth = 3;
contentLayout.marginHeight = 3;
Composite wContentComp = new Composite(wTabFolder, SWT.NONE);
PropsUi.setLook(wContentComp);
wContentComp.setLayout(contentLayout);
// Append to end of file?
wlAppend = new Label(wContentComp, SWT.RIGHT);
wlAppend.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.Append.Label"));
PropsUi.setLook(wlAppend);
FormData fdlAppend = new FormData();
fdlAppend.left = new FormAttachment(0, 0);
fdlAppend.top = new FormAttachment(0, 0);
fdlAppend.right = new FormAttachment(middle, -margin);
wlAppend.setLayoutData(fdlAppend);
wAppend = new Button(wContentComp, SWT.CHECK);
PropsUi.setLook(wAppend);
FormData fdAppend = new FormData();
fdAppend.left = new FormAttachment(middle, 0);
fdAppend.top = new FormAttachment(wlAppend, 0, SWT.CENTER);
fdAppend.right = new FormAttachment(100, 0);
wAppend.setLayoutData(fdAppend);
wAppend.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
private void headerDisabling() {
wHeader.setSelection(false);
wHeader.setEnabled(!wAppend.getSelection());
}
});
Label wlSeparator = new Label(wContentComp, SWT.RIGHT);
wlSeparator.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.Separator.Label"));
PropsUi.setLook(wlSeparator);
FormData fdlSeparator = new FormData();
fdlSeparator.left = new FormAttachment(0, 0);
fdlSeparator.top = new FormAttachment(wAppend, margin);
fdlSeparator.right = new FormAttachment(middle, -margin);
wlSeparator.setLayoutData(fdlSeparator);
Button wbSeparator = new Button(wContentComp, SWT.PUSH | SWT.CENTER);
PropsUi.setLook(wbSeparator);
wbSeparator.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.Separator.Button"));
FormData fdbSeparator = new FormData();
fdbSeparator.right = new FormAttachment(100, 0);
fdbSeparator.top = new FormAttachment(wAppend, 0);
wbSeparator.setLayoutData(fdbSeparator);
wbSeparator.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent se) {
wSeparator.getTextWidget().insert("\t");
}
});
wSeparator = new TextVar(variables, wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
PropsUi.setLook(wSeparator);
wSeparator.addModifyListener(lsMod);
FormData fdSeparator = new FormData();
fdSeparator.left = new FormAttachment(middle, 0);
fdSeparator.top = new FormAttachment(wAppend, margin);
fdSeparator.right = new FormAttachment(wbSeparator, -margin);
wSeparator.setLayoutData(fdSeparator);
// Enclosure line...
Label wlEnclosure = new Label(wContentComp, SWT.RIGHT);
wlEnclosure.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.Enclosure.Label"));
PropsUi.setLook(wlEnclosure);
FormData fdlEnclosure = new FormData();
fdlEnclosure.left = new FormAttachment(0, 0);
fdlEnclosure.top = new FormAttachment(wSeparator, margin);
fdlEnclosure.right = new FormAttachment(middle, -margin);
wlEnclosure.setLayoutData(fdlEnclosure);
wEnclosure = new TextVar(variables, wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
PropsUi.setLook(wEnclosure);
wEnclosure.addModifyListener(lsMod);
FormData fdEnclosure = new FormData();
fdEnclosure.left = new FormAttachment(middle, 0);
fdEnclosure.top = new FormAttachment(wSeparator, margin);
fdEnclosure.right = new FormAttachment(100, 0);
wEnclosure.setLayoutData(fdEnclosure);
Label wlEnclForced = new Label(wContentComp, SWT.RIGHT);
wlEnclForced.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.EnclForced.Label"));
PropsUi.setLook(wlEnclForced);
FormData fdlEnclForced = new FormData();
fdlEnclForced.left = new FormAttachment(0, 0);
fdlEnclForced.top = new FormAttachment(wEnclosure, margin);
fdlEnclForced.right = new FormAttachment(middle, -margin);
wlEnclForced.setLayoutData(fdlEnclForced);
wEnclForced = new Button(wContentComp, SWT.CHECK);
PropsUi.setLook(wEnclForced);
FormData fdEnclForced = new FormData();
fdEnclForced.left = new FormAttachment(middle, 0);
fdEnclForced.top = new FormAttachment(wlEnclForced, 0, SWT.CENTER);
fdEnclForced.right = new FormAttachment(100, 0);
wEnclForced.setLayoutData(fdEnclForced);
wEnclForced.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
Label wlDisableEnclosureFix = new Label(wContentComp, SWT.RIGHT);
wlDisableEnclosureFix.setText(
BaseMessages.getString(PKG, "TextFileOutputDialog.DisableEnclosureFix.Label"));
PropsUi.setLook(wlDisableEnclosureFix);
FormData fdlDisableEnclosureFix = new FormData();
fdlDisableEnclosureFix.left = new FormAttachment(0, 0);
fdlDisableEnclosureFix.top = new FormAttachment(wEnclForced, margin);
fdlDisableEnclosureFix.right = new FormAttachment(middle, -margin);
wlDisableEnclosureFix.setLayoutData(fdlDisableEnclosureFix);
wDisableEnclosureFix = new Button(wContentComp, SWT.CHECK);
PropsUi.setLook(wDisableEnclosureFix);
FormData fdDisableEnclosureFix = new FormData();
fdDisableEnclosureFix.left = new FormAttachment(middle, 0);
fdDisableEnclosureFix.top = new FormAttachment(wlDisableEnclosureFix, 0, SWT.CENTER);
fdDisableEnclosureFix.right = new FormAttachment(100, 0);
wDisableEnclosureFix.setLayoutData(fdDisableEnclosureFix);
wDisableEnclosureFix.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
Label wlHeader = new Label(wContentComp, SWT.RIGHT);
wlHeader.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.Header.Label"));
PropsUi.setLook(wlHeader);
FormData fdlHeader = new FormData();
fdlHeader.left = new FormAttachment(0, 0);
fdlHeader.top = new FormAttachment(wDisableEnclosureFix, margin);
fdlHeader.right = new FormAttachment(middle, -margin);
wlHeader.setLayoutData(fdlHeader);
wHeader = new Button(wContentComp, SWT.CHECK);
PropsUi.setLook(wHeader);
FormData fdHeader = new FormData();
fdHeader.left = new FormAttachment(middle, 0);
fdHeader.top = new FormAttachment(wlHeader, 0, SWT.CENTER);
fdHeader.right = new FormAttachment(100, 0);
wHeader.setLayoutData(fdHeader);
wHeader.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
Label wlFooter = new Label(wContentComp, SWT.RIGHT);
wlFooter.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.Footer.Label"));
PropsUi.setLook(wlFooter);
FormData fdlFooter = new FormData();
fdlFooter.left = new FormAttachment(0, 0);
fdlFooter.top = new FormAttachment(wHeader, margin);
fdlFooter.right = new FormAttachment(middle, -margin);
wlFooter.setLayoutData(fdlFooter);
wFooter = new Button(wContentComp, SWT.CHECK);
PropsUi.setLook(wFooter);
FormData fdFooter = new FormData();
fdFooter.left = new FormAttachment(middle, 0);
fdFooter.top = new FormAttachment(wlFooter, 0, SWT.CENTER);
fdFooter.right = new FormAttachment(100, 0);
wFooter.setLayoutData(fdFooter);
wFooter.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
Label wlFormat = new Label(wContentComp, SWT.RIGHT);
wlFormat.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.Format.Label"));
PropsUi.setLook(wlFormat);
FormData fdlFormat = new FormData();
fdlFormat.left = new FormAttachment(0, 0);
fdlFormat.top = new FormAttachment(wFooter, margin);
fdlFormat.right = new FormAttachment(middle, -margin);
wlFormat.setLayoutData(fdlFormat);
wFormat = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
wFormat.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.Format.Label"));
PropsUi.setLook(wFormat);
for (int i = 0; i < TextFileOutputMeta.formatMapperLineTerminator.length; i++) {
// add e.g. TextFileOutputDialog.Format.DOS, .UNIX, .CR, .None
wFormat.add(
BaseMessages.getString(
PKG,
"TextFileOutputDialog.Format." + TextFileOutputMeta.formatMapperLineTerminator[i]));
}
wFormat.select(0);
wFormat.addModifyListener(lsMod);
FormData fdFormat = new FormData();
fdFormat.left = new FormAttachment(middle, 0);
fdFormat.top = new FormAttachment(wFooter, margin);
fdFormat.right = new FormAttachment(100, 0);
wFormat.setLayoutData(fdFormat);
Label wlCompression = new Label(wContentComp, SWT.RIGHT);
wlCompression.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.Compression.Label"));
PropsUi.setLook(wlCompression);
FormData fdlCompression = new FormData();
fdlCompression.left = new FormAttachment(0, 0);
fdlCompression.top = new FormAttachment(wFormat, margin);
fdlCompression.right = new FormAttachment(middle, -margin);
wlCompression.setLayoutData(fdlCompression);
wCompression = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
wCompression.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.Compression.Label"));
PropsUi.setLook(wCompression);
wCompression.setItems(CompressionProviderFactory.getInstance().getCompressionProviderNames());
wCompression.addModifyListener(lsMod);
FormData fdCompression = new FormData();
fdCompression.left = new FormAttachment(middle, 0);
fdCompression.top = new FormAttachment(wFormat, margin);
fdCompression.right = new FormAttachment(100, 0);
wCompression.setLayoutData(fdCompression);
Label wlEncoding = new Label(wContentComp, SWT.RIGHT);
wlEncoding.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.Encoding.Label"));
PropsUi.setLook(wlEncoding);
FormData fdlEncoding = new FormData();
fdlEncoding.left = new FormAttachment(0, 0);
fdlEncoding.top = new FormAttachment(wCompression, margin);
fdlEncoding.right = new FormAttachment(middle, -margin);
wlEncoding.setLayoutData(fdlEncoding);
wEncoding = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
wEncoding.setEditable(true);
PropsUi.setLook(wEncoding);
wEncoding.addModifyListener(lsMod);
FormData fdEncoding = new FormData();
fdEncoding.left = new FormAttachment(middle, 0);
fdEncoding.top = new FormAttachment(wCompression, margin);
fdEncoding.right = new FormAttachment(100, 0);
wEncoding.setLayoutData(fdEncoding);
wEncoding.addFocusListener(
new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
// Do nothing
}
@Override
public void focusGained(FocusEvent e) {
Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
shell.setCursor(busy);
setEncodings();
shell.setCursor(null);
busy.dispose();
}
});
Label wlPad = new Label(wContentComp, SWT.RIGHT);
wlPad.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.Pad.Label"));
PropsUi.setLook(wlPad);
FormData fdlPad = new FormData();
fdlPad.left = new FormAttachment(0, 0);
fdlPad.top = new FormAttachment(wEncoding, margin);
fdlPad.right = new FormAttachment(middle, -margin);
wlPad.setLayoutData(fdlPad);
wPad = new Button(wContentComp, SWT.CHECK);
PropsUi.setLook(wPad);
FormData fdPad = new FormData();
fdPad.left = new FormAttachment(middle, 0);
fdPad.top = new FormAttachment(wlPad, 0, SWT.CENTER);
fdPad.right = new FormAttachment(100, 0);
wPad.setLayoutData(fdPad);
wPad.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
Label wlFastDump = new Label(wContentComp, SWT.RIGHT);
wlFastDump.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.FastDump.Label"));
PropsUi.setLook(wlFastDump);
FormData fdlFastDump = new FormData();
fdlFastDump.left = new FormAttachment(0, 0);
fdlFastDump.top = new FormAttachment(wPad, margin);
fdlFastDump.right = new FormAttachment(middle, -margin);
wlFastDump.setLayoutData(fdlFastDump);
wFastDump = new Button(wContentComp, SWT.CHECK);
PropsUi.setLook(wFastDump);
FormData fdFastDump = new FormData();
fdFastDump.left = new FormAttachment(middle, 0);
fdFastDump.top = new FormAttachment(wlFastDump, 0, SWT.CENTER);
fdFastDump.right = new FormAttachment(100, 0);
wFastDump.setLayoutData(fdFastDump);
wFastDump.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
wlSplitEvery = new Label(wContentComp, SWT.RIGHT);
wlSplitEvery.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.SplitEvery.Label"));
PropsUi.setLook(wlSplitEvery);
FormData fdlSplitEvery = new FormData();
fdlSplitEvery.left = new FormAttachment(0, 0);
fdlSplitEvery.top = new FormAttachment(wFastDump, margin);
fdlSplitEvery.right = new FormAttachment(middle, -margin);
wlSplitEvery.setLayoutData(fdlSplitEvery);
wSplitEvery = new TextVar(variables, wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
PropsUi.setLook(wSplitEvery);
wSplitEvery.addModifyListener(lsMod);
FormData fdSplitEvery = new FormData();
fdSplitEvery.left = new FormAttachment(middle, 0);
fdSplitEvery.top = new FormAttachment(wFastDump, margin);
fdSplitEvery.right = new FormAttachment(100, 0);
wSplitEvery.setLayoutData(fdSplitEvery);
// Bruise:
Label wlEndedLine = new Label(wContentComp, SWT.RIGHT);
wlEndedLine.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.EndedLine.Label"));
PropsUi.setLook(wlEndedLine);
FormData fdlEndedLine = new FormData();
fdlEndedLine.left = new FormAttachment(0, 0);
fdlEndedLine.top = new FormAttachment(wSplitEvery, margin);
fdlEndedLine.right = new FormAttachment(middle, -margin);
wlEndedLine.setLayoutData(fdlEndedLine);
wEndedLine = new TextVar(variables, wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
PropsUi.setLook(wEndedLine);
wEndedLine.addModifyListener(lsMod);
FormData fdEndedLine = new FormData();
fdEndedLine.left = new FormAttachment(middle, 0);
fdEndedLine.top = new FormAttachment(wSplitEvery, margin);
fdEndedLine.right = new FormAttachment(100, 0);
wEndedLine.setLayoutData(fdEndedLine);
FormData fdContentComp = new FormData();
fdContentComp.left = new FormAttachment(0, 0);
fdContentComp.top = new FormAttachment(0, 0);
fdContentComp.right = new FormAttachment(100, 0);
fdContentComp.bottom = new FormAttachment(100, 0);
wContentComp.setLayoutData(fdContentComp);
wContentComp.layout();
wContentTab.setControl(wContentComp);
// ///////////////////////////////////////////////////////////
// / END OF CONTENT TAB
// ///////////////////////////////////////////////////////////
// Fields tab...
//
SelectionListener lsSelection =
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fillFieldsLayoutFromSchema();
input.setChanged();
}
};
CTabItem wFieldsTab = new CTabItem(wTabFolder, SWT.NONE);
wFieldsTab.setFont(GuiResource.getInstance().getFontDefault());
wFieldsTab.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.FieldsTab.TabTitle"));
FormLayout fieldsLayout = new FormLayout();
fieldsLayout.marginWidth = 3;
fieldsLayout.marginHeight = 3;
Composite wFieldsComp = new Composite(wTabFolder, SWT.NONE);
PropsUi.setLook(wFieldsComp);
wFieldsComp.setLayout(fieldsLayout);
Group fieldGroup = new Group(wFieldsComp, SWT.SHADOW_NONE);
PropsUi.setLook(fieldGroup);
fieldGroup.setText(
BaseMessages.getString(PKG, "TextFileOutputDialog.ManualSchemaDefinition.Label"));
FormLayout fieldGroupGroupLayout = new FormLayout();
fieldGroupGroupLayout.marginWidth = 10;
fieldGroupGroupLayout.marginHeight = 10;
fieldGroup.setLayout(fieldGroupGroupLayout);
wGet = new Button(fieldGroup, SWT.PUSH);
wGet.setText(BaseMessages.getString(PKG, "System.Button.GetFields"));
wGet.setToolTipText(BaseMessages.getString(PKG, "System.Tooltip.GetFields"));
Button wMinWidth = new Button(fieldGroup, SWT.PUSH);
wMinWidth.setText(BaseMessages.getString(PKG, "TextFileOutputDialog.MinWidth.Button"));
wMinWidth.setToolTipText(BaseMessages.getString(PKG, "TextFileOutputDialog.MinWidth.Tooltip"));
wMinWidth.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
setButtonPositions(new Button[] {wGet, wMinWidth}, margin, null);
wSchemaDefinition =
new MetaSelectionLine<>(
variables,
metadataProvider,
SchemaDefinition.class,
wFieldsComp,
SWT.NONE,
BaseMessages.getString(PKG, "TextFileOutputDialog.SchemaDefinition.Label"),
BaseMessages.getString(PKG, "TextFileOutputDialog.SchemaDefinition.Tooltip"));
PropsUi.setLook(wSchemaDefinition);
FormData fdSchemaDefinition = new FormData();
fdSchemaDefinition.left = new FormAttachment(0, 0);
fdSchemaDefinition.top = new FormAttachment(0, margin);
fdSchemaDefinition.right = new FormAttachment(100, 0);
wSchemaDefinition.setLayoutData(fdSchemaDefinition);
try {
wSchemaDefinition.fillItems();
} catch (Exception e) {
log.logError("Error getting schema definition items", e);
}
wSchemaDefinition.addSelectionListener(lsSelection);
final int FieldsRows = input.getOutputFields().length;
colinf =
new ColumnInfo[] {
new ColumnInfo(
BaseMessages.getString(PKG, "TextFileOutputDialog.NameColumn.Column"),
ColumnInfo.COLUMN_TYPE_CCOMBO,
new String[] {""},
false),
new ColumnInfo(
BaseMessages.getString(PKG, "TextFileOutputDialog.TypeColumn.Column"),
ColumnInfo.COLUMN_TYPE_CCOMBO,
ValueMetaFactory.getValueMetaNames()),
new ColumnInfo(
BaseMessages.getString(PKG, "TextFileOutputDialog.FormatColumn.Column"),
ColumnInfo.COLUMN_TYPE_FORMAT,
2),
new ColumnInfo(
BaseMessages.getString(PKG, "TextFileOutputDialog.LengthColumn.Column"),
ColumnInfo.COLUMN_TYPE_TEXT,
false),
new ColumnInfo(
BaseMessages.getString(PKG, "TextFileOutputDialog.PrecisionColumn.Column"),
ColumnInfo.COLUMN_TYPE_TEXT,
false),
new ColumnInfo(
BaseMessages.getString(PKG, "TextFileOutputDialog.CurrencyColumn.Column"),
ColumnInfo.COLUMN_TYPE_TEXT,
false),
new ColumnInfo(
BaseMessages.getString(PKG, "TextFileOutputDialog.DecimalColumn.Column"),
ColumnInfo.COLUMN_TYPE_TEXT,
false),
new ColumnInfo(
BaseMessages.getString(PKG, "TextFileOutputDialog.GroupColumn.Column"),
ColumnInfo.COLUMN_TYPE_TEXT,
false),
new ColumnInfo(
BaseMessages.getString(PKG, "TextFileOutputDialog.TrimTypeColumn.Column"),
ColumnInfo.COLUMN_TYPE_CCOMBO,
ValueMetaBase.trimTypeDesc,
true),
new ColumnInfo(
BaseMessages.getString(PKG, "TextFileOutputDialog.NullColumn.Column"),
ColumnInfo.COLUMN_TYPE_TEXT,
false),
new ColumnInfo(
BaseMessages.getString(PKG, "TextFileOutputDialog.RoundingTypeColumn.Column"),
ColumnInfo.COLUMN_TYPE_CCOMBO,
ValueMetaBase.roundingTypeDesc,
true),
};
wFields =
new TableView(
variables,
fieldGroup,
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, 0);
fdFields.right = new FormAttachment(100, 0);
fdFields.bottom = new FormAttachment(wGet, -margin);
wFields.setLayoutData(fdFields);
//
// Search the fields in the background
final Runnable runnable =
() -> {
TransformMeta transformMeta = pipelineMeta.findTransform(transformName);
if (transformMeta != null) {
try {
IRowMeta row = pipelineMeta.getPrevTransformFields(variables, transformMeta);
// Remember these fields...
for (int i = 0; i < row.size(); i++) {
inputFields.add(row.getValueMeta(i).getName());
}
setComboBoxes();
} catch (HopException e) {
logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
}
};
new Thread(runnable).start();
FormData fdFieldGroup = new FormData();
fdFieldGroup.left = new FormAttachment(0, margin);
fdFieldGroup.top = new FormAttachment(wSchemaDefinition, margin);
fdFieldGroup.right = new FormAttachment(100, -margin);
fdFieldGroup.bottom = new FormAttachment(100, 0);
fieldGroup.setLayoutData(fdFieldGroup);
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);
wFieldsComp.setLayoutData(fdFieldsComp);
wFieldsComp.layout();
wFieldsTab.setControl(wFieldsComp);
FormData fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(wTransformName, margin);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(wOk, -2 * margin);
wTabFolder.setLayoutData(fdTabFolder);
wGet.addListener(SWT.Selection, e -> get());
wMinWidth.addListener(SWT.Selection, e -> setMinimalWidth());
// Whenever something changes, set the tooltip to the expanded version:
wFilename.addModifyListener(
e -> wFilename.setToolTipText(variables.resolve(wFilename.getText())));
wbFilename.addListener(
SWT.Selection,
e ->
BaseDialog.presentFileDialog(
true,
shell,
wFilename,
variables,
new String[] {"*.txt", "*.csv", "*"},
new String[] {
BaseMessages.getString(PKG, "System.FileType.TextFiles"),
BaseMessages.getString(PKG, "System.FileType.CSVFiles"),
BaseMessages.getString(PKG, "System.FileType.AllFiles")
},
true));
wTabFolder.setSelection(0);
getData();
activeFileNameField();
enableParentFolder();
input.setChanged(changed);
BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
return transformName;
}