1
/*******************************************************************************
2
* Copyright (c) 2006 IBM Corporation.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse, Anithra P J
10
*******************************************************************************/
12
package org.eclipse.linuxtools.systemtap.ui.dashboard.actions;
14
import org.eclipse.jface.action.Action;
15
import org.eclipse.jface.action.IAction;
16
import org.eclipse.jface.viewers.ISelection;
17
import org.eclipse.jface.viewers.IStructuredSelection;
18
import org.eclipse.ui.IViewActionDelegate;
19
import org.eclipse.ui.IViewPart;
20
import org.eclipse.ui.PlatformUI;
22
import org.eclipse.linuxtools.systemtap.ui.dashboard.structures.DashboardGraphData;
23
import org.eclipse.linuxtools.systemtap.ui.dashboard.structures.GraphTreeNode;
24
import org.eclipse.linuxtools.systemtap.ui.dashboard.views.ActiveModuleBrowserView;
25
import org.eclipse.linuxtools.systemtap.ui.dashboard.views.DashboardView;
28
* This action is responsible for stopping an active graph. This is used when a module
29
* has already been started, but the user no longer wants to see one of the graphs.
30
* This will make the selected graph inactive, with the option for bringing it back up
34
public class StopGraphAction extends Action implements IViewActionDelegate {
35
public void init(IViewPart view) {
39
public void run(IAction act) {
48
* This method retreives the graph information for the selected item and then
49
* disposes of the graph from the display.
50
* @param selected The graph item that is currently selected and needs to be deactivated
52
public void run(GraphTreeNode selected) {
53
DashboardGraphData data = ((DashboardGraphData)selected.getData());
54
IViewPart ivp = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(DashboardView.ID);
55
DashboardView dv = (DashboardView)ivp;
56
dv.removeGraph(data.adapter,data.adapter.getmodulename());
59
ivp = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(ActiveModuleBrowserView.ID);
60
ActiveModuleBrowserView ambv = (ActiveModuleBrowserView)ivp;
61
ambv.getViewer().refresh();
65
* This method updates what item is currently selected.
66
* @param action The action that started this method.
67
* @param selection The newly selected item
69
public void selectionChanged(IAction action, ISelection selection) {
70
if(selection instanceof IStructuredSelection) {
71
IStructuredSelection selected = (IStructuredSelection)selection;
72
Object o = selected.getFirstElement();
73
if(o instanceof GraphTreeNode) {
74
selectedItem = (GraphTreeNode)o;
75
o = selectedItem.getData();
76
if(null == ((DashboardGraphData)o).adapter) {
77
action.setEnabled(false);
82
action.setEnabled(true);
85
private GraphTreeNode selectedItem;