/** * Set the manager to cache context id changes. * * @param cache * <code>true</code> to turn caching on, <code>false</code> * to turn caching off and send an event if necessary. * @since 3.3 */ private void setEventCaching(boolean cache) { if (caching == cache) { return; } caching = cache; boolean fireChange = activeContextsChange; Set<String> holdOldIds = (oldIds == null ? Collections.EMPTY_SET : oldIds); if (caching) { oldIds = new HashSet<>(activeContextIds); } else { oldIds = null; } activeContextsChange = false; if (!caching && fireChange) { fireContextManagerChanged(new ContextManagerEvent(this, null, false, true, holdOldIds)); } } }
/** * Set the manager to cache context id changes. * * @param cache * <code>true</code> to turn caching on, <code>false</code> * to turn caching off and send an event if necessary. * @since 3.3 */ private void setEventCaching(boolean cache) { if (caching == cache) { return; } caching = cache; boolean fireChange = activeContextsChange; Set<String> holdOldIds = (oldIds == null ? Collections.EMPTY_SET : oldIds); if (caching) { oldIds = new HashSet<>(activeContextIds); } else { oldIds = null; } activeContextsChange = false; if (!caching && fireChange) { fireContextManagerChanged(new ContextManagerEvent(this, null, false, true, holdOldIds)); } } }
/** * Set the manager to cache context id changes. * * @param cache * <code>true</code> to turn caching on, <code>false</code> * to turn caching off and send an event if necessary. * @since 3.3 */ private void setEventCaching(boolean cache) { if (caching == cache) { return; } caching = cache; boolean fireChange = activeContextsChange; Set<String> holdOldIds = (oldIds == null ? Collections.EMPTY_SET : oldIds); if (caching) { oldIds = new HashSet<>(activeContextIds); } else { oldIds = null; } activeContextsChange = false; if (!caching && fireChange) { fireContextManagerChanged(new ContextManagerEvent(this, null, false, true, holdOldIds)); } } }
/** * Activates a context in this context manager. * * @param contextId * The identifier of the context to activate; must not be * <code>null</code>. */ public final void addActiveContext(final String contextId) { if (activeContextIds.contains(contextId)) { return; } activeContextsChange = true; if (caching) { activeContextIds.add(contextId); } else { final Set<String> previouslyActiveContextIds = new HashSet<>(activeContextIds); activeContextIds.add(contextId); fireContextManagerChanged(new ContextManagerEvent(this, null, false, true, previouslyActiveContextIds)); } if (DEBUG) { Tracing.printTrace("CONTEXTS", activeContextIds.toString()); //$NON-NLS-1$ } }
/** * Activates a context in this context manager. * * @param contextId * The identifier of the context to activate; must not be * <code>null</code>. */ public final void addActiveContext(final String contextId) { if (activeContextIds.contains(contextId)) { return; } activeContextsChange = true; if (caching) { activeContextIds.add(contextId); } else { final Set<String> previouslyActiveContextIds = new HashSet<>(activeContextIds); activeContextIds.add(contextId); fireContextManagerChanged(new ContextManagerEvent(this, null, false, true, previouslyActiveContextIds)); } if (DEBUG) { Tracing.printTrace("CONTEXTS", activeContextIds.toString()); //$NON-NLS-1$ } }
/** * Activates a context in this context manager. * * @param contextId * The identifier of the context to activate; must not be * <code>null</code>. */ public final void addActiveContext(final String contextId) { if (activeContextIds.contains(contextId)) { return; } activeContextsChange = true; if (caching) { activeContextIds.add(contextId); } else { final Set<String> previouslyActiveContextIds = new HashSet<>(activeContextIds); activeContextIds.add(contextId); fireContextManagerChanged(new ContextManagerEvent(this, null, false, true, previouslyActiveContextIds)); } if (DEBUG) { Tracing.printTrace("CONTEXTS", activeContextIds.toString()); //$NON-NLS-1$ } }
/** * Deactivates a context in this context manager. * * @param contextId * The identifier of the context to deactivate; must not be * <code>null</code>. */ public final void removeActiveContext(final String contextId) { if (!activeContextIds.contains(contextId)) { return; } activeContextsChange = true; if (caching) { activeContextIds.remove(contextId); } else { final Set<String> previouslyActiveContextIds = new HashSet<>(activeContextIds); activeContextIds.remove(contextId); fireContextManagerChanged(new ContextManagerEvent(this, null, false, true, previouslyActiveContextIds)); } if (DEBUG) { Tracing.printTrace("CONTEXTS", activeContextIds.toString()); //$NON-NLS-1$ } }
/** * Deactivates a context in this context manager. * * @param contextId * The identifier of the context to deactivate; must not be * <code>null</code>. */ public final void removeActiveContext(final String contextId) { if (!activeContextIds.contains(contextId)) { return; } activeContextsChange = true; if (caching) { activeContextIds.remove(contextId); } else { final Set<String> previouslyActiveContextIds = new HashSet<>(activeContextIds); activeContextIds.remove(contextId); fireContextManagerChanged(new ContextManagerEvent(this, null, false, true, previouslyActiveContextIds)); } if (DEBUG) { Tracing.printTrace("CONTEXTS", activeContextIds.toString()); //$NON-NLS-1$ } }
/** * Deactivates a context in this context manager. * * @param contextId * The identifier of the context to deactivate; must not be * <code>null</code>. */ public final void removeActiveContext(final String contextId) { if (!activeContextIds.contains(contextId)) { return; } activeContextsChange = true; if (caching) { activeContextIds.remove(contextId); } else { final Set<String> previouslyActiveContextIds = new HashSet<>(activeContextIds); activeContextIds.remove(contextId); fireContextManagerChanged(new ContextManagerEvent(this, null, false, true, previouslyActiveContextIds)); } if (DEBUG) { Tracing.printTrace("CONTEXTS", activeContextIds.toString()); //$NON-NLS-1$ } }
/** * Changes the set of active contexts for this context manager. The whole * set is required so that internal consistency can be maintained and so * that excessive recomputations do nothing occur. * * @param activeContextIds * The new set of active context identifiers; may be * <code>null</code>. */ @SuppressWarnings("unchecked") public final void setActiveContextIds(@SuppressWarnings("rawtypes") final Set activeContextIds) { if (Util.equals(this.activeContextIds, activeContextIds)) { return; } activeContextsChange = true; final Set<String> previouslyActiveContextIds = this.activeContextIds; if (activeContextIds != null) { this.activeContextIds = new HashSet<>(); this.activeContextIds.addAll(activeContextIds); } else { this.activeContextIds = null; } if (DEBUG) { Tracing.printTrace("CONTEXTS", (activeContextIds == null) ? "none" //$NON-NLS-1$ //$NON-NLS-2$ : activeContextIds.toString()); } if (!caching) { fireContextManagerChanged(new ContextManagerEvent(this, null, false, true, previouslyActiveContextIds)); } }
/** * Changes the set of active contexts for this context manager. The whole * set is required so that internal consistency can be maintained and so * that excessive recomputations do nothing occur. * * @param activeContextIds * The new set of active context identifiers; may be * <code>null</code>. */ @SuppressWarnings("unchecked") public final void setActiveContextIds(@SuppressWarnings("rawtypes") final Set activeContextIds) { if (Util.equals(this.activeContextIds, activeContextIds)) { return; } activeContextsChange = true; final Set<String> previouslyActiveContextIds = this.activeContextIds; if (activeContextIds != null) { this.activeContextIds = new HashSet<>(); this.activeContextIds.addAll(activeContextIds); } else { this.activeContextIds = null; } if (DEBUG) { Tracing.printTrace("CONTEXTS", (activeContextIds == null) ? "none" //$NON-NLS-1$ //$NON-NLS-2$ : activeContextIds.toString()); } if (!caching) { fireContextManagerChanged(new ContextManagerEvent(this, null, false, true, previouslyActiveContextIds)); } }
/** * Changes the set of active contexts for this context manager. The whole * set is required so that internal consistency can be maintained and so * that excessive recomputations do nothing occur. * * @param activeContextIds * The new set of active context identifiers; may be * <code>null</code>. */ @SuppressWarnings("unchecked") public final void setActiveContextIds(@SuppressWarnings("rawtypes") final Set activeContextIds) { if (Util.equals(this.activeContextIds, activeContextIds)) { return; } activeContextsChange = true; final Set<String> previouslyActiveContextIds = this.activeContextIds; if (activeContextIds != null) { this.activeContextIds = new HashSet<>(); this.activeContextIds.addAll(activeContextIds); } else { this.activeContextIds = null; } if (DEBUG) { Tracing.printTrace("CONTEXTS", (activeContextIds == null) ? "none" //$NON-NLS-1$ //$NON-NLS-2$ : activeContextIds.toString()); } if (!caching) { fireContextManagerChanged(new ContextManagerEvent(this, null, false, true, previouslyActiveContextIds)); } }
@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)); } } }
@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)); } } }
@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)); } } }