Search in sources :

Example 81 with DBPDataSourceContainer

use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.

the class DatabaseDebugConfigurationTab method performApply.

@Override
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
    DBPDataSourceContainer dataSource = connectionCombo.getSelectedItem();
    configuration.setAttribute(DBGConstants.ATTR_DATASOURCE_ID, dataSource == null ? null : dataSource.getId());
    configuration.setAttribute(DBGConstants.ATTR_DEBUG_TYPE, selectedDebugType == null ? null : selectedDebugType.getId());
    if (selectedDebugPanel != null) {
        Map<String, Object> attrs = new HashMap<>();
        selectedDebugPanel.saveConfiguration(dataSource, attrs);
        DebugUtils.putContextInConfiguration(configuration, attrs);
    }
}
Also used : HashMap(java.util.HashMap) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Example 82 with DBPDataSourceContainer

use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.

the class DBGSourcePathComputer method computeSourceContainers.

@Override
public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
    DBPDataSourceContainer dataSource = DebugUtils.getDataSourceContainer(configuration);
    DatabaseNavigatorSourceContainer container = new DatabaseNavigatorSourceContainer(dataSource);
    return new ISourceContainer[] { container };
}
Also used : ISourceContainer(org.eclipse.debug.core.sourcelookup.ISourceContainer) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Example 83 with DBPDataSourceContainer

use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.

the class ERDDiagram method addEntity.

public void addEntity(ERDEntity entity, int i, boolean reflect) {
    DBSEntity object = entity.getObject();
    if (object == null) {
        log.debug("Null object passed");
        return;
    } else if (object.getDataSource() == null) {
        log.debug("Object " + object.getName() + " is not connected with datasource");
        return;
    }
    synchronized (entities) {
        if (i < 0) {
            entities.add(entity);
        } else {
            entities.add(i, entity);
        }
        entityMap.put(object, entity);
        DBPDataSourceContainer dataSource = object.getDataSource().getContainer();
        DataSourceInfo dsInfo = dataSourceMap.computeIfAbsent(dataSource, dsc -> new DataSourceInfo(dataSourceMap.size()));
        dsInfo.entities.add(entity);
        DBSObjectContainer container = DBUtils.getParentOfType(DBSObjectContainer.class, entity.getObject());
        if (container != null) {
            dataSourceContainerMap.putIfAbsent(dataSource, new LinkedHashMap<>());
            Map<DBSObjectContainer, Integer> containerMap = dataSourceContainerMap.get(dataSource);
            containerMap.putIfAbsent(container, containerMap.size());
        }
    }
    if (reflect) {
        firePropertyChange(CHILD, null, entity);
    /*
            for (ERDAssociation rel : entity.getReferences()) {
                entity.firePropertyChange(INPUT, null, rel);
            }
            for (ERDAssociation rel : entity.getAssociations()) {
                entity.firePropertyChange(OUTPUT, null, rel);
            }
*/
    }
    resolveRelations(reflect);
    if (reflect) {
        for (ERDAssociation rel : entity.getReferences()) {
            rel.getSourceEntity().firePropertyChange(OUTPUT, null, rel);
        }
        for (ERDAssociation rel : entity.getAssociations()) {
            rel.getTargetEntity().firePropertyChange(INPUT, null, rel);
        }
    }
}
Also used : DBSObjectContainer(org.jkiss.dbeaver.model.struct.DBSObjectContainer) DBSEntity(org.jkiss.dbeaver.model.struct.DBSEntity) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Example 84 with DBPDataSourceContainer

use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.

the class BasePlatformImpl method initialize.

