This repository was archived by the owner on Nov 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGossamerController.java
More file actions
102 lines (91 loc) · 3.71 KB
/
GossamerController.java
File metadata and controls
102 lines (91 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package gossamer;
import javafx.fxml.FXML;
import javafx.scene.control.ProgressBar;
import javafx.scene.text.Text;
import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import org.xml.sax.SAXException;
import javax.swing.filechooser.FileSystemView;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.xpath.XPathExpressionException;
import java.io.File;
import java.io.IOException;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
public class GossamerController {
@FXML protected void handleProcessAction()
throws IOException, ParserConfigurationException, SAXException, XPathExpressionException, TransformerException {
statusMessage.setText("Building folders...");
progressBar.setVisible(true);
eadFile.buildDirectories(progressBar);
}
@FXML protected void handleSelectXmlFindingAid()
throws BackingStoreException, IOException, ParserConfigurationException, SAXException, XPathExpressionException {
String home = FileSystemView.getFileSystemView().getHomeDirectory().toString();
String initialDirectory = prefs.get(
GOSSAMER_FILE_NODE,
home
);
File f = new File(initialDirectory);
if (!f.exists() || !f.isDirectory()) {
prefs.put(
GOSSAMER_FILE_NODE,
home
);
initialDirectory = home;
}
fileChooser.getExtensionFilters().setAll(
new FileChooser.ExtensionFilter("XML", "*.xml"),
new FileChooser.ExtensionFilter("All Files", "*.*")
);
fileChooser.setInitialDirectory(new File(initialDirectory));
eadFile = new EadFile(fileChooser.showOpenDialog(stage), xmlFilename, statusMessage);
if (containerFolder != null) {
eadFile.setDirectory(containerFolder);
}
}
@FXML protected void handleSelectContainerFolder() throws IOException {
String home = FileSystemView.getFileSystemView().getHomeDirectory().toString();
String GOSSAMER_DIRECTORY_NODE = "gossamer/ui/prefs/Directory";
String initialDirectory = prefs.get(
GOSSAMER_DIRECTORY_NODE,
home
);
File f = new File(initialDirectory);
if (!f.exists() || !f.isDirectory()) {
prefs.put(
GOSSAMER_FILE_NODE,
home
);
initialDirectory = home;
}
directoryChooser.setInitialDirectory(new File(initialDirectory));
containerFolder = directoryChooser.showDialog(stage);
if (containerFolder != null) {
prefs.put(
GOSSAMER_DIRECTORY_NODE,
containerFolder.toString()
);
containerFoldername.setText(containerFolder.getCanonicalPath());
if (eadFile != null) {
eadFile.setDirectory(containerFolder);
}
}
}
void setStage(Stage primaryStage) {
stage = primaryStage;
}
private Stage stage;
final private FileChooser fileChooser = new FileChooser();
final private DirectoryChooser directoryChooser = new DirectoryChooser();
private EadFile eadFile;
private File containerFolder;
@FXML private Text xmlFilename;
@FXML private Text containerFoldername;
@FXML private Text statusMessage;
@FXML private ProgressBar progressBar;
private final String GOSSAMER_FILE_NODE = "gossamer/ui/prefs/File";
private Preferences prefs = Preferences.userRoot();
}