Search in sources :

Example 1 with DBPWorkspace

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

the class NavigatorHandlerCreateFile method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (selection instanceof IStructuredSelection) {
        final IStructuredSelection structSelection = (IStructuredSelection) selection;
        Object element = structSelection.getFirstElement();
        if (!(element instanceof DBNResource)) {
            return null;
        }
        DBPWorkspace workspace = DBWorkbench.getPlatform().getWorkspace();
        IResource resource = ((DBNResource) element).getResource();
        DBPResourceCreator handler = (DBPResourceCreator) workspace.getResourceHandler(resource);
        if (resource instanceof IFolder) {
            try {
                handler.createResource((IFolder) resource);
            } catch (Exception e) {
                DBWorkbench.getPlatformUI().showError("Can't create file", "Error during " + handler.getTypeName(resource) + " creation", e);
            }
        }
    }
    return null;
}
Also used : DBNResource(org.jkiss.dbeaver.model.navigator.DBNResource) DBPWorkspace(org.jkiss.dbeaver.model.app.DBPWorkspace) DBPResourceCreator(org.jkiss.dbeaver.model.app.DBPResourceCreator) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IResource(org.eclipse.core.resources.IResource) ExecutionException(org.eclipse.core.commands.ExecutionException) IFolder(org.eclipse.core.resources.IFolder)

Example 2 with DBPWorkspace

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

the class NavigatorHandlerProjectSetActive method setActiveProject.

static void setActiveProject(DBPProject project) {
    DBPWorkspace workspace = DBWorkbench.getPlatform().getWorkspace();
    if (workspace.getActiveProject() != project) {
        workspace.setActiveProject(project);
        GlobalPropertyTester.firePropertyChange(GlobalPropertyTester.PROP_HAS_ACTIVE_PROJECT);
    }
}
Also used : DBPWorkspace(org.jkiss.dbeaver.model.app.DBPWorkspace)

Example 3 with DBPWorkspace

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

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)

Example 4 with DBPWorkspace

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

the class ApplicationWorkbenchWindowAdvisor method dispose.

@Override
public void dispose() {
    ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
    // Remove project listener
    DBPPlatform platform = DBWorkbench.getPlatform();
    if (platform != null) {
        DBPWorkspace workspace = platform.getWorkspace();
        workspace.removeProjectListener(this);
    }
    super.dispose();
}
Also used : DBPWorkspace(org.jkiss.dbeaver.model.app.DBPWorkspace) DBPPlatform(org.jkiss.dbeaver.model.app.DBPPlatform)

Example 5 with DBPWorkspace

use of org.jkiss.dbeaver.model.app.DBPWorkspace in project dbeaver by dbeaver.

the class DataSourceRegistry method getAllDataSources.

public static List<DBPDataSourceContainer> getAllDataSources() {
    List<DBPDataSourceContainer> result = new ArrayList<>();
    DBPWorkspace workspace = DBWorkbench.getPlatform().getWorkspace();
    for (DBPProject project : workspace.getProjects()) {
        if (project.isOpen() && project.isRegistryLoaded()) {
            result.addAll(project.getDataSourceRegistry().getDataSources());
        }
    }
    return result;
}
Also used : DBPWorkspace(org.jkiss.dbeaver.model.app.DBPWorkspace) DBPProject(org.jkiss.dbeaver.model.app.DBPProject)

Aggregations

DBPWorkspace (org.jkiss.dbeaver.model.app.DBPWorkspace)18 DBPProject (org.jkiss.dbeaver.model.app.DBPProject)8 IResource (org.eclipse.core.resources.IResource)6 DBPResourceCreator (org.jkiss.dbeaver.model.app.DBPResourceCreator)6 IProject (org.eclipse.core.resources.IProject)4 DBPResourceHandler (org.jkiss.dbeaver.model.app.DBPResourceHandler)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ArrayList (java.util.ArrayList)2 ExecutionException (org.eclipse.core.commands.ExecutionException)2 IContainer (org.eclipse.core.resources.IContainer)2 IFolder (org.eclipse.core.resources.IFolder)2 CoreException (org.eclipse.core.runtime.CoreException)2 IContributionItem (org.eclipse.jface.action.IContributionItem)2 Separator (org.eclipse.jface.action.Separator)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 DBException (org.jkiss.dbeaver.DBException)2 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)2 DBPImage (org.jkiss.dbeaver.model.DBPImage)2 DBPDataSourceRegistry (org.jkiss.dbeaver.model.app.DBPDataSourceRegistry)2