use of org.apache.hop.ui.pipeline.transform.BaseTransformDialog in project hop by apache.
the class MongoDbOutputDialog method open.
@Override
public String open() {
Shell parent = getParent();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
props.setLook(shell);
setShellImage(shell, currentMeta);
// used to listen to a text field (wTransformName)
ModifyListener lsMod = e -> currentMeta.setChanged();
changed = currentMeta.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "MongoDbOutputDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Buttons inherited from BaseTransformDialog
wOk = new Button(shell, SWT.PUSH);
//
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOk.addListener(SWT.Selection, e -> ok());
wCancel = new Button(shell, SWT.PUSH);
//
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wCancel.addListener(SWT.Selection, e -> cancel());
setButtonPositions(new Button[] { wOk, wCancel }, margin, null);
// TransformName line
wlTransformName = new Label(shell, SWT.RIGHT);
wlTransformName.setText(BaseMessages.getString(PKG, "MongoDbOutputDialog.TransformName.Label"));
props.setLook(wlTransformName);
FormData fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.right = new FormAttachment(middle, -margin);
fd.top = new FormAttachment(0, margin);
wlTransformName.setLayoutData(fd);
wTransformName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wTransformName.setText(transformName);
props.setLook(wTransformName);
wTransformName.addModifyListener(lsMod);
// format the text field
fd = new FormData();
fd.left = new FormAttachment(middle, 0);
fd.top = new FormAttachment(0, margin);
fd.right = new FormAttachment(100, 0);
wTransformName.setLayoutData(fd);
/**
* various UI bits and pieces for the dialog
*/
// The tabs of the dialog
CTabFolder wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
// --- start of the options tab
CTabItem wOutputOptionsTab = new CTabItem(wTabFolder, SWT.NONE);
wOutputOptionsTab.setText("Output options");
Composite wOutputComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wOutputComp);
FormLayout outputLayout = new FormLayout();
outputLayout.marginWidth = 3;
outputLayout.marginHeight = 3;
wOutputComp.setLayout(outputLayout);
// The connection to use...
//
wConnection = new MetaSelectionLine<>(variables, metadataProvider, MongoDbConnection.class, wOutputComp, SWT.NONE, BaseMessages.getString(PKG, "MongoDbOutputDialog.ConnectionName.Label"), BaseMessages.getString(PKG, "MongoDbOutputDialog.ConnectionName.Tooltip"));
FormData fdConnection = new FormData();
fdConnection.left = new FormAttachment(0, 0);
fdConnection.right = new FormAttachment(100, 0);
fdConnection.top = new FormAttachment(0, 0);
wConnection.setLayoutData(fdConnection);
Control lastControl = wConnection;
try {
wConnection.fillItems();
} catch (HopException e) {
new ErrorDialog(shell, "Error", "Error loading list of MongoDB connection names", e);
}
// collection line
Label collectionLab = new Label(wOutputComp, SWT.RIGHT);
collectionLab.setText(BaseMessages.getString(PKG, "MongoDbOutputDialog.Collection.Label"));
collectionLab.setToolTipText(BaseMessages.getString(PKG, "MongoDbOutputDialog.Collection.TipText"));
props.setLook(collectionLab);
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(lastControl, margin);
fd.right = new FormAttachment(middle, -margin);
collectionLab.setLayoutData(fd);
Button wbGetCollections = new Button(wOutputComp, SWT.PUSH | SWT.CENTER);
props.setLook(wbGetCollections);
wbGetCollections.setText(BaseMessages.getString(PKG, "MongoDbOutputDialog.GetCollections.Button"));
fd = new FormData();
fd.right = new FormAttachment(100, 0);
fd.top = new FormAttachment(collectionLab, 0, SWT.CENTER);
wbGetCollections.setLayoutData(fd);
wbGetCollections.addListener(SWT.Selection, e -> getCollectionNames(false));
wCollectionField = new CCombo(wOutputComp, SWT.BORDER);
props.setLook(wCollectionField);
wCollectionField.addModifyListener(e -> {
currentMeta.setChanged();
wCollectionField.setToolTipText(variables.resolve(wCollectionField.getText()));
});
fd = new FormData();
fd.left = new FormAttachment(middle, 0);
fd.top = new FormAttachment(collectionLab, 0, SWT.CENTER);
fd.right = new FormAttachment(wbGetCollections, -margin);
wCollectionField.setLayoutData(fd);
lastControl = wbGetCollections;
// batch insert line
Label batchLab = new Label(wOutputComp, SWT.RIGHT);
batchLab.setText(BaseMessages.getString(PKG, "MongoDbOutputDialog.BatchInsertSize.Label"));
props.setLook(batchLab);
batchLab.setToolTipText(BaseMessages.getString(PKG, "MongoDbOutputDialog.BatchInsertSize.TipText"));
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(lastControl, margin);
fd.right = new FormAttachment(middle, -margin);
batchLab.setLayoutData(fd);
wBatchInsertSizeField = new TextVar(variables, wOutputComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wBatchInsertSizeField);
wBatchInsertSizeField.addModifyListener(lsMod);
// set the tool tip to the contents with any env variables expanded
wBatchInsertSizeField.addModifyListener(e -> wBatchInsertSizeField.setToolTipText(variables.resolve(wBatchInsertSizeField.getText())));
fd = new FormData();
fd.right = new FormAttachment(100, 0);
fd.top = new FormAttachment(batchLab, 0, SWT.CENTER);
fd.left = new FormAttachment(middle, 0);
wBatchInsertSizeField.setLayoutData(fd);
lastControl = wBatchInsertSizeField;
// truncate line
Label truncateLab = new Label(wOutputComp, SWT.RIGHT);
truncateLab.setText(BaseMessages.getString(PKG, "MongoDbOutputDialog.Truncate.Label"));
props.setLook(truncateLab);
truncateLab.setToolTipText(BaseMessages.getString(PKG, "MongoDbOutputDialog.Truncate.TipText"));
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(lastControl, 2 * margin);
fd.right = new FormAttachment(middle, -margin);
truncateLab.setLayoutData(fd);
wbTruncate = new Button(wOutputComp, SWT.CHECK);
props.setLook(wbTruncate);
wbTruncate.setToolTipText(BaseMessages.getString(PKG, "MongoDbOutputDialog.Truncate.TipText"));
fd = new FormData();
fd.right = new FormAttachment(100, 0);
fd.top = new FormAttachment(truncateLab, 0, SWT.CENTER);
fd.left = new FormAttachment(middle, 0);
wbTruncate.setLayoutData(fd);
wbTruncate.addListener(SWT.Selection, e -> currentMeta.setChanged());
lastControl = truncateLab;
// update line
Label updateLab = new Label(wOutputComp, SWT.RIGHT);
updateLab.setText(BaseMessages.getString(PKG, "MongoDbOutputDialog.Update.Label"));
props.setLook(updateLab);
updateLab.setToolTipText(BaseMessages.getString(PKG, "MongoDbOutputDialog.Update.TipText"));
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(lastControl, 2 * margin);
fd.right = new FormAttachment(middle, -margin);
updateLab.setLayoutData(fd);
wbUpdate = new Button(wOutputComp, SWT.CHECK);
props.setLook(wbUpdate);
wbUpdate.setToolTipText(BaseMessages.getString(PKG, "MongoDbOutputDialog.Update.TipText"));
fd = new FormData();
fd.right = new FormAttachment(100, 0);
fd.top = new FormAttachment(updateLab, 0, SWT.CENTER);
fd.left = new FormAttachment(middle, 0);
wbUpdate.setLayoutData(fd);
lastControl = updateLab;
// multi update can only be used when the update document
// contains modifier operations:
// http://docs.mongodb.org/manual/reference/method/db.collection.update/#multi-parameter
wbUpdate.addListener(SWT.Selection, e -> {
currentMeta.setChanged();
wbUpsert.setEnabled(wbUpdate.getSelection());
wbModifierUpdate.setEnabled(wbUpdate.getSelection());
wbMulti.setEnabled(wbUpdate.getSelection());
if (!wbUpdate.getSelection()) {
wbModifierUpdate.setSelection(false);
wbMulti.setSelection(false);
wbUpsert.setSelection(false);
}
wbMulti.setEnabled(wbModifierUpdate.getSelection());
if (!wbMulti.getEnabled()) {
wbMulti.setSelection(false);
}
});
// upsert line
Label upsertLab = new Label(wOutputComp, SWT.RIGHT);
upsertLab.setText(BaseMessages.getString(PKG, "MongoDbOutputDialog.Upsert.Label"));
props.setLook(upsertLab);
upsertLab.setToolTipText(BaseMessages.getString(PKG, "MongoDbOutputDialog.Upsert.TipText"));
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(lastControl, 2 * margin);
fd.right = new FormAttachment(middle, -margin);
upsertLab.setLayoutData(fd);
wbUpsert = new Button(wOutputComp, SWT.CHECK);
props.setLook(wbUpsert);
wbUpsert.setToolTipText(BaseMessages.getString(PKG, "MongoDbOutputDialog.Upsert.TipText"));
fd = new FormData();
fd.right = new FormAttachment(100, 0);
fd.top = new FormAttachment(upsertLab, 0, SWT.CENTER);
fd.left = new FormAttachment(middle, 0);
wbUpsert.setLayoutData(fd);
lastControl = upsertLab;
// multi line
Label multiLab = new Label(wOutputComp, SWT.RIGHT);
multiLab.setText(BaseMessages.getString(PKG, "MongoDbOutputDialog.Multi.Label"));
props.setLook(multiLab);
multiLab.setToolTipText(BaseMessages.getString(PKG, "MongoDbOutputDialog.Multi.TipText"));
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(lastControl, 2 * margin);
fd.right = new FormAttachment(middle, -margin);
multiLab.setLayoutData(fd);
wbMulti = new Button(wOutputComp, SWT.CHECK);
props.setLook(wbMulti);
wbMulti.setToolTipText(BaseMessages.getString(PKG, "MongoDbOutputDialog.Multi.TipText"));
fd = new FormData();
fd.right = new FormAttachment(100, 0);
fd.top = new FormAttachment(multiLab, 0, SWT.CENTER);
fd.left = new FormAttachment(middle, 0);
wbMulti.setLayoutData(fd);
wbMulti.addListener(SWT.Selection, e -> currentMeta.setChanged());
lastControl = multiLab;
// modifier update
Label modifierLab = new Label(wOutputComp, SWT.RIGHT);
modifierLab.setText(BaseMessages.getString(PKG, "MongoDbOutputDialog.Modifier.Label"));
props.setLook(modifierLab);
modifierLab.setToolTipText(BaseMessages.getString(PKG, "MongoDbOutputDialog.Modifier.TipText"));
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(lastControl, 2 * margin);
fd.right = new FormAttachment(middle, -margin);
modifierLab.setLayoutData(fd);
wbModifierUpdate = new Button(wOutputComp, SWT.CHECK);
props.setLook(wbModifierUpdate);
wbModifierUpdate.setToolTipText(BaseMessages.getString(PKG, "MongoDbOutputDialog.Modifier.TipText"));
fd = new FormData();
fd.right = new FormAttachment(100, 0);
fd.top = new FormAttachment(modifierLab, 0, SWT.CENTER);
fd.left = new FormAttachment(middle, 0);
wbModifierUpdate.setLayoutData(fd);
wbModifierUpdate.addListener(SWT.Selection, e -> {
currentMeta.setChanged();
wbMulti.setEnabled(wbModifierUpdate.getSelection());
if (!wbModifierUpdate.getSelection()) {
wbMulti.setSelection(false);
}
});
lastControl = modifierLab;
// retries stuff
Label retriesLab = new Label(wOutputComp, SWT.RIGHT);
props.setLook(retriesLab);
retriesLab.setText(BaseMessages.getString(PKG, "MongoDbOutputDialog.WriteRetries.Label"));
retriesLab.setToolTipText(BaseMessages.getString(PKG, "MongoDbOutputDialog.WriteRetries.TipText"));
fd = new FormData();
fd.left = new FormAttachment(0, -margin);
fd.top = new FormAttachment(lastControl, margin);
fd.right = new FormAttachment(middle, -margin);
retriesLab.setLayoutData(fd);
wWriteRetries = new TextVar(variables, wOutputComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wWriteRetries);
fd = new FormData();
fd.left = new FormAttachment(middle, 0);
fd.top = new FormAttachment(retriesLab, 0, SWT.CENTER);
fd.right = new FormAttachment(100, 0);
wWriteRetries.setLayoutData(fd);
wWriteRetries.addModifyListener(e -> wWriteRetries.setToolTipText(variables.resolve(wWriteRetries.getText())));
Label retriesDelayLab = new Label(wOutputComp, SWT.RIGHT);
props.setLook(retriesDelayLab);
retriesDelayLab.setText(BaseMessages.getString(PKG, "MongoDbOutputDialog.WriteRetriesDelay.Label"));
fd = new FormData();
fd.left = new FormAttachment(0, -margin);
fd.top = new FormAttachment(wWriteRetries, margin);
fd.right = new FormAttachment(middle, -margin);
retriesDelayLab.setLayoutData(fd);
wWriteRetryDelay = new TextVar(variables, wOutputComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wWriteRetryDelay);
fd = new FormData();
fd.left = new FormAttachment(middle, 0);
fd.top = new FormAttachment(wWriteRetries, margin);
fd.right = new FormAttachment(100, 0);
wWriteRetryDelay.setLayoutData(fd);
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(100, 0);
wOutputComp.setLayoutData(fd);
wOutputComp.layout();
wOutputOptionsTab.setControl(wOutputComp);
// --- start of the fields tab
CTabItem wMongoFieldsTab = new CTabItem(wTabFolder, SWT.NONE);
wMongoFieldsTab.setText(BaseMessages.getString(PKG, "MongoDbOutputDialog.FieldsTab.TabTitle"));
Composite wFieldsComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wFieldsComp);
FormLayout filterLayout = new FormLayout();
filterLayout.marginWidth = 3;
filterLayout.marginHeight = 3;
wFieldsComp.setLayout(filterLayout);
final ColumnInfo[] colInf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "MongoDbOutputDialog.Fields.Incoming"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "MongoDbOutputDialog.Fields.Path"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "MongoDbOutputDialog.Fields.UseIncomingName"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "Y", "N" }), new ColumnInfo(BaseMessages.getString(PKG, "MongoDbOutputDialog.Fields.NullValues"), ColumnInfo.COLUMN_TYPE_CCOMBO, BaseMessages.getString(PKG, "MongoDbOutputDialog.Fields.NullValues.Insert"), BaseMessages.getString(PKG, "MongoDbOutputDialog.Fields.NullValues.Ignore")), new ColumnInfo(BaseMessages.getString(PKG, "MongoDbOutputDialog.Fields.JSON"), ColumnInfo.COLUMN_TYPE_CCOMBO, "Y", "N"), new ColumnInfo(BaseMessages.getString(PKG, "MongoDbOutputDialog.Fields.UpdateMatchField"), ColumnInfo.COLUMN_TYPE_CCOMBO, "Y", "N"), new ColumnInfo(BaseMessages.getString(PKG, "MongoDbOutputDialog.Fields.ModifierUpdateOperation"), ColumnInfo.COLUMN_TYPE_CCOMBO, "N/A", "$set", "$inc", "$push"), new ColumnInfo(BaseMessages.getString(PKG, "MongoDbOutputDialog.Fields.ModifierApplyPolicy"), ColumnInfo.COLUMN_TYPE_CCOMBO, "Insert&Update", "Insert", "Update") };
// get fields but
Button wbGetFields = new Button(wFieldsComp, SWT.PUSH | SWT.CENTER);
props.setLook(wbGetFields);
wbGetFields.setText(BaseMessages.getString(PKG, "MongoDbOutputDialog.GetFieldsBut"));
fd = new FormData();
fd.bottom = new FormAttachment(100, -margin * 2);
fd.left = new FormAttachment(0, margin);
wbGetFields.setLayoutData(fd);
wbGetFields.addListener(SWT.Selection, e -> getFields());
Button wbPreviewDocStruct = new Button(wFieldsComp, SWT.PUSH | SWT.CENTER);
props.setLook(wbPreviewDocStruct);
wbPreviewDocStruct.setText(BaseMessages.getString(PKG, "MongoDbOutputDialog.PreviewDocStructBut"));
fd = new FormData();
fd.bottom = new FormAttachment(100, -margin * 2);
fd.left = new FormAttachment(wbGetFields, margin);
wbPreviewDocStruct.setLayoutData(fd);
wbPreviewDocStruct.addListener(SWT.Selection, e -> previewDocStruct());
wMongoFields = new TableView(variables, wFieldsComp, SWT.FULL_SELECTION | SWT.MULTI, colInf, 1, lsMod, props);
fd = new FormData();
fd.top = new FormAttachment(0, margin * 2);
fd.bottom = new FormAttachment(wbGetFields, -margin * 2);
fd.left = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
wMongoFields.setLayoutData(fd);
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(100, 0);
wFieldsComp.setLayoutData(fd);
wFieldsComp.layout();
wMongoFieldsTab.setControl(wFieldsComp);
// indexes tab ------------------
CTabItem wMongoIndexesTab = new CTabItem(wTabFolder, SWT.NONE);
wMongoIndexesTab.setText(BaseMessages.getString(PKG, "MongoDbOutputDialog.IndexesTab.TabTitle"));
Composite wIndexesComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wIndexesComp);
FormLayout indexesLayout = new FormLayout();
indexesLayout.marginWidth = 3;
indexesLayout.marginHeight = 3;
wIndexesComp.setLayout(indexesLayout);
final ColumnInfo[] colInf2 = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "MongoDbOutputDialog.Indexes.IndexFields"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "MongoDbOutputDialog.Indexes.IndexOpp"), ColumnInfo.COLUMN_TYPE_CCOMBO, false), new ColumnInfo(BaseMessages.getString(PKG, "MongoDbOutputDialog.Indexes.Unique"), ColumnInfo.COLUMN_TYPE_CCOMBO, false), new ColumnInfo(BaseMessages.getString(PKG, "MongoDbOutputDialog.Indexes.Sparse"), ColumnInfo.COLUMN_TYPE_CCOMBO, false) };
colInf2[1].setComboValues(new String[] { "Create", "Drop" });
colInf2[1].setReadOnly(true);
//
colInf2[2].setComboValues(new String[] { "Y", "N" });
colInf2[2].setReadOnly(true);
//
colInf2[3].setComboValues(new String[] { "Y", "N" });
colInf2[3].setReadOnly(true);
// get indexes but
Button wbShowIndexes = new Button(wIndexesComp, SWT.PUSH | SWT.CENTER);
props.setLook(wbShowIndexes);
//
wbShowIndexes.setText(BaseMessages.getString(PKG, "MongoDbOutputDialog.ShowIndexesBut"));
fd = new FormData();
fd.bottom = new FormAttachment(100, -margin * 2);
fd.left = new FormAttachment(0, margin);
wbShowIndexes.setLayoutData(fd);
wbShowIndexes.addListener(SWT.Selection, e -> showIndexInfo());
wMongoIndexes = new TableView(variables, wIndexesComp, SWT.FULL_SELECTION | SWT.MULTI, colInf2, 1, lsMod, props);
fd = new FormData();
fd.top = new FormAttachment(0, margin * 2);
fd.bottom = new FormAttachment(wbShowIndexes, -margin * 2);
fd.left = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
wMongoIndexes.setLayoutData(fd);
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(100, 0);
wIndexesComp.setLayoutData(fd);
wIndexesComp.layout();
wMongoIndexesTab.setControl(wIndexesComp);
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(wTransformName, margin);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(wOk, -2 * margin);
wTabFolder.setLayoutData(fd);
wTabFolder.setSelection(0);
getData();
BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
return transformName;
}
use of org.apache.hop.ui.pipeline.transform.BaseTransformDialog in project hop by apache.
the class StreamSchemaDialog method open.
/**
* The constructor should simply invoke super() and save the incoming meta object to a local
* variable, so it can conveniently read and write settings from/to it.
*
* <p>or null if the user cancelled the dialog.
*/
@Override
public String open() {
// store some convenient SWT variables
Shell parent = getParent();
// SWT code for preparing the dialog
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
props.setLook(shell);
setShellImage(shell, meta);
// Save the value of the changed flag on the meta object. If the user cancels
// the dialog, it will be restored to this saved value.
// The "changed" variable is inherited from BaseTransformDialog
changed = meta.hasChanged();
// The ModifyListener used on all controls. It will update the meta object to
// indicate that changes are being made.
ModifyListener lsMod = e -> meta.setChanged();
// ------------------------------------------------------- //
// SWT code for building the actual settings dialog //
// ------------------------------------------------------- //
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "StreamSchemaTransform.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// TransformName line
Label wlTransformName = new Label(shell, SWT.RIGHT);
wlTransformName.setText(BaseMessages.getString(PKG, "System.Label.TransformName"));
props.setLook(wlTransformName);
fdlTransformName = new FormData();
fdlTransformName.left = new FormAttachment(0, 0);
fdlTransformName.right = new FormAttachment(middle, -margin);
fdlTransformName.top = new FormAttachment(0, margin);
wlTransformName.setLayoutData(fdlTransformName);
wTransformName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wTransformName.setText(transformName);
props.setLook(wTransformName);
wTransformName.addModifyListener(lsMod);
fdTransformName = new FormData();
fdTransformName.left = new FormAttachment(middle, 0);
fdTransformName.top = new FormAttachment(0, margin);
fdTransformName.right = new FormAttachment(100, 0);
wTransformName.setLayoutData(fdTransformName);
// OK, get and cancel 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, "StreamSchema.getPreviousTransforms.Label"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOk, wGet, wCancel }, margin, null);
// Table with fields for inputting transform names
Label wlTransforms = new Label(shell, SWT.NONE);
wlTransforms.setText(BaseMessages.getString(PKG, "StreamSchemaTransformDialog.Transforms.Label"));
props.setLook(wlTransforms);
FormData fdlTransforms = new FormData();
fdlTransforms.left = new FormAttachment(0, 0);
fdlTransforms.top = new FormAttachment(wTransformName, margin);
wlTransforms.setLayoutData(fdlTransforms);
final int FieldsCols = 1;
final int FieldsRows = meta.getNumberOfTransforms();
previousTransforms = pipelineMeta.getPrevTransformNames(transformName);
ColumnInfo[] colinf = new ColumnInfo[FieldsCols];
colinf[0] = new ColumnInfo(BaseMessages.getString(PKG, "StreamSchemaTransformDialog.TransformName.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, previousTransforms, false);
wTransforms = new TableView(variables, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod, props);
FormData fdTransforms = new FormData();
fdTransforms.left = new FormAttachment(0, 0);
fdTransforms.top = new FormAttachment(wlTransforms, margin);
fdTransforms.right = new FormAttachment(100, 0);
fdTransforms.bottom = new FormAttachment(wOk, -2 * margin);
wTransforms.setLayoutData(fdTransforms);
// Add listeners for cancel and OK
wCancel.addListener(SWT.Selection, e -> cancel());
wOk.addListener(SWT.Selection, e -> ok());
wGet.addListener(SWT.Selection, e -> get());
// populate the dialog with the values from the meta object
populateDialog();
// restore the changed flag to original value, as the modify listeners fire during dialog
// population
meta.setChanged(changed);
// open dialog and enter event loop
BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
// The "TransformName" variable is inherited from BaseTransformDialog
return transformName;
}
Aggregations