KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > contexts > ProxyContextManager


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.internal.contexts;
13
14 import java.util.SortedSet JavaDoc;
15
16 import org.eclipse.ui.contexts.ContextManagerEvent;
17 import org.eclipse.ui.contexts.IContext;
18 import org.eclipse.ui.contexts.IContextManager;
19 import org.eclipse.ui.contexts.IContextManagerListener;
20
21 public final class ProxyContextManager extends AbstractContextManager {
22     private IContextManager contextManager;
23
24     public ProxyContextManager(IContextManager contextManager) {
25         if (contextManager == null)
26             throw new NullPointerException JavaDoc();
27
28         this.contextManager = contextManager;
29
30         this
31             .contextManager
32             .addContextManagerListener(new IContextManagerListener() {
33             public void contextManagerChanged(ContextManagerEvent contextManagerEvent) {
34                 ContextManagerEvent proxyContextManagerEvent =
35                     new ContextManagerEvent(
36                         ProxyContextManager.this,
37                         contextManagerEvent.haveDefinedContextIdsChanged(),
38                         contextManagerEvent.haveEnabledContextIdsChanged(),
39                         contextManagerEvent.getPreviouslyDefinedContextIds(),
40                         contextManagerEvent.getPreviouslyEnabledContextIds());
41                 fireContextManagerChanged(proxyContextManagerEvent);
42             }
43         });
44     }
45
46     public IContext getContext(String JavaDoc contextId) {
47         return contextManager.getContext(contextId);
48     }
49
50     public SortedSet JavaDoc getDefinedContextIds() {
51         return contextManager.getDefinedContextIds();
52     }
53
54     public SortedSet JavaDoc getEnabledContextIds() {
55         return contextManager.getEnabledContextIds();
56     }
57 }
58
Popular Tags