use of org.pentaho.di.ui.core.widget.TextVar in project pentaho-kettle by pentaho.
the class TransExecutorDialog 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, transExecutorMeta);
lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
transExecutorMeta.setChanged();
setFlags();
}
};
changed = transExecutorMeta.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = 15;
formLayout.marginHeight = 15;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "TransExecutorDialog.Shell.Title"));
Label wicon = new Label(shell, SWT.RIGHT);
wicon.setImage(getImage());
FormData fdlicon = new FormData();
fdlicon.top = new FormAttachment(0, 0);
fdlicon.right = new FormAttachment(100, 0);
wicon.setLayoutData(fdlicon);
props.setLook(wicon);
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "TransExecutorDialog.Stepname.Label"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.top = new FormAttachment(0, 0);
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.width = 250;
fdStepname.left = new FormAttachment(0, 0);
fdStepname.top = new FormAttachment(wlStepname, 5);
wStepname.setLayoutData(fdStepname);
Label spacer = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR);
FormData fdSpacer = new FormData();
fdSpacer.left = new FormAttachment(0, 0);
fdSpacer.top = new FormAttachment(wStepname, 15);
fdSpacer.right = new FormAttachment(100, 0);
spacer.setLayoutData(fdSpacer);
wlPath = new Label(shell, SWT.LEFT);
props.setLook(wlPath);
wlPath.setText(BaseMessages.getString(PKG, "TransExecutorDialog.Transformation.Label"));
FormData fdlTransformation = new FormData();
fdlTransformation.left = new FormAttachment(0, 0);
fdlTransformation.top = new FormAttachment(spacer, 20);
fdlTransformation.right = new FormAttachment(50, 0);
wlPath.setLayoutData(fdlTransformation);
wPath = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wPath);
FormData fdTransformation = new FormData();
fdTransformation.left = new FormAttachment(0, 0);
fdTransformation.top = new FormAttachment(wlPath, 5);
fdTransformation.width = 350;
wPath.setLayoutData(fdTransformation);
wbBrowse = new Button(shell, SWT.PUSH);
props.setLook(wbBrowse);
wbBrowse.setText(BaseMessages.getString(PKG, "TransExecutorDialog.Browse.Label"));
FormData fdBrowse = new FormData();
fdBrowse.left = new FormAttachment(wPath, 5);
fdBrowse.top = new FormAttachment(wlPath, Const.isOSX() ? 0 : 5);
wbBrowse.setLayoutData(fdBrowse);
wbBrowse.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (repository != null) {
selectRepositoryTrans();
} else {
selectFileTrans();
}
}
});
//
// Add a tab folder for the parameters and various input and output
// streams
//
wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
wTabFolder.setSimple(false);
wTabFolder.setUnselectedCloseVisible(true);
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
FormData fdCancel = new FormData();
fdCancel.right = new FormAttachment(100, 0);
fdCancel.bottom = new FormAttachment(100, 0);
wCancel.setLayoutData(fdCancel);
// Some buttons
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
FormData fdOk = new FormData();
fdOk.right = new FormAttachment(wCancel, -5);
fdOk.bottom = new FormAttachment(100, 0);
wOK.setLayoutData(fdOk);
Label hSpacer = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR);
FormData fdhSpacer = new FormData();
fdhSpacer.left = new FormAttachment(0, 0);
fdhSpacer.bottom = new FormAttachment(wCancel, -15);
fdhSpacer.right = new FormAttachment(100, 0);
hSpacer.setLayoutData(fdhSpacer);
FormData fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(wPath, 20);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(hSpacer, -15);
wTabFolder.setLayoutData(fdTabFolder);
// Add the tabs...
//
addParametersTab();
addExecutionResultTab();
addRowGroupTab();
addResultRowsTab();
addResultFilesTab();
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wOK.addListener(SWT.Selection, lsOK);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wPath.addSelectionListener(lsDef);
wResultFileNameField.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(shell, 620, 675);
getData();
transExecutorMeta.setChanged(changed);
wTabFolder.setSelection(0);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.widget.TextVar in project pentaho-kettle by pentaho.
the class TransExecutorDialog method addRowGroupTab.
private void addRowGroupTab() {
final CTabItem wTab = new CTabItem(wTabFolder, SWT.NONE);
wTab.setText(BaseMessages.getString(PKG, "TransExecutorDialog.RowGroup.Title"));
wTab.setToolTipText(BaseMessages.getString(PKG, "TransExecutorDialog.RowGroup.Tooltip"));
Composite wInputComposite = new Composite(wTabFolder, SWT.NONE);
props.setLook(wInputComposite);
FormLayout tabLayout = new FormLayout();
tabLayout.marginWidth = 15;
tabLayout.marginHeight = 15;
wInputComposite.setLayout(tabLayout);
// Group size
//
wlGroupSize = new Label(wInputComposite, SWT.RIGHT);
props.setLook(wlGroupSize);
wlGroupSize.setText(BaseMessages.getString(PKG, "TransExecutorDialog.GroupSize.Label"));
FormData fdlGroupSize = new FormData();
fdlGroupSize.top = new FormAttachment(0, 0);
fdlGroupSize.left = new FormAttachment(0, 0);
wlGroupSize.setLayoutData(fdlGroupSize);
wGroupSize = new TextVar(transMeta, wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wGroupSize);
wGroupSize.addModifyListener(lsMod);
FormData fdGroupSize = new FormData();
fdGroupSize.width = 250;
fdGroupSize.top = new FormAttachment(wlGroupSize, 5);
fdGroupSize.left = new FormAttachment(0, 0);
wGroupSize.setLayoutData(fdGroupSize);
// Group field
//
wlGroupField = new Label(wInputComposite, SWT.RIGHT);
props.setLook(wlGroupField);
wlGroupField.setText(BaseMessages.getString(PKG, "TransExecutorDialog.GroupField.Label"));
FormData fdlGroupField = new FormData();
fdlGroupField.top = new FormAttachment(wGroupSize, 10);
fdlGroupField.left = new FormAttachment(0, 0);
wlGroupField.setLayoutData(fdlGroupField);
wGroupField = new CCombo(wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wGroupField);
wGroupField.addModifyListener(lsMod);
FormData fdGroupField = new FormData();
fdGroupField.width = 250;
fdGroupField.top = new FormAttachment(wlGroupField, 5);
fdGroupField.left = new FormAttachment(0, 0);
wGroupField.setLayoutData(fdGroupField);
// Group time
//
wlGroupTime = new Label(wInputComposite, SWT.RIGHT);
props.setLook(wlGroupTime);
wlGroupTime.setText(BaseMessages.getString(PKG, "TransExecutorDialog.GroupTime.Label"));
FormData fdlGroupTime = new FormData();
fdlGroupTime.top = new FormAttachment(wGroupField, 10);
// First one in the left
fdlGroupTime.left = new FormAttachment(0, 0);
wlGroupTime.setLayoutData(fdlGroupTime);
wGroupTime = new TextVar(transMeta, wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wGroupTime);
wGroupTime.addModifyListener(lsMod);
FormData fdGroupTime = new FormData();
fdGroupTime.width = 250;
fdGroupTime.top = new FormAttachment(wlGroupTime, 5);
fdGroupTime.left = new FormAttachment(0, 0);
wGroupTime.setLayoutData(fdGroupTime);
wTab.setControl(wInputComposite);
wTabFolder.setSelection(wTab);
}
use of org.pentaho.di.ui.core.widget.TextVar in project pentaho-kettle by pentaho.
the class TransExecutorDialog method addResultFilesTab.
private void addResultFilesTab() {
final CTabItem wTab = new CTabItem(wTabFolder, SWT.NONE);
wTab.setText(BaseMessages.getString(PKG, "TransExecutorDialog.ResultFiles.Title"));
wTab.setToolTipText(BaseMessages.getString(PKG, "TransExecutorDialog.ResultFiles.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);
wlResultFilesTarget = new Label(wInputComposite, SWT.RIGHT);
props.setLook(wlResultFilesTarget);
wlResultFilesTarget.setText(BaseMessages.getString(PKG, "TransExecutorDialog.ResultFilesTarget.Label"));
FormData fdlResultFilesTarget = new FormData();
fdlResultFilesTarget.top = new FormAttachment(0, 0);
// First one in the left
fdlResultFilesTarget.left = new FormAttachment(0, 0);
wlResultFilesTarget.setLayoutData(fdlResultFilesTarget);
wResultFilesTarget = new CCombo(wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wResultFilesTarget);
wResultFilesTarget.addModifyListener(lsMod);
FormData fdResultFilesTarget = new FormData();
fdResultFilesTarget.width = 250;
fdResultFilesTarget.top = new FormAttachment(wlResultFilesTarget, 5);
// To the right
fdResultFilesTarget.left = new FormAttachment(0, 0);
wResultFilesTarget.setLayoutData(fdResultFilesTarget);
// ResultFileNameField
//
wlResultFileNameField = new Label(wInputComposite, SWT.RIGHT);
props.setLook(wlResultFileNameField);
wlResultFileNameField.setText(BaseMessages.getString(PKG, "TransExecutorDialog.ResultFileNameField.Label"));
FormData fdlResultFileNameField = new FormData();
fdlResultFileNameField.top = new FormAttachment(wResultFilesTarget, 10);
// First one in the left
fdlResultFileNameField.left = new FormAttachment(0, 0);
wlResultFileNameField.setLayoutData(fdlResultFileNameField);
wResultFileNameField = new TextVar(transMeta, wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wResultFileNameField);
wResultFileNameField.addModifyListener(lsMod);
FormData fdResultFileNameField = new FormData();
fdResultFileNameField.width = 250;
fdResultFileNameField.top = new FormAttachment(wlResultFileNameField, 5);
// To the right
fdResultFileNameField.left = new FormAttachment(0, 0);
wResultFileNameField.setLayoutData(fdResultFileNameField);
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.TextVar 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.TextVar 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;
}
Aggregations