01: package org.eclipse.ui.internal.provisional.views.markers;
02:
03: /*******************************************************************************
04: * Copyright (c) 2007 IBM Corporation and others.
05: * All rights reserved. This program and the accompanying materials
06: * are made available under the terms of the Eclipse Public License v1.0
07: * which accompanies this distribution, and is available at
08: * http://www.eclipse.org/legal/epl-v10.html
09: *
10: * Contributors:
11: * IBM Corporation - initial API and implementation
12: ******************************************************************************/
13:
14: import org.eclipse.core.resources.IMarker;
15: import org.eclipse.core.runtime.IAdapterFactory;
16: import org.eclipse.help.HelpSystem;
17: import org.eclipse.help.IContext;
18: import org.eclipse.help.IContextProvider;
19: import org.eclipse.ui.PlatformUI;
20: import org.eclipse.ui.ide.IDE;
21:
22: /**
23: * MarkerHelpAdapterFactory is the adapter factory for the markerHelp.
24: * @since 3.4
25: *
26: */
27: public class MarkerHelpAdapterFactory implements IAdapterFactory {
28:
29: private static final Class[] classes = new Class[] { IContextProvider.class };
30:
31: public Object getAdapter(Object adaptableObject, Class adapterType) {
32: if (!(adaptableObject instanceof ExtendedMarkersView))
33: return null;
34:
35: final ExtendedMarkersView view = (ExtendedMarkersView) adaptableObject;
36:
37: return new IContextProvider() {
38:
39: public int getContextChangeMask() {
40: return SELECTION;
41: }
42:
43: public IContext getContext(Object target) {
44: String contextId = null;
45: // See if there is a context registered for the current selection
46: IMarker[] markers = view.getSelectedMarkers();
47: if (markers.length > 0) {
48: contextId = IDE.getMarkerHelpRegistry().getHelp(
49: markers[0]);
50: }
51:
52: //TODO this needs to be migrated to the ide plug-in
53: if (contextId == null)
54: contextId = PlatformUI.PLUGIN_ID
55: + ".problem_view_context";//$NON-NLS-1$
56:
57: return HelpSystem.getContext(contextId);
58: }
59:
60: /*
61: * (non-Javadoc)
62: *
63: * @see org.eclipse.help.IContextProvider#getSearchExpression(java.lang.Object)
64: */
65: public String getSearchExpression(Object target) {
66: return null;
67: }
68:
69: };
70: }
71:
72: /* (non-Javadoc)
73: * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
74: */
75: public Class[] getAdapterList() {
76: return classes;
77: }
78:
79: }
|