diff --git a/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/Rendering.java b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/Rendering.java index 8dc505b316e..359c2349838 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/Rendering.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/Rendering.java @@ -90,7 +90,7 @@ public class Rendering extends Composite implements IDebugEventSetListener private int fCurrentScrollSelection = 0; // current scroll selection; - private BigInteger fCaretAddress = BigInteger.valueOf(0); // -1 ? + private BigInteger fCaretAddress; // user settings @@ -463,7 +463,11 @@ public class Rendering extends Composite implements IDebugEventSetListener protected BigInteger getCaretAddress() { - return fCaretAddress; + // Return the caret address if it has been set, otherwise return the + // viewport address. When the rendering is first created, the caret is + // unset until the user clicks somewhere in the rendering. It also reset + // (unset) when the user gives us a new viewport address + return (fCaretAddress != null) ? fCaretAddress : fViewportAddress; } private void doGoToAddress() { @@ -1469,7 +1473,12 @@ public class Rendering extends Composite implements IDebugEventSetListener return; } - fViewportAddress = address; // TODO update fCaretAddress + fViewportAddress = address; + + // reset the caret and selection state (no caret and no selection) + fCaretAddress = null; + fSelection = new Selection(); + redrawPanes(); } diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ExportMemoryDialog.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ExportMemoryDialog.java index 0301c554a72..942965a971a 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ExportMemoryDialog.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ExportMemoryDialog.java @@ -11,6 +11,7 @@ package org.eclipse.cdt.debug.ui.memory.transport; +import java.math.BigInteger; import java.util.Properties; import java.util.Vector; @@ -51,14 +52,17 @@ public class ExportMemoryDialog extends SelectionDialog private String fFormatNames[]; private Properties fProperties = new Properties(); + + private BigInteger fInitialStartAddr; - public ExportMemoryDialog(Shell parent, IMemoryBlock memoryBlock) + public ExportMemoryDialog(Shell parent, IMemoryBlock memoryBlock, BigInteger initialStartAddr) { super(parent); super.setTitle("Export Memory"); setShellStyle(getShellStyle() | SWT.RESIZE); fMemoryBlock = memoryBlock; + fInitialStartAddr = initialStartAddr; } /* (non-Javadoc) @@ -181,6 +185,7 @@ public class ExportMemoryDialog extends SelectionDialog public void widgetSelected(SelectionEvent e) { if(fCurrentControl != null) fCurrentControl.dispose(); + initProperties(fProperties, fInitialStartAddr); fCurrentControl = fFormatExporters[fFormatCombo.getSelectionIndex()].createControl(container, fMemoryBlock, fProperties, ExportMemoryDialog.this); } @@ -188,12 +193,25 @@ public class ExportMemoryDialog extends SelectionDialog fFormatCombo.select(0); + initProperties(fProperties, fInitialStartAddr); fCurrentControl = fFormatExporters[0].createControl(container, fMemoryBlock, fProperties, ExportMemoryDialog.this); return composite; } + /** + * Initializes the start and end address properties to a particular value if + * and only if we have a fresh/clean properties object. + */ + static void initProperties(Properties properties, BigInteger addr) { + final String addrstr = "0x" + addr.toString(16); + if (!properties.containsKey(IMemoryExporter.TRANSFER_START)) { + properties.setProperty(IMemoryExporter.TRANSFER_START, addrstr); + properties.setProperty(IMemoryExporter.TRANSFER_END, addrstr); + } + } + public void setValid(boolean isValid) { getButton(IDialogConstants.OK_ID).setEnabled(isValid); diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ImportMemoryDialog.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ImportMemoryDialog.java index 68cce024e96..df606088915 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ImportMemoryDialog.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ImportMemoryDialog.java @@ -15,6 +15,7 @@ import java.math.BigInteger; import java.util.Properties; import java.util.Vector; +import org.eclipse.cdt.debug.ui.memory.transport.model.IMemoryExporter; import org.eclipse.cdt.debug.ui.memory.transport.model.IMemoryImporter; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionPoint; @@ -62,8 +63,10 @@ public class ImportMemoryDialog extends SelectionDialog private Properties fProperties = new Properties(); private IMemoryRenderingSite fMemoryView; + + private BigInteger fInitialStartAddr; - public ImportMemoryDialog(Shell parent, IMemoryBlock memoryBlock, IMemoryRenderingSite renderingSite) + public ImportMemoryDialog(Shell parent, IMemoryBlock memoryBlock, BigInteger initialStartAddr, IMemoryRenderingSite renderingSite) { super(parent); super.setTitle("Download to Memory"); @@ -71,6 +74,7 @@ public class ImportMemoryDialog extends SelectionDialog fMemoryBlock = memoryBlock; fMemoryView = renderingSite; + fInitialStartAddr = initialStartAddr; } protected void scrollRenderings(final BigInteger address) @@ -226,18 +230,33 @@ public class ImportMemoryDialog extends SelectionDialog public void widgetSelected(SelectionEvent e) { if(fCurrentControl != null) fCurrentControl.dispose(); + + initProperties(fProperties, fInitialStartAddr); // use utility from export code fCurrentControl = fFormatImporters[fFormatCombo.getSelectionIndex()].createControl(container, fMemoryBlock, fProperties, ImportMemoryDialog.this); } }); fFormatCombo.select(0); + + initProperties(fProperties, fInitialStartAddr); // use utility from export code fCurrentControl = fFormatImporters[0].createControl(container,fMemoryBlock, fProperties, ImportMemoryDialog.this); return composite; } - + + /** + * Initializes the start address properties to a particular value if + * and only if we have a fresh/clean properties object. + */ + static void initProperties(Properties properties, BigInteger addr) { + final String addrstr = "0x" + addr.toString(16); + if (!properties.containsKey(IMemoryExporter.TRANSFER_START)) { + properties.setProperty(IMemoryExporter.TRANSFER_START, addrstr); + } + } + public void setValid(boolean isValid) { getButton(IDialogConstants.OK_ID).setEnabled(isValid); diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java index 48d62a568d7..837f82810bc 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java @@ -157,26 +157,11 @@ public class PlainTextExporter implements IMemoryExporter { fFileText.setText(properties.getProperty(TRANSFER_FILE, "")); try { - BigInteger startAddress = null; - if(fMemoryBlock instanceof IMemoryBlockExtension) - startAddress = ((IMemoryBlockExtension) fMemoryBlock) - .getBigBaseAddress(); // FIXME use selection/caret address? - else - startAddress = BigInteger.valueOf(fMemoryBlock.getStartAddress()); - - if(properties.getProperty(TRANSFER_START) != null) - fStartText.setText(properties.getProperty(TRANSFER_START)); - else - fStartText.setText("0x" + startAddress.toString(16)); - - if(properties.getProperty(TRANSFER_END) != null) - fEndText.setText(properties.getProperty(TRANSFER_END)); - else - fEndText.setText("0x" + startAddress.toString(16)); - + fStartText.setText(properties.getProperty(TRANSFER_START)); + fEndText.setText(properties.getProperty(TRANSFER_END)); fLengthText.setText(getEndAddress().subtract(getStartAddress()).toString()); } - catch(Exception e) + catch(IllegalArgumentException e) { MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextImporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextImporter.java index 2da8b589549..02403238339 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextImporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextImporter.java @@ -144,20 +144,9 @@ public class PlainTextImporter implements IMemoryImporter { fScrollToStart = new Boolean(properties.getProperty(TRANSFER_SCROLL_TO_START, "true")); try { - BigInteger startAddress = null; - if(fMemoryBlock instanceof IMemoryBlockExtension) - startAddress = ((IMemoryBlockExtension) fMemoryBlock) - .getBigBaseAddress(); // FIXME use selection/caret address? - else - startAddress = BigInteger.valueOf(fMemoryBlock.getStartAddress()); - - if(properties.getProperty(TRANSFER_START) != null) - fStartText.setText(properties.getProperty(TRANSFER_START)); - else - fStartText.setText("0x" + startAddress.toString(16)); - + fStartText.setText(properties.getProperty(TRANSFER_START)); } - catch(Exception e) + catch(IllegalArgumentException e) { MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryExporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryExporter.java index ca15bfdd2a8..8000ff24075 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryExporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryExporter.java @@ -155,25 +155,11 @@ public class RAWBinaryExporter implements IMemoryExporter fFileText.setText(properties.getProperty(TRANSFER_FILE, "")); try { - BigInteger startAddress = null; - if(fMemoryBlock instanceof IMemoryBlockExtension) - startAddress = ((IMemoryBlockExtension) fMemoryBlock).getBigBaseAddress(); - else - startAddress = BigInteger.valueOf(fMemoryBlock.getStartAddress()); - - if(properties.getProperty(TRANSFER_START) != null) - fStartText.setText(properties.getProperty(TRANSFER_START)); - else - fStartText.setText("0x" + startAddress.toString(16)); - - if(properties.getProperty(TRANSFER_END) != null) - fEndText.setText(properties.getProperty(TRANSFER_END)); - else - fEndText.setText("0x" + startAddress.toString(16)); - + fStartText.setText(properties.getProperty(TRANSFER_START)); + fEndText.setText(properties.getProperty(TRANSFER_END)); fLengthText.setText(getEndAddress().subtract(getStartAddress()).toString()); } - catch(Exception e) + catch(IllegalArgumentException e) { MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryImporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryImporter.java index d0270ae962e..2026e546fa4 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryImporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryImporter.java @@ -121,19 +121,9 @@ public class RAWBinaryImporter implements IMemoryImporter { fScrollToStart = new Boolean(properties.getProperty(TRANSFER_SCROLL_TO_START, "true")); try { - BigInteger startAddress = null; - if(fMemoryBlock instanceof IMemoryBlockExtension) - startAddress = ((IMemoryBlockExtension) fMemoryBlock).getBigBaseAddress(); - else - startAddress = BigInteger.valueOf(fMemoryBlock.getStartAddress()); - - if(properties.getProperty(TRANSFER_START) != null) - fStartText.setText(properties.getProperty(TRANSFER_START)); - else - fStartText.setText("0x" + startAddress.toString(16)); - + fStartText.setText(properties.getProperty(TRANSFER_START)); } - catch(Exception e) + catch(IllegalArgumentException e) { MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordExporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordExporter.java index 8e6f61b7c9a..83f70cf5c1d 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordExporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordExporter.java @@ -155,26 +155,11 @@ public class SRecordExporter implements IMemoryExporter fFileText.setText(properties.getProperty(TRANSFER_FILE, "")); try { - BigInteger startAddress = null; - if(fMemoryBlock instanceof IMemoryBlockExtension) - startAddress = ((IMemoryBlockExtension) fMemoryBlock) - .getBigBaseAddress(); // FIXME use selection/caret address? - else - startAddress = BigInteger.valueOf(fMemoryBlock.getStartAddress()); - - if(properties.getProperty(TRANSFER_START) != null) - fStartText.setText(properties.getProperty(TRANSFER_START)); - else - fStartText.setText("0x" + startAddress.toString(16)); - - if(properties.getProperty(TRANSFER_END) != null) - fEndText.setText(properties.getProperty(TRANSFER_END)); - else - fEndText.setText("0x" + startAddress.toString(16)); - + fStartText.setText(properties.getProperty(TRANSFER_START)); + fEndText.setText(properties.getProperty(TRANSFER_END)); fLengthText.setText(getEndAddress().subtract(getStartAddress()).toString()); } - catch(Exception e) + catch(IllegalArgumentException e) { MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordImporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordImporter.java index 4a586c48d8d..550db13bb47 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordImporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordImporter.java @@ -159,20 +159,9 @@ public class SRecordImporter implements IMemoryImporter { fScrollToStart = new Boolean(properties.getProperty(TRANSFER_SCROLL_TO_START, "true")); try { - BigInteger startAddress = null; - if(fMemoryBlock instanceof IMemoryBlockExtension) - startAddress = ((IMemoryBlockExtension) fMemoryBlock) - .getBigBaseAddress(); // FIXME use selection/caret address? - else - startAddress = BigInteger.valueOf(fMemoryBlock.getStartAddress()); - - if(properties.getProperty(TRANSFER_START) != null) - fStartText.setText(properties.getProperty(TRANSFER_START)); - else - fStartText.setText("0x" + startAddress.toString(16)); - + fStartText.setText(properties.getProperty(TRANSFER_START)); } - catch(Exception e) + catch(IllegalArgumentException e) { MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/actions/ExportMemoryAction.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/actions/ExportMemoryAction.java index 460ded8bbe6..075ed6150ee 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/actions/ExportMemoryAction.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/actions/ExportMemoryAction.java @@ -11,11 +11,16 @@ package org.eclipse.cdt.debug.ui.memory.transport.actions; +import java.math.BigInteger; + import org.eclipse.cdt.debug.ui.memory.transport.ExportMemoryDialog; import org.eclipse.cdt.debug.ui.memory.transport.MemoryTransportPlugin; +import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; import org.eclipse.debug.ui.memory.IMemoryRendering; import org.eclipse.debug.ui.memory.IMemoryRenderingSite; +import org.eclipse.debug.ui.memory.IRepositionableMemoryRendering; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; @@ -34,46 +39,89 @@ public class ExportMemoryAction implements IViewActionDelegate { fView = (IMemoryRenderingSite) view; } - private IMemoryBlock getMemoryBlock(ISelection selection) + + /** + * Utility PODS to return a memory block and an address from a method + */ + static class BlockAndAddress { + + static public final BlockAndAddress EMPTY = new BlockAndAddress(null, BigInteger.valueOf(0)); + + public BlockAndAddress(IMemoryBlock block, BigInteger addr) { + this.block = block; + this.addr = addr; + } + + public IMemoryBlock block; + public BigInteger addr; + } + + /** + * Returns the memory block and initial base address for the export + * operation. + * + * @return a result object; null is never returned + */ + static BlockAndAddress getMemoryBlockAndInitialStartAddress(ISelection selection) { + IMemoryBlock memBlock = null; + BigInteger initialStartAddr = null; if (selection instanceof IStructuredSelection) { IStructuredSelection strucSel = (IStructuredSelection) selection; // return if current selection is empty if (strucSel.isEmpty()) - return null; + return BlockAndAddress.EMPTY; Object obj = strucSel.getFirstElement(); if (obj == null) - return null; + return BlockAndAddress.EMPTY; + // Get the initial start address for the operation. if (obj instanceof IMemoryRendering) { memBlock = ((IMemoryRendering) obj).getMemoryBlock(); + if (obj instanceof IRepositionableMemoryRendering) { + initialStartAddr = ((IRepositionableMemoryRendering)obj).getSelectedAddress(); + } } else if (obj instanceof IMemoryBlock) { memBlock = (IMemoryBlock) obj; } + + if (initialStartAddr == null) { + if (memBlock instanceof IMemoryBlockExtension) { + try { + initialStartAddr = ((IMemoryBlockExtension)memBlock).getBigBaseAddress(); + } catch (DebugException e) { + initialStartAddr = BigInteger.valueOf(memBlock.getStartAddress()); + } + } + else { + initialStartAddr = BigInteger.valueOf(memBlock.getStartAddress()); + } + } } - return memBlock; + + return new BlockAndAddress(memBlock, initialStartAddr); } public void run(IAction action) { ISelection selection = fView.getSite().getSelectionProvider() .getSelection(); - IMemoryBlock memBlock = getMemoryBlock(selection); - if(memBlock == null) + BlockAndAddress blockAndAddr = getMemoryBlockAndInitialStartAddress(selection); + if(blockAndAddr.block == null) return; - ExportMemoryDialog dialog = new ExportMemoryDialog(MemoryTransportPlugin.getShell(), memBlock); + ExportMemoryDialog dialog = new ExportMemoryDialog(MemoryTransportPlugin.getShell(), blockAndAddr.block, blockAndAddr.addr); dialog.open(); dialog.getResult(); } public void selectionChanged(IAction action, ISelection selection) { - action.setEnabled(getMemoryBlock(selection) != null); + action.setEnabled(getMemoryBlockAndInitialStartAddress(selection).block != null); } } diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/actions/ImportMemoryAction.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/actions/ImportMemoryAction.java index 872fa075f60..ec9a0f66d22 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/actions/ImportMemoryAction.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/actions/ImportMemoryAction.java @@ -13,13 +13,9 @@ package org.eclipse.cdt.debug.ui.memory.transport.actions; import org.eclipse.cdt.debug.ui.memory.transport.ImportMemoryDialog; import org.eclipse.cdt.debug.ui.memory.transport.MemoryTransportPlugin; -import org.eclipse.debug.core.model.IMemoryBlock; -import org.eclipse.debug.internal.ui.views.memory.MemoryView; -import org.eclipse.debug.ui.memory.IMemoryRendering; import org.eclipse.debug.ui.memory.IMemoryRenderingSite; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewPart; @@ -36,47 +32,25 @@ public class ImportMemoryAction implements IViewActionDelegate { fView = (IMemoryRenderingSite) view; } - private IMemoryBlock getMemoryBlock(ISelection selection) - { - IMemoryBlock memBlock = null; - - if (selection instanceof IStructuredSelection) { - IStructuredSelection strucSel = (IStructuredSelection) selection; - - // return if current selection is empty - if (strucSel.isEmpty()) - return null; - - Object obj = strucSel.getFirstElement(); - - if (obj == null) - return null; - - if (obj instanceof IMemoryRendering) { - memBlock = ((IMemoryRendering) obj).getMemoryBlock(); - } else if (obj instanceof IMemoryBlock) { - memBlock = (IMemoryBlock) obj; - } - } - return memBlock; - } - public void run(IAction action) { ISelection selection = fView.getSite().getSelectionProvider() .getSelection(); - IMemoryBlock memBlock = getMemoryBlock(selection); - if(memBlock == null) + + // use utility function in export code + ExportMemoryAction.BlockAndAddress blockAndAddr = ExportMemoryAction.getMemoryBlockAndInitialStartAddress(selection); + if(blockAndAddr.block == null) return; - ImportMemoryDialog dialog = new ImportMemoryDialog(MemoryTransportPlugin.getShell(), memBlock, fView); + ImportMemoryDialog dialog = new ImportMemoryDialog(MemoryTransportPlugin.getShell(), blockAndAddr.block, blockAndAddr.addr, fView); dialog.open(); dialog.getResult(); } public void selectionChanged(IAction action, ISelection selection) { - action.setEnabled(getMemoryBlock(selection) != null); + // use utility function in export code + action.setEnabled(ExportMemoryAction.getMemoryBlockAndInitialStartAddress(selection).block != null); } } diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/model/IMemoryExporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/model/IMemoryExporter.java index d90853b8fce..8f3da546fe3 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/model/IMemoryExporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/model/IMemoryExporter.java @@ -24,6 +24,13 @@ public interface IMemoryExporter public static final String TRANSFER_START = "Start"; public static final String TRANSFER_END = "End"; + /** + * @param parent + * @param memBlock + * @param properties This will contain initial values for TRANSFER_START and TRANSFER_END. + * @param parentDialog + * @return + */ public Control createControl(Composite parent, IMemoryBlock memBlock, Properties properties, ExportMemoryDialog parentDialog); public void exportMemory(); diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/model/IMemoryImporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/model/IMemoryImporter.java index 5defe42fc6e..1541c43ae0a 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/model/IMemoryImporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/model/IMemoryImporter.java @@ -22,10 +22,16 @@ public interface IMemoryImporter { public static final String TRANSFER_FILE = "File"; public static final String TRANSFER_START = "Start"; - public static final String TRANSFER_END = "End"; public static final String TRANSFER_CUSTOM_START_ADDRESS = "CustomStartAddress"; public static final String TRANSFER_SCROLL_TO_START = "ScrollToStart"; + /** + * @param parent + * @param memBlock + * @param properties This will contain an initial values for TRANSFER_START + * @param parentDialog + * @return + */ public Control createControl(Composite parent, IMemoryBlock memBlock, Properties properties, ImportMemoryDialog parentDialog); public void importMemory();