1
/*******************************************************************************
2
* Copyright (c) 2004, 2006 QNX Software Systems and others.
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
* QNX Software Systems - Initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.debug.mi.internal.ui.actions;
13
import org.eclipse.cdt.debug.mi.core.GDBProcess;
14
import org.eclipse.cdt.debug.mi.ui.console.VerboseModeChangedEvent;
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.IObjectActionDelegate;
19
import org.eclipse.ui.IWorkbenchPart;
20
import org.eclipse.ui.actions.ActionDelegate;
22
public class VerboseModeActionDelegate extends ActionDelegate implements IObjectActionDelegate {
24
private GDBProcess fProcess;
27
* @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
29
public void setActivePart( IAction action, IWorkbenchPart targetPart ) {
33
* @see org.eclipse.ui.actions.ActionDelegate#run(org.eclipse.jface.action.IAction)
35
public void run( IAction action ) {
36
if ( fProcess != null ) {
37
boolean enabled = fProcess.getTarget().isVerboseModeEnabled();
38
fProcess.getTarget().enableVerboseMode( !enabled );
39
fProcess.getTarget().getMISession().notifyObservers(new VerboseModeChangedEvent(fProcess.getTarget().getMISession(),0));
44
* @see org.eclipse.ui.actions.ActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
46
public void selectionChanged( IAction action, ISelection selection ) {
47
IStructuredSelection s = (IStructuredSelection)selection;
48
fProcess = ( !s.isEmpty() ) ? (GDBProcess)s.getFirstElement() : null;
49
action.setEnabled( fProcess != null && !fProcess.isTerminated());
50
action.setChecked( fProcess != null && fProcess.getTarget().isVerboseModeEnabled() );