Method is used in NewDSAction @return the new datastore or null if an error occurs
()
| 2349 | * @return the new datastore or null if an error occurs |
| 2350 | */ |
| 2351 | protected DataStore createSerialDataStore() { |
| 2352 | DataStore ds = null; |
| 2353 | |
| 2354 | // get the URL (a file in this case) |
| 2355 | fileChooser.setDialogTitle("Please create a new empty directory"); |
| 2356 | fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
| 2357 | fileChooser.setFileFilter(fileChooser.getAcceptAllFileFilter()); |
| 2358 | fileChooser.setResource("gate.persist.SerialDataStore"); |
| 2359 | if(fileChooser.showOpenDialog(MainFrame.this) |
| 2360 | == JFileChooser.APPROVE_OPTION) { |
| 2361 | try { |
| 2362 | URL dsURL = fileChooser.getSelectedFile().toURI().toURL(); |
| 2363 | ds = |
| 2364 | Factory.createDataStore("gate.persist.SerialDataStore", dsURL |
| 2365 | .toExternalForm()); |
| 2366 | } |
| 2367 | catch(MalformedURLException mue) { |
| 2368 | JOptionPane.showMessageDialog(MainFrame.this, |
| 2369 | "Invalid location for the datastore\n " + mue.toString(), "GATE", |
| 2370 | JOptionPane.ERROR_MESSAGE); |
| 2371 | } |
| 2372 | catch(PersistenceException pe) { |
| 2373 | JOptionPane.showMessageDialog(MainFrame.this, |
| 2374 | "Datastore creation error!\n " + pe.toString(), "GATE", |
| 2375 | JOptionPane.ERROR_MESSAGE); |
| 2376 | } // catch |
| 2377 | } // if |
| 2378 | |
| 2379 | return ds; |
| 2380 | } // createSerialDataStore() |
| 2381 | |
| 2382 | /** |
| 2383 | * Method is used in OpenDSAction |
no test coverage detected