Search in sources :

Example 1 with DBNLocalFolder

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());
        }
    }
}
Also used : DBNLocalFolder(org.jkiss.dbeaver.model.navigator.DBNLocalFolder) DataSourceViewDescriptor(org.jkiss.dbeaver.registry.DataSourceViewDescriptor) DataSourceProviderDescriptor(org.jkiss.dbeaver.registry.DataSourceProviderDescriptor)

Example 2 with DBNLocalFolder

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

Example 3 with DBNLocalFolder

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;
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBNLocalFolder(org.jkiss.dbeaver.model.navigator.DBNLocalFolder) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) DBNDataSource(org.jkiss.dbeaver.model.navigator.DBNDataSource) ArrayList(java.util.ArrayList) ISelection(org.eclipse.jface.viewers.ISelection) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Aggregations

DBNLocalFolder (org.jkiss.dbeaver.model.navigator.DBNLocalFolder)3 ArrayList (java.util.ArrayList)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)2 DBNDataSource (org.jkiss.dbeaver.model.navigator.DBNDataSource)2 Iterator (java.util.Iterator)1 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)1 DBNProjectDatabases (org.jkiss.dbeaver.model.navigator.DBNProjectDatabases)1 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)1 DataSourceProviderDescriptor (org.jkiss.dbeaver.registry.DataSourceProviderDescriptor)1 DataSourceViewDescriptor (org.jkiss.dbeaver.registry.DataSourceViewDescriptor)1