1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 06:02:11 +02:00

Bug 398329 : MemoryBrowser - switching between debuggees does not update the provider for browser operations like Import and Export

Bug 398332 : The validation logic and feedback for all of the Importers/Exporters is very bad
This commit is contained in:
unknown 2013-01-16 17:37:03 -05:00 committed by Randy Rohrbach
parent 7c58fc5f33
commit 7bbf2d8511
9 changed files with 231 additions and 121 deletions

View file

@ -994,7 +994,9 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM
CTabFolder tabFolder = fContextFolders.get(retrieval); CTabFolder tabFolder = fContextFolders.get(retrieval);
if(tabFolder != null) { if(tabFolder != null) {
fStackLayout.topControl = tabFolder; fStackLayout.topControl = tabFolder;
handleTabActivated(tabFolder.getSelection()); CTabItem tabItem = (CTabItem) tabFolder.getSelection();
getSite().getSelectionProvider().setSelection(new StructuredSelection(tabItem.getData(KEY_RENDERING)));
handleTabActivated(tabItem);
} }
else { else {
tabFolder = createTabFolder(fRenderingsComposite); tabFolder = createTabFolder(fRenderingsComposite);

View file

@ -32,13 +32,11 @@
<importer <importer
name="%importer.name.0" name="%importer.name.0"
id="org.eclipse.cdt.debug.ui.memory.transport.SRecordImporter" id="org.eclipse.cdt.debug.ui.memory.transport.SRecordImporter"
maxmemorysize="32"
class="org.eclipse.cdt.debug.ui.memory.transport.SRecordImporter"> class="org.eclipse.cdt.debug.ui.memory.transport.SRecordImporter">
</importer> </importer>
<exporter <exporter
name="%exporter.name.0" name="%exporter.name.0"
id="org.eclipse.cdt.debug.ui.memory.transport.SRecordExporter" id="org.eclipse.cdt.debug.ui.memory.transport.SRecordExporter"
maxmemorysize="32"
class="org.eclipse.cdt.debug.ui.memory.transport.SRecordExporter"> class="org.eclipse.cdt.debug.ui.memory.transport.SRecordExporter">
</exporter> </exporter>

View file

@ -96,7 +96,7 @@ public class PlainTextExporter implements IMemoryExporter {
fStartText = new Text(composite, SWT.BORDER); fStartText = new Text(composite, SWT.BORDER);
data = new FormData(); data = new FormData();
data.left = new FormAttachment(startLabel); data.left = new FormAttachment(startLabel);
data.width = 100; data.width = 120;
fStartText.setLayoutData(data); fStartText.setLayoutData(data);
// end address // end address
@ -112,7 +112,7 @@ public class PlainTextExporter implements IMemoryExporter {
data = new FormData(); data = new FormData();
data.top = new FormAttachment(fStartText, 0, SWT.CENTER); data.top = new FormAttachment(fStartText, 0, SWT.CENTER);
data.left = new FormAttachment(endLabel); data.left = new FormAttachment(endLabel);
data.width = 100; data.width = 120;
fEndText.setLayoutData(data); fEndText.setLayoutData(data);
// length // length
@ -128,7 +128,7 @@ public class PlainTextExporter implements IMemoryExporter {
data = new FormData(); data = new FormData();
data.top = new FormAttachment(fStartText, 0, SWT.CENTER); data.top = new FormAttachment(fStartText, 0, SWT.CENTER);
data.left = new FormAttachment(lengthLabel); data.left = new FormAttachment(lengthLabel);
data.width = 100; data.width = 120;
fLengthText.setLayoutData(data); fLengthText.setLayoutData(data);
// file // file
@ -145,7 +145,7 @@ public class PlainTextExporter implements IMemoryExporter {
data = new FormData(); data = new FormData();
data.top = new FormAttachment(fileButton, 0, SWT.CENTER); data.top = new FormAttachment(fileButton, 0, SWT.CENTER);
data.left = new FormAttachment(fileLabel); data.left = new FormAttachment(fileLabel);
data.width = 300; data.width = 360;
fFileText.setLayoutData(data); fFileText.setLayoutData(data);
fileButton.setText(Messages.getString("Exporter.Browse")); //$NON-NLS-1$ fileButton.setText(Messages.getString("Exporter.Browse")); //$NON-NLS-1$
@ -189,26 +189,26 @@ public class PlainTextExporter implements IMemoryExporter {
fStartText.addKeyListener(new KeyListener() { fStartText.addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
boolean valid = true;
try try
{ {
getStartAddress(); fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
BigInteger actualLength = getEndAddress().subtract(getStartAddress());
fLengthText.setText(actualLength.toString());
if(actualLength.compareTo(BigInteger.ZERO) <= 0) {
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
}
} }
catch(Exception ex) catch(Exception ex)
{ {
valid = false; fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
} }
fStartText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) :
Display.getDefault().getSystemColor(SWT.COLOR_RED));
//
BigInteger endAddress = getEndAddress();
BigInteger startAddress = getStartAddress();
fLengthText.setText(endAddress.subtract(startAddress).toString());
validate(); validate();
} }
@ -219,20 +219,22 @@ public class PlainTextExporter implements IMemoryExporter {
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
try try
{ {
getEndAddress(); fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
BigInteger endAddress = getEndAddress(); BigInteger actualLength = getEndAddress().subtract(getStartAddress());
BigInteger startAddress = getStartAddress(); fLengthText.setText(actualLength.toString());
String lengthString = endAddress.subtract(startAddress).toString(); if(actualLength.compareTo(BigInteger.ZERO) <= 0) {
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
if(!fLengthText.getText().equals(lengthString)) fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
fLengthText.setText(lengthString); }
} }
catch(Exception ex) catch(Exception ex)
{ {
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
} }
validate(); validate();
@ -246,23 +248,31 @@ public class PlainTextExporter implements IMemoryExporter {
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
try try
{ {
BigInteger length = getLength(); fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
BigInteger startAddress = getStartAddress();
String endString = "0x" + startAddress.add(length).toString(16); //$NON-NLS-1$ BigInteger length = getLength();
if(!fEndText.getText().equals(endString)) String endString = "0x" + getStartAddress().add(length).toString(16); //$NON-NLS-1$
fStartText.setText(fStartText.getText().trim());
fEndText.setText(endString); fEndText.setText(endString);
if(length.compareTo(BigInteger.ZERO) <= 0) {
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
}
} }
catch(Exception ex) catch(Exception ex)
{ {
if ( fLengthText.getText().trim().length() != 0 ) {
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
}
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
} }
validate(); validate();
} }
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
} }
@ -273,9 +283,7 @@ public class PlainTextExporter implements IMemoryExporter {
validate(); validate();
} }
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {}
}
}); });
composite.pack(); composite.pack();
@ -301,6 +309,7 @@ public class PlainTextExporter implements IMemoryExporter {
public BigInteger getEndAddress() public BigInteger getEndAddress()
{ {
String text = fEndText.getText(); String text = fEndText.getText();
text = text.trim();
boolean hex = text.startsWith("0x"); //$NON-NLS-1$ boolean hex = text.startsWith("0x"); //$NON-NLS-1$
BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text, BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text,
hex ? 16 : 10); hex ? 16 : 10);
@ -311,6 +320,7 @@ public class PlainTextExporter implements IMemoryExporter {
public BigInteger getStartAddress() public BigInteger getStartAddress()
{ {
String text = fStartText.getText(); String text = fStartText.getText();
text = text.trim();
boolean hex = text.startsWith("0x"); //$NON-NLS-1$ boolean hex = text.startsWith("0x"); //$NON-NLS-1$
BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text,
hex ? 16 : 10); hex ? 16 : 10);
@ -321,6 +331,7 @@ public class PlainTextExporter implements IMemoryExporter {
public BigInteger getLength() public BigInteger getLength()
{ {
String text = fLengthText.getText(); String text = fLengthText.getText();
text = text.trim();
boolean hex = text.startsWith("0x"); //$NON-NLS-1$ boolean hex = text.startsWith("0x"); //$NON-NLS-1$
BigInteger lengthAddress = new BigInteger(hex ? text.substring(2) : text, BigInteger lengthAddress = new BigInteger(hex ? text.substring(2) : text,
hex ? 16 : 10); hex ? 16 : 10);
@ -340,7 +351,6 @@ public class PlainTextExporter implements IMemoryExporter {
try try
{ {
getEndAddress(); getEndAddress();
getStartAddress(); getStartAddress();
BigInteger length = getLength(); BigInteger length = getLength();
@ -348,8 +358,19 @@ public class PlainTextExporter implements IMemoryExporter {
if(length.compareTo(BigInteger.ZERO) <= 0) if(length.compareTo(BigInteger.ZERO) <= 0)
isValid = false; isValid = false;
if(!getFile().getParentFile().exists()) File file = getFile();
if ( file != null ) {
File parentFile = file.getParentFile();
if(parentFile != null && ! parentFile.exists() )
isValid = false; isValid = false;
if(parentFile != null && parentFile.exists() && ( ! parentFile.canRead() || ! parentFile.isDirectory() ) )
isValid = false;
if ( file.isDirectory() )
isValid = false;
}
} }
catch(Exception e) catch(Exception e)
{ {
@ -357,7 +378,6 @@ public class PlainTextExporter implements IMemoryExporter {
} }
fParentDialog.setValid(isValid); fParentDialog.setValid(isValid);
} }
public String getId() public String getId()

View file

@ -113,7 +113,7 @@ public class PlainTextImporter implements IMemoryImporter {
data = new FormData(); data = new FormData();
// data.top = new FormAttachment(fComboRestoreToFileAddress); // data.top = new FormAttachment(fComboRestoreToFileAddress);
data.left = new FormAttachment(labelStartText); data.left = new FormAttachment(labelStartText);
data.width = 100; data.width = 120;
fStartText.setLayoutData(data); fStartText.setLayoutData(data);
// file // file
@ -226,9 +226,10 @@ public class PlainTextImporter implements IMemoryImporter {
try try
{ {
getStartAddress(); getStartAddress();
if(!getFile().exists()) if(!getFile().exists()) {
isValid = false; isValid = false;
} }
}
catch(Exception e) catch(Exception e)
{ {
isValid = false; isValid = false;
@ -245,6 +246,7 @@ public class PlainTextImporter implements IMemoryImporter {
public BigInteger getStartAddress() public BigInteger getStartAddress()
{ {
String text = fStartText.getText(); String text = fStartText.getText();
text = text.trim();
boolean hex = text.startsWith("0x"); //$NON-NLS-1$ boolean hex = text.startsWith("0x"); //$NON-NLS-1$
BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text,
hex ? 16 : 10); hex ? 16 : 10);

View file

@ -95,7 +95,7 @@ public class RAWBinaryExporter implements IMemoryExporter
fStartText = new Text(composite, SWT.BORDER); fStartText = new Text(composite, SWT.BORDER);
data = new FormData(); data = new FormData();
data.left = new FormAttachment(startLabel); data.left = new FormAttachment(startLabel);
data.width = 100; data.width = 120;
fStartText.setLayoutData(data); fStartText.setLayoutData(data);
// end address // end address
@ -111,7 +111,7 @@ public class RAWBinaryExporter implements IMemoryExporter
data = new FormData(); data = new FormData();
data.top = new FormAttachment(fStartText, 0, SWT.CENTER); data.top = new FormAttachment(fStartText, 0, SWT.CENTER);
data.left = new FormAttachment(endLabel); data.left = new FormAttachment(endLabel);
data.width = 100; data.width = 120;
fEndText.setLayoutData(data); fEndText.setLayoutData(data);
// length // length
@ -127,7 +127,7 @@ public class RAWBinaryExporter implements IMemoryExporter
data = new FormData(); data = new FormData();
data.top = new FormAttachment(fStartText, 0, SWT.CENTER); data.top = new FormAttachment(fStartText, 0, SWT.CENTER);
data.left = new FormAttachment(lengthLabel); data.left = new FormAttachment(lengthLabel);
data.width = 100; data.width = 120;
fLengthText.setLayoutData(data); fLengthText.setLayoutData(data);
// file // file
@ -144,7 +144,7 @@ public class RAWBinaryExporter implements IMemoryExporter
data = new FormData(); data = new FormData();
data.top = new FormAttachment(fileButton, 0, SWT.CENTER); data.top = new FormAttachment(fileButton, 0, SWT.CENTER);
data.left = new FormAttachment(fileLabel); data.left = new FormAttachment(fileLabel);
data.width = 300; data.width = 360;
fFileText.setLayoutData(data); fFileText.setLayoutData(data);
fileButton.setText(Messages.getString("Exporter.Browse")); //$NON-NLS-1$ fileButton.setText(Messages.getString("Exporter.Browse")); //$NON-NLS-1$
@ -190,26 +190,26 @@ public class RAWBinaryExporter implements IMemoryExporter
fStartText.addKeyListener(new KeyListener() { fStartText.addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
boolean valid = true;
try try
{ {
getStartAddress(); fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
BigInteger actualLength = getEndAddress().subtract(getStartAddress());
fLengthText.setText(actualLength.toString());
if(actualLength.compareTo(BigInteger.ZERO) <= 0) {
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
}
} }
catch(Exception ex) catch(Exception ex)
{ {
valid = false; fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
} }
fStartText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) :
Display.getDefault().getSystemColor(SWT.COLOR_RED));
//
BigInteger endAddress = getEndAddress();
BigInteger startAddress = getStartAddress();
fLengthText.setText(endAddress.subtract(startAddress).toString());
validate(); validate();
} }
@ -220,20 +220,22 @@ public class RAWBinaryExporter implements IMemoryExporter
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
try try
{ {
getEndAddress(); fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
BigInteger endAddress = getEndAddress(); BigInteger actualLength = getEndAddress().subtract(getStartAddress());
BigInteger startAddress = getStartAddress(); fLengthText.setText(actualLength.toString());
String lengthString = endAddress.subtract(startAddress).toString(); if(actualLength.compareTo(BigInteger.ZERO) <= 0) {
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
if(!fLengthText.getText().equals(lengthString)) fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
fLengthText.setText(lengthString); }
} }
catch(Exception ex) catch(Exception ex)
{ {
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
} }
validate(); validate();
@ -247,23 +249,31 @@ public class RAWBinaryExporter implements IMemoryExporter
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
try try
{ {
BigInteger length = getLength(); fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
BigInteger startAddress = getStartAddress();
String endString = "0x" + startAddress.add(length).toString(16); //$NON-NLS-1$ BigInteger length = getLength();
if(!fEndText.getText().equals(endString)) String endString = "0x" + getStartAddress().add(length).toString(16); //$NON-NLS-1$
fStartText.setText(fStartText.getText().trim());
fEndText.setText(endString); fEndText.setText(endString);
if(length.compareTo(BigInteger.ZERO) <= 0) {
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
}
} }
catch(Exception ex) catch(Exception ex)
{ {
if ( fLengthText.getText().trim().length() != 0 ) {
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
}
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
} }
validate(); validate();
} }
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
} }
@ -274,9 +284,7 @@ public class RAWBinaryExporter implements IMemoryExporter
validate(); validate();
} }
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {}
}
}); });
composite.pack(); composite.pack();
@ -303,6 +311,7 @@ public class RAWBinaryExporter implements IMemoryExporter
public BigInteger getEndAddress() public BigInteger getEndAddress()
{ {
String text = fEndText.getText(); String text = fEndText.getText();
text = text.trim();
boolean hex = text.startsWith("0x"); //$NON-NLS-1$ boolean hex = text.startsWith("0x"); //$NON-NLS-1$
BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text, BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text,
hex ? 16 : 10); hex ? 16 : 10);
@ -313,6 +322,7 @@ public class RAWBinaryExporter implements IMemoryExporter
public BigInteger getStartAddress() public BigInteger getStartAddress()
{ {
String text = fStartText.getText(); String text = fStartText.getText();
text = text.trim();
boolean hex = text.startsWith("0x"); //$NON-NLS-1$ boolean hex = text.startsWith("0x"); //$NON-NLS-1$
BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text,
hex ? 16 : 10); hex ? 16 : 10);
@ -323,6 +333,7 @@ public class RAWBinaryExporter implements IMemoryExporter
public BigInteger getLength() public BigInteger getLength()
{ {
String text = fLengthText.getText(); String text = fLengthText.getText();
text = text.trim();
boolean hex = text.startsWith("0x"); //$NON-NLS-1$ boolean hex = text.startsWith("0x"); //$NON-NLS-1$
BigInteger lengthAddress = new BigInteger(hex ? text.substring(2) : text, BigInteger lengthAddress = new BigInteger(hex ? text.substring(2) : text,
hex ? 16 : 10); hex ? 16 : 10);
@ -342,7 +353,6 @@ public class RAWBinaryExporter implements IMemoryExporter
try try
{ {
getEndAddress(); getEndAddress();
getStartAddress(); getStartAddress();
BigInteger length = getLength(); BigInteger length = getLength();
@ -350,8 +360,19 @@ public class RAWBinaryExporter implements IMemoryExporter
if(length.compareTo(BigInteger.ZERO) <= 0) if(length.compareTo(BigInteger.ZERO) <= 0)
isValid = false; isValid = false;
if(!getFile().getParentFile().exists()) File file = getFile();
if ( file != null ) {
File parentFile = file.getParentFile();
if(parentFile != null && ! parentFile.exists() )
isValid = false; isValid = false;
if(parentFile != null && parentFile.exists() && ( ! parentFile.canRead() || ! parentFile.isDirectory() ) )
isValid = false;
if ( file.isDirectory() )
isValid = false;
}
} }
catch(Exception e) catch(Exception e)
{ {
@ -361,7 +382,6 @@ public class RAWBinaryExporter implements IMemoryExporter
fParentDialog.setValid(isValid); fParentDialog.setValid(isValid);
} }
public String getId() public String getId()
{ {
return "rawbinary"; //$NON-NLS-1$ return "rawbinary"; //$NON-NLS-1$

View file

@ -95,7 +95,7 @@ public class RAWBinaryImporter implements IMemoryImporter {
fStartText = new Text(composite, SWT.BORDER); fStartText = new Text(composite, SWT.BORDER);
FormData data = new FormData(); FormData data = new FormData();
data.left = new FormAttachment(labelStartText); data.left = new FormAttachment(labelStartText);
data.width = 100; data.width = 120;
fStartText.setLayoutData(data); fStartText.setLayoutData(data);
// file // file
@ -206,9 +206,10 @@ public class RAWBinaryImporter implements IMemoryImporter {
try try
{ {
getStartAddress(); getStartAddress();
if(!getFile().exists()) if(!getFile().exists()) {
isValid = false; isValid = false;
} }
}
catch(Exception e) catch(Exception e)
{ {
isValid = false; isValid = false;
@ -225,6 +226,7 @@ public class RAWBinaryImporter implements IMemoryImporter {
public BigInteger getStartAddress() public BigInteger getStartAddress()
{ {
String text = fStartText.getText(); String text = fStartText.getText();
text = text.trim();
boolean hex = text.startsWith("0x"); //$NON-NLS-1$ boolean hex = text.startsWith("0x"); //$NON-NLS-1$
BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text,
hex ? 16 : 10); hex ? 16 : 10);

View file

@ -98,7 +98,7 @@ public class SRecordExporter implements IMemoryExporter
fStartText = new Text(composite, SWT.BORDER); fStartText = new Text(composite, SWT.BORDER);
data = new FormData(); data = new FormData();
data.left = new FormAttachment(startLabel); data.left = new FormAttachment(startLabel);
data.width = 100; data.width = 120;
fStartText.setLayoutData(data); fStartText.setLayoutData(data);
// end address // end address
@ -114,7 +114,7 @@ public class SRecordExporter implements IMemoryExporter
data = new FormData(); data = new FormData();
data.top = new FormAttachment(fStartText, 0, SWT.CENTER); data.top = new FormAttachment(fStartText, 0, SWT.CENTER);
data.left = new FormAttachment(endLabel); data.left = new FormAttachment(endLabel);
data.width = 100; data.width = 120;
fEndText.setLayoutData(data); fEndText.setLayoutData(data);
// length // length
@ -130,7 +130,7 @@ public class SRecordExporter implements IMemoryExporter
data = new FormData(); data = new FormData();
data.top = new FormAttachment(fStartText, 0, SWT.CENTER); data.top = new FormAttachment(fStartText, 0, SWT.CENTER);
data.left = new FormAttachment(lengthLabel); data.left = new FormAttachment(lengthLabel);
data.width = 100; data.width = 120;
fLengthText.setLayoutData(data); fLengthText.setLayoutData(data);
// file // file
@ -147,7 +147,7 @@ public class SRecordExporter implements IMemoryExporter
data = new FormData(); data = new FormData();
data.top = new FormAttachment(fileButton, 0, SWT.CENTER); data.top = new FormAttachment(fileButton, 0, SWT.CENTER);
data.left = new FormAttachment(fileLabel); data.left = new FormAttachment(fileLabel);
data.width = 300; data.width = 360;
fFileText.setLayoutData(data); fFileText.setLayoutData(data);
fileButton.setText(Messages.getString("Exporter.Browse")); //$NON-NLS-1$ fileButton.setText(Messages.getString("Exporter.Browse")); //$NON-NLS-1$
@ -156,6 +156,24 @@ public class SRecordExporter implements IMemoryExporter
data.left = new FormAttachment(fFileText); data.left = new FormAttachment(fFileText);
fileButton.setLayoutData(data); fileButton.setLayoutData(data);
// Restriction notice about 32-bit support
Label spacingLabel = new Label(composite, SWT.NONE);
spacingLabel.setText(""); //$NON-NLS-1$
data = new FormData();
data.left = new FormAttachment(0);
data.top = new FormAttachment(fileLabel);
spacingLabel.setLayoutData(data);
Label restrictionLabel = new Label(composite, SWT.NONE);
restrictionLabel.setText(Messages.getString("SRecordExporter.32BitLimitationMessage")); //$NON-NLS-1$
data = new FormData();
data.left = new FormAttachment(0);
data.top = new FormAttachment(spacingLabel);
restrictionLabel.setLayoutData(data);
String textValue = fProperties.get(TRANSFER_FILE); String textValue = fProperties.get(TRANSFER_FILE);
fFileText.setText(textValue != null ? textValue : ""); //$NON-NLS-1$ fFileText.setText(textValue != null ? textValue : ""); //$NON-NLS-1$
@ -171,7 +189,6 @@ public class SRecordExporter implements IMemoryExporter
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
} }
textValue = fProperties.get(TRANSFER_END); textValue = fProperties.get(TRANSFER_END);
fEndText.setText(textValue != null ? textValue : "0x0"); //$NON-NLS-1$ fEndText.setText(textValue != null ? textValue : "0x0"); //$NON-NLS-1$
@ -186,7 +203,11 @@ public class SRecordExporter implements IMemoryExporter
try try
{ {
fLengthText.setText(getEndAddress().subtract(getStartAddress()).toString()); BigInteger length = getEndAddress().subtract(getStartAddress());
fLengthText.setText(length.toString());
if(length.compareTo(BigInteger.ZERO) <= 0) {
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
}
} }
catch(Exception e) catch(Exception e)
{ {
@ -225,21 +246,24 @@ public class SRecordExporter implements IMemoryExporter
try try
{ {
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
BigInteger actualLength = getEndAddress().subtract(getStartAddress()); fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
String lengthString = actualLength.toString(); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
if(!fLengthText.getText().equals(lengthString)) { BigInteger actualLength = getEndAddress().subtract(getStartAddress());
if ( ! actualLength.equals( BigInteger.ZERO ) ) { fLengthText.setText(actualLength.toString());
fLengthText.setText(lengthString);
if(actualLength.compareTo(BigInteger.ZERO) <= 0) {
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
} }
} }
validate();
}
catch(Exception ex) catch(Exception ex)
{ {
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
validate(); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
} }
validate();
} }
public void keyPressed(KeyEvent e) {} public void keyPressed(KeyEvent e) {}
@ -249,24 +273,25 @@ public class SRecordExporter implements IMemoryExporter
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
try try
{ {
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
BigInteger actualLength = getEndAddress().subtract(getStartAddress()); BigInteger actualLength = getEndAddress().subtract(getStartAddress());
String lengthString = actualLength.toString(); fLengthText.setText(actualLength.toString());
if(!fLengthText.getText().equals(lengthString)) { if(actualLength.compareTo(BigInteger.ZERO) <= 0) {
if ( ! actualLength.equals( BigInteger.ZERO ) ) { fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
fLengthText.setText(lengthString); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
} }
} }
validate();
}
catch(Exception ex) catch(Exception ex)
{ {
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
validate(); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
} }
validate();
} }
public void keyPressed(KeyEvent e) {} public void keyPressed(KeyEvent e) {}
@ -277,21 +302,29 @@ public class SRecordExporter implements IMemoryExporter
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
try try
{ {
BigInteger length = getLength(); fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
BigInteger length = getLength();
String endString = "0x" + getStartAddress().add(length).toString(16); //$NON-NLS-1$ String endString = "0x" + getStartAddress().add(length).toString(16); //$NON-NLS-1$
if(!fEndText.getText().equals(endString)) { fStartText.setText(fStartText.getText().trim());
if ( ! length.equals( BigInteger.ZERO ) ) {
fEndText.setText(endString); fEndText.setText(endString);
if(length.compareTo(BigInteger.ZERO) <= 0) {
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
} }
} }
validate();
}
catch(Exception ex) catch(Exception ex)
{ {
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); if ( fLengthText.getText().trim().length() != 0 ) {
validate(); fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
} }
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
}
validate();
} }
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
@ -333,6 +366,7 @@ public class SRecordExporter implements IMemoryExporter
public BigInteger getEndAddress() public BigInteger getEndAddress()
{ {
String text = fEndText.getText(); String text = fEndText.getText();
text = text.trim();
boolean hex = text.startsWith("0x"); //$NON-NLS-1$ boolean hex = text.startsWith("0x"); //$NON-NLS-1$
BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text, BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text,
hex ? 16 : 10); hex ? 16 : 10);
@ -347,6 +381,7 @@ public class SRecordExporter implements IMemoryExporter
public BigInteger getStartAddress() public BigInteger getStartAddress()
{ {
String text = fStartText.getText(); String text = fStartText.getText();
text = text.trim();
boolean hex = text.startsWith("0x"); //$NON-NLS-1$ boolean hex = text.startsWith("0x"); //$NON-NLS-1$
BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text,
hex ? 16 : 10); hex ? 16 : 10);
@ -361,6 +396,7 @@ public class SRecordExporter implements IMemoryExporter
public BigInteger getLength() public BigInteger getLength()
{ {
String text = fLengthText.getText(); String text = fLengthText.getText();
text = text.trim();
boolean hex = text.startsWith("0x"); //$NON-NLS-1$ boolean hex = text.startsWith("0x"); //$NON-NLS-1$
BigInteger lengthAddress = new BigInteger(hex ? text.substring(2) : text, BigInteger lengthAddress = new BigInteger(hex ? text.substring(2) : text,
hex ? 16 : 10); hex ? 16 : 10);
@ -381,7 +417,6 @@ public class SRecordExporter implements IMemoryExporter
try try
{ {
getEndAddress(); getEndAddress();
getStartAddress(); getStartAddress();
BigInteger length = getLength(); BigInteger length = getLength();
@ -389,8 +424,19 @@ public class SRecordExporter implements IMemoryExporter
if(length.compareTo(BigInteger.ZERO) <= 0) if(length.compareTo(BigInteger.ZERO) <= 0)
isValid = false; isValid = false;
if(!getFile().getParentFile().exists()) File file = getFile();
if ( file != null ) {
File parentFile = file.getParentFile();
if(parentFile != null && ! parentFile.exists() )
isValid = false; isValid = false;
if(parentFile != null && parentFile.exists() && ( ! parentFile.canRead() || ! parentFile.isDirectory() ) )
isValid = false;
if ( file.isDirectory() )
isValid = false;
}
} }
catch(Exception e) catch(Exception e)
{ {
@ -400,7 +446,6 @@ public class SRecordExporter implements IMemoryExporter
fParentDialog.setValid(isValid); fParentDialog.setValid(isValid);
} }
public String getId() public String getId()
{ {
return "srecord"; //$NON-NLS-1$ return "srecord"; //$NON-NLS-1$

View file

@ -115,7 +115,7 @@ public class SRecordImporter implements IMemoryImporter {
data = new FormData(); data = new FormData();
data.top = new FormAttachment(fComboRestoreToFileAddress); data.top = new FormAttachment(fComboRestoreToFileAddress);
data.left = new FormAttachment(fComboRestoreToThisAddress); data.left = new FormAttachment(fComboRestoreToThisAddress);
data.width = 100; data.width = 120;
fStartText.setLayoutData(data); fStartText.setLayoutData(data);
fComboRestoreToFileAddress.addSelectionListener(new SelectionListener() { fComboRestoreToFileAddress.addSelectionListener(new SelectionListener() {
@ -247,6 +247,24 @@ public class SRecordImporter implements IMemoryImporter {
final boolean scrollToStart = fProperties.getBoolean(TRANSFER_SCROLL_TO_START); final boolean scrollToStart = fProperties.getBoolean(TRANSFER_SCROLL_TO_START);
fScrollToBeginningOnImportComplete.setSelection(scrollToStart); fScrollToBeginningOnImportComplete.setSelection(scrollToStart);
// Restriction notice about 32-bit support
Label spacingLabel = new Label(composite, SWT.NONE);
spacingLabel.setText(""); //$NON-NLS-1$
data = new FormData();
data.left = new FormAttachment(0);
data.top = new FormAttachment(fScrollToBeginningOnImportComplete);
spacingLabel.setLayoutData(data);
Label restrictionLabel = new Label(composite, SWT.NONE);
restrictionLabel.setText(Messages.getString("SRecordImporter.32BitLimitationMessage")); //$NON-NLS-1$
data = new FormData();
data.left = new FormAttachment(0);
data.top = new FormAttachment(spacingLabel);
restrictionLabel.setLayoutData(data);
composite.pack(); composite.pack();
parent.pack(); parent.pack();
@ -294,6 +312,7 @@ public class SRecordImporter implements IMemoryImporter {
public BigInteger getStartAddress() public BigInteger getStartAddress()
{ {
String text = fStartText.getText(); String text = fStartText.getText();
text = text.trim();
boolean hex = text.startsWith("0x"); //$NON-NLS-1$ boolean hex = text.startsWith("0x"); //$NON-NLS-1$
BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text,
hex ? 16 : 10); hex ? 16 : 10);

View file

@ -51,6 +51,7 @@ SRecordExporter.EndAddress=End address:
SRecordExporter.Length=Length: SRecordExporter.Length=Length:
SRecordExporter.Name=SRecord SRecordExporter.Name=SRecord
SRecordExporter.StartAddress=Start address: SRecordExporter.StartAddress=Start address:
SRecordExporter.32BitLimitationMessage=SRecord format only supports 32-bit address spaces.
SRecordImporter.ChecksumFalure=Checksum failure of line = SRecordImporter.ChecksumFalure=Checksum failure of line =
SRecordImporter.ChooseFile=Choose memory import file SRecordImporter.ChooseFile=Choose memory import file
@ -62,6 +63,7 @@ SRecordImporter.InvalidData=Invalid file format. Invalid data at line %d
SRecordImporter.InvalidLineLength=Invalid file format. Invalid line length at line %d SRecordImporter.InvalidLineLength=Invalid file format. Invalid line length at line %d
SRecordImporter.Name=SRecord SRecordImporter.Name=SRecord
SRecordImporter.ScrollToStart=Scroll to restore address SRecordImporter.ScrollToStart=Scroll to restore address
SRecordImporter.32BitLimitationMessage=SRecord format only supports 32-bit address spaces.
RAWBinaryExporter.ChooseFile=Choose memory export file RAWBinaryExporter.ChooseFile=Choose memory export file
RAWBinaryExporter.EndAddress=End address: RAWBinaryExporter.EndAddress=End address: