下面列出了org.eclipse.ui.contexts.IContextService#activateContext ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void handleStateChange() {
boolean isActive = false;
for (IPyContextObserver obs : this.observers.getListeners()) {
if (obs.isPyContextActive()) {
isActive = true;
break;
}
}
IContextService contextService = (IContextService) PlatformUI.getWorkbench().getService(IContextService.class);
//May be null on shutdown on Eclipse 4.
if (contextService != null) {
if (isActive) {
if (activateContext == null) {
activateContext = contextService.activateContext("com.python.pydev.contexts.window");
}
} else {
if (activateContext != null) {
contextService.deactivateContext(activateContext);
}
activateContext = null;
}
}
}
@Override
protected void createControls(Composite composite) {
super.createControls(composite);
ICompareContainer container = getCompareConfiguration().getContainer();
IWorkbenchPart workbenchPart= container.getWorkbenchPart();
if (workbenchPart != null) {
IContextService service= workbenchPart.getSite().getService(IContextService.class);
if (service != null) {
service.activateContext(EditorSettings_Actual.EDITOR_CONTEXT_ID);
}
}
// TODO: activate Lang editor commands
// IHandlerService handlerSvc = container.getServiceLocator().getService(IHandlerService.class);
// handlerSvc.activateHandler(EditorCommandIds.OpenDef_ID, new OpenDefinitionHandler2());
}
/**
* Activate a context that this view uses. It will be tied to this view activation events and will be removed when
* the view is disposed.
*
*/
private void activateContext() {
IContextService contextService = getSite().getService(IContextService.class);
// this will get cleaned up automatically when the site
// is disposed
contextService.activateContext(VIEW_CONTEXT_ID);
}
@Override
protected void createControls(Composite composite) {
super.createControls(composite);
IWorkbenchPart workbenchPart = getCompareConfiguration().getContainer().getWorkbenchPart();
if (workbenchPart != null) {
IContextService service = workbenchPart.getSite().getService(IContextService.class);
if (service != null) {
service.activateContext("ts.eclipse.ide.jsdt.ui.typeScriptEditorScope"); //$NON-NLS-1$
}
}
}
/**
* Sets view part.
*
* @param viewSite The view part to set
*/
public void setSite(ViewPart viewSite) {
fSite = viewSite;
fSite.getSite().setSelectionProvider(fSelProvider);
Object serviceObject = fSite.getSite().getWorkbenchWindow().getService(IContextService.class);
IContextService service = (IContextService) serviceObject;
service.activateContext("org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"); //$NON-NLS-1$
service.activateContext(IContextIds.CONTEXT_ID_WINDOW);
}
@Override
protected void createControls(Composite composite) {
super.createControls(composite);
IWorkbenchPart workbenchPart = getCompareConfiguration().getContainer().getWorkbenchPart();
if (workbenchPart != null) {
IContextService service = (IContextService)workbenchPart.getSite().getService(IContextService.class);
if (service != null) {
service.activateContext("org.eclipse.jdt.ui.javaEditorScope"); //$NON-NLS-1$
}
}
}
@Override
public void createPartControl(Composite parent) {
// Open the context
final IContextService contextService = getSite().getService(IContextService.class);
contextService.activateContext(CONTEXT_ID);
// Overridden for setting the label provider, which is set in a private function in the super type.
super.createPartControl(parent);
internalResetLabelProvider();
restoreFilterAndSorter();
}
private void activateDesignerEditPart( )
{
IContextService contextService = (IContextService) PlatformUI.getWorkbench( )
.getService( IContextService.class );
if ( contextActivation == null )
contextActivation = contextService.activateContext( VIEW_CONTEXT_ID );
}
@Override
public void initialize(final IWorkbenchConfigurer configurer) {
super.initialize(configurer);
configurer.setSaveAndRestore(true);
final IContextService contextService = PlatformUI.getWorkbench().getService(IContextService.class);
contextService.activateContext("org.bonitasoft.studio.context.id");
initializeIDEImages(configurer);
}
private void activateContext() {
IContextService contextService = getService(IContextService.class);
if (contextService != null) {
contextActivation = contextService.activateContext(CONTEXT_ID);
}
}
/**
* Override standard 'Check for Updates' handler.
*/
public static void activateXdsUpdateContext() {
IContextService contextService = (IContextService) PlatformUI.getWorkbench().getService(IContextService.class);
activateContext = contextService.activateContext( XDS_UPDATE_CONTEXT );
}
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
super.init(site, input);
IContextService contextService = (IContextService) site.getService(IContextService.class);
contextService.activateContext(CONTEXT);
}
/**
* @see org.eclipse.ui.console.IConsolePageParticipant#activated()
*/
public void activated() {
IContextService contextService = (IContextService) PlatformUI.getWorkbench().getAdapter(IContextService.class);
fContextActivation = contextService.activateContext("org.eclipse.ui.textEditorScope"); //$NON-NLS-1$
((EmacsPlusConsole)console).onLine();
}