# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /home/matthias/src/core-main # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/BlobFieldTableCellEditor.java --- db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/BlobFieldTableCellEditor.java Base (BASE) +++ db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/BlobFieldTableCellEditor.java Locally Modified (Based On LOCAL) @@ -50,15 +50,21 @@ import java.sql.Blob; import java.sql.SQLException; import java.util.EventObject; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.*; import javax.swing.table.TableCellEditor; import org.netbeans.api.progress.ProgressUtils; import org.netbeans.modules.db.dataview.util.FileBackedBlob; +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; import org.openide.util.NbBundle; public class BlobFieldTableCellEditor extends AbstractCellEditor implements TableCellEditor, ActionListener { + private static final Logger LOG = Logger.getLogger(BlobFieldTableCellEditor.class + .getName()); protected static final String EDIT = "edit"; protected Blob currentValue; @@ -184,9 +190,11 @@ f.delete(); } } catch (IOException ex) { - throw new RuntimeException(ex); + LOG.log(Level.INFO, "IOError while saving BLOB to file", ex); + displayError(f, ex, false); } catch (SQLException ex) { - throw new RuntimeException(ex); + LOG.log(Level.INFO, "SQLException while saving BLOB to file", ex); + displayError(f, ex, false); } } } @@ -205,9 +213,13 @@ result = null; } } catch (IOException ex) { - throw new RuntimeException(ex); + LOG.log(Level.INFO, "IOError while loading BLOB from file", ex); + displayError(f, ex, true); + result = null; } catch (SQLException ex) { - throw new RuntimeException(ex); + LOG.log(Level.INFO, "SQLException while loading BLOB from file", ex); + displayError(f, ex, true); + result = null; } } return result; @@ -238,4 +250,50 @@ } return !ft.isCancel(); } + + private void displayError(File f, Exception ex, boolean read) { + DialogDisplayer dd = DialogDisplayer.getDefault(); + + String errorObjectMsg; + String messageMsg; + String titleMsg; + + if(ex instanceof SQLException) { + errorObjectMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class, + "lobErrorObject.database"); + } else { + errorObjectMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class, + "lobErrorObject.file"); } + + if(! read) { + titleMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class, + "blobSaveToFileError.title"); + messageMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class, + "blobSaveToFileError.message", + errorObjectMsg, + f.getAbsolutePath(), + ex.getLocalizedMessage() + ); + } else { + titleMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class, + "blobReadFromFileError.title"); + messageMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class, + "blobReadFromFileError.message", + errorObjectMsg, + f.getAbsolutePath(), + ex.getLocalizedMessage() + ); + } + + NotifyDescriptor nd = new NotifyDescriptor( + messageMsg, + titleMsg, + NotifyDescriptor.OK_CANCEL_OPTION, + NotifyDescriptor.WARNING_MESSAGE, + new Object[] {NotifyDescriptor.CANCEL_OPTION}, + NotifyDescriptor.CANCEL_OPTION); + + dd.notifyLater(nd); + } +} \ No newline at end of file Index: db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/Bundle.properties --- db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/Bundle.properties Base (BASE) +++ db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/Bundle.properties Locally Modified (Based On LOCAL) @@ -47,3 +47,13 @@ saveLob.targetNotWriteable=Target file can't be written.\nCheck file/directory permissions. saveLob.failure=Failure while saving file: {0} saveLob.dbError=DB-Failure: {0} +lobErrorObject.database=Database error +lobErrorObject.file=File error +blobSaveToFileError.title=Error while saving BLOB to file +blobReadFromFileError.title=Error while loading BLOB from file +blobSaveToFileError.message={0} while saving BLOB\n\nFile: {1}\n\nMessage:\n{2} +blobReadFromFileError.message={0} while loading BLOB\n\nFile: {1}\n\nMessage:\n{2} +clobSaveToFileError.title=Error while saving CLOB to file +clobReadFromFileError.title=Error while loading CLOB from file +clobSaveToFileError.message={0} while saving CLOB\n\nFile: {1}\n\nMessage:\n{2} +clobReadFromFileError.message={0} while loading CLOB\n\nFile: {1}\n\nMessage:\n{2} \ No newline at end of file Index: db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/ClobFieldTableCellEditor.java --- db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/ClobFieldTableCellEditor.java Base (BASE) +++ db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/ClobFieldTableCellEditor.java Locally Modified (Based On LOCAL) @@ -51,10 +51,14 @@ import java.sql.Clob; import java.sql.SQLException; import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.*; import javax.swing.table.TableCellEditor; import org.netbeans.api.progress.ProgressUtils; import org.netbeans.modules.db.dataview.util.FileBackedClob; +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.openide.windows.WindowManager; @@ -88,6 +92,8 @@ charsetSelect.setSelectedItem(selectedCharset); } } + private static final Logger LOG = Logger.getLogger(ClobFieldTableCellEditor.class + .getName()); protected static final String EDIT = "edit"; protected Clob currentValue; protected JButton button; @@ -228,9 +234,11 @@ f.delete(); } } catch (IOException ex) { - throw new RuntimeException(ex); + LOG.log(Level.INFO, "IOException while saving CLOB to file", ex); + displayError(f, ex, false); } catch (SQLException ex) { - throw new RuntimeException(ex); + LOG.log(Level.INFO, "SQLException while saving CLOB to file", ex); + displayError(f, ex, false); } } } @@ -251,9 +259,13 @@ result = null; } } catch (IOException ex) { - throw new RuntimeException(ex); + LOG.log(Level.INFO, "IOException while loading CLOB from file", ex); + displayError(f, ex, true); + result = null; } catch (SQLException ex) { - throw new RuntimeException(ex); + LOG.log(Level.INFO, "SQLException while loading CLOB from file", ex); + displayError(f, ex, true); + result = null; } } return result; @@ -286,6 +298,52 @@ return !ft.isCancel(); } + private void displayError(File f, Exception ex, boolean read) { + DialogDisplayer dd = DialogDisplayer.getDefault(); + + String errorObjectMsg; + String messageMsg; + String titleMsg; + + if(ex instanceof SQLException) { + errorObjectMsg = NbBundle.getMessage(ClobFieldTableCellEditor.class, + "lobErrorObject.database"); + } else { + errorObjectMsg = NbBundle.getMessage(ClobFieldTableCellEditor.class, + "lobErrorObject.file"); + } + + if(! read) { + titleMsg = NbBundle.getMessage(ClobFieldTableCellEditor.class, + "clobSaveToFileError.title"); + messageMsg = NbBundle.getMessage(ClobFieldTableCellEditor.class, + "clobSaveToFileError.message", + errorObjectMsg, + f.getAbsolutePath(), + ex.getLocalizedMessage() + ); + } else { + titleMsg = NbBundle.getMessage(ClobFieldTableCellEditor.class, + "clobReadFromFileError.title"); + messageMsg = NbBundle.getMessage(ClobFieldTableCellEditor.class, + "clobReadFromFileError.message", + errorObjectMsg, + f.getAbsolutePath(), + ex.getLocalizedMessage() + ); + } + + NotifyDescriptor nd = new NotifyDescriptor( + messageMsg, + titleMsg, + NotifyDescriptor.OK_CANCEL_OPTION, + NotifyDescriptor.WARNING_MESSAGE, + new Object[] {NotifyDescriptor.CANCEL_OPTION}, + NotifyDescriptor.CANCEL_OPTION); + + dd.notifyLater(nd); + } + protected void editCell() { String stringVal = ""; if (currentValue != null) {