use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.
the class StringOperationsDialog 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, "StringOperationsDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "StringOperationsDialog.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);
wlKey = new Label(shell, SWT.NONE);
wlKey.setText(BaseMessages.getString(PKG, "StringOperationsDialog.Fields.Label"));
props.setLook(wlKey);
fdlKey = new FormData();
fdlKey.left = new FormAttachment(0, 0);
fdlKey.top = new FormAttachment(wStepname, 2 * margin);
wlKey.setLayoutData(fdlKey);
int nrFieldCols = 11;
int nrFieldRows = (input.getFieldInStream() != null ? input.getFieldInStream().length : 1);
ciKey = new ColumnInfo[nrFieldCols];
ciKey[0] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.InStreamField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciKey[1] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.OutStreamField"), ColumnInfo.COLUMN_TYPE_TEXT, false);
ciKey[2] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.Trim"), ColumnInfo.COLUMN_TYPE_CCOMBO, StringOperationsMeta.trimTypeDesc, true);
ciKey[3] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.LowerUpper"), ColumnInfo.COLUMN_TYPE_CCOMBO, StringOperationsMeta.lowerUpperDesc, true);
ciKey[4] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.Padding"), ColumnInfo.COLUMN_TYPE_CCOMBO, StringOperationsMeta.paddingDesc, true);
ciKey[5] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.CharPad"), ColumnInfo.COLUMN_TYPE_TEXT, false);
ciKey[6] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.LenPad"), ColumnInfo.COLUMN_TYPE_TEXT, false);
ciKey[7] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.InitCap"), ColumnInfo.COLUMN_TYPE_CCOMBO, StringOperationsMeta.initCapDesc);
ciKey[8] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.MaskXML"), ColumnInfo.COLUMN_TYPE_CCOMBO, StringOperationsMeta.maskXMLDesc);
ciKey[9] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.Digits"), ColumnInfo.COLUMN_TYPE_CCOMBO, StringOperationsMeta.digitsDesc);
ciKey[10] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.RemoveSpecialCharacters"), ColumnInfo.COLUMN_TYPE_CCOMBO, StringOperationsMeta.removeSpecialCharactersDesc);
ciKey[1].setToolTip(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.OutStreamField.Tooltip"));
ciKey[1].setUsingVariables(true);
ciKey[4].setUsingVariables(true);
ciKey[5].setUsingVariables(true);
ciKey[6].setUsingVariables(true);
ciKey[7].setUsingVariables(true);
wFields = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciKey, nrFieldRows, lsMod, props);
fdKey = new FormData();
fdKey.left = new FormAttachment(0, 0);
fdKey.top = new FormAttachment(wlKey, margin);
fdKey.right = new FormAttachment(100, -margin);
fdKey.bottom = new FormAttachment(100, -30);
wFields.setLayoutData(fdKey);
// 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"));
wGet = new Button(shell, SWT.PUSH);
wGet.setText(BaseMessages.getString(PKG, "StringOperationsDialog.GetFields.Button"));
fdGet = new FormData();
fdGet.right = new FormAttachment(100, 0);
fdGet.top = new FormAttachment(wStepname, 3 * middle);
wGet.setLayoutData(fdGet);
setButtonPositions(new Button[] { wOK, wGet, 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);
// 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();
//
// 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);
if (row != null) {
// Remember these fields...
for (int i = 0; i < row.size(); i++) {
inputFields.put(row.getValueMeta(i).getName(), new Integer(i));
}
setComboBoxes();
}
// Dislay in red missing field names
Display.getDefault().asyncExec(new Runnable() {
public void run() {
if (!wFields.isDisposed()) {
for (int i = 0; i < wFields.table.getItemCount(); i++) {
TableItem it = wFields.table.getItem(i);
if (!Utils.isEmpty(it.getText(1))) {
if (!inputFields.containsKey(it.getText(1))) {
it.setBackground(GUIResource.getInstance().getColorRed());
}
}
}
}
}
});
} catch (KettleException e) {
logError("Error getting fields from incoming stream!", e);
}
}
}
};
new Thread(runnable).start();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.
the class SecretKeyGeneratorDialog method preview.
// Preview the data
private void preview() {
try {
// Create the SecretKeyGeneratorMeta input step
SecretKeyGeneratorMeta oneMeta = new SecretKeyGeneratorMeta();
getInfo(oneMeta);
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "SecretKeyGeneratorDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "SecretKeyGeneratorDialog.NumberRows.DialogMessage"));
int previewSize = numberDialog.open();
if (previewSize > 0) {
TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
progressDialog.open();
if (!progressDialog.isCancelled()) {
Trans trans = progressDialog.getTrans();
String loggingText = progressDialog.getLoggingText();
if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
etd.setReadOnly();
etd.open();
}
PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), progressDialog.getPreviewRowsMeta(wStepname.getText()), progressDialog.getPreviewRows(wStepname.getText()), loggingText);
prd.open();
}
}
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "SecretKeyGeneratorDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "SecretKeyGeneratorDialog.ErrorPreviewingData.DialogMessage"), e);
}
}
use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.
the class SymmetricCryptoTransDialog method setSecretKeyFieldname.
private void setSecretKeyFieldname() {
try {
String field = wSecretKeyField.getText();
wSecretKeyField.removeAll();
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null) {
wSecretKeyField.setItems(r.getFieldNames());
}
if (field != null) {
wSecretKeyField.setText(field);
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "SymmetricCryptoTransDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "SymmetricCryptoTransDialogMod.FailedToGetFields.DialogMessage"), ke);
}
}
use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.
the class SymmetricCryptoTransDialog method setFieldname.
private void setFieldname() {
try {
String field = wMessage.getText();
wMessage.removeAll();
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
wMessage.setItems(r.getFieldNames());
if (field != null) {
wMessage.setText(field);
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "SymmetricCryptoTransDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "SymmetricCryptoTransDialogMod.FailedToGetFields.DialogMessage"), ke);
}
}
use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.
the class SynchronizeAfterMergeDialog method get.
private void get() {
try {
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null) {
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, "SynchronizeAfterMergeDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "SynchronizeAfterMergeDialog.FailedToGetFields.DialogMessage"), ke);
}
}
Aggregations