Search in sources :

Example 1 with DBNProjectDatabases

use of org.jkiss.dbeaver.model.navigator.DBNProjectDatabases in project dbeaver by serge-rider.

the class NavigatorHandlerLocalFolderCreate method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    final ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structSelection = (IStructuredSelection) selection;
        List<DBNDataSource> dataSources = new ArrayList<>();
        DBNProjectDatabases databasesNode = null;
        DBNLocalFolder parentFolder = null;
        for (Iterator iter = structSelection.iterator(); iter.hasNext(); ) {
            Object element = iter.next();
            if (element instanceof DBNDataSource) {
                dataSources.add((DBNDataSource) element);
                element = ((DBNDataSource) element).getParentNode();
            }
            if (element instanceof DBNLocalFolder) {
                parentFolder = (DBNLocalFolder) element;
                databasesNode = parentFolder.getParentNode();
            } else if (element instanceof DBNProjectDatabases) {
                databasesNode = (DBNProjectDatabases) element;
            }
        }
        if (databasesNode != null) {
            createFolder(HandlerUtil.getActiveWorkbenchWindow(event), activePart, databasesNode, parentFolder, dataSources, null);
        }
    }
    return null;
}
Also used : DBNProjectDatabases(org.jkiss.dbeaver.model.navigator.DBNProjectDatabases) DBNLocalFolder(org.jkiss.dbeaver.model.navigator.DBNLocalFolder) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) DBNDataSource(org.jkiss.dbeaver.model.navigator.DBNDataSource) ISelection(org.eclipse.jface.viewers.ISelection) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1 DBNDataSource (org.jkiss.dbeaver.model.navigator.DBNDataSource)1 DBNLocalFolder (org.jkiss.dbeaver.model.navigator.DBNLocalFolder)1 DBNProjectDatabases (org.jkiss.dbeaver.model.navigator.DBNProjectDatabases)1