Search in sources :

Example 26 with DBPDataSourceContainer

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

the class DBNBookmark method getNodeDescription.

@Override
public String getNodeDescription() {
    String dsInfo = "";
    Collection<DBPDataSourceContainer> dataSources = getAssociatedDataSources();
    if (!CommonUtils.isEmpty(dataSources)) {
        DBPDataSourceContainer dataSource = dataSources.iterator().next();
        dsInfo = " ('" + dataSource.getName() + "' - " + dataSource.getDriver().getName() + ")";
    }
    return storage.getDescription() + dsInfo;
}
Also used : DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Example 27 with DBPDataSourceContainer

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

the class AuthModelSelector method loadSettings.

public void loadSettings(DBPDataSourceContainer dataSourceContainer, DBPAuthModelDescriptor activeAuthModel, String defaultAuthModelId) {
    this.activeDataSource = dataSourceContainer;
    this.selectedAuthModel = activeAuthModel;
    this.allAuthModels = activeDataSource.getDriver() == DriverDescriptor.NULL_DRIVER ? DataSourceProviderRegistry.getInstance().getAllAuthModels() : DataSourceProviderRegistry.getInstance().getApplicableAuthModels(activeDataSource.getDriver());
    this.allAuthModels.removeIf(o -> modelFilter != null && !modelFilter.isValidElement(o));
    this.allAuthModels.sort((Comparator<DBPAuthModelDescriptor>) (o1, o2) -> AuthModelDatabaseNative.ID.equals(o1.getId()) ? -1 : (AuthModelDatabaseNative.ID.equals(o2.getId()) ? 1 : o1.getName().compareTo(o2.getName())));
    if (selectedAuthModel == null && !CommonUtils.isEmpty(defaultAuthModelId)) {
        // Set default to native
        for (DBPAuthModelDescriptor amd : allAuthModels) {
            if (amd.getId().equals(defaultAuthModelId)) {
                selectedAuthModel = amd;
                break;
            }
        }
        if (selectedAuthModel == null) {
            // First one
            selectedAuthModel = allAuthModels.get(0);
        }
    }
    changeAuthModel();
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CommonUtils(org.jkiss.utils.CommonUtils) IElementFilter(org.jkiss.dbeaver.ui.IElementFilter) UIConnectionMessages(org.jkiss.dbeaver.ui.internal.UIConnectionMessages) org.eclipse.swt.widgets(org.eclipse.swt.widgets) IObjectPropertyConfigurator(org.jkiss.dbeaver.ui.IObjectPropertyConfigurator) DBPAuthModelDescriptor(org.jkiss.dbeaver.model.connection.DBPAuthModelDescriptor) DriverDescriptor(org.jkiss.dbeaver.registry.driver.DriverDescriptor) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) AuthModelDatabaseNative(org.jkiss.dbeaver.model.impl.auth.AuthModelDatabaseNative) List(java.util.List) DBException(org.jkiss.dbeaver.DBException) UIUtils(org.jkiss.dbeaver.ui.UIUtils) SWT(org.eclipse.swt.SWT) Log(org.jkiss.dbeaver.Log) DataSourceProviderRegistry(org.jkiss.dbeaver.registry.DataSourceProviderRegistry) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout) UIPropertyConfiguratorRegistry(org.jkiss.dbeaver.registry.configurator.UIPropertyConfiguratorRegistry) Comparator(java.util.Comparator) UIPropertyConfiguratorDescriptor(org.jkiss.dbeaver.registry.configurator.UIPropertyConfiguratorDescriptor) DBPAuthModelDescriptor(org.jkiss.dbeaver.model.connection.DBPAuthModelDescriptor)

Example 28 with DBPDataSourceContainer

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

