Search in sources :

Example 1 with MetaSelectionLine

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;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) SplunkConnection(org.apache.hop.splunk.SplunkConnection) TableView(org.apache.hop.ui.core.widget.TableView) IVariables(org.apache.hop.core.variables.IVariables) org.apache.hop.ui.core.dialog(org.apache.hop.ui.core.dialog) Rectangle(org.eclipse.swt.graphics.Rectangle) MetaSelectionLine(org.apache.hop.ui.core.widget.MetaSelectionLine) ITransformDialog(org.apache.hop.pipeline.transform.ITransformDialog) ValueMetaFactory(org.apache.hop.core.row.value.ValueMetaFactory) PipelinePreviewFactory(org.apache.hop.pipeline.PipelinePreviewFactory) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) ColumnInfo(org.apache.hop.ui.core.widget.ColumnInfo) BaseMessages(org.apache.hop.i18n.BaseMessages) GuiResource(org.apache.hop.ui.core.gui.GuiResource) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) org.eclipse.swt.widgets(org.eclipse.swt.widgets) BaseTransformMeta(org.apache.hop.pipeline.transform.BaseTransformMeta) IHopMetadataSerializer(org.apache.hop.metadata.api.IHopMetadataSerializer) FormAttachment(org.eclipse.swt.layout.FormAttachment) ResultsReaderXml(com.splunk.ResultsReaderXml) Const(org.apache.hop.core.Const) Args(com.splunk.Args) List(java.util.List) Service(com.splunk.Service) Pipeline(org.apache.hop.pipeline.Pipeline) ModifyListener(org.eclipse.swt.events.ModifyListener) SWT(org.eclipse.swt.SWT) JobArgs(com.splunk.JobArgs) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) PipelinePreviewProgressDialog(org.apache.hop.ui.pipeline.dialog.PipelinePreviewProgressDialog) BaseTransformDialog(org.apache.hop.ui.pipeline.transform.BaseTransformDialog) InputStream(java.io.InputStream) FormData(org.eclipse.swt.layout.FormData) ModifyListener(org.eclipse.swt.events.ModifyListener) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Rectangle(org.eclipse.swt.graphics.Rectangle) ColumnInfo(org.apache.hop.ui.core.widget.ColumnInfo) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) FormAttachment(org.eclipse.swt.layout.FormAttachment) SplunkConnection(org.apache.hop.splunk.SplunkConnection) TableView(org.apache.hop.ui.core.widget.TableView)

Example 2 with MetaSelectionLine

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;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) Utils(org.apache.hop.core.util.Utils) TableView(org.apache.hop.ui.core.widget.TableView) IVariables(org.apache.hop.core.variables.IVariables) IActionDialog(org.apache.hop.workflow.action.IActionDialog) WorkflowMeta(org.apache.hop.workflow.WorkflowMeta) MetaSelectionLine(org.apache.hop.ui.core.widget.MetaSelectionLine) NeoConnection(org.apache.hop.neo4j.shared.NeoConnection) WindowProperty(org.apache.hop.ui.core.gui.WindowProperty) ActionDialog(org.apache.hop.ui.workflow.action.ActionDialog) ColumnInfo(org.apache.hop.ui.core.widget.ColumnInfo) BaseMessages(org.apache.hop.i18n.BaseMessages) FormLayout(org.eclipse.swt.layout.FormLayout) WorkflowDialog(org.apache.hop.ui.workflow.dialog.WorkflowDialog) BaseDialog(org.apache.hop.ui.core.dialog.BaseDialog) FormData(org.eclipse.swt.layout.FormData) org.eclipse.swt.widgets(org.eclipse.swt.widgets) FormAttachment(org.eclipse.swt.layout.FormAttachment) Const(org.apache.hop.core.Const) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) List(java.util.List) ModifyListener(org.eclipse.swt.events.ModifyListener) SWT(org.eclipse.swt.SWT) IAction(org.apache.hop.workflow.action.IAction) BaseTransformDialog(org.apache.hop.ui.pipeline.transform.BaseTransformDialog) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ModifyListener(org.eclipse.swt.events.ModifyListener) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) ColumnInfo(org.apache.hop.ui.core.widget.ColumnInfo) NeoConnection(org.apache.hop.neo4j.shared.NeoConnection) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.apache.hop.ui.core.widget.TableView)

