use of org.eclipse.ui.internal.services.IWorkbenchLocationService in project eclipse.platform.ui by eclipse-platform.
the class CommandServiceFactory method create.
@Override
public Object create(Class serviceInterface, IServiceLocator parentLocator, IServiceLocator locator) {
if (!ICommandService.class.equals(serviceInterface)) {
return null;
}
IWorkbenchLocationService wls = locator.getService(IWorkbenchLocationService.class);
final IWorkbench wb = wls.getWorkbench();
if (wb == null) {
return null;
}
Object parent = parentLocator.getService(serviceInterface);
if (parent == null) {
// we are registering the global services in the Workbench
return null;
}
final IWorkbenchWindow window = wls.getWorkbenchWindow();
final IWorkbenchPartSite site = wls.getPartSite();
if (site == null) {
return new SlaveCommandService((ICommandService) parent, IServiceScopes.WINDOW_SCOPE, window);
}
if (parent instanceof SlaveCommandService) {
IServiceLocator pageSite = wls.getPageSite();
if (pageSite != null) {
MContext context = pageSite.getService(MContext.class);
if (context == null) {
return new SlaveCommandService((ICommandService) parent, IServiceScopes.PAGESITE_SCOPE, pageSite);
}
return new SlaveCommandService((ICommandService) parent, IServiceScopes.PAGESITE_SCOPE, pageSite, context.getContext());
}
IServiceLocator mpepSite = wls.getMultiPageEditorSite();
if (mpepSite != null) {
MContext context = mpepSite.getService(MContext.class);
if (context == null) {
return new SlaveCommandService((ICommandService) parent, IServiceScopes.MPESITE_SCOPE, mpepSite);
}
return new SlaveCommandService((ICommandService) parent, IServiceScopes.MPESITE_SCOPE, mpepSite, context.getContext());
}
}
return new SlaveCommandService((ICommandService) parent, IServiceScopes.PARTSITE_SCOPE, site);
}
use of org.eclipse.ui.internal.services.IWorkbenchLocationService in project eclipse.platform.ui by eclipse-platform.
the class ContextServiceFactory method create.
@Override
public Object create(Class serviceInterface, IServiceLocator parentLocator, IServiceLocator locator) {
if (!IContextService.class.equals(serviceInterface)) {
return null;
}
IWorkbenchLocationService wls = locator.getService(IWorkbenchLocationService.class);
final IWorkbench wb = wls.getWorkbench();
if (wb == null) {
return null;
}
Object parent = parentLocator.getService(serviceInterface);
if (parent == null) {
// we are registering the global services in the Workbench
return null;
}
final IWorkbenchWindow window = wls.getWorkbenchWindow();
final IWorkbenchPartSite site = wls.getPartSite();
if (site == null) {
Expression exp = new WorkbenchWindowExpression(window);
return new SlaveContextService((IContextService) parent, exp);
}
if (parent instanceof SlaveContextService) {
Expression exp = ((SlaveContextService) parent).fDefaultExpression;
if (exp instanceof ActivePartExpression) {
return new NestableContextService((IContextService) parent, exp);
}
}
Expression exp = new ActivePartExpression(site.getPart());
return new SlaveContextService((IContextService) parent, exp);
}
use of org.eclipse.ui.internal.services.IWorkbenchLocationService in project eclipse.platform.ui by eclipse-platform.
the class WorkbenchMenuService method getWindow.
protected IWorkbenchWindow getWindow() {
if (serviceLocator == null)
return null;
IWorkbenchLocationService wls = serviceLocator.getService(IWorkbenchLocationService.class);
IWorkbenchWindow window = null;
if (window == null) {
window = wls.getWorkbenchWindow();
}
if (window == null) {
IWorkbench wb = wls.getWorkbench();
if (wb != null) {
window = wb.getActiveWorkbenchWindow();
}
}
if (window == null) {
window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
}
return window;
}
use of org.eclipse.ui.internal.services.IWorkbenchLocationService in project eclipse.platform.ui by eclipse-platform.
the class WorkbenchSupportFactory method create.
@Override
public Object create(Class serviceInterface, IServiceLocator parentLocator, IServiceLocator locator) {
IWorkbenchLocationService wls = locator.getService(IWorkbenchLocationService.class);
final IWorkbench wb = wls.getWorkbench();
if (wb == null) {
return null;
}
final IWorkbenchWindow window = wls.getWorkbenchWindow();
final IWorkbenchPartSite site = wls.getPartSite();
Object parent = parentLocator.getService(serviceInterface);
if (parent == null) {
// return top level services
if (IProgressService.class.equals(serviceInterface)) {
return wb.getProgressService();
}
if (IWorkbenchSiteProgressService.class.equals(serviceInterface)) {
if (site instanceof PartSite) {
return ((PartSite) site).getSiteProgressService();
}
}
if (IPartService.class.equals(serviceInterface)) {
if (window != null) {
return window.getPartService();
}
}
if (IPageService.class.equals(serviceInterface)) {
if (window != null) {
return window;
}
}
if (ISelectionService.class.equals(serviceInterface)) {
if (window != null) {
return window.getSelectionService();
}
}
return null;
}
if (ISelectionService.class.equals(serviceInterface)) {
return new SlaveSelectionService((ISelectionService) parent);
}
if (IProgressService.class.equals(serviceInterface)) {
if (site instanceof PartSite) {
return ((PartSite) site).getSiteProgressService();
}
}
if (IPartService.class.equals(serviceInterface)) {
return new SlavePartService((IPartService) parent);
}
if (IPageService.class.equals(serviceInterface)) {
return new SlavePageService((IPageService) parent);
}
return null;
}
use of org.eclipse.ui.internal.services.IWorkbenchLocationService in project eclipse.platform.ui by eclipse-platform.
the class ToggleCoolbarHandler method updateElement.
@Override
public void updateElement(UIElement element, Map parameters) {
IWorkbenchLocationService wls = element.getServiceLocator().getService(IWorkbenchLocationService.class);
IWorkbenchWindow window = wls.getWorkbenchWindow();
if (window == null || !(window instanceof WorkbenchWindow))
return;
element.setText(isCoolbarVisible((WorkbenchWindow) window) ? WorkbenchMessages.ToggleCoolbarVisibilityAction_hide_text : WorkbenchMessages.ToggleCoolbarVisibilityAction_show_text);
}
Aggregations