the class NavigatorHandlerAssociateScript method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final Shell activeShell = HandlerUtil.getActiveShell(event);
    List<IFile> scripts = new ArrayList<>();
    final ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
        for (Iterator iter = ((IStructuredSelection) selection).iterator(); iter.hasNext(); ) {
            final DBNNode node = RuntimeUtils.getObjectAdapter(iter.next(), DBNNode.class);
            if (node instanceof DBNResource) {
                IResource resource = ((DBNResource) node).getResource();
                if (resource instanceof IFile) {
                    scripts.add((IFile) resource);
                }
            }
        }
    }
    if (!scripts.isEmpty()) {
        SelectDataSourceDialog dialog = new SelectDataSourceDialog(activeShell, DBWorkbench.getPlatform().getWorkspace().getProject(scripts.get(0).getProject()), null);
        if (dialog.open() == IDialogConstants.CANCEL_ID) {
            return null;
        }
        DBPDataSourceContainer dataSource = dialog.getDataSource();
        for (IFile script : scripts) {
            EditorUtils.setFileDataSource(script, new SimpleDatabaseEditorContext(dataSource));
            DBNUtils.refreshNavigatorResource(script, dataSource);
        }
    }
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) SimpleDatabaseEditorContext(org.jkiss.dbeaver.ui.editors.SimpleDatabaseEditorContext) DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DBNResource(org.jkiss.dbeaver.model.navigator.DBNResource) Shell(org.eclipse.swt.widgets.Shell) ISelection(org.eclipse.jface.viewers.ISelection) Iterator(java.util.Iterator) SelectDataSourceDialog(org.jkiss.dbeaver.ui.navigator.dialogs.SelectDataSourceDialog) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) IResource(org.eclipse.core.resources.IResource)

Example 29 with DBPDataSourceContainer

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

the class NNAHDataSourceReadOnly method handleNodeAction.

@Override
public void handleNodeAction(INavigatorModelView view, DBNNode node, Event event, boolean defaultAction) {
    if (node instanceof DBNDatabaseNode) {
        DBPDataSourceContainer dataSourceContainer = ((DBNDatabaseNode) node).getDataSourceContainer();
        UIServiceConnections serviceConnections = DBWorkbench.getService(UIServiceConnections.class);
        if (serviceConnections != null) {
            serviceConnections.openConnectionEditor(dataSourceContainer, "ConnectionPageGeneral");
        }
    }
}
Also used : DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) UIServiceConnections(org.jkiss.dbeaver.runtime.ui.UIServiceConnections)

Example 30 with DBPDataSourceContainer

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

the class WMIConnectionPage method loadSettings.

@Override
public void loadSettings() {
    // Load values from new connection info
    DBPDataSourceContainer activeDataSource = site.getActiveDataSource();
    DBPConnectionConfiguration connectionInfo = activeDataSource.getConnectionConfiguration();
    if (connectionInfo.getHostName() == null) {
        connectionInfo.setHostName(DEFAULT_HOST);
    }
    if (connectionInfo.getDatabaseName() == null) {
        connectionInfo.setDatabaseName(DEFAULT_NAMESPACE);
    }
    if (hostText != null) {
        hostText.setText(CommonUtils.notEmpty(connectionInfo.getHostName()));
    }
    if (domainText != null) {
        domainText.setText(CommonUtils.notEmpty(connectionInfo.getServerName()));
    }
    if (namespaceCombo != null) {
        namespaceCombo.setText(CommonUtils.notEmpty(connectionInfo.getDatabaseName()));
    }
    super.loadSettings();
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Aggregations

DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)148 IFile (org.eclipse.core.resources.IFile)22 ArrayList (java.util.ArrayList)21 DBException (org.jkiss.dbeaver.DBException)19 DBCExecutionContext (org.jkiss.dbeaver.model.exec.DBCExecutionContext)19 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)19 DBPDataSource (org.jkiss.dbeaver.model.DBPDataSource)14 DBNDataSource (org.jkiss.dbeaver.model.navigator.DBNDataSource)14 InvocationTargetException (java.lang.reflect.InvocationTargetException)13 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)13 DBPConnectionConfiguration (org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)12 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)12 IFolder (org.eclipse.core.resources.IFolder)11 IEditorPart (org.eclipse.ui.IEditorPart)11 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)10 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 DBNNode (org.jkiss.dbeaver.model.navigator.DBNNode)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 GridData (org.eclipse.swt.layout.GridData)9 IDataSourceContainerProvider (org.jkiss.dbeaver.model.IDataSourceContainerProvider)9