use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.
the class DBProcDialog method get.
private void get() {
try {
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null && !r.isEmpty()) {
TableItemInsertListener listener = new TableItemInsertListener() {
public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
tableItem.setText(2, "IN");
return true;
}
};
BaseStepDialog.getFieldsFromPrevious(r, wFields, 1, new int[] { 1 }, new int[] { 3 }, -1, -1, listener);
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "DBProcDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "DBProcDialog.FailedToGetFields.DialogMessage"), ke);
}
}
use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.
the class DeleteDialog method get.
private void get() {
try {
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null && !r.isEmpty()) {
TableItemInsertListener listener = new TableItemInsertListener() {
public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
tableItem.setText(2, "=");
return true;
}
};
BaseStepDialog.getFieldsFromPrevious(r, wKey, 1, new int[] { 1, 3 }, new int[] {}, -1, -1, listener);
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "DeleteDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "DeleteDialog.FailedToGetFields.DialogMessage"), ke);
}
}
use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.
the class DeleteDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
input.setChanged();
}
};
ModifyListener lsTableMod = new ModifyListener() {
public void modifyText(ModifyEvent arg0) {
input.setChanged();
setTableFieldCombo();
}
};
SelectionListener lsSelection = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
setTableFieldCombo();
}
};
changed = input.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "DeleteDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "DeleteDialog.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);
// Connection line
wConnection = addConnectionLine(shell, wStepname, middle, margin);
if (input.getDatabaseMeta() == null && transMeta.nrDatabases() == 1) {
wConnection.select(0);
}
wConnection.addModifyListener(lsMod);
wConnection.addSelectionListener(lsSelection);
// Schema line...
wlSchema = new Label(shell, SWT.RIGHT);
wlSchema.setText(BaseMessages.getString(PKG, "DeleteDialog.TargetSchema.Label"));
props.setLook(wlSchema);
fdlSchema = new FormData();
fdlSchema.left = new FormAttachment(0, 0);
fdlSchema.right = new FormAttachment(middle, -margin);
fdlSchema.top = new FormAttachment(wConnection, margin * 2);
wlSchema.setLayoutData(fdlSchema);
wbSchema = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbSchema);
wbSchema.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
fdbSchema = new FormData();
fdbSchema.top = new FormAttachment(wConnection, 2 * margin);
fdbSchema.right = new FormAttachment(100, 0);
wbSchema.setLayoutData(fdbSchema);
wSchema = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wSchema);
wSchema.addModifyListener(lsTableMod);
fdSchema = new FormData();
fdSchema.left = new FormAttachment(middle, 0);
fdSchema.top = new FormAttachment(wConnection, margin * 2);
fdSchema.right = new FormAttachment(wbSchema, -margin);
wSchema.setLayoutData(fdSchema);
// Table line...
wlTable = new Label(shell, SWT.RIGHT);
wlTable.setText(BaseMessages.getString(PKG, "DeleteDialog.TargetTable.Label"));
props.setLook(wlTable);
fdlTable = new FormData();
fdlTable.left = new FormAttachment(0, 0);
fdlTable.right = new FormAttachment(middle, -margin);
fdlTable.top = new FormAttachment(wbSchema, margin);
wlTable.setLayoutData(fdlTable);
wbTable = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbTable);
wbTable.setText(BaseMessages.getString(PKG, "DeleteDialog.Browse.Button"));
fdbTable = new FormData();
fdbTable.right = new FormAttachment(100, 0);
fdbTable.top = new FormAttachment(wbSchema, margin);
wbTable.setLayoutData(fdbTable);
wTable = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wTable);
wTable.addModifyListener(lsTableMod);
fdTable = new FormData();
fdTable.left = new FormAttachment(middle, 0);
fdTable.top = new FormAttachment(wbSchema, margin);
fdTable.right = new FormAttachment(wbTable, -margin);
wTable.setLayoutData(fdTable);
// Commit line
wlCommit = new Label(shell, SWT.RIGHT);
wlCommit.setText(BaseMessages.getString(PKG, "DeleteDialog.Commit.Label"));
props.setLook(wlCommit);
fdlCommit = new FormData();
fdlCommit.left = new FormAttachment(0, 0);
fdlCommit.top = new FormAttachment(wTable, margin);
fdlCommit.right = new FormAttachment(middle, -margin);
wlCommit.setLayoutData(fdlCommit);
wCommit = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wCommit);
wCommit.addModifyListener(lsMod);
fdCommit = new FormData();
fdCommit.left = new FormAttachment(middle, 0);
fdCommit.top = new FormAttachment(wTable, margin);
fdCommit.right = new FormAttachment(100, 0);
wCommit.setLayoutData(fdCommit);
wlKey = new Label(shell, SWT.NONE);
wlKey.setText(BaseMessages.getString(PKG, "DeleteDialog.Key.Label"));
props.setLook(wlKey);
fdlKey = new FormData();
fdlKey.left = new FormAttachment(0, 0);
fdlKey.top = new FormAttachment(wCommit, margin);
wlKey.setLayoutData(fdlKey);
int nrKeyCols = 4;
int nrKeyRows = (input.getKeyStream() != null ? input.getKeyStream().length : 1);
ciKey = new ColumnInfo[nrKeyCols];
ciKey[0] = new ColumnInfo(BaseMessages.getString(PKG, "DeleteDialog.ColumnInfo.TableField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciKey[1] = new ColumnInfo(BaseMessages.getString(PKG, "DeleteDialog.ColumnInfo.Comparator"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "=", "<>", "<", "<=", ">", ">=", "LIKE", "BETWEEN", "IS NULL", "IS NOT NULL" });
ciKey[2] = new ColumnInfo(BaseMessages.getString(PKG, "DeleteDialog.ColumnInfo.StreamField1"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciKey[3] = new ColumnInfo(BaseMessages.getString(PKG, "DeleteDialog.ColumnInfo.StreamField2"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
tableFieldColumns.add(ciKey[0]);
wKey = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciKey, nrKeyRows, lsMod, props);
wGet = new Button(shell, SWT.PUSH);
wGet.setText(BaseMessages.getString(PKG, "DeleteDialog.GetFields.Button"));
fdGet = new FormData();
fdGet.right = new FormAttachment(100, 0);
fdGet.top = new FormAttachment(wlKey, margin);
wGet.setLayoutData(fdGet);
fdKey = new FormData();
fdKey.left = new FormAttachment(0, 0);
fdKey.top = new FormAttachment(wlKey, margin);
fdKey.right = new FormAttachment(wGet, -margin);
fdKey.bottom = new FormAttachment(100, -30);
wKey.setLayoutData(fdKey);
//
// Search the fields in the background
//
final Runnable runnable = new Runnable() {
public void run() {
StepMeta stepMeta = transMeta.findStep(stepname);
if (stepMeta != null) {
try {
RowMetaInterface row = transMeta.getPrevStepFields(stepMeta);
// Remember these fields...
for (int i = 0; i < row.size(); i++) {
inputFields.put(row.getValueMeta(i).getName(), i);
}
setComboBoxes();
} catch (KettleException e) {
logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
}
}
};
new Thread(runnable).start();
// THE BUTTONS
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOK, wCancel }, margin, null);
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsGet = new Listener() {
public void handleEvent(Event e) {
get();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wGet.addListener(SWT.Selection, lsGet);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wSchema.addSelectionListener(lsDef);
wTable.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
wbSchema.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
getSchemaNames();
}
});
wbTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
getTableName();
}
});
// Set the shell size, based upon previous time...
setSize();
getData();
setTableFieldCombo();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.
the class DeleteDialog method setTableFieldCombo.
private void setTableFieldCombo() {
Runnable fieldLoader = new Runnable() {
public void run() {
if (!wTable.isDisposed() && !wConnection.isDisposed() && !wSchema.isDisposed()) {
final String tableName = wTable.getText(), connectionName = wConnection.getText(), schemaName = wSchema.getText();
// clear
for (ColumnInfo colInfo : tableFieldColumns) {
colInfo.setComboValues(new String[] {});
}
if (!Utils.isEmpty(tableName)) {
DatabaseMeta ci = transMeta.findDatabase(connectionName);
if (ci != null) {
Database db = new Database(loggingObject, ci);
try {
db.connect();
String schemaTable = ci.getQuotedSchemaTableCombination(transMeta.environmentSubstitute(schemaName), transMeta.environmentSubstitute(tableName));
RowMetaInterface r = db.getTableFields(schemaTable);
if (null != r) {
String[] fieldNames = r.getFieldNames();
if (null != fieldNames) {
for (ColumnInfo colInfo : tableFieldColumns) {
colInfo.setComboValues(fieldNames);
}
}
}
} catch (Exception e) {
for (ColumnInfo colInfo : tableFieldColumns) {
colInfo.setComboValues(new String[] {});
}
// ignore any errors here. drop downs will not be
// filled, but no problem for the user
} finally {
try {
if (db != null) {
db.disconnect();
}
} catch (Exception ignored) {
// ignore any errors here.
db = null;
}
}
}
}
}
}
};
shell.getDisplay().asyncExec(fieldLoader);
}
use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.
the class DenormaliserDialog method getAgg.
private void getAgg() {
// The grouping fields: ignore those.
wGroup.removeEmptyRows();
final String[] groupingFields = wGroup.getItems(0);
try {
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null && !r.isEmpty()) {
BaseStepDialog.getFieldsFromPrevious(r, wTarget, 2, new int[] {}, new int[] {}, -1, -1, new TableItemInsertListener() {
@Override
public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
if (Const.indexOfString(v.getName(), groupingFields) < 0) {
// Not a grouping field
if (!wKeyField.getText().equalsIgnoreCase(v.getName())) {
// Not the key field
int nr = tableItem.getParent().indexOf(tableItem) + 1;
tableItem.setText(1, BaseMessages.getString(PKG, "DenormaliserDialog.TargetFieldname.Label") + // the target fieldname
nr);
tableItem.setText(2, v.getName());
tableItem.setText(4, v.getTypeDesc());
if (v.getLength() >= 0) {
tableItem.setText(6, "" + v.getLength());
}
if (v.getPrecision() >= 0) {
tableItem.setText(7, "" + v.getPrecision());
}
}
}
return true;
}
});
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "DenormaliserDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "DenormaliserDialog.FailedToGetFields.DialogMessage"), ke);
}
}
Aggregations