This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 211554
Collapse All | Expand All

(-)db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/BlobFieldTableCellEditor.java (-4 / +62 lines)
Lines 50-64 Link Here
50
import java.sql.Blob;
50
import java.sql.Blob;
51
import java.sql.SQLException;
51
import java.sql.SQLException;
52
import java.util.EventObject;
52
import java.util.EventObject;
53
import java.util.logging.Level;
54
import java.util.logging.Logger;
53
import javax.swing.*;
55
import javax.swing.*;
54
import javax.swing.table.TableCellEditor;
56
import javax.swing.table.TableCellEditor;
55
import org.netbeans.api.progress.ProgressUtils;
57
import org.netbeans.api.progress.ProgressUtils;
56
import org.netbeans.modules.db.dataview.util.FileBackedBlob;
58
import org.netbeans.modules.db.dataview.util.FileBackedBlob;
59
import org.openide.DialogDisplayer;
60
import org.openide.NotifyDescriptor;
57
import org.openide.util.NbBundle;
61
import org.openide.util.NbBundle;
58
62
59
public class BlobFieldTableCellEditor extends AbstractCellEditor
63
public class BlobFieldTableCellEditor extends AbstractCellEditor
60
        implements TableCellEditor,
64
        implements TableCellEditor,
61
        ActionListener {
65
        ActionListener {
66
    private static final Logger LOG = Logger.getLogger(BlobFieldTableCellEditor.class
67
            .getName());
62
68
63
    protected static final String EDIT = "edit";
69
    protected static final String EDIT = "edit";
64
    protected Blob currentValue;
70
    protected Blob currentValue;
Lines 184-192 Link Here
184
                    f.delete();
190
                    f.delete();
185
                }
191
                }
186
            } catch (IOException ex) {
192
            } catch (IOException ex) {
187
                throw new RuntimeException(ex);
193
                LOG.log(Level.INFO, "IOError while saving BLOB to file", ex);
194
                displayError(f, ex, false);
188
            } catch (SQLException ex) {
195
            } catch (SQLException ex) {
189
                throw new RuntimeException(ex);
196
                LOG.log(Level.INFO, "SQLException while saving BLOB to file", ex);
197
                displayError(f, ex, false);
190
            }
198
            }
191
        }
199
        }
192
    }
200
    }
Lines 205-213 Link Here
205
                    result = null;
213
                    result = null;
206
                }
214
                }
207
            } catch (IOException ex) {
215
            } catch (IOException ex) {
208
                throw new RuntimeException(ex);
216
                LOG.log(Level.INFO, "IOError while loading BLOB from file", ex);
217
                displayError(f, ex, true);
218
                result = null;
209
            } catch (SQLException ex) {
219
            } catch (SQLException ex) {
210
                throw new RuntimeException(ex);
220
                LOG.log(Level.INFO, "SQLException while loading BLOB from file", ex);
221
                displayError(f, ex, true);
222
                result = null;
211
            }
223
            }
212
        }
224
        }
213
        return result;
225
        return result;
Lines 238-241 Link Here
238
        }
250
        }
239
        return !ft.isCancel();
251
        return !ft.isCancel();
240
    }
252
    }
253
    
254
    private void displayError(File f, Exception ex, boolean read) {
255
        DialogDisplayer dd = DialogDisplayer.getDefault();
256
        
257
        String errorObjectMsg;
258
        String messageMsg;
259
        String titleMsg;
260
        
261
        if(ex instanceof SQLException) {
262
            errorObjectMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class,
263
                         "lobErrorObject.database");
264
        } else {
265
            errorObjectMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class,
266
                         "lobErrorObject.file");
241
}
267
}
268
        
269
        if(! read) {
270
            titleMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class, 
271
                    "blobSaveToFileError.title");
272
            messageMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class, 
273
                    "blobSaveToFileError.message",
274
                    errorObjectMsg,
275
                    f.getAbsolutePath(),
276
                    ex.getLocalizedMessage()
277
                    );
278
        } else {
279
            titleMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class, 
280
                    "blobReadFromFileError.title");
281
            messageMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class, 
282
                    "blobReadFromFileError.message",
283
                    errorObjectMsg,
284
                    f.getAbsolutePath(),
285
                    ex.getLocalizedMessage()
286
                    );
287
        }
288
        
289
        NotifyDescriptor nd = new NotifyDescriptor(
290
                messageMsg, 
291
                titleMsg,
292
                NotifyDescriptor.OK_CANCEL_OPTION,
293
                NotifyDescriptor.WARNING_MESSAGE,
294
                new Object[] {NotifyDescriptor.CANCEL_OPTION},
295
                NotifyDescriptor.CANCEL_OPTION);
296
        
297
        dd.notifyLater(nd);
298
    }
