1 /*******************************************************************************
2  * Copyright (c) 2000, 2015 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.jdt.internal.debug.ui.actions;
15 
16 import org.eclipse.core.runtime.IAdapterFactory;
17 import org.eclipse.debug.ui.actions.IRunToLineTarget;
18 import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
19 
20 /**
21  * Creates adapters for retargettable actions in debug platform.
22  * Contributed via <code>org.eclipse.core.runtime.adapters</code>
23  * extension point.
24  *
25  * @since 3.0
26  */
27 public class RetargettableActionAdapterFactory implements IAdapterFactory {
28 	/* (non-Javadoc)
29 	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
30 	 */
31 	@Override
32 	@SuppressWarnings("unchecked")
getAdapter(Object adaptableObject, Class<T> adapterType)33 	public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
34 		if (adapterType == IRunToLineTarget.class) {
35 			return (T) new RunToLineAdapter();
36 		}
37 		if (adapterType == IToggleBreakpointsTarget.class) {
38 			return (T) new ToggleBreakpointAdapter();
39 		}
40 		return null;
41 	}
42 	/* (non-Javadoc)
43 	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
44 	 */
45 	@Override
getAdapterList()46 	public Class<?>[] getAdapterList() {
47 		return new Class[]{IRunToLineTarget.class, IToggleBreakpointsTarget.class};
48 	}
49 }
50