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;
}
Aggregations