1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

[247765] [memory] implement "scroll to start address" for memory importers

This commit is contained in:
Ted Williams 2008-09-18 01:16:41 +00:00
parent a26d5d6642
commit fb9f3b039c
4 changed files with 70 additions and 4 deletions

View file

@ -11,21 +11,26 @@
package org.eclipse.dd.debug.ui.memory.transport;
import java.math.BigInteger;
import java.util.Properties;
import java.util.Vector;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryExporter;
import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryImporter;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.views.memory.MemoryView;
import org.eclipse.debug.internal.ui.views.memory.RenderingViewPane;
import org.eclipse.debug.ui.memory.IMemoryRendering;
import org.eclipse.debug.ui.memory.IMemoryRenderingContainer;
import org.eclipse.debug.ui.memory.IRepositionableMemoryRendering;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
@ -36,10 +41,12 @@ import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.SelectionDialog;
import org.eclipse.ui.progress.UIJob;
public class ImportMemoryDialog extends SelectionDialog
{
@ -55,13 +62,50 @@ public class ImportMemoryDialog extends SelectionDialog
private Properties fProperties = new Properties();
public ImportMemoryDialog(Shell parent, IMemoryBlock memoryBlock)
private MemoryView fMemoryView;
public ImportMemoryDialog(Shell parent, IMemoryBlock memoryBlock, MemoryView view)
{
super(parent);
super.setTitle("Download to Memory");
setShellStyle(getShellStyle() | SWT.RESIZE);
fMemoryBlock = memoryBlock;
fMemoryView = view;
}
protected void scrollRenderings(final BigInteger address)
{
UIJob job = new UIJob("repositionRenderings"){ //$NON-NLS-1$
public IStatus runInUIThread(IProgressMonitor monitor) {
final IMemoryRenderingContainer containers[] = fMemoryView.getMemoryRenderingContainers();
for(int i = 0; i < containers.length; i++)
{
if(containers[i] instanceof RenderingViewPane)
{
IMemoryRendering rendering = containers[i].getActiveRendering();
if(rendering instanceof IRepositionableMemoryRendering)
{
try
{
((IRepositionableMemoryRendering) rendering).goToAddress(address);
}
catch (DebugException e)
{
// do nothing
}
}
}
}
return Status.OK_STATUS;
}};
job.setSystem(true);
job.setThread(Display.getDefault().getThread());
job.schedule();
}
/* (non-Javadoc)

View file

@ -294,6 +294,8 @@ public class PlainTextImporter implements IMemoryImporter {
if(!fUseCustomAddress)
offset = BigInteger.ZERO;
BigInteger scrollToAddress = null;
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(fInputFile)));
BigInteger jobs = BigInteger.valueOf(fInputFile.length());
@ -323,6 +325,9 @@ public class PlainTextImporter implements IMemoryImporter {
data[i] = new BigInteger(valueString.substring(position++, position++ + 1), 16).byteValue();
}
if(scrollToAddress == null)
scrollToAddress = recordAddress;
((IMemoryBlockExtension) fMemoryBlock).setValue(recordAddress.subtract(((IMemoryBlockExtension)
fMemoryBlock).getBigBaseAddress()).add(BigInteger.valueOf(bytesRead)), data);
@ -343,6 +348,9 @@ public class PlainTextImporter implements IMemoryImporter {
reader.close();
monitor.done();
if(fProperties.getProperty(TRANSFER_SCROLL_TO_START, "false").equals("true"))
fParentDialog.scrollRenderings(scrollToAddress);
}
catch(Exception e)
{

View file

@ -289,6 +289,8 @@ public class SRecordImporter implements IMemoryImporter {
final int CHECKSUM_LENGTH = 1;
BigInteger scrollToAddress = null;
BigInteger offset = null;
if(!fUseCustomAddress)
offset = BigInteger.ZERO;
@ -364,6 +366,9 @@ public class SRecordImporter implements IMemoryImporter {
return new Status( IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), "Checksum failure of line = " + line); //$NON-NLS-1$
}
if(scrollToAddress == null)
scrollToAddress = recordAddress;
// FIXME error on incorrect checksum
((IMemoryBlockExtension) fMemoryBlock).setValue(recordAddress.subtract(((IMemoryBlockExtension) fMemoryBlock).getBigBaseAddress()), data);
@ -380,6 +385,9 @@ public class SRecordImporter implements IMemoryImporter {
reader.close();
monitor.done();
if(fProperties.getProperty(TRANSFER_SCROLL_TO_START, "false").equals("true"))
fParentDialog.scrollRenderings(scrollToAddress);
}
catch(Exception e)
{

View file

@ -16,7 +16,9 @@ import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.views.memory.MemoryView;
import org.eclipse.debug.internal.ui.views.memory.MemoryViewIdRegistry;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.contexts.IDebugContextService;
import org.eclipse.debug.ui.memory.IMemoryRendering;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
@ -36,6 +38,10 @@ public class ImportMemoryAction implements IViewActionDelegate {
public void init(IViewPart view) {
if (view instanceof MemoryView)
fView = (MemoryView) view;
// IDebugContextService debugContextService = DebugUITools.getDebugContextManager().getContextService(view.getSite().getWorkbenchWindow());
// this.
// debugContextService.getActiveContext();
}
private IMemoryBlock getMemoryBlock(ISelection selection)
@ -71,7 +77,7 @@ public class ImportMemoryAction implements IViewActionDelegate {
if(memBlock == null)
return;
ImportMemoryDialog dialog = new ImportMemoryDialog(DebugUIPlugin.getShell(), memBlock);
ImportMemoryDialog dialog = new ImportMemoryDialog(DebugUIPlugin.getShell(), memBlock, fView);
dialog.open();
dialog.getResult();