blob: 81ebc8dac822178af7dcb07b9fa7c7cbda50f0a2 (
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
|
/*******************************************************************************
* Copyright (c) 2012 Wind River Systems 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:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.tcf.debug.test;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.ui.contexts.DebugContextEvent;
import org.eclipse.debug.ui.contexts.IDebugContextListener;
import org.eclipse.debug.ui.contexts.IDebugContextProvider;
import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
/**
*
*/
public class TestSourceDisplayService implements IDebugContextListener {
private IDebugContextProvider fDebugContextProvider;
public TestSourceDisplayService(IDebugContextProvider debugContextProvider) {
fDebugContextProvider = debugContextProvider;
fDebugContextProvider.addDebugContextListener(this);
}
public void dispose() {
fDebugContextProvider.removeDebugContextListener(this);
}
public void debugContextChanged(DebugContextEvent event) {
if ((event.getFlags() & DebugContextEvent.ACTIVATED) == 0) return;
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) return;
if (event.getContext() instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection)event.getContext();
if (structuredSelection.size() == 1) {
Object context = (structuredSelection).getFirstElement();
IWorkbenchPage page = null;
page = window.getActivePage();
ISourceDisplay adapter = (ISourceDisplay) DebugPlugin.getAdapter(context, ISourceDisplay.class);
if (adapter != null) {
adapter.displaySource(context, page, false);
}
}
}
}
}
|