use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.
the class CsvInputDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
props.setLook(shell);
setShellImage(shell, inputMeta);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
inputMeta.setChanged();
}
};
changed = inputMeta.hasChanged();
ModifyListener lsContent = new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
// asyncUpdatePreview();
}
};
initializing = true;
previewBusy = new AtomicBoolean(false);
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "CsvInputDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Step name line
//
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "CsvInputDialog.Stepname.Label"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
Control lastControl = wStepname;
// See if the step receives input. If so, we don't ask for the filename, but
// for the filename field.
//
isReceivingInput = transMeta.findNrPrevSteps(stepMeta) > 0;
if (isReceivingInput) {
RowMetaInterface previousFields;
try {
previousFields = transMeta.getPrevStepFields(stepMeta);
} catch (KettleStepException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "CsvInputDialog.ErrorDialog.UnableToGetInputFields.Title"), BaseMessages.getString(PKG, "CsvInputDialog.ErrorDialog.UnableToGetInputFields.Message"), e);
previousFields = new RowMeta();
}
// The filename field ...
//
Label wlFilename = new Label(shell, SWT.RIGHT);
wlFilename.setText(BaseMessages.getString(PKG, inputMeta.getDescription("FILENAME_FIELD")));
props.setLook(wlFilename);
FormData fdlFilename = new FormData();
fdlFilename.top = new FormAttachment(lastControl, margin);
fdlFilename.left = new FormAttachment(0, 0);
fdlFilename.right = new FormAttachment(middle, -margin);
wlFilename.setLayoutData(fdlFilename);
wFilenameField = new CCombo(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wFilenameField.setItems(previousFields.getFieldNames());
props.setLook(wFilenameField);
wFilenameField.addModifyListener(lsMod);
FormData fdFilename = new FormData();
fdFilename.top = new FormAttachment(lastControl, margin);
fdFilename.left = new FormAttachment(middle, 0);
fdFilename.right = new FormAttachment(100, 0);
wFilenameField.setLayoutData(fdFilename);
lastControl = wFilenameField;
// Checkbox to include the filename in the output...
//
Label wlIncludeFilename = new Label(shell, SWT.RIGHT);
wlIncludeFilename.setText(BaseMessages.getString(PKG, inputMeta.getDescription("INCLUDE_FILENAME")));
props.setLook(wlIncludeFilename);
FormData fdlIncludeFilename = new FormData();
fdlIncludeFilename.top = new FormAttachment(lastControl, margin);
fdlIncludeFilename.left = new FormAttachment(0, 0);
fdlIncludeFilename.right = new FormAttachment(middle, -margin);
wlIncludeFilename.setLayoutData(fdlIncludeFilename);
wIncludeFilename = new Button(shell, SWT.CHECK);
props.setLook(wIncludeFilename);
wFilenameField.addModifyListener(lsMod);
FormData fdIncludeFilename = new FormData();
fdIncludeFilename.top = new FormAttachment(lastControl, margin);
fdIncludeFilename.left = new FormAttachment(middle, 0);
fdIncludeFilename.right = new FormAttachment(100, 0);
wIncludeFilename.setLayoutData(fdIncludeFilename);
lastControl = wIncludeFilename;
} else {
// Filename...
//
// The filename browse button
//
wbbFilename = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbbFilename);
wbbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
wbbFilename.setToolTipText(BaseMessages.getString(PKG, "System.Tooltip.BrowseForFileOrDirAndAdd"));
FormData fdbFilename = new FormData();
fdbFilename.top = new FormAttachment(lastControl, margin);
fdbFilename.right = new FormAttachment(100, 0);
wbbFilename.setLayoutData(fdbFilename);
// The field itself...
//
Label wlFilename = new Label(shell, SWT.RIGHT);
wlFilename.setText(BaseMessages.getString(PKG, inputMeta.getDescription("FILENAME")));
props.setLook(wlFilename);
FormData fdlFilename = new FormData();
fdlFilename.top = new FormAttachment(lastControl, margin);
fdlFilename.left = new FormAttachment(0, 0);
fdlFilename.right = new FormAttachment(middle, -margin);
wlFilename.setLayoutData(fdlFilename);
wFilename = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wFilename);
wFilename.addModifyListener(lsMod);
FormData fdFilename = new FormData();
fdFilename.top = new FormAttachment(lastControl, margin);
fdFilename.left = new FormAttachment(middle, 0);
fdFilename.right = new FormAttachment(wbbFilename, -margin);
wFilename.setLayoutData(fdFilename);
/*
* wFilename.addFocusListener(new FocusAdapter() {
*
* @Override public void focusLost(FocusEvent arg0) { asyncUpdatePreview(); } });
*/
lastControl = wFilename;
}
// delimiter
Label wlDelimiter = new Label(shell, SWT.RIGHT);
wlDelimiter.setText(BaseMessages.getString(PKG, inputMeta.getDescription("DELIMITER")));
props.setLook(wlDelimiter);
FormData fdlDelimiter = new FormData();
fdlDelimiter.top = new FormAttachment(lastControl, margin);
fdlDelimiter.left = new FormAttachment(0, 0);
fdlDelimiter.right = new FormAttachment(middle, -margin);
wlDelimiter.setLayoutData(fdlDelimiter);
wbDelimiter = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbDelimiter);
wbDelimiter.setText(BaseMessages.getString(PKG, "CsvInputDialog.Delimiter.Button"));
FormData fdbDelimiter = new FormData();
fdbDelimiter.top = new FormAttachment(lastControl, margin);
fdbDelimiter.right = new FormAttachment(100, 0);
wbDelimiter.setLayoutData(fdbDelimiter);
wDelimiter = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wDelimiter);
wDelimiter.addModifyListener(lsMod);
FormData fdDelimiter = new FormData();
fdDelimiter.top = new FormAttachment(lastControl, margin);
fdDelimiter.left = new FormAttachment(middle, 0);
fdDelimiter.right = new FormAttachment(wbDelimiter, -margin);
wDelimiter.setLayoutData(fdDelimiter);
wDelimiter.addModifyListener(lsContent);
lastControl = wDelimiter;
// enclosure
Label wlEnclosure = new Label(shell, SWT.RIGHT);
wlEnclosure.setText(BaseMessages.getString(PKG, inputMeta.getDescription("ENCLOSURE")));
props.setLook(wlEnclosure);
FormData fdlEnclosure = new FormData();
fdlEnclosure.top = new FormAttachment(lastControl, margin);
fdlEnclosure.left = new FormAttachment(0, 0);
fdlEnclosure.right = new FormAttachment(middle, -margin);
wlEnclosure.setLayoutData(fdlEnclosure);
wEnclosure = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wEnclosure);
wEnclosure.addModifyListener(lsMod);
FormData fdEnclosure = new FormData();
fdEnclosure.top = new FormAttachment(lastControl, margin);
fdEnclosure.left = new FormAttachment(middle, 0);
fdEnclosure.right = new FormAttachment(100, 0);
wEnclosure.setLayoutData(fdEnclosure);
wEnclosure.addModifyListener(lsContent);
lastControl = wEnclosure;
// bufferSize
//
Label wlBufferSize = new Label(shell, SWT.RIGHT);
wlBufferSize.setText(BaseMessages.getString(PKG, inputMeta.getDescription("BUFFERSIZE")));
props.setLook(wlBufferSize);
FormData fdlBufferSize = new FormData();
fdlBufferSize.top = new FormAttachment(lastControl, margin);
fdlBufferSize.left = new FormAttachment(0, 0);
fdlBufferSize.right = new FormAttachment(middle, -margin);
wlBufferSize.setLayoutData(fdlBufferSize);
wBufferSize = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wBufferSize);
wBufferSize.addModifyListener(lsMod);
FormData fdBufferSize = new FormData();
fdBufferSize.top = new FormAttachment(lastControl, margin);
fdBufferSize.left = new FormAttachment(middle, 0);
fdBufferSize.right = new FormAttachment(100, 0);
wBufferSize.setLayoutData(fdBufferSize);
lastControl = wBufferSize;
// performingLazyConversion?
//
Label wlLazyConversion = new Label(shell, SWT.RIGHT);
wlLazyConversion.setText(BaseMessages.getString(PKG, inputMeta.getDescription("LAZY_CONVERSION")));
props.setLook(wlLazyConversion);
FormData fdlLazyConversion = new FormData();
fdlLazyConversion.top = new FormAttachment(lastControl, margin);
fdlLazyConversion.left = new FormAttachment(0, 0);
fdlLazyConversion.right = new FormAttachment(middle, -margin);
wlLazyConversion.setLayoutData(fdlLazyConversion);
wLazyConversion = new Button(shell, SWT.CHECK);
props.setLook(wLazyConversion);
FormData fdLazyConversion = new FormData();
fdLazyConversion.top = new FormAttachment(lastControl, margin);
fdLazyConversion.left = new FormAttachment(middle, 0);
fdLazyConversion.right = new FormAttachment(100, 0);
wLazyConversion.setLayoutData(fdLazyConversion);
lastControl = wLazyConversion;
// header row?
//
Label wlHeaderPresent = new Label(shell, SWT.RIGHT);
wlHeaderPresent.setText(BaseMessages.getString(PKG, inputMeta.getDescription("HEADER_PRESENT")));
props.setLook(wlHeaderPresent);
FormData fdlHeaderPresent = new FormData();
fdlHeaderPresent.top = new FormAttachment(lastControl, margin);
fdlHeaderPresent.left = new FormAttachment(0, 0);
fdlHeaderPresent.right = new FormAttachment(middle, -margin);
wlHeaderPresent.setLayoutData(fdlHeaderPresent);
wHeaderPresent = new Button(shell, SWT.CHECK);
props.setLook(wHeaderPresent);
FormData fdHeaderPresent = new FormData();
fdHeaderPresent.top = new FormAttachment(lastControl, margin);
fdHeaderPresent.left = new FormAttachment(middle, 0);
fdHeaderPresent.right = new FormAttachment(100, 0);
wHeaderPresent.setLayoutData(fdHeaderPresent);
/*
* wHeaderPresent.addSelectionListener(new SelectionAdapter() {
*
* @Override public void widgetSelected(SelectionEvent arg0) { asyncUpdatePreview(); } });
*/
lastControl = wHeaderPresent;
wlAddResult = new Label(shell, SWT.RIGHT);
wlAddResult.setText(BaseMessages.getString(PKG, inputMeta.getDescription("ADD_FILENAME_RESULT")));
props.setLook(wlAddResult);
fdlAddResult = new FormData();
fdlAddResult.left = new FormAttachment(0, 0);
fdlAddResult.top = new FormAttachment(wHeaderPresent, margin);
fdlAddResult.right = new FormAttachment(middle, -margin);
wlAddResult.setLayoutData(fdlAddResult);
wAddResult = new Button(shell, SWT.CHECK);
props.setLook(wAddResult);
wAddResult.setToolTipText(BaseMessages.getString(PKG, inputMeta.getTooltip("ADD_FILENAME_RESULT")));
fdAddResult = new FormData();
fdAddResult.left = new FormAttachment(middle, 0);
fdAddResult.top = new FormAttachment(wHeaderPresent, margin);
wAddResult.setLayoutData(fdAddResult);
lastControl = wAddResult;
// The field itself...
//
Label wlRowNumField = new Label(shell, SWT.RIGHT);
wlRowNumField.setText(BaseMessages.getString(PKG, inputMeta.getDescription("ROW_NUM_FIELD")));
props.setLook(wlRowNumField);
FormData fdlRowNumField = new FormData();
fdlRowNumField.top = new FormAttachment(lastControl, margin);
fdlRowNumField.left = new FormAttachment(0, 0);
fdlRowNumField.right = new FormAttachment(middle, -margin);
wlRowNumField.setLayoutData(fdlRowNumField);
wRowNumField = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wRowNumField);
wRowNumField.addModifyListener(lsMod);
FormData fdRowNumField = new FormData();
fdRowNumField.top = new FormAttachment(lastControl, margin);
fdRowNumField.left = new FormAttachment(middle, 0);
fdRowNumField.right = new FormAttachment(100, 0);
wRowNumField.setLayoutData(fdRowNumField);
lastControl = wRowNumField;
// running in parallel?
//
wlRunningInParallel = new Label(shell, SWT.RIGHT);
wlRunningInParallel.setText(BaseMessages.getString(PKG, inputMeta.getDescription("PARALLEL")));
props.setLook(wlRunningInParallel);
FormData fdlRunningInParallel = new FormData();
fdlRunningInParallel.top = new FormAttachment(lastControl, margin);
fdlRunningInParallel.left = new FormAttachment(0, 0);
fdlRunningInParallel.right = new FormAttachment(middle, -margin);
wlRunningInParallel.setLayoutData(fdlRunningInParallel);
wRunningInParallel = new Button(shell, SWT.CHECK);
props.setLook(wRunningInParallel);
FormData fdRunningInParallel = new FormData();
fdRunningInParallel.top = new FormAttachment(lastControl, margin);
fdRunningInParallel.left = new FormAttachment(middle, 0);
wRunningInParallel.setLayoutData(fdRunningInParallel);
lastControl = wRunningInParallel;
// Is a new line possible in a field?
//
Label wlNewlinePossible = new Label(shell, SWT.RIGHT);
wlNewlinePossible.setText(BaseMessages.getString(PKG, inputMeta.getDescription("NEWLINE_POSSIBLE")));
props.setLook(wlNewlinePossible);
FormData fdlNewlinePossible = new FormData();
fdlNewlinePossible.top = new FormAttachment(lastControl, margin);
fdlNewlinePossible.left = new FormAttachment(0, 0);
fdlNewlinePossible.right = new FormAttachment(middle, -margin);
wlNewlinePossible.setLayoutData(fdlNewlinePossible);
wNewlinePossible = new Button(shell, SWT.CHECK);
props.setLook(wNewlinePossible);
FormData fdNewlinePossible = new FormData();
fdNewlinePossible.top = new FormAttachment(lastControl, margin);
fdNewlinePossible.left = new FormAttachment(middle, 0);
wNewlinePossible.setLayoutData(fdNewlinePossible);
wNewlinePossible.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
setFlags();
}
});
wNewlinePossible.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
asyncUpdatePreview();
}
});
lastControl = wNewlinePossible;
// Encoding
Label wlEncoding = new Label(shell, SWT.RIGHT);
wlEncoding.setText(BaseMessages.getString(PKG, inputMeta.getDescription("ENCODING")));
props.setLook(wlEncoding);
FormData fdlEncoding = new FormData();
fdlEncoding.top = new FormAttachment(lastControl, margin);
fdlEncoding.left = new FormAttachment(0, 0);
fdlEncoding.right = new FormAttachment(middle, -margin);
wlEncoding.setLayoutData(fdlEncoding);
wEncoding = new ComboVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wEncoding);
wEncoding.addModifyListener(lsMod);
FormData fdEncoding = new FormData();
fdEncoding.top = new FormAttachment(lastControl, margin);
fdEncoding.left = new FormAttachment(middle, 0);
fdEncoding.right = new FormAttachment(100, 0);
wEncoding.setLayoutData(fdEncoding);
wEncoding.addModifyListener(lsContent);
lastControl = wEncoding;
wEncoding.addFocusListener(new FocusListener() {
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
}
public void focusGained(org.eclipse.swt.events.FocusEvent e) {
Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
shell.setCursor(busy);
setEncodings();
shell.setCursor(null);
busy.dispose();
}
});
// Some buttons first, so that the dialog scales nicely...
//
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"));
wPreview = new Button(shell, SWT.PUSH);
wPreview.setText(BaseMessages.getString(PKG, "System.Button.Preview"));
wPreview.setEnabled(!isReceivingInput);
wGet = new Button(shell, SWT.PUSH);
wGet.setText(BaseMessages.getString(PKG, "System.Button.GetFields"));
wGet.setEnabled(!isReceivingInput);
setButtonPositions(new Button[] { wOK, wGet, wPreview, wCancel }, margin, null);
// Fields
ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_NAME")), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_TYPE")), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames(), true), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_FORMAT")), ColumnInfo.COLUMN_TYPE_FORMAT, 2), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_LENGTH")), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_PRECISION")), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_CURRENCY")), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_DECIMAL")), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_GROUP")), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_TRIM_TYPE")), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaString.trimTypeDesc) };
colinf[2].setComboValuesSelectionListener(new ComboValuesSelectionListener() {
public String[] getComboValues(TableItem tableItem, int rowNr, int colNr) {
String[] comboValues = new String[] {};
int type = ValueMetaFactory.getIdForValueMeta(tableItem.getText(colNr - 1));
switch(type) {
case ValueMetaInterface.TYPE_DATE:
comboValues = Const.getDateFormats();
break;
case ValueMetaInterface.TYPE_INTEGER:
case ValueMetaInterface.TYPE_BIGNUMBER:
case ValueMetaInterface.TYPE_NUMBER:
comboValues = Const.getNumberFormats();
break;
default:
break;
}
return comboValues;
}
});
wFields = new TableView(transMeta, shell, SWT.FULL_SELECTION | SWT.MULTI, colinf, 1, lsMod, props);
FormData fdFields = new FormData();
fdFields.top = new FormAttachment(lastControl, margin * 2);
fdFields.bottom = new FormAttachment(wOK, -margin * 2);
fdFields.left = new FormAttachment(0, 0);
fdFields.right = new FormAttachment(100, 0);
wFields.setLayoutData(fdFields);
wFields.setContentListener(lsContent);
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsPreview = new Listener() {
public void handleEvent(Event e) {
preview();
}
};
lsGet = new Listener() {
public void handleEvent(Event e) {
getCSV();
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wOK.addListener(SWT.Selection, lsOK);
wPreview.addListener(SWT.Selection, lsPreview);
wGet.addListener(SWT.Selection, lsGet);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
if (wFilename != null) {
wFilename.addSelectionListener(lsDef);
}
if (wFilenameField != null) {
wFilenameField.addSelectionListener(lsDef);
}
wDelimiter.addSelectionListener(lsDef);
wEnclosure.addSelectionListener(lsDef);
wBufferSize.addSelectionListener(lsDef);
wRowNumField.addSelectionListener(lsDef);
// Allow the insertion of tabs as separator...
wbDelimiter.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent se) {
Text t = wDelimiter.getTextWidget();
if (t != null) {
t.insert("\t");
}
}
});
if (wbbFilename != null) {
// Listen to the browse button next to the file name
wbbFilename.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
dialog.setFilterExtensions(new String[] { "*.txt;*.csv", "*.csv", "*.txt", "*" });
if (wFilename.getText() != null) {
String fname = transMeta.environmentSubstitute(wFilename.getText());
dialog.setFileName(fname);
}
dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "System.FileType.CSVFiles") + ", " + BaseMessages.getString(PKG, "System.FileType.TextFiles"), BaseMessages.getString(PKG, "System.FileType.CSVFiles"), BaseMessages.getString(PKG, "System.FileType.TextFiles"), BaseMessages.getString(PKG, "System.FileType.AllFiles") });
if (dialog.open() != null) {
String str = dialog.getFilterPath() + System.getProperty("file.separator") + dialog.getFileName();
wFilename.setText(str);
}
}
});
}
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
// Set the shell size, based upon previous time...
setSize();
getData();
inputMeta.setChanged(changed);
initializing = false;
// Update the preview window.
//
// asyncUpdatePreview();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.
the class ValidatorDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
props.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
input.setChanged();
}
};
changed = input.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "ValidatorDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
Rectangle imageBounds = GUIResource.getInstance().getImageInfoHop().getBounds();
// Stepname line
//
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "ValidatorDialog.Stepname.Label"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wStepname.setText(stepname);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
// Some buttons
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wNew = new Button(shell, SWT.PUSH);
wNew.setText(BaseMessages.getString(PKG, "ValidatorDialog.NewButton.Label"));
wClear = new Button(shell, SWT.PUSH);
wClear.setText(BaseMessages.getString(PKG, "ValidatorDialog.ClearButton.Label"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOK, wNew, wClear, wCancel }, margin, null);
// List of fields to the left...
//
Label wlFieldList = new Label(shell, SWT.LEFT);
wlFieldList.setText(BaseMessages.getString(PKG, "ValidatorDialog.FieldList.Label"));
props.setLook(wlFieldList);
FormData fdlFieldList = new FormData();
fdlFieldList.left = new FormAttachment(0, 0);
fdlFieldList.right = new FormAttachment(middle, -margin);
fdlFieldList.top = new FormAttachment(wStepname, margin);
wlFieldList.setLayoutData(fdlFieldList);
wValidationsList = new List(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
props.setLook(wValidationsList);
wValidationsList.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
showSelectedValidatorField(wValidationsList.getSelection()[0]);
}
});
FormData fdFieldList = new FormData();
fdFieldList.left = new FormAttachment(0, 0);
fdFieldList.top = new FormAttachment(wlFieldList, margin);
fdFieldList.right = new FormAttachment(middle, -margin);
fdFieldList.bottom = new FormAttachment(wOK, -margin * 2);
wValidationsList.setLayoutData(fdFieldList);
// General: an option to allow ALL the options to be checked.
//
wValidateAll = new Button(shell, SWT.CHECK);
wValidateAll.setText(BaseMessages.getString(PKG, "ValidatorDialog.ValidateAll.Label"));
props.setLook(wValidateAll);
FormData fdValidateAll = new FormData();
fdValidateAll.left = new FormAttachment(middle, 0);
fdValidateAll.right = new FormAttachment(100, 0);
fdValidateAll.top = new FormAttachment(wStepname, margin);
wValidateAll.setLayoutData(fdValidateAll);
wValidateAll.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
setFlags();
}
});
// General: When validating all options, still output a single row, errors concatenated
//
wConcatErrors = new Button(shell, SWT.CHECK);
wConcatErrors.setText(BaseMessages.getString(PKG, "ValidatorDialog.ConcatErrors.Label"));
props.setLook(wConcatErrors);
FormData fdConcatErrors = new FormData();
fdConcatErrors.left = new FormAttachment(middle, 0);
fdConcatErrors.top = new FormAttachment(wValidateAll, margin);
wConcatErrors.setLayoutData(fdConcatErrors);
wConcatErrors.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
setFlags();
}
});
// The separator
//
wConcatSeparator = new TextVarWarning(transMeta, shell, SWT.LEFT | SWT.SINGLE | SWT.BORDER);
props.setLook(wConcatSeparator);
FormData fdConcatSeparator = new FormData();
fdConcatSeparator.left = new FormAttachment(wConcatErrors, margin);
fdConcatSeparator.right = new FormAttachment(100, 0);
fdConcatSeparator.top = new FormAttachment(wValidateAll, margin);
wConcatSeparator.setLayoutData(fdConcatSeparator);
// Create a scrolled composite on the right side...
//
ScrolledComposite wSComp = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
props.setLook(wSComp);
wSComp.setLayout(new FillLayout());
FormData fdComp = new FormData();
fdComp.left = new FormAttachment(middle, 0);
fdComp.top = new FormAttachment(wConcatSeparator, 2 * margin);
fdComp.right = new FormAttachment(100, 0);
fdComp.bottom = new FormAttachment(wOK, -margin * 2);
wSComp.setLayoutData(fdComp);
Composite wComp = new Composite(wSComp, SWT.BORDER);
props.setLook(wComp);
FormLayout compLayout = new FormLayout();
compLayout.marginWidth = 3;
compLayout.marginHeight = 3;
wComp.setLayout(compLayout);
int extra = imageBounds.width;
// Description (list key)
//
wlDescription = new Label(wComp, SWT.RIGHT);
wlDescription.setText(BaseMessages.getString(PKG, "ValidatorDialog.Description.Label"));
props.setLook(wlDescription);
FormData fdlDescription = new FormData();
fdlDescription.left = new FormAttachment(0, 0);
fdlDescription.right = new FormAttachment(middle, -margin);
fdlDescription.top = new FormAttachment(0, 0);
wlDescription.setLayoutData(fdlDescription);
wDescription = new Text(wComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wDescription);
FormData fdDescription = new FormData();
fdDescription.left = new FormAttachment(middle, margin + extra);
fdDescription.right = new FormAttachment(100, 0);
fdDescription.top = new FormAttachment(0, 0);
wDescription.setLayoutData(fdDescription);
wDescription.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
//
if (wValidationsList != null && wValidationsList.getItemCount() > 0 && wValidationsList.getSelection().length == 1) {
int index = wValidationsList.getSelectionIndex();
String description = wValidationsList.getItem(index);
Validation validation = Validation.findValidation(selectionList, description);
String newDescription = wDescription.getText();
validation.setName(newDescription);
wValidationsList.setItem(index, newDescription);
wValidationsList.select(index);
}
}
});
// The name of the field to validate
//
wlFieldName = new Label(wComp, SWT.RIGHT);
wlFieldName.setText(BaseMessages.getString(PKG, "ValidatorDialog.FieldName.Label"));
props.setLook(wlFieldName);
FormData fdlFieldName = new FormData();
fdlFieldName.left = new FormAttachment(0, 0);
fdlFieldName.right = new FormAttachment(middle, -margin);
fdlFieldName.top = new FormAttachment(wDescription, margin);
wlFieldName.setLayoutData(fdlFieldName);
wFieldName = new CCombo(wComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wFieldName);
FormData fdFieldName = new FormData();
fdFieldName.left = new FormAttachment(middle, margin + extra);
fdFieldName.right = new FormAttachment(100, 0);
fdFieldName.top = new FormAttachment(wDescription, margin);
wFieldName.setLayoutData(fdFieldName);
//
try {
inputFields = transMeta.getPrevStepFields(stepMeta);
wFieldName.setItems(inputFields.getFieldNames());
} catch (KettleStepException ex) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "ValidatorDialog.Exception.CantGetFieldsFromPreviousSteps.Title"), BaseMessages.getString(PKG, "ValidatorDialog.Exception.CantGetFieldsFromPreviousSteps.Message"), ex);
}
// ErrorCode
//
wlErrorCode = new Label(wComp, SWT.RIGHT);
wlErrorCode.setText(BaseMessages.getString(PKG, "ValidatorDialog.ErrorCode.Label"));
props.setLook(wlErrorCode);
FormData fdlErrorCode = new FormData();
fdlErrorCode.left = new FormAttachment(0, 0);
fdlErrorCode.right = new FormAttachment(middle, -margin);
fdlErrorCode.top = new FormAttachment(wFieldName, margin);
wlErrorCode.setLayoutData(fdlErrorCode);
wErrorCode = new TextVarWarning(transMeta, wComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wErrorCode);
FormData fdErrorCode = new FormData();
fdErrorCode.left = new FormAttachment(middle, margin);
fdErrorCode.right = new FormAttachment(100, 0);
fdErrorCode.top = new FormAttachment(wFieldName, margin);
wErrorCode.setLayoutData(fdErrorCode);
addSpacesWarning(wErrorCode);
// ErrorDescription
//
wlErrorDescription = new Label(wComp, SWT.RIGHT);
wlErrorDescription.setText(BaseMessages.getString(PKG, "ValidatorDialog.ErrorDescription.Label"));
props.setLook(wlErrorDescription);
FormData fdlErrorDescription = new FormData();
fdlErrorDescription.left = new FormAttachment(0, 0);
fdlErrorDescription.right = new FormAttachment(middle, -margin);
fdlErrorDescription.top = new FormAttachment(wErrorCode, margin);
wlErrorDescription.setLayoutData(fdlErrorDescription);
wErrorDescription = new TextVarWarning(transMeta, wComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wErrorDescription);
FormData fdErrorDescription = new FormData();
fdErrorDescription.left = new FormAttachment(middle, margin);
fdErrorDescription.right = new FormAttachment(100, 0);
fdErrorDescription.top = new FormAttachment(wErrorCode, margin);
wErrorDescription.setLayoutData(fdErrorDescription);
addSpacesWarning(wErrorDescription);
// Data type validations & constants masks...
//
wgType = new Group(wComp, SWT.NONE);
props.setLook(wgType);
wgType.setText(BaseMessages.getString(PKG, "ValidatorDialog.TypeGroup.Label"));
FormLayout typeGroupLayout = new FormLayout();
typeGroupLayout.marginHeight = Const.FORM_MARGIN;
typeGroupLayout.marginWidth = Const.FORM_MARGIN;
wgType.setLayout(typeGroupLayout);
FormData fdType = new FormData();
fdType.left = new FormAttachment(0, 0);
fdType.right = new FormAttachment(100, 0);
fdType.top = new FormAttachment(wErrorDescription, margin * 2);
wgType.setLayoutData(fdType);
// Check for data type correctness?
//
wlDataTypeVerified = new Label(wgType, SWT.RIGHT);
wlDataTypeVerified.setText(BaseMessages.getString(PKG, "ValidatorDialog.DataTypeVerified.Label"));
props.setLook(wlDataTypeVerified);
FormData fdldataTypeVerified = new FormData();
fdldataTypeVerified.left = new FormAttachment(0, 0);
fdldataTypeVerified.right = new FormAttachment(middle, -margin);
fdldataTypeVerified.top = new FormAttachment(0, 0);
wlDataTypeVerified.setLayoutData(fdldataTypeVerified);
wDataTypeVerified = new Button(wgType, SWT.CHECK);
props.setLook(wDataTypeVerified);
FormData fddataTypeVerified = new FormData();
fddataTypeVerified.left = new FormAttachment(middle, margin + extra);
fddataTypeVerified.right = new FormAttachment(100, 0);
fddataTypeVerified.top = new FormAttachment(0, 0);
wDataTypeVerified.setLayoutData(fddataTypeVerified);
// Data type
//
wlDataType = new Label(wgType, SWT.RIGHT);
wlDataType.setText(BaseMessages.getString(PKG, "ValidatorDialog.DataType.Label"));
props.setLook(wlDataType);
FormData fdlDataType = new FormData();
fdlDataType.left = new FormAttachment(0, 0);
fdlDataType.right = new FormAttachment(middle, -margin);
fdlDataType.top = new FormAttachment(wDataTypeVerified, margin);
wlDataType.setLayoutData(fdlDataType);
wDataType = new Combo(wgType, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wDataType.setItems(ValueMetaFactory.getValueMetaNames());
props.setLook(wDataType);
FormData fdDataType = new FormData();
fdDataType.left = new FormAttachment(middle, margin + extra);
fdDataType.right = new FormAttachment(100, 0);
fdDataType.top = new FormAttachment(wDataTypeVerified, margin);
wDataType.setLayoutData(fdDataType);
// Conversion mask
//
wlConversionMask = new Label(wgType, SWT.RIGHT);
wlConversionMask.setText(BaseMessages.getString(PKG, "ValidatorDialog.ConversionMask.Label"));
props.setLook(wlConversionMask);
FormData fdlConversionMask = new FormData();
fdlConversionMask.left = new FormAttachment(0, 0);
fdlConversionMask.right = new FormAttachment(middle, -margin);
fdlConversionMask.top = new FormAttachment(wDataType, margin);
wlConversionMask.setLayoutData(fdlConversionMask);
wConversionMask = new TextVarWarning(transMeta, wgType, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wConversionMask);
FormData fdConversionMask = new FormData();
fdConversionMask.left = new FormAttachment(middle, margin);
fdConversionMask.right = new FormAttachment(100, 0);
fdConversionMask.top = new FormAttachment(wDataType, margin);
wConversionMask.setLayoutData(fdConversionMask);
addSpacesWarning(wConversionMask);
// Decimal Symbol
//
wlDecimalSymbol = new Label(wgType, SWT.RIGHT);
wlDecimalSymbol.setText(BaseMessages.getString(PKG, "ValidatorDialog.DecimalSymbol.Label"));
props.setLook(wlDecimalSymbol);
FormData fdlDecimalSymbol = new FormData();
fdlDecimalSymbol.left = new FormAttachment(0, 0);
fdlDecimalSymbol.right = new FormAttachment(middle, -margin);
fdlDecimalSymbol.top = new FormAttachment(wConversionMask, margin);
wlDecimalSymbol.setLayoutData(fdlDecimalSymbol);
wDecimalSymbol = new TextVarWarning(transMeta, wgType, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wDecimalSymbol);
FormData fdDecimalSymbol = new FormData();
fdDecimalSymbol.left = new FormAttachment(middle, margin);
fdDecimalSymbol.right = new FormAttachment(100, 0);
fdDecimalSymbol.top = new FormAttachment(wConversionMask, margin);
wDecimalSymbol.setLayoutData(fdDecimalSymbol);
addSpacesWarning(wDecimalSymbol);
// Grouping Symbol
//
wlGroupingSymbol = new Label(wgType, SWT.RIGHT);
wlGroupingSymbol.setText(BaseMessages.getString(PKG, "ValidatorDialog.GroupingSymbol.Label"));
props.setLook(wlGroupingSymbol);
FormData fdlGroupingSymbol = new FormData();
fdlGroupingSymbol.left = new FormAttachment(0, 0);
fdlGroupingSymbol.right = new FormAttachment(middle, -margin);
fdlGroupingSymbol.top = new FormAttachment(wDecimalSymbol, margin);
wlGroupingSymbol.setLayoutData(fdlGroupingSymbol);
wGroupingSymbol = new TextVarWarning(transMeta, wgType, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wGroupingSymbol);
FormData fdGroupingSymbol = new FormData();
fdGroupingSymbol.left = new FormAttachment(middle, margin);
fdGroupingSymbol.right = new FormAttachment(100, 0);
fdGroupingSymbol.top = new FormAttachment(wDecimalSymbol, margin);
wGroupingSymbol.setLayoutData(fdGroupingSymbol);
addSpacesWarning(wGroupingSymbol);
// /////////////////////////////////////////////////////////////////////////////////////////////////
//
// The data group...
//
//
wgData = new Group(wComp, SWT.NONE);
props.setLook(wgData);
wgData.setText(BaseMessages.getString(PKG, "ValidatorDialog.DataGroup.Label"));
FormLayout dataGroupLayout = new FormLayout();
dataGroupLayout.marginHeight = Const.FORM_MARGIN;
dataGroupLayout.marginWidth = Const.FORM_MARGIN;
wgData.setLayout(dataGroupLayout);
FormData fdData = new FormData();
fdData.left = new FormAttachment(0, 0);
fdData.right = new FormAttachment(100, 0);
fdData.top = new FormAttachment(wgType, margin);
wgData.setLayoutData(fdData);
// Check for null?
//
wlNullAllowed = new Label(wgData, SWT.RIGHT);
wlNullAllowed.setText(BaseMessages.getString(PKG, "ValidatorDialog.NullAllowed.Label"));
props.setLook(wlNullAllowed);
FormData fdlNullAllowed = new FormData();
fdlNullAllowed.left = new FormAttachment(0, 0);
fdlNullAllowed.right = new FormAttachment(middle, -margin);
fdlNullAllowed.top = new FormAttachment(0, 0);
wlNullAllowed.setLayoutData(fdlNullAllowed);
wNullAllowed = new Button(wgData, SWT.CHECK);
props.setLook(wNullAllowed);
FormData fdNullAllowed = new FormData();
fdNullAllowed.left = new FormAttachment(middle, margin + extra);
fdNullAllowed.right = new FormAttachment(100, 0);
fdNullAllowed.top = new FormAttachment(0, 0);
wNullAllowed.setLayoutData(fdNullAllowed);
// Only null allowed?
//
wlOnlyNullAllowed = new Label(wgData, SWT.RIGHT);
wlOnlyNullAllowed.setText(BaseMessages.getString(PKG, "ValidatorDialog.OnlyNullAllowed.Label"));
props.setLook(wlOnlyNullAllowed);
FormData fdlOnlyNullAllowed = new FormData();
fdlOnlyNullAllowed.left = new FormAttachment(0, 0);
fdlOnlyNullAllowed.right = new FormAttachment(middle, -margin);
fdlOnlyNullAllowed.top = new FormAttachment(wNullAllowed, margin);
wlOnlyNullAllowed.setLayoutData(fdlOnlyNullAllowed);
wOnlyNullAllowed = new Button(wgData, SWT.CHECK);
props.setLook(wOnlyNullAllowed);
FormData fdOnlyNullAllowed = new FormData();
fdOnlyNullAllowed.left = new FormAttachment(middle, margin + extra);
fdOnlyNullAllowed.right = new FormAttachment(100, 0);
fdOnlyNullAllowed.top = new FormAttachment(wNullAllowed, margin);
wOnlyNullAllowed.setLayoutData(fdOnlyNullAllowed);
// Only numeric allowed?
//
wlOnlyNumeric = new Label(wgData, SWT.RIGHT);
wlOnlyNumeric.setText(BaseMessages.getString(PKG, "ValidatorDialog.OnlyNumeric.Label"));
props.setLook(wlOnlyNumeric);
FormData fdlOnlyNumeric = new FormData();
fdlOnlyNumeric.left = new FormAttachment(0, 0);
fdlOnlyNumeric.right = new FormAttachment(middle, -margin);
fdlOnlyNumeric.top = new FormAttachment(wOnlyNullAllowed, margin);
wlOnlyNumeric.setLayoutData(fdlOnlyNumeric);
wOnlyNumeric = new Button(wgData, SWT.CHECK);
props.setLook(wOnlyNumeric);
FormData fdOnlyNumeric = new FormData();
fdOnlyNumeric.left = new FormAttachment(middle, margin + extra);
fdOnlyNumeric.right = new FormAttachment(100, 0);
fdOnlyNumeric.top = new FormAttachment(wOnlyNullAllowed, margin);
wOnlyNumeric.setLayoutData(fdOnlyNumeric);
// Maximum length
//
wlMaxLength = new Label(wgData, SWT.RIGHT);
wlMaxLength.setText(BaseMessages.getString(PKG, "ValidatorDialog.MaxLength.Label"));
props.setLook(wlMaxLength);
FormData fdlMaxLength = new FormData();
fdlMaxLength.left = new FormAttachment(0, 0);
fdlMaxLength.right = new FormAttachment(middle, -margin);
fdlMaxLength.top = new FormAttachment(wOnlyNumeric, margin);
wlMaxLength.setLayoutData(fdlMaxLength);
wMaxLength = new TextVarWarning(transMeta, wgData, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wMaxLength);
FormData fdMaxLength = new FormData();
fdMaxLength.left = new FormAttachment(middle, margin);
fdMaxLength.right = new FormAttachment(100, 0);
fdMaxLength.top = new FormAttachment(wOnlyNumeric, margin);
wMaxLength.setLayoutData(fdMaxLength);
addSpacesWarning(wMaxLength);
// Minimum length
//
wlMinLength = new Label(wgData, SWT.RIGHT);
wlMinLength.setText(BaseMessages.getString(PKG, "ValidatorDialog.MinLength.Label"));
props.setLook(wlMinLength);
FormData fdlMinLength = new FormData();
fdlMinLength.left = new FormAttachment(0, 0);
fdlMinLength.right = new FormAttachment(middle, -margin);
fdlMinLength.top = new FormAttachment(wMaxLength, margin);
wlMinLength.setLayoutData(fdlMinLength);
wMinLength = new TextVarWarning(transMeta, wgData, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wMinLength);
FormData fdMinLength = new FormData();
fdMinLength.left = new FormAttachment(middle, margin);
fdMinLength.right = new FormAttachment(100, 0);
fdMinLength.top = new FormAttachment(wMaxLength, margin);
wMinLength.setLayoutData(fdMinLength);
addSpacesWarning(wMinLength);
// Maximum value
//
wlMaxValue = new Label(wgData, SWT.RIGHT);
wlMaxValue.setText(BaseMessages.getString(PKG, "ValidatorDialog.MaxValue.Label"));
props.setLook(wlMaxValue);
FormData fdlMaxValue = new FormData();
fdlMaxValue.left = new FormAttachment(0, 0);
fdlMaxValue.right = new FormAttachment(middle, -margin);
fdlMaxValue.top = new FormAttachment(wMinLength, margin);
wlMaxValue.setLayoutData(fdlMaxValue);
wMaxValue = new TextVarWarning(transMeta, wgData, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wMaxValue);
FormData fdMaxValue = new FormData();
fdMaxValue.left = new FormAttachment(middle, margin);
fdMaxValue.right = new FormAttachment(100, 0);
fdMaxValue.top = new FormAttachment(wMinLength, margin);
wMaxValue.setLayoutData(fdMaxValue);
addSpacesWarning(wMaxValue);
// Minimum value
//
wlMinValue = new Label(wgData, SWT.RIGHT);
wlMinValue.setText(BaseMessages.getString(PKG, "ValidatorDialog.MinValue.Label"));
props.setLook(wlMinValue);
FormData fdlMinValue = new FormData();
fdlMinValue.left = new FormAttachment(0, 0);
fdlMinValue.right = new FormAttachment(middle, -margin);
fdlMinValue.top = new FormAttachment(wMaxValue, margin);
wlMinValue.setLayoutData(fdlMinValue);
wMinValue = new TextVarWarning(transMeta, wgData, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wMinValue);
FormData fdMinValue = new FormData();
fdMinValue.left = new FormAttachment(middle, margin);
fdMinValue.right = new FormAttachment(100, 0);
fdMinValue.top = new FormAttachment(wMaxValue, margin);
wMinValue.setLayoutData(fdMinValue);
addSpacesWarning(wMinValue);
// Expected start string
//
wlStartStringExpected = new Label(wgData, SWT.RIGHT);
wlStartStringExpected.setText(BaseMessages.getString(PKG, "ValidatorDialog.StartStringExpected.Label"));
props.setLook(wlStartStringExpected);
FormData fdlStartStringExpected = new FormData();
fdlStartStringExpected.left = new FormAttachment(0, 0);
fdlStartStringExpected.right = new FormAttachment(middle, -margin);
fdlStartStringExpected.top = new FormAttachment(wMinValue, margin);
wlStartStringExpected.setLayoutData(fdlStartStringExpected);
wStartStringExpected = new TextVarWarning(transMeta, wgData, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wStartStringExpected);
FormData fdStartStringExpected = new FormData();
fdStartStringExpected.left = new FormAttachment(middle, margin);
fdStartStringExpected.right = new FormAttachment(100, 0);
fdStartStringExpected.top = new FormAttachment(wMinValue, margin);
wStartStringExpected.setLayoutData(fdStartStringExpected);
addSpacesWarning(wStartStringExpected);
// Expected End string
//
wlEndStringExpected = new Label(wgData, SWT.RIGHT);
wlEndStringExpected.setText(BaseMessages.getString(PKG, "ValidatorDialog.EndStringExpected.Label"));
props.setLook(wlEndStringExpected);
FormData fdlEndStringExpected = new FormData();
fdlEndStringExpected.left = new FormAttachment(0, 0);
fdlEndStringExpected.right = new FormAttachment(middle, -margin);
fdlEndStringExpected.top = new FormAttachment(wStartStringExpected, margin);
wlEndStringExpected.setLayoutData(fdlEndStringExpected);
wEndStringExpected = new TextVarWarning(transMeta, wgData, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wEndStringExpected);
FormData fdEndStringExpected = new FormData();
fdEndStringExpected.left = new FormAttachment(middle, margin);
fdEndStringExpected.right = new FormAttachment(100, 0);
fdEndStringExpected.top = new FormAttachment(wStartStringExpected, margin);
wEndStringExpected.setLayoutData(fdEndStringExpected);
addSpacesWarning(wEndStringExpected);
// Disallowed start string
//
wlStartStringDisallowed = new Label(wgData, SWT.RIGHT);
wlStartStringDisallowed.setText(BaseMessages.getString(PKG, "ValidatorDialog.StartStringDisallowed.Label"));
props.setLook(wlStartStringDisallowed);
FormData fdlStartStringDisallowed = new FormData();
fdlStartStringDisallowed.left = new FormAttachment(0, 0);
fdlStartStringDisallowed.right = new FormAttachment(middle, -margin);
fdlStartStringDisallowed.top = new FormAttachment(wEndStringExpected, margin);
wlStartStringDisallowed.setLayoutData(fdlStartStringDisallowed);
wStartStringDisallowed = new TextVarWarning(transMeta, wgData, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wStartStringDisallowed);
FormData fdStartStringDisallowed = new FormData();
fdStartStringDisallowed.left = new FormAttachment(middle, margin);
fdStartStringDisallowed.right = new FormAttachment(100, 0);
fdStartStringDisallowed.top = new FormAttachment(wEndStringExpected, margin);
wStartStringDisallowed.setLayoutData(fdStartStringDisallowed);
addSpacesWarning(wStartStringDisallowed);
// Disallowed End string
//
wlEndStringDisallowed = new Label(wgData, SWT.RIGHT);
wlEndStringDisallowed.setText(BaseMessages.getString(PKG, "ValidatorDialog.EndStringDisallowed.Label"));
props.setLook(wlEndStringDisallowed);
FormData fdlEndStringDisallowed = new FormData();
fdlEndStringDisallowed.left = new FormAttachment(0, 0);
fdlEndStringDisallowed.right = new FormAttachment(middle, -margin);
fdlEndStringDisallowed.top = new FormAttachment(wStartStringDisallowed, margin);
wlEndStringDisallowed.setLayoutData(fdlEndStringDisallowed);
wEndStringDisallowed = new TextVarWarning(transMeta, wgData, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wEndStringDisallowed);
FormData fdEndStringDisallowed = new FormData();
fdEndStringDisallowed.left = new FormAttachment(middle, margin);
fdEndStringDisallowed.right = new FormAttachment(100, 0);
fdEndStringDisallowed.top = new FormAttachment(wStartStringDisallowed, margin);
wEndStringDisallowed.setLayoutData(fdEndStringDisallowed);
addSpacesWarning(wEndStringDisallowed);
// Expected regular expression
//
wlRegExpExpected = new Label(wgData, SWT.RIGHT);
wlRegExpExpected.setText(BaseMessages.getString(PKG, "ValidatorDialog.RegExpExpected.Label"));
props.setLook(wlRegExpExpected);
FormData fdlRegExpExpected = new FormData();
fdlRegExpExpected.left = new FormAttachment(0, 0);
fdlRegExpExpected.right = new FormAttachment(middle, -margin);
fdlRegExpExpected.top = new FormAttachment(wEndStringDisallowed, margin);
wlRegExpExpected.setLayoutData(fdlRegExpExpected);
wRegExpExpected = new TextVarWarning(transMeta, wgData, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wRegExpExpected);
FormData fdRegExpExpected = new FormData();
fdRegExpExpected.left = new FormAttachment(middle, margin);
fdRegExpExpected.right = new FormAttachment(100, 0);
fdRegExpExpected.top = new FormAttachment(wEndStringDisallowed, margin);
wRegExpExpected.setLayoutData(fdRegExpExpected);
addSpacesWarning(wRegExpExpected);
// Disallowed regular expression
//
wlRegExpDisallowed = new Label(wgData, SWT.RIGHT);
wlRegExpDisallowed.setText(BaseMessages.getString(PKG, "ValidatorDialog.RegExpDisallowed.Label"));
props.setLook(wlRegExpDisallowed);
FormData fdlRegExpDisallowed = new FormData();
fdlRegExpDisallowed.left = new FormAttachment(0, 0);
fdlRegExpDisallowed.right = new FormAttachment(middle, -margin);
fdlRegExpDisallowed.top = new FormAttachment(wRegExpExpected, margin);
wlRegExpDisallowed.setLayoutData(fdlRegExpDisallowed);
wRegExpDisallowed = new TextVarWarning(transMeta, wgData, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wRegExpDisallowed);
FormData fdRegExpDisallowed = new FormData();
fdRegExpDisallowed.left = new FormAttachment(middle, margin);
fdRegExpDisallowed.right = new FormAttachment(100, 0);
fdRegExpDisallowed.top = new FormAttachment(wRegExpExpected, margin);
wRegExpDisallowed.setLayoutData(fdRegExpDisallowed);
addSpacesWarning(wRegExpDisallowed);
// Allowed values: a list box.
//
// Add an entry
//
wbAddAllowed = new Button(wgData, SWT.PUSH);
wbAddAllowed.setText(BaseMessages.getString(PKG, "ValidatorDialog.ButtonAddAllowed.Label"));
FormData fdbAddAllowed = new FormData();
fdbAddAllowed.right = new FormAttachment(100, 0);
fdbAddAllowed.top = new FormAttachment(wRegExpDisallowed, margin);
wbAddAllowed.setLayoutData(fdbAddAllowed);
wbAddAllowed.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
addAllowedValue();
}
});
// Remove an entry
//
wbRemoveAllowed = new Button(wgData, SWT.PUSH);
wbRemoveAllowed.setText(BaseMessages.getString(PKG, "ValidatorDialog.ButtonRemoveAllowed.Label"));
FormData fdbRemoveAllowed = new FormData();
fdbRemoveAllowed.right = new FormAttachment(100, 0);
fdbRemoveAllowed.top = new FormAttachment(wbAddAllowed, margin);
wbRemoveAllowed.setLayoutData(fdbRemoveAllowed);
wbRemoveAllowed.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
removeAllowedValue();
}
});
wlAllowedValues = new Label(wgData, SWT.RIGHT);
wlAllowedValues.setText(BaseMessages.getString(PKG, "ValidatorDialog.AllowedValues.Label"));
props.setLook(wlAllowedValues);
FormData fdlAllowedValues = new FormData();
fdlAllowedValues.left = new FormAttachment(0, 0);
fdlAllowedValues.right = new FormAttachment(middle, -margin);
fdlAllowedValues.top = new FormAttachment(wRegExpDisallowed, margin);
wlAllowedValues.setLayoutData(fdlAllowedValues);
wAllowedValues = new List(wgData, SWT.MULTI | SWT.LEFT | SWT.BORDER);
props.setLook(wAllowedValues);
FormData fdAllowedValues = new FormData();
fdAllowedValues.left = new FormAttachment(middle, margin + extra);
fdAllowedValues.right = new FormAttachment(wbRemoveAllowed, -20);
fdAllowedValues.top = new FormAttachment(wRegExpDisallowed, margin);
fdAllowedValues.bottom = new FormAttachment(wRegExpDisallowed, 150);
wAllowedValues.setLayoutData(fdAllowedValues);
// Source allowed values from another step?
//
wlSourceValues = new Label(wgData, SWT.RIGHT);
wlSourceValues.setText(BaseMessages.getString(PKG, "ValidatorDialog.SourceValues.Label"));
props.setLook(wlSourceValues);
FormData fdlSourceValues = new FormData();
fdlSourceValues.left = new FormAttachment(0, 0);
fdlSourceValues.right = new FormAttachment(middle, -margin);
fdlSourceValues.top = new FormAttachment(wAllowedValues, margin);
wlSourceValues.setLayoutData(fdlSourceValues);
wSourceValues = new Button(wgData, SWT.CHECK);
props.setLook(wSourceValues);
FormData fdSourceValues = new FormData();
fdSourceValues.left = new FormAttachment(middle, margin + extra);
fdSourceValues.right = new FormAttachment(100, 0);
fdSourceValues.top = new FormAttachment(wAllowedValues, margin);
wSourceValues.setLayoutData(fdSourceValues);
wSourceValues.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
enableFields();
}
});
// Source allowed values : source step
//
wlSourceStep = new Label(wgData, SWT.RIGHT);
wlSourceStep.setText(BaseMessages.getString(PKG, "ValidatorDialog.SourceStep.Label"));
props.setLook(wlSourceStep);
FormData fdlSourceStep = new FormData();
fdlSourceStep.left = new FormAttachment(0, margin);
fdlSourceStep.right = new FormAttachment(middle, -margin);
fdlSourceStep.top = new FormAttachment(wSourceValues, margin);
wlSourceStep.setLayoutData(fdlSourceStep);
wSourceStep = new Combo(wgData, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wSourceStep);
FormData fdSourceStep = new FormData();
fdSourceStep.left = new FormAttachment(middle, margin + extra);
fdSourceStep.right = new FormAttachment(100, 0);
fdSourceStep.top = new FormAttachment(wSourceValues, margin);
wSourceStep.setLayoutData(fdSourceStep);
wSourceStep.addFocusListener(new FocusAdapter() {
public void focusGained(org.eclipse.swt.events.FocusEvent e) {
getSteps();
}
});
wSourceStep.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
getSteps();
}
});
// Source allowed values : source field
//
wlSourceField = new Label(wgData, SWT.RIGHT);
wlSourceField.setText(BaseMessages.getString(PKG, "ValidatorDialog.SourceField.Label"));
props.setLook(wlSourceField);
FormData fdlSourceField = new FormData();
fdlSourceField.left = new FormAttachment(0, margin);
fdlSourceField.right = new FormAttachment(middle, -margin);
fdlSourceField.top = new FormAttachment(wSourceStep, margin);
wlSourceField.setLayoutData(fdlSourceField);
wSourceField = new Combo(wgData, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wSourceField);
FormData fdSourceField = new FormData();
fdSourceField.left = new FormAttachment(middle, margin + extra);
fdSourceField.right = new FormAttachment(100, 0);
fdSourceField.top = new FormAttachment(wSourceStep, margin);
wSourceField.setLayoutData(fdSourceField);
wSourceField.addFocusListener(new FocusAdapter() {
public void focusGained(org.eclipse.swt.events.FocusEvent e) {
getFields();
}
});
wSourceField.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
getFields();
}
});
wComp.layout();
wComp.pack();
Rectangle bounds = wComp.getBounds();
wSComp.setContent(wComp);
wSComp.setExpandHorizontal(true);
wSComp.setExpandVertical(true);
wSComp.setMinWidth(bounds.width);
wSComp.setMinHeight(bounds.height);
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wOK.addListener(SWT.Selection, lsOK);
wClear.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
// Clear the validation rules for a certain field...
//
int index = wValidationsList.getSelectionIndex();
if (index >= 0) {
selectionList.remove(index);
selectedField = null;
wValidationsList.remove(index);
enableFields();
}
}
});
wNew.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
// Create a new validation rule page ...
//
EnterStringDialog enterStringDialog = new EnterStringDialog(shell, "", BaseMessages.getString(PKG, "ValidatorDialog.EnterValidationRuleName.Title"), BaseMessages.getString(PKG, "ValidatorDialog.EnterValidationRuleName.Message"));
String description = enterStringDialog.open();
if (description != null) {
if (Validation.findValidation(selectionList, description) != null) {
MessageBox messageBox = new MessageBox(shell, SWT.ICON_ERROR);
// CHECKSTYLE:LineLength:OFF
messageBox.setText(BaseMessages.getString(PKG, "ValidatorDialog.ValidationRuleNameAlreadyExists.Title"));
messageBox.setMessage(BaseMessages.getString(PKG, "ValidatorDialog.ValidationRuleNameAlreadyExists.Message"));
messageBox.open();
return;
}
saveChanges();
Validation validation = new Validation();
validation.setName(description);
selectionList.add(validation);
selectedField = validation;
refreshValidationsList();
wValidationsList.select(selectionList.size() - 1);
getValidatorFieldData(validation);
}
}
});
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wConversionMask.addSelectionListener(lsDef);
wGroupingSymbol.addSelectionListener(lsDef);
wDecimalSymbol.addSelectionListener(lsDef);
wMaxLength.addSelectionListener(lsDef);
wMinLength.addSelectionListener(lsDef);
wMaxValue.addSelectionListener(lsDef);
wMinValue.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
// Set the shell size, based upon previous time...
setSize();
getData();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.
the class ParGzipCsvInputDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
props.setLook(shell);
setShellImage(shell, inputMeta);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
inputMeta.setChanged();
}
};
changed = inputMeta.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Step name line
//
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.Stepname.Label"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
Control lastControl = wStepname;
// See if the step receives input. If so, we don't ask for the filename, but for the filename field.
//
isReceivingInput = transMeta.findNrPrevSteps(stepMeta) > 0;
if (isReceivingInput) {
RowMetaInterface previousFields;
try {
previousFields = transMeta.getPrevStepFields(stepMeta);
} catch (KettleStepException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "ParGzipCsvInputDialog.ErrorDialog.UnableToGetInputFields.Title"), BaseMessages.getString(PKG, "ParGzipCsvInputDialog.ErrorDialog.UnableToGetInputFields.Message"), e);
previousFields = new RowMeta();
}
// The filename field ...
//
Label wlFilename = new Label(shell, SWT.RIGHT);
wlFilename.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.FilenameField.Label"));
props.setLook(wlFilename);
FormData fdlFilename = new FormData();
fdlFilename.top = new FormAttachment(lastControl, margin);
fdlFilename.left = new FormAttachment(0, 0);
fdlFilename.right = new FormAttachment(middle, -margin);
wlFilename.setLayoutData(fdlFilename);
wFilenameField = new CCombo(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wFilenameField.setItems(previousFields.getFieldNames());
props.setLook(wFilenameField);
wFilenameField.addModifyListener(lsMod);
FormData fdFilename = new FormData();
fdFilename.top = new FormAttachment(lastControl, margin);
fdFilename.left = new FormAttachment(middle, 0);
fdFilename.right = new FormAttachment(100, 0);
wFilenameField.setLayoutData(fdFilename);
lastControl = wFilenameField;
// Checkbox to include the filename in the output...
//
Label wlIncludeFilename = new Label(shell, SWT.RIGHT);
wlIncludeFilename.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.IncludeFilenameField.Label"));
props.setLook(wlIncludeFilename);
FormData fdlIncludeFilename = new FormData();
fdlIncludeFilename.top = new FormAttachment(lastControl, margin);
fdlIncludeFilename.left = new FormAttachment(0, 0);
fdlIncludeFilename.right = new FormAttachment(middle, -margin);
wlIncludeFilename.setLayoutData(fdlIncludeFilename);
wIncludeFilename = new Button(shell, SWT.CHECK);
props.setLook(wIncludeFilename);
wFilenameField.addModifyListener(lsMod);
FormData fdIncludeFilename = new FormData();
fdIncludeFilename.top = new FormAttachment(lastControl, margin);
fdIncludeFilename.left = new FormAttachment(middle, 0);
fdIncludeFilename.right = new FormAttachment(100, 0);
wIncludeFilename.setLayoutData(fdIncludeFilename);
lastControl = wIncludeFilename;
} else {
// Filename...
//
// The filename browse button
//
wbbFilename = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbbFilename);
wbbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
wbbFilename.setToolTipText(BaseMessages.getString(PKG, "System.Tooltip.BrowseForFileOrDirAndAdd"));
FormData fdbFilename = new FormData();
fdbFilename.top = new FormAttachment(lastControl, margin);
fdbFilename.right = new FormAttachment(100, 0);
wbbFilename.setLayoutData(fdbFilename);
// The field itself...
//
Label wlFilename = new Label(shell, SWT.RIGHT);
wlFilename.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.Filename.Label"));
props.setLook(wlFilename);
FormData fdlFilename = new FormData();
fdlFilename.top = new FormAttachment(lastControl, margin);
fdlFilename.left = new FormAttachment(0, 0);
fdlFilename.right = new FormAttachment(middle, -margin);
wlFilename.setLayoutData(fdlFilename);
wFilename = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wFilename);
wFilename.addModifyListener(lsMod);
FormData fdFilename = new FormData();
fdFilename.top = new FormAttachment(lastControl, margin);
fdFilename.left = new FormAttachment(middle, 0);
fdFilename.right = new FormAttachment(wbbFilename, -margin);
wFilename.setLayoutData(fdFilename);
lastControl = wFilename;
}
// delimiter
Label wlDelimiter = new Label(shell, SWT.RIGHT);
wlDelimiter.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.Delimiter.Label"));
props.setLook(wlDelimiter);
FormData fdlDelimiter = new FormData();
fdlDelimiter.top = new FormAttachment(lastControl, margin);
fdlDelimiter.left = new FormAttachment(0, 0);
fdlDelimiter.right = new FormAttachment(middle, -margin);
wlDelimiter.setLayoutData(fdlDelimiter);
wbDelimiter = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbDelimiter);
wbDelimiter.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.Delimiter.Button"));
FormData fdbDelimiter = new FormData();
fdbDelimiter.top = new FormAttachment(lastControl, margin);
fdbDelimiter.right = new FormAttachment(100, 0);
wbDelimiter.setLayoutData(fdbDelimiter);
wDelimiter = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wDelimiter);
wDelimiter.addModifyListener(lsMod);
FormData fdDelimiter = new FormData();
fdDelimiter.top = new FormAttachment(lastControl, margin);
fdDelimiter.left = new FormAttachment(middle, 0);
fdDelimiter.right = new FormAttachment(wbDelimiter, -margin);
wDelimiter.setLayoutData(fdDelimiter);
lastControl = wDelimiter;
// enclosure
Label wlEnclosure = new Label(shell, SWT.RIGHT);
wlEnclosure.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.Enclosure.Label"));
props.setLook(wlEnclosure);
FormData fdlEnclosure = new FormData();
fdlEnclosure.top = new FormAttachment(lastControl, margin);
fdlEnclosure.left = new FormAttachment(0, 0);
fdlEnclosure.right = new FormAttachment(middle, -margin);
wlEnclosure.setLayoutData(fdlEnclosure);
wEnclosure = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wEnclosure);
wEnclosure.addModifyListener(lsMod);
FormData fdEnclosure = new FormData();
fdEnclosure.top = new FormAttachment(lastControl, margin);
fdEnclosure.left = new FormAttachment(middle, 0);
fdEnclosure.right = new FormAttachment(100, 0);
wEnclosure.setLayoutData(fdEnclosure);
lastControl = wEnclosure;
// bufferSize
//
Label wlBufferSize = new Label(shell, SWT.RIGHT);
wlBufferSize.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.BufferSize.Label"));
props.setLook(wlBufferSize);
FormData fdlBufferSize = new FormData();
fdlBufferSize.top = new FormAttachment(lastControl, margin);
fdlBufferSize.left = new FormAttachment(0, 0);
fdlBufferSize.right = new FormAttachment(middle, -margin);
wlBufferSize.setLayoutData(fdlBufferSize);
wBufferSize = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wBufferSize);
wBufferSize.addModifyListener(lsMod);
FormData fdBufferSize = new FormData();
fdBufferSize.top = new FormAttachment(lastControl, margin);
fdBufferSize.left = new FormAttachment(middle, 0);
fdBufferSize.right = new FormAttachment(100, 0);
wBufferSize.setLayoutData(fdBufferSize);
lastControl = wBufferSize;
// performingLazyConversion?
//
Label wlLazyConversion = new Label(shell, SWT.RIGHT);
wlLazyConversion.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.LazyConversion.Label"));
props.setLook(wlLazyConversion);
FormData fdlLazyConversion = new FormData();
fdlLazyConversion.top = new FormAttachment(lastControl, margin);
fdlLazyConversion.left = new FormAttachment(0, 0);
fdlLazyConversion.right = new FormAttachment(middle, -margin);
wlLazyConversion.setLayoutData(fdlLazyConversion);
wLazyConversion = new Button(shell, SWT.CHECK);
props.setLook(wLazyConversion);
FormData fdLazyConversion = new FormData();
fdLazyConversion.top = new FormAttachment(lastControl, margin);
fdLazyConversion.left = new FormAttachment(middle, 0);
fdLazyConversion.right = new FormAttachment(100, 0);
wLazyConversion.setLayoutData(fdLazyConversion);
lastControl = wLazyConversion;
// header row?
//
Label wlHeaderPresent = new Label(shell, SWT.RIGHT);
wlHeaderPresent.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.HeaderPresent.Label"));
props.setLook(wlHeaderPresent);
FormData fdlHeaderPresent = new FormData();
fdlHeaderPresent.top = new FormAttachment(lastControl, margin);
fdlHeaderPresent.left = new FormAttachment(0, 0);
fdlHeaderPresent.right = new FormAttachment(middle, -margin);
wlHeaderPresent.setLayoutData(fdlHeaderPresent);
wHeaderPresent = new Button(shell, SWT.CHECK);
props.setLook(wHeaderPresent);
FormData fdHeaderPresent = new FormData();
fdHeaderPresent.top = new FormAttachment(lastControl, margin);
fdHeaderPresent.left = new FormAttachment(middle, 0);
fdHeaderPresent.right = new FormAttachment(100, 0);
wHeaderPresent.setLayoutData(fdHeaderPresent);
lastControl = wHeaderPresent;
wlAddResult = new Label(shell, SWT.RIGHT);
wlAddResult.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.AddResult.Label"));
props.setLook(wlAddResult);
fdlAddResult = new FormData();
fdlAddResult.left = new FormAttachment(0, 0);
fdlAddResult.top = new FormAttachment(wHeaderPresent, margin);
fdlAddResult.right = new FormAttachment(middle, -margin);
wlAddResult.setLayoutData(fdlAddResult);
wAddResult = new Button(shell, SWT.CHECK);
props.setLook(wAddResult);
wAddResult.setToolTipText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.AddResult.Tooltip"));
fdAddResult = new FormData();
fdAddResult.left = new FormAttachment(middle, 0);
fdAddResult.top = new FormAttachment(wHeaderPresent, margin);
wAddResult.setLayoutData(fdAddResult);
lastControl = wAddResult;
// The field itself...
//
Label wlRowNumField = new Label(shell, SWT.RIGHT);
wlRowNumField.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.RowNumField.Label"));
props.setLook(wlRowNumField);
FormData fdlRowNumField = new FormData();
fdlRowNumField.top = new FormAttachment(lastControl, margin);
fdlRowNumField.left = new FormAttachment(0, 0);
fdlRowNumField.right = new FormAttachment(middle, -margin);
wlRowNumField.setLayoutData(fdlRowNumField);
wRowNumField = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wRowNumField);
wRowNumField.addModifyListener(lsMod);
FormData fdRowNumField = new FormData();
fdRowNumField.top = new FormAttachment(lastControl, margin);
fdRowNumField.left = new FormAttachment(middle, 0);
fdRowNumField.right = new FormAttachment(100, 0);
wRowNumField.setLayoutData(fdRowNumField);
lastControl = wRowNumField;
// running in parallel?
//
Label wlRunningInParallel = new Label(shell, SWT.RIGHT);
wlRunningInParallel.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.RunningInParallel.Label"));
props.setLook(wlRunningInParallel);
FormData fdlRunningInParallel = new FormData();
fdlRunningInParallel.top = new FormAttachment(lastControl, margin);
fdlRunningInParallel.left = new FormAttachment(0, 0);
fdlRunningInParallel.right = new FormAttachment(middle, -margin);
wlRunningInParallel.setLayoutData(fdlRunningInParallel);
wRunningInParallel = new Button(shell, SWT.CHECK);
props.setLook(wRunningInParallel);
FormData fdRunningInParallel = new FormData();
fdRunningInParallel.top = new FormAttachment(lastControl, margin);
fdRunningInParallel.left = new FormAttachment(middle, 0);
wRunningInParallel.setLayoutData(fdRunningInParallel);
lastControl = wRunningInParallel;
// Encoding
Label wlEncoding = new Label(shell, SWT.RIGHT);
wlEncoding.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.Encoding.Label"));
props.setLook(wlEncoding);
FormData fdlEncoding = new FormData();
fdlEncoding.top = new FormAttachment(lastControl, margin);
fdlEncoding.left = new FormAttachment(0, 0);
fdlEncoding.right = new FormAttachment(middle, -margin);
wlEncoding.setLayoutData(fdlEncoding);
wEncoding = new ComboVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wEncoding);
wEncoding.addModifyListener(lsMod);
FormData fdEncoding = new FormData();
fdEncoding.top = new FormAttachment(lastControl, margin);
fdEncoding.left = new FormAttachment(middle, 0);
fdEncoding.right = new FormAttachment(100, 0);
wEncoding.setLayoutData(fdEncoding);
lastControl = wEncoding;
wEncoding.addFocusListener(new FocusListener() {
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
}
public void focusGained(org.eclipse.swt.events.FocusEvent e) {
Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
shell.setCursor(busy);
setEncodings();
shell.setCursor(null);
busy.dispose();
}
});
// Some buttons first, so that the dialog scales nicely...
//
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"));
wPreview = new Button(shell, SWT.PUSH);
wPreview.setText(BaseMessages.getString(PKG, "System.Button.Preview"));
wPreview.setEnabled(!isReceivingInput);
wGet = new Button(shell, SWT.PUSH);
wGet.setText(BaseMessages.getString(PKG, "System.Button.GetFields"));
wGet.setEnabled(!isReceivingInput);
setButtonPositions(new Button[] { wOK, wPreview, wGet, wCancel }, margin, null);
// Fields
ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.NameColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.TypeColumn.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames(), true), new ColumnInfo(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.FormatColumn.Column"), ColumnInfo.COLUMN_TYPE_FORMAT, 2), new ColumnInfo(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.LengthColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.PrecisionColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.CurrencyColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.DecimalColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.GroupColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.TrimTypeColumn.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaString.trimTypeDesc) };
colinf[2].setComboValuesSelectionListener(new ComboValuesSelectionListener() {
public String[] getComboValues(TableItem tableItem, int rowNr, int colNr) {
String[] comboValues = new String[] {};
int type = ValueMetaFactory.getIdForValueMeta(tableItem.getText(colNr - 1));
switch(type) {
case ValueMetaInterface.TYPE_DATE:
comboValues = Const.getDateFormats();
break;
case ValueMetaInterface.TYPE_INTEGER:
case ValueMetaInterface.TYPE_BIGNUMBER:
case ValueMetaInterface.TYPE_NUMBER:
comboValues = Const.getNumberFormats();
break;
default:
break;
}
return comboValues;
}
});
wFields = new TableView(transMeta, shell, SWT.FULL_SELECTION | SWT.MULTI, colinf, 1, lsMod, props);
FormData fdFields = new FormData();
fdFields.top = new FormAttachment(lastControl, margin * 2);
fdFields.bottom = new FormAttachment(wOK, -margin * 2);
fdFields.left = new FormAttachment(0, 0);
fdFields.right = new FormAttachment(100, 0);
wFields.setLayoutData(fdFields);
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsPreview = new Listener() {
public void handleEvent(Event e) {
preview();
}
};
lsGet = new Listener() {
public void handleEvent(Event e) {
getCSV();
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wOK.addListener(SWT.Selection, lsOK);
wPreview.addListener(SWT.Selection, lsPreview);
wGet.addListener(SWT.Selection, lsGet);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
if (wFilename != null) {
wFilename.addSelectionListener(lsDef);
}
if (wFilenameField != null) {
wFilenameField.addSelectionListener(lsDef);
}
wDelimiter.addSelectionListener(lsDef);
wEnclosure.addSelectionListener(lsDef);
wBufferSize.addSelectionListener(lsDef);
wRowNumField.addSelectionListener(lsDef);
// Allow the insertion of tabs as separator...
wbDelimiter.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent se) {
Text t = wDelimiter.getTextWidget();
if (t != null) {
t.insert("\t");
}
}
});
if (wbbFilename != null) {
// Listen to the browse button next to the file name
wbbFilename.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
dialog.setFilterExtensions(new String[] { "*.txt;*.csv", "*.csv", "*.txt", "*" });
if (wFilename.getText() != null) {
String fname = transMeta.environmentSubstitute(wFilename.getText());
dialog.setFileName(fname);
}
dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "System.FileType.CSVFiles") + ", " + BaseMessages.getString(PKG, "System.FileType.TextFiles"), BaseMessages.getString(PKG, "System.FileType.CSVFiles"), BaseMessages.getString(PKG, "System.FileType.TextFiles"), BaseMessages.getString(PKG, "System.FileType.AllFiles") });
if (dialog.open() != null) {
String str = dialog.getFilterPath() + System.getProperty("file.separator") + dialog.getFileName();
wFilename.setText(str);
}
}
});
}
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
// Set the shell size, based upon previous time...
setSize();
getData();
inputMeta.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.
the class SpoonJobDelegate method ripDB.
public JobMeta ripDB(final List<DatabaseMeta> databases, final String jobname, final RepositoryDirectoryInterface repdir, final String directory, final DatabaseMeta sourceDbInfo, final DatabaseMeta targetDbInfo, final String[] tables) {
//
// Create a new job...
//
final JobMeta jobMeta = new JobMeta();
jobMeta.setDatabases(databases);
jobMeta.setFilename(null);
jobMeta.setName(jobname);
if (spoon.getRepository() != null) {
jobMeta.setRepositoryDirectory(repdir);
} else {
jobMeta.setFilename(Const.createFilename(directory, jobname, "." + Const.STRING_JOB_DEFAULT_EXT));
}
spoon.refreshTree();
spoon.refreshGraph();
final Point location = new Point(50, 50);
// The start entry...
final JobEntryCopy start = JobMeta.createStartEntry();
start.setLocation(new Point(location.x, location.y));
start.setDrawn();
jobMeta.addJobEntry(start);
// final Thread parentThread = Thread.currentThread();
// Create a dialog with a progress indicator!
IRunnableWithProgress op = monitor -> {
try {
// This is running in a new process: copy some KettleVariables
// info
// LocalVariables.getInstance().createKettleVariables(Thread.currentThread().getName(),
// parentThread.getName(), true);
monitor.beginTask(BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.BuildingNewJob"), tables.length);
monitor.worked(0);
JobEntryCopy previous = start;
// Loop over the table-names...
for (int i = 0; i < tables.length && !monitor.isCanceled(); i++) {
monitor.setTaskName(BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.ProcessingTable") + tables[i] + "]...");
//
// Create the new transformation...
//
String transname = BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.Transname1") + sourceDbInfo + "].[" + tables[i] + BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.Transname2") + targetDbInfo + "]";
TransMeta transMeta = new TransMeta();
if (repdir != null) {
transMeta.setRepositoryDirectory(repdir);
} else {
transMeta.setFilename(Const.createFilename(directory, transname, "." + Const.STRING_TRANS_DEFAULT_EXT));
}
// Add the source & target db
transMeta.addDatabase(sourceDbInfo);
transMeta.addDatabase(targetDbInfo);
//
// Add a note
//
String note = BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.Note1") + tables[i] + BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.Note2") + sourceDbInfo + "]" + Const.CR;
note += BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.Note3") + tables[i] + BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.Note4") + targetDbInfo + "]";
NotePadMeta ni = new NotePadMeta(note, 150, 10, -1, -1);
transMeta.addNote(ni);
//
// Add the TableInputMeta step...
//
String fromstepname = BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.FromStep.Name") + tables[i] + "]";
TableInputMeta tii = new TableInputMeta();
tii.setDefault();
tii.setDatabaseMeta(sourceDbInfo);
// It's already quoted!
tii.setSQL("SELECT * FROM " + tables[i]);
String fromstepid = PluginRegistry.getInstance().getPluginId(StepPluginType.class, tii);
StepMeta fromstep = new StepMeta(fromstepid, fromstepname, tii);
fromstep.setLocation(150, 100);
fromstep.setDraw(true);
fromstep.setDescription(BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.FromStep.Description") + tables[i] + BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.FromStep.Description2") + sourceDbInfo + "]");
transMeta.addStep(fromstep);
//
// Add the TableOutputMeta step...
//
String tostepname = BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.ToStep.Name") + tables[i] + "]";
TableOutputMeta toi = new TableOutputMeta();
toi.setDatabaseMeta(targetDbInfo);
toi.setTableName(tables[i]);
toi.setCommitSize(100);
toi.setTruncateTable(true);
String tostepid = PluginRegistry.getInstance().getPluginId(StepPluginType.class, toi);
StepMeta tostep = new StepMeta(tostepid, tostepname, toi);
tostep.setLocation(500, 100);
tostep.setDraw(true);
tostep.setDescription(BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.ToStep.Description1") + tables[i] + BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.ToStep.Description2") + targetDbInfo + "]");
transMeta.addStep(tostep);
//
// Add a hop between the two steps...
//
TransHopMeta hi = new TransHopMeta(fromstep, tostep);
transMeta.addTransHop(hi);
//
// Now we generate the SQL needed to run for this
// transformation.
//
// First set the limit to 1 to speed things up!
String tmpSql = tii.getSQL();
tii.setSQL(tii.getSQL() + sourceDbInfo.getLimitClause(1));
String sql;
try {
sql = transMeta.getSQLStatementsString();
} catch (KettleStepException kse) {
throw new InvocationTargetException(kse, BaseMessages.getString(PKG, "Spoon.RipDB.Exception.ErrorGettingSQLFromTransformation") + transMeta + "] : " + kse.getMessage());
}
// remove the limit
tii.setSQL(tmpSql);
//
// Now, save the transformation...
//
boolean ok;
if (spoon.getRepository() != null) {
ok = spoon.saveToRepository(transMeta, false);
} else {
ok = spoon.saveToFile(transMeta);
}
if (!ok) {
throw new InvocationTargetException(new Exception(BaseMessages.getString(PKG, "Spoon.RipDB.Exception.UnableToSaveTransformationToRepository")), BaseMessages.getString(PKG, "Spoon.RipDB.Exception.UnableToSaveTransformationToRepository"));
}
// We can now continue with the population of the job...
// //////////////////////////////////////////////////////////////////////
location.x = 250;
if (i > 0) {
location.y += 100;
}
//
if (!Utils.isEmpty(sql)) {
String jesqlname = BaseMessages.getString(PKG, "Spoon.RipDB.JobEntrySQL.Name") + tables[i] + "]";
JobEntrySQL jesql = new JobEntrySQL(jesqlname);
jesql.setDatabase(targetDbInfo);
jesql.setSQL(sql);
jesql.setDescription(BaseMessages.getString(PKG, "Spoon.RipDB.JobEntrySQL.Description") + targetDbInfo + "].[" + tables[i] + "]");
JobEntryCopy jecsql = new JobEntryCopy();
jecsql.setEntry(jesql);
jecsql.setLocation(new Point(location.x, location.y));
jecsql.setDrawn();
jobMeta.addJobEntry(jecsql);
// Add the hop too...
JobHopMeta jhi = new JobHopMeta(previous, jecsql);
jobMeta.addJobHop(jhi);
previous = jecsql;
}
//
// Add the jobentry for the transformation too...
//
String jetransname = BaseMessages.getString(PKG, "Spoon.RipDB.JobEntryTrans.Name") + tables[i] + "]";
JobEntryTrans jetrans = new JobEntryTrans(jetransname);
jetrans.setTransname(transMeta.getName());
if (spoon.getRepository() != null) {
jetrans.setSpecificationMethod(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
jetrans.setDirectory(transMeta.getRepositoryDirectory().getPath());
} else {
jetrans.setSpecificationMethod(ObjectLocationSpecificationMethod.FILENAME);
jetrans.setFileName(Const.createFilename("${" + Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY + "}", transMeta.getName(), "." + Const.STRING_TRANS_DEFAULT_EXT));
}
JobEntryCopy jectrans = new JobEntryCopy(jetrans);
jectrans.setDescription(BaseMessages.getString(PKG, "Spoon.RipDB.JobEntryTrans.Description1") + Const.CR + BaseMessages.getString(PKG, "Spoon.RipDB.JobEntryTrans.Description2") + sourceDbInfo + "].[" + tables[i] + "]" + Const.CR + BaseMessages.getString(PKG, "Spoon.RipDB.JobEntryTrans.Description3") + targetDbInfo + "].[" + tables[i] + "]");
jectrans.setDrawn();
location.x += 400;
jectrans.setLocation(new Point(location.x, location.y));
jobMeta.addJobEntry(jectrans);
// Add a hop between the last 2 job entries.
JobHopMeta jhi2 = new JobHopMeta(previous, jectrans);
jobMeta.addJobHop(jhi2);
previous = jectrans;
monitor.worked(1);
}
monitor.worked(100);
monitor.done();
} catch (Exception e) {
new ErrorDialog(spoon.getShell(), "Error", "An unexpected error occurred!", e);
}
};
try {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(spoon.getShell());
pmd.run(false, true, op);
} catch (InvocationTargetException | InterruptedException e) {
new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "Spoon.ErrorDialog.RipDB.ErrorRippingTheDatabase.Title"), BaseMessages.getString(PKG, "Spoon.ErrorDialog.RipDB.ErrorRippingTheDatabase.Message"), e);
return null;
} finally {
spoon.refreshGraph();
spoon.refreshTree();
}
return jobMeta;
}
use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.
the class RssOutputDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
input.setChanged();
}
};
backupChanged = input.hasChanged();
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "RssOutputDialog.DialogTitle"));
// get previous fields name
getFields();
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "System.Label.StepName"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wStepname.setText(stepname);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
// ////////////////////////
// START OF CHANNEL TAB ///
// ////////////////////////
wChannelTab = new CTabItem(wTabFolder, SWT.NONE);
wChannelTab.setText(BaseMessages.getString(PKG, "RssOutputDialog.ChannelTab.TabTitle"));
wChannelComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wChannelComp);
FormLayout channelLayout = new FormLayout();
channelLayout.marginWidth = 3;
channelLayout.marginHeight = 3;
wChannelComp.setLayout(channelLayout);
// Create Custom RSS?
wlCustomRss = new Label(wChannelComp, SWT.RIGHT);
wlCustomRss.setText(BaseMessages.getString(PKG, "RssOutputDialog.CustomRss.Label"));
props.setLook(wlCustomRss);
fdlCustomRss = new FormData();
fdlCustomRss.left = new FormAttachment(0, 0);
fdlCustomRss.top = new FormAttachment(0, margin);
fdlCustomRss.right = new FormAttachment(middle, -margin);
wlCustomRss.setLayoutData(fdlCustomRss);
wCustomRss = new Button(wChannelComp, SWT.CHECK);
wCustomRss.setToolTipText(BaseMessages.getString(PKG, "RssOutputDialog.CustomRss.Tooltip"));
props.setLook(wCustomRss);
fdCustomRss = new FormData();
fdCustomRss.left = new FormAttachment(middle, 0);
fdCustomRss.top = new FormAttachment(0, margin);
fdCustomRss.right = new FormAttachment(100, 0);
wCustomRss.setLayoutData(fdCustomRss);
wCustomRss.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
setCustomRSS();
input.setChanged();
}
});
// Create Custom RSS?
wlDisplayItem = new Label(wChannelComp, SWT.RIGHT);
wlDisplayItem.setText(BaseMessages.getString(PKG, "RssOutputDialog.DisplayItem.Label"));
props.setLook(wlDisplayItem);
fdlDisplayItem = new FormData();
fdlDisplayItem.left = new FormAttachment(0, 0);
fdlDisplayItem.top = new FormAttachment(wCustomRss, margin);
fdlDisplayItem.right = new FormAttachment(middle, -margin);
wlDisplayItem.setLayoutData(fdlDisplayItem);
wDisplayItem = new Button(wChannelComp, SWT.CHECK);
wDisplayItem.setToolTipText(BaseMessages.getString(PKG, "RssOutputDialog.DisplayItem.Tooltip"));
props.setLook(wDisplayItem);
fdDisplayItem = new FormData();
fdDisplayItem.left = new FormAttachment(middle, 0);
fdDisplayItem.top = new FormAttachment(wCustomRss, margin);
fdDisplayItem.right = new FormAttachment(100, 0);
wDisplayItem.setLayoutData(fdDisplayItem);
wDisplayItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// ChannelGroup grouping?
// ////////////////////////
// START OF ChannelGroup GROUP
//
wChannelGroup = new Group(wChannelComp, SWT.SHADOW_NONE);
props.setLook(wChannelGroup);
wChannelGroup.setText(BaseMessages.getString(PKG, "RssOutputDialog.Group.ChannelGroup.Label"));
FormLayout groupChannelGroupLayout = new FormLayout();
groupChannelGroupLayout.marginWidth = 10;
groupChannelGroupLayout.marginHeight = 10;
wChannelGroup.setLayout(groupChannelGroupLayout);
// RemarqChannel
wlRemarqChannel = new Label(wChannelGroup, SWT.RIGHT);
wlRemarqChannel.setText(BaseMessages.getString(PKG, "RssOutputDialog.RemarqChannel.Label"));
props.setLook(wlRemarqChannel);
fdlRemarqChannel = new FormData();
fdlRemarqChannel.left = new FormAttachment(0, 0);
fdlRemarqChannel.top = new FormAttachment(wDisplayItem, margin);
// fdlRemarq.right = new FormAttachment(middle, -margin);
wlRemarqChannel.setLayoutData(fdlRemarqChannel);
// RemarqMandatory
wlRemarqMandatory = new Label(wChannelGroup, SWT.RIGHT);
wlRemarqMandatory.setText(BaseMessages.getString(PKG, "RssOutputDialog.RemarqMandatory.Label"));
props.setLook(wlRemarqMandatory);
fdlRemarqMandatory = new FormData();
fdlRemarqMandatory.left = new FormAttachment(0, 0);
fdlRemarqMandatory.top = new FormAttachment(wlRemarqChannel, margin);
// fdlRemarq.right = new FormAttachment(middle, -margin);
wlRemarqMandatory.setLayoutData(fdlRemarqMandatory);
// ChannelTitle line
wlChannelTitle = new Label(wChannelGroup, SWT.RIGHT);
wlChannelTitle.setText(BaseMessages.getString(PKG, "RssOutputDialog.ChannelTitle.Label"));
props.setLook(wlChannelTitle);
fdlChannelTitle = new FormData();
fdlChannelTitle.left = new FormAttachment(0, 0);
fdlChannelTitle.top = new FormAttachment(wlRemarqMandatory, 2 * margin);
fdlChannelTitle.right = new FormAttachment(middle, -margin);
wlChannelTitle.setLayoutData(fdlChannelTitle);
wChannelTitle = new CCombo(wChannelGroup, SWT.BORDER | SWT.READ_ONLY);
wChannelTitle.setEditable(true);
wChannelTitle.setItems(fieldNames);
props.setLook(wChannelTitle);
wChannelTitle.addModifyListener(lsMod);
fdChannelTitle = new FormData();
fdChannelTitle.left = new FormAttachment(middle, 0);
fdChannelTitle.top = new FormAttachment(wlRemarqMandatory, 2 * margin);
fdChannelTitle.right = new FormAttachment(100, 0);
wChannelTitle.setLayoutData(fdChannelTitle);
// Channel Description
wlChannelDescription = new Label(wChannelGroup, SWT.RIGHT);
wlChannelDescription.setText(BaseMessages.getString(PKG, "RssOutputDialog.ChannelDescription.Label"));
props.setLook(wlChannelDescription);
fdlChannelDescription = new FormData();
fdlChannelDescription.left = new FormAttachment(0, 0);
fdlChannelDescription.top = new FormAttachment(wChannelTitle, margin);
fdlChannelDescription.right = new FormAttachment(middle, -margin);
wlChannelDescription.setLayoutData(fdlChannelDescription);
wChannelDescription = new CCombo(wChannelGroup, SWT.BORDER | SWT.READ_ONLY);
wChannelDescription.setEditable(true);
wChannelDescription.setItems(fieldNames);
props.setLook(wChannelDescription);
wChannelDescription.addModifyListener(lsMod);
fdChannelDescription = new FormData();
fdChannelDescription.left = new FormAttachment(middle, 0);
fdChannelDescription.top = new FormAttachment(wChannelTitle, margin);
fdChannelDescription.right = new FormAttachment(100, 0);
wChannelDescription.setLayoutData(fdChannelDescription);
// ChannelLink line
wlChannelLink = new Label(wChannelGroup, SWT.RIGHT);
wlChannelLink.setText(BaseMessages.getString(PKG, "RssOutputDialog.ChannelLink.Label"));
props.setLook(wlChannelLink);
fdlChannelLink = new FormData();
fdlChannelLink.left = new FormAttachment(0, 0);
fdlChannelLink.top = new FormAttachment(wChannelDescription, margin);
fdlChannelLink.right = new FormAttachment(middle, -margin);
wlChannelLink.setLayoutData(fdlChannelLink);
wChannelLink = new CCombo(wChannelGroup, SWT.BORDER | SWT.READ_ONLY);
wChannelLink.setEditable(true);
wChannelLink.setItems(fieldNames);
props.setLook(wChannelLink);
wChannelLink.addModifyListener(lsMod);
fdChannelLink = new FormData();
fdChannelLink.left = new FormAttachment(middle, 0);
fdChannelLink.top = new FormAttachment(wChannelDescription, margin);
fdChannelLink.right = new FormAttachment(100, 0);
wChannelLink.setLayoutData(fdChannelLink);
// ChannelPubDate line
wlChannelPubDate = new Label(wChannelGroup, SWT.RIGHT);
wlChannelPubDate.setText(BaseMessages.getString(PKG, "RssOutputDialog.ChannelPubDate.Label"));
props.setLook(wlChannelPubDate);
fdlChannelPubDate = new FormData();
fdlChannelPubDate.left = new FormAttachment(0, 0);
fdlChannelPubDate.top = new FormAttachment(wChannelLink, margin);
fdlChannelPubDate.right = new FormAttachment(middle, -margin);
wlChannelPubDate.setLayoutData(fdlChannelPubDate);
wChannelPubDate = new CCombo(wChannelGroup, SWT.BORDER | SWT.READ_ONLY);
wChannelPubDate.setEditable(true);
wChannelPubDate.setItems(fieldNames);
props.setLook(wChannelPubDate);
wChannelPubDate.addModifyListener(lsMod);
fdChannelPubDate = new FormData();
fdChannelPubDate.left = new FormAttachment(middle, 0);
fdChannelPubDate.top = new FormAttachment(wChannelLink, margin);
fdChannelPubDate.right = new FormAttachment(100, 0);
wChannelPubDate.setLayoutData(fdChannelPubDate);
// Channel Language
wlChannelLanguage = new Label(wChannelGroup, SWT.RIGHT);
wlChannelLanguage.setText(BaseMessages.getString(PKG, "RssOutputDialog.ChannelLanguage.Label"));
props.setLook(wlChannelLanguage);
fdlChannelLanguage = new FormData();
fdlChannelLanguage.left = new FormAttachment(0, 0);
fdlChannelLanguage.top = new FormAttachment(wChannelPubDate, margin);
fdlChannelLanguage.right = new FormAttachment(middle, -margin);
wlChannelLanguage.setLayoutData(fdlChannelLanguage);
wChannelLanguage = new CCombo(wChannelGroup, SWT.BORDER | SWT.READ_ONLY);
wChannelLanguage.setEditable(true);
wChannelLanguage.setItems(fieldNames);
props.setLook(wChannelLanguage);
wChannelLanguage.addModifyListener(lsMod);
fdChannelLanguage = new FormData();
fdChannelLanguage.left = new FormAttachment(middle, 0);
fdChannelLanguage.top = new FormAttachment(wChannelPubDate, margin);
fdChannelLanguage.right = new FormAttachment(100, 0);
wChannelLanguage.setLayoutData(fdChannelLanguage);
// Channel Author
wlChannelAuthor = new Label(wChannelGroup, SWT.RIGHT);
wlChannelAuthor.setText(BaseMessages.getString(PKG, "RssOutputDialog.ChannelAuthor.Label"));
props.setLook(wlChannelAuthor);
fdlChannelAuthor = new FormData();
fdlChannelAuthor.left = new FormAttachment(0, 0);
fdlChannelAuthor.top = new FormAttachment(wChannelLanguage, margin);
fdlChannelAuthor.right = new FormAttachment(middle, -margin);
wlChannelAuthor.setLayoutData(fdlChannelAuthor);
wChannelAuthor = new CCombo(wChannelGroup, SWT.BORDER | SWT.READ_ONLY);
wChannelAuthor.setEditable(true);
wChannelAuthor.setItems(fieldNames);
props.setLook(wChannelAuthor);
wChannelAuthor.addModifyListener(lsMod);
fdChannelAuthor = new FormData();
fdChannelAuthor.left = new FormAttachment(middle, 0);
fdChannelAuthor.top = new FormAttachment(wChannelLanguage, margin);
fdChannelAuthor.right = new FormAttachment(100, 0);
wChannelAuthor.setLayoutData(fdChannelAuthor);
// Channel Copyright
wlChannelCopyright = new Label(wChannelGroup, SWT.RIGHT);
wlChannelCopyright.setText(BaseMessages.getString(PKG, "RssOutputDialog.ChannelCopyright.Label"));
props.setLook(wlChannelCopyright);
fdlChannelCopyright = new FormData();
fdlChannelCopyright.left = new FormAttachment(0, 0);
fdlChannelCopyright.top = new FormAttachment(wChannelAuthor, margin);
fdlChannelCopyright.right = new FormAttachment(middle, -margin);
wlChannelCopyright.setLayoutData(fdlChannelCopyright);
wChannelCopyright = new CCombo(wChannelGroup, SWT.BORDER | SWT.READ_ONLY);
wChannelCopyright.setEditable(true);
wChannelCopyright.setItems(fieldNames);
props.setLook(wChannelCopyright);
wChannelCopyright.addModifyListener(lsMod);
fdChannelCopyright = new FormData();
fdChannelCopyright.left = new FormAttachment(middle, 0);
fdChannelCopyright.top = new FormAttachment(wChannelAuthor, margin);
fdChannelCopyright.right = new FormAttachment(100, 0);
wChannelCopyright.setLayoutData(fdChannelCopyright);
// Add Image ?
wlAddImage = new Label(wChannelGroup, SWT.RIGHT);
wlAddImage.setText(BaseMessages.getString(PKG, "RssOutputDialog.AddImage.Label"));
props.setLook(wlAddImage);
fdlAddImage = new FormData();
fdlAddImage.left = new FormAttachment(0, 0);
fdlAddImage.top = new FormAttachment(wChannelCopyright, margin);
fdlAddImage.right = new FormAttachment(middle, -margin);
wlAddImage.setLayoutData(fdlAddImage);
wAddImage = new Button(wChannelGroup, SWT.CHECK);
wAddImage.setToolTipText(BaseMessages.getString(PKG, "RssOutputDialog.AddImage.Tooltip"));
props.setLook(wAddImage);
fdAddImage = new FormData();
fdAddImage.left = new FormAttachment(middle, 0);
fdAddImage.top = new FormAttachment(wChannelCopyright, margin);
fdAddImage.right = new FormAttachment(100, 0);
wAddImage.setLayoutData(fdAddImage);
wAddImage.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
setImage();
input.setChanged();
}
});
// Channel Image title
wlChannelImageTitle = new Label(wChannelGroup, SWT.RIGHT);
wlChannelImageTitle.setText(BaseMessages.getString(PKG, "RssOutputDialog.ChannelImageTitle.Label"));
props.setLook(wlChannelImageTitle);
fdlChannelImageTitle = new FormData();
fdlChannelImageTitle.left = new FormAttachment(0, 0);
fdlChannelImageTitle.top = new FormAttachment(wAddImage, margin);
fdlChannelImageTitle.right = new FormAttachment(middle, -margin);
wlChannelImageTitle.setLayoutData(fdlChannelImageTitle);
wChannelImageTitle = new CCombo(wChannelGroup, SWT.BORDER | SWT.READ_ONLY);
wChannelImageTitle.setEditable(true);
wChannelImageTitle.setItems(fieldNames);
props.setLook(wChannelImageTitle);
wChannelImageTitle.addModifyListener(lsMod);
fdChannelImageTitle = new FormData();
fdChannelImageTitle.left = new FormAttachment(middle, 0);
fdChannelImageTitle.top = new FormAttachment(wAddImage, margin);
fdChannelImageTitle.right = new FormAttachment(100, 0);
wChannelImageTitle.setLayoutData(fdChannelImageTitle);
// Channel Image Link
wlChannelImageLink = new Label(wChannelGroup, SWT.RIGHT);
wlChannelImageLink.setText(BaseMessages.getString(PKG, "RssOutputDialog.ChannelImageLink.Label"));
props.setLook(wlChannelImageLink);
fdlChannelImageLink = new FormData();
fdlChannelImageLink.left = new FormAttachment(0, 0);
fdlChannelImageLink.top = new FormAttachment(wChannelImageTitle, margin);
fdlChannelImageLink.right = new FormAttachment(middle, -margin);
wlChannelImageLink.setLayoutData(fdlChannelImageLink);
wChannelImageLink = new CCombo(wChannelGroup, SWT.BORDER | SWT.READ_ONLY);
wChannelImageLink.setEditable(true);
wChannelImageLink.setItems(fieldNames);
props.setLook(wChannelImageLink);
wChannelImageLink.addModifyListener(lsMod);
fdChannelImageLink = new FormData();
fdChannelImageLink.left = new FormAttachment(middle, 0);
fdChannelImageLink.top = new FormAttachment(wChannelImageTitle, margin);
fdChannelImageLink.right = new FormAttachment(100, 0);
wChannelImageLink.setLayoutData(fdChannelImageLink);
// Channel Image Url
wlChannelImageUrl = new Label(wChannelGroup, SWT.RIGHT);
wlChannelImageUrl.setText(BaseMessages.getString(PKG, "RssOutputDialog.ChannelImageUrl.Label"));
props.setLook(wlChannelImageUrl);
fdlChannelImageUrl = new FormData();
fdlChannelImageUrl.left = new FormAttachment(0, 0);
fdlChannelImageUrl.top = new FormAttachment(wChannelImageLink, margin);
fdlChannelImageUrl.right = new FormAttachment(middle, -margin);
wlChannelImageUrl.setLayoutData(fdlChannelImageUrl);
wChannelImageUrl = new CCombo(wChannelGroup, SWT.BORDER | SWT.READ_ONLY);
wChannelImageUrl.setEditable(true);
wChannelImageUrl.setItems(fieldNames);
props.setLook(wChannelImageUrl);
wChannelImageUrl.addModifyListener(lsMod);
fdChannelImageUrl = new FormData();
fdChannelImageUrl.left = new FormAttachment(middle, 0);
fdChannelImageUrl.top = new FormAttachment(wChannelImageLink, margin);
fdChannelImageUrl.right = new FormAttachment(100, 0);
wChannelImageUrl.setLayoutData(fdChannelImageUrl);
// Channel Image Description
wlChannelImageDescription = new Label(wChannelGroup, SWT.RIGHT);
wlChannelImageDescription.setText(BaseMessages.getString(PKG, "RssOutputDialog.ChannelImageDescription.Label"));
props.setLook(wlChannelImageDescription);
fdlChannelImageDescription = new FormData();
fdlChannelImageDescription.left = new FormAttachment(0, 0);
fdlChannelImageDescription.top = new FormAttachment(wChannelImageUrl, margin);
fdlChannelImageDescription.right = new FormAttachment(middle, -margin);
wlChannelImageDescription.setLayoutData(fdlChannelImageDescription);
wChannelImageDescription = new CCombo(wChannelGroup, SWT.BORDER | SWT.READ_ONLY);
wChannelImageDescription.setEditable(true);
wChannelImageDescription.setItems(fieldNames);
props.setLook(wChannelImageDescription);
wChannelImageDescription.addModifyListener(lsMod);
fdChannelImageDescription = new FormData();
fdChannelImageDescription.left = new FormAttachment(middle, 0);
fdChannelImageDescription.top = new FormAttachment(wChannelImageUrl, margin);
fdChannelImageDescription.right = new FormAttachment(100, 0);
wChannelImageDescription.setLayoutData(fdChannelImageDescription);
// Encoding
wlEncoding = new Label(wChannelComp, SWT.RIGHT);
wlEncoding.setText(BaseMessages.getString(PKG, "RssOutputDialog.Encoding.Label"));
props.setLook(wlEncoding);
fdlEncoding = new FormData();
fdlEncoding.left = new FormAttachment(0, 0);
fdlEncoding.top = new FormAttachment(wChannelGroup, 2 * margin);
fdlEncoding.right = new FormAttachment(middle, -margin);
wlEncoding.setLayoutData(fdlEncoding);
wEncoding = new CCombo(wChannelComp, SWT.BORDER | SWT.READ_ONLY);
wEncoding.setEditable(true);
props.setLook(wEncoding);
wEncoding.addModifyListener(lsMod);
fdEncoding = new FormData();
fdEncoding.left = new FormAttachment(middle, 0);
fdEncoding.top = new FormAttachment(wChannelGroup, 2 * margin);
fdEncoding.right = new FormAttachment(100, 0);
wEncoding.setLayoutData(fdEncoding);
wEncoding.addFocusListener(new FocusListener() {
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
}
public void focusGained(org.eclipse.swt.events.FocusEvent e) {
Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
shell.setCursor(busy);
setEncodings();
shell.setCursor(null);
busy.dispose();
}
});
// Version
wlVersion = new Label(wChannelComp, SWT.RIGHT);
wlVersion.setText(BaseMessages.getString(PKG, "RssOutputDialog.Version.Label"));
props.setLook(wlVersion);
fdlVersion = new FormData();
fdlVersion.left = new FormAttachment(0, 0);
fdlVersion.top = new FormAttachment(wEncoding, margin);
fdlVersion.right = new FormAttachment(middle, -margin);
wlVersion.setLayoutData(fdlVersion);
wVersion = new CCombo(wChannelComp, SWT.BORDER | SWT.READ_ONLY);
wVersion.setEditable(true);
wVersion.setItems(rss_versions);
props.setLook(wVersion);
wVersion.addModifyListener(lsMod);
fdVersion = new FormData();
fdVersion.left = new FormAttachment(middle, 0);
fdVersion.top = new FormAttachment(wEncoding, margin);
fdVersion.right = new FormAttachment(100, 0);
wVersion.setLayoutData(fdVersion);
fdChannelGroup = new FormData();
fdChannelGroup.left = new FormAttachment(0, margin);
fdChannelGroup.top = new FormAttachment(wDisplayItem, margin);
fdChannelGroup.right = new FormAttachment(100, -margin);
wChannelGroup.setLayoutData(fdChannelGroup);
// ///////////////////////////////////////////////////////////
// / END OF ChannelGroup GROUP
// ///////////////////////////////////////////////////////////
fdChannelComp = new FormData();
fdChannelComp.left = new FormAttachment(0, 0);
fdChannelComp.top = new FormAttachment(0, 0);
fdChannelComp.right = new FormAttachment(100, 0);
fdChannelComp.bottom = new FormAttachment(100, 0);
wChannelComp.setLayoutData(fdChannelComp);
wChannelComp.layout();
wChannelTab.setControl(wChannelComp);
props.setLook(wChannelComp);
// ///////////////////////////////////////////////////////////
// / END OF GENERAL TAB
// ///////////////////////////////////////////////////////////
// ////////////////////////
// START OF GENERAL TAB ///
// ////////////////////////
wGeneralTab = new CTabItem(wTabFolder, SWT.NONE);
wGeneralTab.setText(BaseMessages.getString(PKG, "RssOutputDialog.GeneralTab.TabTitle"));
wGeneralComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wGeneralComp);
FormLayout generalLayout = new FormLayout();
generalLayout.marginWidth = 3;
generalLayout.marginHeight = 3;
wGeneralComp.setLayout(generalLayout);
// Fields grouping?
// ////////////////////////
// START OF Fields GROUP
//
wFields = new Group(wGeneralComp, SWT.SHADOW_NONE);
props.setLook(wFields);
wFields.setText(BaseMessages.getString(PKG, "RssOutputDialog.Group.Fields.Label"));
FormLayout groupFieldsLayout = new FormLayout();
groupFieldsLayout.marginWidth = 10;
groupFieldsLayout.marginHeight = 10;
wFields.setLayout(groupFieldsLayout);
// RemarqItem
wlRemarqItem = new Label(wFields, SWT.RIGHT);
wlRemarqItem.setText(BaseMessages.getString(PKG, "RssOutputDialog.RemarqItem.Label"));
props.setLook(wlRemarqItem);
fdlRemarqItem = new FormData();
fdlRemarqItem.left = new FormAttachment(0, 0);
fdlRemarqItem.top = new FormAttachment(0, margin);
// fdlRemarq.right = new FormAttachment(middle, -margin);
wlRemarqItem.setLayoutData(fdlRemarqItem);
// Item Title
wlItemTitle = new Label(wFields, SWT.RIGHT);
wlItemTitle.setText(BaseMessages.getString(PKG, "RssOutputDialog.ItemTitle.Label"));
props.setLook(wlItemTitle);
fdlItemTitle = new FormData();
fdlItemTitle.left = new FormAttachment(0, 0);
fdlItemTitle.top = new FormAttachment(wlRemarqItem, 3 * margin);
fdlItemTitle.right = new FormAttachment(middle, -margin);
wlItemTitle.setLayoutData(fdlItemTitle);
wItemTitle = new CCombo(wFields, SWT.BORDER | SWT.READ_ONLY);
wItemTitle.setEditable(true);
wItemTitle.setItems(fieldNames);
props.setLook(wItemTitle);
wItemTitle.addModifyListener(lsMod);
fdItemTitle = new FormData();
fdItemTitle.left = new FormAttachment(middle, 0);
fdItemTitle.top = new FormAttachment(wlRemarqItem, 3 * margin);
fdItemTitle.right = new FormAttachment(100, 0);
wItemTitle.setLayoutData(fdItemTitle);
// Item Description
wlItemDescription = new Label(wFields, SWT.RIGHT);
wlItemDescription.setText(BaseMessages.getString(PKG, "RssOutputDialog.ItemDescripion.Label"));
props.setLook(wlItemDescription);
fdlItemDescription = new FormData();
fdlItemDescription.left = new FormAttachment(0, 0);
fdlItemDescription.top = new FormAttachment(wItemTitle, margin);
fdlItemDescription.right = new FormAttachment(middle, -margin);
wlItemDescription.setLayoutData(fdlItemDescription);
wItemDescription = new CCombo(wFields, SWT.BORDER | SWT.READ_ONLY);
wItemDescription.setEditable(true);
wItemDescription.setItems(fieldNames);
props.setLook(wItemDescription);
wItemDescription.addModifyListener(lsMod);
fdItemDescription = new FormData();
fdItemDescription.left = new FormAttachment(middle, 0);
fdItemDescription.top = new FormAttachment(wItemTitle, margin);
fdItemDescription.right = new FormAttachment(100, 0);
wItemDescription.setLayoutData(fdItemDescription);
// Item Link
wlItemLink = new Label(wFields, SWT.RIGHT);
wlItemLink.setText(BaseMessages.getString(PKG, "RssOutputDialog.ItemLink.Label"));
props.setLook(wlItemLink);
fdlItemLink = new FormData();
fdlItemLink.left = new FormAttachment(0, 0);
fdlItemLink.top = new FormAttachment(wItemDescription, margin);
fdlItemLink.right = new FormAttachment(middle, -margin);
wlItemLink.setLayoutData(fdlItemLink);
wItemLink = new CCombo(wFields, SWT.BORDER | SWT.READ_ONLY);
wItemLink.setEditable(true);
wItemLink.setItems(fieldNames);
props.setLook(wItemLink);
wItemLink.addModifyListener(lsMod);
fdItemLink = new FormData();
fdItemLink.left = new FormAttachment(middle, 0);
fdItemLink.top = new FormAttachment(wItemDescription, margin);
fdItemLink.right = new FormAttachment(100, 0);
wItemLink.setLayoutData(fdItemLink);
// Item PubDate
wlItemPubDate = new Label(wFields, SWT.RIGHT);
wlItemPubDate.setText(BaseMessages.getString(PKG, "RssOutputDialog.ItemPubDate.Label"));
props.setLook(wlItemPubDate);
fdlItemPubDate = new FormData();
fdlItemPubDate.left = new FormAttachment(0, 0);
fdlItemPubDate.top = new FormAttachment(wItemLink, margin);
fdlItemPubDate.right = new FormAttachment(middle, -margin);
wlItemPubDate.setLayoutData(fdlItemPubDate);
wItemPubDate = new CCombo(wFields, SWT.BORDER | SWT.READ_ONLY);
wItemPubDate.setEditable(true);
wItemPubDate.setItems(fieldNames);
props.setLook(wItemPubDate);
wItemPubDate.addModifyListener(lsMod);
fdItemPubDate = new FormData();
fdItemPubDate.left = new FormAttachment(middle, 0);
fdItemPubDate.top = new FormAttachment(wItemLink, margin);
fdItemPubDate.right = new FormAttachment(100, 0);
wItemPubDate.setLayoutData(fdItemPubDate);
// Item Author
wlItemAuthor = new Label(wFields, SWT.RIGHT);
wlItemAuthor.setText(BaseMessages.getString(PKG, "RssOutputDialog.ItemAuthor.Label"));
props.setLook(wlItemAuthor);
fdlItemAuthor = new FormData();
fdlItemAuthor.left = new FormAttachment(0, 0);
fdlItemAuthor.top = new FormAttachment(wItemPubDate, margin);
fdlItemAuthor.right = new FormAttachment(middle, -margin);
wlItemAuthor.setLayoutData(fdlItemAuthor);
wItemAuthor = new CCombo(wFields, SWT.BORDER | SWT.READ_ONLY);
wItemAuthor.setEditable(true);
wItemAuthor.setItems(fieldNames);
props.setLook(wItemAuthor);
wItemAuthor.addModifyListener(lsMod);
fdItemAuthor = new FormData();
fdItemAuthor.left = new FormAttachment(middle, 0);
fdItemAuthor.top = new FormAttachment(wItemPubDate, margin);
fdItemAuthor.right = new FormAttachment(100, 0);
wItemAuthor.setLayoutData(fdItemAuthor);
// Add GeoRSS ?
wlAddGeoRSS = new Label(wFields, SWT.RIGHT);
wlAddGeoRSS.setText(BaseMessages.getString(PKG, "RssOutputDialog.AddGeoRSS.Label"));
props.setLook(wlAddGeoRSS);
fdlAddGeoRSS = new FormData();
fdlAddGeoRSS.left = new FormAttachment(0, 0);
fdlAddGeoRSS.top = new FormAttachment(wItemAuthor, margin);
fdlAddGeoRSS.right = new FormAttachment(middle, -margin);
wlAddGeoRSS.setLayoutData(fdlAddGeoRSS);
wAddGeoRSS = new Button(wFields, SWT.CHECK);
wAddGeoRSS.setToolTipText(BaseMessages.getString(PKG, "RssOutputDialog.AddGeoRSS.Tooltip"));
props.setLook(wAddGeoRSS);
fdAddGeoRSS = new FormData();
fdAddGeoRSS.left = new FormAttachment(middle, 0);
fdAddGeoRSS.top = new FormAttachment(wItemAuthor, margin);
fdAddGeoRSS.right = new FormAttachment(100, 0);
wAddGeoRSS.setLayoutData(fdAddGeoRSS);
wAddGeoRSS.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
activateGeoRSS();
input.setChanged();
}
});
// Add GeoRSS ?
wluseGeoRSSGML = new Label(wFields, SWT.RIGHT);
wluseGeoRSSGML.setText(BaseMessages.getString(PKG, "RssOutputDialog.useGeoRSSGML.Label"));
props.setLook(wluseGeoRSSGML);
fdluseGeoRSSGML = new FormData();
fdluseGeoRSSGML.left = new FormAttachment(0, 0);
fdluseGeoRSSGML.top = new FormAttachment(wAddGeoRSS, margin);
fdluseGeoRSSGML.right = new FormAttachment(middle, -margin);
wluseGeoRSSGML.setLayoutData(fdluseGeoRSSGML);
wuseGeoRSSGML = new Button(wFields, SWT.CHECK);
wuseGeoRSSGML.setToolTipText(BaseMessages.getString(PKG, "RssOutputDialog.useGeoRSSGML.Tooltip"));
props.setLook(wuseGeoRSSGML);
fduseGeoRSSGML = new FormData();
fduseGeoRSSGML.left = new FormAttachment(middle, 0);
fduseGeoRSSGML.top = new FormAttachment(wAddGeoRSS, margin);
fduseGeoRSSGML.right = new FormAttachment(100, 0);
wuseGeoRSSGML.setLayoutData(fduseGeoRSSGML);
wuseGeoRSSGML.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// GeoPointLat
wlGeoPointLat = new Label(wFields, SWT.RIGHT);
wlGeoPointLat.setText(BaseMessages.getString(PKG, "RssOutputDialog.GeoPointLat.Label"));
props.setLook(wlGeoPointLat);
fdlGeoPointLat = new FormData();
fdlGeoPointLat.left = new FormAttachment(0, 0);
fdlGeoPointLat.top = new FormAttachment(wuseGeoRSSGML, margin);
fdlGeoPointLat.right = new FormAttachment(middle, -margin);
wlGeoPointLat.setLayoutData(fdlGeoPointLat);
wGeoPointLat = new CCombo(wFields, SWT.BORDER | SWT.READ_ONLY);
wGeoPointLat.setEditable(true);
wGeoPointLat.setItems(fieldNames);
props.setLook(wGeoPointLat);
wGeoPointLat.addModifyListener(lsMod);
fdGeoPointLat = new FormData();
fdGeoPointLat.left = new FormAttachment(middle, 0);
fdGeoPointLat.top = new FormAttachment(wuseGeoRSSGML, margin);
fdGeoPointLat.right = new FormAttachment(100, 0);
wGeoPointLat.setLayoutData(fdGeoPointLat);
// GeoPointLong
wlGeoPointLong = new Label(wFields, SWT.RIGHT);
wlGeoPointLong.setText(BaseMessages.getString(PKG, "RssOutputDialog.GeoPointLong.Label"));
props.setLook(wlGeoPointLong);
fdlGeoPointLong = new FormData();
fdlGeoPointLong.left = new FormAttachment(0, 0);
fdlGeoPointLong.top = new FormAttachment(wGeoPointLat, margin);
fdlGeoPointLong.right = new FormAttachment(middle, -margin);
wlGeoPointLong.setLayoutData(fdlGeoPointLong);
wGeoPointLong = new CCombo(wFields, SWT.BORDER | SWT.READ_ONLY);
wGeoPointLong.setEditable(true);
wGeoPointLong.setItems(fieldNames);
props.setLook(wGeoPointLong);
wGeoPointLong.addModifyListener(lsMod);
fdGeoPointLong = new FormData();
fdGeoPointLong.left = new FormAttachment(middle, 0);
fdGeoPointLong.top = new FormAttachment(wGeoPointLat, margin);
fdGeoPointLong.right = new FormAttachment(100, 0);
wGeoPointLong.setLayoutData(fdGeoPointLong);
fdFields = new FormData();
fdFields.left = new FormAttachment(0, margin);
fdFields.top = new FormAttachment(0, margin);
fdFields.right = new FormAttachment(100, -margin);
wFields.setLayoutData(fdFields);
// ///////////////////////////////////////////////////////////
// / END OF Fields GROUP
// ///////////////////////////////////////////////////////////
fdGeneralComp = new FormData();
fdGeneralComp.left = new FormAttachment(0, 0);
fdGeneralComp.top = new FormAttachment(0, 0);
fdGeneralComp.right = new FormAttachment(100, 0);
fdGeneralComp.bottom = new FormAttachment(100, 0);
wGeneralComp.setLayoutData(fdGeneralComp);
wGeneralComp.layout();
wGeneralTab.setControl(wGeneralComp);
props.setLook(wGeneralComp);
// ///////////////////////////////////////////////////////////
// / END OF GENERAL TAB
// ///////////////////////////////////////////////////////////
// ////////////////////////
// START OF CUSTOM TAB ///
// ////////////////////////
wCustomTab = new CTabItem(wTabFolder, SWT.NONE);
wCustomTab.setText(BaseMessages.getString(PKG, "RssOutputDialog.CustomTab.TabTitle"));
wCustomComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wCustomComp);
FormLayout customLayout = new FormLayout();
customLayout.marginWidth = 3;
customLayout.marginHeight = 3;
wCustomComp.setLayout(customLayout);
wlChannelCustom = new Label(wCustomComp, SWT.NONE);
wlChannelCustom.setText(BaseMessages.getString(PKG, "RssOutputDialog.Keys.Label"));
props.setLook(wlChannelCustom);
fdlChannelCustom = new FormData();
fdlChannelCustom.left = new FormAttachment(0, 0);
fdlChannelCustom.top = new FormAttachment(0, margin);
wlChannelCustom.setLayoutData(fdlChannelCustom);
int nrChannelCols = 2;
int nrChannelRows = (input.getChannelCustomFields() != null ? input.getChannelCustomFields().length : 1);
ColumnInfo[] ciChannel = new ColumnInfo[nrChannelCols];
ciChannel[0] = new ColumnInfo(BaseMessages.getString(PKG, "RssOutputDialog.ColumnInfo.Tag"), ColumnInfo.COLUMN_TYPE_TEXT, false);
ciChannel[1] = new ColumnInfo(BaseMessages.getString(PKG, "RssOutputDialog.ColumnInfo.Field"), ColumnInfo.COLUMN_TYPE_CCOMBO);
ciChannel[0].setUsingVariables(true);
ciChannel[1].setComboValues(fieldNames);
wChannelCustom = new TableView(transMeta, wCustomComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciChannel, nrChannelRows, lsMod, props);
wGet = new Button(wCustomComp, SWT.PUSH);
wGet.setText(BaseMessages.getString(PKG, "RssOutputDialog.GetFields.Button"));
fdGet = new FormData();
fdGet.right = new FormAttachment(100, 0);
fdGet.top = new FormAttachment(wlChannelCustom, margin);
wGet.setLayoutData(fdGet);
fdChannelCustom = new FormData();
fdChannelCustom.left = new FormAttachment(0, 0);
fdChannelCustom.top = new FormAttachment(wlChannelCustom, margin);
fdChannelCustom.right = new FormAttachment(wGet, -margin);
fdChannelCustom.bottom = new FormAttachment(wlChannelCustom, 190);
wChannelCustom.setLayoutData(fdChannelCustom);
// THE 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"));
setButtonPositions(new Button[] { wOK, wCancel }, margin, null);
// THE Item Custom
wlItemCustom = new Label(wCustomComp, SWT.NONE);
wlItemCustom.setText(BaseMessages.getString(PKG, "RssOutputDialog.ItemCustom.Label"));
props.setLook(wlItemCustom);
fdlItemCustom = new FormData();
fdlItemCustom.left = new FormAttachment(0, 0);
fdlItemCustom.top = new FormAttachment(wChannelCustom, margin);
wlItemCustom.setLayoutData(fdlItemCustom);
int UpInsCols = 2;
int UpInsRows = (input.getItemCustomFields() != null ? input.getItemCustomFields().length : 1);
ColumnInfo[] ciItem = new ColumnInfo[UpInsCols];
ciItem[0] = new ColumnInfo(BaseMessages.getString(PKG, "RssOutputDialog.ColumnInfo.Tag"), ColumnInfo.COLUMN_TYPE_TEXT, false);
ciItem[1] = new ColumnInfo(BaseMessages.getString(PKG, "RssOutputDialog.ColumnInfo.Field"), ColumnInfo.COLUMN_TYPE_CCOMBO);
ciItem[1].setComboValues(fieldNames);
wItemCustom = new TableView(transMeta, wCustomComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciItem, UpInsRows, lsMod, props);
wGetCustomItem = new Button(wCustomComp, SWT.PUSH);
wGetCustomItem.setText(BaseMessages.getString(PKG, "RssOutputDialog.GetItemFields.Label"));
fdGetCustomItem = new FormData();
fdGetCustomItem.top = new FormAttachment(wlItemCustom, margin);
fdGetCustomItem.right = new FormAttachment(100, 0);
wGetCustomItem.setLayoutData(fdGetCustomItem);
fdItemCustom = new FormData();
fdItemCustom.left = new FormAttachment(0, 0);
fdItemCustom.top = new FormAttachment(wlItemCustom, margin);
fdItemCustom.right = new FormAttachment(wGetCustomItem, -margin);
fdItemCustom.bottom = new FormAttachment(100, -2 * margin);
wItemCustom.setLayoutData(fdItemCustom);
fdCustomComp = new FormData();
fdCustomComp.left = new FormAttachment(0, 0);
fdCustomComp.top = new FormAttachment(0, 0);
fdCustomComp.right = new FormAttachment(100, 0);
fdCustomComp.bottom = new FormAttachment(100, 0);
wCustomComp.setLayoutData(fdCustomComp);
wCustomComp.layout();
wCustomTab.setControl(wCustomComp);
props.setLook(wCustomComp);
// ///////////////////////////////////////////////////////////
// / END OF CUSTOM TAB
// ///////////////////////////////////////////////////////////
// ////////////////////////////////////
// START OF CUSTOM NAMESPACE TAB ///
// ////////////////////////////////////
wCustomNameSpace = new CTabItem(wTabFolder, SWT.NONE);
wCustomNameSpace.setText(BaseMessages.getString(PKG, "RssOutputDialog.CustomNameSpace.TabTitle"));
wCustomNameSpaceComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wCustomNameSpaceComp);
FormLayout customnamespaceLayout = new FormLayout();
customnamespaceLayout.marginWidth = 3;
customnamespaceLayout.marginHeight = 3;
wCustomNameSpaceComp.setLayout(customnamespaceLayout);
// Namespaces
wlNameSpace = new Label(wCustomNameSpaceComp, SWT.NONE);
wlNameSpace.setText(BaseMessages.getString(PKG, "RssOutputDialog.NameSpace.Label"));
props.setLook(wlNameSpace);
fdlNameSpace = new FormData();
fdlNameSpace.left = new FormAttachment(0, 0);
fdlNameSpace.top = new FormAttachment(0, margin);
wlNameSpace.setLayoutData(fdlItemCustom);
int nrRows = (input.getNameSpaces() != null ? input.getNameSpaces().length : 1);
ColumnInfo[] ciNameSpace = new ColumnInfo[2];
ciNameSpace[0] = new ColumnInfo(BaseMessages.getString(PKG, "RssOutputDialog.ColumnInfo.NameSpace.Title"), ColumnInfo.COLUMN_TYPE_TEXT, false);
ciNameSpace[1] = new ColumnInfo(BaseMessages.getString(PKG, "RssOutputDialog.ColumnInfo.NameSpace"), ColumnInfo.COLUMN_TYPE_TEXT, false);
ciNameSpace[0].setUsingVariables(true);
ciNameSpace[1].setUsingVariables(true);
wNameSpaceCustom = new TableView(transMeta, wCustomNameSpaceComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciNameSpace, nrRows, lsMod, props);
fdNameSpaceCustom = new FormData();
fdNameSpaceCustom.left = new FormAttachment(0, 0);
fdNameSpaceCustom.top = new FormAttachment(wlNameSpace, margin);
fdNameSpaceCustom.right = new FormAttachment(100, -margin);
fdNameSpaceCustom.bottom = new FormAttachment(100, -2 * margin);
wNameSpaceCustom.setLayoutData(fdNameSpaceCustom);
fdCustomNameSpace = new FormData();
fdCustomNameSpace.left = new FormAttachment(0, 0);
fdCustomNameSpace.top = new FormAttachment(0, 0);
fdCustomNameSpace.right = new FormAttachment(100, 0);
fdCustomNameSpace.bottom = new FormAttachment(100, 0);
wCustomNameSpaceComp.setLayoutData(fdCustomNameSpace);
wCustomNameSpaceComp.layout();
wCustomNameSpace.setControl(wCustomNameSpaceComp);
props.setLook(wCustomNameSpaceComp);
// ///////////////////////////////////////////////////////////
// / END OF CUSTOM NAMESPACE TAB
// ///////////////////////////////////////////////////////////
// ////////////////////////
// START OF CONTENT TAB///
// /
wContentTab = new CTabItem(wTabFolder, SWT.NONE);
wContentTab.setText(BaseMessages.getString(PKG, "RssOutputDialog.ContentTab.TabTitle"));
FormLayout contentLayout = new FormLayout();
contentLayout.marginWidth = 3;
contentLayout.marginHeight = 3;
wContentComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wContentComp);
wContentComp.setLayout(contentLayout);
// File grouping?
// ////////////////////////
// START OF FileName GROUP
//
wFileName = new Group(wContentComp, SWT.SHADOW_NONE);
props.setLook(wFileName);
wFileName.setText(BaseMessages.getString(PKG, "RssOutputDialog.Group.File.Label"));
FormLayout groupFileLayout = new FormLayout();
groupFileLayout.marginWidth = 10;
groupFileLayout.marginHeight = 10;
wFileName.setLayout(groupFileLayout);
// Filename line
wlFilename = new Label(wFileName, SWT.RIGHT);
wlFilename.setText(BaseMessages.getString(PKG, "RssOutputDialog.Filename.Label"));
props.setLook(wlFilename);
fdlFilename = new FormData();
fdlFilename.left = new FormAttachment(0, 0);
fdlFilename.top = new FormAttachment(wFields, margin);
fdlFilename.right = new FormAttachment(middle, -margin);
wlFilename.setLayoutData(fdlFilename);
wbFilename = new Button(wFileName, SWT.PUSH | SWT.CENTER);
props.setLook(wbFilename);
wbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
fdbFilename = new FormData();
fdbFilename.right = new FormAttachment(100, 0);
fdbFilename.top = new FormAttachment(wFields, 0);
wbFilename.setLayoutData(fdbFilename);
wFilename = new TextVar(transMeta, wFileName, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wFilename);
wFilename.addModifyListener(lsMod);
fdFilename = new FormData();
fdFilename.left = new FormAttachment(middle, 0);
fdFilename.top = new FormAttachment(wFields, margin);
fdFilename.right = new FormAttachment(wbFilename, -margin);
wFilename.setLayoutData(fdFilename);
// Create Parent Folder
wlCreateParentFolder = new Label(wFileName, SWT.RIGHT);
wlCreateParentFolder.setText(BaseMessages.getString(PKG, "RssOutputDialog.CreateParentFolder.Label"));
props.setLook(wlCreateParentFolder);
fdlCreateParentFolder = new FormData();
fdlCreateParentFolder.left = new FormAttachment(0, 0);
fdlCreateParentFolder.top = new FormAttachment(wFilename, margin);
fdlCreateParentFolder.right = new FormAttachment(middle, -margin);
wlCreateParentFolder.setLayoutData(fdlCreateParentFolder);
wCreateParentFolder = new Button(wFileName, SWT.CHECK);
wCreateParentFolder.setToolTipText(BaseMessages.getString(PKG, "RssOutputDialog.CreateParentFolder.Tooltip"));
props.setLook(wCreateParentFolder);
fdCreateParentFolder = new FormData();
fdCreateParentFolder.left = new FormAttachment(middle, 0);
fdCreateParentFolder.top = new FormAttachment(wFilename, margin);
fdCreateParentFolder.right = new FormAttachment(100, 0);
wCreateParentFolder.setLayoutData(fdCreateParentFolder);
wCreateParentFolder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// FileName defined in a field
wlFileNameInField = new Label(wFileName, SWT.RIGHT);
wlFileNameInField.setText(BaseMessages.getString(PKG, "RssOutputDialog.FileNameInField.Label"));
props.setLook(wlFileNameInField);
fdlFileNameInField = new FormData();
fdlFileNameInField.left = new FormAttachment(0, 0);
fdlFileNameInField.top = new FormAttachment(wCreateParentFolder, margin);
fdlFileNameInField.right = new FormAttachment(middle, -margin);
wlFileNameInField.setLayoutData(fdlFileNameInField);
wFileNameInField = new Button(wFileName, SWT.CHECK);
wFileNameInField.setToolTipText(BaseMessages.getString(PKG, "RssOutputDialog.FileNameInField.Tooltip"));
props.setLook(wFileNameInField);
fdFileNameInField = new FormData();
fdFileNameInField.left = new FormAttachment(middle, 0);
fdFileNameInField.top = new FormAttachment(wCreateParentFolder, margin);
fdFileNameInField.right = new FormAttachment(100, 0);
wFileNameInField.setLayoutData(fdFileNameInField);
wFileNameInField.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
setFieldFilename();
input.setChanged();
}
});
// FieldFieldFileName line
wlFieldFilename = new Label(wFileName, SWT.RIGHT);
wlFieldFilename.setText(BaseMessages.getString(PKG, "RssOutputDialog.FieldFilename.Label"));
props.setLook(wlFieldFilename);
fdlFieldFilename = new FormData();
fdlFieldFilename.left = new FormAttachment(0, 0);
fdlFieldFilename.top = new FormAttachment(wFileNameInField, margin);
fdlFieldFilename.right = new FormAttachment(middle, -margin);
wlFieldFilename.setLayoutData(fdlFieldFilename);
wFieldFilename = new CCombo(wFileName, SWT.BORDER | SWT.READ_ONLY);
wFieldFilename.setEditable(true);
wFieldFilename.setItems(fieldNames);
props.setLook(wFieldFilename);
wFieldFilename.addModifyListener(lsMod);
fdFieldFilename = new FormData();
fdFieldFilename.left = new FormAttachment(middle, 0);
fdFieldFilename.top = new FormAttachment(wFileNameInField, margin);
fdFieldFilename.right = new FormAttachment(100, -margin);
wFieldFilename.setLayoutData(fdFieldFilename);
// Extension line
wlExtension = new Label(wFileName, SWT.RIGHT);
wlExtension.setText(BaseMessages.getString(PKG, "System.Label.Extension"));
props.setLook(wlExtension);
fdlExtension = new FormData();
fdlExtension.left = new FormAttachment(0, 0);
fdlExtension.top = new FormAttachment(wFieldFilename, margin);
fdlExtension.right = new FormAttachment(middle, -margin);
wlExtension.setLayoutData(fdlExtension);
wExtension = new TextVar(transMeta, wFileName, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wExtension);
wExtension.addModifyListener(lsMod);
fdExtension = new FormData();
fdExtension.left = new FormAttachment(middle, 0);
fdExtension.top = new FormAttachment(wFieldFilename, margin);
fdExtension.right = new FormAttachment(100, -margin);
wExtension.setLayoutData(fdExtension);
// Create multi-part file?
wlAddStepnr = new Label(wFileName, SWT.RIGHT);
wlAddStepnr.setText(BaseMessages.getString(PKG, "RssOutputDialog.AddStepnr.Label"));
props.setLook(wlAddStepnr);
fdlAddStepnr = new FormData();
fdlAddStepnr.left = new FormAttachment(0, 0);
fdlAddStepnr.top = new FormAttachment(wExtension, 2 * margin);
fdlAddStepnr.right = new FormAttachment(middle, -margin);
wlAddStepnr.setLayoutData(fdlAddStepnr);
wAddStepnr = new Button(wFileName, SWT.CHECK);
props.setLook(wAddStepnr);
fdAddStepnr = new FormData();
fdAddStepnr.left = new FormAttachment(middle, 0);
fdAddStepnr.top = new FormAttachment(wExtension, 2 * margin);
fdAddStepnr.right = new FormAttachment(100, 0);
wAddStepnr.setLayoutData(fdAddStepnr);
wAddStepnr.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// Create multi-part file?
wlAddDate = new Label(wFileName, SWT.RIGHT);
wlAddDate.setText(BaseMessages.getString(PKG, "RssOutputDialog.AddDate.Label"));
props.setLook(wlAddDate);
fdlAddDate = new FormData();
fdlAddDate.left = new FormAttachment(0, 0);
fdlAddDate.top = new FormAttachment(wAddStepnr, margin);
fdlAddDate.right = new FormAttachment(middle, -margin);
wlAddDate.setLayoutData(fdlAddDate);
wAddDate = new Button(wFileName, SWT.CHECK);
props.setLook(wAddDate);
fdAddDate = new FormData();
fdAddDate.left = new FormAttachment(middle, 0);
fdAddDate.top = new FormAttachment(wAddStepnr, margin);
fdAddDate.right = new FormAttachment(100, 0);
wAddDate.setLayoutData(fdAddDate);
wAddDate.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
// System.out.println("wAddDate.getSelection()="+wAddDate.getSelection());
}
});
// Create multi-part file?
wlAddTime = new Label(wFileName, SWT.RIGHT);
wlAddTime.setText(BaseMessages.getString(PKG, "RssOutputDialog.AddTime.Label"));
props.setLook(wlAddTime);
fdlAddTime = new FormData();
fdlAddTime.left = new FormAttachment(0, 0);
fdlAddTime.top = new FormAttachment(wAddDate, margin);
fdlAddTime.right = new FormAttachment(middle, -margin);
wlAddTime.setLayoutData(fdlAddTime);
wAddTime = new Button(wFileName, SWT.CHECK);
props.setLook(wAddTime);
fdAddTime = new FormData();
fdAddTime.left = new FormAttachment(middle, 0);
fdAddTime.top = new FormAttachment(wAddDate, margin);
fdAddTime.right = new FormAttachment(100, 0);
wAddTime.setLayoutData(fdAddTime);
wAddTime.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
wbShowFiles = new Button(wFileName, SWT.PUSH | SWT.CENTER);
props.setLook(wbShowFiles);
wbShowFiles.setText(BaseMessages.getString(PKG, "RssOutputDialog.ShowFiles.Button"));
fdbShowFiles = new FormData();
fdbShowFiles.left = new FormAttachment(middle, 0);
fdbShowFiles.top = new FormAttachment(wAddTime, margin * 2);
wbShowFiles.setLayoutData(fdbShowFiles);
wbShowFiles.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
RssOutputMeta tfoi = new RssOutputMeta();
getInfo(tfoi);
try {
String[] files = tfoi.getFiles(transMeta);
if (files != null && files.length > 0) {
EnterSelectionDialog esd = new EnterSelectionDialog(shell, files, BaseMessages.getString(PKG, "RssOutputDialog.SelectOutputFiles.DialogTitle"), BaseMessages.getString(PKG, "RssOutputDialog.SelectOutputFiles.DialogMessage"));
esd.setViewOnly();
esd.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "RssOutputDialog.NoFilesFound.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "System.DialogTitle.Error"));
mb.open();
}
} catch (KettleStepException s) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "RssOutputDialog.ErrorGettingFiles.DialogMessage", s.getMessage()));
mb.setText(BaseMessages.getString(PKG, "System.DialogTitle.Error"));
mb.open();
}
}
});
fdFileName = new FormData();
fdFileName.left = new FormAttachment(0, margin);
fdFileName.top = new FormAttachment(wFields, margin);
fdFileName.right = new FormAttachment(100, -margin);
wFileName.setLayoutData(fdFileName);
// ///////////////////////////////////////////////////////////
// / END OF FileName GROUP
// ///////////////////////////////////////////////////////////
// File grouping?
// ////////////////////////
// START OF ResultFile GROUP
//
wResultFile = new Group(wContentComp, SWT.SHADOW_NONE);
props.setLook(wResultFile);
wResultFile.setText(BaseMessages.getString(PKG, "RssOutputDialog.Group.ResultFile.Label"));
FormLayout groupResultFile = new FormLayout();
groupResultFile.marginWidth = 10;
groupResultFile.marginHeight = 10;
wResultFile.setLayout(groupResultFile);
// Add File to the result files name
wlAddToResult = new Label(wResultFile, SWT.RIGHT);
wlAddToResult.setText(BaseMessages.getString(PKG, "RssOutputDialog.AddFileToResult.Label"));
props.setLook(wlAddToResult);
fdlAddToResult = new FormData();
fdlAddToResult.left = new FormAttachment(0, 0);
fdlAddToResult.top = new FormAttachment(wFileName, margin);
fdlAddToResult.right = new FormAttachment(middle, -margin);
wlAddToResult.setLayoutData(fdlAddToResult);
wAddToResult = new Button(wResultFile, SWT.CHECK);
wAddToResult.setToolTipText(BaseMessages.getString(PKG, "RssOutputDialog.AddFileToResult.Tooltip"));
props.setLook(wAddToResult);
fdAddToResult = new FormData();
fdAddToResult.left = new FormAttachment(middle, 0);
fdAddToResult.top = new FormAttachment(wFileName, margin);
fdAddToResult.right = new FormAttachment(100, 0);
wAddToResult.setLayoutData(fdAddToResult);
SelectionAdapter lsSelAR = new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
input.setChanged();
}
};
wAddToResult.addSelectionListener(lsSelAR);
fdResultFile = new FormData();
fdResultFile.left = new FormAttachment(0, margin);
fdResultFile.top = new FormAttachment(wFileName, margin);
fdResultFile.right = new FormAttachment(100, -margin);
wResultFile.setLayoutData(fdResultFile);
// ///////////////////////////////////////////////////////////
// / END OF ResultFile GROUP
// ///////////////////////////////////////////////////////////
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(wContentComp);
wContentComp.layout();
wContentTab.setControl(wContentComp);
// ///////////////////////////////////////////////////////////
// / END OF CONTENT TAB
// ///////////////////////////////////////////////////////////
fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(wStepname, margin);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(100, -50);
wTabFolder.setLayoutData(fdTabFolder);
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsGet = new Listener() {
public void handleEvent(Event e) {
get(wChannelCustom);
}
};
lsGetCustomItem = new Listener() {
public void handleEvent(Event e) {
get(wItemCustom);
}
};
wOK.addListener(SWT.Selection, lsOK);
wCancel.addListener(SWT.Selection, lsCancel);
wGet.addListener(SWT.Selection, lsGet);
wGetCustomItem.addListener(SWT.Selection, lsGetCustomItem);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wbFilename.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(shell, SWT.SAVE);
dialog.setFilterExtensions(new String[] { "*.txt", "*.TXT", "*" });
if (wFilename.getText() != null) {
dialog.setFileName(transMeta.environmentSubstitute(wFilename.getText()));
}
dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "System.FileType.TextFiles"), BaseMessages.getString(PKG, "System.FileType.CSVFiles"), BaseMessages.getString(PKG, "System.FileType.AllFiles") });
if (dialog.open() != null) {
String extension = wExtension.getText();
if (extension != null && dialog.getFileName() != null && dialog.getFileName().endsWith("." + extension)) {
// The extension is filled in and matches the end
// of the selected file => Strip off the extension.
String fileName = dialog.getFileName();
wFilename.setText(dialog.getFilterPath() + System.getProperty("file.separator") + fileName.substring(0, fileName.length() - (extension.length() + 1)));
} else {
wFilename.setText(dialog.getFilterPath() + System.getProperty("file.separator") + dialog.getFileName());
}
}
}
});
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
lsResize = new Listener() {
public void handleEvent(Event event) {
// Point size = shell.getSize();
}
};
shell.addListener(SWT.Resize, lsResize);
wTabFolder.setSelection(0);
// Set the shell size, based upon previous time...
setSize();
getData();
setCustomRSS();
setFieldFilename();
setImage();
activateGeoRSS();
// backupChanged);
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
Aggregations