use of org.apache.hop.ui.core.widget.MetaSelectionLine in project hop by apache.
the class SplunkInputDialog method open.
@Override
public String open() {
Shell parent = getParent();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
setShellImage(shell, input);
FormLayout shellLayout = new FormLayout();
shell.setLayout(shellLayout);
shell.setText("Splunk Input");
ModifyListener lsMod = e -> input.setChanged();
changed = input.hasChanged();
ScrolledComposite wScrolledComposite = new ScrolledComposite(shell, SWT.V_SCROLL | SWT.H_SCROLL);
FormLayout scFormLayout = new FormLayout();
wScrolledComposite.setLayout(scFormLayout);
FormData fdSComposite = new FormData();
fdSComposite.left = new FormAttachment(0, 0);
fdSComposite.right = new FormAttachment(100, 0);
fdSComposite.top = new FormAttachment(0, 0);
fdSComposite.bottom = new FormAttachment(100, 0);
wScrolledComposite.setLayoutData(fdSComposite);
Composite wComposite = new Composite(wScrolledComposite, SWT.NONE);
props.setLook(wComposite);
FormData fdComposite = new FormData();
fdComposite.left = new FormAttachment(0, 0);
fdComposite.right = new FormAttachment(100, 0);
fdComposite.top = new FormAttachment(0, 0);
fdComposite.bottom = new FormAttachment(100, 0);
wComposite.setLayoutData(fdComposite);
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
wComposite.setLayout(formLayout);
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Some buttons at the bottom
wOk = new Button(wComposite, SWT.PUSH);
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOk.addListener(SWT.Selection, e -> ok());
wPreview = new Button(wComposite, SWT.PUSH);
wPreview.setText(BaseMessages.getString(PKG, "System.Button.Preview"));
wPreview.addListener(SWT.Selection, e -> preview());
wCancel = new Button(wComposite, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wCancel.addListener(SWT.Selection, e -> cancel());
setButtonPositions(new Button[] { wOk, wPreview, wCancel }, margin, null);
// Transform name line
//
Label wlTransformName = new Label(wComposite, SWT.RIGHT);
wlTransformName.setText("Transform name");
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(wComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wTransformName);
wTransformName.addModifyListener(lsMod);
fdTransformName = new FormData();
fdTransformName.left = new FormAttachment(middle, 0);
fdTransformName.top = new FormAttachment(wlTransformName, 0, SWT.CENTER);
fdTransformName.right = new FormAttachment(100, 0);
wTransformName.setLayoutData(fdTransformName);
Control lastControl = wTransformName;
wConnection = new MetaSelectionLine<>(variables, metadataProvider, SplunkConnection.class, wComposite, SWT.SINGLE | SWT.LEFT, "Splunk Connection", "Select, create or edit a Splunk Connection");
props.setLook(wConnection);
wConnection.addModifyListener(lsMod);
FormData fdConnection = new FormData();
fdConnection.left = new FormAttachment(0, 0);
fdConnection.right = new FormAttachment(100, 0);
fdConnection.top = new FormAttachment(lastControl, margin);
wConnection.setLayoutData(fdConnection);
lastControl = wConnection;
Label wlQuery = new Label(wComposite, SWT.LEFT);
wlQuery.setText("Query:");
props.setLook(wlQuery);
FormData fdlQuery = new FormData();
fdlQuery.left = new FormAttachment(0, 0);
fdlQuery.right = new FormAttachment(middle, -margin);
fdlQuery.top = new FormAttachment(lastControl, margin);
wlQuery.setLayoutData(fdlQuery);
wQuery = new Text(wComposite, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
wQuery.setFont(GuiResource.getInstance().getFontFixed());
props.setLook(wQuery);
wQuery.addModifyListener(lsMod);
FormData fdQuery = new FormData();
fdQuery.left = new FormAttachment(0, 0);
fdQuery.right = new FormAttachment(100, 0);
fdQuery.top = new FormAttachment(wlQuery, margin);
fdQuery.bottom = new FormAttachment(60, 0);
wQuery.setLayoutData(fdQuery);
lastControl = wQuery;
// Table: return field name and type
//
ColumnInfo[] returnColumns = new ColumnInfo[] { new ColumnInfo("Field name", ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo("Splunk name", ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo("Return type", ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getAllValueMetaNames(), false), new ColumnInfo("Length", ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo("Format", ColumnInfo.COLUMN_TYPE_TEXT, false) };
Label wlReturns = new Label(wComposite, SWT.LEFT);
wlReturns.setText("Returns");
props.setLook(wlReturns);
FormData fdlReturns = new FormData();
fdlReturns.left = new FormAttachment(0, 0);
fdlReturns.right = new FormAttachment(middle, -margin);
fdlReturns.top = new FormAttachment(lastControl, margin);
wlReturns.setLayoutData(fdlReturns);
Button wbGetReturnFields = new Button(wComposite, SWT.PUSH);
wbGetReturnFields.setText("Get Output Fields");
FormData fdbGetReturnFields = new FormData();
fdbGetReturnFields.right = new FormAttachment(100, 0);
fdbGetReturnFields.top = new FormAttachment(lastControl, margin);
wbGetReturnFields.setLayoutData(fdbGetReturnFields);
wbGetReturnFields.addListener(SWT.Selection, e -> getReturnValues());
lastControl = wbGetReturnFields;
wReturns = new TableView(variables, wComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, returnColumns, input.getReturnValues().size(), lsMod, props);
props.setLook(wReturns);
wReturns.addModifyListener(lsMod);
FormData fdReturns = new FormData();
fdReturns.left = new FormAttachment(0, 0);
fdReturns.right = new FormAttachment(100, 0);
fdReturns.top = new FormAttachment(lastControl, margin);
fdReturns.bottom = new FormAttachment(wOk, -2 * margin);
wReturns.setLayoutData(fdReturns);
wComposite.pack();
Rectangle bounds = wComposite.getBounds();
wScrolledComposite.setContent(wComposite);
wScrolledComposite.setExpandHorizontal(true);
wScrolledComposite.setExpandVertical(true);
wScrolledComposite.setMinWidth(bounds.width);
wScrolledComposite.setMinHeight(bounds.height);
getData();
input.setChanged(changed);
BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
return transformName;
}
use of org.apache.hop.ui.core.widget.MetaSelectionLine in project hop by apache.
the class Neo4jConstraintDialog method open.
@Override
public IAction open() {
Shell parent = getParent();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
props.setLook(shell);
WorkflowDialog.setShellImage(shell, meta);
ModifyListener lsMod = e -> meta.setChanged();
changed = meta.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "Neo4jConstraintDialog.Dialog.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
Label wlName = new Label(shell, SWT.RIGHT);
wlName.setText(BaseMessages.getString(PKG, "Neo4jConstraintDialog.ActionName.Label"));
props.setLook(wlName);
FormData fdlName = new FormData();
fdlName.left = new FormAttachment(0, 0);
fdlName.right = new FormAttachment(middle, -margin);
fdlName.top = new FormAttachment(0, margin);
wlName.setLayoutData(fdlName);
wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wName);
wName.addModifyListener(lsMod);
FormData fdName = new FormData();
fdName.left = new FormAttachment(middle, 0);
fdName.top = new FormAttachment(0, margin);
fdName.right = new FormAttachment(100, 0);
wName.setLayoutData(fdName);
Control lastControl = wName;
wConnection = new MetaSelectionLine<>(variables, getMetadataProvider(), NeoConnection.class, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER, BaseMessages.getString(PKG, "Neo4jConstraintDialog.NeoConnection.Label"), BaseMessages.getString(PKG, "Neo4jConstraintDialog.NeoConnection.Tooltip"));
props.setLook(wConnection);
wConnection.addModifyListener(lsMod);
FormData fdConnection = new FormData();
fdConnection.left = new FormAttachment(0, 0);
fdConnection.right = new FormAttachment(100, 0);
fdConnection.top = new FormAttachment(lastControl, margin);
wConnection.setLayoutData(fdConnection);
try {
wConnection.fillItems();
} catch (Exception e) {
new ErrorDialog(shell, "Error", "Error getting list of connections", e);
}
// Add buttons first, then the script field can use dynamic sizing
//
Button wOk = new Button(shell, SWT.PUSH);
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOk.addListener(SWT.Selection, e -> ok());
Button wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wCancel.addListener(SWT.Selection, e -> cancel());
Label wlUpdates = new Label(shell, SWT.LEFT);
wlUpdates.setText(BaseMessages.getString(PKG, "Neo4jConstraintDialog.ConstraintUpdates.Label"));
props.setLook(wlUpdates);
FormData fdlCypher = new FormData();
fdlCypher.left = new FormAttachment(0, 0);
fdlCypher.right = new FormAttachment(100, 0);
fdlCypher.top = new FormAttachment(wConnection, margin);
wlUpdates.setLayoutData(fdlCypher);
// The columns
//
ColumnInfo[] columns = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "Neo4jConstraintDialog.ConstraintUpdates.Column.UpdateType"), ColumnInfo.COLUMN_TYPE_CCOMBO, UpdateType.getNames()), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jConstraintDialog.ConstraintUpdates.Column.ObjectType"), ColumnInfo.COLUMN_TYPE_CCOMBO, ObjectType.getNames()), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jConstraintDialog.ConstraintUpdates.Column.ConstraintType"), ColumnInfo.COLUMN_TYPE_CCOMBO, ConstraintType.getNames()), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jConstraintDialog.ConstraintUpdates.Column.ConstraintName"), ColumnInfo.COLUMN_TYPE_TEXT), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jConstraintDialog.ConstraintUpdates.Column.ObjectName"), ColumnInfo.COLUMN_TYPE_TEXT), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jConstraintDialog.ConstraintUpdates.Column.ObjectProperties"), ColumnInfo.COLUMN_TYPE_TEXT) };
wUpdates = new TableView(variables, shell, SWT.NONE, columns, meta.getConstraintUpdates().size(), false, null, props);
props.setLook(wUpdates);
wUpdates.addModifyListener(lsMod);
FormData fdCypher = new FormData();
fdCypher.left = new FormAttachment(0, 0);
fdCypher.right = new FormAttachment(100, 0);
fdCypher.top = new FormAttachment(wlUpdates, margin);
fdCypher.bottom = new FormAttachment(wOk, -margin * 2);
wUpdates.setLayoutData(fdCypher);
// Put these buttons at the bottom
//
BaseTransformDialog.positionBottomButtons(shell, new Button[] { wOk, wCancel }, margin, null);
getData();
BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
return meta;
}
use of org.apache.hop.ui.core.widget.MetaSelectionLine in project hop by apache.
the class CypherScriptDialog method open.
@Override
public IAction open() {
Shell parent = getParent();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
props.setLook(shell);
WorkflowDialog.setShellImage(shell, cypherScript);
ModifyListener lsMod = e -> cypherScript.setChanged();
changed = cypherScript.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "CypherScriptDialog.Dialog.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
Label wlName = new Label(shell, SWT.RIGHT);
wlName.setText(BaseMessages.getString(PKG, "CypherScriptDialog.ActionName.Label"));
props.setLook(wlName);
FormData fdlName = new FormData();
fdlName.left = new FormAttachment(0, 0);
fdlName.right = new FormAttachment(middle, -margin);
fdlName.top = new FormAttachment(0, margin);
wlName.setLayoutData(fdlName);
wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wName);
wName.addModifyListener(lsMod);
FormData fdName = new FormData();
fdName.left = new FormAttachment(middle, 0);
fdName.top = new FormAttachment(0, margin);
fdName.right = new FormAttachment(100, 0);
wName.setLayoutData(fdName);
Control lastControl = wName;
wConnection = new MetaSelectionLine<>(variables, getMetadataProvider(), NeoConnection.class, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER, BaseMessages.getString(PKG, "CypherScriptDialog.NeoConnection.Label"), BaseMessages.getString(PKG, "CypherScriptDialog.NeoConnection.Tooltip"));
props.setLook(wConnection);
wConnection.addModifyListener(lsMod);
FormData fdConnection = new FormData();
fdConnection.left = new FormAttachment(0, 0);
fdConnection.right = new FormAttachment(100, 0);
fdConnection.top = new FormAttachment(lastControl, margin);
wConnection.setLayoutData(fdConnection);
try {
wConnection.fillItems();
} catch (Exception e) {
new ErrorDialog(shell, "Error", "Error getting list of connections", e);
}
// Add buttons first, then the script field can use dynamic sizing
//
Button wOk = new Button(shell, SWT.PUSH);
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOk.addListener(SWT.Selection, e -> ok());
Button wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wCancel.addListener(SWT.Selection, e -> cancel());
Label wlReplaceVariables = new Label(shell, SWT.LEFT);
wlReplaceVariables.setText(BaseMessages.getString(PKG, "CypherScriptDialog.ReplaceVariables.Label"));
props.setLook(wlReplaceVariables);
FormData fdlReplaceVariables = new FormData();
fdlReplaceVariables.left = new FormAttachment(0, 0);
fdlReplaceVariables.right = new FormAttachment(middle, -margin);
fdlReplaceVariables.bottom = new FormAttachment(wOk, -margin * 2);
wlReplaceVariables.setLayoutData(fdlReplaceVariables);
wReplaceVariables = new Button(shell, SWT.CHECK | SWT.BORDER);
props.setLook(wReplaceVariables);
FormData fdReplaceVariables = new FormData();
fdReplaceVariables.left = new FormAttachment(middle, 0);
fdReplaceVariables.right = new FormAttachment(100, 0);
fdReplaceVariables.top = new FormAttachment(wlReplaceVariables, 0, SWT.CENTER);
wReplaceVariables.setLayoutData(fdReplaceVariables);
Label wlScript = new Label(shell, SWT.LEFT);
wlScript.setText(BaseMessages.getString(PKG, "CypherScriptDialog.CypherScript.Label"));
props.setLook(wlScript);
FormData fdlCypher = new FormData();
fdlCypher.left = new FormAttachment(0, 0);
fdlCypher.right = new FormAttachment(100, 0);
fdlCypher.top = new FormAttachment(wConnection, margin);
wlScript.setLayoutData(fdlCypher);
wScript = new TextVar(variables, shell, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
wScript.getTextWidget().setFont(GuiResource.getInstance().getFontFixed());
props.setLook(wScript);
wScript.addModifyListener(lsMod);
FormData fdCypher = new FormData();
fdCypher.left = new FormAttachment(0, 0);
fdCypher.right = new FormAttachment(100, 0);
fdCypher.top = new FormAttachment(wlScript, margin);
fdCypher.bottom = new FormAttachment(wReplaceVariables, -margin * 2);
wScript.setLayoutData(fdCypher);
// Put these buttons at the bottom
//
BaseTransformDialog.positionBottomButtons(shell, new Button[] { wOk, wCancel }, margin, null);
getData();
BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
return cypherScript;
}
use of org.apache.hop.ui.core.widget.MetaSelectionLine in project hop by apache.
the class Neo4jIndexDialog method open.
@Override
public IAction open() {
Shell parent = getParent();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
props.setLook(shell);
WorkflowDialog.setShellImage(shell, meta);
ModifyListener lsMod = e -> meta.setChanged();
changed = meta.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "Neo4jIndexDialog.Dialog.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
Label wlName = new Label(shell, SWT.RIGHT);
wlName.setText(BaseMessages.getString(PKG, "Neo4jIndexDialog.ActionName.Label"));
props.setLook(wlName);
FormData fdlName = new FormData();
fdlName.left = new FormAttachment(0, 0);
fdlName.right = new FormAttachment(middle, -margin);
fdlName.top = new FormAttachment(0, margin);
wlName.setLayoutData(fdlName);
wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wName);
wName.addModifyListener(lsMod);
FormData fdName = new FormData();
fdName.left = new FormAttachment(middle, 0);
fdName.top = new FormAttachment(0, margin);
fdName.right = new FormAttachment(100, 0);
wName.setLayoutData(fdName);
Control lastControl = wName;
wConnection = new MetaSelectionLine<>(variables, getMetadataProvider(), NeoConnection.class, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER, BaseMessages.getString(PKG, "Neo4jIndexDialog.NeoConnection.Label"), BaseMessages.getString(PKG, "Neo4jIndexDialog.NeoConnection.Tooltip"));
props.setLook(wConnection);
wConnection.addModifyListener(lsMod);
FormData fdConnection = new FormData();
fdConnection.left = new FormAttachment(0, 0);
fdConnection.right = new FormAttachment(100, 0);
fdConnection.top = new FormAttachment(lastControl, margin);
wConnection.setLayoutData(fdConnection);
try {
wConnection.fillItems();
} catch (Exception e) {
new ErrorDialog(shell, "Error", "Error getting list of connections", e);
}
// Add buttons first, then the script field can use dynamic sizing
//
Button wOk = new Button(shell, SWT.PUSH);
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOk.addListener(SWT.Selection, e -> ok());
Button wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wCancel.addListener(SWT.Selection, e -> cancel());
Label wlUpdates = new Label(shell, SWT.LEFT);
wlUpdates.setText(BaseMessages.getString(PKG, "Neo4jIndexDialog.IndexUpdates.Label"));
props.setLook(wlUpdates);
FormData fdlCypher = new FormData();
fdlCypher.left = new FormAttachment(0, 0);
fdlCypher.right = new FormAttachment(100, 0);
fdlCypher.top = new FormAttachment(wConnection, margin);
wlUpdates.setLayoutData(fdlCypher);
// The columns
//
ColumnInfo[] columns = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "Neo4jIndexDialog.IndexUpdates.Column.UpdateType"), ColumnInfo.COLUMN_TYPE_CCOMBO, UpdateType.getNames()), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jIndexDialog.IndexUpdates.Column.ObjectType"), ColumnInfo.COLUMN_TYPE_CCOMBO, ObjectType.getNames()), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jIndexDialog.IndexUpdates.Column.IndexName"), ColumnInfo.COLUMN_TYPE_TEXT), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jIndexDialog.IndexUpdates.Column.ObjectName"), ColumnInfo.COLUMN_TYPE_TEXT), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jIndexDialog.IndexUpdates.Column.ObjectProperties"), ColumnInfo.COLUMN_TYPE_TEXT) };
wUpdates = new TableView(variables, shell, SWT.NONE, columns, meta.getIndexUpdates().size(), false, null, props);
props.setLook(wUpdates);
wUpdates.addModifyListener(lsMod);
FormData fdCypher = new FormData();
fdCypher.left = new FormAttachment(0, 0);
fdCypher.right = new FormAttachment(100, 0);
fdCypher.top = new FormAttachment(wlUpdates, margin);
fdCypher.bottom = new FormAttachment(wOk, -margin * 2);
wUpdates.setLayoutData(fdCypher);
// Put these buttons at the bottom
//
BaseTransformDialog.positionBottomButtons(shell, new Button[] { wOk, wCancel }, margin, null);
getData();
BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
return meta;
}
use of org.apache.hop.ui.core.widget.MetaSelectionLine 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;
}
Aggregations