Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] MI UI additions

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.ui/ChangeLog,v
retrieving revision 1.3
diff -u -r1.3 ChangeLog
--- ChangeLog	6 Jan 2003 22:14:05 -0000	1.3
+++ ChangeLog	17 Jan 2003 16:08:15 -0000
@@ -1,3 +1,7 @@
+2003-01-17 David Inglis
+	* src/.../internal/ui/CDebuggerPage.java
+	Added some browse buttons and new text field for gdbinit file.
+	
 2003-01-03 Alain Magloire

 	* build.properties: Patch from Judy Green.
Index: src/org/eclipse/cdt/debug/mi/internal/ui/CDebuggerPage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/CDebuggerPage.java,v
retrieving revision 1.6
diff -u -r1.6 CDebuggerPage.java
--- src/org/eclipse/cdt/debug/mi/internal/ui/CDebuggerPage.java	16 Jan 2003 20:59:21 -0000	1.6
+++ src/org/eclipse/cdt/debug/mi/internal/ui/CDebuggerPage.java	17 Jan 2003 16:08:15 -0000
@@ -4,6 +4,8 @@
  */
 package org.eclipse.cdt.debug.mi.internal.ui;

+import java.io.File;
+
 import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.debug.core.ILaunchConfiguration;
@@ -18,86 +20,134 @@
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;

 public class CDebuggerPage extends AbstractLaunchConfigurationTab {
-	
-	protected Text fDebuggerCommandText;
+
+	private Text fGDBCommandText;
+	private Text fGDBInitText;
 	private Button fAutoSoLibButton;
+	private Button fGDBButton;

 	public void createControl(Composite parent) {
-		Composite comp = new Composite(parent, SWT.NONE);
-		GridLayout topLayout = new GridLayout();
-		topLayout.numColumns = 2;
-		comp.setLayout(topLayout);
-		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-		comp.setLayoutData(gd);
-		setControl(comp);	
+		GridData gd;
+		Label label;
+		Button button;
+		Composite comp, subComp;
 		
-		createVerticalSpacer(comp, 2);
-		
-		Label debugCommandLabel= new Label(comp, SWT.NONE);
-		debugCommandLabel.setText("MI Debugger:");
+		comp = new Composite(parent, SWT.NONE);
+		comp.setLayout(new GridLayout());
+		comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+		setControl(comp);
+
+		createVerticalSpacer(comp, 1);
+
+		subComp = new Composite(comp, SWT.NONE);
+		GridLayout gdbLayout = new GridLayout();
+		gdbLayout.numColumns = 2;
+		gdbLayout.marginHeight = 0;
+		gdbLayout.marginWidth = 0;
+		subComp.setLayout(gdbLayout);
+		subComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+		label = new Label(subComp, SWT.NONE);
+		label.setText("GDB debugger:");
+		gd = new GridData();
+		gd.horizontalSpan = 2;
+		label.setLayoutData(gd);
 		
-		fDebuggerCommandText= new Text(comp, SWT.SINGLE | SWT.BORDER);
+		fGDBCommandText = new Text(subComp, SWT.SINGLE | SWT.BORDER);
 		gd = new GridData(GridData.FILL_HORIZONTAL);
-		fDebuggerCommandText.setLayoutData(gd);
-		fDebuggerCommandText.addModifyListener(new ModifyListener() {
+		fGDBCommandText.setLayoutData(gd);
+		fGDBCommandText.addModifyListener(new ModifyListener() {
 			public void modifyText(ModifyEvent evt) {
 				updateLaunchConfigurationDialog();
 			}
 		});

-		createVerticalSpacer(comp, 2);
-
-		fAutoSoLibButton = new Button(comp, SWT.CHECK ) ;
-		fAutoSoLibButton.setText("Load shared library symbols automatically");
-		fAutoSoLibButton.addSelectionListener(new SelectionAdapter() {
-			public void widgetSelected(SelectionEvent e) {
+		button = createPushButton(subComp, "&Browse...", null);
+		button.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent evt) {
+				handleGDBButtonSelected();
 				updateLaunchConfigurationDialog();
 			}
+			private void handleGDBButtonSelected() {
+				FileDialog dialog= new FileDialog(getShell(), SWT.NONE);
+				dialog.setText("GDB Command");
+				String gdbCommand = fGDBCommandText.getText().trim();
+				int lastSeparatorIndex = gdbCommand.lastIndexOf(File.separator);
+				if (lastSeparatorIndex != -1) {
+					dialog.setFilterPath(gdbCommand.substring(0,lastSeparatorIndex));
+				}
+				String res= dialog.open();
+				if (res == null) {
+					return;
+				}
+				fGDBCommandText.setText(res);
+			}
 		});

+
+		subComp = new Composite(comp, SWT.NONE);
+		gdbLayout = new GridLayout();
+		gdbLayout.numColumns = 2;
+		gdbLayout.marginHeight = 0;
+		gdbLayout.marginWidth = 0;
+		subComp.setLayout(gdbLayout);
+		subComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+		label = new Label(subComp, SWT.NONE);
+		label.setText("GDB command file:");
 		gd = new GridData();
 		gd.horizontalSpan = 2;
-		fAutoSoLibButton.setLayoutData(gd);
-/*
-		ListEditor listEditor = new ListEditor("1", "Shared library search paths:", comp) {
-			protected String createList(String[] items) {
-				StringBuffer buf = new StringBuffer();
-				for (int i = 0; i < items.length; i++) {
-					buf.append(items[i]);
-					buf.append(';');
-				}
-				return buf.toString();
+		label.setLayoutData(gd);
+
+		fGDBInitText = new Text(subComp, SWT.SINGLE | SWT.BORDER);
+		gd = new GridData(GridData.FILL_HORIZONTAL);
+		fGDBInitText.setLayoutData(gd);
+		fGDBInitText.addModifyListener(new ModifyListener() {
+			public void modifyText(ModifyEvent evt) {
+				updateLaunchConfigurationDialog();
 			}
-			protected String getNewInputObject() {
-//				StringInputDialog dialog= new StringInputDialog(comp.getShell(), "Library Path", null, "Enter a library path", "", null);
-//				if (dialog.open() == dialog.OK) {
-//					return dialog.getValue();
-//				} else {
-//					return null;
-//				}
-				return null;
-			}
-
-			protected String[] parseString(String list) {
-				StringTokenizer st = new StringTokenizer(list, ";");
-				ArrayList v = new ArrayList();
-				while (st.hasMoreElements()) {
-					v.add(st.nextElement());
+		});
+		button = createPushButton(subComp, "&Browse...", null);
+		button.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent evt) {
+				handleGDBInitButtonSelected();
+				updateLaunchConfigurationDialog();
+			}
+			private void handleGDBInitButtonSelected() {
+				FileDialog dialog= new FileDialog(getShell(), SWT.NONE);
+				dialog.setText("GDB command file");
+				String gdbCommand = fGDBInitText.getText().trim();
+				int lastSeparatorIndex = gdbCommand.lastIndexOf(File.separator);
+				if (lastSeparatorIndex != -1) {
+					dialog.setFilterPath(gdbCommand.substring(0,lastSeparatorIndex));
+				}
+				String res= dialog.open();
+				if (res == null) {
+					return;
 				}
-				return (String[]) v.toArray(new String[v.size()]);
+				fGDBInitText.setText(res);
 			}
+		});

-		};
-*/		
-		
+		createVerticalSpacer(comp, 1);
+
+		fAutoSoLibButton = new Button(comp, SWT.CHECK);
+		fAutoSoLibButton.setText("Load shared library symbols automatically");
+		fAutoSoLibButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				updateLaunchConfigurationDialog();
+			}
+		});
 	}

 	public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
 		configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb");
