Skip to main content
summaryrefslogtreecommitdiffstats
blob: 440077c229493d14fbd1666ca1c856ef96a497b5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*******************************************************************************
 * Copyright (c) 2009 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * IBM Corporation - Initial API and implementation
 *******************************************************************************/
package org.eclipse.ptp.services.internal.ui.adapters;

import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.ptp.services.core.IServiceConfiguration;
import org.eclipse.ptp.services.core.IServiceModelManager;
import org.eclipse.ptp.services.core.IServiceProvider;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.model.IWorkbenchAdapter2;

public class ServiceModelWorkbenchAdapterFactory implements IAdapterFactory {

	private static final ServiceModelWorkbenchAdapter SERVICE_MODEL_WORKBENCH_ADAPTER =
		new ServiceModelWorkbenchAdapter();
	private static final ServiceConfigurationWorkbenchAdapter SERVICE_CONFIGURATION_WORKBENCH_ADAPTER =
		new ServiceConfigurationWorkbenchAdapter();
	private static final ServiceProviderWorkbenchAdapter SERVICE_PROVIDER_WORKBENCH_ADAPTER =
		new ServiceProviderWorkbenchAdapter();

	public Object getAdapter(Object adaptableObject, 
			@SuppressWarnings("unchecked") Class adapterType) {
		if (adapterType == IWorkbenchAdapter.class || adapterType == IWorkbenchAdapter2.class) {
			if (adaptableObject instanceof IServiceModelManager) {
				return SERVICE_MODEL_WORKBENCH_ADAPTER;
			}
			if (adaptableObject instanceof IServiceConfiguration) {
				return SERVICE_CONFIGURATION_WORKBENCH_ADAPTER;
			}
			if (adaptableObject instanceof IServiceProvider) {
				return SERVICE_PROVIDER_WORKBENCH_ADAPTER;
			}
		}
		return null;
	}

	@SuppressWarnings("unchecked")
	public Class[] getAdapterList() {
		return new Class[] {IWorkbenchAdapter.class, IWorkbenchAdapter2.class};
	}

}

Back to the top