Search in sources :

Example 16 with DBPWorkspace

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

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)

Example 17 with DBPWorkspace

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

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 18 with DBPWorkspace

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

the class ResourcePropertyTester method test.

@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    if (!(receiver instanceof IResource)) {
        return false;
    }
    IResource resource = (IResource) receiver;
    DBPWorkspace workspace = DBWorkbench.getPlatform().getWorkspace();
    DBPResourceHandler handler = workspace.getResourceHandler(resource);
    if (handler == null) {
        return false;
    }
    switch(property) {
        case PROP_CAN_OPEN:
            return (handler.getFeatures(resource) & DBPResourceHandler.FEATURE_OPEN) != 0;
        case PROP_CAN_DELETE:
            return (handler.getFeatures(resource) & DBPResourceHandler.FEATURE_DELETE) != 0;
        case PROP_CAN_CREATE_FILE:
            return handler instanceof DBPResourceCreator && (handler.getFeatures(resource) & DBPResourceCreator.FEATURE_CREATE_FILE) != 0;
        case PROP_CAN_CREATE_FOLDER:
            return (handler.getFeatures(resource) & DBPResourceHandler.FEATURE_CREATE_FOLDER) != 0;
        case PROP_CAN_CREATE_LINK:
            return (handler.getFeatures(resource) & DBPResourceHandler.FEATURE_CREATE_FOLDER) != 0 && !resource.isLinked(IResource.CHECK_ANCESTORS);
        case PROP_CAN_SET_ACTIVE:
            {
                DBPProject activeProject = workspace.getActiveProject();
                return resource instanceof IProject && (activeProject == null || resource != activeProject.getEclipseProject());
            }
        case PROP_TYPE:
            final DBPResourceHandler resourceHandler = DBWorkbench.getPlatform().getWorkspace().getResourceHandler(resource);
            return resourceHandler != null && expectedValue.equals(resourceHandler.getTypeName(resource));
    }
    return false;
}
Also used : DBPWorkspace(org.jkiss.dbeaver.model.app.DBPWorkspace) DBPResourceCreator(org.jkiss.dbeaver.model.app.DBPResourceCreator) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) DBPResourceHandler(org.jkiss.dbeaver.model.app.DBPResourceHandler) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject)

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