use of org.pentaho.di.ui.core.dialog.SimpleMessageDialog in project pentaho-kettle by pentaho.
the class CommonStepDialog method openDialog.
protected void openDialog(final String title, final String message, final int dialogType) {
final Dialog dialog = new SimpleMessageDialog(shell, title, message, dialogType);
dialog.open();
}
use of org.pentaho.di.ui.core.dialog.SimpleMessageDialog in project pentaho-kettle by pentaho.
the class Spoon method loadLastUsedFile.
private void loadLastUsedFile(LastUsedFile lastUsedFile, String repositoryName, boolean trackIt, boolean isStartup) throws KettleException {
boolean useRepository = repositoryName != null;
//
if (lastUsedFile.isSourceRepository()) {
if (!Utils.isEmpty(lastUsedFile.getRepositoryName())) {
if (useRepository && !lastUsedFile.getRepositoryName().equalsIgnoreCase(repositoryName)) {
// We just asked...
useRepository = false;
}
}
}
if (useRepository && lastUsedFile.isSourceRepository()) {
if (rep != null) {
// load from this repository...
if (rep.getName().equalsIgnoreCase(lastUsedFile.getRepositoryName())) {
RepositoryDirectoryInterface rdi = rep.findDirectory(lastUsedFile.getDirectory());
if (rdi != null) {
// does the file exist in the repo?
final RepositoryObjectType fileType = lastUsedFile.isJob() ? RepositoryObjectType.JOB : RepositoryObjectType.TRANSFORMATION;
if (!rep.exists(lastUsedFile.getFilename(), rdi, fileType)) {
// opening this file
if (isStartup) {
if (log.isDetailed()) {
log.logDetailed(BaseMessages.getString(PKG, "Spoon.log.openingMissingFile"));
}
} else {
final Dialog dlg = new SimpleMessageDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Message", lastUsedFile.getLongFileType().toLowerCase()), MessageDialog.ERROR, BaseMessages.getString(PKG, "System.Button.Close"), MISSING_RECENT_DLG_WIDTH, SimpleMessageDialog.BUTTON_WIDTH);
dlg.open();
}
} else {
// Are we loading a transformation or a job?
if (lastUsedFile.isTransformation()) {
if (log.isDetailed()) {
// "Auto loading transformation ["+lastfiles[0]+"] from repository directory ["+lastdirs[0]+"]"
log.logDetailed(BaseMessages.getString(PKG, "Spoon.Log.AutoLoadingTransformation", lastUsedFile.getFilename(), lastUsedFile.getDirectory()));
}
TransLoadProgressDialog tlpd = new TransLoadProgressDialog(shell, rep, lastUsedFile.getFilename(), rdi, null);
TransMeta transMeta = tlpd.open();
if (transMeta != null) {
if (trackIt) {
props.addLastFile(LastUsedFile.FILE_TYPE_TRANSFORMATION, lastUsedFile.getFilename(), rdi.getPath(), true, rep.getName(), getUsername(), null);
}
// transMeta.setFilename(lastUsedFile.getFilename());
transMeta.clearChanged();
addTransGraph(transMeta);
refreshTree();
}
} else if (lastUsedFile.isJob()) {
JobLoadProgressDialog progressDialog = new JobLoadProgressDialog(shell, rep, lastUsedFile.getFilename(), rdi, null);
JobMeta jobMeta = progressDialog.open();
if (jobMeta != null) {
if (trackIt) {
props.addLastFile(LastUsedFile.FILE_TYPE_JOB, lastUsedFile.getFilename(), rdi.getPath(), true, rep.getName(), getUsername(), null);
}
jobMeta.clearChanged();
addJobGraph(jobMeta);
}
}
refreshTree();
}
}
}
}
}
// open files stored locally, not in the repository
if (!lastUsedFile.isSourceRepository() && !Utils.isEmpty(lastUsedFile.getFilename())) {
if (lastUsedFile.isTransformation()) {
openFile(lastUsedFile.getFilename(), rep != null);
}
if (lastUsedFile.isJob()) {
openFile(lastUsedFile.getFilename(), false);
}
refreshTree();
}
}
use of org.pentaho.di.ui.core.dialog.SimpleMessageDialog in project pentaho-kettle by pentaho.
the class Spoon method openFile.
public void openFile(String filename, boolean importfile) {
// Open the XML and see what's in there.
// We expect a single <transformation> or <job> root at this time...
// does the file exist? If not, show an error dialog
boolean fileExists = false;
try {
final FileObject file = KettleVFS.getFileObject(filename);
fileExists = file.exists();
} catch (final KettleFileException | FileSystemException e) {
// nothing to do, null fileObject will be handled below
}
if (StringUtils.isBlank(filename) || !fileExists) {
final Dialog dlg = new SimpleMessageDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Message", getFileType(filename).toLowerCase()), MessageDialog.ERROR, BaseMessages.getString(PKG, "System.Button.Close"), MISSING_RECENT_DLG_WIDTH, SimpleMessageDialog.BUTTON_WIDTH);
dlg.open();
return;
}
boolean loaded = false;
FileListener listener = null;
Node root = null;
// match by extension first
int idx = filename.lastIndexOf('.');
if (idx != -1) {
for (FileListener li : fileListeners) {
if (li.accepts(filename)) {
listener = li;
break;
}
}
}
// types.
try {
Document document = XMLHandler.loadXMLFile(filename);
root = document.getDocumentElement();
} catch (KettleXMLException e) {
if (log.isDetailed()) {
log.logDetailed(BaseMessages.getString(PKG, "Spoon.File.Xml.Parse.Error"));
}
}
// as XML
if (listener == null && root != null) {
for (FileListener li : fileListeners) {
if (li.acceptsXml(root.getNodeName())) {
listener = li;
break;
}
}
}
//
if (!Utils.isEmpty(filename)) {
if (listener != null) {
try {
loaded = listener.open(root, filename, importfile);
} catch (KettleMissingPluginsException e) {
log.logError(e.getMessage(), e);
}
}
if (!loaded) {
// Give error back
hideSplash();
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "Spoon.UnknownFileType.Message", filename));
mb.setText(BaseMessages.getString(PKG, "Spoon.UnknownFileType.Title"));
mb.open();
} else {
// set variables in the newly loaded
applyVariables();
// transformation(s) and job(s).
}
}
}
use of org.pentaho.di.ui.core.dialog.SimpleMessageDialog in project pentaho-kettle by pentaho.
the class JobEntryTransDialog method ok.
protected void ok() {
if (Utils.isEmpty(wName.getText())) {
final Dialog dialog = new SimpleMessageDialog(shell, BaseMessages.getString(PKG, "System.StepJobEntryNameMissing.Title"), BaseMessages.getString(PKG, "System.JobEntryNameMissing.Msg"), MessageDialog.ERROR);
dialog.open();
return;
}
jobEntry.setName(wName.getText());
try {
getInfo(jobEntry);
} catch (KettleException e) {
// suppress exceptions at this time - we will let the runtime report on any errors
}
jobEntry.setChanged();
dispose();
}
Aggregations