Method is used in OpenDSAction @return the opened datastore or null if an error occurs
()
| 2384 | * @return the opened datastore or null if an error occurs |
| 2385 | */ |
| 2386 | protected DataStore openSerialDataStore() { |
| 2387 | DataStore ds = null; |
| 2388 | |
| 2389 | // get the URL (a file in this case) |
| 2390 | fileChooser.setDialogTitle("Select the datastore directory"); |
| 2391 | fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
| 2392 | fileChooser.setFileFilter(fileChooser.getAcceptAllFileFilter()); |
| 2393 | fileChooser.setResource("gate.persist.SerialDataStore"); |
| 2394 | if(fileChooser.showOpenDialog(MainFrame.this) |
| 2395 | == JFileChooser.APPROVE_OPTION) { |
| 2396 | try { |
| 2397 | URL dsURL = fileChooser.getSelectedFile().toURI().toURL(); |
| 2398 | ds = |
| 2399 | Factory.openDataStore("gate.persist.SerialDataStore", dsURL |
| 2400 | .toExternalForm()); |
| 2401 | } |
| 2402 | catch(MalformedURLException mue) { |
| 2403 | JOptionPane.showMessageDialog(MainFrame.this, |
| 2404 | "Invalid location for the datastore\n " + mue.toString(), "GATE", |
| 2405 | JOptionPane.ERROR_MESSAGE); |
| 2406 | } |
| 2407 | catch(PersistenceException pe) { |
| 2408 | JOptionPane.showMessageDialog(MainFrame.this, |
| 2409 | "Datastore opening error!\n " + pe.toString(), "GATE", |
| 2410 | JOptionPane.ERROR_MESSAGE); |
| 2411 | } // catch |
| 2412 | } // if |
| 2413 | |
| 2414 | return ds; |
| 2415 | } // openSerialDataStore() |
| 2416 | |
| 2417 | /** |
| 2418 | * Method is used in ....OpenDSAction |
no test coverage detected