mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
[245752] [memory] Search results should be highlighted
This commit is contained in:
parent
db563baeb9
commit
6958d0987f
5 changed files with 91 additions and 7 deletions
|
@ -329,6 +329,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)
|
||||
{
|
||||
this.fRendering.gotoAddress(address);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue