use of org.pentaho.di.ui.core.widget.TableView in project pentaho-kettle by pentaho.
the class MySQLBulkLoaderDialog 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();
}
};
FocusListener lsFocusLost = new FocusAdapter() {
public void focusLost(FocusEvent arg0) {
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, "MySQLBulkLoaderDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.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);
// Schema line...
wlSchema = new Label(shell, SWT.RIGHT);
wlSchema.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.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);
wSchema = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wSchema);
wSchema.addModifyListener(lsMod);
wSchema.addFocusListener(lsFocusLost);
fdSchema = new FormData();
fdSchema.left = new FormAttachment(middle, 0);
fdSchema.top = new FormAttachment(wConnection, margin * 2);
fdSchema.right = new FormAttachment(100, 0);
wSchema.setLayoutData(fdSchema);
// Table line...
wlTable = new Label(shell, SWT.RIGHT);
wlTable.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.TargetTable.Label"));
props.setLook(wlTable);
fdlTable = new FormData();
fdlTable.left = new FormAttachment(0, 0);
fdlTable.right = new FormAttachment(middle, -margin);
fdlTable.top = new FormAttachment(wSchema, margin);
wlTable.setLayoutData(fdlTable);
wbTable = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbTable);
wbTable.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.Browse.Button"));
fdbTable = new FormData();
fdbTable.right = new FormAttachment(100, 0);
fdbTable.top = new FormAttachment(wSchema, margin);
wbTable.setLayoutData(fdbTable);
wTable = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wTable);
wTable.addModifyListener(lsMod);
wTable.addFocusListener(lsFocusLost);
fdTable = new FormData();
fdTable.left = new FormAttachment(middle, 0);
fdTable.top = new FormAttachment(wSchema, margin);
fdTable.right = new FormAttachment(wbTable, -margin);
wTable.setLayoutData(fdTable);
// FifoFile line...
wlFifoFile = new Label(shell, SWT.RIGHT);
wlFifoFile.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.FifoFile.Label"));
props.setLook(wlFifoFile);
fdlFifoFile = new FormData();
fdlFifoFile.left = new FormAttachment(0, 0);
fdlFifoFile.right = new FormAttachment(middle, -margin);
fdlFifoFile.top = new FormAttachment(wTable, margin);
wlFifoFile.setLayoutData(fdlFifoFile);
wFifoFile = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wFifoFile);
wFifoFile.addModifyListener(lsMod);
fdFifoFile = new FormData();
fdFifoFile.left = new FormAttachment(middle, 0);
fdFifoFile.top = new FormAttachment(wTable, margin);
fdFifoFile.right = new FormAttachment(100, 0);
wFifoFile.setLayoutData(fdFifoFile);
// Delimiter line...
wlDelimiter = new Label(shell, SWT.RIGHT);
wlDelimiter.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.Delimiter.Label"));
props.setLook(wlDelimiter);
fdlDelimiter = new FormData();
fdlDelimiter.left = new FormAttachment(0, 0);
fdlDelimiter.right = new FormAttachment(middle, -margin);
fdlDelimiter.top = new FormAttachment(wFifoFile, margin);
wlDelimiter.setLayoutData(fdlDelimiter);
wbDelimiter = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbDelimiter);
wbDelimiter.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.Delimiter.Button"));
FormData fdbDelimiter = new FormData();
fdbDelimiter.top = new FormAttachment(wFifoFile, margin);
fdbDelimiter.right = new FormAttachment(100, 0);
wbDelimiter.setLayoutData(fdbDelimiter);
wDelimiter = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wDelimiter);
wDelimiter.addModifyListener(lsMod);
fdDelimiter = new FormData();
fdDelimiter.left = new FormAttachment(middle, 0);
fdDelimiter.top = new FormAttachment(wFifoFile, margin);
fdDelimiter.right = new FormAttachment(wbDelimiter, -margin);
wDelimiter.setLayoutData(fdDelimiter);
// Allow the insertion of tabs as separator...
wbDelimiter.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent se) {
Text t = wDelimiter.getTextWidget();
if (t != null) {
t.insert("\t");
}
}
});
// Enclosure line...
wlEnclosure = new Label(shell, SWT.RIGHT);
wlEnclosure.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.Enclosure.Label"));
props.setLook(wlEnclosure);
fdlEnclosure = new FormData();
fdlEnclosure.left = new FormAttachment(0, 0);
fdlEnclosure.right = new FormAttachment(middle, -margin);
fdlEnclosure.top = new FormAttachment(wDelimiter, margin);
wlEnclosure.setLayoutData(fdlEnclosure);
wEnclosure = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wEnclosure);
wEnclosure.addModifyListener(lsMod);
fdEnclosure = new FormData();
fdEnclosure.left = new FormAttachment(middle, 0);
fdEnclosure.top = new FormAttachment(wDelimiter, margin);
fdEnclosure.right = new FormAttachment(100, 0);
wEnclosure.setLayoutData(fdEnclosure);
// EscapeChar line...
wlEscapeChar = new Label(shell, SWT.RIGHT);
wlEscapeChar.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.EscapeChar.Label"));
props.setLook(wlEscapeChar);
fdlEscapeChar = new FormData();
fdlEscapeChar.left = new FormAttachment(0, 0);
fdlEscapeChar.right = new FormAttachment(middle, -margin);
fdlEscapeChar.top = new FormAttachment(wEnclosure, margin);
wlEscapeChar.setLayoutData(fdlEscapeChar);
wEscapeChar = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wEscapeChar);
wEscapeChar.addModifyListener(lsMod);
fdEscapeChar = new FormData();
fdEscapeChar.left = new FormAttachment(middle, 0);
fdEscapeChar.top = new FormAttachment(wEnclosure, margin);
fdEscapeChar.right = new FormAttachment(100, 0);
wEscapeChar.setLayoutData(fdEscapeChar);
// CharSet line...
wlCharSet = new Label(shell, SWT.RIGHT);
wlCharSet.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.CharSet.Label"));
props.setLook(wlCharSet);
fdlCharSet = new FormData();
fdlCharSet.left = new FormAttachment(0, 0);
fdlCharSet.right = new FormAttachment(middle, -margin);
fdlCharSet.top = new FormAttachment(wEscapeChar, margin);
wlCharSet.setLayoutData(fdlCharSet);
wCharSet = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wCharSet);
wCharSet.addModifyListener(lsMod);
fdCharSet = new FormData();
fdCharSet.left = new FormAttachment(middle, 0);
fdCharSet.top = new FormAttachment(wEscapeChar, margin);
fdCharSet.right = new FormAttachment(100, 0);
wCharSet.setLayoutData(fdCharSet);
// BulkSize line...
wlBulkSize = new Label(shell, SWT.RIGHT);
wlBulkSize.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.BulkSize.Label"));
props.setLook(wlBulkSize);
fdlBulkSize = new FormData();
fdlBulkSize.left = new FormAttachment(0, 0);
fdlBulkSize.right = new FormAttachment(middle, -margin);
fdlBulkSize.top = new FormAttachment(wCharSet, margin);
wlBulkSize.setLayoutData(fdlBulkSize);
wBulkSize = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wBulkSize);
wBulkSize.addModifyListener(lsMod);
fdBulkSize = new FormData();
fdBulkSize.left = new FormAttachment(middle, 0);
fdBulkSize.top = new FormAttachment(wCharSet, margin);
fdBulkSize.right = new FormAttachment(100, 0);
wBulkSize.setLayoutData(fdBulkSize);
// Replace line...
wlReplace = new Label(shell, SWT.RIGHT);
wlReplace.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.Replace.Label"));
props.setLook(wlReplace);
fdlReplace = new FormData();
fdlReplace.left = new FormAttachment(0, 0);
fdlReplace.right = new FormAttachment(middle, -margin);
fdlReplace.top = new FormAttachment(wBulkSize, margin * 2);
wlReplace.setLayoutData(fdlReplace);
wReplace = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wReplace);
fdReplace = new FormData();
fdReplace.left = new FormAttachment(middle, 0);
fdReplace.top = new FormAttachment(wBulkSize, margin * 2);
fdReplace.right = new FormAttachment(100, 0);
wReplace.setLayoutData(fdReplace);
wReplace.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
if (wReplace.getSelection()) {
wIgnore.setSelection(false);
}
input.setChanged();
}
});
// Ignore line...
wlIgnore = new Label(shell, SWT.RIGHT);
wlIgnore.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.Ignore.Label"));
props.setLook(wlIgnore);
fdlIgnore = new FormData();
fdlIgnore.left = new FormAttachment(0, 0);
fdlIgnore.right = new FormAttachment(middle, -margin);
fdlIgnore.top = new FormAttachment(wReplace, margin * 2);
wlIgnore.setLayoutData(fdlIgnore);
wIgnore = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wIgnore);
fdIgnore = new FormData();
fdIgnore.left = new FormAttachment(middle, 0);
fdIgnore.top = new FormAttachment(wReplace, margin * 2);
fdIgnore.right = new FormAttachment(100, 0);
wIgnore.setLayoutData(fdIgnore);
wIgnore.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
if (wIgnore.getSelection()) {
wReplace.setSelection(false);
}
input.setChanged();
}
});
// Local line...
wlLocal = new Label(shell, SWT.RIGHT);
wlLocal.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.Local.Label"));
props.setLook(wlLocal);
fdlLocal = new FormData();
fdlLocal.left = new FormAttachment(0, 0);
fdlLocal.right = new FormAttachment(middle, -margin);
fdlLocal.top = new FormAttachment(wIgnore, margin * 2);
wlLocal.setLayoutData(fdlLocal);
wLocal = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wLocal);
fdLocal = new FormData();
fdLocal.left = new FormAttachment(middle, 0);
fdLocal.top = new FormAttachment(wIgnore, margin * 2);
fdLocal.right = new FormAttachment(100, 0);
wLocal.setLayoutData(fdLocal);
wLocal.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
input.setChanged();
}
});
// THE BUTTONS
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wSQL = new Button(shell, SWT.PUSH);
wSQL.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.SQL.Button"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOK, wCancel, wSQL }, margin, null);
// The field Table
wlReturn = new Label(shell, SWT.NONE);
wlReturn.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.Fields.Label"));
props.setLook(wlReturn);
fdlReturn = new FormData();
fdlReturn.left = new FormAttachment(0, 0);
fdlReturn.top = new FormAttachment(wLocal, margin);
wlReturn.setLayoutData(fdlReturn);
int UpInsCols = 3;
int UpInsRows = (input.getFieldTable() != null ? input.getFieldTable().length : 1);
ciReturn = new ColumnInfo[UpInsCols];
ciReturn[0] = new ColumnInfo(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.ColumnInfo.TableField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciReturn[1] = new ColumnInfo(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.ColumnInfo.StreamField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciReturn[2] = new ColumnInfo(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.ColumnInfo.FormatOK"), ColumnInfo.COLUMN_TYPE_CCOMBO, MySQLBulkLoaderMeta.getFieldFormatTypeDescriptions(), true);
tableFieldColumns.add(ciReturn[0]);
wReturn = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciReturn, UpInsRows, lsMod, props);
wGetLU = new Button(shell, SWT.PUSH);
wGetLU.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.GetFields.Label"));
fdGetLU = new FormData();
fdGetLU.top = new FormAttachment(wlReturn, margin);
fdGetLU.right = new FormAttachment(100, 0);
wGetLU.setLayoutData(fdGetLU);
wDoMapping = new Button(shell, SWT.PUSH);
wDoMapping.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.EditMapping.Label"));
fdDoMapping = new FormData();
fdDoMapping.top = new FormAttachment(wGetLU, margin);
fdDoMapping.right = new FormAttachment(100, 0);
wDoMapping.setLayoutData(fdDoMapping);
wDoMapping.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event arg0) {
generateMappings();
}
});
fdReturn = new FormData();
fdReturn.left = new FormAttachment(0, 0);
fdReturn.top = new FormAttachment(wlReturn, margin);
fdReturn.right = new FormAttachment(wDoMapping, -margin);
fdReturn.bottom = new FormAttachment(wOK, -2 * margin);
wReturn.setLayoutData(fdReturn);
//
// 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();
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsGetLU = new Listener() {
public void handleEvent(Event e) {
getUpdate();
}
};
lsSQL = new Listener() {
public void handleEvent(Event e) {
create();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wGetLU.addListener(SWT.Selection, lsGetLU);
wSQL.addListener(SWT.Selection, lsSQL);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wSchema.addSelectionListener(lsDef);
wFifoFile.addSelectionListener(lsDef);
wTable.addSelectionListener(lsDef);
wDelimiter.addSelectionListener(lsDef);
wEnclosure.addSelectionListener(lsDef);
wCharSet.addSelectionListener(lsDef);
wBulkSize.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
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.ui.core.widget.TableView in project pentaho-kettle by pentaho.
the class NormaliserDialog 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();
}
};
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, "NormaliserDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "NormaliserDialog.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);
// Typefield line
wlTypefield = new Label(shell, SWT.RIGHT);
wlTypefield.setText(BaseMessages.getString(PKG, "NormaliserDialog.TypeField.Label"));
props.setLook(wlTypefield);
fdlTypefield = new FormData();
fdlTypefield.left = new FormAttachment(0, 0);
fdlTypefield.right = new FormAttachment(middle, -margin);
fdlTypefield.top = new FormAttachment(wStepname, margin);
wlTypefield.setLayoutData(fdlTypefield);
wTypefield = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wTypefield.setText("");
props.setLook(wTypefield);
wTypefield.addModifyListener(lsMod);
fdTypefield = new FormData();
fdTypefield.left = new FormAttachment(middle, 0);
fdTypefield.top = new FormAttachment(wStepname, margin);
fdTypefield.right = new FormAttachment(100, 0);
wTypefield.setLayoutData(fdTypefield);
wlFields = new Label(shell, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "NormaliserDialog.Fields.Label"));
props.setLook(wlFields);
fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.top = new FormAttachment(wTypefield, margin);
wlFields.setLayoutData(fdlFields);
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, "NormaliserDialog.GetFields.Button"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOK, wCancel, wGet }, margin, null);
final int fieldsCols = 3;
final int fieldsRows = input.getNormaliserFields().length;
colinf = new ColumnInfo[fieldsCols];
colinf[0] = new ColumnInfo(BaseMessages.getString(PKG, "NormaliserDialog.ColumnInfo.Fieldname"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
colinf[1] = new ColumnInfo(BaseMessages.getString(PKG, "NormaliserDialog.ColumnInfo.Type"), ColumnInfo.COLUMN_TYPE_TEXT, false);
colinf[2] = new ColumnInfo(BaseMessages.getString(PKG, "NormaliserDialog.ColumnInfo.NewField"), ColumnInfo.COLUMN_TYPE_TEXT, false);
wFields = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, fieldsRows, lsMod, 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);
//
// 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(), Integer.valueOf(i));
}
setComboBoxes();
} catch (KettleException e) {
logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
}
}
};
new Thread(runnable).start();
// 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);
// 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();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.widget.TableView in project pentaho-kettle by pentaho.
the class NullIfDialog 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();
}
};
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, "NullIfDialog.Shell.Label"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "NullIfDialog.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);
wlFields = new Label(shell, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "NullIfDialog.Fields.Label"));
props.setLook(wlFields);
fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.top = new FormAttachment(wStepname, margin);
wlFields.setLayoutData(fdlFields);
final int FieldsCols = 2;
final int fieldsRows = input.getFields().length;
colinf = new ColumnInfo[FieldsCols];
colinf[0] = new ColumnInfo(BaseMessages.getString(PKG, "NullIfDialog.ColumnInfo.Name"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
colinf[1] = new ColumnInfo(BaseMessages.getString(PKG, "NullIfDialog.ColumnInfo.ValueToNull"), ColumnInfo.COLUMN_TYPE_TEXT, false);
wFields = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, fieldsRows, lsMod, 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(100, -50);
wFields.setLayoutData(fdFields);
//
// 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(), Integer.valueOf(i));
}
setComboBoxes();
} catch (KettleException e) {
logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
}
}
};
new Thread(runnable).start();
// Some buttons
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, wCancel, wGet }, margin, wFields);
// 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);
wGet.addListener(SWT.Selection, lsGet);
wOK.addListener(SWT.Selection, lsOK);
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();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.widget.TableView in project pentaho-kettle by pentaho.
the class MappingDialog method addMappingDefinitionTab.
private void addMappingDefinitionTab(List<MappingIODefinition> definitions, final String tabTitle, String listLabel, String addToolTip, String removeToolTip, String inputStepLabel, String outputStepLabel, String descriptionLabel, String sourceColumnLabel, String targetColumnLabel, String noItemsLabel, final boolean input) {
final CTabItem wTab = new CTabItem(wTabFolder, SWT.NONE);
wTab.setText(tabTitle);
Composite wInputComposite = new Composite(wTabFolder, SWT.NONE);
props.setLook(wInputComposite);
FormLayout tabLayout = new FormLayout();
tabLayout.marginWidth = 15;
tabLayout.marginHeight = 15;
wInputComposite.setLayout(tabLayout);
Label wAvailableInputs = new Label(wInputComposite, SWT.LEFT);
props.setLook(wAvailableInputs);
wAvailableInputs.setText(listLabel);
FormData fdwAvailableInputs = new FormData();
fdwAvailableInputs.left = new FormAttachment(0);
fdwAvailableInputs.top = new FormAttachment(0);
Label wRemoveButton = new Label(wInputComposite, SWT.NONE);
wRemoveButton.setImage(GUIResource.getInstance().getImage("ui/images/generic-delete.svg"));
wRemoveButton.setToolTipText(removeToolTip);
props.setLook(wRemoveButton);
FormData fdwAddInputButton = new FormData();
fdwAddInputButton.top = new FormAttachment(0);
fdwAddInputButton.right = new FormAttachment(30);
wRemoveButton.setLayoutData(fdwAddInputButton);
Label wAddButton = new Label(wInputComposite, SWT.NONE);
wAddButton.setImage(GUIResource.getInstance().getImage("ui/images/Add.svg"));
wAddButton.setToolTipText(addToolTip);
props.setLook(wAddButton);
FormData fdwAddButton = new FormData();
fdwAddButton.top = new FormAttachment(0);
fdwAddButton.right = new FormAttachment(wRemoveButton, -5);
wAddButton.setLayoutData(fdwAddButton);
org.eclipse.swt.widgets.List wInputList = new org.eclipse.swt.widgets.List(wInputComposite, SWT.BORDER);
FormData fdwInputList = new FormData();
fdwInputList.left = new FormAttachment(0);
fdwInputList.top = new FormAttachment(wAvailableInputs, 5);
fdwInputList.bottom = new FormAttachment(100);
fdwInputList.right = new FormAttachment(30);
wInputList.setLayoutData(fdwInputList);
for (int i = 0; i < definitions.size(); i++) {
String label = !Utils.isEmpty(definitions.get(i).getInputStepname()) ? definitions.get(i).getInputStepname() : tabTitle + (i > 0 ? String.valueOf(i + 1) : "");
wInputList.add(label);
}
final Label wlNoItems = new Label(wInputComposite, SWT.CENTER);
wlNoItems.setText(noItemsLabel);
props.setLook(wlNoItems);
FormData fdlNoItems = new FormData();
fdlNoItems.left = new FormAttachment(wInputList, 30);
fdlNoItems.right = new FormAttachment(100);
fdlNoItems.top = new FormAttachment(50);
wlNoItems.setLayoutData(fdlNoItems);
wlNoItems.setVisible(false);
Composite wFieldsComposite = new Composite(wInputComposite, SWT.NONE);
props.setLook(wFieldsComposite);
FormLayout fieldLayout = new FormLayout();
fieldLayout.marginWidth = 0;
fieldLayout.marginHeight = 0;
wFieldsComposite.setLayout(fieldLayout);
final Button wMainPath = new Button(wFieldsComposite, SWT.CHECK);
wMainPath.setText(BaseMessages.getString(PKG, "MappingDialog.input.MainDataPath"));
props.setLook(wMainPath);
FormData fdMainPath = new FormData();
fdMainPath.top = new FormAttachment(0);
fdMainPath.left = new FormAttachment(0);
wMainPath.setLayoutData(fdMainPath);
wMainPath.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
definitions.get(wInputList.getSelectionIndex()).setMainDataPath(!definitions.get(wInputList.getSelectionIndex()).isMainDataPath());
}
});
final Label wlInputStep = new Label(wFieldsComposite, SWT.RIGHT);
props.setLook(wlInputStep);
wlInputStep.setText(inputStepLabel);
FormData fdlInputStep = new FormData();
fdlInputStep.top = new FormAttachment(wMainPath, 10);
fdlInputStep.left = new FormAttachment(0);
wlInputStep.setLayoutData(fdlInputStep);
// What's the stepname to read from? (empty is OK too)
//
final Button wbInputStep = new Button(wFieldsComposite, SWT.PUSH);
props.setLook(wbInputStep);
wbInputStep.setText(BaseMessages.getString(PKG, "MappingDialog.button.SourceStepName"));
FormData fdbInputStep = new FormData();
fdbInputStep.top = new FormAttachment(wlInputStep, 5);
// First one in the
fdbInputStep.right = new FormAttachment(100);
// left top corner
wbInputStep.setLayoutData(fdbInputStep);
final Text wInputStep = new Text(wFieldsComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wInputStep);
wInputStep.addModifyListener(lsMod);
FormData fdInputStep = new FormData();
fdInputStep.top = new FormAttachment(wlInputStep, 5);
// To the right of
fdInputStep.left = new FormAttachment(0);
// the label
fdInputStep.right = new FormAttachment(wbInputStep, -5);
wInputStep.setLayoutData(fdInputStep);
wInputStep.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent event) {
definitions.get(wInputList.getSelectionIndex()).setInputStepname(wInputStep.getText());
String label = !Utils.isEmpty(wInputStep.getText()) ? wInputStep.getText() : tabTitle + (wInputList.getSelectionIndex() > 0 ? String.valueOf(wInputList.getSelectionIndex() + 1) : "");
wInputList.setItem(wInputList.getSelectionIndex(), label);
}
});
wbInputStep.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
String stepName = selectTransformationStepname(input, input);
if (stepName != null) {
wInputStep.setText(stepName);
definitions.get(wInputList.getSelectionIndex()).setInputStepname(stepName);
}
}
});
// What's the step name to read from? (empty is OK too)
//
final Label wlOutputStep = new Label(wFieldsComposite, SWT.RIGHT);
props.setLook(wlOutputStep);
wlOutputStep.setText(outputStepLabel);
FormData fdlOutputStep = new FormData();
fdlOutputStep.top = new FormAttachment(wInputStep, 10);
fdlOutputStep.left = new FormAttachment(0);
wlOutputStep.setLayoutData(fdlOutputStep);
final Button wbOutputStep = new Button(wFieldsComposite, SWT.PUSH);
props.setLook(wbOutputStep);
wbOutputStep.setText(BaseMessages.getString(PKG, "MappingDialog.button.SourceStepName"));
FormData fdbOutputStep = new FormData();
fdbOutputStep.top = new FormAttachment(wlOutputStep, 5);
fdbOutputStep.right = new FormAttachment(100);
wbOutputStep.setLayoutData(fdbOutputStep);
final Text wOutputStep = new Text(wFieldsComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wOutputStep);
wOutputStep.addModifyListener(lsMod);
FormData fdOutputStep = new FormData();
fdOutputStep.top = new FormAttachment(wlOutputStep, 5);
// To the right of
fdOutputStep.left = new FormAttachment(0);
// the label
fdOutputStep.right = new FormAttachment(wbOutputStep, -5);
wOutputStep.setLayoutData(fdOutputStep);
// Allow for a small description
//
Label wlDescription = new Label(wFieldsComposite, SWT.RIGHT);
props.setLook(wlDescription);
wlDescription.setText(descriptionLabel);
FormData fdlDescription = new FormData();
fdlDescription.top = new FormAttachment(wOutputStep, 5);
// First one in the left
fdlDescription.left = new FormAttachment(0);
wlDescription.setLayoutData(fdlDescription);
final Text wDescription = new Text(wFieldsComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wDescription);
wDescription.addModifyListener(lsMod);
FormData fdDescription = new FormData();
fdDescription.top = new FormAttachment(wlDescription, 5);
// To the right of
fdDescription.left = new FormAttachment(0);
// the label
fdDescription.right = new FormAttachment(100);
wDescription.setLayoutData(fdDescription);
wDescription.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent event) {
definitions.get(wInputList.getSelectionIndex()).setDescription(wDescription.getText());
}
});
final Button wbEnterMapping = new Button(wFieldsComposite, SWT.PUSH);
props.setLook(wbEnterMapping);
wbEnterMapping.setText(BaseMessages.getString(PKG, "MappingDialog.button.EnterMapping"));
FormData fdbEnterMapping = new FormData();
fdbEnterMapping.bottom = new FormAttachment(100);
fdbEnterMapping.right = new FormAttachment(100);
wbEnterMapping.setLayoutData(fdbEnterMapping);
wbEnterMapping.setEnabled(input);
ColumnInfo[] colinfo = new ColumnInfo[] { new ColumnInfo(sourceColumnLabel, ColumnInfo.COLUMN_TYPE_TEXT, false, false), new ColumnInfo(targetColumnLabel, ColumnInfo.COLUMN_TYPE_TEXT, false, false) };
final TableView wFieldMappings = new TableView(transMeta, wFieldsComposite, SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER, colinfo, 1, false, lsMod, props, false);
props.setLook(wFieldMappings);
FormData fdMappings = new FormData();
fdMappings.top = new FormAttachment(wDescription, 20);
fdMappings.bottom = new FormAttachment(wbEnterMapping, -5);
fdMappings.left = new FormAttachment(0);
fdMappings.right = new FormAttachment(100);
wFieldMappings.setLayoutData(fdMappings);
wFieldMappings.getTable().addListener(SWT.Resize, new ColumnsResizer(0, 50, 50));
wbEnterMapping.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
try {
RowMetaInterface sourceRowMeta = getFieldsFromStep(wInputStep.getText(), true, input);
RowMetaInterface targetRowMeta = getFieldsFromStep(wOutputStep.getText(), false, input);
String[] sourceFields = sourceRowMeta.getFieldNames();
String[] targetFields = targetRowMeta.getFieldNames();
// Refresh mappings
int nrLines = wFieldMappings.nrNonEmpty();
definitions.get(wInputList.getSelectionIndex()).getValueRenames().clear();
for (int i = 0; i < nrLines; i++) {
TableItem item = wFieldMappings.getNonEmpty(i);
definitions.get(wInputList.getSelectionIndex()).getValueRenames().add(new MappingValueRename(item.getText(1), item.getText(2)));
}
List<MappingValueRename> mappingValue = definitions.get(wInputList.getSelectionIndex()).getValueRenames();
List<SourceToTargetMapping> currentMappings = MappingUtil.getCurrentMappings(Arrays.asList(sourceFields), Arrays.asList(targetFields), mappingValue);
EnterMappingDialog dialog = new EnterMappingDialog(shell, sourceFields, targetFields, currentMappings);
List<SourceToTargetMapping> mappings = dialog.open();
if (mappings != null) {
// first clear the dialog...
wFieldMappings.clearAll(false);
//
mappingValue.clear();
// Now add the new values...
for (SourceToTargetMapping mapping : mappings) {
TableItem item = new TableItem(wFieldMappings.table, SWT.NONE);
item.setText(1, mapping.getSourceString(sourceFields));
item.setText(2, mapping.getTargetString(targetFields));
String source = input ? item.getText(1) : item.getText(2);
String target = input ? item.getText(2) : item.getText(1);
mappingValue.add(new MappingValueRename(source, target));
}
wFieldMappings.removeEmptyRows();
wFieldMappings.setRowNums();
wFieldMappings.optWidth(true);
}
} catch (KettleException e) {
Listener ok = new Listener() {
@Override
public void handleEvent(final Event event) {
/* do nothing for now */
}
};
Map<String, Listener> listenerMap = new LinkedHashMap<>();
listenerMap.put(BaseMessages.getString("System.Button.OK"), ok);
new WarningDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), e.getMessage(), listenerMap);
// new ErrorDialog( shell, BaseMessages.getString( PKG, "System.Dialog.Error.Title" ), BaseMessages.getString(
// PKG, "MappingDialog.Exception.ErrorGettingMappingSourceAndTargetFields", e.toString() ), e );
}
}
});
wOutputStep.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent event) {
definitions.get(wInputList.getSelectionIndex()).setOutputStepname(wOutputStep.getText());
try {
enableMappingButton(wbEnterMapping, input, wInputStep.getText(), wOutputStep.getText());
} catch (KettleException e) {
// Show the missing/wrong step name error
//
Listener ok = new Listener() {
@Override
public void handleEvent(final Event event) {
/* do nothing for now */
}
};
Map<String, Listener> listenerMap = new LinkedHashMap<>();
listenerMap.put(BaseMessages.getString("System.Button.OK"), ok);
new WarningDialog(shell, "Error", e.getMessage(), listenerMap).open();
//
// new ErrorDialog( shell, "Error", "Unexpected error", e );
}
}
});
wbOutputStep.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
String stepName = selectTransformationStepname(!input, input);
if (stepName != null) {
wOutputStep.setText(stepName);
definitions.get(wInputList.getSelectionIndex()).setOutputStepname(stepName);
try {
enableMappingButton(wbEnterMapping, input, wInputStep.getText(), wOutputStep.getText());
} catch (KettleException e) {
// Show the missing/wrong stepname error
new ErrorDialog(shell, "Error", "Unexpected error", e);
}
}
}
});
final Button wRenameOutput;
if (input) {
// Add a checkbox to indicate that all output mappings need to rename
// the values back...
//
wRenameOutput = new Button(wFieldsComposite, SWT.CHECK);
wRenameOutput.setText(BaseMessages.getString(PKG, "MappingDialog.input.RenamingOnOutput"));
props.setLook(wRenameOutput);
FormData fdRenameOutput = new FormData();
fdRenameOutput.top = new FormAttachment(wFieldMappings, 5);
fdRenameOutput.left = new FormAttachment(0);
wRenameOutput.setLayoutData(fdRenameOutput);
wRenameOutput.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
definitions.get(wInputList.getSelectionIndex()).setRenamingOnOutput(!definitions.get(wInputList.getSelectionIndex()).isRenamingOnOutput());
}
});
} else {
wRenameOutput = null;
}
FormData fdInputComposite = new FormData();
fdInputComposite.left = new FormAttachment(0);
fdInputComposite.top = new FormAttachment(0);
fdInputComposite.right = new FormAttachment(100);
fdInputComposite.bottom = new FormAttachment(100);
wInputComposite.setLayoutData(fdInputComposite);
FormData fdFieldsComposite = new FormData();
fdFieldsComposite.left = new FormAttachment(wInputList, 30);
fdFieldsComposite.right = new FormAttachment(100);
fdFieldsComposite.bottom = new FormAttachment(100);
fdFieldsComposite.top = new FormAttachment(0);
wFieldsComposite.setLayoutData(fdFieldsComposite);
wInputComposite.layout();
wTab.setControl(wInputComposite);
wMainPath.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
setTabFlags(wMainPath, wlInputStep, wInputStep, wbInputStep, wlOutputStep, wOutputStep, wbOutputStep, wlDescription, wDescription);
}
});
wInputList.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent selectionEvent) {
updateFields(definitions.get(wInputList.getSelectionIndex()), input, wMainPath, wlInputStep, wInputStep, wbInputStep, wlOutputStep, wOutputStep, wbOutputStep, wlDescription, wDescription, wFieldMappings, wRenameOutput);
}
});
wAddButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent mouseEvent) {
MappingIODefinition definition = new MappingIODefinition();
definition.setMainDataPath(true);
definitions.add(definition);
wInputList.add(tabTitle + (definitions.size() > 1 ? String.valueOf(definitions.size()) : ""));
wInputList.select(definitions.size() - 1);
updateFields(definitions.get(wInputList.getSelectionIndex()), input, wMainPath, wlInputStep, wInputStep, wbInputStep, wlOutputStep, wOutputStep, wbOutputStep, wlDescription, wDescription, wFieldMappings, wRenameOutput);
wlNoItems.setVisible(false);
wFieldsComposite.setVisible(true);
wRemoveButton.setEnabled(true);
}
});
wRemoveButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent mouseEvent) {
MessageBox box = new MessageBox(shell, SWT.YES | SWT.NO);
box.setText(BaseMessages.getString(PKG, "MappingDialog.CloseDefinitionTabAreYouSure.Title"));
box.setMessage(BaseMessages.getString(PKG, "MappingDialog.CloseDefinitionTabAreYouSure.Message"));
int answer = box.open();
if (answer != SWT.YES) {
return;
}
int index = wInputList.getSelectionIndex();
definitions.remove(index);
wInputList.removeAll();
for (int i = 0; i < definitions.size(); i++) {
String label = !Utils.isEmpty(definitions.get(i).getInputStepname()) ? definitions.get(i).getInputStepname() : tabTitle + (i > 0 ? String.valueOf(i + 1) : "");
wInputList.add(label);
}
if (index > 0) {
wInputList.select(index - 1);
} else if (definitions.size() > 0) {
wInputList.select(index);
} else {
index = -1;
}
if (index != -1) {
updateFields(definitions.get(wInputList.getSelectionIndex()), input, wMainPath, wlInputStep, wInputStep, wbInputStep, wlOutputStep, wOutputStep, wbOutputStep, wlDescription, wDescription, wFieldMappings, wRenameOutput);
}
if (definitions.size() == 0) {
wlNoItems.setVisible(true);
wFieldsComposite.setVisible(false);
wRemoveButton.setEnabled(false);
}
}
});
if (definitions.size() > 0) {
wInputList.select(0);
updateFields(definitions.get(0), input, wMainPath, wlInputStep, wInputStep, wbInputStep, wlOutputStep, wOutputStep, wbOutputStep, wlDescription, wDescription, wFieldMappings, wRenameOutput);
} else {
wlNoItems.setVisible(true);
wFieldsComposite.setVisible(false);
wRemoveButton.setEnabled(false);
}
setTabFlags(wMainPath, wlInputStep, wInputStep, wbInputStep, wlOutputStep, wOutputStep, wbOutputStep, wlDescription, wDescription);
wTabFolder.setSelection(wTab);
}
use of org.pentaho.di.ui.core.widget.TableView in project pentaho-kettle by pentaho.
the class IngresVectorwiseLoaderDialog method addFieldSelection.
private Control addFieldSelection(Control lastControl) {
// The fields table
Label wlFields = new Label(shell, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.InsertFields.Label"));
props.setLook(wlFields);
FormData fdlUpIns = new FormData();
fdlUpIns.left = new FormAttachment(0, 0);
fdlUpIns.top = new FormAttachment(lastControl, 2 * margin);
wlFields.setLayoutData(fdlUpIns);
int tableCols = 2;
int UpInsRows = (input.getFieldStream() != null ? input.getFieldStream().length : 1);
ColumnInfo[] ciFields = new ColumnInfo[tableCols];
ciFields[0] = new ColumnInfo(BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.ColumnInfo.TableField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciFields[1] = new ColumnInfo(BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.ColumnInfo.StreamField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
tableFieldColumns.add(ciFields[0]);
wFields = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciFields, UpInsRows, lsMod, props);
Button wGetFields = new Button(shell, SWT.PUSH);
wGetFields.setText(BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.GetFields.Button"));
FormData fdGetFields = new FormData();
fdGetFields.top = new FormAttachment(wlFields, margin);
fdGetFields.right = new FormAttachment(100, 0);
wGetFields.setLayoutData(fdGetFields);
Button wDoMapping = new Button(shell, SWT.PUSH);
wDoMapping.setText(BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.DoMapping.Button"));
FormData fdDoMapping = new FormData();
fdDoMapping.top = new FormAttachment(wGetFields, margin);
fdDoMapping.right = new FormAttachment(100, 0);
wDoMapping.setLayoutData(fdDoMapping);
wGetFields.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
get();
}
});
wDoMapping.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event arg0) {
generateMappings();
}
});
FormData fdFields = new FormData();
fdFields.left = new FormAttachment(0, 0);
fdFields.top = new FormAttachment(wlFields, margin);
fdFields.right = new FormAttachment(wDoMapping, -margin);
fdFields.bottom = new FormAttachment(wOK, -2 * margin);
wFields.setLayoutData(fdFields);
return wFields;
}
Aggregations