1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-02 13:55:39 +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

Added more error checking. See comments in the bugzillas for the details.
This commit is contained in:
Randy Rohrbach 2013-01-21 17:20:49 -05:00
parent 629232eae1
commit 975d6f48e2
6 changed files with 89 additions and 48 deletions

View file

@ -69,13 +69,17 @@ public class PlainTextExporter implements IMemoryExporter {
@Override @Override
public void dispose() public void dispose()
{ {
fProperties.put(TRANSFER_FILE, fFileText.getText()); fProperties.put(TRANSFER_FILE, fFileText.getText().trim());
fProperties.put(TRANSFER_START, fStartText.getText()); fProperties.put(TRANSFER_START, fStartText.getText().trim());
fProperties.put(TRANSFER_END, fEndText.getText()); fProperties.put(TRANSFER_END, fEndText.getText().trim());
fStartAddress = getStartAddress(); try
fEndAddress = getEndAddress(); {
fOutputFile = getFile(); fStartAddress = getStartAddress();
fEndAddress = getEndAddress();
fOutputFile = getFile();
}
catch(Exception e) {}
super.dispose(); super.dispose();
} }
@ -203,7 +207,7 @@ public class PlainTextExporter implements IMemoryExporter {
dialog.setText(Messages.getString("PlainTextExporter.ChooseFile")); //$NON-NLS-1$ dialog.setText(Messages.getString("PlainTextExporter.ChooseFile")); //$NON-NLS-1$
dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$NON-NLS-1$
dialog.setFilterNames(new String[] { Messages.getString("Exporter.AllFiles") } ); //$NON-NLS-1$ dialog.setFilterNames(new String[] { Messages.getString("Exporter.AllFiles") } ); //$NON-NLS-1$
dialog.setFileName(fFileText.getText()); dialog.setFileName(fFileText.getText().trim());
dialog.open(); dialog.open();
String filename = dialog.getFileName(); String filename = dialog.getFileName();
@ -419,7 +423,7 @@ public class PlainTextExporter implements IMemoryExporter {
public File getFile() public File getFile()
{ {
return new File(fFileText.getText()); return new File(fFileText.getText().trim());
} }
private void validate() private void validate()
@ -436,6 +440,9 @@ public class PlainTextExporter implements IMemoryExporter {
if(length.compareTo(BigInteger.ZERO) <= 0) if(length.compareTo(BigInteger.ZERO) <= 0)
isValid = false; isValid = false;
if ( fFileText.getText().trim().length() == 0 )
isValid = false;
File file = getFile(); File file = getFile();
if ( file != null ) { if ( file != null ) {
File parentFile = file.getParentFile(); File parentFile = file.getParentFile();

View file

@ -76,13 +76,17 @@ public class PlainTextImporter implements IMemoryImporter {
@Override @Override
public void dispose() public void dispose()
{ {
fProperties.put(TRANSFER_FILE, fFileText.getText()); fProperties.put(TRANSFER_FILE, fFileText.getText().trim());
fProperties.put(TRANSFER_START, fStartText.getText()); fProperties.put(TRANSFER_START, fStartText.getText().trim());
fProperties.put(TRANSFER_SCROLL_TO_START, fScrollToBeginningOnImportComplete.getSelection()); fProperties.put(TRANSFER_SCROLL_TO_START, fScrollToBeginningOnImportComplete.getSelection());
fStartAddress = getStartAddress(); try
fInputFile = getFile(); {
fScrollToStart = getScrollToStart(); fStartAddress = getStartAddress();
fInputFile = getFile();
fScrollToStart = getScrollToStart();
}
catch(Exception e) {}
super.dispose(); super.dispose();
} }
@ -157,7 +161,7 @@ public class PlainTextImporter implements IMemoryImporter {
dialog.setText(Messages.getString("PlainTextImporter.ChooseFile")); //$NON-NLS-1$ dialog.setText(Messages.getString("PlainTextImporter.ChooseFile")); //$NON-NLS-1$
dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$NON-NLS-1$
dialog.setFilterNames(new String[] { Messages.getString("Importer.AllFiles") } ); //$NON-NLS-1$ dialog.setFilterNames(new String[] { Messages.getString("Importer.AllFiles") } ); //$NON-NLS-1$
dialog.setFileName(fFileText.getText()); dialog.setFileName(fFileText.getText().trim());
dialog.open(); dialog.open();
String filename = dialog.getFileName(); String filename = dialog.getFileName();
@ -226,6 +230,11 @@ public class PlainTextImporter implements IMemoryImporter {
try try
{ {
getStartAddress(); getStartAddress();
if ( fFileText.getText().trim().length() == 0 )
isValid = false;
if(!getFile().exists()) { if(!getFile().exists()) {
isValid = false; isValid = false;
} }
@ -256,7 +265,7 @@ public class PlainTextImporter implements IMemoryImporter {
public File getFile() public File getFile()
{ {
return new File(fFileText.getText()); return new File(fFileText.getText().trim());
} }
public String getId() public String getId()

View file

@ -69,13 +69,17 @@ public class RAWBinaryExporter implements IMemoryExporter
@Override @Override
public void dispose() public void dispose()
{ {
fProperties.put(TRANSFER_FILE, fFileText.getText()); fProperties.put(TRANSFER_FILE, fFileText.getText().trim());
fProperties.put(TRANSFER_START, fStartText.getText()); fProperties.put(TRANSFER_START, fStartText.getText().trim());
fProperties.put(TRANSFER_END, fEndText.getText()); fProperties.put(TRANSFER_END, fEndText.getText().trim());
fStartAddress = getStartAddress(); try
fEndAddress = getEndAddress(); {
fOutputFile = getFile(); fStartAddress = getStartAddress();
fEndAddress = getEndAddress();
fOutputFile = getFile();
}
catch(Exception e) {}
super.dispose(); super.dispose();
} }
@ -204,7 +208,7 @@ public class RAWBinaryExporter implements IMemoryExporter
dialog.setText(Messages.getString("RAWBinaryExporter.ChooseFile")); //$NON-NLS-1$ dialog.setText(Messages.getString("RAWBinaryExporter.ChooseFile")); //$NON-NLS-1$
dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$NON-NLS-1$
dialog.setFilterNames(new String[] { Messages.getString("Exporter.AllFiles") } ); //$NON-NLS-1$ dialog.setFilterNames(new String[] { Messages.getString("Exporter.AllFiles") } ); //$NON-NLS-1$
dialog.setFileName(fFileText.getText()); dialog.setFileName(fFileText.getText().trim());
dialog.open(); dialog.open();
String filename = dialog.getFileName(); String filename = dialog.getFileName();
@ -421,7 +425,7 @@ public class RAWBinaryExporter implements IMemoryExporter
public File getFile() public File getFile()
{ {
return new File(fFileText.getText()); return new File(fFileText.getText().trim());
} }
private void validate() private void validate()
@ -438,6 +442,9 @@ public class RAWBinaryExporter implements IMemoryExporter
if(length.compareTo(BigInteger.ZERO) <= 0) if(length.compareTo(BigInteger.ZERO) <= 0)
isValid = false; isValid = false;
if ( fFileText.getText().trim().length() == 0 )
isValid = false;
File file = getFile(); File file = getFile();
if ( file != null ) { if ( file != null ) {
File parentFile = file.getParentFile(); File parentFile = file.getParentFile();

View file

@ -71,13 +71,17 @@ public class RAWBinaryImporter implements IMemoryImporter {
@Override @Override
public void dispose() public void dispose()
{ {
fProperties.put(TRANSFER_FILE, fFileText.getText()); fProperties.put(TRANSFER_FILE, fFileText.getText().trim());
fProperties.put(TRANSFER_START, fStartText.getText()); fProperties.put(TRANSFER_START, fStartText.getText().trim());
fProperties.put(TRANSFER_SCROLL_TO_START, fScrollToBeginningOnImportComplete.getSelection()); fProperties.put(TRANSFER_SCROLL_TO_START, fScrollToBeginningOnImportComplete.getSelection());
fStartAddress = getStartAddress(); try
fInputFile = getFile(); {
fScrollToStart = getScrollToStart(); fStartAddress = getStartAddress();
fInputFile = getFile();
fScrollToStart = getScrollToStart();
}
catch(Exception e) {}
super.dispose(); super.dispose();
} }
@ -137,7 +141,7 @@ public class RAWBinaryImporter implements IMemoryImporter {
dialog.setText(Messages.getString("RAWBinaryImporter.ChooseFile")); //$NON-NLS-1$ dialog.setText(Messages.getString("RAWBinaryImporter.ChooseFile")); //$NON-NLS-1$
dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$NON-NLS-1$
dialog.setFilterNames(new String[] { Messages.getString("Importer.AllFiles") } ); //$NON-NLS-1$ dialog.setFilterNames(new String[] { Messages.getString("Importer.AllFiles") } ); //$NON-NLS-1$
dialog.setFileName(fFileText.getText()); dialog.setFileName(fFileText.getText().trim());
dialog.open(); dialog.open();
String filename = dialog.getFileName(); String filename = dialog.getFileName();
@ -206,6 +210,11 @@ public class RAWBinaryImporter implements IMemoryImporter {
try try
{ {
getStartAddress(); getStartAddress();
if ( fFileText.getText().trim().length() == 0 )
isValid = false;
if(!getFile().exists()) { if(!getFile().exists()) {
isValid = false; isValid = false;
} }
@ -236,7 +245,7 @@ public class RAWBinaryImporter implements IMemoryImporter {
public File getFile() public File getFile()
{ {
return new File(fFileText.getText()); return new File(fFileText.getText().trim());
} }
public String getId() public String getId()

View file

@ -68,9 +68,9 @@ public class SRecordExporter implements IMemoryExporter
{ {
public void dispose() public void dispose()
{ {
fProperties.put(TRANSFER_FILE, fFileText.getText()); fProperties.put(TRANSFER_FILE, fFileText.getText().trim());
fProperties.put(TRANSFER_START, fStartText.getText()); fProperties.put(TRANSFER_START, fStartText.getText().trim());
fProperties.put(TRANSFER_END, fEndText.getText()); fProperties.put(TRANSFER_END, fEndText.getText().trim());
try try
{ {
@ -227,7 +227,7 @@ public class SRecordExporter implements IMemoryExporter
dialog.setText(Messages.getString("SRecordExporter.ChooseFile")); //$NON-NLS-1$ dialog.setText(Messages.getString("SRecordExporter.ChooseFile")); //$NON-NLS-1$
dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$NON-NLS-1$
dialog.setFilterNames(new String[] { Messages.getString("Exporter.AllFiles") } ); //$NON-NLS-1$ dialog.setFilterNames(new String[] { Messages.getString("Exporter.AllFiles") } ); //$NON-NLS-1$
dialog.setFileName(fFileText.getText()); dialog.setFileName(fFileText.getText().trim());
dialog.open(); dialog.open();
String filename = dialog.getFileName(); String filename = dialog.getFileName();
@ -455,7 +455,7 @@ public class SRecordExporter implements IMemoryExporter
public File getFile() public File getFile()
{ {
return new File(fFileText.getText()); return new File(fFileText.getText().trim());
} }
private void validate() private void validate()
@ -472,6 +472,9 @@ public class SRecordExporter implements IMemoryExporter
if(length.compareTo(BigInteger.ZERO) <= 0) if(length.compareTo(BigInteger.ZERO) <= 0)
isValid = false; isValid = false;
if ( fFileText.getText().trim().length() == 0 )
isValid = false;
File file = getFile(); File file = getFile();
if ( file != null ) { if ( file != null ) {
File parentFile = file.getParentFile(); File parentFile = file.getParentFile();

View file

@ -77,14 +77,20 @@ public class SRecordImporter implements IMemoryImporter {
{ {
public void dispose() public void dispose()
{ {
fProperties.put(TRANSFER_FILE, fFileText.getText()); fProperties.put(TRANSFER_FILE, fFileText.getText().trim());
fProperties.put(TRANSFER_START, fStartText.getText()); fProperties.put(TRANSFER_START, fStartText.getText().trim());
fProperties.put(TRANSFER_SCROLL_TO_START, fScrollToBeginningOnImportComplete.getSelection()); fProperties.put(TRANSFER_SCROLL_TO_START, fScrollToBeginningOnImportComplete.getSelection());
fProperties.put(TRANSFER_CUSTOM_START_ADDRESS, fComboRestoreToThisAddress.getSelection()); fProperties.put(TRANSFER_CUSTOM_START_ADDRESS, fComboRestoreToThisAddress.getSelection());
fStartAddress = getStartAddress(); try
fInputFile = getFile(); {
fScrollToStart = getScrollToStart(); if(fProperties.getBoolean(TRANSFER_CUSTOM_START_ADDRESS)) {
fStartAddress = getStartAddress();
}
fInputFile = getFile();
fScrollToStart = getScrollToStart();
}
catch(Exception e) {}
super.dispose(); super.dispose();
} }
@ -187,7 +193,7 @@ public class SRecordImporter implements IMemoryImporter {
dialog.setText(Messages.getString("SRecordImporter.ChooseFile")); //$NON-NLS-1$ dialog.setText(Messages.getString("SRecordImporter.ChooseFile")); //$NON-NLS-1$
dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$NON-NLS-1$
dialog.setFilterNames(new String[] { Messages.getString("Importer.AllFiles") } ); //$NON-NLS-1$ dialog.setFilterNames(new String[] { Messages.getString("Importer.AllFiles") } ); //$NON-NLS-1$
dialog.setFileName(fFileText.getText()); dialog.setFileName(fFileText.getText().trim());
dialog.open(); dialog.open();
String filename = dialog.getFileName(); String filename = dialog.getFileName();
@ -289,11 +295,11 @@ public class SRecordImporter implements IMemoryImporter {
getStartAddress(); getStartAddress();
} }
boolean restoreToAddressFromFile = fComboRestoreToFileAddress.getSelection(); if ( fFileText.getText().trim().length() == 0 )
if ( restoreToAddressFromFile ) { isValid = false;
if(!getFile().exists()) {
isValid = false; if(!getFile().exists()) {
} isValid = false;
} }
} }
catch(Exception e) catch(Exception e)
@ -327,7 +333,7 @@ public class SRecordImporter implements IMemoryImporter {
public File getFile() public File getFile()
{ {
return new File(fFileText.getText()); return new File(fFileText.getText().trim());
} }
public String getId() public String getId()