use of org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress in project dbeaver by dbeaver.
the class NavigatorHandlerSetActiveObject method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
IStructuredSelection structSelection = (IStructuredSelection) selection;
Object element = structSelection.getFirstElement();
if (element instanceof DBNDatabaseNode) {
final DBNDatabaseNode databaseNode = (DBNDatabaseNode) element;
final DBSObjectSelector activeContainer = DBUtils.getParentAdapter(DBSObjectSelector.class, databaseNode.getObject());
if (activeContainer != null) {
TasksJob.runTask("Select active object", new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
activeContainer.setDefaultObject(monitor, databaseNode.getObject());
} catch (DBException e) {
throw new InvocationTargetException(e);
}
}
});
}
}
}
return null;
}
use of org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress in project dbeaver by dbeaver.
the class TasksJob method run.
@Override
protected IStatus run(DBRProgressMonitor monitor) {
monitor.beginTask(getName(), tasks.size());
boolean ignoreErrors = false;
for (int i = 0; i < tasks.size(); ) {
DBRRunnableWithProgress task = tasks.get(i);
if (monitor.isCanceled()) {
break;
}
try {
task.run(monitor);
} catch (InvocationTargetException e) {
if (tasks.size() == 1) {
DBUserInterface.getInstance().showError(getName(), null, e.getTargetException());
} else if (!ignoreErrors) {
boolean keepRunning = true;
switch(ExecutionQueueErrorJob.showError(getName(), e.getTargetException(), true)) {
case STOP:
keepRunning = false;
break;
case RETRY:
// just make it again
continue;
case IGNORE:
// Just do nothing
break;
case IGNORE_ALL:
ignoreErrors = true;
break;
}
if (!keepRunning) {
break;
}
}
} catch (InterruptedException e) {
// Ignore
}
monitor.worked(1);
i++;
}
monitor.done();
return Status.OK_STATUS;
}
use of org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress in project dbeaver by dbeaver.
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 dbeaver.
the class ObjectPropertiesEditor method makeDatabaseEditorTabs.
private void makeDatabaseEditorTabs(final IDatabaseEditor part, final List<TabbedFolderInfo> tabList) {
final DBNDatabaseNode node = part.getEditorInput().getNavigatorNode();
if (node == null) {
return;
}
final DBSObject object = node.getObject();
if (!node.getMeta().isStandaloneNode()) {
// Collect tabs from navigator tree model
DBRRunnableWithProgress tabsCollector = new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) {
collectNavigatorTabs(monitor, part, node, tabList);
}
};
try {
if (node.needsInitialization()) {
DBeaverUI.runInProgressService(tabsCollector);
} else {
tabsCollector.run(new VoidProgressMonitor());
}
} catch (InvocationTargetException e) {
log.error(e.getTargetException());
} catch (InterruptedException e) {
// just go further
}
}
// Query for entity editors
List<EntityEditorDescriptor> editors = EntityEditorsRegistry.getInstance().getEntityEditors(object, this, null);
if (!CommonUtils.isEmpty(editors)) {
for (EntityEditorDescriptor descriptor : editors) {
if (descriptor.getType() == EntityEditorDescriptor.Type.folder) {
tabList.add(new TabbedFolderInfo(descriptor.getId(), descriptor.getName(), descriptor.getIcon(), descriptor.getDescription(), descriptor.isEmbeddable(), new TabbedFolderPageEditor(this, descriptor)));
}
}
}
}
use of org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress in project dbeaver by dbeaver.
the class AttributesSelectorPage method fillAttributes.
protected void fillAttributes(final DBSEntity entity) {
// Collect attributes
final List<DBSEntityAttribute> attributes = new ArrayList<>();
try {
DBeaverUI.runInProgressService(new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
for (DBSEntityAttribute attr : CommonUtils.safeCollection(entity.getAttributes(monitor))) {
if (!DBUtils.isHiddenObject(attr)) {
attributes.add(attr);
}
}
} catch (DBException e) {
throw new InvocationTargetException(e);
}
}
});
} catch (InvocationTargetException e) {
DBUserInterface.getInstance().showError(CoreMessages.dialog_struct_columns_select_error_load_columns_title, CoreMessages.dialog_struct_columns_select_error_load_columns_message, e.getTargetException());
} catch (InterruptedException e) {
// do nothing
}
for (DBSEntityAttribute attribute : attributes) {
TableItem columnItem = new TableItem(columnsTable, SWT.NONE);
AttributeInfo col = new AttributeInfo(attribute);
this.attributes.add(col);
DBNDatabaseNode attributeNode = DBeaverCore.getInstance().getNavigatorModel().findNode(attribute);
if (attributeNode != null) {
columnItem.setImage(0, DBeaverIcons.getImage(attributeNode.getNodeIcon()));
}
fillAttributeColumns(attribute, col, columnItem);
columnItem.setData(col);
if (isColumnSelected(attribute)) {
columnItem.setChecked(true);
handleItemSelect(columnItem, false);
}
}
UIUtils.packColumns(columnsTable);
updateToggleButton();
}
Aggregations