diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 945df88dc9e..028943ab1d2 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -328,6 +328,12 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe super.deactivated(); } + + public void setSelection(BigInteger start, BigInteger end) + { + fRendering.getSelection().setStart(start, start); + fRendering.getSelection().setEnd(end, end); + } public void gotoAddress(final BigInteger address) { diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java index 6b822ab54a3..621ce9ee792 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java @@ -11,6 +11,8 @@ package org.eclipse.dd.debug.ui.memory.search; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.math.BigInteger; import java.util.Properties; import java.util.StringTokenizer; @@ -885,7 +887,7 @@ public class FindReplaceDialog extends SelectionDialog public IStatus run(IProgressMonitor monitor) throws OperationCanceledException { - BigInteger searchPhraseLength = BigInteger.valueOf(searchPhrase.getByteLength()); + final BigInteger searchPhraseLength = BigInteger.valueOf(searchPhrase.getByteLength()); BigInteger range = searchForward ? end.subtract(start) : start.subtract(end); BigInteger currentPosition = start; @@ -918,7 +920,7 @@ public class FindReplaceDialog extends SelectionDialog if(matched) { if(all && !isReplace) - ((MemorySearchResult) getSearchResult()).addMatch("0x" + currentPosition.toString(16)); //$NON-NLS-1$ + ((MemorySearchResult) getSearchResult()).addMatch(new MemoryMatch(currentPosition, searchPhraseLength)); if(isReplace) { @@ -958,6 +960,17 @@ public class FindReplaceDialog extends SelectionDialog MemorySearchPlugin.logError(Messages.getString("FindReplaceDialog.RepositioningMemoryViewFailed"), e); //$NON-NLS-1$ } } + if(rendering != null) + { + // Temporary, until platform accepts/adds new interface for setting the selection + try { + Method m = rendering.getClass().getMethod("setSelection", new Class[] { BigInteger.class, BigInteger.class } ); + if(m != null) + m.invoke(rendering, finalCurrentPosition, finalCurrentPosition.add(searchPhraseLength)); + } catch (Exception e) { + // do nothing + } + } } } diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemoryMatch.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemoryMatch.java new file mode 100644 index 00000000000..596547bb622 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemoryMatch.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2008 Wind River Systems, Inc. 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 + * + * Contributors: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.search; + +import java.math.BigInteger; + +public class MemoryMatch +{ + BigInteger fStartAddress; + + public BigInteger getStartAddress() { + return fStartAddress; + } + + public void setStartAddress(BigInteger startAddress) { + fStartAddress = startAddress; + } + + public BigInteger getLength() { + return fLength; + } + + public void setLength(BigInteger length) { + fLength = length; + } + + BigInteger fLength; + + public MemoryMatch(BigInteger startAddress, BigInteger length) + { + fStartAddress = startAddress; + fLength = length; + } + + public BigInteger getEndAddress() + { + return getStartAddress().add(getLength()); + } +} diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResult.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResult.java index 32f7fa08958..41f040bbe79 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResult.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResult.java @@ -53,15 +53,15 @@ public class MemorySearchResult implements ISearchResult return fLabel; } - public String[] getMatches() + public MemoryMatch[] getMatches() { - String matches[] = new String[fMatches.size()]; + MemoryMatch matches[] = new MemoryMatch[fMatches.size()]; for(int i = 0; i < matches.length; i++) - matches[i] = (String) fMatches.elementAt(i); + matches[i] = (MemoryMatch) fMatches.elementAt(i); return matches; } - public void addMatch(String address) + public void addMatch(MemoryMatch address) { fMatches.addElement(address); fireChange(); diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResultsPage.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResultsPage.java index 4a3cb184fd3..2dc4a1e83fd 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResultsPage.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResultsPage.java @@ -11,6 +11,7 @@ package org.eclipse.dd.debug.ui.memory.search; +import java.lang.reflect.Method; import java.math.BigInteger; import org.eclipse.dd.debug.ui.memory.search.FindReplaceDialog.IMemorySearchQuery; @@ -177,17 +178,30 @@ public class MemorySearchResultsPage extends Page implements ISearchResultPage, if( event.getSelection() instanceof StructuredSelection) { IMemoryRenderingContainer containers[] = ((IMemorySearchQuery) fQuery).getMemoryView().getMemoryRenderingContainers(); + MemoryMatch match = (MemoryMatch) ((StructuredSelection) event.getSelection()).getFirstElement(); for(int i = 0; i < containers.length; i++) { IMemoryRendering rendering = containers[i].getActiveRendering(); if(rendering instanceof IRepositionableMemoryRendering) { try { - ((IRepositionableMemoryRendering) rendering).goToAddress(new BigInteger(((StructuredSelection) event.getSelection()).getFirstElement().toString().substring(2), 16)); + ((IRepositionableMemoryRendering) rendering).goToAddress(match.getStartAddress()); } catch (DebugException e) { MemorySearchPlugin.logError(Messages.getString("MemorySearchResultsPage.RepositioningMemoryViewFailed"), e); //$NON-NLS-1$ } } + + if(rendering != null) + { + // Temporary, until platform accepts/adds new interface for setting the selection + try { + Method m = rendering.getClass().getMethod("setSelection", new Class[] { BigInteger.class, BigInteger.class } ); //$NON-NLS-1$ + if(m != null) + m.invoke(rendering, match.getStartAddress(), match.getEndAddress()); + } catch (Exception e) { + // do nothing + } + } } } } @@ -201,6 +215,9 @@ public class MemorySearchResultsPage extends Page implements ISearchResultPage, } public String getText(Object element) { + if(element instanceof MemoryMatch) + return "0x" + ((MemoryMatch) element).getStartAddress().toString(16); //$NON-NLS-1$ + return element.toString(); }