use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by serge-rider.
the class DBNModel method resourceChanged.
@Override
public void resourceChanged(IResourceChangeEvent event) {
if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
IResourceDelta delta = event.getDelta();
for (IResourceDelta childDelta : delta.getAffectedChildren()) {
if (childDelta.getResource() instanceof IProject) {
IProject project = (IProject) childDelta.getResource();
DBNProject projectNode = getRoot().getProjectNode(project);
if (projectNode == null) {
if (childDelta.getKind() == IResourceDelta.ADDED) {
// New projectNode
DBPProject projectMeta = platform.getWorkspace().getProject(project);
if (projectMeta == null) {
log.error("Can't find project '" + project.getName() + "' metadata");
} else {
getRoot().addProject(projectMeta, true);
}
} else if (childDelta.getKind() != IResourceDelta.REMOVED) {
// Project not found - report an error
log.error("Project '" + childDelta.getResource().getName() + "' not found in navigator");
}
} else {
if (childDelta.getKind() == IResourceDelta.REMOVED) {
// Project deleted
DBPProject projectMeta = platform.getWorkspace().getProject(project);
if (projectMeta == null) {
log.error("Can't find project '" + project.getName() + "' metadata");
} else {
getRoot().removeProject(projectMeta);
}
} else {
// Some resource changed within the projectNode
// Let it handle this event itself
projectNode.handleResourceChange(childDelta);
}
}
}
}
}
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by serge-rider.
the class RecentTasksMenuContributor method fillContributionItems.
@Override
protected void fillContributionItems(final List<IContributionItem> menuItems) {
DBPProject project = NavigatorUtils.getSelectedProject();
if (project == null) {
return;
}
DBTTask[] tasks = project.getTaskManager().getAllTasks();
Arrays.sort(tasks, (o1, o2) -> {
DBTTaskRun lr1 = o1.getLastRun();
DBTTaskRun lr2 = o1.getLastRun();
if (lr1 == lr2)
return o1.getCreateTime().compareTo(o2.getCreateTime());
else if (lr1 == null)
return -1;
else if (lr2 == null)
return 1;
else
return lr1.getStartTime().compareTo(lr2.getStartTime());
});
for (int i = 0; i < tasks.length && i <= MAX_ITEMS; i++) {
DBTTask task = tasks[i];
DBPImage taskIcon = task.getType().getIcon();
if (taskIcon == null)
taskIcon = DBIcon.TREE_TASK;
menuItems.add(ActionUtils.makeActionContribution(new Action(task.getName(), DBeaverIcons.getImageDescriptor(taskIcon)) {
@Override
public void run() {
TaskHandlerRun.runTask(task);
}
}, false));
}
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by serge-rider.
the class DatabaseTasksTree method refreshTasks.
private void refreshTasks() {
allTasks.clear();
for (DBPProject project : DBWorkbench.getPlatform().getWorkspace().getProjects()) {
DBTTaskManager taskManager = project.getTaskManager();
DBTTask[] tasks = taskManager.getAllTasks();
if (tasks.length == 0) {
continue;
}
Collections.addAll(allTasks, tasks);
}
allTasks.sort(Comparator.comparing(DBTTask::getName));
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by serge-rider.
the class DBUtils method getAllRegistries.
public static List<DBPDataSourceRegistry> getAllRegistries(boolean forceLoad) {
List<DBPDataSourceRegistry> result = new ArrayList<>();
for (DBPProject project : DBWorkbench.getPlatform().getWorkspace().getProjects()) {
if (forceLoad || (project.isOpen() && project.isRegistryLoaded())) {
project.ensureOpen();
DBPDataSourceRegistry registry = project.getDataSourceRegistry();
if (registry != null) {
result.add(registry);
}
}
}
return result;
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by serge-rider.
the class ResultSetViewer method dispose.
// //////////////////////////////////////////////////////////
// Misc
private void dispose() {
if (themeChangeListener != null) {
PlatformUI.getWorkbench().getThemeManager().removePropertyChangeListener(themeChangeListener);
themeChangeListener = null;
}
DBWorkbench.getPlatform().getDataSourceProviderRegistry().getGlobalDataSourcePreferenceStore().removePropertyChangeListener(dataPropertyListener);
DBWorkbench.getPlatform().getPreferenceStore().removePropertyChangeListener(dataPropertyListener);
if (activePresentation != null) {
activePresentation.dispose();
}
DBPProject project = container.getProject();
if (project != null) {
project.getDataSourceRegistry().removeDataSourceListener(this);
}
savePresentationSettings();
clearData();
for (ToolBarManager tb : toolbarList) {
try {
tb.dispose();
} catch (Throwable e) {
// ignore
log.debug("Error disposing toolbar " + tb, e);
}
}
toolbarList.clear();
UIUtils.dispose(this.sizingGC);
}
Aggregations