protected void initialize() {
    log.debug("Initialize base platform...");
    DBPPreferenceStore prefsStore = getPreferenceStore();
    // Global pref events forwarder
    prefsStore.addPropertyChangeListener(event -> {
        // Forward event to all data source preferences
        for (DBPDataSourceContainer ds : DataSourceRegistry.getAllDataSources()) {
            ((AbstractPreferenceStore) ds.getPreferenceStore()).firePropertyChangeEvent(prefsStore, event.getProperty(), event.getOldValue(), event.getNewValue());
        }
    });
    this.localSystem = new OSDescriptor(Platform.getOS(), Platform.getOSArch());
    {
        this.language = PlatformLanguageRegistry.getInstance().getLanguage(Locale.getDefault());
        if (this.language == null) {
            log.debug("Language for locale '" + Locale.getDefault() + "' not found. Use default.");
            this.language = PlatformLanguageRegistry.getInstance().getLanguage(Locale.ENGLISH);
        }
    }
    // Navigator model
    this.navigatorModel = new DBNModel(this, null);
    this.navigatorModel.initialize();
    // Activate plugin services
    for (IPluginService pluginService : PluginServiceRegistry.getInstance().getServices()) {
        try {
            pluginService.activateService();
            activatedServices.add(pluginService);
        } catch (Throwable e) {
            log.error("Error activating plugin service", e);
        }
    }
    // Keep-alive job
    new KeepAliveListenerJob(this).scheduleMonitor();
}
Also used : AbstractPreferenceStore(org.jkiss.dbeaver.model.impl.preferences.AbstractPreferenceStore) KeepAliveListenerJob(org.jkiss.dbeaver.runtime.jobs.KeepAliveListenerJob) IPluginService(org.jkiss.dbeaver.runtime.IPluginService) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) OSDescriptor(org.jkiss.dbeaver.model.runtime.OSDescriptor) DBNModel(org.jkiss.dbeaver.model.navigator.DBNModel)

Example 85 with DBPDataSourceContainer

use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.

the class KeepAliveListenerJob method run.

@Override
protected IStatus run(DBRProgressMonitor monitor) {
    if (platform.isShuttingDown()) {
        return Status.OK_STATUS;
    }
    if (lastPingTime > 0 && System.currentTimeMillis() - lastPingTime > SYSTEM_SUSPEND_INTERVAL) {
        log.debug("System suspend detected! Reinitialize all remote connections.");
    }
    lastPingTime = System.currentTimeMillis();
    final DBPWorkspace workspace = platform.getWorkspace();
    for (DBPProject project : workspace.getProjects()) {
        if (project.isOpen() && project.isRegistryLoaded()) {
            DBPDataSourceRegistry dataSourceRegistry = project.getDataSourceRegistry();
            for (DBPDataSourceContainer ds : dataSourceRegistry.getDataSources()) {
                checkDataSourceAlive(ds);
            }
        }
    }
    if (!platform.isShuttingDown()) {
        scheduleMonitor();
    }
    return Status.OK_STATUS;
}
Also used : DBPWorkspace(org.jkiss.dbeaver.model.app.DBPWorkspace) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) DBPDataSourceRegistry(org.jkiss.dbeaver.model.app.DBPDataSourceRegistry) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Aggregations

DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)230 DBException (org.jkiss.dbeaver.DBException)32 ArrayList (java.util.ArrayList)31 IFile (org.eclipse.core.resources.IFile)30 DBCExecutionContext (org.jkiss.dbeaver.model.exec.DBCExecutionContext)27 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)27 DBNDataSource (org.jkiss.dbeaver.model.navigator.DBNDataSource)24 InvocationTargetException (java.lang.reflect.InvocationTargetException)22 DBPDataSource (org.jkiss.dbeaver.model.DBPDataSource)19 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)19 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)18 SelectionEvent (org.eclipse.swt.events.SelectionEvent)18 DBPProject (org.jkiss.dbeaver.model.app.DBPProject)18 DBPConnectionConfiguration (org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)18 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)17 GridData (org.eclipse.swt.layout.GridData)16 IEditorPart (org.eclipse.ui.IEditorPart)16 DBNNode (org.jkiss.dbeaver.model.navigator.DBNNode)16 DBNResource (org.jkiss.dbeaver.model.navigator.DBNResource)16 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)13