use of org.pentaho.di.ui.trans.steps.missing.MissingTransDialog in project pentaho-kettle by pentaho.
the class TransFileListener method open.
public boolean open(Node transNode, String fname, boolean importfile) throws KettleMissingPluginsException {
final Spoon spoon = Spoon.getInstance();
final PropsUI props = PropsUI.getInstance();
try {
// Call extension point(s) before the file has been opened
ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.TransBeforeOpen.id, fname);
TransMeta transMeta = new TransMeta();
transMeta.loadXML(transNode, fname, spoon.getMetaStore(), spoon.getRepository(), true, new Variables(), new OverwritePrompter() {
public boolean overwritePrompt(String message, String rememberText, String rememberPropertyName) {
MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
Object[] res = spoon.messageDialogWithToggle(BaseMessages.getString(PKG, "System.Button.Yes"), null, message, Const.WARNING, new String[] { BaseMessages.getString(PKG, "System.Button.Yes"), BaseMessages.getString(PKG, "System.Button.No") }, 1, rememberText, !props.askAboutReplacingDatabaseConnections());
int idx = ((Integer) res[0]).intValue();
boolean toggleState = ((Boolean) res[1]).booleanValue();
props.setAskAboutReplacingDatabaseConnections(!toggleState);
// Yes means: overwrite
return ((idx & 0xFF) == 0);
}
});
if (transMeta.hasMissingPlugins()) {
StepMeta stepMeta = transMeta.getStep(0);
MissingTransDialog missingDialog = new MissingTransDialog(spoon.getShell(), transMeta.getMissingTrans(), stepMeta.getStepMetaInterface(), transMeta, stepMeta.getName());
if (missingDialog.open() == null) {
return true;
}
}
transMeta.setRepositoryDirectory(spoon.getDefaultSaveLocation(transMeta));
transMeta.setRepository(spoon.getRepository());
transMeta.setMetaStore(spoon.getMetaStore());
spoon.setTransMetaVariables(transMeta);
spoon.getProperties().addLastFile(LastUsedFile.FILE_TYPE_TRANSFORMATION, fname, null, false, null);
spoon.addMenuLast();
// if any exist.
if (importfile) {
if (spoon.getRepository() != null) {
transMeta = fixLinks(transMeta);
}
} else {
transMeta.clearChanged();
}
transMeta.setFilename(fname);
spoon.addTransGraph(transMeta);
spoon.sharedObjectsFileMap.put(transMeta.getSharedObjects().getFilename(), transMeta.getSharedObjects());
// Call extension point(s) now that the file has been opened
ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.TransAfterOpen.id, transMeta);
SpoonPerspectiveManager.getInstance().activatePerspective(MainSpoonPerspective.class);
spoon.refreshTree();
return true;
} catch (KettleMissingPluginsException e) {
throw e;
} catch (KettleException e) {
new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorOpening.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorOpening.Message") + fname, e);
}
return false;
}
use of org.pentaho.di.ui.trans.steps.missing.MissingTransDialog in project pentaho-kettle by pentaho.
the class TransLoadProgressDialog method open.
public TransMeta open() {
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
Spoon spoon = Spoon.getInstance();
try {
// Call extension point(s) before the file has been opened
ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.TransBeforeOpen.id, (objectId == null) ? transname : objectId.toString());
if (objectId != null) {
transInfo = rep.loadTransformation(objectId, versionLabel);
} else {
transInfo = rep.loadTransformation(transname, repdir, new ProgressMonitorAdapter(monitor), true, versionLabel);
}
// Call extension point(s) now that the file has been opened
ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.TransAfterOpen.id, transInfo);
if (transInfo.hasMissingPlugins()) {
StepMeta stepMeta = transInfo.getStep(0);
Display.getDefault().syncExec(() -> {
MissingTransDialog missingTransDialog = new MissingTransDialog(shell, transInfo.getMissingTrans(), stepMeta.getStepMetaInterface(), transInfo, stepMeta.getName());
if (missingTransDialog.open() == null) {
transInfo = null;
}
});
}
} catch (KettleException e) {
throw new InvocationTargetException(e, BaseMessages.getString(PKG, "TransLoadProgressDialog.Exception.ErrorLoadingTransformation"));
}
}
};
try {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
pmd.run(true, false, op);
} catch (InvocationTargetException e) {
KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
if (krle != null) {
throw krle;
}
new ErrorDialog(shell, BaseMessages.getString(PKG, "TransLoadProgressDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "TransLoadProgressDialog.ErrorLoadingTransformation.DialogMessage"), e);
transInfo = null;
} catch (InterruptedException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "TransLoadProgressDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "TransLoadProgressDialog.ErrorLoadingTransformation.DialogMessage"), e);
transInfo = null;
}
return transInfo;
}
Aggregations