blob: f852af398a04904afe6c674e7791ca6a7da9ef2d (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/*******************************************************************************
* Copyright (c) 2012 Oracle. 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:
* Oracle - initial API and implementation
******************************************************************************/
package org.eclipse.jpt.jaxb.ui.internal;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.jpt.common.ui.internal.WorkbenchTools;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatform;
import org.eclipse.jpt.jaxb.ui.JaxbWorkbench;
import org.eclipse.jpt.jaxb.ui.internal.platform.InternalJaxbPlatformUiManager;
import org.eclipse.jpt.jaxb.ui.platform.JaxbPlatformUi;
import org.eclipse.jpt.jaxb.ui.platform.JaxbPlatformUiManager;
/**
* Factory to build adapters for a {@link JaxbPlatform}:<ul>
* <li>{@link JaxbPlatformUi}
* </ul>
* See <code>org.eclipse.jpt.jaxb.ui/plugin.xml:org.eclipse.core.runtime.adapters</code>.
*
* @see InternalJaxbPlatformUiManager
*/
public class JaxbPlatformAdapterFactory
implements IAdapterFactory
{
private static final Class<?>[] ADAPTER_LIST = new Class[] { JaxbPlatformUi.class };
public Class<?>[] getAdapterList() {
return ADAPTER_LIST;
}
public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes") Class adapterType) {
if (adaptableObject instanceof JaxbPlatform) {
return this.getAdapter((JaxbPlatform) adaptableObject, adapterType);
}
return null;
}
private Object getAdapter(JaxbPlatform jaxbPlatform, Class<?> adapterType) {
if (adapterType == JaxbPlatformUi.class) {
return this.getJaxbPlatformUi(jaxbPlatform);
}
return null;
}
private JaxbPlatformUi getJaxbPlatformUi(JaxbPlatform jaxbPlatform) {
JaxbPlatformUiManager jaxbPlatformUiManager = this.getJaxbPlatformUiManager();
return (jaxbPlatformUiManager == null) ? null : jaxbPlatformUiManager.getJaxbPlatformUi(jaxbPlatform);
}
private JaxbPlatformUiManager getJaxbPlatformUiManager() {
JaxbWorkbench jaxbWorkbench = this.getJaxbWorkbench();
return (jaxbWorkbench == null) ? null : jaxbWorkbench.getJaxbPlatformUiManager();
}
private JaxbWorkbench getJaxbWorkbench() {
return WorkbenchTools.getAdapter(JaxbWorkbench.class);
}
}
|