use of org.pentaho.di.repository.KettleRepositoryLostException in project pentaho-kettle by pentaho.
the class Spoon method exploreRepository.
public void exploreRepository() {
if (rep != null) {
final RepositoryExplorerCallback cb = new RepositoryExplorerCallback() {
@Override
public boolean open(UIRepositoryContent element, String revision) throws Exception {
String objName = element.getName();
if (objName != null) {
RepositoryObjectType objectType = element.getRepositoryElementType();
RepositoryDirectory repDir = element.getRepositoryDirectory();
if (element.getObjectId() != null) {
// new way
loadObjectFromRepository(element.getObjectId(), objectType, revision);
} else {
// old way
loadObjectFromRepository(objName, objectType, repDir, revision);
}
}
// do not close explorer
return false;
}
@Override
public boolean error(String message) throws Exception {
closeRepository();
return true;
}
};
try {
final KettleWaitBox box = (KettleWaitBox) this.mainSpoonContainer.getDocumentRoot().createElement("iconwaitbox");
box.setIndeterminate(true);
box.setCanCancel(false);
box.setIcon("ui/images/kettle_logo_small.svg");
box.setTitle(BaseMessages.getString(RepositoryDialogInterface.class, "RepositoryExplorerDialog.Connection.Wait.Title"));
box.setMessage(BaseMessages.getString(RepositoryDialogInterface.class, "RepositoryExplorerDialog.Explorer.Wait.Message"));
box.setDialogParent(shell);
box.setRunnable(new WaitBoxRunnable(box) {
@Override
public void run() {
shell.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
RepositoryExplorer explorer;
try {
try {
explorer = new RepositoryExplorer(shell, rep, cb, Variables.getADefaultVariableSpace(), sharedObjectSyncUtil);
} catch (final KettleRepositoryLostException krle) {
handleRepositoryLost(krle);
closeRepository();
return;
} finally {
box.stop();
}
if (explorer.isInitialized()) {
explorer.show();
} else {
return;
}
explorer.dispose();
} catch (final Throwable e) {
shell.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Error"), e.getMessage(), e);
}
});
}
}
});
}
@Override
public void cancel() {
}
});
box.start();
} catch (Throwable e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Error"), e.getMessage(), e);
}
}
}
use of org.pentaho.di.repository.KettleRepositoryLostException in project pentaho-kettle by pentaho.
the class JobDialog method open.
public JobMeta open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN | SWT.APPLICATION_MODAL);
props.setLook(shell);
shell.setImage(GUIResource.getInstance().getImageJobGraph());
lsMod = new ModifyListener() {
public void modifyText(ModifyEvent 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, "JobDialog.JobProperties.ShellText"));
middle = props.getMiddlePct();
margin = Const.MARGIN;
wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
//
for (LogTableInterface logTable : logTables) {
// can be null
logTableUserInterfaces.add(getLogTableUserInterface(logTable, jobMeta, lsMod));
}
addJobTab();
addParamTab();
addSettingsTab();
addLogTab();
// See if there are any other tabs to be added...
extraTabs = new ArrayList<JobDialogPluginInterface>();
java.util.List<PluginInterface> jobDialogPlugins = PluginRegistry.getInstance().getPlugins(JobDialogPluginType.class);
for (PluginInterface jobDialogPlugin : jobDialogPlugins) {
try {
JobDialogPluginInterface extraTab = (JobDialogPluginInterface) PluginRegistry.getInstance().loadClass(jobDialogPlugin);
extraTab.addTab(jobMeta, parent, wTabFolder);
extraTabs.add(extraTab);
} catch (Exception e) {
KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
if (krle != null) {
throw krle;
}
new ErrorDialog(shell, "Error", "Error loading job dialog plugin with id " + jobDialogPlugin.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"));
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 }, margin, wSharedObjectsFile);
BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wSQL, wCancel }, Const.MARGIN, null);
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsSQL = new Listener() {
public void handleEvent(Event e) {
sql();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wSQL.addListener(SWT.Selection, lsSQL);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wJobname.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
wTabFolder.setSelection(0);
getData();
BaseStepDialog.setSize(shell);
changed = false;
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return jobMeta;
}
use of org.pentaho.di.repository.KettleRepositoryLostException in project pentaho-kettle by pentaho.
the class JobLoadProgressDialog method open.
public JobMeta 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.JobBeforeOpen.id, (objectId == null) ? jobname : objectId.toString());
if (objectId != null) {
jobInfo = rep.loadJob(objectId, versionLabel);
} else {
jobInfo = rep.loadJob(jobname, repdir, new ProgressMonitorAdapter(monitor), versionLabel);
}
// Call extension point(s) now that the file has been opened
ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.JobAfterOpen.id, jobInfo);
if (jobInfo.hasMissingPlugins()) {
MissingEntryDialog missingDialog = new MissingEntryDialog(shell, jobInfo.getMissingEntries());
if (missingDialog.open() == null) {
jobInfo = null;
}
}
} catch (KettleException e) {
throw new InvocationTargetException(e, "Error loading job");
}
}
};
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, "Error loading job", "An error occured loading the job!", e);
jobInfo = null;
} catch (InterruptedException e) {
new ErrorDialog(shell, "Error loading job", "An error occured loading the job!", e);
jobInfo = null;
}
return jobInfo;
}
use of org.pentaho.di.repository.KettleRepositoryLostException in project pentaho-kettle by pentaho.
the class Spoon method setShellText.
public void setShellText() {
if (shell.isDisposed()) {
return;
}
String filename = null;
String name = null;
String version = null;
ChangedFlagInterface changed = null;
boolean versioningEnabled = true;
AbstractMeta meta = getActiveJob() != null ? getActiveJob() : getActiveTransformation();
if (meta != null) {
changed = meta;
filename = meta.getFilename();
name = meta.getName();
version = meta.getObjectRevision() == null ? null : meta.getObjectRevision().getName();
try {
versioningEnabled = isVersionEnabled(rep, meta);
} catch (KettleRepositoryLostException krle) {
handleRepositoryLost(krle);
}
}
String text = "";
if (rep != null) {
text += APP_TITLE + " - [" + getRepositoryName() + "] ";
} else {
text += APP_TITLE + " - ";
}
if (Utils.isEmpty(name)) {
if (!Utils.isEmpty(filename)) {
text += filename;
} else {
String tab = getActiveTabText();
if (!Utils.isEmpty(tab)) {
text += tab;
} else {
// "[no name]"
text += BaseMessages.getString(PKG, "Spoon.Various.NoName");
}
}
} else {
text += name;
}
if (versioningEnabled && !Utils.isEmpty(version)) {
text += " v" + version;
}
if (changed != null && changed.hasChanged()) {
text += " " + BaseMessages.getString(PKG, "Spoon.Various.Changed");
}
shell.setText(text);
markTabsChanged(false);
}
use of org.pentaho.di.repository.KettleRepositoryLostException in project pentaho-kettle by pentaho.
the class Spoon method refreshDbConnectionsSubtree.
@VisibleForTesting
void refreshDbConnectionsSubtree(TreeItem tiRootName, AbstractMeta meta, GUIResource guiResource) {
TreeItem tiDbTitle = createTreeItem(tiRootName, STRING_CONNECTIONS, guiResource.getImageFolder());
DatabasesCollector collector = new DatabasesCollector(meta, rep);
try {
try {
collector.collectDatabases();
} catch (KettleException e) {
if (e.getCause() instanceof KettleRepositoryLostException) {
handleRepositoryLost((KettleRepositoryLostException) e.getCause());
collector = new DatabasesCollector(meta, null);
collector.collectDatabases();
} else {
throw e;
}
}
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.ErrorDialog.Title"), BaseMessages.getString(PKG, "Spoon.ErrorDialog.ErrorFetchingFromRepo.DbConnections"), e);
}
for (String dbName : collector.getDatabaseNames()) {
if (!filterMatch(dbName)) {
continue;
}
DatabaseMeta databaseMeta = collector.getMetaFor(dbName);
TreeItem tiDb = createTreeItem(tiDbTitle, databaseMeta.getDisplayName(), guiResource.getImageConnectionTree());
if (databaseMeta.isShared()) {
tiDb.setFont(guiResource.getFontBold());
}
}
}
Aggregations