use of org.pentaho.di.ui.trans.step.ComponentSelectionListener in project pentaho-kettle by pentaho.
the class CreditCardValidatorDialog 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();
}
};
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, "CreditCardValidatorDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "CreditCardValidatorDialog.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);
// filename field
wlFieldName = new Label(shell, SWT.RIGHT);
wlFieldName.setText(BaseMessages.getString(PKG, "CreditCardValidatorDialog.FieldName.Label"));
props.setLook(wlFieldName);
fdlFieldName = new FormData();
fdlFieldName.left = new FormAttachment(0, 0);
fdlFieldName.right = new FormAttachment(middle, -margin);
fdlFieldName.top = new FormAttachment(wStepname, margin);
wlFieldName.setLayoutData(fdlFieldName);
wFieldName = new CCombo(shell, SWT.BORDER | SWT.READ_ONLY);
props.setLook(wFieldName);
wFieldName.addModifyListener(lsMod);
fdFieldName = new FormData();
fdFieldName.left = new FormAttachment(middle, 0);
fdFieldName.top = new FormAttachment(wStepname, margin);
fdFieldName.right = new FormAttachment(100, -margin);
wFieldName.setLayoutData(fdFieldName);
wFieldName.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);
get();
shell.setCursor(null);
busy.dispose();
}
});
// get only digits?
wlgetOnlyDigits = new Label(shell, SWT.RIGHT);
wlgetOnlyDigits.setText(BaseMessages.getString(PKG, "CreditCardValidator.getOnlyDigits.Label"));
props.setLook(wlgetOnlyDigits);
fdlgetOnlyDigits = new FormData();
fdlgetOnlyDigits.left = new FormAttachment(0, 0);
fdlgetOnlyDigits.top = new FormAttachment(wFieldName, margin);
fdlgetOnlyDigits.right = new FormAttachment(middle, -margin);
wlgetOnlyDigits.setLayoutData(fdlgetOnlyDigits);
wgetOnlyDigits = new Button(shell, SWT.CHECK);
props.setLook(wgetOnlyDigits);
wgetOnlyDigits.setToolTipText(BaseMessages.getString(PKG, "CreditCardValidator.getOnlyDigits.Tooltip"));
fdgetOnlyDigits = new FormData();
fdgetOnlyDigits.left = new FormAttachment(middle, 0);
fdgetOnlyDigits.top = new FormAttachment(wFieldName, margin);
wgetOnlyDigits.setLayoutData(fdgetOnlyDigits);
wgetOnlyDigits.addSelectionListener(new ComponentSelectionListener(input));
// ///////////////////////////////
// START OF Output Fields GROUP //
// ///////////////////////////////
wOutputFields = new Group(shell, SWT.SHADOW_NONE);
props.setLook(wOutputFields);
wOutputFields.setText(BaseMessages.getString(PKG, "CreditCardValidatorDialog.OutputFields.Label"));
FormLayout OutputFieldsgroupLayout = new FormLayout();
OutputFieldsgroupLayout.marginWidth = 10;
OutputFieldsgroupLayout.marginHeight = 10;
wOutputFields.setLayout(OutputFieldsgroupLayout);
// Result fieldname ...
wlResult = new Label(wOutputFields, SWT.RIGHT);
wlResult.setText(BaseMessages.getString(PKG, "CreditCardValidatorDialog.ResultField.Label"));
props.setLook(wlResult);
fdlResult = new FormData();
fdlResult.left = new FormAttachment(0, -margin);
fdlResult.right = new FormAttachment(middle, -2 * margin);
fdlResult.top = new FormAttachment(wgetOnlyDigits, 2 * margin);
wlResult.setLayoutData(fdlResult);
wResult = new TextVar(transMeta, wOutputFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wResult.setToolTipText(BaseMessages.getString(PKG, "CreditCardValidatorDialog.ResultField.Tooltip"));
props.setLook(wResult);
wResult.addModifyListener(lsMod);
fdResult = new FormData();
fdResult.left = new FormAttachment(middle, -margin);
fdResult.top = new FormAttachment(wgetOnlyDigits, 2 * margin);
fdResult.right = new FormAttachment(100, 0);
wResult.setLayoutData(fdResult);
// FileType fieldname ...
wlCardType = new Label(wOutputFields, SWT.RIGHT);
wlCardType.setText(BaseMessages.getString(PKG, "CreditCardValidatorDialog.CardType.Label"));
props.setLook(wlCardType);
fdlCardType = new FormData();
fdlCardType.left = new FormAttachment(0, -margin);
fdlCardType.right = new FormAttachment(middle, -2 * margin);
fdlCardType.top = new FormAttachment(wResult, margin);
wlCardType.setLayoutData(fdlCardType);
wFileType = new TextVar(transMeta, wOutputFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wFileType.setToolTipText(BaseMessages.getString(PKG, "CreditCardValidatorDialog.CardType.Tooltip"));
props.setLook(wFileType);
wFileType.addModifyListener(lsMod);
fdCardType = new FormData();
fdCardType.left = new FormAttachment(middle, -margin);
fdCardType.top = new FormAttachment(wResult, margin);
fdCardType.right = new FormAttachment(100, 0);
wFileType.setLayoutData(fdCardType);
// UnvalidMsg fieldname ...
wlNotValidMsg = new Label(wOutputFields, SWT.RIGHT);
wlNotValidMsg.setText(BaseMessages.getString(PKG, "CreditCardValidatorDialog.NotValidMsg.Label"));
props.setLook(wlNotValidMsg);
fdlNotValidMsg = new FormData();
fdlNotValidMsg.left = new FormAttachment(0, -margin);
fdlNotValidMsg.right = new FormAttachment(middle, -2 * margin);
fdlNotValidMsg.top = new FormAttachment(wFileType, margin);
wlNotValidMsg.setLayoutData(fdlNotValidMsg);
wNotValidMsg = new TextVar(transMeta, wOutputFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wNotValidMsg.setToolTipText(BaseMessages.getString(PKG, "CreditCardValidatorDialog.NotValidMsg.Tooltip"));
props.setLook(wNotValidMsg);
wNotValidMsg.addModifyListener(lsMod);
fdNotValidMsg = new FormData();
fdNotValidMsg.left = new FormAttachment(middle, -margin);
fdNotValidMsg.top = new FormAttachment(wFileType, margin);
fdNotValidMsg.right = new FormAttachment(100, 0);
wNotValidMsg.setLayoutData(fdNotValidMsg);
fdAdditionalFields = new FormData();
fdAdditionalFields.left = new FormAttachment(0, margin);
fdAdditionalFields.top = new FormAttachment(wgetOnlyDigits, 2 * margin);
fdAdditionalFields.right = new FormAttachment(100, -margin);
wOutputFields.setLayoutData(fdAdditionalFields);
// ///////////////////////////////
// END OF Additional Fields GROUP //
// ///////////////////////////////
// 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, wOutputFields);
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.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.ui.trans.step.ComponentSelectionListener in project pentaho-kettle by pentaho.
the class ExcelInputDialog method open.
@Override
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);
lsMod = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
input.setChanged();
checkAlerts();
}
};
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, "ExcelInputDialog.DialogTitle"));
middle = props.getMiddlePct();
margin = Const.MARGIN;
// 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.top = new FormAttachment(0, margin);
fdlStepname.right = new FormAttachment(middle, -margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wStepname.setText(stepname);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
// Status Message
wlStatusMessage = new Label(shell, SWT.RIGHT);
wlStatusMessage.setText("(This Space To Let)");
wlStatusMessage.setForeground(display.getSystemColor(SWT.COLOR_RED));
props.setLook(wlStatusMessage);
fdlStatusMessage = new FormData();
fdlStatusMessage.left = new FormAttachment(0, 0);
fdlStatusMessage.top = new FormAttachment(wlStepname, margin);
fdlStatusMessage.right = new FormAttachment(middle, -margin);
wlStatusMessage.setLayoutData(fdlStatusMessage);
// Tabs
wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
//
// START OF FILE TAB /
//
wFileTab = new CTabItem(wTabFolder, SWT.NONE);
wFileTab.setText(BaseMessages.getString(PKG, "ExcelInputDialog.FileTab.TabTitle"));
wFileComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wFileComp);
FormLayout fileLayout = new FormLayout();
fileLayout.marginWidth = 3;
fileLayout.marginHeight = 3;
wFileComp.setLayout(fileLayout);
// spreadsheet engine type
wlSpreadSheetType = new Label(wFileComp, SWT.RIGHT);
wlSpreadSheetType.setText(BaseMessages.getString(PKG, "ExcelInputDialog.SpreadSheetType.Label"));
props.setLook(wlSpreadSheetType);
fdlSpreadSheetType = new FormData();
fdlSpreadSheetType.left = new FormAttachment(0, 0);
fdlSpreadSheetType.right = new FormAttachment(middle, -margin);
fdlSpreadSheetType.top = new FormAttachment(0, 0);
wlSpreadSheetType.setLayoutData(fdlSpreadSheetType);
wSpreadSheetType = new CCombo(wFileComp, SWT.BORDER | SWT.READ_ONLY);
wSpreadSheetType.setEditable(true);
props.setLook(wSpreadSheetType);
wSpreadSheetType.addModifyListener(lsMod);
fdSpreadSheetType = new FormData();
fdSpreadSheetType.left = new FormAttachment(middle, 0);
fdSpreadSheetType.right = new FormAttachment(100, 0);
fdSpreadSheetType.top = new FormAttachment(0, 0);
wSpreadSheetType.setLayoutData(fdSpreadSheetType);
for (SpreadSheetType type : SpreadSheetType.values()) {
wSpreadSheetType.add(type.getDescription());
}
// Filename line
wlFilename = new Label(wFileComp, SWT.RIGHT);
wlFilename.setText(BaseMessages.getString(PKG, "ExcelInputDialog.Filename.Label"));
props.setLook(wlFilename);
fdlFilename = new FormData();
fdlFilename.left = new FormAttachment(0, 0);
fdlFilename.top = new FormAttachment(wSpreadSheetType, margin);
fdlFilename.right = new FormAttachment(middle, -margin);
wlFilename.setLayoutData(fdlFilename);
wbbFilename = new Button(wFileComp, SWT.PUSH | SWT.CENTER);
props.setLook(wbbFilename);
wbbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
wbbFilename.setToolTipText(BaseMessages.getString(PKG, "System.Tooltip.BrowseForFileOrDirAndAdd"));
fdbFilename = new FormData();
fdbFilename.right = new FormAttachment(100, 0);
fdbFilename.top = new FormAttachment(wSpreadSheetType, margin);
wbbFilename.setLayoutData(fdbFilename);
wbaFilename = new Button(wFileComp, SWT.PUSH | SWT.CENTER);
props.setLook(wbaFilename);
wbaFilename.setText(BaseMessages.getString(PKG, "ExcelInputDialog.FilenameAdd.Button"));
wbaFilename.setToolTipText(BaseMessages.getString(PKG, "ExcelInputDialog.FilenameAdd.Tooltip"));
fdbaFilename = new FormData();
fdbaFilename.right = new FormAttachment(wbbFilename, -margin);
fdbaFilename.top = new FormAttachment(wSpreadSheetType, margin);
wbaFilename.setLayoutData(fdbaFilename);
wFilename = new TextVar(transMeta, wFileComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wFilename);
wFilename.addModifyListener(lsMod);
fdFilename = new FormData();
fdFilename.left = new FormAttachment(middle, 0);
fdFilename.right = new FormAttachment(wbaFilename, -margin);
fdFilename.top = new FormAttachment(wSpreadSheetType, margin);
wFilename.setLayoutData(fdFilename);
wlFilemask = new Label(wFileComp, SWT.RIGHT);
wlFilemask.setText(BaseMessages.getString(PKG, "ExcelInputDialog.Filemask.Label"));
props.setLook(wlFilemask);
fdlFilemask = new FormData();
fdlFilemask.left = new FormAttachment(0, 0);
fdlFilemask.top = new FormAttachment(wFilename, margin);
fdlFilemask.right = new FormAttachment(middle, -margin);
wlFilemask.setLayoutData(fdlFilemask);
wFilemask = new Text(wFileComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wFilemask);
wFilemask.addModifyListener(lsMod);
fdFilemask = new FormData();
fdFilemask.left = new FormAttachment(middle, 0);
fdFilemask.top = new FormAttachment(wFilename, margin);
fdFilemask.right = new FormAttachment(wbaFilename, -margin);
wFilemask.setLayoutData(fdFilemask);
wlExcludeFilemask = new Label(wFileComp, SWT.RIGHT);
wlExcludeFilemask.setText(BaseMessages.getString(PKG, "ExcelInputDialog.ExcludeFilemask.Label"));
props.setLook(wlExcludeFilemask);
fdlExcludeFilemask = new FormData();
fdlExcludeFilemask.left = new FormAttachment(0, 0);
fdlExcludeFilemask.top = new FormAttachment(wFilemask, margin);
fdlExcludeFilemask.right = new FormAttachment(middle, -margin);
wlExcludeFilemask.setLayoutData(fdlExcludeFilemask);
wExcludeFilemask = new TextVar(transMeta, wFileComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wExcludeFilemask);
wExcludeFilemask.addModifyListener(lsMod);
fdExcludeFilemask = new FormData();
fdExcludeFilemask.left = new FormAttachment(middle, 0);
fdExcludeFilemask.top = new FormAttachment(wFilemask, margin);
fdExcludeFilemask.right = new FormAttachment(wFilename, 0, SWT.RIGHT);
wExcludeFilemask.setLayoutData(fdExcludeFilemask);
// Filename list line
wlFilenameList = new Label(wFileComp, SWT.RIGHT);
wlFilenameList.setText(BaseMessages.getString(PKG, "ExcelInputDialog.FilenameList.Label"));
props.setLook(wlFilenameList);
fdlFilenameList = new FormData();
fdlFilenameList.left = new FormAttachment(0, 0);
fdlFilenameList.top = new FormAttachment(wExcludeFilemask, margin);
fdlFilenameList.right = new FormAttachment(middle, -margin);
wlFilenameList.setLayoutData(fdlFilenameList);
// Buttons to the right of the screen...
wbdFilename = new Button(wFileComp, SWT.PUSH | SWT.CENTER);
props.setLook(wbdFilename);
wbdFilename.setText(BaseMessages.getString(PKG, "ExcelInputDialog.FilenameDelete.Button"));
wbdFilename.setToolTipText(BaseMessages.getString(PKG, "ExcelInputDialog.FilenameDelete.Tooltip"));
fdbdFilename = new FormData();
fdbdFilename.right = new FormAttachment(100, 0);
fdbdFilename.top = new FormAttachment(wExcludeFilemask, 40);
wbdFilename.setLayoutData(fdbdFilename);
wbeFilename = new Button(wFileComp, SWT.PUSH | SWT.CENTER);
props.setLook(wbeFilename);
wbeFilename.setText(BaseMessages.getString(PKG, "ExcelInputDialog.FilenameEdit.Button"));
wbeFilename.setToolTipText(BaseMessages.getString(PKG, "ExcelInputDialog.FilenameEdit.Tooltip"));
fdbeFilename = new FormData();
fdbeFilename.right = new FormAttachment(100, 0);
fdbeFilename.left = new FormAttachment(wbdFilename, 0, SWT.LEFT);
fdbeFilename.top = new FormAttachment(wbdFilename, margin);
wbeFilename.setLayoutData(fdbeFilename);
wbShowFiles = new Button(wFileComp, SWT.PUSH | SWT.CENTER);
props.setLook(wbShowFiles);
wbShowFiles.setText(BaseMessages.getString(PKG, "ExcelInputDialog.ShowFiles.Button"));
fdbShowFiles = new FormData();
fdbShowFiles.left = new FormAttachment(middle, 0);
fdbShowFiles.bottom = new FormAttachment(100, -margin);
wbShowFiles.setLayoutData(fdbShowFiles);
// Accepting filenames group
//
gAccepting = new Group(wFileComp, SWT.SHADOW_ETCHED_IN);
gAccepting.setText(BaseMessages.getString(PKG, "ExcelInputDialog.AcceptingGroup.Label"));
FormLayout acceptingLayout = new FormLayout();
acceptingLayout.marginWidth = 3;
acceptingLayout.marginHeight = 3;
gAccepting.setLayout(acceptingLayout);
props.setLook(gAccepting);
// Accept filenames from previous steps?
//
wlAccFilenames = new Label(gAccepting, SWT.RIGHT);
wlAccFilenames.setText(BaseMessages.getString(PKG, "ExcelInputDialog.AcceptFilenames.Label"));
props.setLook(wlAccFilenames);
fdlAccFilenames = new FormData();
fdlAccFilenames.top = new FormAttachment(0, margin);
fdlAccFilenames.left = new FormAttachment(0, 0);
fdlAccFilenames.right = new FormAttachment(middle, -margin);
wlAccFilenames.setLayoutData(fdlAccFilenames);
wAccFilenames = new Button(gAccepting, SWT.CHECK);
wAccFilenames.setToolTipText(BaseMessages.getString(PKG, "ExcelInputDialog.AcceptFilenames.Tooltip"));
props.setLook(wAccFilenames);
fdAccFilenames = new FormData();
fdAccFilenames.top = new FormAttachment(0, margin);
fdAccFilenames.left = new FormAttachment(middle, 0);
fdAccFilenames.right = new FormAttachment(100, 0);
wAccFilenames.setLayoutData(fdAccFilenames);
wAccFilenames.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
setFlags();
input.setChanged();
}
});
// Which step to read from?
wlAccStep = new Label(gAccepting, SWT.RIGHT);
wlAccStep.setText(BaseMessages.getString(PKG, "ExcelInputDialog.AcceptStep.Label"));
props.setLook(wlAccStep);
fdlAccStep = new FormData();
fdlAccStep.top = new FormAttachment(wAccFilenames, margin);
fdlAccStep.left = new FormAttachment(0, 0);
fdlAccStep.right = new FormAttachment(middle, -margin);
wlAccStep.setLayoutData(fdlAccStep);
wAccStep = new CCombo(gAccepting, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wAccStep.setToolTipText(BaseMessages.getString(PKG, "ExcelInputDialog.AcceptStep.Tooltip"));
props.setLook(wAccStep);
fdAccStep = new FormData();
fdAccStep.top = new FormAttachment(wAccFilenames, margin);
fdAccStep.left = new FormAttachment(middle, 0);
fdAccStep.right = new FormAttachment(100, 0);
wAccStep.setLayoutData(fdAccStep);
// Which field?
//
wlAccField = new Label(gAccepting, SWT.RIGHT);
wlAccField.setText(BaseMessages.getString(PKG, "ExcelInputDialog.AcceptField.Label"));
props.setLook(wlAccField);
fdlAccField = new FormData();
fdlAccField.top = new FormAttachment(wAccStep, margin);
fdlAccField.left = new FormAttachment(0, 0);
fdlAccField.right = new FormAttachment(middle, -margin);
wlAccField.setLayoutData(fdlAccField);
wAccField = new CCombo(gAccepting, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
RowMetaInterface previousFields;
try {
previousFields = transMeta.getPrevStepFields(stepMeta);
} catch (KettleStepException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "ExcelInputDialog.ErrorDialog.UnableToGetInputFields.Title"), BaseMessages.getString(PKG, "ExcelInputDialog.ErrorDialog.UnableToGetInputFields.Message"), e);
previousFields = new RowMeta();
}
wAccField.setItems(previousFields.getFieldNames());
wAccField.setToolTipText(BaseMessages.getString(PKG, "ExcelInputDialog.AcceptField.Tooltip"));
props.setLook(wAccField);
fdAccField = new FormData();
fdAccField.top = new FormAttachment(wAccStep, margin);
fdAccField.left = new FormAttachment(middle, 0);
fdAccField.right = new FormAttachment(100, 0);
wAccField.setLayoutData(fdAccField);
// Fill in the source steps...
List<StepMeta> prevSteps = transMeta.findPreviousSteps(transMeta.findStep(stepname));
for (StepMeta prevStep : prevSteps) {
wAccStep.add(prevStep.getName());
}
fdAccepting = new FormData();
fdAccepting.left = new FormAttachment(middle, 0);
fdAccepting.right = new FormAttachment(100, 0);
fdAccepting.bottom = new FormAttachment(wbShowFiles, -margin * 2);
// fdAccepting.bottom = new FormAttachment(wAccStep, margin);
gAccepting.setLayoutData(fdAccepting);
ColumnInfo[] colinfo = new ColumnInfo[5];
colinfo[0] = new ColumnInfo(BaseMessages.getString(PKG, "ExcelInputDialog.FileDir.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false);
colinfo[0].setUsingVariables(true);
colinfo[1] = new ColumnInfo(BaseMessages.getString(PKG, "ExcelInputDialog.Wildcard.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false);
colinfo[1].setToolTip(BaseMessages.getString(PKG, "ExcelInputDialog.Wildcard.Tooltip"));
colinfo[2] = new ColumnInfo(BaseMessages.getString(PKG, "ExcelInputDialog.Files.ExcludeWildcard.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false);
colinfo[2].setUsingVariables(true);
colinfo[3] = new ColumnInfo(BaseMessages.getString(PKG, "ExcelInputDialog.Required.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, YES_NO_COMBO);
colinfo[3].setToolTip(BaseMessages.getString(PKG, "ExcelInputDialog.Required.Tooltip"));
colinfo[4] = new ColumnInfo(BaseMessages.getString(PKG, "ExcelInputDialog.IncludeSubDirs.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, YES_NO_COMBO);
colinfo[4].setToolTip(BaseMessages.getString(PKG, "ExcelInputDialog.IncludeSubDirs.Tooltip"));
wFilenameList = new TableView(transMeta, wFileComp, SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER, colinfo, input.getFileName().length, lsMod, props);
props.setLook(wFilenameList);
fdFilenameList = new FormData();
fdFilenameList.left = new FormAttachment(middle, 0);
fdFilenameList.right = new FormAttachment(wbdFilename, -margin);
fdFilenameList.top = new FormAttachment(wExcludeFilemask, margin);
fdFilenameList.bottom = new FormAttachment(gAccepting, -margin);
wFilenameList.setLayoutData(fdFilenameList);
fdFileComp = new FormData();
fdFileComp.left = new FormAttachment(0, 0);
fdFileComp.top = new FormAttachment(0, 0);
fdFileComp.right = new FormAttachment(100, 0);
fdFileComp.bottom = new FormAttachment(100, 0);
wFileComp.setLayoutData(fdFileComp);
wFileComp.layout();
wFileTab.setControl(wFileComp);
//
// / END OF FILE TAB
//
//
// START OF SHEET TAB /
//
wSheetTab = new CTabItem(wTabFolder, SWT.NONE);
wSheetTab.setText(BaseMessages.getString(PKG, "ExcelInputDialog.SheetsTab.TabTitle"));
wSheetComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wSheetComp);
FormLayout sheetLayout = new FormLayout();
sheetLayout.marginWidth = 3;
sheetLayout.marginHeight = 3;
wSheetComp.setLayout(sheetLayout);
wbGetSheets = new Button(wSheetComp, SWT.PUSH | SWT.CENTER);
props.setLook(wbGetSheets);
wbGetSheets.setText(BaseMessages.getString(PKG, "ExcelInputDialog.GetSheets.Button"));
fdbGetSheets = new FormData();
fdbGetSheets.left = new FormAttachment(middle, 0);
fdbGetSheets.bottom = new FormAttachment(100, -margin);
wbGetSheets.setLayoutData(fdbGetSheets);
wlSheetnameList = new Label(wSheetComp, SWT.RIGHT);
wlSheetnameList.setText(BaseMessages.getString(PKG, "ExcelInputDialog.SheetNameList.Label"));
props.setLook(wlSheetnameList);
fdlSheetnameList = new FormData();
fdlSheetnameList.left = new FormAttachment(0, 0);
fdlSheetnameList.top = new FormAttachment(wFilename, margin);
fdlSheetnameList.right = new FormAttachment(middle, -margin);
wlSheetnameList.setLayoutData(fdlSheetnameList);
ColumnInfo[] shinfo = new ColumnInfo[3];
shinfo[0] = new ColumnInfo(BaseMessages.getString(PKG, "ExcelInputDialog.SheetName.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false);
shinfo[1] = new ColumnInfo(BaseMessages.getString(PKG, "ExcelInputDialog.StartRow.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false);
shinfo[2] = new ColumnInfo(BaseMessages.getString(PKG, "ExcelInputDialog.StartColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false);
wSheetnameList = new TableView(transMeta, wSheetComp, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER, shinfo, input.getSheetName().length, lsMod, props);
props.setLook(wSheetnameList);
fdFilenameList = new FormData();
fdFilenameList.left = new FormAttachment(middle, 0);
fdFilenameList.right = new FormAttachment(100, 0);
fdFilenameList.top = new FormAttachment(0, 0);
fdFilenameList.bottom = new FormAttachment(wbGetSheets, -margin);
wSheetnameList.setLayoutData(fdFilenameList);
wSheetnameList.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
checkAlerts();
}
});
fdSheetComp = new FormData();
fdSheetComp.left = new FormAttachment(0, 0);
fdSheetComp.top = new FormAttachment(0, 0);
fdSheetComp.right = new FormAttachment(100, 0);
fdSheetComp.bottom = new FormAttachment(100, 0);
wSheetComp.setLayoutData(fdSheetComp);
wSheetComp.layout();
wSheetTab.setControl(wSheetComp);
//
// / END OF SHEET TAB
//
//
// START OF CONTENT TAB/
// /
wContentTab = new CTabItem(wTabFolder, SWT.NONE);
wContentTab.setText(BaseMessages.getString(PKG, "ExcelInputDialog.ContentTab.TabTitle"));
FormLayout contentLayout = new FormLayout();
contentLayout.marginWidth = 3;
contentLayout.marginHeight = 3;
wContentComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wContentComp);
wContentComp.setLayout(contentLayout);
// Header checkbox
wlHeader = new Label(wContentComp, SWT.RIGHT);
wlHeader.setText(BaseMessages.getString(PKG, "ExcelInputDialog.Header.Label"));
props.setLook(wlHeader);
fdlHeader = new FormData();
fdlHeader.left = new FormAttachment(0, 0);
fdlHeader.top = new FormAttachment(0, 0);
fdlHeader.right = new FormAttachment(middle, -margin);
wlHeader.setLayoutData(fdlHeader);
wHeader = new Button(wContentComp, SWT.CHECK);
props.setLook(wHeader);
fdHeader = new FormData();
fdHeader.left = new FormAttachment(middle, 0);
fdHeader.top = new FormAttachment(0, 0);
fdHeader.right = new FormAttachment(100, 0);
wHeader.setLayoutData(fdHeader);
wHeader.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
setFlags();
input.setChanged();
}
});
wlNoempty = new Label(wContentComp, SWT.RIGHT);
wlNoempty.setText(BaseMessages.getString(PKG, "ExcelInputDialog.NoEmpty.Label"));
props.setLook(wlNoempty);
fdlNoempty = new FormData();
fdlNoempty.left = new FormAttachment(0, 0);
fdlNoempty.top = new FormAttachment(wHeader, margin);
fdlNoempty.right = new FormAttachment(middle, -margin);
wlNoempty.setLayoutData(fdlNoempty);
wNoempty = new Button(wContentComp, SWT.CHECK);
props.setLook(wNoempty);
wNoempty.setToolTipText(BaseMessages.getString(PKG, "ExcelInputDialog.NoEmpty.Tooltip"));
fdNoempty = new FormData();
fdNoempty.left = new FormAttachment(middle, 0);
fdNoempty.top = new FormAttachment(wHeader, margin);
fdNoempty.right = new FormAttachment(100, 0);
wNoempty.setLayoutData(fdNoempty);
wNoempty.addSelectionListener(new ComponentSelectionListener(input));
wlStoponempty = new Label(wContentComp, SWT.RIGHT);
wlStoponempty.setText(BaseMessages.getString(PKG, "ExcelInputDialog.StopOnEmpty.Label"));
props.setLook(wlStoponempty);
fdlStoponempty = new FormData();
fdlStoponempty.left = new FormAttachment(0, 0);
fdlStoponempty.top = new FormAttachment(wNoempty, margin);
fdlStoponempty.right = new FormAttachment(middle, -margin);
wlStoponempty.setLayoutData(fdlStoponempty);
wStoponempty = new Button(wContentComp, SWT.CHECK);
props.setLook(wStoponempty);
wStoponempty.setToolTipText(BaseMessages.getString(PKG, "ExcelInputDialog.StopOnEmpty.Tooltip"));
fdStoponempty = new FormData();
fdStoponempty.left = new FormAttachment(middle, 0);
fdStoponempty.top = new FormAttachment(wNoempty, margin);
fdStoponempty.right = new FormAttachment(100, 0);
wStoponempty.setLayoutData(fdStoponempty);
wStoponempty.addSelectionListener(new ComponentSelectionListener(input));
wlLimit = new Label(wContentComp, SWT.RIGHT);
wlLimit.setText(BaseMessages.getString(PKG, "ExcelInputDialog.Limit.Label"));
props.setLook(wlLimit);
fdlLimit = new FormData();
fdlLimit.left = new FormAttachment(0, 0);
fdlLimit.top = new FormAttachment(wStoponempty, margin);
fdlLimit.right = new FormAttachment(middle, -margin);
wlLimit.setLayoutData(fdlLimit);
wLimit = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wLimit);
wLimit.addModifyListener(lsMod);
fdLimit = new FormData();
fdLimit.left = new FormAttachment(middle, 0);
fdLimit.top = new FormAttachment(wStoponempty, margin);
fdLimit.right = new FormAttachment(100, 0);
wLimit.setLayoutData(fdLimit);
wlEncoding = new Label(wContentComp, SWT.RIGHT);
wlEncoding.setText(BaseMessages.getString(PKG, "ExcelInputDialog.Encoding.Label"));
props.setLook(wlEncoding);
fdlEncoding = new FormData();
fdlEncoding.left = new FormAttachment(0, 0);
fdlEncoding.top = new FormAttachment(wLimit, margin);
fdlEncoding.right = new FormAttachment(middle, -margin);
wlEncoding.setLayoutData(fdlEncoding);
wEncoding = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
wEncoding.setEditable(true);
props.setLook(wEncoding);
wEncoding.addModifyListener(lsMod);
fdEncoding = new FormData();
fdEncoding.left = new FormAttachment(middle, 0);
fdEncoding.top = new FormAttachment(wLimit, margin);
fdEncoding.right = new FormAttachment(100, 0);
wEncoding.setLayoutData(fdEncoding);
wEncoding.addFocusListener(new FocusListener() {
@Override
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
}
@Override
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();
}
});
//
// START OF AddFileResult GROUP
//
wAddFileResult = new Group(wContentComp, SWT.SHADOW_NONE);
props.setLook(wAddFileResult);
wAddFileResult.setText(BaseMessages.getString(PKG, "ExcelInputDialog.AddFileResult.Label"));
FormLayout AddFileResultgroupLayout = new FormLayout();
AddFileResultgroupLayout.marginWidth = 10;
AddFileResultgroupLayout.marginHeight = 10;
wAddFileResult.setLayout(AddFileResultgroupLayout);
wlAddResult = new Label(wAddFileResult, SWT.RIGHT);
wlAddResult.setText(BaseMessages.getString(PKG, "ExcelInputDialog.AddResult.Label"));
props.setLook(wlAddResult);
fdlAddResult = new FormData();
fdlAddResult.left = new FormAttachment(0, 0);
fdlAddResult.top = new FormAttachment(wEncoding, margin);
fdlAddResult.right = new FormAttachment(middle, -margin);
wlAddResult.setLayoutData(fdlAddResult);
wAddResult = new Button(wAddFileResult, SWT.CHECK);
props.setLook(wAddResult);
wAddResult.setToolTipText(BaseMessages.getString(PKG, "ExcelInputDialog.AddResult.Tooltip"));
fdAddResult = new FormData();
fdAddResult.left = new FormAttachment(middle, 0);
fdAddResult.top = new FormAttachment(wEncoding, margin);
wAddResult.setLayoutData(fdAddResult);
wAddResult.addSelectionListener(new ComponentSelectionListener(input));
fdAddFileResult = new FormData();
fdAddFileResult.left = new FormAttachment(0, margin);
fdAddFileResult.top = new FormAttachment(wEncoding, margin);
fdAddFileResult.right = new FormAttachment(100, -margin);
wAddFileResult.setLayoutData(fdAddFileResult);
//
// / END OF AddFileResult 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(fdContentComp);
wContentComp.layout();
wContentTab.setControl(wContentComp);
//
// / END OF CONTENT TAB
//
//
// / START OF CONTENT TAB
//
addErrorTab();
// Fields tab...
//
wFieldsTab = new CTabItem(wTabFolder, SWT.NONE);
wFieldsTab.setText(BaseMessages.getString(PKG, "ExcelInputDialog.FieldsTab.TabTitle"));
FormLayout fieldsLayout = new FormLayout();
fieldsLayout.marginWidth = Const.FORM_MARGIN;
fieldsLayout.marginHeight = Const.FORM_MARGIN;
wFieldsComp = new Composite(wTabFolder, SWT.NONE);
wFieldsComp.setLayout(fieldsLayout);
wbGetFields = new Button(wFieldsComp, SWT.PUSH | SWT.CENTER);
props.setLook(wbGetFields);
wbGetFields.setText(BaseMessages.getString(PKG, "ExcelInputDialog.GetFields.Button"));
setButtonPositions(new Button[] { wbGetFields }, margin, null);
final int FieldsRows = input.getField().length;
int FieldsWidth = 600;
int FieldsHeight = 150;
ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "ExcelInputDialog.Name.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ExcelInputDialog.Type.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames()), new ColumnInfo(BaseMessages.getString(PKG, "ExcelInputDialog.Length.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ExcelInputDialog.Precision.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ExcelInputDialog.TrimType.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaString.trimTypeDesc), new ColumnInfo(BaseMessages.getString(PKG, "ExcelInputDialog.Repeat.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { BaseMessages.getString(PKG, "System.Combo.Yes"), BaseMessages.getString(PKG, "System.Combo.No") }), new ColumnInfo(BaseMessages.getString(PKG, "ExcelInputDialog.Format.Column"), ColumnInfo.COLUMN_TYPE_FORMAT, 2), new ColumnInfo(BaseMessages.getString(PKG, "ExcelInputDialog.Currency.Column"), ColumnInfo.COLUMN_TYPE_TEXT), new ColumnInfo(BaseMessages.getString(PKG, "ExcelInputDialog.Decimal.Column"), ColumnInfo.COLUMN_TYPE_TEXT), new ColumnInfo(BaseMessages.getString(PKG, "ExcelInputDialog.Grouping.Column"), ColumnInfo.COLUMN_TYPE_TEXT) };
colinf[5].setToolTip(BaseMessages.getString(PKG, "ExcelInputDialog.Repeat.Tooltip"));
wFields = new TableView(transMeta, wFieldsComp, SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod, props);
wFields.setSize(FieldsWidth, FieldsHeight);
wFields.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
checkAlerts();
}
});
fdFields = new FormData();
fdFields.left = new FormAttachment(0, 0);
fdFields.top = new FormAttachment(0, 0);
fdFields.right = new FormAttachment(100, 0);
fdFields.bottom = new FormAttachment(wbGetFields, -margin);
wFields.setLayoutData(fdFields);
fdFieldsComp = new FormData();
fdFieldsComp.left = new FormAttachment(0, 0);
fdFieldsComp.top = new FormAttachment(0, 0);
fdFieldsComp.right = new FormAttachment(100, 0);
fdFieldsComp.bottom = new FormAttachment(100, 0);
wFieldsComp.setLayoutData(fdFieldsComp);
wFieldsComp.layout();
wFieldsTab.setControl(wFieldsComp);
props.setLook(wFieldsComp);
addAdditionalFieldsTab();
fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(wlStatusMessage, margin);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(100, -50);
wTabFolder.setLayoutData(fdTabFolder);
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wPreview = new Button(shell, SWT.PUSH);
wPreview.setText(BaseMessages.getString(PKG, "ExcelInputDialog.PreviewRows.Button"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOK, wPreview, wCancel }, margin, wTabFolder);
// Add listeners
lsOK = new Listener() {
@Override
public void handleEvent(Event e) {
ok();
}
};
lsPreview = new Listener() {
@Override
public void handleEvent(Event e) {
preview();
}
};
lsCancel = new Listener() {
@Override
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wPreview.addListener(SWT.Selection, lsPreview);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wFilename.addSelectionListener(lsDef);
wLimit.addSelectionListener(lsDef);
wInclRownumField.addSelectionListener(lsDef);
wInclFilenameField.addSelectionListener(lsDef);
wInclSheetnameField.addSelectionListener(lsDef);
wAccField.addSelectionListener(lsDef);
// Add the file to the list of files...
SelectionAdapter selA = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
wFilenameList.add(new String[] { wFilename.getText(), wFilemask.getText(), wExcludeFilemask.getText(), ExcelInputMeta.RequiredFilesCode[0], ExcelInputMeta.RequiredFilesCode[0] });
wFilename.setText("");
wFilemask.setText("");
wExcludeFilemask.setText("");
wFilenameList.removeEmptyRows();
wFilenameList.setRowNums();
wFilenameList.optWidth(true);
checkAlerts();
}
};
wbaFilename.addSelectionListener(selA);
wFilename.addSelectionListener(selA);
// Delete files from the list of files...
wbdFilename.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
int[] idx = wFilenameList.getSelectionIndices();
wFilenameList.remove(idx);
wFilenameList.removeEmptyRows();
wFilenameList.setRowNums();
checkAlerts();
}
});
// Edit the selected file & remove from the list...
wbeFilename.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
int idx = wFilenameList.getSelectionIndex();
if (idx >= 0) {
String[] string = wFilenameList.getItem(idx);
wFilename.setText(string[0]);
wFilemask.setText(string[1]);
wExcludeFilemask.setText(string[2]);
wFilenameList.remove(idx);
}
wFilenameList.removeEmptyRows();
wFilenameList.setRowNums();
}
});
// Show the files that are selected at this time...
wbShowFiles.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
showFiles();
}
});
// Whenever something changes, set the tooltip to the expanded version of the filename:
wFilename.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
wFilename.setToolTipText(transMeta.environmentSubstitute(wFilename.getText()));
}
});
// Listen to the Browse... button
wbbFilename.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (!Utils.isEmpty(wFilemask.getText()) || !Utils.isEmpty(wExcludeFilemask.getText())) {
// A mask: a directory!
DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN);
if (wFilename.getText() != null) {
String fpath = transMeta.environmentSubstitute(wFilename.getText());
dialog.setFilterPath(fpath);
}
if (dialog.open() != null) {
String str = dialog.getFilterPath();
wFilename.setText(str);
}
} else {
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
String[] extentions = new String[] { "*.xls;*.XLS", "*" };
SpreadSheetType type = SpreadSheetType.getStpreadSheetTypeByDescription(wSpreadSheetType.getText());
switch(type) {
case POI:
extentions = new String[] { "*.xls;*.XLS;*.xlsx;*.XLSX", "*" };
break;
case SAX_POI:
extentions = new String[] { "*.xlsx;*.XLSX", "*" };
break;
case ODS:
extentions = new String[] { "*.ods;*.ODS;", "*" };
break;
case JXL:
default:
extentions = new String[] { "*.xls;*.XLS", "*" };
break;
}
dialog.setFilterExtensions(extentions);
if (wFilename.getText() != null) {
String fname = transMeta.environmentSubstitute(wFilename.getText());
dialog.setFileName(fname);
}
dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "ExcelInputDialog.FilterNames.ExcelFiles"), BaseMessages.getString(PKG, "System.FileType.AllFiles") });
if (dialog.open() != null) {
String str = dialog.getFilterPath() + System.getProperty("file.separator") + dialog.getFileName();
wFilename.setText(str);
}
}
}
});
// Get a list of the sheetnames.
wbGetSheets.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
getSheets();
}
});
wbGetFields.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
getFields();
}
});
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
@Override
public void shellClosed(ShellEvent e) {
cancel();
}
});
wTabFolder.setSelection(0);
// Set the shell size, based upon previous time...
setSize();
getData(input);
input.setChanged(changed);
wFields.optWidth(true);
// resyncing after setup
checkAlerts();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.trans.step.ComponentSelectionListener in project pentaho-kettle by pentaho.
the class HTTPPOSTDialog 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();
}
};
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, "HTTPPOSTDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.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);
wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, PropsUI.WIDGET_STYLE_TAB);
// ////////////////////////
// START OF GENERAL TAB ///
// ////////////////////////
wGeneralTab = new CTabItem(wTabFolder, SWT.NONE);
wGeneralTab.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.GeneralTab.Title"));
wGeneralComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wGeneralComp);
FormLayout fileLayout = new FormLayout();
fileLayout.marginWidth = 3;
fileLayout.marginHeight = 3;
wGeneralComp.setLayout(fileLayout);
// ////////////////////////
// START Settings GROUP
Group gSettings = new Group(wGeneralComp, SWT.SHADOW_ETCHED_IN);
gSettings.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.SettingsGroup.Label"));
FormLayout SettingsLayout = new FormLayout();
SettingsLayout.marginWidth = 3;
SettingsLayout.marginHeight = 3;
gSettings.setLayout(SettingsLayout);
props.setLook(gSettings);
wlUrl = new Label(gSettings, SWT.RIGHT);
wlUrl.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.URL.Label"));
props.setLook(wlUrl);
fdlUrl = new FormData();
fdlUrl.left = new FormAttachment(0, 0);
fdlUrl.right = new FormAttachment(middle, -margin);
fdlUrl.top = new FormAttachment(wStepname, margin);
wlUrl.setLayoutData(fdlUrl);
wUrl = new TextVar(transMeta, gSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wUrl);
wUrl.addModifyListener(lsMod);
fdUrl = new FormData();
fdUrl.left = new FormAttachment(middle, 0);
fdUrl.top = new FormAttachment(wStepname, margin);
fdUrl.right = new FormAttachment(100, 0);
wUrl.setLayoutData(fdUrl);
// UrlInField line
wlUrlInField = new Label(gSettings, SWT.RIGHT);
wlUrlInField.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.UrlInField.Label"));
props.setLook(wlUrlInField);
fdlUrlInField = new FormData();
fdlUrlInField.left = new FormAttachment(0, 0);
fdlUrlInField.top = new FormAttachment(wUrl, margin);
fdlUrlInField.right = new FormAttachment(middle, -margin);
wlUrlInField.setLayoutData(fdlUrlInField);
wUrlInField = new Button(gSettings, SWT.CHECK);
props.setLook(wUrlInField);
fdUrlInField = new FormData();
fdUrlInField.left = new FormAttachment(middle, 0);
fdUrlInField.top = new FormAttachment(wUrl, margin);
fdUrlInField.right = new FormAttachment(100, 0);
wUrlInField.setLayoutData(fdUrlInField);
wUrlInField.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
activeUrlInfield();
}
});
// UrlField Line
wlUrlField = new Label(gSettings, SWT.RIGHT);
wlUrlField.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.UrlField.Label"));
props.setLook(wlUrlField);
fdlUrlField = new FormData();
fdlUrlField.left = new FormAttachment(0, 0);
fdlUrlField.right = new FormAttachment(middle, -margin);
fdlUrlField.top = new FormAttachment(wUrlInField, margin);
wlUrlField.setLayoutData(fdlUrlField);
wUrlField = new ComboVar(transMeta, gSettings, SWT.BORDER | SWT.READ_ONLY);
wUrlField.setEditable(true);
props.setLook(wUrlField);
wUrlField.addModifyListener(lsMod);
fdUrlField = new FormData();
fdUrlField.left = new FormAttachment(middle, 0);
fdUrlField.top = new FormAttachment(wUrlInField, margin);
fdUrlField.right = new FormAttachment(100, -margin);
wUrlField.setLayoutData(fdUrlField);
wUrlField.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);
setStreamFields();
shell.setCursor(null);
busy.dispose();
}
});
wlEncoding = new Label(gSettings, SWT.RIGHT);
wlEncoding.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.Encoding.Label"));
props.setLook(wlEncoding);
fdlEncoding = new FormData();
fdlEncoding.left = new FormAttachment(0, 0);
fdlEncoding.top = new FormAttachment(wUrlField, margin);
fdlEncoding.right = new FormAttachment(middle, -margin);
wlEncoding.setLayoutData(fdlEncoding);
wEncoding = new ComboVar(transMeta, gSettings, 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(wUrlField, margin);
fdEncoding.right = new FormAttachment(100, -margin);
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();
}
});
// requestEntity Line
wlrequestEntity = new Label(gSettings, SWT.RIGHT);
wlrequestEntity.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.requestEntity.Label"));
props.setLook(wlrequestEntity);
fdlrequestEntity = new FormData();
fdlrequestEntity.left = new FormAttachment(0, 0);
fdlrequestEntity.right = new FormAttachment(middle, -margin);
fdlrequestEntity.top = new FormAttachment(wEncoding, margin);
wlrequestEntity.setLayoutData(fdlrequestEntity);
wrequestEntity = new ComboVar(transMeta, gSettings, SWT.BORDER | SWT.READ_ONLY);
wrequestEntity.setEditable(true);
props.setLook(wrequestEntity);
wrequestEntity.addModifyListener(lsMod);
fdrequestEntity = new FormData();
fdrequestEntity.left = new FormAttachment(middle, 0);
fdrequestEntity.top = new FormAttachment(wEncoding, margin);
fdrequestEntity.right = new FormAttachment(100, -margin);
wrequestEntity.setLayoutData(fdrequestEntity);
wrequestEntity.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);
setStreamFields();
shell.setCursor(null);
busy.dispose();
}
});
// Post file?
wlPostAFile = new Label(gSettings, SWT.RIGHT);
wlPostAFile.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.postAFile.Label"));
props.setLook(wlPostAFile);
FormData fdlPostAFile = new FormData();
fdlPostAFile.left = new FormAttachment(0, 0);
fdlPostAFile.right = new FormAttachment(middle, -margin);
fdlPostAFile.top = new FormAttachment(wrequestEntity, margin);
wlPostAFile.setLayoutData(fdlPostAFile);
wPostAFile = new Button(gSettings, SWT.CHECK);
wPostAFile.setToolTipText(BaseMessages.getString(PKG, "HTTPPOSTDialog.postAFile.Tooltip"));
props.setLook(wPostAFile);
FormData fdPostAFile = new FormData();
fdPostAFile.left = new FormAttachment(middle, 0);
fdPostAFile.top = new FormAttachment(wrequestEntity, margin);
fdPostAFile.right = new FormAttachment(100, 0);
wPostAFile.setLayoutData(fdPostAFile);
wPostAFile.addSelectionListener(new ComponentSelectionListener(input));
wlConnectionTimeOut = new Label(gSettings, SWT.RIGHT);
wlConnectionTimeOut.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.ConnectionTimeOut.Label"));
props.setLook(wlConnectionTimeOut);
FormData fdlConnectionTimeOut = new FormData();
fdlConnectionTimeOut.top = new FormAttachment(wPostAFile, margin);
fdlConnectionTimeOut.left = new FormAttachment(0, 0);
fdlConnectionTimeOut.right = new FormAttachment(middle, -margin);
wlConnectionTimeOut.setLayoutData(fdlConnectionTimeOut);
wConnectionTimeOut = new TextVar(transMeta, gSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wConnectionTimeOut.addModifyListener(lsMod);
wConnectionTimeOut.setToolTipText(BaseMessages.getString(PKG, "HTTPPOSTDialog.ConnectionTimeOut.Tooltip"));
props.setLook(wConnectionTimeOut);
FormData fdConnectionTimeOut = new FormData();
fdConnectionTimeOut.top = new FormAttachment(wPostAFile, margin);
fdConnectionTimeOut.left = new FormAttachment(middle, 0);
fdConnectionTimeOut.right = new FormAttachment(100, 0);
wConnectionTimeOut.setLayoutData(fdConnectionTimeOut);
wlSocketTimeOut = new Label(gSettings, SWT.RIGHT);
wlSocketTimeOut.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.SocketTimeOut.Label"));
props.setLook(wlSocketTimeOut);
FormData fdlSocketTimeOut = new FormData();
fdlSocketTimeOut.top = new FormAttachment(wConnectionTimeOut, margin);
fdlSocketTimeOut.left = new FormAttachment(0, 0);
fdlSocketTimeOut.right = new FormAttachment(middle, -margin);
wlSocketTimeOut.setLayoutData(fdlSocketTimeOut);
wSocketTimeOut = new TextVar(transMeta, gSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wSocketTimeOut.addModifyListener(lsMod);
wSocketTimeOut.setToolTipText(BaseMessages.getString(PKG, "HTTPPOSTDialog.SocketTimeOut.Tooltip"));
props.setLook(wSocketTimeOut);
FormData fdSocketTimeOut = new FormData();
fdSocketTimeOut.top = new FormAttachment(wConnectionTimeOut, margin);
fdSocketTimeOut.left = new FormAttachment(middle, 0);
fdSocketTimeOut.right = new FormAttachment(100, 0);
wSocketTimeOut.setLayoutData(fdSocketTimeOut);
wlCloseIdleConnectionsTime = new Label(gSettings, SWT.RIGHT);
wlCloseIdleConnectionsTime.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.CloseIdleConnectionsTime.Label"));
props.setLook(wlCloseIdleConnectionsTime);
FormData fdlCloseIdleConnectionsTime = new FormData();
fdlCloseIdleConnectionsTime.top = new FormAttachment(wSocketTimeOut, margin);
fdlCloseIdleConnectionsTime.left = new FormAttachment(0, 0);
fdlCloseIdleConnectionsTime.right = new FormAttachment(middle, -margin);
wlCloseIdleConnectionsTime.setLayoutData(fdlCloseIdleConnectionsTime);
wCloseIdleConnectionsTime = new TextVar(transMeta, gSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wCloseIdleConnectionsTime.addModifyListener(lsMod);
wCloseIdleConnectionsTime.setToolTipText(BaseMessages.getString(PKG, "HTTPPOSTDialog.CloseIdleConnectionsTime.Tooltip"));
props.setLook(wCloseIdleConnectionsTime);
FormData fdCloseIdleConnectionsTime = new FormData();
fdCloseIdleConnectionsTime.top = new FormAttachment(wSocketTimeOut, margin);
fdCloseIdleConnectionsTime.left = new FormAttachment(middle, 0);
fdCloseIdleConnectionsTime.right = new FormAttachment(100, 0);
wCloseIdleConnectionsTime.setLayoutData(fdCloseIdleConnectionsTime);
FormData fdSettings = new FormData();
fdSettings.left = new FormAttachment(0, 0);
fdSettings.right = new FormAttachment(100, 0);
fdSettings.top = new FormAttachment(wStepname, margin);
gSettings.setLayoutData(fdSettings);
// END Output Settings GROUP
// ////////////////////////
// ////////////////////////
// START Output Fields GROUP
Group gOutputFields = new Group(wGeneralComp, SWT.SHADOW_ETCHED_IN);
gOutputFields.setText(BaseMessages.getString(PKG, "HTTPDialog.OutputFieldsGroup.Label"));
FormLayout OutputFieldsLayout = new FormLayout();
OutputFieldsLayout.marginWidth = 3;
OutputFieldsLayout.marginHeight = 3;
gOutputFields.setLayout(OutputFieldsLayout);
props.setLook(gOutputFields);
// Result line...
wlResult = new Label(gOutputFields, SWT.RIGHT);
wlResult.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.Result.Label"));
props.setLook(wlResult);
fdlResult = new FormData();
fdlResult.left = new FormAttachment(0, 0);
fdlResult.right = new FormAttachment(middle, -margin);
fdlResult.top = new FormAttachment(wPostAFile, margin);
wlResult.setLayoutData(fdlResult);
wResult = new TextVar(transMeta, gOutputFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wResult);
wResult.addModifyListener(lsMod);
fdResult = new FormData();
fdResult.left = new FormAttachment(middle, 0);
fdResult.top = new FormAttachment(wPostAFile, margin);
fdResult.right = new FormAttachment(100, -margin);
wResult.setLayoutData(fdResult);
// Resultcode line...
wlResultCode = new Label(gOutputFields, SWT.RIGHT);
wlResultCode.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.ResultCode.Label"));
props.setLook(wlResultCode);
fdlResultCode = new FormData();
fdlResultCode.left = new FormAttachment(0, 0);
fdlResultCode.right = new FormAttachment(middle, -margin);
fdlResultCode.top = new FormAttachment(wResult, margin);
wlResultCode.setLayoutData(fdlResultCode);
wResultCode = new TextVar(transMeta, gOutputFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wResultCode);
wResultCode.addModifyListener(lsMod);
fdResultCode = new FormData();
fdResultCode.left = new FormAttachment(middle, 0);
fdResultCode.top = new FormAttachment(wResult, margin);
fdResultCode.right = new FormAttachment(100, -margin);
wResultCode.setLayoutData(fdResultCode);
// Response time line...
wlResponseTime = new Label(gOutputFields, SWT.RIGHT);
wlResponseTime.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.ResponseTime.Label"));
props.setLook(wlResponseTime);
fdlResponseTime = new FormData();
fdlResponseTime.left = new FormAttachment(0, 0);
fdlResponseTime.right = new FormAttachment(middle, -margin);
fdlResponseTime.top = new FormAttachment(wResultCode, margin);
wlResponseTime.setLayoutData(fdlResponseTime);
wResponseTime = new TextVar(transMeta, gOutputFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wResponseTime);
wResponseTime.addModifyListener(lsMod);
fdResponseTime = new FormData();
fdResponseTime.left = new FormAttachment(middle, 0);
fdResponseTime.top = new FormAttachment(wResultCode, margin);
fdResponseTime.right = new FormAttachment(100, 0);
wResponseTime.setLayoutData(fdResponseTime);
// Response header line...
wlResponseHeader = new Label(gOutputFields, SWT.RIGHT);
wlResponseHeader.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.ResponseHeader.Label"));
props.setLook(wlResponseHeader);
fdlResponseHeader = new FormData();
fdlResponseHeader.left = new FormAttachment(0, 0);
fdlResponseHeader.right = new FormAttachment(middle, -margin);
fdlResponseHeader.top = new FormAttachment(wResponseTime, margin);
wlResponseHeader.setLayoutData(fdlResponseHeader);
wResponseHeader = new TextVar(transMeta, gOutputFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wResponseHeader);
wResponseHeader.addModifyListener(lsMod);
fdResponseHeader = new FormData();
fdResponseHeader.left = new FormAttachment(middle, 0);
fdResponseHeader.top = new FormAttachment(wResponseTime, margin);
fdResponseHeader.right = new FormAttachment(100, 0);
wResponseHeader.setLayoutData(fdResponseHeader);
FormData fdOutputFields = new FormData();
fdOutputFields.left = new FormAttachment(0, 0);
fdOutputFields.right = new FormAttachment(100, 0);
fdOutputFields.top = new FormAttachment(gSettings, margin);
gOutputFields.setLayoutData(fdOutputFields);
// END Output Fields GROUP
// ////////////////////////
// ////////////////////////
// START HTTP AUTH GROUP
Group gHttpAuth = new Group(wGeneralComp, SWT.SHADOW_ETCHED_IN);
gHttpAuth.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.HttpAuthGroup.Label"));
FormLayout httpAuthLayout = new FormLayout();
httpAuthLayout.marginWidth = 3;
httpAuthLayout.marginHeight = 3;
gHttpAuth.setLayout(httpAuthLayout);
props.setLook(gHttpAuth);
// HTTP Login
wlHttpLogin = new Label(gHttpAuth, SWT.RIGHT);
wlHttpLogin.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.HttpLogin.Label"));
props.setLook(wlHttpLogin);
FormData fdlHttpLogin = new FormData();
fdlHttpLogin.top = new FormAttachment(0, margin);
fdlHttpLogin.left = new FormAttachment(0, 0);
fdlHttpLogin.right = new FormAttachment(middle, -margin);
wlHttpLogin.setLayoutData(fdlHttpLogin);
wHttpLogin = new TextVar(transMeta, gHttpAuth, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wHttpLogin.addModifyListener(lsMod);
wHttpLogin.setToolTipText(BaseMessages.getString(PKG, "HTTPPOSTDialog.HttpLogin.Tooltip"));
props.setLook(wHttpLogin);
FormData fdHttpLogin = new FormData();
fdHttpLogin.top = new FormAttachment(0, margin);
fdHttpLogin.left = new FormAttachment(middle, 0);
fdHttpLogin.right = new FormAttachment(100, 0);
wHttpLogin.setLayoutData(fdHttpLogin);
// HTTP Password
wlHttpPassword = new Label(gHttpAuth, SWT.RIGHT);
wlHttpPassword.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.HttpPassword.Label"));
props.setLook(wlHttpPassword);
FormData fdlHttpPassword = new FormData();
fdlHttpPassword.top = new FormAttachment(wHttpLogin, margin);
fdlHttpPassword.left = new FormAttachment(0, 0);
fdlHttpPassword.right = new FormAttachment(middle, -margin);
wlHttpPassword.setLayoutData(fdlHttpPassword);
wHttpPassword = new PasswordTextVar(transMeta, gHttpAuth, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wHttpPassword.addModifyListener(lsMod);
wHttpPassword.setToolTipText(BaseMessages.getString(PKG, "HTTPPOSTDialog.HttpPassword.Tooltip"));
props.setLook(wHttpPassword);
FormData fdHttpPassword = new FormData();
fdHttpPassword.top = new FormAttachment(wHttpLogin, margin);
fdHttpPassword.left = new FormAttachment(middle, 0);
fdHttpPassword.right = new FormAttachment(100, 0);
wHttpPassword.setLayoutData(fdHttpPassword);
FormData fdHttpAuth = new FormData();
fdHttpAuth.left = new FormAttachment(0, 0);
fdHttpAuth.right = new FormAttachment(100, 0);
fdHttpAuth.top = new FormAttachment(gOutputFields, margin);
gHttpAuth.setLayoutData(fdHttpAuth);
// END HTTP AUTH GROUP
// ////////////////////////
// ////////////////////////
// START PROXY GROUP
Group gProxy = new Group(wGeneralComp, SWT.SHADOW_ETCHED_IN);
gProxy.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.ProxyGroup.Label"));
FormLayout proxyLayout = new FormLayout();
proxyLayout.marginWidth = 3;
proxyLayout.marginHeight = 3;
gProxy.setLayout(proxyLayout);
props.setLook(gProxy);
// HTTP Login
wlProxyHost = new Label(gProxy, SWT.RIGHT);
wlProxyHost.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.ProxyHost.Label"));
props.setLook(wlProxyHost);
FormData fdlProxyHost = new FormData();
fdlProxyHost.top = new FormAttachment(0, margin);
fdlProxyHost.left = new FormAttachment(0, 0);
fdlProxyHost.right = new FormAttachment(middle, -margin);
wlProxyHost.setLayoutData(fdlProxyHost);
wProxyHost = new TextVar(transMeta, gProxy, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wProxyHost.addModifyListener(lsMod);
wProxyHost.setToolTipText(BaseMessages.getString(PKG, "HTTPPOSTDialog.ProxyHost.Tooltip"));
props.setLook(wProxyHost);
FormData fdProxyHost = new FormData();
fdProxyHost.top = new FormAttachment(0, margin);
fdProxyHost.left = new FormAttachment(middle, 0);
fdProxyHost.right = new FormAttachment(100, 0);
wProxyHost.setLayoutData(fdProxyHost);
// HTTP Password
wlProxyPort = new Label(gProxy, SWT.RIGHT);
wlProxyPort.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.ProxyPort.Label"));
props.setLook(wlProxyPort);
FormData fdlProxyPort = new FormData();
fdlProxyPort.top = new FormAttachment(wProxyHost, margin);
fdlProxyPort.left = new FormAttachment(0, 0);
fdlProxyPort.right = new FormAttachment(middle, -margin);
wlProxyPort.setLayoutData(fdlProxyPort);
wProxyPort = new TextVar(transMeta, gProxy, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wProxyPort.addModifyListener(lsMod);
wProxyPort.setToolTipText(BaseMessages.getString(PKG, "HTTPPOSTDialog.ProxyPort.Tooltip"));
props.setLook(wProxyPort);
FormData fdProxyPort = new FormData();
fdProxyPort.top = new FormAttachment(wProxyHost, margin);
fdProxyPort.left = new FormAttachment(middle, 0);
fdProxyPort.right = new FormAttachment(100, 0);
wProxyPort.setLayoutData(fdProxyPort);
FormData fdProxy = new FormData();
fdProxy.left = new FormAttachment(0, 0);
fdProxy.right = new FormAttachment(100, 0);
fdProxy.top = new FormAttachment(gHttpAuth, margin);
gProxy.setLayoutData(fdProxy);
// END HTTP AUTH GROUP
// ////////////////////////
fdGeneralComp = new FormData();
fdGeneralComp.left = new FormAttachment(0, 0);
fdGeneralComp.top = new FormAttachment(wStepname, margin);
fdGeneralComp.right = new FormAttachment(100, 0);
fdGeneralComp.bottom = new FormAttachment(100, 0);
wGeneralComp.setLayoutData(fdGeneralComp);
wGeneralComp.layout();
wGeneralTab.setControl(wGeneralComp);
// ///////////////////////////////////////////////////////////
// / END OF GENERAL TAB
// ///////////////////////////////////////////////////////////
// Additional tab...
//
wAdditionalTab = new CTabItem(wTabFolder, SWT.NONE);
wAdditionalTab.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.FieldsTab.Title"));
FormLayout addLayout = new FormLayout();
addLayout.marginWidth = Const.FORM_MARGIN;
addLayout.marginHeight = Const.FORM_MARGIN;
wAdditionalComp = new Composite(wTabFolder, SWT.NONE);
wAdditionalComp.setLayout(addLayout);
props.setLook(wAdditionalComp);
wlFields = new Label(wAdditionalComp, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.Parameters.Label"));
props.setLook(wlFields);
fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.top = new FormAttachment(gProxy, margin);
wlFields.setLayoutData(fdlFields);
final int FieldsRows = input.getArgumentField().length;
colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "HTTPPOSTDialog.ColumnInfo.Name"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false), new ColumnInfo(BaseMessages.getString(PKG, "HTTPPOSTDialog.ColumnInfo.Parameter"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "HTTPPOSTDialog.ColumnInfo.Header"), ColumnInfo.COLUMN_TYPE_CCOMBO, YES_NO_COMBO) };
colinf[1].setUsingVariables(true);
wFields = new TableView(transMeta, wAdditionalComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod, props);
wGetBodyParam = new Button(wAdditionalComp, SWT.PUSH);
wGetBodyParam.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.GetFields.Button"));
fdGetBodyParam = new FormData();
fdGetBodyParam.top = new FormAttachment(wlFields, margin);
fdGetBodyParam.right = new FormAttachment(100, 0);
wGetBodyParam.setLayoutData(fdGetBodyParam);
fdFields = new FormData();
fdFields.left = new FormAttachment(0, 0);
fdFields.top = new FormAttachment(wlFields, margin);
fdFields.right = new FormAttachment(wGetBodyParam, -margin);
fdFields.bottom = new FormAttachment(wlFields, 200);
wFields.setLayoutData(fdFields);
wlQuery = new Label(wAdditionalComp, SWT.NONE);
wlQuery.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.QueryParameters.Label"));
props.setLook(wlQuery);
fdlQuery = new FormData();
fdlQuery.left = new FormAttachment(0, 0);
fdlQuery.top = new FormAttachment(wFields, margin);
wlQuery.setLayoutData(fdlQuery);
final int QueryRows = input.getQueryParameter().length;
colinfquery = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "HTTPPOSTDialog.ColumnInfo.QueryName"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false), new ColumnInfo(BaseMessages.getString(PKG, "HTTPPOSTDialog.ColumnInfo.QueryParameter"), ColumnInfo.COLUMN_TYPE_TEXT, false) };
colinfquery[1].setUsingVariables(true);
wQuery = new TableView(transMeta, wAdditionalComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinfquery, QueryRows, lsMod, props);
wGet = new Button(wAdditionalComp, SWT.PUSH);
wGet.setText(BaseMessages.getString(PKG, "HTTPPOSTDialog.GetFields.Button"));
fdGet = new FormData();
fdGet.top = new FormAttachment(wlQuery, margin);
fdGet.right = new FormAttachment(100, 0);
wGet.setLayoutData(fdGet);
fdQuery = new FormData();
fdQuery.left = new FormAttachment(0, 0);
fdQuery.top = new FormAttachment(wlQuery, margin);
fdQuery.right = new FormAttachment(wGet, -margin);
fdQuery.bottom = new FormAttachment(100, -margin);
wQuery.setLayoutData(fdQuery);
//
// Search the fields in the background
//
final Runnable runnable = new Runnable() {
public void run() {
StepMeta stepMeta = transMeta.findStep(stepname);
if (stepMeta != null) {
try {
RowMetaInterface row = transMeta.getPrevStepFields(stepMeta);
// Remember these fields...
for (int i = 0; i < row.size(); i++) {
inputFields.put(row.getValueMeta(i).getName(), Integer.valueOf(i));
}
setComboBoxes();
} catch (KettleException e) {
logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
}
}
};
new Thread(runnable).start();
fdAdditionalComp = new FormData();
fdAdditionalComp.left = new FormAttachment(0, 0);
fdAdditionalComp.top = new FormAttachment(wStepname, margin);
fdAdditionalComp.right = new FormAttachment(100, 0);
fdAdditionalComp.bottom = new FormAttachment(100, 0);
wAdditionalComp.setLayoutData(fdAdditionalComp);
wAdditionalComp.layout();
wAdditionalTab.setControl(wAdditionalComp);
// ////// END of Additional 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);
// 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, wTabFolder);
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsGet = new Listener() {
public void handleEvent(Event e) {
getQueryFields();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsGetBodyParam = new Listener() {
public void handleEvent(Event e) {
get();
}
};
wOK.addListener(SWT.Selection, lsOK);
wGet.addListener(SWT.Selection, lsGet);
wCancel.addListener(SWT.Selection, lsCancel);
wGetBodyParam.addListener(SWT.Selection, lsGetBodyParam);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wUrl.addSelectionListener(lsDef);
wResult.addSelectionListener(lsDef);
wResultCode.addSelectionListener(lsDef);
wResponseTime.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
lsResize = new Listener() {
public void handleEvent(Event event) {
Point size = shell.getSize();
wFields.setSize(size.x - 10, size.y - 50);
wFields.table.setSize(size.x - 10, size.y - 50);
wFields.redraw();
}
};
shell.addListener(SWT.Resize, lsResize);
// Set the shell size, based upon previous time...
setSize();
wTabFolder.setSelection(0);
getData();
activeUrlInfield();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.trans.step.ComponentSelectionListener in project pentaho-kettle by pentaho.
the class InsertUpdateDialog 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();
}
};
ModifyListener lsTableMod = new ModifyListener() {
public void modifyText(ModifyEvent arg0) {
input.setChanged();
setTableFieldCombo();
}
};
SelectionListener lsSelection = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
setTableFieldCombo();
}
};
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, "InsertUpdateDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "InsertUpdateDialog.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);
// Connection line
wConnection = addConnectionLine(shell, wStepname, middle, margin);
if (input.getDatabaseMeta() == null && transMeta.nrDatabases() == 1) {
wConnection.select(0);
}
wConnection.addModifyListener(lsMod);
wConnection.addSelectionListener(lsSelection);
// Schema line...
wlSchema = new Label(shell, SWT.RIGHT);
wlSchema.setText(BaseMessages.getString(PKG, "InsertUpdateDialog.TargetSchema.Label"));
props.setLook(wlSchema);
fdlSchema = new FormData();
fdlSchema.left = new FormAttachment(0, 0);
fdlSchema.right = new FormAttachment(middle, -margin);
fdlSchema.top = new FormAttachment(wConnection, margin * 2);
wlSchema.setLayoutData(fdlSchema);
wbSchema = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbSchema);
wbSchema.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
fdbSchema = new FormData();
fdbSchema.top = new FormAttachment(wConnection, 2 * margin);
fdbSchema.right = new FormAttachment(100, 0);
wbSchema.setLayoutData(fdbSchema);
wSchema = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wSchema);
wSchema.addModifyListener(lsTableMod);
fdSchema = new FormData();
fdSchema.left = new FormAttachment(middle, 0);
fdSchema.top = new FormAttachment(wConnection, margin * 2);
fdSchema.right = new FormAttachment(wbSchema, -margin);
wSchema.setLayoutData(fdSchema);
// Table line...
wlTable = new Label(shell, SWT.RIGHT);
wlTable.setText(BaseMessages.getString(PKG, "InsertUpdateDialog.TargetTable.Label"));
props.setLook(wlTable);
fdlTable = new FormData();
fdlTable.left = new FormAttachment(0, 0);
fdlTable.right = new FormAttachment(middle, -margin);
fdlTable.top = new FormAttachment(wbSchema, margin);
wlTable.setLayoutData(fdlTable);
wbTable = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbTable);
wbTable.setText(BaseMessages.getString(PKG, "InsertUpdateDialog.Browse.Button"));
fdbTable = new FormData();
fdbTable.right = new FormAttachment(100, 0);
fdbTable.top = new FormAttachment(wbSchema, margin);
wbTable.setLayoutData(fdbTable);
wTable = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wTable);
wTable.addModifyListener(lsTableMod);
fdTable = new FormData();
fdTable.left = new FormAttachment(middle, 0);
fdTable.top = new FormAttachment(wbSchema, margin);
fdTable.right = new FormAttachment(wbTable, -margin);
wTable.setLayoutData(fdTable);
// Commit line
wlCommit = new Label(shell, SWT.RIGHT);
wlCommit.setText(BaseMessages.getString(PKG, "InsertUpdateDialog.CommitSize.Label"));
props.setLook(wlCommit);
fdlCommit = new FormData();
fdlCommit.left = new FormAttachment(0, 0);
fdlCommit.top = new FormAttachment(wTable, margin);
fdlCommit.right = new FormAttachment(middle, -margin);
wlCommit.setLayoutData(fdlCommit);
wCommit = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wCommit);
wCommit.addModifyListener(lsMod);
fdCommit = new FormData();
fdCommit.left = new FormAttachment(middle, 0);
fdCommit.top = new FormAttachment(wTable, margin);
fdCommit.right = new FormAttachment(100, 0);
wCommit.setLayoutData(fdCommit);
// UpdateBypassed line
wlUpdateBypassed = new Label(shell, SWT.RIGHT);
wlUpdateBypassed.setText(BaseMessages.getString(PKG, "InsertUpdateDialog.UpdateBypassed.Label"));
props.setLook(wlUpdateBypassed);
fdlUpdateBypassed = new FormData();
fdlUpdateBypassed.left = new FormAttachment(0, 0);
fdlUpdateBypassed.top = new FormAttachment(wCommit, margin);
fdlUpdateBypassed.right = new FormAttachment(middle, -margin);
wlUpdateBypassed.setLayoutData(fdlUpdateBypassed);
wUpdateBypassed = new Button(shell, SWT.CHECK);
props.setLook(wUpdateBypassed);
fdUpdateBypassed = new FormData();
fdUpdateBypassed.left = new FormAttachment(middle, 0);
fdUpdateBypassed.top = new FormAttachment(wCommit, margin);
fdUpdateBypassed.right = new FormAttachment(100, 0);
wUpdateBypassed.setLayoutData(fdUpdateBypassed);
wUpdateBypassed.addSelectionListener(new ComponentSelectionListener(input));
wlKey = new Label(shell, SWT.NONE);
wlKey.setText(BaseMessages.getString(PKG, "InsertUpdateDialog.Keys.Label"));
props.setLook(wlKey);
fdlKey = new FormData();
fdlKey.left = new FormAttachment(0, 0);
fdlKey.top = new FormAttachment(wUpdateBypassed, margin);
wlKey.setLayoutData(fdlKey);
int nrKeyCols = 4;
int nrKeyRows = (input.getKeyStream() != null ? input.getKeyStream().length : 1);
ciKey = new ColumnInfo[nrKeyCols];
ciKey[0] = new ColumnInfo(BaseMessages.getString(PKG, "InsertUpdateDialog.ColumnInfo.TableField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciKey[1] = new ColumnInfo(BaseMessages.getString(PKG, "InsertUpdateDialog.ColumnInfo.Comparator"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "=", "= ~NULL", "<>", "<", "<=", ">", ">=", "LIKE", "BETWEEN", "IS NULL", "IS NOT NULL" });
ciKey[2] = new ColumnInfo(BaseMessages.getString(PKG, "InsertUpdateDialog.ColumnInfo.StreamField1"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciKey[3] = new ColumnInfo(BaseMessages.getString(PKG, "InsertUpdateDialog.ColumnInfo.StreamField2"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
tableFieldColumns.add(ciKey[0]);
wKey = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciKey, nrKeyRows, lsMod, props);
wGet = new Button(shell, SWT.PUSH);
wGet.setText(BaseMessages.getString(PKG, "InsertUpdateDialog.GetFields.Button"));
fdGet = new FormData();
fdGet.right = new FormAttachment(100, 0);
fdGet.top = new FormAttachment(wlKey, margin);
wGet.setLayoutData(fdGet);
fdKey = new FormData();
fdKey.left = new FormAttachment(0, 0);
fdKey.top = new FormAttachment(wlKey, margin);
fdKey.right = new FormAttachment(wGet, -margin);
fdKey.bottom = new FormAttachment(wlKey, 190);
wKey.setLayoutData(fdKey);
// THE BUTTONS
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wSQL = new Button(shell, SWT.PUSH);
wSQL.setText(BaseMessages.getString(PKG, "InsertUpdateDialog.SQL.Button"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOK, wCancel, wSQL }, margin, null);
// THE UPDATE/INSERT TABLE
wlReturn = new Label(shell, SWT.NONE);
wlReturn.setText(BaseMessages.getString(PKG, "InsertUpdateDialog.UpdateFields.Label"));
props.setLook(wlReturn);
fdlReturn = new FormData();
fdlReturn.left = new FormAttachment(0, 0);
fdlReturn.top = new FormAttachment(wKey, margin);
wlReturn.setLayoutData(fdlReturn);
int UpInsCols = 3;
int UpInsRows = (input.getUpdateLookup() != null ? input.getUpdateLookup().length : 1);
ciReturn = new ColumnInfo[UpInsCols];
ciReturn[0] = new ColumnInfo(BaseMessages.getString(PKG, "InsertUpdateDialog.ColumnInfo.TableField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciReturn[1] = new ColumnInfo(BaseMessages.getString(PKG, "InsertUpdateDialog.ColumnInfo.StreamField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciReturn[2] = new ColumnInfo(BaseMessages.getString(PKG, "InsertUpdateDialog.ColumnInfo.Update"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "Y", "N" });
tableFieldColumns.add(ciReturn[0]);
wReturn = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciReturn, UpInsRows, lsMod, props);
wGetLU = new Button(shell, SWT.PUSH);
wGetLU.setText(BaseMessages.getString(PKG, "InsertUpdateDialog.GetAndUpdateFields.Label"));
fdGetLU = new FormData();
fdGetLU.top = new FormAttachment(wlReturn, margin);
fdGetLU.right = new FormAttachment(100, 0);
wGetLU.setLayoutData(fdGetLU);
wDoMapping = new Button(shell, SWT.PUSH);
wDoMapping.setText(BaseMessages.getString(PKG, "InsertUpdateDialog.EditMapping.Label"));
fdDoMapping = new FormData();
fdDoMapping.top = new FormAttachment(wGetLU, margin);
fdDoMapping.right = new FormAttachment(100, 0);
wDoMapping.setLayoutData(fdDoMapping);
wDoMapping.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event arg0) {
generateMappings();
}
});
fdReturn = new FormData();
fdReturn.left = new FormAttachment(0, 0);
fdReturn.top = new FormAttachment(wlReturn, margin);
fdReturn.right = new FormAttachment(wGetLU, -margin);
fdReturn.bottom = new FormAttachment(wOK, -2 * margin);
wReturn.setLayoutData(fdReturn);
//
// Search the fields in the background
//
final Runnable runnable = new Runnable() {
public void run() {
StepMeta stepMeta = transMeta.findStep(stepname);
if (stepMeta != null) {
try {
RowMetaInterface row = transMeta.getPrevStepFields(stepMeta);
// Remember these fields...
for (int i = 0; i < row.size(); i++) {
inputFields.put(row.getValueMeta(i).getName(), i);
}
setComboBoxes();
} catch (KettleException e) {
logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
}
}
};
new Thread(runnable).start();
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsGet = new Listener() {
public void handleEvent(Event e) {
get();
}
};
lsGetLU = new Listener() {
public void handleEvent(Event e) {
getUpdate();
}
};
lsSQL = new Listener() {
public void handleEvent(Event e) {
create();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wGet.addListener(SWT.Selection, lsGet);
wGetLU.addListener(SWT.Selection, lsGetLU);
wSQL.addListener(SWT.Selection, lsSQL);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wSchema.addSelectionListener(lsDef);
wTable.addSelectionListener(lsDef);
wCommit.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
wbSchema.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
getSchemaNames();
}
});
wbTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
getTableName();
}
});
// Set the shell size, based upon previous time...
setSize();
getData();
setTableFieldCombo();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.trans.step.ComponentSelectionListener in project pentaho-kettle by pentaho.
the class FileExistsDialog 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();
}
};
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, "FileExistsDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "FileExistsDialog.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);
// filename field
wlFileName = new Label(shell, SWT.RIGHT);
wlFileName.setText(BaseMessages.getString(PKG, "FileExistsDialog.FileName.Label"));
props.setLook(wlFileName);
fdlFileName = new FormData();
fdlFileName.left = new FormAttachment(0, 0);
fdlFileName.right = new FormAttachment(middle, -margin);
fdlFileName.top = new FormAttachment(wStepname, margin);
wlFileName.setLayoutData(fdlFileName);
wFileName = new CCombo(shell, SWT.BORDER | SWT.READ_ONLY);
props.setLook(wFileName);
wFileName.addModifyListener(lsMod);
fdFileName = new FormData();
fdFileName.left = new FormAttachment(middle, 0);
fdFileName.top = new FormAttachment(wStepname, margin);
fdFileName.right = new FormAttachment(100, -margin);
wFileName.setLayoutData(fdFileName);
wFileName.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);
get();
shell.setCursor(null);
busy.dispose();
}
});
// Result fieldname ...
wlResult = new Label(shell, SWT.RIGHT);
wlResult.setText(BaseMessages.getString(PKG, "FileExistsDialog.ResultField.Label"));
props.setLook(wlResult);
fdlResult = new FormData();
fdlResult.left = new FormAttachment(0, 0);
fdlResult.right = new FormAttachment(middle, -margin);
fdlResult.top = new FormAttachment(wFileName, margin * 2);
wlResult.setLayoutData(fdlResult);
wResult = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wResult.setToolTipText(BaseMessages.getString(PKG, "FileExistsDialog.ResultField.Tooltip"));
props.setLook(wResult);
wResult.addModifyListener(lsMod);
fdResult = new FormData();
fdResult.left = new FormAttachment(middle, 0);
fdResult.top = new FormAttachment(wFileName, margin * 2);
fdResult.right = new FormAttachment(100, 0);
wResult.setLayoutData(fdResult);
// Add filename to result filenames?
wlAddResult = new Label(shell, SWT.RIGHT);
wlAddResult.setText(BaseMessages.getString(PKG, "FileExistsDialog.AddResult.Label"));
props.setLook(wlAddResult);
fdlAddResult = new FormData();
fdlAddResult.left = new FormAttachment(0, 0);
fdlAddResult.top = new FormAttachment(wResult, margin);
fdlAddResult.right = new FormAttachment(middle, -margin);
wlAddResult.setLayoutData(fdlAddResult);
wAddResult = new Button(shell, SWT.CHECK);
props.setLook(wAddResult);
wAddResult.setToolTipText(BaseMessages.getString(PKG, "FileExistsDialog.AddResult.Tooltip"));
fdAddResult = new FormData();
fdAddResult.left = new FormAttachment(middle, 0);
fdAddResult.top = new FormAttachment(wResult, margin);
wAddResult.setLayoutData(fdAddResult);
wAddResult.addSelectionListener(new ComponentSelectionListener(input));
// ///////////////////////////////
// START OF Additional Fields GROUP //
// ///////////////////////////////
wAdditionalFields = new Group(shell, SWT.SHADOW_NONE);
props.setLook(wAdditionalFields);
wAdditionalFields.setText(BaseMessages.getString(PKG, "FileExistsDialog.wAdditionalFields.Label"));
FormLayout AdditionalFieldsgroupLayout = new FormLayout();
AdditionalFieldsgroupLayout.marginWidth = 10;
AdditionalFieldsgroupLayout.marginHeight = 10;
wAdditionalFields.setLayout(AdditionalFieldsgroupLayout);
// include filetype?
wlInclFileType = new Label(wAdditionalFields, SWT.RIGHT);
wlInclFileType.setText(BaseMessages.getString(PKG, "FileExistsDialog.InclFileType.Label"));
props.setLook(wlInclFileType);
fdlInclFileType = new FormData();
fdlInclFileType.left = new FormAttachment(0, 0);
fdlInclFileType.top = new FormAttachment(wResult, margin);
fdlInclFileType.right = new FormAttachment(middle, -margin);
wlInclFileType.setLayoutData(fdlInclFileType);
wInclFileType = new Button(wAdditionalFields, SWT.CHECK);
props.setLook(wInclFileType);
wInclFileType.setToolTipText(BaseMessages.getString(PKG, "FileExistsDialog.InclFileType.Tooltip"));
fdInclFileType = new FormData();
fdInclFileType.left = new FormAttachment(middle, 0);
fdInclFileType.top = new FormAttachment(wResult, margin);
wInclFileType.setLayoutData(fdInclFileType);
wInclFileType.addSelectionListener(new ComponentSelectionListener(input));
// Enable/disable the right fields to allow a filename to be added to each row...
wInclFileType.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
activeFileType();
}
});
// FileType fieldname ...
wlFileType = new Label(wAdditionalFields, SWT.RIGHT);
wlFileType.setText(BaseMessages.getString(PKG, "FileExistsDialog.FileTypeField.Label"));
props.setLook(wlFileType);
fdlFileType = new FormData();
fdlFileType.left = new FormAttachment(wInclFileType, 2 * margin);
fdlFileType.top = new FormAttachment(wResult, margin);
wlFileType.setLayoutData(fdlFileType);
wFileType = new TextVar(transMeta, wAdditionalFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wFileType.setToolTipText(BaseMessages.getString(PKG, "FileExistsDialog.FileTypeField.Tooltip"));
props.setLook(wFileType);
wFileType.addModifyListener(lsMod);
fdFileType = new FormData();
fdFileType.left = new FormAttachment(wlFileType, margin);
fdFileType.top = new FormAttachment(wResult, margin);
fdFileType.right = new FormAttachment(100, 0);
wFileType.setLayoutData(fdFileType);
fdAdditionalFields = new FormData();
fdAdditionalFields.left = new FormAttachment(0, margin);
fdAdditionalFields.top = new FormAttachment(wAddResult, margin);
fdAdditionalFields.right = new FormAttachment(100, -margin);
wAdditionalFields.setLayoutData(fdAdditionalFields);
// ///////////////////////////////
// END OF Additional Fields GROUP //
// ///////////////////////////////
// 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, wAdditionalFields);
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.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();
activeFileType();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
Aggregations