protected String selectTransformationStepname( boolean getTransformationStep, boolean mappingInput) { String dialogTitle = Messages.getString("MappingFieldRunnerDialog.SelectTransStep.Title"); String dialogMessage = Messages.getString("MappingFieldRunnerDialog.SelectTransStep.Message"); if (getTransformationStep) { dialogTitle = Messages.getString("MappingFieldRunnerDialog.SelectTransStep.Title"); dialogMessage = Messages.getString("MappingFieldRunnerDialog.SelectTransStep.Message"); String[] stepnames; if (mappingInput) { stepnames = transMeta.getPrevStepNames(stepMeta); } else { stepnames = transMeta.getNextStepNames(stepMeta); } EnterSelectionDialog dialog = new EnterSelectionDialog(shell, stepnames, dialogTitle, dialogMessage); return dialog.open(); } else { dialogTitle = Messages.getString("MappingFieldRunnerDialog.SelectMappingStep.Title"); dialogMessage = Messages.getString("MappingFieldRunnerDialog.SelectMappingStep.Message"); String[] stepnames = getMappingSteps(mappingTransMeta, mappingInput); EnterSelectionDialog dialog = new EnterSelectionDialog(shell, stepnames, dialogTitle, dialogMessage); return dialog.open(); } }
// Listen to the Variable... button public static final String getVariableName(Shell shell, VariableSpace space) { String keys[] = space.listVariables(); Arrays.sort(keys); int size = keys.length; String key[] = new String[size]; String val[] = new String[size]; String str[] = new String[size]; for (int i = 0; i < keys.length; i++) { key[i] = keys[i]; val[i] = space.getVariable(key[i]); str[i] = key[i] + " [" + val[i] + "]"; } EnterSelectionDialog esd = new EnterSelectionDialog( shell, str, Messages.getString("System.Dialog.SelectEnvironmentVar.Title"), Messages.getString("System.Dialog.SelectEnvironmentVar.Message")); esd.clearModal(); if (esd.open() != null) { int nr = esd.getSelectionNr(); String var = key[nr]; return var; } else { return null; } }
private void getSchemaNames() { if (wSchemaname.isDisposed()) return; DatabaseMeta databaseMeta = transMeta.findDatabase(wConnection.getText()); if (databaseMeta != null) { Database database = new Database(loggingObject, databaseMeta); database.shareVariablesWith(transMeta); try { database.connect(); String schemas[] = database.getSchemas(); if (null != schemas && schemas.length > 0) { schemas = Const.sortStrings(schemas); EnterSelectionDialog dialog = new EnterSelectionDialog( shell, schemas, BaseMessages.getString( PKG, "System.Dialog.AvailableSchemas.Title", wConnection.getText()), BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.Message")); String d = dialog.open(); if (d != null) { wSchemaname.setText(Const.NVL(d.toString(), "")); } } else { MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR); mb.setMessage( BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.Empty.Message")); mb.setText(BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.Empty.Title")); mb.open(); } } catch (Exception e) { new ErrorDialog( shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.ConnectionError"), e); } finally { if (database != null) { database.disconnect(); database = null; } } } }
/** Get a list of columns, comma separated, allow the user to select from it. */ private void getListColumns() { if (!Const.isEmpty(wTablename.getText())) { DatabaseMeta databaseMeta = jobMeta.findDatabase(wConnection.getText()); if (databaseMeta != null) { Database database = new Database(loggingObject, databaseMeta); database.shareVariablesWith(jobMeta); try { database.connect(); String schemaTable = databaseMeta.getQuotedSchemaTableCombination( wSchemaname.getText(), wTablename.getText()); RowMetaInterface row = database.getTableFields(schemaTable); String[] available = row.getFieldNames(); String[] source = wListattribut.getText().split(","); for (int i = 0; i < source.length; i++) { source[i] = Const.trim(source[i]); } int[] idxSource = Const.indexsOfStrings(source, available); EnterSelectionDialog dialog = new EnterSelectionDialog( shell, available, BaseMessages.getString(PKG, "JobMysqlBulkLoad.SelectColumns.Title"), BaseMessages.getString(PKG, "JobMysqlBulkLoad.SelectColumns.Message")); dialog.setMulti(true); dialog.setAvoidQuickSearch(); dialog.setSelectedNrs(idxSource); if (dialog.open() != null) { String columns = ""; int[] idx = dialog.getSelectionIndeces(); for (int i = 0; i < idx.length; i++) { if (i > 0) { columns += ", "; } columns += available[idx[i]]; } wListattribut.setText(columns); } } catch (KettleDatabaseException e) { new ErrorDialog( shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "JobMysqlBulkLoad.ConnectionError2.DialogMessage"), e); } finally { database.disconnect(); } } } }