use of org.jkiss.dbeaver.model.navigator.DBNLocalFolder in project dbeaver by serge-rider.
the class NewConnectionWizard method addPages.
/**
* Adding the page to the wizard.
*/
@Override
public void addPages() {
pageDrivers = new ConnectionPageDriver(this);
addPage(pageDrivers);
List<DataSourceProviderDescriptor> providers = DataSourceProviderRegistry.getInstance().getDataSourceProviders();
for (DataSourceProviderDescriptor provider : providers) {
DataSourceViewDescriptor view = provider.getView(IActionConstants.NEW_CONNECTION_POINT);
availableProvides.add(provider);
if (view != null) {
ConnectionPageSettings pageSettings = new ConnectionPageSettings(NewConnectionWizard.this, view);
settingsPages.put(provider, pageSettings);
addPage(pageSettings);
}
}
pageGeneral = new ConnectionPageGeneral(this);
pageNetwork = new ConnectionPageNetwork(this);
addPage(pageGeneral);
addPage(pageNetwork);
// Initial settings
if (selection != null && !selection.isEmpty()) {
final Object element = selection.getFirstElement();
if (element instanceof DBNLocalFolder) {
pageGeneral.setDataSourceFolder(((DBNLocalFolder) element).getFolder());
}
}
}
use of org.jkiss.dbeaver.model.navigator.DBNLocalFolder 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;
}
use of org.jkiss.dbeaver.model.navigator.DBNLocalFolder in project dbeaver by serge-rider.
the class OpenHandler method getDataSourceContainers.
private static List<DBPDataSourceContainer> getDataSourceContainers(ExecutionEvent event) {
List<DBPDataSourceContainer> containers = new ArrayList<>();
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
for (Object obj : ((IStructuredSelection) selection).toArray()) {
if (obj instanceof DBNLocalFolder) {
for (DBNDataSource ds : ((DBNLocalFolder) obj).getDataSources()) {
containers.add(ds.getDataSourceContainer());
}
} else {
DBSObject selectedObject = DBUtils.getFromObject(obj);
if (selectedObject != null) {
if (selectedObject instanceof DBPDataSourceContainer) {
containers.add((DBPDataSourceContainer) selectedObject);
} else {
containers.add(selectedObject.getDataSource().getContainer());
}
}
}
}
}
if (containers.isEmpty()) {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
DBPDataSourceContainer partContainer = getDataSourceContainers(activePart);
if (partContainer != null) {
containers.add(partContainer);
}
}
return containers;
}
Aggregations