Example 3 with MetaSelectionLine

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;
}
Also used : Utils(org.apache.hop.core.util.Utils) BaseMessages(org.apache.hop.i18n.BaseMessages) GuiResource(org.apache.hop.ui.core.gui.GuiResource) FormLayout(org.eclipse.swt.layout.FormLayout) IVariables(org.apache.hop.core.variables.IVariables) WorkflowDialog(org.apache.hop.ui.workflow.dialog.WorkflowDialog) IActionDialog(org.apache.hop.workflow.action.IActionDialog) BaseDialog(org.apache.hop.ui.core.dialog.BaseDialog) FormData(org.eclipse.swt.layout.FormData) WorkflowMeta(org.apache.hop.workflow.WorkflowMeta) org.eclipse.swt.widgets(org.eclipse.swt.widgets) FormAttachment(org.eclipse.swt.layout.FormAttachment) MetaSelectionLine(org.apache.hop.ui.core.widget.MetaSelectionLine) Const(org.apache.hop.core.Const) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) NeoConnection(org.apache.hop.neo4j.shared.NeoConnection) TextVar(org.apache.hop.ui.core.widget.TextVar) ModifyListener(org.eclipse.swt.events.ModifyListener) SWT(org.eclipse.swt.SWT) WindowProperty(org.apache.hop.ui.core.gui.WindowProperty) IAction(org.apache.hop.workflow.action.IAction) BaseTransformDialog(org.apache.hop.ui.pipeline.transform.BaseTransformDialog) ActionDialog(org.apache.hop.ui.workflow.action.ActionDialog) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ModifyListener(org.eclipse.swt.events.ModifyListener) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) TextVar(org.apache.hop.ui.core.widget.TextVar) NeoConnection(org.apache.hop.neo4j.shared.NeoConnection) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 4 with MetaSelectionLine

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;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) Utils(org.apache.hop.core.util.Utils) TableView(org.apache.hop.ui.core.widget.TableView) IVariables(org.apache.hop.core.variables.IVariables) IActionDialog(org.apache.hop.workflow.action.IActionDialog) WorkflowMeta(org.apache.hop.workflow.WorkflowMeta) MetaSelectionLine(org.apache.hop.ui.core.widget.MetaSelectionLine) NeoConnection(org.apache.hop.neo4j.shared.NeoConnection) WindowProperty(org.apache.hop.ui.core.gui.WindowProperty) ActionDialog(org.apache.hop.ui.workflow.action.ActionDialog) ColumnInfo(org.apache.hop.ui.core.widget.ColumnInfo) BaseMessages(org.apache.hop.i18n.BaseMessages) FormLayout(org.eclipse.swt.layout.FormLayout) WorkflowDialog(org.apache.hop.ui.workflow.dialog.WorkflowDialog) BaseDialog(org.apache.hop.ui.core.dialog.BaseDialog) FormData(org.eclipse.swt.layout.FormData) org.eclipse.swt.widgets(org.eclipse.swt.widgets) FormAttachment(org.eclipse.swt.layout.FormAttachment) Const(org.apache.hop.core.Const) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) List(java.util.List) ModifyListener(org.eclipse.swt.events.ModifyListener) SWT(org.eclipse.swt.SWT) IAction(org.apache.hop.workflow.action.IAction) BaseTransformDialog(org.apache.hop.ui.pipeline.transform.BaseTransformDialog) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ModifyListener(org.eclipse.swt.events.ModifyListener) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) ColumnInfo(org.apache.hop.ui.core.widget.ColumnInfo) NeoConnection(org.apache.hop.neo4j.shared.NeoConnection) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.apache.hop.ui.core.widget.TableView)

