use of org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress in project dbeaver by serge-rider.
the class SSHTunnelImpl method closeTunnel.
@Override
public void closeTunnel(DBRProgressMonitor monitor) throws DBException, IOException {
if (session != null) {
RuntimeUtils.runTask(new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
session.disconnect();
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
}, "Close SSH session", 1000);
session = null;
}
}
use of org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress in project dbeaver by serge-rider.
the class CompareObjectsWizard method performFinish.
@Override
public boolean performFinish() {
// Save settings
getSettings().saveTo(getDialogSettings());
showError(null);
// Compare
final CompareObjectsExecutor executor = new CompareObjectsExecutor(settings);
try {
DBeaverUI.run(getContainer(), true, true, new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
CompareReport report = generateReport(monitor, executor);
renderReport(monitor, report);
} catch (DBException e) {
throw new InvocationTargetException(e);
}
}
});
UIUtils.showMessageBox(getShell(), "Objects compare", "Objects compare finished", SWT.ICON_INFORMATION);
} catch (InvocationTargetException e) {
if (executor.getInitializeError() != null) {
showError(executor.getInitializeError().getMessage());
} else {
log.error(e.getTargetException());
showError(e.getTargetException().getMessage());
}
return false;
} catch (InterruptedException e) {
showError("Compare interrupted");
return false;
} finally {
executor.dispose();
}
// Done
return true;
}
use of org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress in project dbeaver by serge-rider.
the class NavigatorHandlerObjectOpen method refreshDatabaseNode.
private static void refreshDatabaseNode(@NotNull DBNDatabaseNode selectedNode) throws InvocationTargetException, InterruptedException {
final DBNDatabaseNode nodeToRefresh = selectedNode;
DBeaverUI.runInProgressService(new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
nodeToRefresh.refreshNode(monitor, nodeToRefresh);
} catch (DBException e) {
log.error("Error refreshing database object", e);
}
}
});
}
use of org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress in project dbeaver by serge-rider.
the class NavigatorHandlerLinkEditor method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
if (activeEditor == null) {
return null;
}
NavigatorViewBase navigatorView = NavigatorUtils.getActiveNavigatorView(event);
if (navigatorView == null) {
return null;
}
if (navigatorView instanceof ProjectExplorerView) {
if (activeEditor instanceof SQLEditor) {
IFile file = EditorUtils.getFileFromInput(activeEditor.getEditorInput());
if (file != null) {
showResourceInNavigator(navigatorView, file);
}
} else if (activeEditor.getEditorInput() instanceof ProjectFileEditorInput) {
IFile editorFile = ((ProjectFileEditorInput) activeEditor.getEditorInput()).getFile();
showResourceInNavigator(navigatorView, editorFile);
}
} else if (activeEditor.getEditorInput() instanceof IDatabaseEditorInput) {
IDatabaseEditorInput editorInput = (IDatabaseEditorInput) activeEditor.getEditorInput();
DBNNode dbnNode = editorInput.getNavigatorNode();
if (dbnNode != null) {
navigatorView.showNode(dbnNode);
}
} else if (activeEditor instanceof IDataSourceContainerProvider) {
DBPDataSourceContainer dsContainer = ((IDataSourceContainerProvider) activeEditor).getDataSourceContainer();
@NotNull final DBSObject activeObject;
if (dsContainer != null) {
DBPDataSource dataSource = dsContainer.getDataSource();
if (dataSource != null) {
activeObject = DBUtils.getDefaultOrActiveObject(dataSource);
} else {
activeObject = dsContainer;
}
final NavigatorViewBase view = navigatorView;
DBeaverUI.runInUI(activePage.getWorkbenchWindow(), new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
DBSObject showObject = activeObject;
if (showObject instanceof DBPDataSource) {
showObject = ((DBPDataSource) showObject).getContainer();
}
DBNDatabaseNode objectNode = view.getModel().getNodeByObject(monitor, showObject, true);
if (objectNode != null) {
view.showNode(objectNode);
}
}
});
}
}
activePage.activate(navigatorView);
return null;
}
use of org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress in project dbeaver by serge-rider.
the class NavigatorHandlerObjectCreateCopy method pasteResource.
private void pasteResource(DBNResource resourceNode, DBNResource toFolder) {
final IResource resource = resourceNode.getResource();
final IResource targetResource = toFolder.getResource();
assert resource != null;
assert targetResource != null;
final IContainer targetFolder = targetResource instanceof IContainer ? (IContainer) targetResource : targetResource.getParent();
try {
DBeaverUI.runInProgressService(new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
copyResource(monitor, resource, targetFolder);
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
});
} catch (InvocationTargetException e) {
UIUtils.showErrorDialog(null, "Copy error", "Error copying resource", e.getTargetException());
} catch (InterruptedException e) {
// ignore
}
}
Aggregations