@Override public String getId() { return wrappedContext.getId(); }
private int getLevel(Context c) { int l = 0; try { String parentId = c.getParentId(); while (parentId != null) { l++; Context context = manager.getContext(parentId); parentId = context.getParentId(); } } catch (NotDefinedException e) { // ignore } return l; } }
/** * Adds an action set. * @param desc */ private void addActionSet(ActionSetDescriptor desc) { children.add(desc); Context actionSetContext = contextService.getContext(desc.getId()); if (!actionSetContext.isDefined()) { actionSetContext.define(desc.getLabel(), desc.getDescription(), "org.eclipse.ui.contexts.actionSet"); //$NON-NLS-1$ } }
/** * Gets the context with the given identifier. If no such context currently * exists, then the context will be created (but be undefined). * * @param contextId * The identifier to find; must not be <code>null</code>. * @return The context with the given identifier; this value will never be * <code>null</code>, but it might be undefined. * @see Context */ public final Context getContext(final String contextId) { checkId(contextId); Context context = (Context) handleObjectsById.get(contextId); if (context == null) { context = new Context(contextId); handleObjectsById.put(contextId, context); context.addContextListener(this); } return context; }
Context context = contextManager.getContext(contextId); try { String parentId = context.getParentId(); while (parentId != null) { if (IContextIds.CONTEXT_ID_DIALOG.equals(parentId)) { parentId = context.getParentId(); if (context == null || !bindingErrors.contains(context.getId())) { if (context != null) { bindingErrors.add(context.getId());
@Override public final void contextChanged(final ContextEvent contextEvent) { if (contextEvent.isDefinedChanged()) { final Context context = contextEvent.getContext(); final String contextId = context.getId(); final boolean contextIdAdded = context.isDefined(); if (contextIdAdded) { definedHandleObjects.add(context); } else { definedHandleObjects.remove(context); } if (isListenerAttached()) { fireContextManagerChanged(new ContextManagerEvent(this, contextId, contextIdAdded, false, null)); } } }
for (Context ctx : contextManager.getDefinedContexts()) { try { MBindingContext contextModel = contexts.get(ctx.getId()); if (contextModel == null) { contextModel = CommandsFactoryImpl.eINSTANCE.createBindingContext(); contexts.put(ctx.getId(), contextModel); contextModel.setElementId(ctx.getId()); contextModel.setName(ctx.getName()); contextModel.setDescription(ctx.getDescription()); MBindingContext contextModel = contexts.get(ctx.getId()); String parentId = ctx.getParentId(); if (parentId == null) { if (!application.getRootContext().contains(contextModel)) { if (parentContextModel == null) { System.err.println("Could not find parent " + parentId + " for child " //$NON-NLS-1$ //$NON-NLS-2$ + ctx.getId()); } else { if (!parentContextModel.getChildren().contains(contextModel)) {
/** * Updates the label next to the context that says "extends" if the context * is a child of another context. If the context is not a child of another * context, then the label is simply blank. */ private void updateLabelContextExtends() { final String contextId = getContextId(); if (contextId != null) { final Context context = contextService.getContext(getContextId()); if (context.isDefined()) { try { final String parentId = context.getParentId(); if (parentId != null) { final String name = (String) contextUniqueNamesById .get(parentId); if (name != null) { labelContextExtends.setText(MessageFormat.format( Util.translateString(RESOURCE_BUNDLE, "extends"), //$NON-NLS-1$ name)); return; } } } catch (final NotDefinedException e) { // Do nothing } } } labelContextExtends.setText(Util.ZERO_LENGTH_STRING); }
public void init(Context context) { setId(context.getId()); setModelObject(context); try { setName(context.getName()); setDescription(context.getDescription()); } catch (NotDefinedException e) { } } }
.next()); try { String name = context.getName(); Collection contexts = (Collection) contextsByName.get(name); contextIdsByUniqueName.put(name, context.getId()); contextUniqueNamesById.put(context.getId(), name); } else { while (iterator2.hasNext()) { String uniqueName = MessageFormat.format( Util.translateString(RESOURCE_BUNDLE, "uniqueName"), //$NON-NLS-1$ name, context.getId()); contextIdsByUniqueName.put(uniqueName, context.getId()); contextUniqueNamesById.put(context.getId(), uniqueName);
@Override public boolean isDefined() { return wrappedContext.isDefined(); }
/** * Makes this context become undefined. This has the side effect of changing * the name, description and parent identifier to <code>null</code>. * Notification is sent to all listeners. */ @Override public final void undefine() { string = null; final boolean definedChanged = defined; defined = false; final boolean nameChanged = name != null; name = null; final boolean descriptionChanged = description != null; description = null; final boolean parentIdChanged = parentId != null; parentId = null; fireContextChanged(new ContextEvent(this, definedChanged, nameChanged, descriptionChanged, parentIdChanged)); } }
@Override public void addContextListener(IContextListener contextListener) { final LegacyContextListenerWrapper wrapper = new LegacyContextListenerWrapper( contextListener, contextManager, this); wrappedContext.addContextListener(wrapper); /* * We need to add the listener to the context manager as well, as only * the manager advertises changes to the enabled state. */ contextManager.addContextManagerListener(wrapper); }
Context context = contextManager.getContext(contextId); try { String parentId = context.getParentId(); while (parentId != null) { if (IContextIds.CONTEXT_ID_DIALOG.equals(parentId)) { parentId = context.getParentId(); if (context == null || !bindingErrors.contains(context.getId())) { if (context != null) { bindingErrors.add(context.getId());
@Override public final void contextChanged(final ContextEvent contextEvent) { if (contextEvent.isDefinedChanged()) { final Context context = contextEvent.getContext(); final String contextId = context.getId(); final boolean contextIdAdded = context.isDefined(); if (contextIdAdded) { definedHandleObjects.add(context); } else { definedHandleObjects.remove(context); } if (isListenerAttached()) { fireContextManagerChanged(new ContextManagerEvent(this, contextId, contextIdAdded, false, null)); } } }