protected void getParamsData() { wParams.clearAll(false); ArrayList<String> paramNames = new ArrayList<String>(configuration.getParams().keySet()); Collections.sort(paramNames); for (int i = 0; i < paramNames.size(); i++) { String paramName = paramNames.get(i); String paramValue = configuration.getParams().get(paramName); String defaultValue; try { defaultValue = abstractMeta.getParameterDefault(paramName); } catch (UnknownParamException e) { defaultValue = ""; } String description; try { description = abstractMeta.getParameterDescription(paramName); } catch (UnknownParamException e) { description = ""; } TableItem tableItem = new TableItem(wParams.table, SWT.NONE); tableItem.setText(1, paramName); tableItem.setText(2, Const.NVL(defaultValue, "")); tableItem.setText(3, Const.NVL(paramValue, "")); tableItem.setText(4, Const.NVL(description, "")); } wParams.removeEmptyRows(); wParams.setRowNums(); wParams.optWidth(true); }
private void getArgumentsData() { wArguments.clearAll(false); List<String> argumentNames = new ArrayList<String>(configuration.getArguments().keySet()); Collections.sort(argumentNames); for (int i = 0; i < argumentNames.size(); i++) { String argumentName = argumentNames.get(i); String argumentValue = configuration.getArguments().get(argumentName); TableItem tableItem = new TableItem(wArguments.table, SWT.NONE); tableItem.setText(1, Const.NVL(argumentName, "")); tableItem.setText(2, Const.NVL(argumentValue, "")); } wArguments.removeEmptyRows(); wArguments.setRowNums(); wArguments.optWidth(true); }
private void getInfoArguments() { Map<String, String> map = new HashMap<String, String>(); int nrNonEmptyArguments = wArguments.nrNonEmpty(); for (int i = 0; i < nrNonEmptyArguments; i++) { TableItem tableItem = wArguments.getNonEmpty(i); String varName = tableItem.getText(1); String varValue = tableItem.getText(2); if (!Const.isEmpty(varName)) { map.put(varName, varValue); } } configuration.setArguments(map); }
protected void getInfoVariables() { Map<String, String> map = new HashMap<String, String>(); int nrNonEmptyVariables = wVariables.nrNonEmpty(); for (int i = 0; i < nrNonEmptyVariables; i++) { TableItem tableItem = wVariables.getNonEmpty(i); String varName = tableItem.getText(1); String varValue = tableItem.getText(2); if (!Const.isEmpty(varName)) { map.put(varName, varValue); } } configuration.setVariables(map); }
/** Get the parameters from the dialog. */ protected void getInfoParameters() { Map<String, String> map = new HashMap<String, String>(); int nrNonEmptyVariables = wParams.nrNonEmpty(); for (int i = 0; i < nrNonEmptyVariables; i++) { TableItem tableItem = wParams.getNonEmpty(i); String paramName = tableItem.getText(1); String defaultValue = tableItem.getText(2); String paramValue = tableItem.getText(3); if (Const.isEmpty(paramValue)) { paramValue = Const.NVL(defaultValue, ""); } map.put(paramName, paramValue); } configuration.setParams(map); }
public ConfigurationDialog( Shell parent, ExecutionConfiguration configuration, AbstractMeta meta) { super(parent); this.parent = parent; this.configuration = configuration; this.abstractMeta = meta; initCheckboxFlag(); // Fill the parameters, maybe do this in another place? Map<String, String> params = configuration.getParams(); params.clear(); String[] paramNames = meta.listParameters(); for (String name : paramNames) { params.put(name, ""); } props = PropsUI.getInstance(); }
/** * Create the composite. * * @param parent * @param style */ public ArgumentsDialog( final Shell parent, ExecutionConfiguration configuration, AbstractMeta abstractMeta) { super(parent); this.configuration = configuration; display = parent.getDisplay(); shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.APPLICATION_MODAL); props = PropsUI.getInstance(); props.setLook(shell); shell.setImage(parent.getImage()); shell.setLayout(new FormLayout()); shell.setText(BaseMessages.getString(PKG, "ArgumentsDialog.Arguments.Label")); ColumnInfo[] cArguments = { new ColumnInfo( BaseMessages.getString(PKG, "ArgumentsDialog.ArgumentsColumn.Argument"), ColumnInfo.COLUMN_TYPE_TEXT, false, true, 180), // Argument name new ColumnInfo( BaseMessages.getString(PKG, "ArgumentsDialog.ArgumentsColumn.Value"), ColumnInfo.COLUMN_TYPE_TEXT, false, false, 172), // Actual value }; int nrArguments = configuration.getArguments() != null ? configuration.getArguments().size() : 0; wArguments = new TableView( abstractMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, cArguments, nrArguments, false, null, props, false); FormData fd_argumentsTable = new FormData(); fd_argumentsTable.top = new FormAttachment(0, 15); fd_argumentsTable.left = new FormAttachment(0, 15); fd_argumentsTable.bottom = new FormAttachment(0, 221); fd_argumentsTable.right = new FormAttachment(0, 371); wArguments.setLayoutData(fd_argumentsTable); Label separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); FormData fd_separator = new FormData(); fd_separator.top = new FormAttachment(wArguments, 15); fd_separator.right = new FormAttachment(wArguments, 0, SWT.RIGHT); fd_separator.left = new FormAttachment(0, 15); separator.setLayoutData(fd_separator); Button okButton = new Button(shell, SWT.NONE); okButton.setText("OK"); FormData fd_okButton = new FormData(); fd_okButton.left = new FormAttachment(0, 269); okButton.setLayoutData(fd_okButton); okButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ok(); } }); Button cancelButton = new Button(shell, SWT.NONE); fd_okButton.top = new FormAttachment(cancelButton, 0, SWT.TOP); fd_okButton.right = new FormAttachment(cancelButton, -4); cancelButton.setText("Cancel"); FormData fd_cancelButton = new FormData(); fd_cancelButton.top = new FormAttachment(separator, 13); fd_cancelButton.right = new FormAttachment(wArguments, 0, SWT.RIGHT); cancelButton.setLayoutData(fd_cancelButton); cancelButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { dispose(); } }); Button btnHelp = new Button(shell, SWT.NONE); btnHelp.setImage(GUIResource.getInstance().getImageHelpWeb()); btnHelp.setText(BaseMessages.getString(PKG, "System.Button.Help")); btnHelp.setToolTipText(BaseMessages.getString(PKG, "System.Tooltip.Help")); FormData fd_btnHelp = new FormData(); fd_btnHelp.top = new FormAttachment(separator, 13); fd_btnHelp.left = new FormAttachment(separator, 0, SWT.LEFT); btnHelp.setLayoutData(fd_btnHelp); btnHelp.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent evt) { String docUrl = BaseMessages.getString(Spoon.class, "Spoon.ArgumentsDialog.Help"); String docTitle = BaseMessages.getString(PKG, "ArgumentsDialog.docTitle"); String docHeader = BaseMessages.getString(PKG, "ArgumentsDialog.docHeader"); HelpUtils.openHelpDialog(parent.getShell(), docTitle, docUrl, docHeader); } }); shell.setSize(394, 319); getArgumentsData(); shell.open(); Rectangle shellBounds = getParent().getBounds(); Point dialogSize = shell.getSize(); shell.setLocation( shellBounds.x + (shellBounds.width - dialogSize.x) / 2, shellBounds.y + (shellBounds.height - dialogSize.y) / 2); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
protected void parametersSectionLayout(Class<?> PKG, String prefix) { tabFolder = new CTabFolder(shell, SWT.BORDER); props.setLook(tabFolder, Props.WIDGET_STYLE_TAB); fdDetails.bottom = new FormAttachment(tabFolder, -16); fd_tabFolder = new FormData(); fd_tabFolder.right = new FormAttachment(100, -15); fd_tabFolder.left = new FormAttachment(0, 15); fd_tabFolder.top = new FormAttachment(0, 276); tabFolder.setLayoutData(fd_tabFolder); // Parameters CTabItem tbtmParameters = new CTabItem(tabFolder, SWT.NONE); tbtmParameters.setText(BaseMessages.getString(PKG, prefix + ".Params.Label")); Composite parametersComposite = new Composite(tabFolder, SWT.NONE); props.setLook(parametersComposite); parametersComposite.setLayout(new FormLayout()); tbtmParameters.setControl(parametersComposite); ColumnInfo[] cParams = { new ColumnInfo( BaseMessages.getString(PKG, prefix + ".ParamsColumn.Argument"), ColumnInfo.COLUMN_TYPE_TEXT, false, true, 126), // Stepname new ColumnInfo( BaseMessages.getString(PKG, prefix + ".ParamsColumn.Default"), ColumnInfo.COLUMN_TYPE_TEXT, false, true, 138), // Preview size new ColumnInfo( BaseMessages.getString(PKG, prefix + ".ParamsColumn.Value"), ColumnInfo.COLUMN_TYPE_TEXT, false, false, 142), // Preview size new ColumnInfo( BaseMessages.getString(PKG, prefix + ".ParamsColumn.Description"), ColumnInfo.COLUMN_TYPE_TEXT, false, true, 181), // Preview size }; String[] namedParams = abstractMeta.listParameters(); int nrParams = namedParams.length; wParams = new TableView( abstractMeta, parametersComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, cParams, nrParams, false, null, props, false); FormData fdParams = new FormData(); fdParams.top = new FormAttachment(0, 10); fdParams.left = new FormAttachment(0, 10); wParams.setLayoutData(fdParams); tabFolder.setSelection(0); Button argsButton = new Button(parametersComposite, SWT.NONE); fdParams.right = new FormAttachment(argsButton, 0, SWT.RIGHT); fdParams.bottom = new FormAttachment(argsButton, -6); FormData fd_argsButton = new FormData(); fd_argsButton.right = new FormAttachment(100, -10); fd_argsButton.bottom = new FormAttachment(100, -10); argsButton.setLayoutData(fd_argsButton); argsButton.setText(BaseMessages.getString(PKG, prefix + ".Arguments.Label")); argsButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { new ArgumentsDialog(shell, configuration, abstractMeta); } }); // Variables CTabItem tbtmVariables = new CTabItem(tabFolder, SWT.NONE); tbtmVariables.setText(BaseMessages.getString(PKG, prefix + ".Variables.Label")); Composite variablesComposite = new Composite(tabFolder, SWT.NONE); props.setLook(variablesComposite); variablesComposite.setLayout(new FormLayout()); tbtmVariables.setControl(variablesComposite); ColumnInfo[] cVariables = { new ColumnInfo( BaseMessages.getString(PKG, prefix + ".VariablesColumn.Argument"), ColumnInfo.COLUMN_TYPE_TEXT, false, false, 287), // Stepname new ColumnInfo( BaseMessages.getString(PKG, prefix + ".VariablesColumn.Value"), ColumnInfo.COLUMN_TYPE_TEXT, false, false, 300), // Preview size }; int nrVariables = configuration.getVariables() != null ? configuration.getVariables().size() : 0; wVariables = new TableView( abstractMeta, variablesComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, cVariables, nrVariables, false, null, props, false); FormData fdVariables = new FormData(); fdVariables.top = new FormAttachment(0, 10); fdVariables.left = new FormAttachment(0, 10); fdVariables.bottom = new FormAttachment(0, 221); fdVariables.right = new FormAttachment(100, -10); wVariables.setLayoutData(fdVariables); }