use of org.pentaho.di.repository.KettleRepositoryLostException 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;
}
use of org.pentaho.di.repository.KettleRepositoryLostException in project pentaho-kettle by pentaho.
the class Spoon method openFile.
public void openFile(boolean importfile) {
try {
SpoonPerspective activePerspective = SpoonPerspectiveManager.getInstance().getActivePerspective();
//
if (!importfile) {
if (activePerspective instanceof SpoonPerspectiveOpenSaveInterface) {
((SpoonPerspectiveOpenSaveInterface) activePerspective).open();
return;
}
}
String activePerspectiveId = activePerspective.getId();
boolean etlPerspective = activePerspectiveId.equals(MainSpoonPerspective.ID);
if (rep == null || importfile || !etlPerspective) {
// Load from XML
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
LinkedHashSet<String> extensions = new LinkedHashSet<>();
LinkedHashSet<String> extensionNames = new LinkedHashSet<>();
StringBuilder allExtensions = new StringBuilder();
for (FileListener l : fileListeners) {
for (String ext : l.getSupportedExtensions()) {
extensions.add("*." + ext);
allExtensions.append("*.").append(ext).append(";");
}
Collections.addAll(extensionNames, l.getFileTypeDisplayNames(Locale.getDefault()));
}
extensions.add("*");
extensionNames.add(BaseMessages.getString(PKG, "Spoon.Dialog.OpenFile.AllFiles"));
String[] exts = new String[extensions.size() + 1];
exts[0] = allExtensions.toString();
System.arraycopy(extensions.toArray(new String[extensions.size()]), 0, exts, 1, extensions.size());
String[] extNames = new String[extensionNames.size() + 1];
extNames[0] = BaseMessages.getString(PKG, "Spoon.Dialog.OpenFile.AllTypes");
System.arraycopy(extensionNames.toArray(new String[extensionNames.size()]), 0, extNames, 1, extensionNames.size());
dialog.setFilterExtensions(exts);
setFilterPath(dialog);
String filename = dialog.open();
if (filename != null) {
if (importfile) {
if (activePerspective instanceof SpoonPerspectiveOpenSaveInterface) {
((SpoonPerspectiveOpenSaveInterface) activePerspective).importFile(filename);
return;
}
}
lastDirOpened = dialog.getFilterPath();
openFile(filename, importfile);
}
} else {
try {
FileDialogOperation fileDialogOperation = new FileDialogOperation(FileDialogOperation.OPEN, FileDialogOperation.ORIGIN_SPOON);
ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.SpoonOpenSaveRepository.id, fileDialogOperation);
if (fileDialogOperation.getRepositoryObject() != null) {
RepositoryObject repositoryObject = (RepositoryObject) fileDialogOperation.getRepositoryObject();
loadObjectFromRepository(repositoryObject.getObjectId(), repositoryObject.getObjectType(), null);
}
} catch (Exception e) {
// Ignore
}
}
} catch (KettleRepositoryLostException krle) {
new ErrorDialog(getShell(), BaseMessages.getString(PKG, "Spoon.Error"), krle.getPrefaceMessage(), krle);
this.closeRepository();
}
}
use of org.pentaho.di.repository.KettleRepositoryLostException in project pentaho-kettle by pentaho.
the class Spoon method saveFile.
public boolean saveFile() {
try {
EngineMetaInterface meta = getActiveMeta();
if (meta != null) {
if (AbstractMeta.class.isAssignableFrom(meta.getClass()) && ((AbstractMeta) meta).hasMissingPlugins()) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "Spoon.ErrorDialog.MissingPlugin.Error"));
mb.setText(BaseMessages.getString(PKG, "Spoon.ErrorDialog.MissingPlugin.Title"));
mb.open();
return false;
}
if (meta != null) {
return saveToFile(meta);
}
}
} catch (Exception e) {
KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
if (krle != null) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Title"), krle.getPrefaceMessage(), krle);
closeRepository();
} else {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Title"), BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Message"), e);
}
}
return false;
}
use of org.pentaho.di.repository.KettleRepositoryLostException in project pentaho-kettle by pentaho.
the class Spoon method saveFileAs.
public boolean saveFileAs() throws KettleException {
try {
EngineMetaInterface meta = getActiveMeta();
if (meta != null && AbstractMeta.class.isAssignableFrom(meta.getClass())) {
if (((AbstractMeta) meta).hasMissingPlugins()) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "Spoon.ErrorDialog.MissingPlugin.Error"));
mb.setText(BaseMessages.getString(PKG, "Spoon.ErrorDialog.MissingPlugin.Title"));
mb.open();
return false;
}
}
if (meta != null) {
if (meta.canSave()) {
return saveFileAs(meta);
}
}
} catch (Exception e) {
KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
if (krle != null) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Title"), krle.getPrefaceMessage(), krle);
closeRepository();
} else {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Title"), BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Message"), e);
}
}
return false;
}
use of org.pentaho.di.repository.KettleRepositoryLostException in project pentaho-kettle by pentaho.
the class TransDialog method open.
public TransMeta open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
shell.setImage(GUIResource.getInstance().getImageTransGraph());
lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
changed = true;
}
};
lsModSel = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
changed = true;
}
};
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "TransDialog.Shell.Title"));
middle = props.getMiddlePct();
margin = Const.MARGIN;
wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
wTabFolder.setSimple(false);
addTransTab();
addParamTab();
addLogTab();
addDateTab();
addDepTab();
addMiscTab();
addMonitoringTab();
// See if there are any other tabs to be added...
extraTabs = new ArrayList<TransDialogPluginInterface>();
java.util.List<PluginInterface> transDialogPlugins = PluginRegistry.getInstance().getPlugins(TransDialogPluginType.class);
for (PluginInterface transDialogPlugin : transDialogPlugins) {
try {
TransDialogPluginInterface extraTab = (TransDialogPluginInterface) PluginRegistry.getInstance().loadClass(transDialogPlugin);
extraTab.addTab(transMeta, parent, wTabFolder);
extraTabs.add(extraTab);
} catch (Exception e) {
KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
if (krle != null) {
throw krle;
}
new ErrorDialog(shell, "Error", "Error loading transformation dialog plugin with id " + transDialogPlugin.getIds()[0], e);
}
}
fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(0, 0);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(100, -50);
wTabFolder.setLayoutData(fdTabFolder);
// 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, "System.Button.SQL"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wSQL, wCancel }, Const.MARGIN, null);
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsGet = new Listener() {
public void handleEvent(Event e) {
get();
}
};
lsSQL = new Listener() {
public void handleEvent(Event e) {
sql();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wGet.addListener(SWT.Selection, lsGet);
wSQL.addListener(SWT.Selection, lsSQL);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wTransname.addSelectionListener(lsDef);
wTransdescription.addSelectionListener(lsDef);
wTransversion.addSelectionListener(lsDef);
wMaxdatetable.addSelectionListener(lsDef);
wMaxdatefield.addSelectionListener(lsDef);
wMaxdateoffset.addSelectionListener(lsDef);
wMaxdatediff.addSelectionListener(lsDef);
wSizeRowset.addSelectionListener(lsDef);
wUniqueConnections.addSelectionListener(lsDef);
wFeedbackSize.addSelectionListener(lsDef);
wStepPerfInterval.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
if (currentTab != null) {
setCurrentTab(currentTab);
} else {
wTabFolder.setSelection(0);
}
getData();
BaseStepDialog.setSize(shell);
changed = false;
sharedObjectsFileChanged = false;
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return transMeta;
}
Aggregations