private void addFields() { int FieldsCols = 4; ColumnInfo[] colinf = new ColumnInfo[FieldsCols]; // Table with fields wlFields = new Label(shell, SWT.NONE); wlFields.setText(BaseMessages.getString(PKG, "IfNullDialog.Fields.Label")); props.setLook(wlFields); fdlFields = new FormData(); fdlFields.left = new FormAttachment(0, 0); fdlFields.top = new FormAttachment(wValueTypes, margin); wlFields.setLayoutData(fdlFields); colinf[0] = new ColumnInfo( BaseMessages.getString(PKG, "IfNullDialog.Fieldname.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] {}, false); colinf[1] = new ColumnInfo( BaseMessages.getString(PKG, "IfNullDialog.Value.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false); colinf[2] = new ColumnInfo( BaseMessages.getString(PKG, "IfNullDialog.Value.ConversionMask"), ColumnInfo.COLUMN_TYPE_CCOMBO, Const.getDateFormats()); colinf[1].setUsingVariables(true); colinf[3] = new ColumnInfo( BaseMessages.getString(PKG, "IfNullDialog.Value.SetEmptyString"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { BaseMessages.getString(PKG, "System.Combo.Yes"), BaseMessages.getString(PKG, "System.Combo.No") }); wFields = new TableView( transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, fieldsRows, oldlsMod, props); fdFields = new FormData(); fdFields.left = new FormAttachment(0, 0); fdFields.top = new FormAttachment(wlFields, margin); fdFields.right = new FormAttachment(100, 0); fdFields.bottom = new FormAttachment(wOK, -2 * margin); wFields.setLayoutData(fdFields); setComboValues(); fieldColumns.add(colinf[0]); }
public String open() { Shell parent = getParent(); Display display = parent.getDisplay(); shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX); props.setLook(shell); setShellImage(shell, input); lsMod = new ModifyListener() { public void modifyText(ModifyEvent e) { input.setChanged(); } }; changed = input.hasChanged(); oldlsMod = lsMod; FormLayout formLayout = new FormLayout(); formLayout.marginWidth = Const.FORM_MARGIN; formLayout.marginHeight = Const.FORM_MARGIN; middle = props.getMiddlePct(); margin = Const.MARGIN; fieldsRows = input.getFields().length; shell.setLayout(formLayout); shell.setText(BaseMessages.getString(PKG, "IfNullDialog.Shell.Title")); // Stepname line wlStepname = new Label(shell, SWT.RIGHT); wlStepname.setText(BaseMessages.getString(PKG, "IfNullDialog.Stepname.Label")); props.setLook(wlStepname); fdlStepname = new FormData(); fdlStepname.left = new FormAttachment(0, 0); fdlStepname.right = new FormAttachment(middle, -margin); fdlStepname.top = new FormAttachment(0, margin); wlStepname.setLayoutData(fdlStepname); wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER); wStepname.setText(stepname); props.setLook(wStepname); wStepname.addModifyListener(lsMod); fdStepname = new FormData(); fdStepname.left = new FormAttachment(middle, 0); fdStepname.top = new FormAttachment(0, margin); fdStepname.right = new FormAttachment(100, 0); wStepname.setLayoutData(fdStepname); // /////////////////////////////// // START OF All Fields GROUP // // /////////////////////////////// wAllFields = new Group(shell, SWT.SHADOW_NONE); props.setLook(wAllFields); wAllFields.setText(BaseMessages.getString(PKG, "IfNullDialog.AllFields.Label")); FormLayout AllFieldsgroupLayout = new FormLayout(); AllFieldsgroupLayout.marginWidth = 10; AllFieldsgroupLayout.marginHeight = 10; wAllFields.setLayout(AllFieldsgroupLayout); // Replace by Value wlReplaceByValue = new Label(wAllFields, SWT.RIGHT); wlReplaceByValue.setText(BaseMessages.getString(PKG, "IfNullDialog.ReplaceByValue.Label")); props.setLook(wlReplaceByValue); fdlReplaceByValue = new FormData(); fdlReplaceByValue.left = new FormAttachment(0, 0); fdlReplaceByValue.right = new FormAttachment(middle, -margin); fdlReplaceByValue.top = new FormAttachment(wStepname, margin * 2); wlReplaceByValue.setLayoutData(fdlReplaceByValue); wReplaceByValue = new TextVar(transMeta, wAllFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER); wReplaceByValue.setToolTipText( BaseMessages.getString(PKG, "IfNullDialog.ReplaceByValue.Tooltip")); props.setLook(wReplaceByValue); fdReplaceByValue = new FormData(); fdReplaceByValue.left = new FormAttachment(middle, 0); fdReplaceByValue.top = new FormAttachment(wStepname, 2 * margin); fdReplaceByValue.right = new FormAttachment(100, 0); wReplaceByValue.setLayoutData(fdReplaceByValue); // SetEmptyStringAll line wlSetEmptyStringAll = new Label(wAllFields, SWT.RIGHT); wlSetEmptyStringAll.setText( BaseMessages.getString(PKG, "IfNullDialog.SetEmptyStringAll.Label")); props.setLook(wlSetEmptyStringAll); fdlSetEmptyStringAll = new FormData(); fdlSetEmptyStringAll.left = new FormAttachment(0, 0); fdlSetEmptyStringAll.top = new FormAttachment(wReplaceByValue, margin); fdlSetEmptyStringAll.right = new FormAttachment(middle, -margin); wlSetEmptyStringAll.setLayoutData(fdlSetEmptyStringAll); wSetEmptyStringAll = new Button(wAllFields, SWT.CHECK); wSetEmptyStringAll.setToolTipText( BaseMessages.getString(PKG, "IfNullDialog.SetEmptyStringAll.Tooltip")); props.setLook(wSetEmptyStringAll); fdSetEmptyStringAll = new FormData(); fdSetEmptyStringAll.left = new FormAttachment(middle, 0); fdSetEmptyStringAll.top = new FormAttachment(wReplaceByValue, margin); fdSetEmptyStringAll.right = new FormAttachment(100, 0); wSetEmptyStringAll.setLayoutData(fdSetEmptyStringAll); wSetEmptyStringAll.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { input.setChanged(); enableSetEmptyStringAll(); } }); wlMask = new Label(wAllFields, SWT.RIGHT); wlMask.setText(BaseMessages.getString(PKG, "IfNullDialog.Mask.Label")); props.setLook(wlMask); fdlMask = new FormData(); fdlMask.left = new FormAttachment(0, 0); fdlMask.top = new FormAttachment(wSetEmptyStringAll, margin); fdlMask.right = new FormAttachment(middle, -margin); wlMask.setLayoutData(fdlMask); wMask = new CCombo(wAllFields, SWT.BORDER | SWT.READ_ONLY); wMask.setEditable(true); wMask.setItems(Const.getDateFormats()); props.setLook(wMask); wMask.addModifyListener(lsMod); fdMask = new FormData(); fdMask.left = new FormAttachment(middle, 0); fdMask.top = new FormAttachment(wSetEmptyStringAll, margin); fdMask.right = new FormAttachment(100, 0); wMask.setLayoutData(fdMask); fdAllFields = new FormData(); fdAllFields.left = new FormAttachment(0, margin); fdAllFields.top = new FormAttachment(wStepname, margin); fdAllFields.right = new FormAttachment(100, -margin); wAllFields.setLayoutData(fdAllFields); // /////////////////////////////////////////////////////////// // / END OF All Fields GROUP // /////////////////////////////////////////////////////////// // Select fields? wlSelectFields = new Label(shell, SWT.RIGHT); wlSelectFields.setText(BaseMessages.getString(PKG, "IfNullDialog.SelectFields.Label")); props.setLook(wlSelectFields); fdlSelectFields = new FormData(); fdlSelectFields.left = new FormAttachment(0, 0); fdlSelectFields.top = new FormAttachment(wAllFields, margin); fdlSelectFields.right = new FormAttachment(middle, -margin); wlSelectFields.setLayoutData(fdlSelectFields); wSelectFields = new Button(shell, SWT.CHECK); wSelectFields.setToolTipText(BaseMessages.getString(PKG, "IfNullDialog.SelectFields.Tooltip")); props.setLook(wSelectFields); fdSelectFields = new FormData(); fdSelectFields.left = new FormAttachment(middle, 0); fdSelectFields.top = new FormAttachment(wAllFields, margin); fdSelectFields.right = new FormAttachment(100, 0); wSelectFields.setLayoutData(fdSelectFields); // Select type? wlSelectValuesType = new Label(shell, SWT.RIGHT); wlSelectValuesType.setText(BaseMessages.getString(PKG, "IfNullDialog.SelectValuesType.Label")); props.setLook(wlSelectValuesType); fdlSelectValuesType = new FormData(); fdlSelectValuesType.left = new FormAttachment(0, 0); fdlSelectValuesType.top = new FormAttachment(wSelectFields, margin); fdlSelectValuesType.right = new FormAttachment(middle, -margin); wlSelectValuesType.setLayoutData(fdlSelectValuesType); wSelectValuesType = new Button(shell, SWT.CHECK); wSelectValuesType.setToolTipText( BaseMessages.getString(PKG, "IfNullDialog.SelectValuesType.Tooltip")); props.setLook(wSelectValuesType); fdSelectValuesType = new FormData(); fdSelectValuesType.left = new FormAttachment(middle, 0); fdSelectValuesType.top = new FormAttachment(wSelectFields, margin); fdSelectValuesType.right = new FormAttachment(100, 0); wSelectValuesType.setLayoutData(fdSelectValuesType); wlValueTypes = new Label(shell, SWT.NONE); wlValueTypes.setText(BaseMessages.getString(PKG, "IfNullDialog.ValueTypes.Label")); props.setLook(wlValueTypes); fdlValueTypes = new FormData(); fdlValueTypes.left = new FormAttachment(0, 0); fdlValueTypes.top = new FormAttachment(wSelectValuesType, margin); wlValueTypes.setLayoutData(fdlValueTypes); int valueTypesRows = input.getValueTypes().length; int FieldsCols = 4; ColumnInfo[] colval = new ColumnInfo[FieldsCols]; colval[0] = new ColumnInfo( BaseMessages.getString(PKG, "IfNullDialog.ValueType.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaInterface.typeCodes); colval[1] = new ColumnInfo( BaseMessages.getString(PKG, "IfNullDialog.Value.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false); colval[2] = new ColumnInfo( BaseMessages.getString(PKG, "IfNullDialog.Value.ConversionMask"), ColumnInfo.COLUMN_TYPE_CCOMBO, Const.getDateFormats()); colval[3] = new ColumnInfo( BaseMessages.getString(PKG, "IfNullDialog.Value.SetEmptyString"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { BaseMessages.getString(PKG, "System.Combo.Yes"), BaseMessages.getString(PKG, "System.Combo.No") }); colval[1].setUsingVariables(true); wValueTypes = new TableView( transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colval, valueTypesRows, oldlsMod, props); fdValueTypes = new FormData(); fdValueTypes.left = new FormAttachment(0, 0); fdValueTypes.top = new FormAttachment(wlValueTypes, margin); fdValueTypes.right = new FormAttachment(100, 0); fdValueTypes.bottom = new FormAttachment(wlValueTypes, 190); wValueTypes.setLayoutData(fdValueTypes); getFirstData(); 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, "System.Button.GetFields")); wCancel = new Button(shell, SWT.PUSH); wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel")); setButtonPositions(new Button[] {wOK, wGet, wCancel}, margin, null); addFields(); wSelectValuesType.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { activeSelectValuesType(); input.setChanged(); } }); wSelectFields.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { activeSelectFields(); input.setChanged(); } }); // Add listeners lsCancel = new Listener() { public void handleEvent(Event e) { cancel(); } }; lsGet = new Listener() { public void handleEvent(Event e) { get(); } }; lsOK = new Listener() { public void handleEvent(Event e) { ok(); } }; wCancel.addListener(SWT.Selection, lsCancel); wOK.addListener(SWT.Selection, lsOK); wGet.addListener(SWT.Selection, lsGet); lsDef = new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { ok(); } }; wStepname.addSelectionListener(lsDef); // Detect X or ALT-F4 or something that kills this window... shell.addShellListener( new ShellAdapter() { public void shellClosed(ShellEvent e) { cancel(); } }); // Set the shell size, based upon previous time... setSize(); getData(); enableSetEmptyStringAll(); // setComboValues(); activeSelectFields(); activeSelectValuesType(); input.setChanged(changed); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return stepname; }