blob: 2a0a5aa2fd13a44cf06da40e5822bf6142714141 (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/*******************************************************************************
* Copyright (c) 2012 Tilera Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* William R. Swanson (Tilera Corporation)
*******************************************************************************/
package org.eclipse.cdt.visualizer.ui.test;
import org.eclipse.cdt.visualizer.ui.canvas.GraphicCanvas;
import org.eclipse.cdt.visualizer.ui.canvas.GraphicCanvasVisualizer;
import org.eclipse.cdt.visualizer.ui.util.SelectionUtils;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
// ---------------------------------------------------------------------------
// TestCanvasVisualizer
// ---------------------------------------------------------------------------
/**
* Default visualizer, used only for testing framework.
*
* This view uses the CDT Visualizer framework.
*/
public class TestCanvasVisualizer extends GraphicCanvasVisualizer {
// --- constants ---
/** Eclipse ID for this visualizer */
public static final String ECLIPSE_ID = "org.eclipse.cdt.visualizer.ui.test.TestCanvasVisualizer";
// --- members ---
/** Visualizer control. */
TestCanvas m_canvas = null;
// --- constructors/destructors ---
// --- accessors ---
/** Gets canvas control. */
public TestCanvas getDefaultCanvas() {
return m_canvas;
}
// --- IVisualizer implementation ---
/** Returns non-localized unique name for this visualizer. */
public String getName() {
return "default";
}
/** Returns localized name to display for this visualizer. */
public String getDisplayName() {
// TODO: use a string resource here.
return "Test Visualizer";
}
/** Returns localized tooltip text to display for this visualizer. */
public String getDescription() {
// TODO: use a string resource here.
return "Test visualizer (for debugging only).";
}
/** Creates and returns visualizer canvas control. */
public GraphicCanvas createCanvas(Composite parent) {
m_canvas = new TestCanvas(parent);
return m_canvas;
}
/** Invoked after visualizer control creation, */
protected void initializeCanvas(GraphicCanvas canvas) {
m_canvas.setBackground(canvas.getDisplay().getSystemColor(SWT.COLOR_WHITE));
m_canvas.setForeground(canvas.getDisplay().getSystemColor(SWT.COLOR_BLACK));
}
// --- workbench selection management ---
/**
* Tests whether if the IVisualizer can display the selection
* (or something reachable from it).
*/
public int handlesSelection(ISelection selection) {
// By default, we don't support anything.
// Changing this to return 1 enables the test canvas.
return 0;
}
/**
* Invoked by VisualizerViewer when workbench selection changes.
*/
public void workbenchSelectionChanged(ISelection selection) {
String text = SelectionUtils.toString(selection);
m_canvas.setText(text);
m_canvas.redraw();
}
}
|