use of org.jkiss.dbeaver.ui.navigator.database.NavigatorViewBase in project dbeaver by serge-rider.
the class NavigatorHandlerLocalFolderCreate method createFolder.
public static boolean createFolder(IWorkbenchWindow workbenchWindow, IWorkbenchPart activePart, DBNProjectDatabases databases, final DBNLocalFolder parentFolder, final Collection<DBNDataSource> nodes, String newName) {
if (newName == null) {
newName = EnterNameDialog.chooseName(workbenchWindow.getShell(), "Folder name");
}
if (CommonUtils.isEmpty(newName)) {
return false;
}
// Create folder and refresh databases root
// DS container will reload folders on refresh
final DBPDataSourceRegistry dsRegistry = databases.getDataSourceRegistry();
DBPDataSourceFolder folder = dsRegistry.addFolder(parentFolder == null ? null : parentFolder.getFolder(), newName);
for (DBNDataSource node : nodes) {
node.setFolder(folder);
}
if (parentFolder != null && activePart instanceof NavigatorViewBase) {
final TreeViewer viewer = ((NavigatorViewBase) activePart).getNavigatorViewer();
if (viewer != null) {
UIUtils.asyncExec(() -> viewer.expandToLevel(parentFolder, 1));
}
}
DBNModel.updateConfigAndRefreshDatabases(databases);
return true;
}
use of org.jkiss.dbeaver.ui.navigator.database.NavigatorViewBase in project dbeaver by serge-rider.
the class NavigatorHandlerExpandAll method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof NavigatorViewBase) {
TreeViewer navigatorViewer = ((NavigatorViewBase) activePart).getNavigatorViewer();
ISelection selection = navigatorViewer.getSelection();
if (selection.isEmpty()) {
navigatorViewer.expandAll();
} else if (selection instanceof IStructuredSelection) {
for (Iterator iter = ((IStructuredSelection) selection).iterator(); iter.hasNext(); ) {
navigatorViewer.expandToLevel(iter.next(), TreeViewer.ALL_LEVELS);
}
}
}
return null;
}
use of org.jkiss.dbeaver.ui.navigator.database.NavigatorViewBase in project dbeaver by serge-rider.
the class SyncConnectionHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final NavigatorViewBase navigatorView = NavigatorUtils.getActiveNavigatorView(event);
if (navigatorView == null) {
return null;
}
IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
if (NavigatorUtils.syncEditorWithNavigator(navigatorView, activeEditor)) {
HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().activate(activeEditor);
}
return null;
}
use of org.jkiss.dbeaver.ui.navigator.database.NavigatorViewBase in project dbeaver by dbeaver.
the class NavigatorHandlerLocalFolderCreate method createFolder.
public static boolean createFolder(IWorkbenchWindow workbenchWindow, IWorkbenchPart activePart, DBNProjectDatabases databases, final DBNLocalFolder parentFolder, final Collection<DBNDataSource> nodes, String newName) {
if (newName == null) {
newName = EnterNameDialog.chooseName(workbenchWindow.getShell(), "Folder name");
}
if (CommonUtils.isEmpty(newName)) {
return false;
}
// Create folder and refresh databases root
// DS container will reload folders on refresh
final DBPDataSourceRegistry dsRegistry = databases.getDataSourceRegistry();
DBPDataSourceFolder folder = dsRegistry.addFolder(parentFolder == null ? null : parentFolder.getFolder(), newName);
for (DBNDataSource node : nodes) {
node.setFolder(folder);
}
if (parentFolder != null && activePart instanceof NavigatorViewBase) {
final TreeViewer viewer = ((NavigatorViewBase) activePart).getNavigatorViewer();
if (viewer != null) {
DBeaverUI.asyncExec(new Runnable() {
@Override
public void run() {
viewer.expandToLevel(parentFolder, 1);
}
});
}
}
DBNModel.updateConfigAndRefreshDatabases(databases);
return true;
}
use of org.jkiss.dbeaver.ui.navigator.database.NavigatorViewBase in project dbeaver by dbeaver.
the class SyncConnectionHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final NavigatorViewBase navigatorView = NavigatorUtils.getActiveNavigatorView(event);
if (navigatorView == null) {
return null;
}
IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
if (NavigatorUtils.syncEditorWithNavigator(navigatorView, activeEditor)) {
HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().activate(activeEditor);
}
return null;
}
Aggregations