private String describe(IEclipseContext context) { StringBuilder sb = new StringBuilder("\n\tcontext chain: "); //$NON-NLS-1$ IEclipseContext activeContext = context; IEclipseContext child = context.getActiveChild(); while (child != null) { sb.append(activeContext).append(" -> "); //$NON-NLS-1$ activeContext = child; child = child.getActiveChild(); } sb.append(activeContext); return sb.toString(); }
@Override public IEclipseContext getActiveLeaf() { IEclipseContext activeContext = this; IEclipseContext child = getActiveChild(); while (child != null) { activeContext = child; child = child.getActiveChild(); } return activeContext; }
private EPartService getActiveWindowService() { IEclipseContext activeWindowContext = application.getContext().getActiveChild(); if (activeWindowContext == null) { throw new IllegalStateException("Application does not have an active window"); //$NON-NLS-1$ } EPartService activeWindowPartService = activeWindowContext.get(EPartService.class); if (activeWindowPartService == null) { throw new IllegalStateException("Active window context is invalid"); //$NON-NLS-1$ } if (activeWindowPartService == this) { throw new IllegalStateException("Application does not have an active window"); //$NON-NLS-1$ } return activeWindowPartService; }
@Override public Object compute(IEclipseContext context, String contextKey) { IEclipseContext childContext = context.getActiveChild(); if (childContext != null) { return childContext.get(var); } return context.get(localVar); }
@Override public boolean changed(IEclipseContext context) { IEclipseContext activeChildContext = context.getActiveChild(); if (activeChildContext != null) { Object selection = activeChildContext.get(IServiceConstants.ACTIVE_SELECTION); theContext.set(IServiceConstants.ACTIVE_SELECTION, selection); } return true; } });
private boolean isActiveChild(MPart part) { IEclipseContext context = part.getContext(); return context != null && context.getParent().getActiveChild() == context; }
private void internalFixContext(MPart part, MUIElement oldSelectedElement) { if (oldSelectedElement == null) { return; } MContext parentPart = getParentWithContext(oldSelectedElement); if (parentPart == null) { // technically this shouldn't happen as there should be an MWindow somewhere return; } IEclipseContext parentContext = parentPart.getContext(); IEclipseContext oldContext = getSubContext(oldSelectedElement); Object child = parentContext.getActiveChild(); if (child == null || oldContext == null || child == oldContext) { if (part == null) { // TBD this should not be necessary; deactivation is missing somewhere IEclipseContext currentActive = parentContext.getActiveChild(); if (currentActive != null) currentActive.deactivate(); } else part.getContext().activate(); } }
public void showPopup(final Event event, final Menu menu, final MPopupMenu menuModel) { // System.err.println("showPopup: " + menuModel + "\n\t" + menu); // we need some context foolery here final IEclipseContext popupContext = menuModel.getContext(); final IEclipseContext parentContext = popupContext.getParent(); final IEclipseContext originalChild = parentContext.getActiveChild(); popupContext.activate(); popupContext.set(TMP_ORIGINAL_CONTEXT, originalChild); }
private void showPopup(final Menu menu, final MPopupMenu menuModel, MenuManager menuManager) { // System.err.println("showPopup: " + menuModel + "\n\t" + menu); // we need some context foolery here final IEclipseContext popupContext = menuModel.getContext(); final IEclipseContext parentContext = popupContext.getParent(); final IEclipseContext originalChild = parentContext.getActiveChild(); popupContext.activate(); popupContext.set(MenuManagerRendererFilter.TMP_ORIGINAL_CONTEXT, originalChild); }
public void showPopup(final Event event, final Menu menu, final MPopupMenu menuModel) { // System.err.println("showPopup: " + menuModel + "\n\t" + menu); // we need some context foolery here final IEclipseContext popupContext = menuModel.getContext(); final IEclipseContext parentContext = popupContext.getParent(); final IEclipseContext originalChild = parentContext.getActiveChild(); popupContext.activate(); popupContext.set(TMP_ORIGINAL_CONTEXT, originalChild); }
private void showPopup(final Menu menu, final MPopupMenu menuModel, MenuManager menuManager) { // System.err.println("showPopup: " + menuModel + "\n\t" + menu); // we need some context foolery here final IEclipseContext popupContext = menuModel.getContext(); final IEclipseContext parentContext = popupContext.getParent(); final IEclipseContext originalChild = parentContext.getActiveChild(); popupContext.activate(); popupContext.set(MenuManagerRendererFilter.TMP_ORIGINAL_CONTEXT, originalChild); }
private static void clearContext(MContext contextME) { MContext ctxt = (MContext) contextME; IEclipseContext lclContext = ctxt.getContext(); if (lclContext != null) { IEclipseContext parentContext = lclContext.getParent(); if (parentContext != null) { IEclipseContext child = parentContext.getActiveChild(); if (child == lclContext) { child.deactivate(); } } else { System.err.println("Strange: " + lclContext + " has no parent!"); //$NON-NLS-1$//$NON-NLS-2$ } ctxt.setContext(null); lclContext.dispose(); } }
private boolean shouldActivate(@NonNull MPartStack stackToActivate) { if (inContentProcessing(stackToActivate)) { return false; } if (this.application != null) { IEclipseContext applicationContext = this.application.getContext(); IEclipseContext activeChild = applicationContext.getActiveChild(); if (activeChild == null || activeChild.get(MWindow.class) != this.application.getSelectedElement() || this.application.getSelectedElement() != this.modelService.getTopLevelWindowFor(stackToActivate)) { return false; } } return true; }
/** * Updates the selection of the workbench window with that of the active * part's. * * @param activePart * the currently active part */ public void updateSelection(IWorkbenchPart activePart) { if (activePart != null) { ISelectionProvider selectionProvider = activePart.getSite().getSelectionProvider(); if (selectionProvider != null) { ISelection selection = selectionProvider.getSelection(); context.set(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection); IEclipseContext applicationContext = application.getContext(); if (applicationContext.getActiveChild() == context) { application.getContext().set(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection); } } } }
private void handleSelectionChanged(MPart part, Object selection, boolean targeted) { selection = createCompatibilitySelection(selection); context.set(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection); IEclipseContext applicationContext = application.getContext(); if (applicationContext.getActiveChild() == context) { application.getContext().set(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection); } Object client = part.getObject(); if (client instanceof CompatibilityPart) { IWorkbenchPart workbenchPart = ((CompatibilityPart) client).getPart(); if (targeted) { notifyListeners(workbenchPart, (ISelection) selection, part.getElementId(), targetedListeners); } else { notifyListeners(workbenchPart, (ISelection) selection, listeners); } } else if (client != null) { if (part.getTransientData().get(E4PartWrapper.E4_WRAPPER_KEY) instanceof E4PartWrapper) { IWorkbenchPart workbenchPart = (IWorkbenchPart) part.getTransientData() .get(E4PartWrapper.E4_WRAPPER_KEY); if (targeted) { notifyListeners(workbenchPart, (ISelection) selection, part.getElementId(), targetedListeners); } else { notifyListeners(workbenchPart, (ISelection) selection, listeners); } } } }
if (curContext.getActiveChild() == theContext) { theContext.deactivate(); if (curContext.getActiveChild() == theContext) { theContext.deactivate();
if (curContext.getActiveChild() == theContext) { theContext.deactivate(); if (curContext.getActiveChild() == theContext) { theContext.deactivate();
IEclipseContext windowContext = window.getContext(); if (windowContext.getParent().getActiveChild() == windowContext && part == activePart) {
&& partActivationHistory.isValid(perspective, activePart)) { MPart target = activePart; IEclipseContext activeChild = activePart.getContext().getParent().getActiveChild(); if (activeChild != null) { activeChild.deactivate();