use of org.jkiss.dbeaver.DBException 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.DBException in project dbeaver by serge-rider.
the class NavigatorActionSetActiveObject method run.
@Override
public void run(IAction action) {
if (selection instanceof IStructuredSelection) {
DBNNode selectedNode = NavigatorUtils.getSelectedNode(selection);
if (selectedNode instanceof DBNDatabaseNode) {
final DBNDatabaseNode databaseNode = (DBNDatabaseNode) selectedNode;
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);
}
}
});
}
}
}
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class NavigatorHandlerAddBookmark method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final Shell activeShell = HandlerUtil.getActiveShell(event);
final ISelection selection = HandlerUtil.getCurrentSelection(event);
if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
final DBNNode node = NavigatorUtils.getSelectedNode(selection);
if (node instanceof DBNDatabaseNode) {
try {
AddBookmarkDialog dialog = new AddBookmarkDialog(activeShell, (DBNDatabaseNode) node);
final String title = dialog.chooseName();
if (title != null) {
BookmarksHandlerImpl.createBookmark((DBNDatabaseNode) node, title, dialog.getTargetFolder());
}
} catch (DBException e) {
UIUtils.showErrorDialog(activeShell, CoreMessages.actions_navigator_bookmark_error_title, CoreMessages.actions_navigator_bookmark_error_message, e);
}
}
}
return null;
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class NavigatorHandlerCreateFolder method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
final IStructuredSelection structSelection = (IStructuredSelection) selection;
Object element = structSelection.getFirstElement();
if (!(element instanceof DBNResource)) {
return null;
}
Shell activeShell = HandlerUtil.getActiveShell(event);
String folderName = EnterNameDialog.chooseName(activeShell, CoreMessages.actions_navigator_create_folder_folder_name);
if (!CommonUtils.isEmpty(folderName)) {
try {
((DBNResource) element).createNewFolder(folderName);
} catch (DBException e) {
UIUtils.showErrorDialog(activeShell, CoreMessages.actions_navigator_create_folder_error_title, NLS.bind(CoreMessages.actions_navigator_create_folder_error_message, folderName), e);
}
}
}
return null;
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class ConnectionPageGeneral method saveSettings.
void saveSettings(DataSourceDescriptor dataSource) {
if (dataSourceDescriptor != null && !activated) {
// No changes anyway
return;
}
dataSource.setName(connectionNameText.getText());
dataSource.setSavePassword(savePasswordCheck.getSelection());
try {
dataSource.setDefaultAutoCommit(autocommit.getSelection(), null, true, null);
if (dataSource.isConnected()) {
int levelIndex = isolationLevel.getSelectionIndex();
if (levelIndex <= 0) {
dataSource.setDefaultTransactionsIsolation(null);
} else {
dataSource.setDefaultTransactionsIsolation(supportedLevels.get(levelIndex - 1));
}
}
} catch (DBException e) {
log.error(e);
}
dataSource.setDefaultActiveObject(defaultSchema.getText());
dataSource.setShowSystemObjects(showSystemObjects.getSelection());
dataSource.setShowUtilityObjects(showUtilityObjects.getSelection());
dataSource.setConnectionReadOnly(readOnlyConnection.getSelection());
if (!dataSource.isSavePassword()) {
dataSource.resetPassword();
}
dataSource.setFolder(dataSourceFolder);
final DBPConnectionConfiguration confConfig = dataSource.getConnectionConfiguration();
if (connectionTypeCombo.getSelectionIndex() >= 0) {
confConfig.setConnectionType(connectionTypeCombo.getItem(connectionTypeCombo.getSelectionIndex()));
}
for (FilterInfo filterInfo : filters) {
if (filterInfo.filter != null) {
dataSource.setObjectFilter(filterInfo.type, null, filterInfo.filter);
}
}
DBPConnectionBootstrap bootstrap = confConfig.getBootstrap();
bootstrap.setIgnoreErrors(ignoreBootstrapErrors);
bootstrap.setInitQueries(bootstrapQueries);
confConfig.setKeepAliveInterval(keepAliveInterval.getSelection());
final String description = descriptionText.getText();
if (description.isEmpty()) {
dataSource.setDescription(null);
} else {
dataSource.setDescription(description);
}
}
Aggregations