Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamantha Chan2005-06-09 00:14:01 +0000
committerSamantha Chan2005-06-09 00:14:01 +0000
commit1f55404fc68a774b27b75351157af0544a2c56ae (patch)
tree28d5989f891b2927cf130d37924ea4fdc218a849
parent18dc4d9c787d299d9868f68c8f317578b5e519c9 (diff)
downloadeclipse.platform.debug-1f55404fc68a774b27b75351157af0544a2c56ae.tar.gz
eclipse.platform.debug-1f55404fc68a774b27b75351157af0544a2c56ae.tar.xz
eclipse.platform.debug-1f55404fc68a774b27b75351157af0544a2c56ae.zip
Bug 99067 - Add Memory Monitor dialog should stay up if there is an error adding a memory monitor
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryBlockAction.java269
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MonitorMemoryBlockDialog.java24
2 files changed, 165 insertions, 128 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryBlockAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryBlockAction.java
index bf19668c6..6a5174968 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryBlockAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryBlockAction.java
@@ -128,147 +128,166 @@ public class AddMemoryBlockAction extends Action implements ISelectionListener,
public void run() {
boolean pin = true;
- try {
-
- if (getMemoryView() != null)
- {
- pin = getMemoryView().isPinMBDisplay();
- getMemoryView().setPinMBDisplay(false);
- }
-
- // get current selection from Debug View
- ISelection selection = fSite.getSite().getPage().getSelection(IDebugUIConstants.ID_DEBUG_VIEW);
- Object elem = ((IStructuredSelection)selection).getFirstElement();
- if (!(elem instanceof IDebugElement))
- return;
- // ask debug element about memeory retrieval
- IDebugTarget debugTarget = ((IDebugElement)elem).getDebugTarget();
- IMemoryBlockRetrieval standardMemRetrieval = (IMemoryBlockRetrieval)((IDebugElement)elem).getAdapter(IMemoryBlockRetrieval.class);
- if (standardMemRetrieval == null)
- {
- // if getAdapter returns null, assume debug target as memory block retrieval
- standardMemRetrieval = debugTarget;
- }
- if (standardMemRetrieval == null)
- return;
- Shell shell= DebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
- // create dialog to ask for expression/address to block
- MonitorMemoryBlockDialog dialog = new MonitorMemoryBlockDialog(shell, standardMemRetrieval);
- dialog.open();
- int returnCode = dialog.getReturnCode();
- if (returnCode == Window.CANCEL)
- {
- return;
- }
- // get expression entered in dialog
- String input = dialog.getExpression();
- ArrayList expressions = new ArrayList();
-
- if (input.length() == 0)
- {
- expressions.add(""); //$NON-NLS-1$
- }
- else
- {
- StringTokenizer tokenizer = new StringTokenizer(input, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens())
+ boolean exit = false;
+ String prefillExp = null;
+ String prefillLength = null;
+ while (!exit)
+ {
+ exit = true;
+ try {
+
+ if (getMemoryView() != null)
{
- expressions.add(tokenizer.nextToken());
+ pin = getMemoryView().isPinMBDisplay();
+ getMemoryView().setPinMBDisplay(false);
}
- }
- String[] expressionsArray = (String[])expressions.toArray(new String[expressions.size()]);
- for (int i=0; i<expressionsArray.length; i++)
- {
- String expression = expressionsArray[i].trim();
- try {
- if (standardMemRetrieval instanceof IMemoryBlockRetrievalExtension)
+
+ // get current selection from Debug View
+ ISelection selection = fSite.getSite().getPage().getSelection(IDebugUIConstants.ID_DEBUG_VIEW);
+ Object elem = ((IStructuredSelection)selection).getFirstElement();
+ if (!(elem instanceof IDebugElement))
+ return;
+ // ask debug element about memeory retrieval
+ IDebugTarget debugTarget = ((IDebugElement)elem).getDebugTarget();
+ IMemoryBlockRetrieval standardMemRetrieval = (IMemoryBlockRetrieval)((IDebugElement)elem).getAdapter(IMemoryBlockRetrieval.class);
+ if (standardMemRetrieval == null)
+ {
+ // if getAdapter returns null, assume debug target as memory block retrieval
+ standardMemRetrieval = debugTarget;
+ }
+ if (standardMemRetrieval == null)
+ return;
+ Shell shell= DebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
+ // create dialog to ask for expression/address to block
+ MonitorMemoryBlockDialog dialog = new MonitorMemoryBlockDialog(shell, standardMemRetrieval, prefillExp, prefillLength);
+ dialog.open();
+ int returnCode = dialog.getReturnCode();
+ if (returnCode == Window.CANCEL)
+ {
+ return;
+ }
+ // get expression entered in dialog
+ String input = dialog.getExpression();
+
+ // remember expression and length
+ prefillExp = input;
+ prefillLength = dialog.getLength();
+
+ ArrayList expressions = new ArrayList();
+
+ if (input.length() == 0)
+ {
+ expressions.add(""); //$NON-NLS-1$
+ }
+ else
+ {
+ StringTokenizer tokenizer = new StringTokenizer(input, ","); //$NON-NLS-1$
+ while (tokenizer.hasMoreTokens())
{
- // if the debug session supports IMemoryBlockExtensionRetrieval
- IMemoryBlockRetrievalExtension memRetrieval = (IMemoryBlockRetrievalExtension)standardMemRetrieval;
-
- // get extended memory block with the expression entered
- IMemoryBlockExtension memBlock = memRetrieval.getExtendedMemoryBlock(expression, elem);
-
- // add block to memory block manager
- if (memBlock != null)
+ expressions.add(tokenizer.nextToken());
+ }
+ }
+ String[] expressionsArray = (String[])expressions.toArray(new String[expressions.size()]);
+ for (int i=0; i<expressionsArray.length; i++)
+ {
+ String expression = expressionsArray[i].trim();
+ try {
+ if (standardMemRetrieval instanceof IMemoryBlockRetrievalExtension)
{
- fLastMemoryBlock = memBlock;
+ // if the debug session supports IMemoryBlockExtensionRetrieval
+ IMemoryBlockRetrievalExtension memRetrieval = (IMemoryBlockRetrievalExtension)standardMemRetrieval;
- MemoryViewUtil.getMemoryBlockManager().addMemoryBlocks(new IMemoryBlock[]{memBlock});
- if (fAddDefaultRenderings)
- addDefaultRenderings(memBlock);
+ // get extended memory block with the expression entered
+ IMemoryBlockExtension memBlock = memRetrieval.getExtendedMemoryBlock(expression, elem);
+
+ // add block to memory block manager
+ if (memBlock != null)
+ {
+ fLastMemoryBlock = memBlock;
+
+ MemoryViewUtil.getMemoryBlockManager().addMemoryBlocks(new IMemoryBlock[]{memBlock});
+ if (fAddDefaultRenderings)
+ addDefaultRenderings(memBlock);
+ }
+ else
+ {
+ // open error if it failed to retrieve a memory block
+ MemoryViewUtil.openError(DebugUIMessages.AddMemoryBlockAction_title, DebugUIMessages.AddMemoryBlockAction_noMemoryBlock, null);
+ exit = false;
+ }
}
else
{
- // open error if it failed to retrieve a memory block
- MemoryViewUtil.openError(DebugUIMessages.AddMemoryBlockAction_title, DebugUIMessages.AddMemoryBlockAction_noMemoryBlock, null);
+ // if the debug session does not support IMemoryBlockExtensionRetrieval
+ expression = expression.toUpperCase();
+ String hexPrefix = "0X"; //$NON-NLS-1$
+ if (expression.startsWith(hexPrefix))
+ {
+ expression = expression.substring(hexPrefix.length());
+ }
+
+ // convert the expression to an address
+ BigInteger address = new BigInteger(expression, 16);
+
+ long longAddress = address.longValue();
+
+ // get the length of memory to block
+ String strLength = dialog.getLength();
+
+ long length = Long.parseLong(strLength);
+
+ // must monitor at least one line
+ if (length <= 0)
+ {
+ String message = DebugUIMessages.AddMemoryBlockAction_failed + "\n" + DebugUIMessages.AddMemoryBlockAction_input_invalid; //$NON-NLS-1$
+ MemoryViewUtil.openError(DebugUIMessages.AddMemoryBlockAction_title, message, null); //$NON-NLS-1$
+ exit = false;
+ continue;
+ }
+
+ // get standard memory block
+ IMemoryBlock memBlock = standardMemRetrieval.getMemoryBlock(longAddress, length);
+
+ // make sure the memory block returned is not an instance of IMemoryBlockExtension
+ if (memBlock instanceof IMemoryBlockExtension)
+ {
+ Status status = new Status(IStatus.WARNING, DebugUIPlugin.getUniqueIdentifier(), 0,
+ "IMemoryBlockRetrieval returns IMemoryBlockExtension. This may result in unexpected behavior.", null); //$NON-NLS-1$
+ DebugUIPlugin.log(status);
+ }
+
+ if (memBlock != null)
+ {
+ // add memory block to memory block manager
+ fLastMemoryBlock = memBlock;
+ MemoryViewUtil.getMemoryBlockManager().addMemoryBlocks(new IMemoryBlock[]{memBlock});
+ if (fAddDefaultRenderings)
+ addDefaultRenderings(memBlock);
+ }
+ else
+ {
+ // otherwise open up an error doalog
+ MemoryViewUtil.openError(DebugUIMessages.AddMemoryBlockAction_title, DebugUIMessages.AddMemoryBlockAction_noMemoryBlock, null);
+ exit = false;
+ }
}
+ } catch (DebugException e1) {
+ MemoryViewUtil.openError(DebugUIMessages.AddMemoryBlockAction_title, DebugUIMessages.AddMemoryBlockAction_failed, e1);
+ exit = false;
}
- else
+ catch(NumberFormatException e2)
{
- // if the debug session does not support IMemoryBlockExtensionRetrieval
- expression = expression.toUpperCase();
- String hexPrefix = "0X"; //$NON-NLS-1$
- if (expression.startsWith(hexPrefix))
- {
- expression = expression.substring(hexPrefix.length());
- }
-
- // convert the expression to an address
- BigInteger address = new BigInteger(expression, 16);
-
- long longAddress = address.longValue();
-
- // get the length of memory to block
- String strLength = dialog.getLength();
-
- long length = Long.parseLong(strLength);
-
- // must monitor at least one line
- if (length == 0)
- {
- length = IInternalDebugUIConstants.ADD_UNIT_PER_LINE;
- }
-
- // get standard memory block
- IMemoryBlock memBlock = standardMemRetrieval.getMemoryBlock(longAddress, length);
-
- // make sure the memory block returned is not an instance of IMemoryBlockExtension
- if (memBlock instanceof IMemoryBlockExtension)
- {
- Status status = new Status(IStatus.WARNING, DebugUIPlugin.getUniqueIdentifier(), 0,
- "IMemoryBlockRetrieval returns IMemoryBlockExtension. This may result in unexpected behavior.", null); //$NON-NLS-1$
- DebugUIPlugin.log(status);
- }
-
- if (memBlock != null)
- {
- // add memory block to memory block manager
- fLastMemoryBlock = memBlock;
- MemoryViewUtil.getMemoryBlockManager().addMemoryBlocks(new IMemoryBlock[]{memBlock});
- if (fAddDefaultRenderings)
- addDefaultRenderings(memBlock);
- }
- else
- {
- // otherwise open up an error doalog
- MemoryViewUtil.openError(DebugUIMessages.AddMemoryBlockAction_title, DebugUIMessages.AddMemoryBlockAction_noMemoryBlock, null);
- }
+ String message = DebugUIMessages.AddMemoryBlockAction_failed + "\n" + DebugUIMessages.AddMemoryBlockAction_input_invalid; //$NON-NLS-1$
+ MemoryViewUtil.openError(DebugUIMessages.AddMemoryBlockAction_title, message, null); //$NON-NLS-1$
+ exit = false;
}
- } catch (DebugException e1) {
- MemoryViewUtil.openError(DebugUIMessages.AddMemoryBlockAction_title, DebugUIMessages.AddMemoryBlockAction_failed, e1);
}
- catch(NumberFormatException e2)
+ } finally {
+ if (getMemoryView() != null)
{
- String message = DebugUIMessages.AddMemoryBlockAction_failed + "\n" + DebugUIMessages.AddMemoryBlockAction_input_invalid; //$NON-NLS-1$
- MemoryViewUtil.openError(DebugUIMessages.AddMemoryBlockAction_title, message, null); //$NON-NLS-1$
+ getMemoryView().setPinMBDisplay(pin);
}
}
- } finally {
- if (getMemoryView() != null)
- {
- getMemoryView().setPinMBDisplay(pin);
- }
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MonitorMemoryBlockDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MonitorMemoryBlockDialog.java
index c38c72bec..478c7c64b 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MonitorMemoryBlockDialog.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MonitorMemoryBlockDialog.java
@@ -42,16 +42,21 @@ public class MonitorMemoryBlockDialog extends Dialog implements ModifyListener{
private String expression;
private String length;
private boolean needLength = true;
+ private String fPrefillExp = null;
+ private String fPrefillLength = null;
/**
* @param parentShell
*/
- public MonitorMemoryBlockDialog(Shell parentShell, IMemoryBlockRetrieval memRetrieval) {
+ public MonitorMemoryBlockDialog(Shell parentShell, IMemoryBlockRetrieval memRetrieval, String prefillExp, String prefillLength) {
super(parentShell);
if (memRetrieval instanceof IMemoryBlockRetrievalExtension)
needLength = false;
+ fPrefillExp = prefillExp;
+ fPrefillLength = prefillLength;
+
PlatformUI.getWorkbench().getHelpSystem().setHelp(parentShell, IDebugUIConstants.PLUGIN_ID + ".MonitorMemoryBlockDialog_context"); //$NON-NLS-1$
}
@@ -90,6 +95,13 @@ public class MonitorMemoryBlockDialog extends Dialog implements ModifyListener{
expressionInput.add(historyExpression[i]);
}
+ // must be done before the listener is added
+ // otherwise, will get into exception when trying to validate
+ // input
+ // This will be validated when the OK & Cancel button is added.
+ if (fPrefillExp != null)
+ expressionInput.setText(fPrefillExp);
+
expressionInput.addModifyListener(this);
if (needLength)
@@ -106,6 +118,10 @@ public class MonitorMemoryBlockDialog extends Dialog implements ModifyListener{
lengthSpec.grabExcessHorizontalSpace= true;
lengthSpec.horizontalAlignment= GridData.FILL;
lengthInput.setLayoutData(lengthSpec);
+
+ if (fPrefillLength != null)
+ lengthInput.setText(fPrefillLength);
+
lengthInput.addModifyListener(this);
}
return parent;
@@ -150,7 +166,10 @@ public class MonitorMemoryBlockDialog extends Dialog implements ModifyListener{
* @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
*/
public void modifyText(ModifyEvent e) {
+ updateOKButtonState();
+ }
+ private void updateOKButtonState() {
if (needLength)
{
String lengthText = lengthInput.getText();
@@ -175,12 +194,11 @@ public class MonitorMemoryBlockDialog extends Dialog implements ModifyListener{
Control ret = super.createButtonBar(parent);
if (needLength)
- getButton(IDialogConstants.OK_ID).setEnabled(false);
+ updateOKButtonState();
else
// always enable the OK button if we only need the expression
getButton(IDialogConstants.OK_ID).setEnabled(true);
return ret;
}
-
}

Back to the top