Search in sources :

Example 1 with ScriptSelectorPanel

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);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IFile(org.eclipse.core.resources.IFile) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder) ScriptSelectorPanel(org.jkiss.dbeaver.ui.controls.ScriptSelectorPanel)

Example 2 with ScriptSelectorPanel

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);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IFile(org.eclipse.core.resources.IFile) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder) ScriptSelectorPanel(org.jkiss.dbeaver.ui.controls.ScriptSelectorPanel)

Aggregations

IFile (org.eclipse.core.resources.IFile)2 IFolder (org.eclipse.core.resources.IFolder)2 IProject (org.eclipse.core.resources.IProject)2 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)2 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)2 ScriptSelectorPanel (org.jkiss.dbeaver.ui.controls.ScriptSelectorPanel)2