use of org.pentaho.di.ui.core.widget.ComboVar in project pentaho-kettle by pentaho.
the class BaseStreamingDialog method buildResultsTab.
private void buildResultsTab() {
wResultsTab = new CTabItem(wTabFolder, SWT.NONE);
wResultsTab.setText(BaseMessages.getString(PKG, "BaseStreamingDialog.ResultsTab"));
wResultsComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wResultsComp);
FormLayout resultsLayout = new FormLayout();
resultsLayout.marginHeight = 15;
resultsLayout.marginWidth = 15;
wResultsComp.setLayout(resultsLayout);
FormData fdResultsComp = new FormData();
fdResultsComp.left = new FormAttachment(0, 0);
fdResultsComp.top = new FormAttachment(0, 0);
fdResultsComp.right = new FormAttachment(100, 0);
fdResultsComp.bottom = new FormAttachment(100, 0);
wResultsComp.setLayoutData(fdResultsComp);
wlSubStep = new Label(wResultsComp, SWT.LEFT);
props.setLook(wlSubStep);
FormData fdlSubTrans = new FormData();
fdlSubTrans.left = new FormAttachment(0, 0);
fdlSubTrans.top = new FormAttachment(0, 0);
wlSubStep.setLayoutData(fdlSubTrans);
wlSubStep.setText(BaseMessages.getString(PKG, "BaseStreaming.Dialog.Transformation.SubTransStep"));
wSubStep = new ComboVar(transMeta, wResultsComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wSubStep);
FormData fdSubStep = new FormData();
fdSubStep.left = new FormAttachment(0, 0);
fdSubStep.top = new FormAttachment(wlSubStep, 5);
fdSubStep.width = 250;
wSubStep.setLayoutData(fdSubStep);
wResultsComp.layout();
wResultsTab.setControl(wResultsComp);
}
use of org.pentaho.di.ui.core.widget.ComboVar in project pentaho-kettle by pentaho.
the class ChangeFileEncodingDialog 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, "ChangeFileEncodingDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "ChangeFileEncodingDialog.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);
// /////////////////////////////////
// START OF SourceFile GROUP
// /////////////////////////////////
wSourceFileGroup = new Group(shell, SWT.SHADOW_NONE);
props.setLook(wSourceFileGroup);
wSourceFileGroup.setText(BaseMessages.getString(PKG, "ChangeFileEncodingDialog.Group.SourceFileGroup.Label"));
FormLayout SourceFilegroupLayout = new FormLayout();
SourceFilegroupLayout.marginWidth = 10;
SourceFilegroupLayout.marginHeight = 10;
wSourceFileGroup.setLayout(SourceFilegroupLayout);
// filename field
wlFileName = new Label(wSourceFileGroup, SWT.RIGHT);
wlFileName.setText(BaseMessages.getString(PKG, "ChangeFileEncodingDialog.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(wSourceFileGroup, SWT.BORDER | SWT.READ_ONLY);
wFileName.setEditable(true);
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) {
get();
}
});
wlSourceEncoding = new Label(wSourceFileGroup, SWT.RIGHT);
wlSourceEncoding.setText(BaseMessages.getString(PKG, "ChangeFileSourceEncodingDialog.SourceEncoding.Label"));
props.setLook(wlSourceEncoding);
fdlSourceEncoding = new FormData();
fdlSourceEncoding.left = new FormAttachment(0, 0);
fdlSourceEncoding.top = new FormAttachment(wFileName, margin);
fdlSourceEncoding.right = new FormAttachment(middle, -margin);
wlSourceEncoding.setLayoutData(fdlSourceEncoding);
wSourceEncoding = new ComboVar(transMeta, wSourceFileGroup, SWT.BORDER | SWT.READ_ONLY);
wSourceEncoding.setEditable(true);
props.setLook(wSourceEncoding);
wSourceEncoding.addModifyListener(lsMod);
fdSourceEncoding = new FormData();
fdSourceEncoding.left = new FormAttachment(middle, 0);
fdSourceEncoding.top = new FormAttachment(wFileName, margin);
fdSourceEncoding.right = new FormAttachment(100, 0);
wSourceEncoding.setLayoutData(fdSourceEncoding);
wSourceEncoding.addFocusListener(new FocusListener() {
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
}
public void focusGained(org.eclipse.swt.events.FocusEvent e) {
setEncodings(wSourceEncoding);
}
});
// Add filename to result filenames?
wlSourceAddResult = new Label(wSourceFileGroup, SWT.RIGHT);
wlSourceAddResult.setText(BaseMessages.getString(PKG, "ChangeFileEncodingDialog.AddSourceResult.Label"));
props.setLook(wlSourceAddResult);
fdlSourceAddResult = new FormData();
fdlSourceAddResult.left = new FormAttachment(0, 0);
fdlSourceAddResult.top = new FormAttachment(wSourceEncoding, margin);
fdlSourceAddResult.right = new FormAttachment(middle, -margin);
wlSourceAddResult.setLayoutData(fdlSourceAddResult);
wSourceAddResult = new Button(wSourceFileGroup, SWT.CHECK);
props.setLook(wSourceAddResult);
wSourceAddResult.setToolTipText(BaseMessages.getString(PKG, "ChangeFileEncodingDialog.AddSourceResult.Tooltip"));
fdSourceAddResult = new FormData();
fdSourceAddResult.left = new FormAttachment(middle, 0);
fdSourceAddResult.top = new FormAttachment(wSourceEncoding, margin);
wSourceAddResult.setLayoutData(fdSourceAddResult);
wSourceAddResult.addSelectionListener(new ComponentSelectionListener(input));
fdSourceFileGroup = new FormData();
fdSourceFileGroup.left = new FormAttachment(0, margin);
fdSourceFileGroup.top = new FormAttachment(wStepname, margin);
fdSourceFileGroup.right = new FormAttachment(100, -margin);
wSourceFileGroup.setLayoutData(fdSourceFileGroup);
// ///////////////////////////////////////////////////////////
// / END OF SourceFile GROUP
// ///////////////////////////////////////////////////////////
// /////////////////////////////////
// START OF TargetFile GROUP
// /////////////////////////////////
wTargetFileGroup = new Group(shell, SWT.SHADOW_NONE);
props.setLook(wTargetFileGroup);
wTargetFileGroup.setText(BaseMessages.getString(PKG, "ChangeFileEncodingDialog.Group.TargetFileGroup.Label"));
FormLayout TargetFilegroupLayout = new FormLayout();
TargetFilegroupLayout.marginWidth = 10;
TargetFilegroupLayout.marginHeight = 10;
wTargetFileGroup.setLayout(TargetFilegroupLayout);
// TargetFileName field
wlTargetFileName = new Label(wTargetFileGroup, SWT.RIGHT);
wlTargetFileName.setText(BaseMessages.getString(PKG, "ChangeFileEncodingDialog.TargetFileName.Label"));
props.setLook(wlTargetFileName);
fdlTargetFileName = new FormData();
fdlTargetFileName.left = new FormAttachment(0, 0);
fdlTargetFileName.right = new FormAttachment(middle, -margin);
fdlTargetFileName.top = new FormAttachment(wSourceEncoding, margin);
wlTargetFileName.setLayoutData(fdlTargetFileName);
wTargetFileName = new CCombo(wTargetFileGroup, SWT.BORDER | SWT.READ_ONLY);
wTargetFileName.setEditable(true);
props.setLook(wTargetFileName);
wTargetFileName.addModifyListener(lsMod);
fdTargetFileName = new FormData();
fdTargetFileName.left = new FormAttachment(middle, 0);
fdTargetFileName.top = new FormAttachment(wSourceEncoding, margin);
fdTargetFileName.right = new FormAttachment(100, -margin);
wTargetFileName.setLayoutData(fdTargetFileName);
wTargetFileName.addFocusListener(new FocusListener() {
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
}
public void focusGained(org.eclipse.swt.events.FocusEvent e) {
get();
}
});
// Create parent folder
wlCreateParentFolder = new Label(wTargetFileGroup, SWT.RIGHT);
wlCreateParentFolder.setText(BaseMessages.getString(PKG, "ChangeFileEncodingDialog.CreateParentFolder.Label"));
props.setLook(wlCreateParentFolder);
fdlCreateParentFolder = new FormData();
fdlCreateParentFolder.left = new FormAttachment(0, 0);
fdlCreateParentFolder.top = new FormAttachment(wTargetFileName, margin);
fdlCreateParentFolder.right = new FormAttachment(middle, -margin);
wlCreateParentFolder.setLayoutData(fdlCreateParentFolder);
wCreateParentFolder = new Button(wTargetFileGroup, SWT.CHECK);
props.setLook(wCreateParentFolder);
wCreateParentFolder.setToolTipText(BaseMessages.getString(PKG, "ChangeFileEncodingDialog.CreateParentFolder.Tooltip"));
fdCreateParentFolder = new FormData();
fdCreateParentFolder.left = new FormAttachment(middle, 0);
fdCreateParentFolder.top = new FormAttachment(wTargetFileName, margin);
wCreateParentFolder.setLayoutData(fdCreateParentFolder);
wCreateParentFolder.addSelectionListener(new ComponentSelectionListener(input));
wlTargetEncoding = new Label(wTargetFileGroup, SWT.RIGHT);
wlTargetEncoding.setText(BaseMessages.getString(PKG, "ChangeFileEncodingDialog.TargetEncoding.Label"));
props.setLook(wlTargetEncoding);
fdlTargetEncoding = new FormData();
fdlTargetEncoding.left = new FormAttachment(0, 0);
fdlTargetEncoding.top = new FormAttachment(wCreateParentFolder, margin);
fdlTargetEncoding.right = new FormAttachment(middle, -margin);
wlTargetEncoding.setLayoutData(fdlTargetEncoding);
wTargetEncoding = new ComboVar(transMeta, wTargetFileGroup, SWT.BORDER | SWT.READ_ONLY);
wTargetEncoding.setEditable(true);
props.setLook(wTargetEncoding);
wTargetEncoding.addModifyListener(lsMod);
fdTargetEncoding = new FormData();
fdTargetEncoding.left = new FormAttachment(middle, 0);
fdTargetEncoding.top = new FormAttachment(wCreateParentFolder, margin);
fdTargetEncoding.right = new FormAttachment(100, 0);
wTargetEncoding.setLayoutData(fdTargetEncoding);
wTargetEncoding.addFocusListener(new FocusListener() {
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
}
public void focusGained(org.eclipse.swt.events.FocusEvent e) {
setEncodings(wTargetEncoding);
}
});
// Add filename to result filenames?
wlTargetAddResult = new Label(wTargetFileGroup, SWT.RIGHT);
wlTargetAddResult.setText(BaseMessages.getString(PKG, "ChangeFileEncodingDialog.AddTargetResult.Label"));
props.setLook(wlTargetAddResult);
fdlTargetAddResult = new FormData();
fdlTargetAddResult.left = new FormAttachment(0, 0);
fdlTargetAddResult.top = new FormAttachment(wTargetEncoding, margin);
fdlTargetAddResult.right = new FormAttachment(middle, -margin);
wlTargetAddResult.setLayoutData(fdlTargetAddResult);
wTargetAddResult = new Button(wTargetFileGroup, SWT.CHECK);
props.setLook(wTargetAddResult);
wTargetAddResult.setToolTipText(BaseMessages.getString(PKG, "ChangeFileEncodingDialog.AddTargetResult.Tooltip"));
fdTargetAddResult = new FormData();
fdTargetAddResult.left = new FormAttachment(middle, 0);
fdTargetAddResult.top = new FormAttachment(wTargetEncoding, margin);
wTargetAddResult.setLayoutData(fdTargetAddResult);
wTargetAddResult.addSelectionListener(new ComponentSelectionListener(input));
fdTargetFileGroup = new FormData();
fdTargetFileGroup.left = new FormAttachment(0, margin);
fdTargetFileGroup.top = new FormAttachment(wSourceFileGroup, margin);
fdTargetFileGroup.right = new FormAttachment(100, -margin);
wTargetFileGroup.setLayoutData(fdTargetFileGroup);
// ///////////////////////////////////////////////////////////
// / END OF TargetFile 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, wTargetFileGroup);
// 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.core.widget.ComboVar in project pentaho-kettle by pentaho.
the class CsvInputDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
props.setLook(shell);
setShellImage(shell, inputMeta);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
inputMeta.setChanged();
}
};
changed = inputMeta.hasChanged();
ModifyListener lsContent = new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
// asyncUpdatePreview();
}
};
initializing = true;
previewBusy = new AtomicBoolean(false);
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "CsvInputDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Step name line
//
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "CsvInputDialog.Stepname.Label"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
Control lastControl = wStepname;
// See if the step receives input. If so, we don't ask for the filename, but
// for the filename field.
//
isReceivingInput = transMeta.findNrPrevSteps(stepMeta) > 0;
if (isReceivingInput) {
RowMetaInterface previousFields;
try {
previousFields = transMeta.getPrevStepFields(stepMeta);
} catch (KettleStepException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "CsvInputDialog.ErrorDialog.UnableToGetInputFields.Title"), BaseMessages.getString(PKG, "CsvInputDialog.ErrorDialog.UnableToGetInputFields.Message"), e);
previousFields = new RowMeta();
}
// The filename field ...
//
Label wlFilename = new Label(shell, SWT.RIGHT);
wlFilename.setText(BaseMessages.getString(PKG, inputMeta.getDescription("FILENAME_FIELD")));
props.setLook(wlFilename);
FormData fdlFilename = new FormData();
fdlFilename.top = new FormAttachment(lastControl, margin);
fdlFilename.left = new FormAttachment(0, 0);
fdlFilename.right = new FormAttachment(middle, -margin);
wlFilename.setLayoutData(fdlFilename);
wFilenameField = new CCombo(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wFilenameField.setItems(previousFields.getFieldNames());
props.setLook(wFilenameField);
wFilenameField.addModifyListener(lsMod);
FormData fdFilename = new FormData();
fdFilename.top = new FormAttachment(lastControl, margin);
fdFilename.left = new FormAttachment(middle, 0);
fdFilename.right = new FormAttachment(100, 0);
wFilenameField.setLayoutData(fdFilename);
lastControl = wFilenameField;
// Checkbox to include the filename in the output...
//
Label wlIncludeFilename = new Label(shell, SWT.RIGHT);
wlIncludeFilename.setText(BaseMessages.getString(PKG, inputMeta.getDescription("INCLUDE_FILENAME")));
props.setLook(wlIncludeFilename);
FormData fdlIncludeFilename = new FormData();
fdlIncludeFilename.top = new FormAttachment(lastControl, margin);
fdlIncludeFilename.left = new FormAttachment(0, 0);
fdlIncludeFilename.right = new FormAttachment(middle, -margin);
wlIncludeFilename.setLayoutData(fdlIncludeFilename);
wIncludeFilename = new Button(shell, SWT.CHECK);
props.setLook(wIncludeFilename);
wFilenameField.addModifyListener(lsMod);
FormData fdIncludeFilename = new FormData();
fdIncludeFilename.top = new FormAttachment(lastControl, margin);
fdIncludeFilename.left = new FormAttachment(middle, 0);
fdIncludeFilename.right = new FormAttachment(100, 0);
wIncludeFilename.setLayoutData(fdIncludeFilename);
lastControl = wIncludeFilename;
} else {
// Filename...
//
// The filename browse button
//
wbbFilename = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbbFilename);
wbbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
wbbFilename.setToolTipText(BaseMessages.getString(PKG, "System.Tooltip.BrowseForFileOrDirAndAdd"));
FormData fdbFilename = new FormData();
fdbFilename.top = new FormAttachment(lastControl, margin);
fdbFilename.right = new FormAttachment(100, 0);
wbbFilename.setLayoutData(fdbFilename);
// The field itself...
//
Label wlFilename = new Label(shell, SWT.RIGHT);
wlFilename.setText(BaseMessages.getString(PKG, inputMeta.getDescription("FILENAME")));
props.setLook(wlFilename);
FormData fdlFilename = new FormData();
fdlFilename.top = new FormAttachment(lastControl, margin);
fdlFilename.left = new FormAttachment(0, 0);
fdlFilename.right = new FormAttachment(middle, -margin);
wlFilename.setLayoutData(fdlFilename);
wFilename = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wFilename);
wFilename.addModifyListener(lsMod);
FormData fdFilename = new FormData();
fdFilename.top = new FormAttachment(lastControl, margin);
fdFilename.left = new FormAttachment(middle, 0);
fdFilename.right = new FormAttachment(wbbFilename, -margin);
wFilename.setLayoutData(fdFilename);
/*
* wFilename.addFocusListener(new FocusAdapter() {
*
* @Override public void focusLost(FocusEvent arg0) { asyncUpdatePreview(); } });
*/
lastControl = wFilename;
}
// delimiter
Label wlDelimiter = new Label(shell, SWT.RIGHT);
wlDelimiter.setText(BaseMessages.getString(PKG, inputMeta.getDescription("DELIMITER")));
props.setLook(wlDelimiter);
FormData fdlDelimiter = new FormData();
fdlDelimiter.top = new FormAttachment(lastControl, margin);
fdlDelimiter.left = new FormAttachment(0, 0);
fdlDelimiter.right = new FormAttachment(middle, -margin);
wlDelimiter.setLayoutData(fdlDelimiter);
wbDelimiter = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbDelimiter);
wbDelimiter.setText(BaseMessages.getString(PKG, "CsvInputDialog.Delimiter.Button"));
FormData fdbDelimiter = new FormData();
fdbDelimiter.top = new FormAttachment(lastControl, margin);
fdbDelimiter.right = new FormAttachment(100, 0);
wbDelimiter.setLayoutData(fdbDelimiter);
wDelimiter = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wDelimiter);
wDelimiter.addModifyListener(lsMod);
FormData fdDelimiter = new FormData();
fdDelimiter.top = new FormAttachment(lastControl, margin);
fdDelimiter.left = new FormAttachment(middle, 0);
fdDelimiter.right = new FormAttachment(wbDelimiter, -margin);
wDelimiter.setLayoutData(fdDelimiter);
wDelimiter.addModifyListener(lsContent);
lastControl = wDelimiter;
// enclosure
Label wlEnclosure = new Label(shell, SWT.RIGHT);
wlEnclosure.setText(BaseMessages.getString(PKG, inputMeta.getDescription("ENCLOSURE")));
props.setLook(wlEnclosure);
FormData fdlEnclosure = new FormData();
fdlEnclosure.top = new FormAttachment(lastControl, margin);
fdlEnclosure.left = new FormAttachment(0, 0);
fdlEnclosure.right = new FormAttachment(middle, -margin);
wlEnclosure.setLayoutData(fdlEnclosure);
wEnclosure = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wEnclosure);
wEnclosure.addModifyListener(lsMod);
FormData fdEnclosure = new FormData();
fdEnclosure.top = new FormAttachment(lastControl, margin);
fdEnclosure.left = new FormAttachment(middle, 0);
fdEnclosure.right = new FormAttachment(100, 0);
wEnclosure.setLayoutData(fdEnclosure);
wEnclosure.addModifyListener(lsContent);
lastControl = wEnclosure;
// bufferSize
//
Label wlBufferSize = new Label(shell, SWT.RIGHT);
wlBufferSize.setText(BaseMessages.getString(PKG, inputMeta.getDescription("BUFFERSIZE")));
props.setLook(wlBufferSize);
FormData fdlBufferSize = new FormData();
fdlBufferSize.top = new FormAttachment(lastControl, margin);
fdlBufferSize.left = new FormAttachment(0, 0);
fdlBufferSize.right = new FormAttachment(middle, -margin);
wlBufferSize.setLayoutData(fdlBufferSize);
wBufferSize = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wBufferSize);
wBufferSize.addModifyListener(lsMod);
FormData fdBufferSize = new FormData();
fdBufferSize.top = new FormAttachment(lastControl, margin);
fdBufferSize.left = new FormAttachment(middle, 0);
fdBufferSize.right = new FormAttachment(100, 0);
wBufferSize.setLayoutData(fdBufferSize);
lastControl = wBufferSize;
// performingLazyConversion?
//
Label wlLazyConversion = new Label(shell, SWT.RIGHT);
wlLazyConversion.setText(BaseMessages.getString(PKG, inputMeta.getDescription("LAZY_CONVERSION")));
props.setLook(wlLazyConversion);
FormData fdlLazyConversion = new FormData();
fdlLazyConversion.top = new FormAttachment(lastControl, margin);
fdlLazyConversion.left = new FormAttachment(0, 0);
fdlLazyConversion.right = new FormAttachment(middle, -margin);
wlLazyConversion.setLayoutData(fdlLazyConversion);
wLazyConversion = new Button(shell, SWT.CHECK);
props.setLook(wLazyConversion);
FormData fdLazyConversion = new FormData();
fdLazyConversion.top = new FormAttachment(lastControl, margin);
fdLazyConversion.left = new FormAttachment(middle, 0);
fdLazyConversion.right = new FormAttachment(100, 0);
wLazyConversion.setLayoutData(fdLazyConversion);
lastControl = wLazyConversion;
// header row?
//
Label wlHeaderPresent = new Label(shell, SWT.RIGHT);
wlHeaderPresent.setText(BaseMessages.getString(PKG, inputMeta.getDescription("HEADER_PRESENT")));
props.setLook(wlHeaderPresent);
FormData fdlHeaderPresent = new FormData();
fdlHeaderPresent.top = new FormAttachment(lastControl, margin);
fdlHeaderPresent.left = new FormAttachment(0, 0);
fdlHeaderPresent.right = new FormAttachment(middle, -margin);
wlHeaderPresent.setLayoutData(fdlHeaderPresent);
wHeaderPresent = new Button(shell, SWT.CHECK);
props.setLook(wHeaderPresent);
FormData fdHeaderPresent = new FormData();
fdHeaderPresent.top = new FormAttachment(lastControl, margin);
fdHeaderPresent.left = new FormAttachment(middle, 0);
fdHeaderPresent.right = new FormAttachment(100, 0);
wHeaderPresent.setLayoutData(fdHeaderPresent);
/*
* wHeaderPresent.addSelectionListener(new SelectionAdapter() {
*
* @Override public void widgetSelected(SelectionEvent arg0) { asyncUpdatePreview(); } });
*/
lastControl = wHeaderPresent;
wlAddResult = new Label(shell, SWT.RIGHT);
wlAddResult.setText(BaseMessages.getString(PKG, inputMeta.getDescription("ADD_FILENAME_RESULT")));
props.setLook(wlAddResult);
fdlAddResult = new FormData();
fdlAddResult.left = new FormAttachment(0, 0);
fdlAddResult.top = new FormAttachment(wHeaderPresent, margin);
fdlAddResult.right = new FormAttachment(middle, -margin);
wlAddResult.setLayoutData(fdlAddResult);
wAddResult = new Button(shell, SWT.CHECK);
props.setLook(wAddResult);
wAddResult.setToolTipText(BaseMessages.getString(PKG, inputMeta.getTooltip("ADD_FILENAME_RESULT")));
fdAddResult = new FormData();
fdAddResult.left = new FormAttachment(middle, 0);
fdAddResult.top = new FormAttachment(wHeaderPresent, margin);
wAddResult.setLayoutData(fdAddResult);
lastControl = wAddResult;
// The field itself...
//
Label wlRowNumField = new Label(shell, SWT.RIGHT);
wlRowNumField.setText(BaseMessages.getString(PKG, inputMeta.getDescription("ROW_NUM_FIELD")));
props.setLook(wlRowNumField);
FormData fdlRowNumField = new FormData();
fdlRowNumField.top = new FormAttachment(lastControl, margin);
fdlRowNumField.left = new FormAttachment(0, 0);
fdlRowNumField.right = new FormAttachment(middle, -margin);
wlRowNumField.setLayoutData(fdlRowNumField);
wRowNumField = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wRowNumField);
wRowNumField.addModifyListener(lsMod);
FormData fdRowNumField = new FormData();
fdRowNumField.top = new FormAttachment(lastControl, margin);
fdRowNumField.left = new FormAttachment(middle, 0);
fdRowNumField.right = new FormAttachment(100, 0);
wRowNumField.setLayoutData(fdRowNumField);
lastControl = wRowNumField;
// running in parallel?
//
wlRunningInParallel = new Label(shell, SWT.RIGHT);
wlRunningInParallel.setText(BaseMessages.getString(PKG, inputMeta.getDescription("PARALLEL")));
props.setLook(wlRunningInParallel);
FormData fdlRunningInParallel = new FormData();
fdlRunningInParallel.top = new FormAttachment(lastControl, margin);
fdlRunningInParallel.left = new FormAttachment(0, 0);
fdlRunningInParallel.right = new FormAttachment(middle, -margin);
wlRunningInParallel.setLayoutData(fdlRunningInParallel);
wRunningInParallel = new Button(shell, SWT.CHECK);
props.setLook(wRunningInParallel);
FormData fdRunningInParallel = new FormData();
fdRunningInParallel.top = new FormAttachment(lastControl, margin);
fdRunningInParallel.left = new FormAttachment(middle, 0);
wRunningInParallel.setLayoutData(fdRunningInParallel);
lastControl = wRunningInParallel;
// Is a new line possible in a field?
//
Label wlNewlinePossible = new Label(shell, SWT.RIGHT);
wlNewlinePossible.setText(BaseMessages.getString(PKG, inputMeta.getDescription("NEWLINE_POSSIBLE")));
props.setLook(wlNewlinePossible);
FormData fdlNewlinePossible = new FormData();
fdlNewlinePossible.top = new FormAttachment(lastControl, margin);
fdlNewlinePossible.left = new FormAttachment(0, 0);
fdlNewlinePossible.right = new FormAttachment(middle, -margin);
wlNewlinePossible.setLayoutData(fdlNewlinePossible);
wNewlinePossible = new Button(shell, SWT.CHECK);
props.setLook(wNewlinePossible);
FormData fdNewlinePossible = new FormData();
fdNewlinePossible.top = new FormAttachment(lastControl, margin);
fdNewlinePossible.left = new FormAttachment(middle, 0);
wNewlinePossible.setLayoutData(fdNewlinePossible);
wNewlinePossible.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
setFlags();
}
});
wNewlinePossible.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
asyncUpdatePreview();
}
});
lastControl = wNewlinePossible;
// Encoding
Label wlEncoding = new Label(shell, SWT.RIGHT);
wlEncoding.setText(BaseMessages.getString(PKG, inputMeta.getDescription("ENCODING")));
props.setLook(wlEncoding);
FormData fdlEncoding = new FormData();
fdlEncoding.top = new FormAttachment(lastControl, margin);
fdlEncoding.left = new FormAttachment(0, 0);
fdlEncoding.right = new FormAttachment(middle, -margin);
wlEncoding.setLayoutData(fdlEncoding);
wEncoding = new ComboVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wEncoding);
wEncoding.addModifyListener(lsMod);
FormData fdEncoding = new FormData();
fdEncoding.top = new FormAttachment(lastControl, margin);
fdEncoding.left = new FormAttachment(middle, 0);
fdEncoding.right = new FormAttachment(100, 0);
wEncoding.setLayoutData(fdEncoding);
wEncoding.addModifyListener(lsContent);
lastControl = wEncoding;
wEncoding.addFocusListener(new FocusListener() {
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
}
public void focusGained(org.eclipse.swt.events.FocusEvent e) {
Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
shell.setCursor(busy);
setEncodings();
shell.setCursor(null);
busy.dispose();
}
});
// Some buttons first, so that the dialog scales nicely...
//
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wPreview = new Button(shell, SWT.PUSH);
wPreview.setText(BaseMessages.getString(PKG, "System.Button.Preview"));
wPreview.setEnabled(!isReceivingInput);
wGet = new Button(shell, SWT.PUSH);
wGet.setText(BaseMessages.getString(PKG, "System.Button.GetFields"));
wGet.setEnabled(!isReceivingInput);
setButtonPositions(new Button[] { wOK, wGet, wPreview, wCancel }, margin, null);
// Fields
ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_NAME")), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_TYPE")), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames(), true), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_FORMAT")), ColumnInfo.COLUMN_TYPE_FORMAT, 2), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_LENGTH")), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_PRECISION")), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_CURRENCY")), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_DECIMAL")), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_GROUP")), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_TRIM_TYPE")), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaString.trimTypeDesc) };
colinf[2].setComboValuesSelectionListener(new ComboValuesSelectionListener() {
public String[] getComboValues(TableItem tableItem, int rowNr, int colNr) {
String[] comboValues = new String[] {};
int type = ValueMetaFactory.getIdForValueMeta(tableItem.getText(colNr - 1));
switch(type) {
case ValueMetaInterface.TYPE_DATE:
comboValues = Const.getDateFormats();
break;
case ValueMetaInterface.TYPE_INTEGER:
case ValueMetaInterface.TYPE_BIGNUMBER:
case ValueMetaInterface.TYPE_NUMBER:
comboValues = Const.getNumberFormats();
break;
default:
break;
}
return comboValues;
}
});
wFields = new TableView(transMeta, shell, SWT.FULL_SELECTION | SWT.MULTI, colinf, 1, lsMod, props);
FormData fdFields = new FormData();
fdFields.top = new FormAttachment(lastControl, margin * 2);
fdFields.bottom = new FormAttachment(wOK, -margin * 2);
fdFields.left = new FormAttachment(0, 0);
fdFields.right = new FormAttachment(100, 0);
wFields.setLayoutData(fdFields);
wFields.setContentListener(lsContent);
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsPreview = new Listener() {
public void handleEvent(Event e) {
preview();
}
};
lsGet = new Listener() {
public void handleEvent(Event e) {
getCSV();
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wOK.addListener(SWT.Selection, lsOK);
wPreview.addListener(SWT.Selection, lsPreview);
wGet.addListener(SWT.Selection, lsGet);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
if (wFilename != null) {
wFilename.addSelectionListener(lsDef);
}
if (wFilenameField != null) {
wFilenameField.addSelectionListener(lsDef);
}
wDelimiter.addSelectionListener(lsDef);
wEnclosure.addSelectionListener(lsDef);
wBufferSize.addSelectionListener(lsDef);
wRowNumField.addSelectionListener(lsDef);
// Allow the insertion of tabs as separator...
wbDelimiter.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent se) {
Text t = wDelimiter.getTextWidget();
if (t != null) {
t.insert("\t");
}
}
});
if (wbbFilename != null) {
// Listen to the browse button next to the file name
wbbFilename.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
dialog.setFilterExtensions(new String[] { "*.txt;*.csv", "*.csv", "*.txt", "*" });
if (wFilename.getText() != null) {
String fname = transMeta.environmentSubstitute(wFilename.getText());
dialog.setFileName(fname);
}
dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "System.FileType.CSVFiles") + ", " + BaseMessages.getString(PKG, "System.FileType.TextFiles"), BaseMessages.getString(PKG, "System.FileType.CSVFiles"), BaseMessages.getString(PKG, "System.FileType.TextFiles"), BaseMessages.getString(PKG, "System.FileType.AllFiles") });
if (dialog.open() != null) {
String str = dialog.getFilterPath() + System.getProperty("file.separator") + dialog.getFileName();
wFilename.setText(str);
}
}
});
}
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
// Set the shell size, based upon previous time...
setSize();
getData();
inputMeta.setChanged(changed);
initializing = false;
// Update the preview window.
//
// asyncUpdatePreview();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.widget.ComboVar in project pentaho-kettle by pentaho.
the class TableOutputDialog method open.
/**
* Open the dialog.
*/
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();
}
};
backupChanged = input.hasChanged();
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "TableOutputDialog.DialogTitle"));
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "System.Label.StepName"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wStepname.setText(stepname);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
// Connection line
wConnection = addConnectionLine(shell, wStepname, middle, margin);
if (input.getDatabaseMeta() == null && transMeta.nrDatabases() == 1) {
wConnection.select(0);
}
wConnection.addModifyListener(lsMod);
wConnection.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setFlags();
}
});
wConnection.addSelectionListener(lsSelection);
// Schema line...
wlSchema = new Label(shell, SWT.RIGHT);
wlSchema.setText(BaseMessages.getString(PKG, "TableOutputDialog.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, "TableOutputDialog.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, "System.Button.Browse"));
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.top = new FormAttachment(wbSchema, margin);
fdTable.left = new FormAttachment(middle, 0);
fdTable.right = new FormAttachment(wbTable, -margin);
wTable.setLayoutData(fdTable);
// Commit size ...
wlCommit = new Label(shell, SWT.RIGHT);
wlCommit.setText(BaseMessages.getString(PKG, "TableOutputDialog.CommitSize.Label"));
props.setLook(wlCommit);
fdlCommit = new FormData();
fdlCommit.left = new FormAttachment(0, 0);
fdlCommit.right = new FormAttachment(middle, -margin);
fdlCommit.top = new FormAttachment(wbTable, 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(wbTable, margin);
fdCommit.right = new FormAttachment(100, 0);
wCommit.setLayoutData(fdCommit);
// Truncate table
wlTruncate = new Label(shell, SWT.RIGHT);
wlTruncate.setText(BaseMessages.getString(PKG, "TableOutputDialog.TruncateTable.Label"));
props.setLook(wlTruncate);
fdlTruncate = new FormData();
fdlTruncate.left = new FormAttachment(0, 0);
fdlTruncate.top = new FormAttachment(wCommit, margin);
fdlTruncate.right = new FormAttachment(middle, -margin);
wlTruncate.setLayoutData(fdlTruncate);
wTruncate = new Button(shell, SWT.CHECK);
props.setLook(wTruncate);
fdTruncate = new FormData();
fdTruncate.left = new FormAttachment(middle, 0);
fdTruncate.top = new FormAttachment(wCommit, margin);
fdTruncate.right = new FormAttachment(100, 0);
wTruncate.setLayoutData(fdTruncate);
SelectionAdapter lsSelMod = new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
input.setChanged();
}
};
wTruncate.addSelectionListener(lsSelMod);
// Ignore errors
wlIgnore = new Label(shell, SWT.RIGHT);
wlIgnore.setText(BaseMessages.getString(PKG, "TableOutputDialog.IgnoreInsertErrors.Label"));
props.setLook(wlIgnore);
fdlIgnore = new FormData();
fdlIgnore.left = new FormAttachment(0, 0);
fdlIgnore.top = new FormAttachment(wTruncate, margin);
fdlIgnore.right = new FormAttachment(middle, -margin);
wlIgnore.setLayoutData(fdlIgnore);
wIgnore = new Button(shell, SWT.CHECK);
props.setLook(wIgnore);
fdIgnore = new FormData();
fdIgnore.left = new FormAttachment(middle, 0);
fdIgnore.top = new FormAttachment(wTruncate, margin);
fdIgnore.right = new FormAttachment(100, 0);
wIgnore.setLayoutData(fdIgnore);
wIgnore.addSelectionListener(lsSelMod);
// Specify fields
wlSpecifyFields = new Label(shell, SWT.RIGHT);
wlSpecifyFields.setText(BaseMessages.getString(PKG, "TableOutputDialog.SpecifyFields.Label"));
props.setLook(wlSpecifyFields);
fdlSpecifyFields = new FormData();
fdlSpecifyFields.left = new FormAttachment(0, 0);
fdlSpecifyFields.top = new FormAttachment(wIgnore, margin);
fdlSpecifyFields.right = new FormAttachment(middle, -margin);
wlSpecifyFields.setLayoutData(fdlSpecifyFields);
wSpecifyFields = new Button(shell, SWT.CHECK);
props.setLook(wSpecifyFields);
fdSpecifyFields = new FormData();
fdSpecifyFields.left = new FormAttachment(middle, 0);
fdSpecifyFields.top = new FormAttachment(wIgnore, margin);
fdSpecifyFields.right = new FormAttachment(100, 0);
wSpecifyFields.setLayoutData(fdSpecifyFields);
wSpecifyFields.addSelectionListener(lsSelMod);
// If the flag is off, gray out the fields tab e.g.
wSpecifyFields.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
setFlags();
}
});
wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
// ////////////////////////
// START OF KEY TAB ///
// /
wMainTab = new CTabItem(wTabFolder, SWT.NONE);
wMainTab.setText(BaseMessages.getString(PKG, "TableOutputDialog.MainTab.CTabItem"));
FormLayout mainLayout = new FormLayout();
mainLayout.marginWidth = 3;
mainLayout.marginHeight = 3;
Composite wMainComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wMainComp);
wMainComp.setLayout(mainLayout);
// Partitioning support
// Use partitioning?
wlUsePart = new Label(wMainComp, SWT.RIGHT);
wlUsePart.setText(BaseMessages.getString(PKG, "TableOutputDialog.UsePart.Label"));
wlUsePart.setToolTipText(BaseMessages.getString(PKG, "TableOutputDialog.UsePart.Tooltip"));
props.setLook(wlUsePart);
fdlUsePart = new FormData();
fdlUsePart.left = new FormAttachment(0, 0);
fdlUsePart.top = new FormAttachment(wSpecifyFields, margin * 5);
fdlUsePart.right = new FormAttachment(middle, -margin);
wlUsePart.setLayoutData(fdlUsePart);
wUsePart = new Button(wMainComp, SWT.CHECK);
props.setLook(wUsePart);
fdUsePart = new FormData();
fdUsePart.left = new FormAttachment(middle, 0);
fdUsePart.top = new FormAttachment(wSpecifyFields, margin * 5);
fdUsePart.right = new FormAttachment(100, 0);
wUsePart.setLayoutData(fdUsePart);
wUsePart.addSelectionListener(lsSelMod);
wUsePart.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
if (wUsePart.getSelection()) {
wNameInField.setSelection(false);
}
setFlags();
}
});
// Partitioning field
wlPartField = new Label(wMainComp, SWT.RIGHT);
wlPartField.setText(BaseMessages.getString(PKG, "TableOutputDialog.PartField.Label"));
props.setLook(wlPartField);
fdlPartField = new FormData();
fdlPartField.top = new FormAttachment(wUsePart, margin);
fdlPartField.left = new FormAttachment(0, 0);
fdlPartField.right = new FormAttachment(middle, -margin);
wlPartField.setLayoutData(fdlPartField);
wPartField = new ComboVar(transMeta, wMainComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wPartField);
wPartField.addModifyListener(lsMod);
fdPartField = new FormData();
fdPartField.top = new FormAttachment(wUsePart, margin);
fdPartField.left = new FormAttachment(middle, 0);
fdPartField.right = new FormAttachment(100, 0);
wPartField.setLayoutData(fdPartField);
wPartField.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);
getFields();
shell.setCursor(null);
busy.dispose();
}
});
// Partition per month
wlPartMonthly = new Label(wMainComp, SWT.RIGHT);
wlPartMonthly.setText(BaseMessages.getString(PKG, "TableOutputDialog.PartMonthly.Label"));
wlPartMonthly.setToolTipText(BaseMessages.getString(PKG, "TableOutputDialog.PartMonthly.Tooltip"));
props.setLook(wlPartMonthly);
fdlPartMonthly = new FormData();
fdlPartMonthly.left = new FormAttachment(0, 0);
fdlPartMonthly.top = new FormAttachment(wPartField, margin);
fdlPartMonthly.right = new FormAttachment(middle, -margin);
wlPartMonthly.setLayoutData(fdlPartMonthly);
wPartMonthly = new Button(wMainComp, SWT.RADIO);
props.setLook(wPartMonthly);
fdPartMonthly = new FormData();
fdPartMonthly.left = new FormAttachment(middle, 0);
fdPartMonthly.top = new FormAttachment(wPartField, margin);
fdPartMonthly.right = new FormAttachment(100, 0);
wPartMonthly.setLayoutData(fdPartMonthly);
wPartMonthly.addSelectionListener(lsSelMod);
wPartMonthly.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
wPartMonthly.setSelection(true);
wPartDaily.setSelection(false);
}
});
// Partition per month
wlPartDaily = new Label(wMainComp, SWT.RIGHT);
wlPartDaily.setText(BaseMessages.getString(PKG, "TableOutputDialog.PartDaily.Label"));
wlPartDaily.setToolTipText(BaseMessages.getString(PKG, "TableOutputDialog.PartDaily.Tooltip"));
props.setLook(wlPartDaily);
fdlPartDaily = new FormData();
fdlPartDaily.left = new FormAttachment(0, 0);
fdlPartDaily.top = new FormAttachment(wPartMonthly, margin);
fdlPartDaily.right = new FormAttachment(middle, -margin);
wlPartDaily.setLayoutData(fdlPartDaily);
wPartDaily = new Button(wMainComp, SWT.RADIO);
props.setLook(wPartDaily);
fdPartDaily = new FormData();
fdPartDaily.left = new FormAttachment(middle, 0);
fdPartDaily.top = new FormAttachment(wPartMonthly, margin);
fdPartDaily.right = new FormAttachment(100, 0);
wPartDaily.setLayoutData(fdPartDaily);
wPartDaily.addSelectionListener(lsSelMod);
wPartDaily.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
wPartDaily.setSelection(true);
wPartMonthly.setSelection(false);
}
});
// Batch update
wlBatch = new Label(wMainComp, SWT.RIGHT);
wlBatch.setText(BaseMessages.getString(PKG, "TableOutputDialog.Batch.Label"));
props.setLook(wlBatch);
fdlBatch = new FormData();
fdlBatch.left = new FormAttachment(0, 0);
fdlBatch.top = new FormAttachment(wPartDaily, 5 * margin);
fdlBatch.right = new FormAttachment(middle, -margin);
wlBatch.setLayoutData(fdlBatch);
wBatch = new Button(wMainComp, SWT.CHECK);
props.setLook(wBatch);
fdBatch = new FormData();
fdBatch.left = new FormAttachment(middle, 0);
fdBatch.top = new FormAttachment(wPartDaily, 5 * margin);
fdBatch.right = new FormAttachment(100, 0);
wBatch.setLayoutData(fdBatch);
wBatch.addSelectionListener(lsSelMod);
wBatch.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
setFlags();
}
});
// NameInField
wlNameInField = new Label(wMainComp, SWT.RIGHT);
wlNameInField.setText(BaseMessages.getString(PKG, "TableOutputDialog.NameInField.Label"));
props.setLook(wlNameInField);
fdlNameInField = new FormData();
fdlNameInField.left = new FormAttachment(0, 0);
fdlNameInField.top = new FormAttachment(wBatch, margin * 5);
fdlNameInField.right = new FormAttachment(middle, -margin);
wlNameInField.setLayoutData(fdlNameInField);
wNameInField = new Button(wMainComp, SWT.CHECK);
props.setLook(wNameInField);
fdNameInField = new FormData();
fdNameInField.left = new FormAttachment(middle, 0);
fdNameInField.top = new FormAttachment(wBatch, margin * 5);
fdNameInField.right = new FormAttachment(100, 0);
wNameInField.setLayoutData(fdNameInField);
wNameInField.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent se) {
if (wNameInField.getSelection()) {
wUsePart.setSelection(false);
}
setFlags();
}
});
wNameInField.addSelectionListener(lsSelMod);
// NameField size ...
wlNameField = new Label(wMainComp, SWT.RIGHT);
wlNameField.setText(BaseMessages.getString(PKG, "TableOutputDialog.NameField.Label"));
props.setLook(wlNameField);
fdlNameField = new FormData();
fdlNameField.left = new FormAttachment(0, 0);
fdlNameField.top = new FormAttachment(wNameInField, margin);
fdlNameField.right = new FormAttachment(middle, -margin);
wlNameField.setLayoutData(fdlNameField);
wNameField = new ComboVar(transMeta, wMainComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wNameField);
wNameField.addModifyListener(lsMod);
fdNameField = new FormData();
fdNameField.left = new FormAttachment(middle, 0);
fdNameField.top = new FormAttachment(wNameInField, margin);
fdNameField.right = new FormAttachment(100, 0);
wNameField.setLayoutData(fdNameField);
wNameField.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);
getFields();
shell.setCursor(null);
busy.dispose();
}
});
// NameInTable
wlNameInTable = new Label(wMainComp, SWT.RIGHT);
wlNameInTable.setText(BaseMessages.getString(PKG, "TableOutputDialog.NameInTable.Label"));
props.setLook(wlNameInTable);
fdlNameInTable = new FormData();
fdlNameInTable.left = new FormAttachment(0, 0);
fdlNameInTable.top = new FormAttachment(wNameField, margin);
fdlNameInTable.right = new FormAttachment(middle, -margin);
wlNameInTable.setLayoutData(fdlNameInTable);
wNameInTable = new Button(wMainComp, SWT.CHECK);
props.setLook(wNameInTable);
fdNameInTable = new FormData();
fdNameInTable.left = new FormAttachment(middle, 0);
fdNameInTable.top = new FormAttachment(wNameField, margin);
fdNameInTable.right = new FormAttachment(100, 0);
wNameInTable.setLayoutData(fdNameInTable);
wNameInTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
setFlags();
}
});
wNameInTable.addSelectionListener(lsSelMod);
// Return generated keys?
wlReturnKeys = new Label(wMainComp, SWT.RIGHT);
wlReturnKeys.setText(BaseMessages.getString(PKG, "TableOutputDialog.ReturnKeys.Label"));
wlReturnKeys.setToolTipText(BaseMessages.getString(PKG, "TableOutputDialog.ReturnKeys.Tooltip"));
props.setLook(wlReturnKeys);
fdlReturnKeys = new FormData();
fdlReturnKeys.left = new FormAttachment(0, 0);
fdlReturnKeys.top = new FormAttachment(wNameInTable, margin * 5);
fdlReturnKeys.right = new FormAttachment(middle, -margin);
wlReturnKeys.setLayoutData(fdlReturnKeys);
wReturnKeys = new Button(wMainComp, SWT.CHECK);
props.setLook(wReturnKeys);
fdReturnKeys = new FormData();
fdReturnKeys.left = new FormAttachment(middle, 0);
fdReturnKeys.top = new FormAttachment(wNameInTable, margin * 5);
fdReturnKeys.right = new FormAttachment(100, 0);
wReturnKeys.setLayoutData(fdReturnKeys);
wReturnKeys.addSelectionListener(lsSelMod);
wReturnKeys.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
setFlags();
}
});
// ReturnField size ...
wlReturnField = new Label(wMainComp, SWT.RIGHT);
wlReturnField.setText(BaseMessages.getString(PKG, "TableOutputDialog.ReturnField.Label"));
props.setLook(wlReturnField);
fdlReturnField = new FormData();
fdlReturnField.left = new FormAttachment(0, 0);
fdlReturnField.right = new FormAttachment(middle, -margin);
fdlReturnField.top = new FormAttachment(wReturnKeys, margin);
wlReturnField.setLayoutData(fdlReturnField);
wReturnField = new TextVar(transMeta, wMainComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wReturnField);
wReturnField.addModifyListener(lsMod);
fdReturnField = new FormData();
fdReturnField.left = new FormAttachment(middle, 0);
fdReturnField.top = new FormAttachment(wReturnKeys, margin);
fdReturnField.right = new FormAttachment(100, 0);
wReturnField.setLayoutData(fdReturnField);
fdMainComp = new FormData();
fdMainComp.left = new FormAttachment(0, 0);
fdMainComp.top = new FormAttachment(0, 0);
fdMainComp.right = new FormAttachment(100, 0);
fdMainComp.bottom = new FormAttachment(100, 0);
wMainComp.setLayoutData(fdMainComp);
wMainComp.layout();
wMainTab.setControl(wMainComp);
//
// Fields tab...
//
wFieldsTab = new CTabItem(wTabFolder, SWT.NONE);
wFieldsTab.setText(BaseMessages.getString(PKG, "TableOutputDialog.FieldsTab.CTabItem.Title"));
Composite wFieldsComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wFieldsComp);
FormLayout fieldsCompLayout = new FormLayout();
fieldsCompLayout.marginWidth = Const.FORM_MARGIN;
fieldsCompLayout.marginHeight = Const.FORM_MARGIN;
wFieldsComp.setLayout(fieldsCompLayout);
// The fields table
wlFields = new Label(wFieldsComp, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "TableOutputDialog.InsertFields.Label"));
props.setLook(wlFields);
FormData fdlUpIns = new FormData();
fdlUpIns.left = new FormAttachment(0, 0);
fdlUpIns.top = new FormAttachment(0, margin);
wlFields.setLayoutData(fdlUpIns);
int tableCols = 2;
int UpInsRows = (input.getFieldStream() != null ? input.getFieldStream().length : 1);
ciFields = new ColumnInfo[tableCols];
ciFields[0] = new ColumnInfo(BaseMessages.getString(PKG, "TableOutputDialog.ColumnInfo.TableField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciFields[1] = new ColumnInfo(BaseMessages.getString(PKG, "TableOutputDialog.ColumnInfo.StreamField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
tableFieldColumns.add(ciFields[0]);
wFields = new TableView(transMeta, wFieldsComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciFields, UpInsRows, lsMod, props);
wGetFields = new Button(wFieldsComp, SWT.PUSH);
wGetFields.setText(BaseMessages.getString(PKG, "TableOutputDialog.GetFields.Button"));
fdGetFields = new FormData();
fdGetFields.top = new FormAttachment(wlFields, margin);
fdGetFields.right = new FormAttachment(100, 0);
wGetFields.setLayoutData(fdGetFields);
wDoMapping = new Button(wFieldsComp, SWT.PUSH);
wDoMapping.setText(BaseMessages.getString(PKG, "TableOutputDialog.DoMapping.Button"));
fdDoMapping = new FormData();
fdDoMapping.top = new FormAttachment(wGetFields, margin);
fdDoMapping.right = new FormAttachment(100, 0);
wDoMapping.setLayoutData(fdDoMapping);
wDoMapping.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event arg0) {
generateMappings();
}
});
FormData fdFields = new FormData();
fdFields.left = new FormAttachment(0, 0);
fdFields.top = new FormAttachment(wlFields, margin);
fdFields.right = new FormAttachment(wDoMapping, -margin);
fdFields.bottom = new FormAttachment(100, -2 * 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);
//
// 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();
// Some buttons
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wCreate = new Button(shell, SWT.PUSH);
wCreate.setText(BaseMessages.getString(PKG, "System.Button.SQL"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOK, wCancel, wCreate }, margin, null);
fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(wSpecifyFields, margin);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(wOK, -margin);
wTabFolder.setLayoutData(fdTabFolder);
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsCreate = new Listener() {
public void handleEvent(Event e) {
sql();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsGet = new Listener() {
public void handleEvent(Event e) {
get();
}
};
wOK.addListener(SWT.Selection, lsOK);
wCreate.addListener(SWT.Selection, lsCreate);
wCancel.addListener(SWT.Selection, lsCancel);
wGetFields.addListener(SWT.Selection, lsGet);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wCommit.addSelectionListener(lsDef);
wSchema.addSelectionListener(lsDef);
wTable.addSelectionListener(lsDef);
wPartField.addSelectionListener(lsDef);
wNameField.addSelectionListener(lsDef);
wReturnField.addSelectionListener(lsDef);
wbTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
getTableName();
}
});
wbSchema.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
getSchemaNames();
}
});
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
wTabFolder.setSelection(0);
// Set the shell size, based upon previous time...
setSize();
getData();
setTableFieldCombo();
input.setChanged(backupChanged);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.widget.ComboVar in project pentaho-kettle by pentaho.
the class MonetDBBulkLoaderDialog method addConnectionLine.
public ComboVar addConnectionLine(Composite parent, Control previous, int middle, int margin, final Class<? extends DatabaseInterface> databaseType, final TransMeta transMeta) {
final ComboVar wConnection;
final FormData fdlConnection, fdbConnection, fdeConnection, fdConnection;
wConnection = new ComboVar(transMeta, parent, SWT.BORDER);
props.setLook(wConnection);
addDatabases(wConnection, null);
//
// Database connection (Label)
//
Label wlConnection = new Label(parent, SWT.LEFT);
wlConnection.setText(BaseMessages.getString(PKG, "MonetDBBulkLoaderDialog.Connection.Label"));
props.setLook(wlConnection);
//
// New (Button)
//
Button wbnConnection = new Button(parent, SWT.RIGHT);
wbnConnection.setText(BaseMessages.getString(PKG, "MonetDBBulkLoaderDialog.NewConnectionButton.Label"));
wbnConnection.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DatabaseMeta databaseMeta = new DatabaseMeta();
databaseMeta.shareVariablesWith(transMeta);
DatabaseDialog cid = getDatabaseDialog(shell);
cid.setDatabaseMeta(databaseMeta);
cid.setModalDialog(true);
if (cid.open() != null) {
transMeta.addDatabase(databaseMeta);
wConnection.removeAll();
addDatabases(wConnection, databaseType);
selectDatabase(wConnection, databaseMeta.getName());
}
}
});
//
// Edit (Button)
//
Button wbeConnection = new Button(parent, SWT.RIGHT);
wbeConnection.setText(BaseMessages.getString(PKG, "BaseStepDialog.EditConnectionButton.Label"));
wbeConnection.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DatabaseMeta databaseMeta = transMeta.findDatabase(wConnection.getText());
if (databaseMeta != null) {
databaseMeta.shareVariablesWith(transMeta);
DatabaseDialog cid = getDatabaseDialog(shell);
cid.setDatabaseMeta(databaseMeta);
cid.setModalDialog(true);
if (cid.open() != null) {
wConnection.removeAll();
addDatabases(wConnection, null);
selectDatabase(wConnection, databaseMeta.getName());
}
}
}
});
//
// Database connection (Label layout)
//
fdlConnection = new FormData();
// attaches to the left of the bounding container
fdlConnection.left = new FormAttachment(0, margin);
if (previous != null) {
fdlConnection.top = new FormAttachment(previous, margin + 10);
} else {
fdlConnection.top = new FormAttachment(0, 0);
}
wlConnection.setLayoutData(fdlConnection);
//
// New (Button layout)
//
fdbConnection = new FormData();
fdbConnection.right = new FormAttachment(100, -margin);
if (previous != null) {
fdbConnection.top = new FormAttachment(previous, margin);
} else {
fdbConnection.top = new FormAttachment(0, 0);
}
wbnConnection.setLayoutData(fdbConnection);
//
// Edit (Button layout)
//
fdeConnection = new FormData();
fdeConnection.right = new FormAttachment(wbnConnection, -margin);
if (previous != null) {
fdeConnection.top = new FormAttachment(previous, margin);
} else {
fdeConnection.top = new FormAttachment(0, 0);
}
wbeConnection.setLayoutData(fdeConnection);
//
// Connection (Combo Box layout)
//
// The right side of the Combo Box is attached to the Edit button
// The left side of the Combo Box is attached to the side of the database connection label
// Effectively, it resizes the combo box between the two components.
fdConnection = new FormData();
// fdConnection.height = fieldHeight;
fdConnection.left = new FormAttachment(middle, margin);
fdConnection.right = new FormAttachment(wbeConnection, -margin);
if (previous != null) {
fdConnection.top = new FormAttachment(previous, margin + 10);
} else {
fdConnection.top = new FormAttachment(wlConnection, margin);
}
wConnection.setLayoutData(fdConnection);
return wConnection;
}
Aggregations