+		configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, "");
 		configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_AUTO_SOLIB, true);
 	}

@@ -105,7 +155,7 @@
 	 * @see ILaunchConfigurationTab#isValid(ILaunchConfiguration)
 	 */
 	public boolean isValid(ILaunchConfiguration launchConfig) {
-		boolean valid= fDebuggerCommandText.getText().length() != 0;
+		boolean valid = fGDBCommandText.getText().length() != 0;
 		if (valid) {
 			setErrorMessage(null);
 			setMessage(null);
@@ -117,25 +167,31 @@
 	}

 	public void initializeFrom(ILaunchConfiguration configuration) {
-		String debuggerCommand = "gdb";
+		String gdbCommand = "gdb";
+		String gdbInit = "";
 		boolean autosolib = false;
 		try {
-			debuggerCommand = configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb");
+			gdbCommand = configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb");
+			gdbInit = configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, "");
 			autosolib = configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_AUTO_SOLIB, true);
 		} catch (CoreException e) {
 		}
-		fDebuggerCommandText.setText(debuggerCommand);
-		fAutoSoLibButton.setSelection(autosolib);		
+		fGDBCommandText.setText(gdbCommand);
+		fGDBInitText.setText(gdbInit);
+		fAutoSoLibButton.setSelection(autosolib);
 	}

 	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
-		String debuggerCommand = fDebuggerCommandText.getText();
-		debuggerCommand.trim();
-		configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, debuggerCommand);
+		String gdbStr = fGDBCommandText.getText();
+		gdbStr.trim();
+		configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, gdbStr);
+		gdbStr = fGDBInitText.getText();
+		gdbStr.trim();
+		configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, gdbStr);
 		configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_AUTO_SOLIB, fAutoSoLibButton.getSelection());
 	}

 	public String getName() {
-		return "GDB/MI Debugger Options";
+		return "GDB Debugger Options";
 	}
 }



Back to the top