299
}
(-)db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/Bundle.properties (+10 lines)
Lines 47-49 Link Here
47
saveLob.targetNotWriteable=Target file can't be written.\nCheck file/directory permissions.
47
saveLob.targetNotWriteable=Target file can't be written.\nCheck file/directory permissions.
48
saveLob.failure=Failure while saving file: {0}
48
saveLob.failure=Failure while saving file: {0}
49
saveLob.dbError=DB-Failure: {0}
49
saveLob.dbError=DB-Failure: {0}
50
lobErrorObject.database=Database error
51
lobErrorObject.file=File error
52
blobSaveToFileError.title=Error while saving BLOB to file
53
blobReadFromFileError.title=Error while loading BLOB from file
54
blobSaveToFileError.message={0} while saving BLOB\n\nFile: {1}\n\nMessage:\n{2}
55
blobReadFromFileError.message={0} while loading BLOB\n\nFile: {1}\n\nMessage:\n{2}
56
clobSaveToFileError.title=Error while saving CLOB to file
57
clobReadFromFileError.title=Error while loading CLOB from file
58
clobSaveToFileError.message={0} while saving CLOB\n\nFile: {1}\n\nMessage:\n{2}
59
clobReadFromFileError.message={0} while loading CLOB\n\nFile: {1}\n\nMessage:\n{2}
(-)db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/ClobFieldTableCellEditor.java (-4 / +62 lines)
Lines 51-60 Link Here
51
import java.sql.Clob;
51
import java.sql.Clob;
52
import java.sql.SQLException;
52
import java.sql.SQLException;
53
import java.util.*;
53
import java.util.*;
54
import java.util.logging.Level;
55
import java.util.logging.Logger;
54
import javax.swing.*;
56
import javax.swing.*;
55
import javax.swing.table.TableCellEditor;
57
import javax.swing.table.TableCellEditor;
56
import org.netbeans.api.progress.ProgressUtils;
58
import org.netbeans.api.progress.ProgressUtils;
57
import org.netbeans.modules.db.dataview.util.FileBackedClob;
59
import org.netbeans.modules.db.dataview.util.FileBackedClob;
60
import org.openide.DialogDisplayer;
61
import org.openide.NotifyDescriptor;
58
import org.openide.util.Exceptions;
62
import org.openide.util.Exceptions;
59
import org.openide.util.NbBundle;
63
import org.openide.util.NbBundle;
60
import org.openide.windows.WindowManager;
64
import org.openide.windows.WindowManager;
Lines 88-93 Link Here
88
            charsetSelect.setSelectedItem(selectedCharset);
92
            charsetSelect.setSelectedItem(selectedCharset);
89
        }
93
        }
90
    }
94
    }
95
    private static final Logger LOG = Logger.getLogger(ClobFieldTableCellEditor.class
96
            .getName());
91
    protected static final String EDIT = "edit";
97
    protected static final String EDIT = "edit";
92
    protected Clob currentValue;
98
    protected Clob currentValue;
93
    protected JButton button;
99
    protected JButton button;
Lines 228-236 Link Here
228
                    f.delete();
234
                    f.delete();
229
                }
235
                }
230
            } catch (IOException ex) {
236
            } catch (IOException ex) {
231
                throw new RuntimeException(ex);
237
                LOG.log(Level.INFO, "IOException while saving CLOB to file", ex);
238
                displayError(f, ex, false);
232
            } catch (SQLException ex) {
239
            } catch (SQLException ex) {
233
                throw new RuntimeException(ex);
240
                LOG.log(Level.INFO, "SQLException while saving CLOB to file", ex);
241
                displayError(f, ex, false);
234
            }
242
            }
235
        }
243
        }
236
    }
244
    }
Lines 251-259 Link Here
251
                    result = null;
259
                    result = null;
252
                }
260
                }
253
            } catch (IOException ex) {
261
            } catch (IOException ex) {
254
                throw new RuntimeException(ex);
262
                LOG.log(Level.INFO, "IOException while loading CLOB from file", ex);
263
                displayError(f, ex, true);
264
                result = null;
255
            } catch (SQLException ex) {
265
            } catch (SQLException ex) {
256
                throw new RuntimeException(ex);
266
                LOG.log(Level.INFO, "SQLException while loading CLOB from file", ex);
267
                displayError(f, ex, true);
268
                result = null;
257
            }
269
            }
258
        }
270
        }
259
        return result;
271
        return result;
Lines 286-291 Link Here
286
        return !ft.isCancel();
298
        return !ft.isCancel();
287
    }
299
    }
288
    
300
    
301
    private void displayError(File f, Exception ex, boolean read) {
302
        DialogDisplayer dd = DialogDisplayer.getDefault();
303
        
304
        String errorObjectMsg;
305
        String messageMsg;
306
        String titleMsg;
307
        
308
        if(ex instanceof SQLException) {
309
            errorObjectMsg = NbBundle.getMessage(ClobFieldTableCellEditor.class,
310
                         "lobErrorObject.database");
311
        } else {
312
            errorObjectMsg = NbBundle.getMessage(ClobFieldTableCellEditor.class,
313
                         "lobErrorObject.file");
314
        }
315
        
316
        if(! read) {
317
            titleMsg = NbBundle.getMessage(ClobFieldTableCellEditor.class, 
318
                    "clobSaveToFileError.title");
319
            messageMsg = NbBundle.getMessage(ClobFieldTableCellEditor.class, 
320
                    "clobSaveToFileError.message",
321
                    errorObjectMsg,
322
                    f.getAbsolutePath(),
323
                    ex.getLocalizedMessage()
324
                    );
325
        } else {
326
            titleMsg = NbBundle.getMessage(ClobFieldTableCellEditor.class, 
327
                    "clobReadFromFileError.title");
328
            messageMsg = NbBundle.getMessage(ClobFieldTableCellEditor.class, 
329
                    "clobReadFromFileError.message",
330
                    errorObjectMsg,
331
                    f.getAbsolutePath(),
332
                    ex.getLocalizedMessage()
333
                    );
334
        }
335
        
336
        NotifyDescriptor nd = new NotifyDescriptor(
337
                messageMsg, 
338
                titleMsg,
339
                NotifyDescriptor.OK_CANCEL_OPTION,
340
                NotifyDescriptor.WARNING_MESSAGE,
341
                new Object[] {NotifyDescriptor.CANCEL_OPTION},
342
                NotifyDescriptor.CANCEL_OPTION);
343
        
344
        dd.notifyLater(nd);
345
    }
346
    
289
    protected void editCell() {
347
    protected void editCell() {
290
        String stringVal = "";
348
        String stringVal = "";
291
        if (currentValue != null) {
349
        if (currentValue != null) {

Return to bug 211554