use of org.pentaho.di.trans.steps.excelinput.SpreadSheetType 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;
}
Aggregations