Example 5 with MetaSelectionLine

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;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) RowMeta(org.apache.hop.core.row.RowMeta) TableView(org.apache.hop.ui.core.widget.TableView) IVariables(org.apache.hop.core.variables.IVariables) Props(org.apache.hop.core.Props) HopException(org.apache.hop.core.exception.HopException) MongoDbConnection(org.apache.hop.mongo.metadata.MongoDbConnection) Variables(org.apache.hop.core.variables.Variables) MetaSelectionLine(org.apache.hop.ui.core.widget.MetaSelectionLine) ITransformDialog(org.apache.hop.pipeline.transform.ITransformDialog) ArrayList(java.util.ArrayList) IValueMeta(org.apache.hop.core.row.IValueMeta) ValueMetaFactory(org.apache.hop.core.row.value.ValueMetaFactory) DBObject(com.mongodb.DBObject) MongoClientWrapper(org.apache.hop.mongo.wrapper.MongoClientWrapper) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) ShowMessageDialog(org.apache.hop.ui.core.dialog.ShowMessageDialog) CCombo(org.eclipse.swt.custom.CCombo) IRowMeta(org.apache.hop.core.row.IRowMeta) ColumnInfo(org.apache.hop.ui.core.widget.ColumnInfo) BaseMessages(org.apache.hop.i18n.BaseMessages) CTabFolder(org.eclipse.swt.custom.CTabFolder) FormLayout(org.eclipse.swt.layout.FormLayout) BaseDialog(org.apache.hop.ui.core.dialog.BaseDialog) FormData(org.eclipse.swt.layout.FormData) org.eclipse.swt.widgets(org.eclipse.swt.widgets) BaseTransformMeta(org.apache.hop.pipeline.transform.BaseTransformMeta) Set(java.util.Set) FormAttachment(org.eclipse.swt.layout.FormAttachment) Const(org.apache.hop.core.Const) CTabItem(org.eclipse.swt.custom.CTabItem) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) List(java.util.List) TextVar(org.apache.hop.ui.core.widget.TextVar) ModifyListener(org.eclipse.swt.events.ModifyListener) MongoClient(com.mongodb.MongoClient) SWT(org.eclipse.swt.SWT) BaseTransformDialog(org.apache.hop.ui.pipeline.transform.BaseTransformDialog) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) CTabFolder(org.eclipse.swt.custom.CTabFolder) ModifyListener(org.eclipse.swt.events.ModifyListener) HopException(org.apache.hop.core.exception.HopException) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) ColumnInfo(org.apache.hop.ui.core.widget.ColumnInfo) CTabItem(org.eclipse.swt.custom.CTabItem) MongoDbConnection(org.apache.hop.mongo.metadata.MongoDbConnection) TextVar(org.apache.hop.ui.core.widget.TextVar) CCombo(org.eclipse.swt.custom.CCombo) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.apache.hop.ui.core.widget.TableView)

Aggregations

MetaSelectionLine (org.apache.hop.ui.core.widget.MetaSelectionLine)9 Const (org.apache.hop.core.Const)7 IVariables (org.apache.hop.core.variables.IVariables)7 BaseMessages (org.apache.hop.i18n.BaseMessages)7 BaseTransformDialog (org.apache.hop.ui.pipeline.transform.BaseTransformDialog)7 SWT (org.eclipse.swt.SWT)7 ModifyListener (org.eclipse.swt.events.ModifyListener)7 FormAttachment (org.eclipse.swt.layout.FormAttachment)7 FormData (org.eclipse.swt.layout.FormData)7 FormLayout (org.eclipse.swt.layout.FormLayout)7 BaseDialog (org.apache.hop.ui.core.dialog.BaseDialog)6 org.eclipse.swt.widgets (org.eclipse.swt.widgets)6 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)5 ColumnInfo (org.apache.hop.ui.core.widget.ColumnInfo)5 TableView (org.apache.hop.ui.core.widget.TableView)5 TextVar (org.apache.hop.ui.core.widget.TextVar)5 List (java.util.List)4 StringUtils (org.apache.commons.lang.StringUtils)4 HopException (org.apache.hop.core.exception.HopException)4 Utils (org.apache.hop.core.util.Utils)4