use of org.jkiss.dbeaver.registry.ProjectRegistry in project dbeaver by serge-rider.
the class ApplicationWorkbenchWindowAdvisor method dispose.
@Override
public void dispose() {
// Remove project listener
DBeaverCore core = DBeaverCore.getInstance();
if (core != null) {
ProjectRegistry projectRegistry = core.getProjectRegistry();
if (projectRegistry != null) {
projectRegistry.removeProjectListener(this);
}
}
super.dispose();
}
use of org.jkiss.dbeaver.registry.ProjectRegistry in project dbeaver by dbeaver.
the class OpenHandler method getCurrentConnection.
@Nullable
private static DBPDataSourceContainer getCurrentConnection(ExecutionEvent event) {
DBPDataSourceContainer dataSourceContainer = getDataSourceContainer(event, false);
final ProjectRegistry projectRegistry = DBeaverCore.getInstance().getProjectRegistry();
IProject project = dataSourceContainer != null ? dataSourceContainer.getRegistry().getProject() : projectRegistry.getActiveProject();
if (dataSourceContainer == null) {
final DataSourceRegistry dataSourceRegistry = projectRegistry.getDataSourceRegistry(project);
if (dataSourceRegistry == null) {
return null;
}
if (dataSourceRegistry.getDataSources().size() == 1) {
dataSourceContainer = dataSourceRegistry.getDataSources().get(0);
} else if (!dataSourceRegistry.getDataSources().isEmpty()) {
SelectDataSourceDialog dialog = new SelectDataSourceDialog(HandlerUtil.getActiveShell(event), project, null);
if (dialog.open() == IDialogConstants.CANCEL_ID) {
return null;
}
dataSourceContainer = dialog.getDataSource();
}
}
return dataSourceContainer;
}
use of org.jkiss.dbeaver.registry.ProjectRegistry in project dbeaver by serge-rider.
the class NavigatorHandlerProjectSetActive 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 DBNProject)) {
return null;
}
DBNProject projectNode = (DBNProject) element;
final ProjectRegistry projectRegistry = DBeaverCore.getInstance().getProjectRegistry();
if (projectRegistry.getActiveProject() != projectNode.getProject()) {
projectRegistry.setActiveProject(projectNode.getProject());
}
}
return null;
}
use of org.jkiss.dbeaver.registry.ProjectRegistry in project dbeaver by serge-rider.
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;
final ProjectRegistry projectRegistry = DBeaverCore.getInstance().getProjectRegistry();
DBPResourceHandler handler = projectRegistry.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_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:
return resource instanceof IProject && resource != projectRegistry.getActiveProject();
case PROP_TYPE:
final DBPResourceHandler resourceHandler = DBeaverCore.getInstance().getProjectRegistry().getResourceHandler(resource);
return resourceHandler != null && expectedValue.equals(resourceHandler.getTypeName(resource));
}
return false;
}
use of org.jkiss.dbeaver.registry.ProjectRegistry in project dbeaver by serge-rider.
the class DBeaverCore method initialize.
private void initialize() {
long startTime = System.currentTimeMillis();
log.debug("Initialize Core...");
// Register properties adapter
this.workspace = ResourcesPlugin.getWorkspace();
this.localSystem = new OSDescriptor(Platform.getOS(), Platform.getOSArch());
QMUtils.initApplication(this);
this.queryManager = new QMControllerImpl();
this.qmLogWriter = new QMLogFileWriter();
this.queryManager.registerMetaListener(qmLogWriter);
// Init default network settings
Authenticator.setDefault(new GlobalProxyAuthenticator());
ProxySelector.setDefault(new GlobalProxySelector(ProxySelector.getDefault()));
this.certificateStorage = new DefaultCertificateStorage(new File(DBeaverActivator.getInstance().getStateLocation().toFile(), "security"));
// Init project registry
this.projectRegistry = new ProjectRegistry(workspace);
// Projects registry
initializeProjects();
// Navigator model
this.navigatorModel = new DBNModel(this);
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 KeepAliveJob().scheduleMonitor();
log.debug("Core initialized (" + (System.currentTimeMillis() - startTime) + "ms)");
}
Aggregations