mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 08:46:02 +02:00
LLDB: Add preference UI
This commit adds a preference page for LLDB. For now, only LLDB path and the "stop at main" preferences are exposed. Bug: 405670 Change-Id: I4ba30fdb48ecd0cdfc6e3aac35fe0de38563c354 Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
This commit is contained in:
parent
b7e23cab72
commit
4548f0a7bc
4 changed files with 167 additions and 0 deletions
|
@ -84,5 +84,14 @@
|
|||
<placement after="org.eclipse.debug.ui.sourceLookupTab"/>
|
||||
</tab>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.preferencePages">
|
||||
<page
|
||||
category="org.eclipse.cdt.debug.ui.CDebugPreferencePage"
|
||||
class="org.eclipse.cdt.llvm.dsf.lldb.ui.internal.LLDBDebugPreferencePage"
|
||||
id="org.eclipse.cdt.llvm.dsf.lldb.ui.preferences"
|
||||
name="%lldbPreferencePage.name">
|
||||
</page>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
/*******************************************************************************
|
||||
* 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.llvm.dsf.lldb.ui.internal;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.cdt.llvm.dsf.lldb.core.ILLDBDebugPreferenceConstants;
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.preference.StringFieldEditor;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.FileDialog;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Link;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
import org.eclipse.ui.dialogs.PreferencesUtil;
|
||||
|
||||
/**
|
||||
* A preference page for settings that are currently supported in LLDB. Based on
|
||||
* the GDB equivalent.
|
||||
*/
|
||||
public class LLDBDebugPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
|
||||
|
||||
private StringFieldEditor fStringFieldEditorCommand;
|
||||
@SuppressWarnings("restriction")
|
||||
private org.eclipse.cdt.dsf.debug.internal.ui.preferences.StringWithBooleanFieldEditor fEnableStopAtMain;
|
||||
|
||||
/**
|
||||
* Constructs the preference page.
|
||||
*/
|
||||
public LLDBDebugPreferencePage() {
|
||||
super(FLAT);
|
||||
IPreferenceStore store = LLDBUIPlugin.getDefault().getCorePreferenceStore();
|
||||
// Note that if we don't set it here, it actually never gets flushed. If
|
||||
// this page was to use two preference stores, make sure that both are
|
||||
// flushed.
|
||||
setPreferenceStore(store);
|
||||
setDescription(Messages.LLDBDebugPreferencePage_description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(IWorkbench workbench) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createFieldEditors() {
|
||||
final Composite parent = getFieldEditorParent();
|
||||
final GridLayout layout = new GridLayout();
|
||||
layout.marginWidth = 0;
|
||||
parent.setLayout(layout);
|
||||
|
||||
final Group group1 = new Group(parent, SWT.NONE);
|
||||
group1.setText(Messages.LLDBDebugPreferencePage_defaults_label);
|
||||
GridLayout groupLayout = new GridLayout(3, false);
|
||||
group1.setLayout(groupLayout);
|
||||
group1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
fStringFieldEditorCommand = new StringFieldEditor(ILLDBDebugPreferenceConstants.PREF_DEFAULT_LLDB_COMMAND,
|
||||
Messages.LLDBCDebuggerPage_debugger_command, group1);
|
||||
|
||||
fStringFieldEditorCommand.fillIntoGrid(group1, 2);
|
||||
GridData stringFieldLayoutData = (GridData) fStringFieldEditorCommand.getTextControl(group1).getLayoutData();
|
||||
stringFieldLayoutData.widthHint = 300;
|
||||
|
||||
addField(fStringFieldEditorCommand);
|
||||
Button browsebutton = new Button(group1, SWT.PUSH);
|
||||
browsebutton.setText(Messages.LLDBCDebuggerPage_browse);
|
||||
browsebutton.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
handleBrowseButtonSelected(Messages.LLDBCDebuggerPage_browse_dialog_title, fStringFieldEditorCommand);
|
||||
}
|
||||
});
|
||||
setButtonLayoutData(browsebutton);
|
||||
|
||||
fEnableStopAtMain = createStopAtMainEditor(group1);
|
||||
fEnableStopAtMain.fillIntoGrid(group1, 3);
|
||||
addField(fEnableStopAtMain);
|
||||
|
||||
group1.setLayout(groupLayout);
|
||||
|
||||
createLinkToGdb(parent);
|
||||
}
|
||||
|
||||
/*
|
||||
* Using full qualified name for return value here so that we don't have to
|
||||
* suppress warning on the whole class.
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
private static org.eclipse.cdt.dsf.debug.internal.ui.preferences.StringWithBooleanFieldEditor createStopAtMainEditor(final Group group1) {
|
||||
return new org.eclipse.cdt.dsf.debug.internal.ui.preferences.StringWithBooleanFieldEditor(
|
||||
ILLDBDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN,
|
||||
ILLDBDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL,
|
||||
Messages.LLDBDebugPreferencePage_Stop_on_startup_at,
|
||||
group1);
|
||||
}
|
||||
|
||||
private Control createLinkToGdb(Composite parent) {
|
||||
String text = Messages.LLDBDebugPreferencePage_see_gdb_preferences;
|
||||
Link link = new Link(parent, SWT.NONE);
|
||||
link.setText(text);
|
||||
link.addListener(SWT.Selection, new Listener() {
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
PreferencesUtil.createPreferenceDialogOn(getShell(), event.text, null, null);
|
||||
}
|
||||
});
|
||||
|
||||
GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
|
||||
gridData.widthHint = 150;
|
||||
link.setLayoutData(gridData);
|
||||
return link;
|
||||
}
|
||||
|
||||
private void handleBrowseButtonSelected(final String dialogTitle, final StringFieldEditor stringFieldEditor) {
|
||||
FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
|
||||
dialog.setText(dialogTitle);
|
||||
String lldbCommand = stringFieldEditor.getStringValue().trim();
|
||||
int lastSeparatorIndex = lldbCommand.lastIndexOf(File.separator);
|
||||
if (lastSeparatorIndex != -1) {
|
||||
dialog.setFilterPath(lldbCommand.substring(0, lastSeparatorIndex));
|
||||
}
|
||||
String res = dialog.open();
|
||||
if (res == null) {
|
||||
return;
|
||||
}
|
||||
stringFieldEditor.setStringValue(res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void adjustGridLayout() {
|
||||
// Do nothing, already handled during creation of controls.
|
||||
}
|
||||
}
|
|
@ -20,6 +20,10 @@ public class Messages extends NLS {
|
|||
public static String LLDBCDebuggerPage_browse_dialog_title;
|
||||
public static String LLDBCDebuggerPage_tab_name;
|
||||
public static String LLDBCDebuggerPage_debugger_command;
|
||||
public static String LLDBDebugPreferencePage_Stop_on_startup_at;
|
||||
public static String LLDBDebugPreferencePage_description;
|
||||
public static String LLDBDebugPreferencePage_defaults_label;
|
||||
public static String LLDBDebugPreferencePage_see_gdb_preferences;
|
||||
|
||||
static {
|
||||
// initialize resource bundle
|
||||
|
|
|
@ -10,3 +10,8 @@ LLDBCDebuggerPage_browse=&Browse...
|
|||
LLDBCDebuggerPage_browse_dialog_title=LLDB-MI Debugger
|
||||
LLDBCDebuggerPage_tab_name=LLDB Debugger Options
|
||||
LLDBCDebuggerPage_debugger_command=LLDB command:
|
||||
LLDBDebugPreferencePage_Stop_on_startup_at=Stop on startup at:
|
||||
|
||||
LLDBDebugPreferencePage_description=General settings for LLDB Debugging
|
||||
LLDBDebugPreferencePage_defaults_label=Debug Configurations Defaults
|
||||
LLDBDebugPreferencePage_see_gdb_preferences=Note: Other preferences that can affect LLDB are available via <a href="org.eclipse.cdt.dsf.gdb.ui.preferences">GDB</a>.
|
||||
|
|
Loading…
Add table
Reference in a new issue