From 66b2e1ceeef72924e043dc031f3d366b151d0faf Mon Sep 17 00:00:00 2001 From: Alena Laskavaia Date: Mon, 28 Jul 2008 20:58:41 +0000 Subject: [PATCH] [241279] - fix for values reverting to defaults --- .../debug/gdbjtag/ui/GDBJtagDebuggerTab.java | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagDebuggerTab.java b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagDebuggerTab.java index b5af4a2d31d..e5a10ae9705 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagDebuggerTab.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/GDBJtagDebuggerTab.java @@ -8,6 +8,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation * Andy Jin - Hardware debugging UI improvements, bug 229946 + * Anna Dushistova(MontaVista) - Hardware Debugging: Host name or ip address not saving in the debug configuration, bug 241279 *******************************************************************************/ package org.eclipse.cdt.debug.gdbjtag.ui; @@ -65,6 +66,8 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab { private Text ipAddress; private Text portNumber; private Combo jtagDevice; + private String savedJtagDevice; + public String getName() { return TAB_NAME; @@ -302,24 +305,26 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab { * @param text */ protected void updateDeviceIpPort(String selectedDeviceName) { - GDBJtagDeviceContribution[] availableDevices = GDBJtagDeviceContributionFactory. - getInstance().getGDBJtagDeviceContribution(); + if (selectedDeviceName.equals(savedJtagDevice)) { + return; + } + GDBJtagDeviceContribution[] availableDevices = GDBJtagDeviceContributionFactory.getInstance() + .getGDBJtagDeviceContribution(); IGDBJtagDevice selectedDevice = null; for (int i = 0; i < availableDevices.length; i++) { String name = availableDevices[i].getDeviceName(); if (name.equals(selectedDeviceName)) { - try { - selectedDevice = availableDevices[i].getDevice(); - } catch (NullPointerException e) { - return; + selectedDevice = availableDevices[i].getDevice(); + if (selectedDevice != null) { + String ip = selectedDevice.getDefaultIpAddress(); + ipAddress.setText(ip); + String port = selectedDevice.getDefaultPortNumber(); + portNumber.setText(port); + updateLaunchConfigurationDialog(); + break; } - break; } } - String ip = selectedDevice.getDefaultIpAddress(); - ipAddress.setText(ip); - String port = selectedDevice.getDefaultPortNumber(); - portNumber.setText(port); } private void useRemoteChanged() { @@ -366,15 +371,16 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab { int portNumberAttr = configuration.getAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, IGDBJtagConstants.DEFAULT_PORT_NUMBER); portNumber.setText(String.valueOf(portNumberAttr)); - String jtagDeviceString = configuration.getAttribute(IGDBJtagConstants.ATTR_JTAG_DEVICE, ""); + savedJtagDevice = configuration.getAttribute(IGDBJtagConstants.ATTR_JTAG_DEVICE, ""); for (int i = 0; i < jtagDevice.getItemCount(); i++) { - if (jtagDevice.getItem(i).equals(jtagDeviceString)) { + if (jtagDevice.getItem(i).equals(savedJtagDevice)) { jtagDevice.select(i); } } } catch (CoreException e) { Activator.getDefault().getLog().log(e.getStatus()); } + } public void performApply(ILaunchConfigurationWorkingCopy configuration) { @@ -382,7 +388,8 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab { configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY, commandFactory.getText()); configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_PROTOCOL, miProtocol.getText()); configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_VERBOSE_MODE, verboseMode.getSelection()); - configuration.setAttribute(IGDBJtagConstants.ATTR_JTAG_DEVICE, jtagDevice.getText()); + savedJtagDevice = jtagDevice.getText(); + configuration.setAttribute(IGDBJtagConstants.ATTR_JTAG_DEVICE, savedJtagDevice); configuration.setAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, useRemote.getSelection()); configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ipAddress.getText().trim()); try {