use of org.jkiss.dbeaver.ui.actions.datasource.DataSourceToolbarHandler in project dbeaver by dbeaver.
the class WorkbenchContextListener method listenWindowEvents.
private void listenWindowEvents(IWorkbenchWindow window) {
{
// Register ds toolbar handler
DataSourceToolbarHandler toolbarHandler = new DataSourceToolbarHandler(window);
window.getShell().addDisposeListener(e -> toolbarHandler.dispose());
}
IPerspectiveListener perspectiveListener = new IPerspectiveListener() {
private IContextActivation perspectiveActivation;
@Override
public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
IContextService contextService = PlatformUI.getWorkbench().getService(IContextService.class);
if (contextService == null) {
return;
}
if (perspective.getId().equals(DBeaverPerspective.PERSPECTIVE_ID)) {
perspectiveActivation = contextService.activateContext(PERSPECTIVE_CONTEXT_ID);
} else if (perspectiveActivation != null) {
contextService.deactivateContext(perspectiveActivation);
perspectiveActivation = null;
}
}
@Override
public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) {
}
};
window.addPerspectiveListener(perspectiveListener);
IWorkbenchPage activePage = window.getActivePage();
if (activePage != null) {
perspectiveListener.perspectiveActivated(activePage, activePage.getPerspective());
}
window.addPageListener(this);
for (IWorkbenchPage page : window.getPages()) {
page.addPartListener(this);
}
}
use of org.jkiss.dbeaver.ui.actions.datasource.DataSourceToolbarHandler in project dbeaver by serge-rider.
the class WorkbenchContextListener method listenWindowEvents.
private void listenWindowEvents(IWorkbenchWindow window) {
{
// Register ds toolbar handler
DataSourceToolbarHandler toolbarHandler = new DataSourceToolbarHandler(window);
window.getShell().addDisposeListener(e -> toolbarHandler.dispose());
}
IPerspectiveListener perspectiveListener = new IPerspectiveListener() {
private IContextActivation perspectiveActivation;
@Override
public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
IContextService contextService = PlatformUI.getWorkbench().getService(IContextService.class);
if (contextService == null) {
return;
}
if (perspective.getId().equals(DBeaverPerspective.PERSPECTIVE_ID)) {
perspectiveActivation = contextService.activateContext(PERSPECTIVE_CONTEXT_ID);
} else if (perspectiveActivation != null) {
contextService.deactivateContext(perspectiveActivation);
perspectiveActivation = null;
}
}
@Override
public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) {
}
};
window.addPerspectiveListener(perspectiveListener);
IWorkbenchPage activePage = window.getActivePage();
if (activePage != null) {
perspectiveListener.perspectiveActivated(activePage, activePage.getPerspective());
}
window.addPageListener(this);
for (IWorkbenchPage page : window.getPages()) {
page.addPartListener(this);
}
}
Aggregations