Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b1ed9fadb8160bd54c4f04fc0f212381ef96b391 (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
/*******************************************************************************
 * Copyright (c) 2014 Ericsson 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:
 *     Marc Dumais (Ericsson) - Initial API and implementation (Bug 441713)
 *     Marc Dumais (Ericsson) - Bug 442312
 *******************************************************************************/

package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.actions;

import org.eclipse.cdt.debug.internal.ui.CDebugImages;
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.MulticoreVisualizerUIPlugin;
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizer;
import org.eclipse.cdt.visualizer.ui.VisualizerAction;

/** Pins the multicore visualizer to the current debug session */
public class PinToDebugSessionAction extends VisualizerAction {

	// --- members ---

	/** current active state of pinning */
	private boolean m_pinActive;

	/** Visualizer instance we're associated with. */
	MulticoreVisualizer m_visualizer = null;

	// --- constructors/destructors ---

	/** Constructor. */
	public PinToDebugSessionAction() {
		super(MulticoreVisualizerUIPlugin.getString("MulticoreVisualizer.actions.PinToDebugSession.text"), //$NON-NLS-1$
				MulticoreVisualizerUIPlugin.getString("MulticoreVisualizer.actions.PinToDebugSession.description"), //$NON-NLS-1$
				CDebugImages.DESC_LCL_PIN_VIEW);

		// at first, this action is disabled (un-pinned)
		setChecked(false);
		m_pinActive = false;
	}

	/** Dispose method. */
	@Override
	public void dispose() {
		m_visualizer = null;
		super.dispose();
	}

	// --- init methods ---

	/** Initializes this action for the specified view. */
	public void init(MulticoreVisualizer visualizer) {
		m_visualizer = visualizer;
	}

	// --- methods ---

	/** Invoked when action is triggered. */
	@Override
	public void run() {
		// Toggle pinned state
		m_pinActive = !m_pinActive;

		if (m_pinActive) {
			m_visualizer.pin();
		} else {
			m_visualizer.unpin();
		}
		// update the toolbar
		m_visualizer.raiseVisualizerChangedEvent();
	}
}

Back to the top