use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class AddSequenceDialog method getSequences.
private void getSequences() {
DatabaseMeta databaseMeta = transMeta.findDatabase(wConnection.getText());
if (databaseMeta != null) {
Database database = new Database(loggingObject, databaseMeta);
try {
database.connect();
String[] sequences = database.getSequences();
if (null != sequences && sequences.length > 0) {
sequences = Const.sortStrings(sequences);
EnterSelectionDialog dialog = new EnterSelectionDialog(shell, sequences, BaseMessages.getString(PKG, "AddSequenceDialog.SelectSequence.Title", wConnection.getText()), BaseMessages.getString(PKG, "AddSequenceDialog.SelectSequence.Message"));
String d = dialog.open();
if (d != null) {
wSeqname.setText(Const.NVL(d.toString(), ""));
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "AddSequenceDialog.NoSequence.Message"));
mb.setText(BaseMessages.getString(PKG, "AddSequenceDialog.NoSequence.Title"));
mb.open();
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "AddSequenceDialog.ErrorGettingSequences"), e);
} finally {
if (database != null) {
database.disconnect();
database = null;
}
}
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class AutoDocDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
props.setLook(shell);
setShellImage(shell, inputMeta);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
inputMeta.setChanged();
}
};
changed = inputMeta.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "AutoDoc.Step.Name"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Step name line
//
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "AutoDocDialog.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);
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);
Control lastControl = wStepname;
RowMetaInterface previousFields;
try {
previousFields = transMeta.getPrevStepFields(stepMeta);
} catch (KettleStepException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "AutoDocDialog.ErrorDialog.UnableToGetInputFields.Title"), BaseMessages.getString(PKG, "AutoDocDialog.ErrorDialog.UnableToGetInputFields.Message"), e);
previousFields = new RowMeta();
}
// The filename field ...
//
wFilenameField = new LabelComboVar(transMeta, shell, BaseMessages.getString(PKG, "AutoDocDialog.FilenameField.Label"), BaseMessages.getString(PKG, "AutoDocDialog.FilenameField.Tooltip"));
wFilenameField.setItems(previousFields.getFieldNames());
props.setLook(wFilenameField);
wFilenameField.addModifyListener(lsMod);
FormData fdFilenameField = new FormData();
fdFilenameField.top = new FormAttachment(lastControl, margin);
fdFilenameField.left = new FormAttachment(0, 0);
fdFilenameField.right = new FormAttachment(100, 0);
wFilenameField.setLayoutData(fdFilenameField);
lastControl = wFilenameField;
// The FileType field ...
//
wFileTypeField = new LabelComboVar(transMeta, shell, BaseMessages.getString(PKG, "AutoDocDialog.FileTypeField.Label"), BaseMessages.getString(PKG, "AutoDocDialog.FileTypeField.Tooltip"));
wFileTypeField.setItems(previousFields.getFieldNames());
props.setLook(wFileTypeField);
wFileTypeField.addModifyListener(lsMod);
FormData fdFileTypeField = new FormData();
fdFileTypeField.top = new FormAttachment(lastControl, margin);
fdFileTypeField.left = new FormAttachment(0, 0);
fdFileTypeField.right = new FormAttachment(100, 0);
wFileTypeField.setLayoutData(fdFileTypeField);
lastControl = wFileTypeField;
// The target filename ...
//
wTargetFilename = new LabelTextVar(transMeta, shell, BaseMessages.getString(PKG, "AutoDocDialog.TargetFilename.Label"), BaseMessages.getString(PKG, "AutoDocDialog.TargetFilename.Tooltip"));
props.setLook(wTargetFilename);
wTargetFilename.addModifyListener(lsMod);
FormData fdTargetFilename = new FormData();
fdTargetFilename.top = new FormAttachment(lastControl, margin);
fdTargetFilename.left = new FormAttachment(0, 0);
fdTargetFilename.right = new FormAttachment(100, 0);
wTargetFilename.setLayoutData(fdTargetFilename);
lastControl = wTargetFilename;
// The output type ...
//
wOutputType = new LabelComboVar(transMeta, shell, BaseMessages.getString(PKG, "AutoDocDialog.OutputType.Label"), BaseMessages.getString(PKG, "AutoDocDialog.OutputType.Tooltip"));
OutputType[] outputTypes = KettleReportBuilder.OutputType.values();
String[] items = new String[outputTypes.length];
for (int i = 0; i < outputTypes.length; i++) {
items[i] = outputTypes[i].name();
}
wOutputType.setItems(items);
props.setLook(wOutputType);
wOutputType.addModifyListener(lsMod);
wOutputType.getComboWidget().setEditable(false);
FormData fdOutputType = new FormData();
fdOutputType.top = new FormAttachment(lastControl, margin);
fdOutputType.left = new FormAttachment(0, 0);
fdOutputType.right = new FormAttachment(100, 0);
wOutputType.setLayoutData(fdOutputType);
wOutputType.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
setFlags();
}
});
lastControl = wOutputType;
// Include name check-box
//
Label wlInclName = new Label(shell, SWT.RIGHT);
wlInclName.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclName.Label"));
props.setLook(wlInclName);
FormData fdlInclName = new FormData();
fdlInclName.left = new FormAttachment(0, 0);
fdlInclName.right = new FormAttachment(middle, -margin);
fdlInclName.top = new FormAttachment(lastControl, margin);
wlInclName.setLayoutData(fdlInclName);
wInclName = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclName);
FormData fdInclName = new FormData();
fdInclName.left = new FormAttachment(middle, 0);
fdInclName.right = new FormAttachment(100, 0);
fdInclName.top = new FormAttachment(lastControl, margin);
wInclName.setLayoutData(fdInclName);
lastControl = wInclName;
// Include description check-box
//
Label wlInclDesc = new Label(shell, SWT.RIGHT);
wlInclDesc.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclDesc.Label"));
props.setLook(wlInclDesc);
FormData fdlInclDesc = new FormData();
fdlInclDesc.left = new FormAttachment(0, 0);
fdlInclDesc.right = new FormAttachment(middle, -margin);
fdlInclDesc.top = new FormAttachment(lastControl, margin);
wlInclDesc.setLayoutData(fdlInclDesc);
wInclDesc = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclDesc);
FormData fdInclDesc = new FormData();
fdInclDesc.left = new FormAttachment(middle, 0);
fdInclDesc.right = new FormAttachment(100, 0);
fdInclDesc.top = new FormAttachment(lastControl, margin);
wInclDesc.setLayoutData(fdInclDesc);
lastControl = wInclDesc;
// Include extended description check-box
//
Label wlInclExtDesc = new Label(shell, SWT.RIGHT);
wlInclExtDesc.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclExtDesc.Label"));
props.setLook(wlInclExtDesc);
FormData fdlInclExtDesc = new FormData();
fdlInclExtDesc.left = new FormAttachment(0, 0);
fdlInclExtDesc.right = new FormAttachment(middle, -margin);
fdlInclExtDesc.top = new FormAttachment(lastControl, margin);
wlInclExtDesc.setLayoutData(fdlInclExtDesc);
wInclExtDesc = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclExtDesc);
FormData fdInclExtDesc = new FormData();
fdInclExtDesc.left = new FormAttachment(middle, 0);
fdInclExtDesc.right = new FormAttachment(100, 0);
fdInclExtDesc.top = new FormAttachment(lastControl, margin);
wInclExtDesc.setLayoutData(fdInclExtDesc);
lastControl = wInclExtDesc;
// Include creation information (user/date) check-box
//
Label wlInclCreated = new Label(shell, SWT.RIGHT);
wlInclCreated.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclCreated.Label"));
props.setLook(wlInclCreated);
FormData fdlInclCreated = new FormData();
fdlInclCreated.left = new FormAttachment(0, 0);
fdlInclCreated.right = new FormAttachment(middle, -margin);
fdlInclCreated.top = new FormAttachment(lastControl, margin);
wlInclCreated.setLayoutData(fdlInclCreated);
wInclCreated = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclCreated);
FormData fdInclCreated = new FormData();
fdInclCreated.left = new FormAttachment(middle, 0);
fdInclCreated.right = new FormAttachment(100, 0);
fdInclCreated.top = new FormAttachment(lastControl, margin);
wInclCreated.setLayoutData(fdInclCreated);
lastControl = wInclCreated;
// Include modified information (user/date) check-box
//
Label wlInclModified = new Label(shell, SWT.RIGHT);
wlInclModified.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclModified.Label"));
props.setLook(wlInclModified);
FormData fdlInclModified = new FormData();
fdlInclModified.left = new FormAttachment(0, 0);
fdlInclModified.right = new FormAttachment(middle, -margin);
fdlInclModified.top = new FormAttachment(lastControl, margin);
wlInclModified.setLayoutData(fdlInclModified);
wInclModified = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclModified);
FormData fdInclModified = new FormData();
fdInclModified.left = new FormAttachment(middle, 0);
fdInclModified.right = new FormAttachment(100, 0);
fdInclModified.top = new FormAttachment(lastControl, margin);
wInclModified.setLayoutData(fdInclModified);
lastControl = wInclModified;
// Include image check-box
//
Label wlInclImage = new Label(shell, SWT.RIGHT);
wlInclImage.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclImage.Label"));
props.setLook(wlInclImage);
FormData fdlInclImage = new FormData();
fdlInclImage.left = new FormAttachment(0, 0);
fdlInclImage.right = new FormAttachment(middle, -margin);
fdlInclImage.top = new FormAttachment(lastControl, margin);
wlInclImage.setLayoutData(fdlInclImage);
wInclImage = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclImage);
FormData fdInclImage = new FormData();
fdInclImage.left = new FormAttachment(middle, 0);
fdInclImage.right = new FormAttachment(100, 0);
fdInclImage.top = new FormAttachment(lastControl, margin);
wInclImage.setLayoutData(fdInclImage);
lastControl = wInclImage;
// Include logging check-box
//
Label wlInclLogging = new Label(shell, SWT.RIGHT);
wlInclLogging.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclLogging.Label"));
props.setLook(wlInclLogging);
FormData fdlInclLogging = new FormData();
fdlInclLogging.left = new FormAttachment(0, 0);
fdlInclLogging.right = new FormAttachment(middle, -margin);
fdlInclLogging.top = new FormAttachment(lastControl, margin);
wlInclLogging.setLayoutData(fdlInclLogging);
wInclLogging = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclLogging);
FormData fdInclLogging = new FormData();
fdInclLogging.left = new FormAttachment(middle, 0);
fdInclLogging.right = new FormAttachment(100, 0);
fdInclLogging.top = new FormAttachment(lastControl, margin);
wInclLogging.setLayoutData(fdInclLogging);
lastControl = wInclLogging;
// Include last execution date check-box
//
Label wlInclLastExecResult = new Label(shell, SWT.RIGHT);
wlInclLastExecResult.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclLastExecResult.Label"));
props.setLook(wlInclLastExecResult);
FormData fdlInclLastExecResult = new FormData();
fdlInclLastExecResult.left = new FormAttachment(0, 0);
fdlInclLastExecResult.right = new FormAttachment(middle, -margin);
fdlInclLastExecResult.top = new FormAttachment(lastControl, margin);
wlInclLastExecResult.setLayoutData(fdlInclLastExecResult);
wInclLastExecResult = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclLastExecResult);
FormData fdInclLastExecResult = new FormData();
fdInclLastExecResult.left = new FormAttachment(middle, 0);
fdInclLastExecResult.right = new FormAttachment(100, 0);
fdInclLastExecResult.top = new FormAttachment(lastControl, margin);
wInclLastExecResult.setLayoutData(fdInclLastExecResult);
lastControl = wInclLastExecResult;
// Some buttons first, so that the dialog scales nicely...
//
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, lastControl);
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wOK.addListener(SWT.Selection, lsOK);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wFilenameField.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();
inputMeta.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class ConcatFieldsDialog method get.
private void get() {
try {
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null) {
TableItemInsertListener listener = new TableItemInsertListener() {
@Override
public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
if (v.isNumber()) {
if (v.getLength() > 0) {
int le = v.getLength();
int pr = v.getPrecision();
if (v.getPrecision() <= 0) {
pr = 0;
}
String mask = "";
for (int m = 0; m < le - pr; m++) {
mask += "0";
}
if (pr > 0) {
mask += ".";
}
for (int m = 0; m < pr; m++) {
mask += "0";
}
tableItem.setText(3, mask);
}
}
return true;
}
};
BaseStepDialog.getFieldsFromPrevious(r, wFields, 1, new int[] { 1 }, new int[] { 2 }, 4, 5, listener);
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Title"), BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"), ke);
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class ChangeFileEncodingDialog method get.
private void get() {
if (!gotPreviousFields) {
try {
String filefield = wFileName.getText();
String targetfilefield = wTargetFileName.getText();
wFileName.removeAll();
wTargetFileName.removeAll();
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null) {
wFileName.setItems(r.getFieldNames());
wTargetFileName.setItems(r.getFieldNames());
}
if (filefield != null) {
wFileName.setText(filefield);
}
if (targetfilefield != null) {
wTargetFileName.setText(targetfilefield);
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "ChangeFileEncodingDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "ChangeFileEncodingDialog.FailedToGetFields.DialogMessage"), ke);
}
gotPreviousFields = true;
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class AggregateRowsDialog method get.
private void get() {
try {
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null && r.size() > 0) {
BaseStepDialog.getFieldsFromPrevious(r, wFields, 1, new int[] { 1, 2 }, new int[] {}, -1, -1, null);
} else {
MessageBox mb;
mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "AggregateRowsDialog.CouldNotRetrieveFields.DialogMessage", Const.CR));
mb.setText(BaseMessages.getString(PKG, "AggregateRowsDialog.CouldNotRetrieveFields.DialogTitle"));
mb.open();
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "AggregateRowsDialog.GetFieldsFailed.DialogTitle"), BaseMessages.getString(PKG, "AggregateRowsDialog.GetFieldsFailed.DialogMessage"), ke);
}
}
Aggregations