KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > contexts > SuspendTriggerAdapterFactory


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

11 package org.eclipse.debug.internal.ui.contexts;
12
13 import java.util.HashMap JavaDoc;
14 import java.util.Map JavaDoc;
15
16 import org.eclipse.core.runtime.IAdapterFactory;
17 import org.eclipse.debug.core.ILaunch;
18 import org.eclipse.debug.ui.contexts.ISuspendTrigger;
19
20 /**
21  * @since 3.2
22  */

23 public class SuspendTriggerAdapterFactory implements IAdapterFactory {
24     
25     private Map JavaDoc fSuspendTriggers = new HashMap JavaDoc();
26
27     /* (non-Javadoc)
28      * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
29      */

30     public synchronized Object JavaDoc getAdapter(Object JavaDoc adaptableObject, Class JavaDoc adapterType) {
31         if (adapterType.equals(ISuspendTrigger.class)) {
32             if (adaptableObject instanceof ILaunch) {
33                 Object JavaDoc trigger = fSuspendTriggers.get(adaptableObject);
34                 if (trigger == null) {
35                     trigger = new LaunchSuspendTrigger((ILaunch) adaptableObject, this);
36                     fSuspendTriggers.put(adaptableObject, trigger);
37                 }
38                 return trigger;
39             }
40         }
41         return null;
42     }
43
44     /* (non-Javadoc)
45      * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
46      */

47     public Class JavaDoc[] getAdapterList() {
48         return new Class JavaDoc[]{ISuspendTrigger.class};
49     }
50     
51     public synchronized void dispose(LaunchSuspendTrigger trigger) {
52         fSuspendTriggers.remove(trigger.getLaunch());
53     }
54
55 }
56
Popular Tags