use of org.jkiss.dbeaver.model.app.DBPWorkspace 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;
}
use of org.jkiss.dbeaver.model.app.DBPWorkspace in project dbeaver by dbeaver.
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();
}
use of org.jkiss.dbeaver.model.app.DBPWorkspace in project dbeaver by dbeaver.
the class NavigatorHandlerObjectCreateNew method fillCreateMenuItems.
// If site is null then we need only item count. BAD CODE.
public static List<IContributionItem> fillCreateMenuItems(@Nullable IWorkbenchPartSite site, DBNNode node) {
List<IContributionItem> createActions = new ArrayList<>();
if (node instanceof DBNLocalFolder || node instanceof DBNProjectDatabases) {
IContributionItem item = makeCreateContributionItem(site, DBPDataSourceContainer.class.getName(), ModelMessages.model_navigator_Connection, UIIcon.SQL_NEW_CONNECTION, false);
createActions.add(item);
}
if (node instanceof DBNDatabaseNode) {
addDatabaseNodeCreateItems(site, createActions, (DBNDatabaseNode) node);
}
if (node instanceof DBNLocalFolder || node instanceof DBNProjectDatabases || node instanceof DBNDataSource) {
createActions.add(makeCommandContributionItem(site, NavigatorCommands.CMD_CREATE_LOCAL_FOLDER));
} else if (node instanceof DBNResource) {
final DBPWorkspace workspace = DBWorkbench.getPlatform().getWorkspace();
IResource resource = ((DBNResource) node).getResource();
if (resource instanceof IProject) {
createActions.add(makeCommandContributionItem(site, NavigatorCommands.CMD_CREATE_PROJECT));
}
DBPResourceHandler handler = workspace.getResourceHandler(resource);
if (handler instanceof DBPResourceCreator && (handler.getFeatures(resource) & DBPResourceCreator.FEATURE_CREATE_FILE) != 0) {
createActions.add(makeCommandContributionItem(site, NavigatorCommands.CMD_CREATE_RESOURCE_FILE));
}
if (handler != null && (handler.getFeatures(resource) & DBPResourceHandler.FEATURE_CREATE_FOLDER) != 0) {
createActions.add(makeCommandContributionItem(site, NavigatorCommands.CMD_CREATE_RESOURCE_FOLDER));
}
if (resource instanceof IContainer) {
createActions.add(makeCommandContributionItem(site, NavigatorCommands.CMD_CREATE_FILE_LINK));
createActions.add(makeCommandContributionItem(site, NavigatorCommands.CMD_CREATE_FOLDER_LINK));
}
}
if (site != null) {
if (!createActions.isEmpty() && !(createActions.get(createActions.size() - 1) instanceof Separator)) {
createActions.add(new Separator());
}
createActions.add(ActionUtils.makeCommandContribution(site, IWorkbenchCommandConstants.FILE_NEW, "Other ...", null));
}
return createActions;
}
use of org.jkiss.dbeaver.model.app.DBPWorkspace in project dbeaver by dbeaver.
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;
}
use of org.jkiss.dbeaver.model.app.DBPWorkspace in project dbeaver by dbeaver.
the class PrefPageProjectResourceSettings method performDefaults.
@Override
protected void performDefaults() {
resourceTable.removeAll();
DBPWorkspace workspace = DBWorkbench.getPlatform().getWorkspace();
for (DBPResourceHandlerDescriptor descriptor : workspace.getResourceHandlerDescriptors()) {
if (!descriptor.isManagable()) {
continue;
}
TableItem item = new TableItem(resourceTable, SWT.NONE);
item.setData(descriptor);
final DBPImage icon = descriptor.getIcon();
if (icon != null) {
item.setImage(DBeaverIcons.getImage(icon));
}
item.setText(0, descriptor.getName());
DBPProject projectMeta = getProjectMeta();
String defaultRoot = projectMeta == null ? null : descriptor.getDefaultRoot(projectMeta);
if (defaultRoot != null) {
item.setText(1, defaultRoot);
}
}
UIUtils.packColumns(resourceTable, true);
super.performDefaults();
}
Aggregations