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) { |