use of org.pentaho.di.ui.core.widget.ColumnInfo in project pentaho-kettle by pentaho.
the class SimpleMappingDialog method addMappingDefinitionTab.
private void addMappingDefinitionTab(final MappingIODefinition definition, int index, final String tabTitle, final String tabTooltip, String sourceColumnLabel, String targetColumnLabel, final boolean input) {
final CTabItem wTab;
if (index >= wTabFolder.getItemCount()) {
wTab = new CTabItem(wTabFolder, SWT.CLOSE);
} else {
wTab = new CTabItem(wTabFolder, SWT.CLOSE, index);
}
setMappingDefinitionTabNameAndToolTip(wTab, tabTitle, tabTooltip, definition, input);
Composite wInputComposite = new Composite(wTabFolder, SWT.NONE);
props.setLook(wInputComposite);
FormLayout tabLayout = new FormLayout();
tabLayout.marginWidth = 15;
tabLayout.marginHeight = 15;
wInputComposite.setLayout(tabLayout);
// Now add a table view with the 2 columns to specify: input and output
// fields for the source and target steps.
//
final Button wbEnterMapping = new Button(wInputComposite, SWT.PUSH);
props.setLook(wbEnterMapping);
if (input) {
wbEnterMapping.setText(BaseMessages.getString(PKG, "SimpleMappingDialog.button.EnterMapping"));
} else {
wbEnterMapping.setText(BaseMessages.getString(PKG, "SimpleMappingDialog.button.GetFields"));
}
FormData fdbEnterMapping = new FormData();
fdbEnterMapping.bottom = new FormAttachment(100);
fdbEnterMapping.right = new FormAttachment(100);
wbEnterMapping.setLayoutData(fdbEnterMapping);
ColumnInfo[] colinfo = new ColumnInfo[] { new ColumnInfo(sourceColumnLabel, ColumnInfo.COLUMN_TYPE_TEXT, false, false), new ColumnInfo(targetColumnLabel, ColumnInfo.COLUMN_TYPE_TEXT, false, false) };
final TableView wFieldMappings = new TableView(transMeta, wInputComposite, SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER, colinfo, 1, false, lsMod, props, false);
props.setLook(wFieldMappings);
FormData fdMappings = new FormData();
fdMappings.left = new FormAttachment(0);
fdMappings.right = new FormAttachment(100);
fdMappings.top = new FormAttachment(0);
fdMappings.bottom = new FormAttachment(wbEnterMapping, -10);
wFieldMappings.setLayoutData(fdMappings);
wFieldMappings.getTable().addListener(SWT.Resize, new ColumnsResizer(0, 50, 50));
for (MappingValueRename valueRename : definition.getValueRenames()) {
TableItem tableItem = new TableItem(wFieldMappings.table, SWT.NONE);
tableItem.setText(1, Const.NVL(valueRename.getSourceValueName(), ""));
tableItem.setText(2, Const.NVL(valueRename.getTargetValueName(), ""));
}
wFieldMappings.removeEmptyRows();
wFieldMappings.setRowNums();
wFieldMappings.optWidth(true);
wbEnterMapping.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
try {
if (input) {
// INPUT
//
RowMetaInterface sourceRowMeta = getFieldsFromStep(true, input);
RowMetaInterface targetRowMeta = getFieldsFromStep(false, input);
String[] sourceFields = sourceRowMeta.getFieldNames();
String[] targetFields = targetRowMeta.getFieldNames();
EnterMappingDialog dialog = new EnterMappingDialog(shell, sourceFields, targetFields);
List<SourceToTargetMapping> mappings = dialog.open();
if (mappings != null) {
// first clear the dialog...
wFieldMappings.clearAll(false);
//
definition.getValueRenames().clear();
// Now add the new values...
for (int i = 0; i < mappings.size(); i++) {
SourceToTargetMapping mapping = mappings.get(i);
TableItem item = new TableItem(wFieldMappings.table, SWT.NONE);
item.setText(1, mapping.getSourceString(sourceFields));
item.setText(2, mapping.getTargetString(targetFields));
String source = input ? item.getText(1) : item.getText(2);
String target = input ? item.getText(2) : item.getText(1);
definition.getValueRenames().add(new MappingValueRename(source, target));
}
wFieldMappings.removeEmptyRows();
wFieldMappings.setRowNums();
wFieldMappings.optWidth(true);
}
} else {
// OUTPUT
//
RowMetaInterface sourceRowMeta = getFieldsFromStep(true, input);
BaseStepDialog.getFieldsFromPrevious(sourceRowMeta, wFieldMappings, 1, new int[] { 1 }, new int[] {}, -1, -1, null);
}
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "SimpleMappingDialog.Exception.ErrorGettingMappingSourceAndTargetFields", e.toString()), e);
}
}
});
if (input) {
Button wRenameOutput = new Button(wInputComposite, SWT.CHECK);
props.setLook(wRenameOutput);
wRenameOutput.setText(BaseMessages.getString(PKG, "SimpleMappingDialog.input.RenamingOnOutput"));
FormData fdRenameOutput = new FormData();
fdRenameOutput.top = new FormAttachment(wFieldMappings, 10);
fdRenameOutput.left = new FormAttachment(0, 0);
wRenameOutput.setLayoutData(fdRenameOutput);
wRenameOutput.setSelection(definition.isRenamingOnOutput());
wRenameOutput.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
// flip the switch
definition.setRenamingOnOutput(!definition.isRenamingOnOutput());
}
});
}
FormData fdParametersComposite = new FormData();
fdParametersComposite.left = new FormAttachment(0, 0);
fdParametersComposite.top = new FormAttachment(0, 0);
fdParametersComposite.right = new FormAttachment(100, 0);
fdParametersComposite.bottom = new FormAttachment(100, 0);
wInputComposite.setLayoutData(fdParametersComposite);
wInputComposite.layout();
wTab.setControl(wInputComposite);
final ApplyChanges applyChanges = new MappingDefinitionTab(definition, wFieldMappings);
changeList.add(applyChanges);
wTabFolder.setSelection(wTab);
}
use of org.pentaho.di.ui.core.widget.ColumnInfo in project pentaho-kettle by pentaho.
the class TransExecutorDialog method addResultRowsTab.
private void addResultRowsTab() {
final CTabItem wTab = new CTabItem(wTabFolder, SWT.NONE);
wTab.setText(BaseMessages.getString(PKG, "TransExecutorDialog.ResultRows.Title"));
wTab.setToolTipText(BaseMessages.getString(PKG, "TransExecutorDialog.ResultRows.Tooltip"));
ScrolledComposite scrolledComposite = new ScrolledComposite(wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL);
scrolledComposite.setLayout(new FillLayout());
Composite wInputComposite = new Composite(scrolledComposite, SWT.NONE);
props.setLook(wInputComposite);
FormLayout tabLayout = new FormLayout();
tabLayout.marginWidth = 15;
tabLayout.marginHeight = 15;
wInputComposite.setLayout(tabLayout);
wlResultRowsTarget = new Label(wInputComposite, SWT.RIGHT);
props.setLook(wlResultRowsTarget);
wlResultRowsTarget.setText(BaseMessages.getString(PKG, "TransExecutorDialog.OutputRowsSource.Label"));
FormData fdlResultRowsTarget = new FormData();
fdlResultRowsTarget.top = new FormAttachment(0, 0);
// First one in the left
fdlResultRowsTarget.left = new FormAttachment(0, 0);
wlResultRowsTarget.setLayoutData(fdlResultRowsTarget);
wOutputRowsSource = new CCombo(wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wOutputRowsSource);
wOutputRowsSource.addModifyListener(lsMod);
FormData fdResultRowsTarget = new FormData();
fdResultRowsTarget.width = 250;
fdResultRowsTarget.top = new FormAttachment(wlResultRowsTarget, 5);
// To the right
fdResultRowsTarget.left = new FormAttachment(0, 0);
wOutputRowsSource.setLayoutData(fdResultRowsTarget);
wlOutputFields = new Label(wInputComposite, SWT.NONE);
wlOutputFields.setText(BaseMessages.getString(PKG, "TransExecutorDialog.ResultFields.Label"));
props.setLook(wlOutputFields);
FormData fdlResultFields = new FormData();
fdlResultFields.left = new FormAttachment(0, 0);
fdlResultFields.top = new FormAttachment(wOutputRowsSource, 10);
wlOutputFields.setLayoutData(fdlResultFields);
int nrRows = (transExecutorMeta.getOutputRowsField() != null ? transExecutorMeta.getOutputRowsField().length : 1);
ColumnInfo[] ciResultFields = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "TransExecutorDialog.ColumnInfo.Field"), ColumnInfo.COLUMN_TYPE_TEXT, false, false), new ColumnInfo(BaseMessages.getString(PKG, "TransExecutorDialog.ColumnInfo.Type"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames()), new ColumnInfo(BaseMessages.getString(PKG, "TransExecutorDialog.ColumnInfo.Length"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "TransExecutorDialog.ColumnInfo.Precision"), ColumnInfo.COLUMN_TYPE_TEXT, false) };
wOutputFields = new TableView(transMeta, wInputComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciResultFields, nrRows, false, lsMod, props, false);
FormData fdResultFields = new FormData();
fdResultFields.left = new FormAttachment(0, 0);
fdResultFields.top = new FormAttachment(wlOutputFields, 5);
fdResultFields.right = new FormAttachment(100, 0);
fdResultFields.bottom = new FormAttachment(100, 0);
wOutputFields.setLayoutData(fdResultFields);
wOutputFields.getTable().addListener(SWT.Resize, new ColumnsResizer(0, 25, 25, 25, 25));
wInputComposite.pack();
Rectangle bounds = wInputComposite.getBounds();
scrolledComposite.setContent(wInputComposite);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
scrolledComposite.setMinWidth(bounds.width);
scrolledComposite.setMinHeight(bounds.height);
wTab.setControl(scrolledComposite);
wTabFolder.setSelection(wTab);
}
use of org.pentaho.di.ui.core.widget.ColumnInfo in project pentaho-kettle by pentaho.
the class UniqueRowsDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
props.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
input.setChanged();
}
};
changed = input.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "UniqueRowsDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "UniqueRowsDialog.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 Settings GROUP //
// ///////////////////////////////
wSettings = new Group(shell, SWT.SHADOW_NONE);
props.setLook(wSettings);
wSettings.setText(BaseMessages.getString(PKG, "UniqueRowsDialog.Settings.Label"));
FormLayout SettingsgroupLayout = new FormLayout();
SettingsgroupLayout.marginWidth = 10;
SettingsgroupLayout.marginHeight = 10;
wSettings.setLayout(SettingsgroupLayout);
wlCount = new Label(wSettings, SWT.RIGHT);
wlCount.setText(BaseMessages.getString(PKG, "UniqueRowsDialog.Count.Label"));
props.setLook(wlCount);
fdlCount = new FormData();
fdlCount.left = new FormAttachment(0, 0);
fdlCount.top = new FormAttachment(wStepname, margin);
fdlCount.right = new FormAttachment(middle, -margin);
wlCount.setLayoutData(fdlCount);
wCount = new Button(wSettings, SWT.CHECK);
props.setLook(wCount);
wCount.setToolTipText(BaseMessages.getString(PKG, "UniqueRowsDialog.Count.ToolTip", Const.CR));
fdCount = new FormData();
fdCount.left = new FormAttachment(middle, 0);
fdCount.top = new FormAttachment(wStepname, margin);
wCount.setLayoutData(fdCount);
wCount.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
setFlags();
}
});
wlCountField = new Label(wSettings, SWT.LEFT);
wlCountField.setText(BaseMessages.getString(PKG, "UniqueRowsDialog.CounterField.Label"));
props.setLook(wlCountField);
fdlCountField = new FormData();
fdlCountField.left = new FormAttachment(wCount, margin);
fdlCountField.top = new FormAttachment(wStepname, margin);
wlCountField.setLayoutData(fdlCountField);
wCountField = new Text(wSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wCountField);
wCountField.addModifyListener(lsMod);
fdCountField = new FormData();
fdCountField.left = new FormAttachment(wlCountField, margin);
fdCountField.top = new FormAttachment(wStepname, margin);
fdCountField.right = new FormAttachment(100, 0);
wCountField.setLayoutData(fdCountField);
wlRejectDuplicateRow = new Label(wSettings, SWT.RIGHT);
wlRejectDuplicateRow.setText(BaseMessages.getString(PKG, "UniqueRowsDialog.RejectDuplicateRow.Label"));
props.setLook(wlRejectDuplicateRow);
fdlRejectDuplicateRow = new FormData();
fdlRejectDuplicateRow.left = new FormAttachment(0, 0);
fdlRejectDuplicateRow.top = new FormAttachment(wCountField, margin);
fdlRejectDuplicateRow.right = new FormAttachment(middle, -margin);
wlRejectDuplicateRow.setLayoutData(fdlRejectDuplicateRow);
wRejectDuplicateRow = new Button(wSettings, SWT.CHECK);
props.setLook(wRejectDuplicateRow);
wRejectDuplicateRow.setToolTipText(BaseMessages.getString(PKG, "UniqueRowsDialog.RejectDuplicateRow.ToolTip", Const.CR));
fdRejectDuplicateRow = new FormData();
fdRejectDuplicateRow.left = new FormAttachment(middle, margin);
fdRejectDuplicateRow.top = new FormAttachment(wCountField, margin);
wRejectDuplicateRow.setLayoutData(fdRejectDuplicateRow);
wRejectDuplicateRow.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
setErrorDesc();
}
});
wlErrorDesc = new Label(wSettings, SWT.LEFT);
wlErrorDesc.setText(BaseMessages.getString(PKG, "UniqueRowsDialog.ErrorDescription.Label"));
props.setLook(wlErrorDesc);
fdlErrorDesc = new FormData();
fdlErrorDesc.left = new FormAttachment(wRejectDuplicateRow, margin);
fdlErrorDesc.top = new FormAttachment(wCountField, margin);
wlErrorDesc.setLayoutData(fdlErrorDesc);
wErrorDesc = new TextVar(transMeta, wSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wErrorDesc);
wErrorDesc.addModifyListener(lsMod);
fdErrorDesc = new FormData();
fdErrorDesc.left = new FormAttachment(wlErrorDesc, margin);
fdErrorDesc.top = new FormAttachment(wCountField, margin);
fdErrorDesc.right = new FormAttachment(100, 0);
wErrorDesc.setLayoutData(fdErrorDesc);
fdSettings = new FormData();
fdSettings.left = new FormAttachment(0, margin);
fdSettings.top = new FormAttachment(wStepname, margin);
fdSettings.right = new FormAttachment(100, -margin);
wSettings.setLayoutData(fdSettings);
// ///////////////////////////////////////////////////////////
// / END OF Settings GROUP
// ///////////////////////////////////////////////////////////
// Some buttons
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wGet = new Button(shell, SWT.PUSH);
wGet.setText(BaseMessages.getString(PKG, "UniqueRowsDialog.Get.Button"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
fdOK = new FormData();
setButtonPositions(new Button[] { wOK, wCancel, wGet }, margin, null);
wlFields = new Label(shell, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "UniqueRowsDialog.Fields.Label"));
props.setLook(wlFields);
fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.top = new FormAttachment(wSettings, margin);
wlFields.setLayoutData(fdlFields);
final int FieldsRows = input.getCompareFields() == null ? 0 : input.getCompareFields().length;
colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "UniqueRowsDialog.ColumnInfo.Fieldname"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false), new ColumnInfo(BaseMessages.getString(PKG, "UniqueRowsDialog.ColumnInfo.IgnoreCase"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "Y", "N" }, true) };
wFields = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod, props);
fdFields = new FormData();
fdFields.left = new FormAttachment(0, 0);
fdFields.top = new FormAttachment(wlFields, margin);
fdFields.right = new FormAttachment(100, 0);
fdFields.bottom = new FormAttachment(wOK, -2 * margin);
wFields.setLayoutData(fdFields);
//
// Search the fields in the background
final Runnable runnable = new Runnable() {
public void run() {
StepMeta stepMeta = transMeta.findStep(stepname);
if (stepMeta != null) {
try {
RowMetaInterface row = transMeta.getPrevStepFields(stepMeta);
// Remember these fields...
for (int i = 0; i < row.size(); i++) {
inputFields.put(row.getValueMeta(i).getName(), Integer.valueOf(i));
}
setComboBoxes();
} catch (KettleException e) {
logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
}
}
};
new Thread(runnable).start();
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsGet = new Listener() {
public void handleEvent(Event e) {
get();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wGet.addListener(SWT.Selection, lsGet);
wOK.addListener(SWT.Selection, lsOK);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wCountField.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.ColumnInfo in project pentaho-kettle by pentaho.
the class UniqueRowsByHashSetDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
props.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
input.setChanged();
}
};
changed = input.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.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 Settings GROUP //
// ///////////////////////////////
wSettings = new Group(shell, SWT.SHADOW_NONE);
props.setLook(wSettings);
wSettings.setText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.Settings.Label"));
FormLayout SettingsgroupLayout = new FormLayout();
SettingsgroupLayout.marginWidth = 10;
SettingsgroupLayout.marginHeight = 10;
wSettings.setLayout(SettingsgroupLayout);
wlStoreValues = new Label(wSettings, SWT.RIGHT);
wlStoreValues.setText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.StoreValues.Label"));
props.setLook(wlStoreValues);
fdlStoreValues = new FormData();
fdlStoreValues.left = new FormAttachment(0, 0);
fdlStoreValues.top = new FormAttachment(wStepname, margin);
fdlStoreValues.right = new FormAttachment(middle, -margin);
wlStoreValues.setLayoutData(fdlStoreValues);
wStoreValues = new Button(wSettings, SWT.CHECK);
props.setLook(wStoreValues);
wStoreValues.setToolTipText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.StoreValues.ToolTip", Const.CR));
fdStoreValues = new FormData();
fdStoreValues.left = new FormAttachment(middle, 0);
fdStoreValues.top = new FormAttachment(wStepname, margin);
wStoreValues.setLayoutData(fdStoreValues);
wStoreValues.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
wlRejectDuplicateRow = new Label(wSettings, SWT.RIGHT);
wlRejectDuplicateRow.setText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.RejectDuplicateRow.Label"));
props.setLook(wlRejectDuplicateRow);
fdlRejectDuplicateRow = new FormData();
fdlRejectDuplicateRow.left = new FormAttachment(0, 0);
fdlRejectDuplicateRow.top = new FormAttachment(wStoreValues, margin);
fdlRejectDuplicateRow.right = new FormAttachment(middle, -margin);
wlRejectDuplicateRow.setLayoutData(fdlRejectDuplicateRow);
wRejectDuplicateRow = new Button(wSettings, SWT.CHECK);
props.setLook(wRejectDuplicateRow);
wRejectDuplicateRow.setToolTipText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.RejectDuplicateRow.ToolTip", Const.CR));
fdRejectDuplicateRow = new FormData();
fdRejectDuplicateRow.left = new FormAttachment(middle, 0);
fdRejectDuplicateRow.top = new FormAttachment(wStoreValues, margin);
wRejectDuplicateRow.setLayoutData(fdRejectDuplicateRow);
wRejectDuplicateRow.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
setErrorDesc();
}
});
wlErrorDesc = new Label(wSettings, SWT.LEFT);
wlErrorDesc.setText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.ErrorDescription.Label"));
props.setLook(wlErrorDesc);
fdlErrorDesc = new FormData();
fdlErrorDesc.left = new FormAttachment(wRejectDuplicateRow, margin);
fdlErrorDesc.top = new FormAttachment(wStoreValues, margin);
wlErrorDesc.setLayoutData(fdlErrorDesc);
wErrorDesc = new TextVar(transMeta, wSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wErrorDesc);
wErrorDesc.addModifyListener(lsMod);
fdErrorDesc = new FormData();
fdErrorDesc.left = new FormAttachment(wlErrorDesc, margin);
fdErrorDesc.top = new FormAttachment(wStoreValues, margin);
fdErrorDesc.right = new FormAttachment(100, 0);
wErrorDesc.setLayoutData(fdErrorDesc);
fdSettings = new FormData();
fdSettings.left = new FormAttachment(0, margin);
fdSettings.top = new FormAttachment(wStepname, margin);
fdSettings.right = new FormAttachment(100, -margin);
wSettings.setLayoutData(fdSettings);
// ///////////////////////////////////////////////////////////
// / END OF Settings GROUP
// ///////////////////////////////////////////////////////////
// Some buttons
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wGet = new Button(shell, SWT.PUSH);
wGet.setText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.Get.Button"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
fdOK = new FormData();
setButtonPositions(new Button[] { wOK, wCancel, wGet }, margin, null);
wlFields = new Label(shell, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.Fields.Label"));
props.setLook(wlFields);
fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.top = new FormAttachment(wSettings, margin);
wlFields.setLayoutData(fdlFields);
final int FieldsRows = input.getCompareFields() == null ? 0 : input.getCompareFields().length;
colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.ColumnInfo.Fieldname"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false) };
wFields = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod, props);
fdFields = new FormData();
fdFields.left = new FormAttachment(0, 0);
fdFields.top = new FormAttachment(wlFields, margin);
fdFields.right = new FormAttachment(100, 0);
fdFields.bottom = new FormAttachment(wOK, -2 * margin);
wFields.setLayoutData(fdFields);
//
// Search the fields in the background
final Runnable runnable = new Runnable() {
public void run() {
StepMeta stepMeta = transMeta.findStep(stepname);
if (stepMeta != null) {
try {
RowMetaInterface row = transMeta.getPrevStepFields(stepMeta);
// Remember these fields...
for (int i = 0; i < row.size(); i++) {
inputFields.put(row.getValueMeta(i).getName(), Integer.valueOf(i));
}
setComboBoxes();
} catch (KettleException e) {
logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
}
}
};
new Thread(runnable).start();
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsGet = new Listener() {
public void handleEvent(Event e) {
get();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wGet.addListener(SWT.Selection, lsGet);
wOK.addListener(SWT.Selection, lsOK);
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();
setErrorDesc();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.widget.ColumnInfo in project pentaho-kettle by pentaho.
the class UserDefinedJavaClassDialog method addInfoTab.
private void addInfoTab() {
infoTab = new CTabItem(wTabFolder, SWT.NONE);
infoTab.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Tabs.Info.Title"));
infoTab.setToolTipText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Tabs.Info.TooltipText"));
Composite wBottom = new Composite(wTabFolder, SWT.NONE);
props.setLook(wBottom);
infoTab.setControl(wBottom);
FormLayout bottomLayout = new FormLayout();
bottomLayout.marginWidth = Const.FORM_MARGIN;
bottomLayout.marginHeight = Const.FORM_MARGIN;
wBottom.setLayout(bottomLayout);
Label wlFields = new Label(wBottom, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.InfoSteps.Label"));
props.setLook(wlFields);
FormData fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.top = new FormAttachment(0, 0);
wlFields.setLayoutData(fdlFields);
final int nrRows = input.getInfoStepDefinitions().size();
ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.ColumnInfo.StepTag"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.ColumnInfo.StepName"), ColumnInfo.COLUMN_TYPE_CCOMBO, prevStepNames), new ColumnInfo(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.ColumnInfo.StepDescription"), ColumnInfo.COLUMN_TYPE_TEXT, false) };
wInfoSteps = new TableView(transMeta, wBottom, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, nrRows, lsMod, props);
FormData fdFields = new FormData();
fdFields.left = new FormAttachment(0, 0);
fdFields.top = new FormAttachment(wlFields, margin);
fdFields.right = new FormAttachment(100, 0);
fdFields.bottom = new FormAttachment(100, 0);
wInfoSteps.setLayoutData(fdFields);
FormData fdBottom = new FormData();
fdBottom.left = new FormAttachment(0, 0);
fdBottom.top = new FormAttachment(0, 0);
fdBottom.right = new FormAttachment(100, 0);
fdBottom.bottom = new FormAttachment(100, 0);
wBottom.setLayoutData(fdBottom);
}
Aggregations