From 85cbc065411d387b1f20b507c619c1939ed3e2cb Mon Sep 17 00:00:00 2001 From: Randy Rohrbach Date: Mon, 21 Jan 2013 17:20:49 -0500 Subject: 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. --- .../ui/memory/transport/PlainTextExporter.java | 25 +++++++++++------- .../ui/memory/transport/PlainTextImporter.java | 23 ++++++++++++----- .../ui/memory/transport/RAWBinaryExporter.java | 23 +++++++++++------ .../ui/memory/transport/RAWBinaryImporter.java | 23 ++++++++++++----- .../debug/ui/memory/transport/SRecordExporter.java | 13 ++++++---- .../debug/ui/memory/transport/SRecordImporter.java | 30 +++++++++++++--------- 6 files changed, 89 insertions(+), 48 deletions(-) diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java index ffeb18f5788..d6e5e1d9452 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java @@ -69,13 +69,17 @@ public class PlainTextExporter implements IMemoryExporter { @Override public void dispose() { - fProperties.put(TRANSFER_FILE, fFileText.getText()); - fProperties.put(TRANSFER_START, fStartText.getText()); - fProperties.put(TRANSFER_END, fEndText.getText()); + fProperties.put(TRANSFER_FILE, fFileText.getText().trim()); + fProperties.put(TRANSFER_START, fStartText.getText().trim()); + fProperties.put(TRANSFER_END, fEndText.getText().trim()); - fStartAddress = getStartAddress(); - fEndAddress = getEndAddress(); - fOutputFile = getFile(); + try + { + fStartAddress = getStartAddress(); + fEndAddress = getEndAddress(); + fOutputFile = getFile(); + } + catch(Exception e) {} super.dispose(); } @@ -203,7 +207,7 @@ public class PlainTextExporter implements IMemoryExporter { dialog.setText(Messages.getString("PlainTextExporter.ChooseFile")); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$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(); String filename = dialog.getFileName(); @@ -419,7 +423,7 @@ public class PlainTextExporter implements IMemoryExporter { public File getFile() { - return new File(fFileText.getText()); + return new File(fFileText.getText().trim()); } private void validate() @@ -436,6 +440,9 @@ public class PlainTextExporter implements IMemoryExporter { if(length.compareTo(BigInteger.ZERO) <= 0) isValid = false; + if ( fFileText.getText().trim().length() == 0 ) + isValid = false; + File file = getFile(); if ( file != null ) { File parentFile = file.getParentFile(); @@ -457,7 +464,7 @@ public class PlainTextExporter implements IMemoryExporter { fParentDialog.setValid(isValid); } - + public String getId() { return "PlainTextExporter"; //$NON-NLS-1$ diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextImporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextImporter.java index acb587d00c2..c06fcfeb58e 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextImporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextImporter.java @@ -76,13 +76,17 @@ public class PlainTextImporter implements IMemoryImporter { @Override public void dispose() { - fProperties.put(TRANSFER_FILE, fFileText.getText()); - fProperties.put(TRANSFER_START, fStartText.getText()); + fProperties.put(TRANSFER_FILE, fFileText.getText().trim()); + fProperties.put(TRANSFER_START, fStartText.getText().trim()); fProperties.put(TRANSFER_SCROLL_TO_START, fScrollToBeginningOnImportComplete.getSelection()); - fStartAddress = getStartAddress(); - fInputFile = getFile(); - fScrollToStart = getScrollToStart(); + try + { + fStartAddress = getStartAddress(); + fInputFile = getFile(); + fScrollToStart = getScrollToStart(); + } + catch(Exception e) {} super.dispose(); } @@ -157,7 +161,7 @@ public class PlainTextImporter implements IMemoryImporter { dialog.setText(Messages.getString("PlainTextImporter.ChooseFile")); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$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(); String filename = dialog.getFileName(); @@ -226,6 +230,11 @@ public class PlainTextImporter implements IMemoryImporter { try { getStartAddress(); + + + if ( fFileText.getText().trim().length() == 0 ) + isValid = false; + if(!getFile().exists()) { isValid = false; } @@ -256,7 +265,7 @@ public class PlainTextImporter implements IMemoryImporter { public File getFile() { - return new File(fFileText.getText()); + return new File(fFileText.getText().trim()); } public String getId() diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryExporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryExporter.java index 1f4190cafbd..801071fde49 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryExporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryExporter.java @@ -69,13 +69,17 @@ public class RAWBinaryExporter implements IMemoryExporter @Override public void dispose() { - fProperties.put(TRANSFER_FILE, fFileText.getText()); - fProperties.put(TRANSFER_START, fStartText.getText()); - fProperties.put(TRANSFER_END, fEndText.getText()); + fProperties.put(TRANSFER_FILE, fFileText.getText().trim()); + fProperties.put(TRANSFER_START, fStartText.getText().trim()); + fProperties.put(TRANSFER_END, fEndText.getText().trim()); - fStartAddress = getStartAddress(); - fEndAddress = getEndAddress(); - fOutputFile = getFile(); + try + { + fStartAddress = getStartAddress(); + fEndAddress = getEndAddress(); + fOutputFile = getFile(); + } + catch(Exception e) {} super.dispose(); } @@ -204,7 +208,7 @@ public class RAWBinaryExporter implements IMemoryExporter dialog.setText(Messages.getString("RAWBinaryExporter.ChooseFile")); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$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(); String filename = dialog.getFileName(); @@ -421,7 +425,7 @@ public class RAWBinaryExporter implements IMemoryExporter public File getFile() { - return new File(fFileText.getText()); + return new File(fFileText.getText().trim()); } private void validate() @@ -438,6 +442,9 @@ public class RAWBinaryExporter implements IMemoryExporter if(length.compareTo(BigInteger.ZERO) <= 0) isValid = false; + if ( fFileText.getText().trim().length() == 0 ) + isValid = false; + File file = getFile(); if ( file != null ) { File parentFile = file.getParentFile(); diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryImporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryImporter.java index 8d1ccb8c1b6..e1e2b7e7268 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryImporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryImporter.java @@ -71,13 +71,17 @@ public class RAWBinaryImporter implements IMemoryImporter { @Override public void dispose() { - fProperties.put(TRANSFER_FILE, fFileText.getText()); - fProperties.put(TRANSFER_START, fStartText.getText()); + fProperties.put(TRANSFER_FILE, fFileText.getText().trim()); + fProperties.put(TRANSFER_START, fStartText.getText().trim()); fProperties.put(TRANSFER_SCROLL_TO_START, fScrollToBeginningOnImportComplete.getSelection()); - fStartAddress = getStartAddress(); - fInputFile = getFile(); - fScrollToStart = getScrollToStart(); + try + { + fStartAddress = getStartAddress(); + fInputFile = getFile(); + fScrollToStart = getScrollToStart(); + } + catch(Exception e) {} super.dispose(); } @@ -137,7 +141,7 @@ public class RAWBinaryImporter implements IMemoryImporter { dialog.setText(Messages.getString("RAWBinaryImporter.ChooseFile")); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$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(); String filename = dialog.getFileName(); @@ -206,6 +210,11 @@ public class RAWBinaryImporter implements IMemoryImporter { try { getStartAddress(); + + + if ( fFileText.getText().trim().length() == 0 ) + isValid = false; + if(!getFile().exists()) { isValid = false; } @@ -236,7 +245,7 @@ public class RAWBinaryImporter implements IMemoryImporter { public File getFile() { - return new File(fFileText.getText()); + return new File(fFileText.getText().trim()); } public String getId() diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordExporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordExporter.java index 9484110a842..870d0d20ba3 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordExporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordExporter.java @@ -68,9 +68,9 @@ public class SRecordExporter implements IMemoryExporter { public void dispose() { - fProperties.put(TRANSFER_FILE, fFileText.getText()); - fProperties.put(TRANSFER_START, fStartText.getText()); - fProperties.put(TRANSFER_END, fEndText.getText()); + fProperties.put(TRANSFER_FILE, fFileText.getText().trim()); + fProperties.put(TRANSFER_START, fStartText.getText().trim()); + fProperties.put(TRANSFER_END, fEndText.getText().trim()); try { @@ -227,7 +227,7 @@ public class SRecordExporter implements IMemoryExporter dialog.setText(Messages.getString("SRecordExporter.ChooseFile")); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$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(); String filename = dialog.getFileName(); @@ -455,7 +455,7 @@ public class SRecordExporter implements IMemoryExporter public File getFile() { - return new File(fFileText.getText()); + return new File(fFileText.getText().trim()); } private void validate() @@ -472,6 +472,9 @@ public class SRecordExporter implements IMemoryExporter if(length.compareTo(BigInteger.ZERO) <= 0) isValid = false; + if ( fFileText.getText().trim().length() == 0 ) + isValid = false; + File file = getFile(); if ( file != null ) { File parentFile = file.getParentFile(); diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordImporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordImporter.java index 56368d7b15c..3795cc6c9df 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordImporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordImporter.java @@ -77,14 +77,20 @@ public class SRecordImporter implements IMemoryImporter { { public void dispose() { - fProperties.put(TRANSFER_FILE, fFileText.getText()); - fProperties.put(TRANSFER_START, fStartText.getText()); + fProperties.put(TRANSFER_FILE, fFileText.getText().trim()); + fProperties.put(TRANSFER_START, fStartText.getText().trim()); fProperties.put(TRANSFER_SCROLL_TO_START, fScrollToBeginningOnImportComplete.getSelection()); fProperties.put(TRANSFER_CUSTOM_START_ADDRESS, fComboRestoreToThisAddress.getSelection()); - fStartAddress = getStartAddress(); - fInputFile = getFile(); - fScrollToStart = getScrollToStart(); + try + { + if(fProperties.getBoolean(TRANSFER_CUSTOM_START_ADDRESS)) { + fStartAddress = getStartAddress(); + } + fInputFile = getFile(); + fScrollToStart = getScrollToStart(); + } + catch(Exception e) {} super.dispose(); } @@ -187,7 +193,7 @@ public class SRecordImporter implements IMemoryImporter { dialog.setText(Messages.getString("SRecordImporter.ChooseFile")); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$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(); String filename = dialog.getFileName(); @@ -289,11 +295,11 @@ public class SRecordImporter implements IMemoryImporter { getStartAddress(); } - boolean restoreToAddressFromFile = fComboRestoreToFileAddress.getSelection(); - if ( restoreToAddressFromFile ) { - if(!getFile().exists()) { - isValid = false; - } + if ( fFileText.getText().trim().length() == 0 ) + isValid = false; + + if(!getFile().exists()) { + isValid = false; } } catch(Exception e) @@ -327,7 +333,7 @@ public class SRecordImporter implements IMemoryImporter { public File getFile() { - return new File(fFileText.getText()); + return new File(fFileText.getText().trim()); } public String getId() -- cgit v1.2.3