1 //
2 // Neuros Database Manipulator
3 // Copyright (C) 2003 Neuros Database Manipulator
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 //
19 // For information about Neuros Database Manipulator and its authors,
20 // please contact the Neuros Database Manipulator Web Site at
21 // http://neurosdbm.sourceforge.net
22 //
23 //
24
25 package net.sourceforge.neurosdbm.actions;
26
27
28 import java.io.IOException;
29 import java.io.FileNotFoundException;
30 import net.sourceforge.neurosdbm.MainFrame;
31 import net.sourceforge.neurosdbm.NeurosProperties;
32 import net.sourceforge.neurosdbm.NeurosDeviceSelection;
33 import net.sourceforge.neurosdbm.db.Database;
34 import net.sourceforge.neurosdbm.db.DatabaseCorruptException;
35 import net.sourceforge.neurosdbm.db.DatabaseDoesNotExistException;
36 import net.sourceforge.neurosdbm.db.DatabaseInternalCorruptionException;
37
38
39 public final class ChangeDevice extends BaseAction {
40
41 private Database database;
42
43 public ChangeDevice(MainFrame parent, Database database) {
44 super(parent, "Change Device");
45 setToolTip("Change Device");
46 this.database = database;
47 }
48
49 void action() {
50 String oldPath = NeurosProperties.getDevicePath();
51 boolean error = true;
52 while (error) {
53 new NeurosDeviceSelection(parent).getDevice();
54 String path = NeurosProperties.getDevicePath();
55 int device = NeurosProperties.getDeviceType();
56 try {
57 database.refreshDatabase(path, device);
58 error = false;
59 } catch (FileNotFoundException exp) {
60 } catch (IOException exp) {
61 } catch (DatabaseCorruptException exp) {
62 } catch (DatabaseDoesNotExistException exp) {
63 }
64 }
65 parent.dataChanged();
66 }
67 }