|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
|
2 // Use of this source code is governed by a BSD-style license that can be |
|
3 // found in the LICENSE file. |
|
4 |
|
5 package org.chromium.debug.core.model; |
|
6 |
|
7 import org.chromium.debug.core.ChromiumDebugPlugin; |
|
8 import org.eclipse.core.resources.IMarker; |
|
9 import org.eclipse.core.runtime.CoreException; |
|
10 import org.eclipse.core.runtime.IAdapterFactory; |
|
11 import org.eclipse.jface.resource.ImageDescriptor; |
|
12 import org.eclipse.ui.model.IWorkbenchAdapter; |
|
13 |
|
14 /** |
|
15 * An IWorkbenchAdapter factory for ChromiumLineBreakpoints. |
|
16 */ |
|
17 public class ChromiumBreakpointWBAFactory implements IAdapterFactory { |
|
18 |
|
19 protected static final Object[] EMPTY_CHILDREN = new Object[0]; |
|
20 |
|
21 @SuppressWarnings("unchecked") |
|
22 public Object getAdapter(Object adaptableObject, Class adapterType) { |
|
23 if (adapterType != IWorkbenchAdapter.class || |
|
24 !(adaptableObject instanceof ChromiumLineBreakpoint)) { |
|
25 return null; |
|
26 } |
|
27 return new IWorkbenchAdapter() { |
|
28 |
|
29 public Object[] getChildren(Object o) { |
|
30 return EMPTY_CHILDREN; |
|
31 } |
|
32 |
|
33 public ImageDescriptor getImageDescriptor(Object object) { |
|
34 return null; |
|
35 } |
|
36 |
|
37 public String getLabel(Object o) { |
|
38 ChromiumLineBreakpoint bp = (ChromiumLineBreakpoint) o; |
|
39 try { |
|
40 return bp.getMarker().getAttribute(IMarker.MESSAGE).toString(); |
|
41 } catch (CoreException e) { |
|
42 ChromiumDebugPlugin.log(e); |
|
43 } |
|
44 return null; |
|
45 } |
|
46 |
|
47 public Object getParent(Object o) { |
|
48 return null; |
|
49 } |
|
50 }; |
|
51 } |
|
52 |
|
53 @SuppressWarnings("unchecked") |
|
54 public Class[] getAdapterList() { |
|
55 return new Class[] { IWorkbenchAdapter.class }; |
|
56 } |
|
57 |
|
58 } |