Commit | Line | Data |
---|---|---|
e8d771d5 BH |
1 | /******************************************************************************* |
2 | * Copyright (c) 2011 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Polytechnique Montréal - Initial API and implementation | |
11 | * Bernd Hufmann - Productification, enhancements and fixes | |
12 | * | |
13 | *******************************************************************************/ | |
14 | package org.eclipse.linuxtools.lttng.ui.tracecontrol.model; | |
15 | ||
16 | import org.eclipse.core.runtime.IAdapterFactory; | |
5945cec9 FC |
17 | import org.eclipse.linuxtools.internal.lttng.core.tracecontrol.model.ProviderResource; |
18 | import org.eclipse.linuxtools.internal.lttng.core.tracecontrol.model.TargetResource; | |
19 | import org.eclipse.linuxtools.internal.lttng.core.tracecontrol.model.TraceResource; | |
e8d771d5 BH |
20 | import org.eclipse.rse.ui.view.AbstractSystemRemoteAdapterFactory; |
21 | import org.eclipse.rse.ui.view.ISystemViewElementAdapter; | |
22 | import org.eclipse.ui.views.properties.IPropertySource; | |
23 | ||
24 | /** | |
25 | * <b><u>TargetResourceAdapter</u></b> | |
26 | * <p> | |
27 | * This factory maps requests for an adapter object from a given remote object. | |
28 | * </p> | |
29 | */ | |
30 | public class TraceAdapterFactory extends AbstractSystemRemoteAdapterFactory implements IAdapterFactory { | |
31 | ||
32 | // ------------------------------------------------------------------------ | |
33 | // Attributes | |
34 | // ------------------------------------------------------------------------ | |
35 | ||
36 | private ProviderResourceAdapter providerAdapter = new ProviderResourceAdapter(); | |
37 | private TargetResourceAdapter targetAdapter = new TargetResourceAdapter(); | |
38 | private TraceResourceAdapter traceAdapter = new TraceResourceAdapter(); | |
39 | ||
40 | // ------------------------------------------------------------------------ | |
41 | // Constructors | |
42 | // ------------------------------------------------------------------------ | |
43 | ||
44 | /** | |
45 | * Constructor for TraceAdapterFactory. | |
46 | */ | |
47 | public TraceAdapterFactory() { | |
48 | super(); | |
49 | } | |
50 | ||
51 | // ------------------------------------------------------------------------ | |
52 | // Operations | |
53 | // ------------------------------------------------------------------------ | |
54 | ||
55 | /* | |
56 | * (non-Javadoc) | |
57 | * @see org.eclipse.rse.ui.view.AbstractSystemRemoteAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) | |
58 | */ | |
59 | @SuppressWarnings("rawtypes") | |
60 | @Override | |
61 | public Object getAdapter(Object adaptableObject, Class adapterType) { | |
62 | ISystemViewElementAdapter adapter = null; | |
63 | if (adaptableObject instanceof ProviderResource) { | |
64 | adapter = providerAdapter; | |
65 | } | |
66 | else if (adaptableObject instanceof TargetResource) { | |
67 | adapter = targetAdapter; | |
68 | } | |
69 | else if (adaptableObject instanceof TraceResource) { | |
70 | adapter = traceAdapter; | |
71 | } | |
72 | // these lines are very important! | |
73 | if ((adapter != null) && (adapterType == IPropertySource.class)) { | |
74 | adapter.setPropertySourceInput(adaptableObject); | |
75 | } | |
76 | return adapter; | |
77 | } | |
78 | } |