use of org.jkiss.dbeaver.ui.controls.ScriptSelectorPanel in project dbeaver by serge-rider.
the class OpenHandler method openEditor.
private static void openEditor(ExecutionEvent event) throws ExecutionException, CoreException {
List<DBPDataSourceContainer> containers = getDataSourceContainers(event);
IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
IProject project = !containers.isEmpty() ? containers.get(0).getRegistry().getProject() : DBeaverCore.getInstance().getProjectRegistry().getActiveProject();
checkProjectIsOpen(project);
final DBPDataSourceContainer[] containerList = containers.toArray(new DBPDataSourceContainer[containers.size()]);
final IFolder rootFolder = ResourceUtils.getScriptsFolder(project, true);
final List<ResourceUtils.ResourceInfo> scriptTree = ResourceUtils.findScriptTree(rootFolder, containerList.length == 0 ? null : containerList);
if (scriptTree.isEmpty() && containerList.length == 1) {
// Create new script
final IFile newScript = ResourceUtils.createNewScript(project, rootFolder, containers.isEmpty() ? null : containers.get(0));
NavigatorHandlerObjectOpen.openResource(newScript, workbenchWindow);
} else {
// Show script chooser
ScriptSelectorPanel selector = new ScriptSelectorPanel(workbenchWindow, containerList, rootFolder);
selector.showTree(scriptTree);
}
}
use of org.jkiss.dbeaver.ui.controls.ScriptSelectorPanel in project dbeaver by dbeaver.
the class OpenHandler method openEditor.
private static void openEditor(ExecutionEvent event) throws ExecutionException, CoreException {
List<DBPDataSourceContainer> containers = getDataSourceContainers(event);
IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
IProject project = !containers.isEmpty() ? containers.get(0).getRegistry().getProject() : DBeaverCore.getInstance().getProjectRegistry().getActiveProject();
checkProjectIsOpen(project);
final DBPDataSourceContainer[] containerList = containers.toArray(new DBPDataSourceContainer[containers.size()]);
final IFolder rootFolder = ResourceUtils.getScriptsFolder(project, true);
final List<ResourceUtils.ResourceInfo> scriptTree = ResourceUtils.findScriptTree(rootFolder, containerList.length == 0 ? null : containerList);
if (scriptTree.isEmpty() && containerList.length == 1) {
// Create new script
final IFile newScript = ResourceUtils.createNewScript(project, rootFolder, containers.isEmpty() ? null : containers.get(0));
NavigatorHandlerObjectOpen.openResource(newScript, workbenchWindow);
} else {
// Show script chooser
ScriptSelectorPanel selector = new ScriptSelectorPanel(workbenchWindow, containerList, rootFolder);
selector.showTree(scriptTree);
}
}
Aggregations