mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-21 07:55:24 +02:00
Bug 303808: Add a console action for "Auto terminate GDB"
Change-Id: Idf4a3b2c60fce5e318114be423fdc89c327be7bf
This commit is contained in:
parent
28f290e9d0
commit
46d0c9633b
4 changed files with 83 additions and 1 deletions
|
@ -46,6 +46,9 @@ public class ConsoleMessages extends NLS {
|
||||||
public static String ConsoleSelectAllAction_name;
|
public static String ConsoleSelectAllAction_name;
|
||||||
public static String ConsoleSelectAllAction_description;
|
public static String ConsoleSelectAllAction_description;
|
||||||
|
|
||||||
|
public static String ConsoleAutoTerminateAction_name;
|
||||||
|
public static String ConsoleAutoTerminateAction_description;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// initialize resource bundle
|
// initialize resource bundle
|
||||||
NLS.initializeMessages(ConsoleMessages.class.getName(), ConsoleMessages.class);
|
NLS.initializeMessages(ConsoleMessages.class.getName(), ConsoleMessages.class);
|
||||||
|
|
|
@ -38,3 +38,6 @@ ConsolePasteAction_description=Paste contents of clip-board to console
|
||||||
|
|
||||||
ConsoleSelectAllAction_name=Select &All
|
ConsoleSelectAllAction_name=Select &All
|
||||||
ConsoleSelectAllAction_description=Select All available text in the associated console
|
ConsoleSelectAllAction_description=Select All available text in the associated console
|
||||||
|
|
||||||
|
ConsoleAutoTerminateAction_name=Terminate GDB when last process exits
|
||||||
|
ConsoleAutoTerminateAction_description=Automatically terminate GDB when the last process being debugged exits
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2016 Ericsson 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
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.dsf.gdb.internal.ui.console;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
|
||||||
|
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||||
|
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||||
|
import org.eclipse.jface.action.Action;
|
||||||
|
import org.eclipse.jface.action.IAction;
|
||||||
|
import org.osgi.service.prefs.BackingStoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action to toggle the preference to terminate GDB when last process exits
|
||||||
|
*/
|
||||||
|
public class GdbAutoTerminateAction extends Action {
|
||||||
|
|
||||||
|
public GdbAutoTerminateAction() {
|
||||||
|
super(ConsoleMessages.ConsoleAutoTerminateAction_name, IAction.AS_CHECK_BOX);
|
||||||
|
setToolTipText(ConsoleMessages.ConsoleAutoTerminateAction_description);
|
||||||
|
|
||||||
|
// initialize state
|
||||||
|
setChecked(readState());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean readState() {
|
||||||
|
return Platform.getPreferencesService().getBoolean(GdbPlugin.PLUGIN_ID,
|
||||||
|
IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB,
|
||||||
|
true, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// All we need to do is update the preference store. There is no other
|
||||||
|
// immediate action to take.
|
||||||
|
IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID);
|
||||||
|
if (preferences != null) {
|
||||||
|
preferences.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, !readState());
|
||||||
|
|
||||||
|
try {
|
||||||
|
preferences.flush();
|
||||||
|
} catch (BackingStoreException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -32,6 +32,8 @@ import org.eclipse.jface.action.IToolBarManager;
|
||||||
import org.eclipse.jface.action.MenuManager;
|
import org.eclipse.jface.action.MenuManager;
|
||||||
import org.eclipse.jface.action.Separator;
|
import org.eclipse.jface.action.Separator;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
|
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||||
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.layout.FillLayout;
|
import org.eclipse.swt.layout.FillLayout;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
@ -63,11 +65,16 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
||||||
|
|
||||||
/** The control for the terminal widget embedded in the console */
|
/** The control for the terminal widget embedded in the console */
|
||||||
private ITerminalViewControl fTerminalControl;
|
private ITerminalViewControl fTerminalControl;
|
||||||
|
|
||||||
private GdbConsoleClearAction fClearAction;
|
private GdbConsoleClearAction fClearAction;
|
||||||
private GdbConsoleCopyAction fCopyAction;
|
private GdbConsoleCopyAction fCopyAction;
|
||||||
private GdbConsolePasteAction fPasteAction;
|
private GdbConsolePasteAction fPasteAction;
|
||||||
private GdbConsoleScrollLockAction fScrollLockAction;
|
private GdbConsoleScrollLockAction fScrollLockAction;
|
||||||
private GdbConsoleSelectAllAction fSelectAllAction;
|
private GdbConsoleSelectAllAction fSelectAllAction;
|
||||||
|
private GdbAutoTerminateAction fAutoTerminateAction;
|
||||||
|
|
||||||
|
private IPropertyChangeListener fConsolePropertyChangeListener;
|
||||||
|
|
||||||
|
|
||||||
public GdbFullCliConsolePage(GdbFullCliConsole gdbConsole, IDebuggerConsoleView view) {
|
public GdbFullCliConsolePage(GdbFullCliConsole gdbConsole, IDebuggerConsoleView view) {
|
||||||
fConsole = gdbConsole;
|
fConsole = gdbConsole;
|
||||||
|
@ -79,6 +86,19 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
||||||
fSession = null;
|
fSession = null;
|
||||||
assert false;
|
assert false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fConsolePropertyChangeListener = new IPropertyChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void propertyChange(PropertyChangeEvent event) {
|
||||||
|
if (event.getProperty().equals(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB) && fAutoTerminateAction != null) {
|
||||||
|
String terminateStr = event.getNewValue().toString();
|
||||||
|
boolean terminate = terminateStr.equals(Boolean.FALSE.toString()) ? false : true;
|
||||||
|
fAutoTerminateAction.setChecked(terminate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GdbUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fConsolePropertyChangeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -88,6 +108,8 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
||||||
getSite().getWorkbenchWindow()).removeDebugContextListener(this);
|
getSite().getWorkbenchWindow()).removeDebugContextListener(this);
|
||||||
fTerminalControl.disposeTerminal();
|
fTerminalControl.disposeTerminal();
|
||||||
fMenuManager.dispose();
|
fMenuManager.dispose();
|
||||||
|
|
||||||
|
GdbUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fConsolePropertyChangeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -148,6 +170,7 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
||||||
fPasteAction = new GdbConsolePasteAction(fTerminalControl);
|
fPasteAction = new GdbConsolePasteAction(fTerminalControl);
|
||||||
fScrollLockAction = new GdbConsoleScrollLockAction(fTerminalControl);
|
fScrollLockAction = new GdbConsoleScrollLockAction(fTerminalControl);
|
||||||
fSelectAllAction = new GdbConsoleSelectAllAction(fTerminalControl);
|
fSelectAllAction = new GdbConsoleSelectAllAction(fTerminalControl);
|
||||||
|
fAutoTerminateAction = new GdbAutoTerminateAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void configureToolBar(IToolBarManager mgr) {
|
protected void configureToolBar(IToolBarManager mgr) {
|
||||||
|
@ -170,6 +193,7 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
||||||
|
|
||||||
menuManager.add(fTerminateLaunchAction);
|
menuManager.add(fTerminateLaunchAction);
|
||||||
menuManager.add(fInvertColorsAction);
|
menuManager.add(fInvertColorsAction);
|
||||||
|
menuManager.add(fAutoTerminateAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue