80 |
80 |
String clipboardIdentifier = "";
|
81 |
81 |
String clipboardRevision = "";
|
82 |
82 |
String clipboardScope = "";
|
83 |
|
JButton copyButton;
|
84 |
|
JButton cutButton;
|
|
83 |
JButton copyButton;
|
|
84 |
JButton cutButton;
|
85 |
85 |
String defaultDocumentType = "eml://ecoinformatics.org/eml-2.0.0";
|
86 |
86 |
String defaultDocumentURL = "http://";
|
87 |
87 |
String defaultHarvestList = "";
|
88 |
88 |
String defaultIdentifier = "1";
|
89 |
89 |
String defaultRevision = "1";
|
90 |
90 |
String defaultScope = "dataset";
|
91 |
|
Document doc;
|
92 |
|
JScrollPane docPane;
|
|
91 |
Document doc;
|
|
92 |
JScrollPane docPane;
|
93 |
93 |
JFileChooser fileChooser = new JFileChooser();
|
94 |
94 |
File harvestListFile;
|
95 |
95 |
boolean harvestListHasChanged = false;
|
96 |
|
JMenuBar menuBar;
|
|
96 |
JMenuBar menuBar;
|
97 |
97 |
final int numColumns = 6;
|
98 |
98 |
final int numRows = 300;
|
99 |
|
JButton pasteButton;
|
100 |
|
JButton pasteDefaultsButton;
|
|
99 |
JButton pasteButton;
|
|
100 |
JButton pasteDefaultsButton;
|
101 |
101 |
Properties properties;
|
102 |
102 |
private String schemaLocation =
|
103 |
|
// "eml://ecoinformatics.org/harvestList ../../lib/harvester/harvestList.xsd";
|
104 |
103 |
"eml://ecoinformatics.org/harvestList harvestList.xsd";
|
105 |
104 |
int selectedRow = -1;
|
106 |
105 |
final JTable table;
|
... | ... | |
131 |
130 |
* Constructor for HarvestListEditor class.
|
132 |
131 |
*/
|
133 |
132 |
public HarvestListEditor() {
|
134 |
|
super("Harvest List Editor");
|
|
133 |
super("Harvest List Editor");
|
135 |
134 |
|
136 |
|
JPanel buttonPanel = new JPanel();
|
|
135 |
JPanel buttonPanel = new JPanel();
|
137 |
136 |
String[] fileItems =
|
138 |
137 |
new String[] {"New", "Open...", "Save", "Save As...", "Exit"};
|
139 |
|
JMenu fileMenu = new JMenu("File");
|
140 |
|
char[] fileShortCuts = {'N', 'O', 'S', 'A', 'X'};
|
|
138 |
JMenu fileMenu = new JMenu("File");
|
|
139 |
char[] fileShortCuts = {'N', 'O', 'S', 'A', 'X'};
|
141 |
140 |
TableColumn tableColumn;
|
142 |
141 |
|
143 |
142 |
loadProperties();
|
144 |
|
setSize(1000, 400);
|
145 |
|
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
146 |
|
menuBar = new JMenuBar();
|
|
143 |
setSize(1000, 400);
|
|
144 |
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
|
145 |
menuBar = new JMenuBar();
|
147 |
146 |
|
148 |
147 |
/*
|
149 |
148 |
* Add menu items to the File menu
|
150 |
149 |
*/
|
151 |
|
newMenuItem.setAccelerator(KeyStroke.getKeyStroke('N',
|
152 |
|
java.awt.Event.CTRL_MASK,
|
153 |
|
false));
|
154 |
|
newMenuItem.addActionListener(this);
|
155 |
|
fileMenu.add(newMenuItem);
|
|
150 |
newMenuItem.setAccelerator(KeyStroke.getKeyStroke('N',
|
|
151 |
java.awt.Event.CTRL_MASK,
|
|
152 |
false));
|
|
153 |
newMenuItem.addActionListener(this);
|
|
154 |
fileMenu.add(newMenuItem);
|
156 |
155 |
|
157 |
|
openMenuItem.setAccelerator(KeyStroke.getKeyStroke('O',
|
158 |
|
java.awt.Event.CTRL_MASK,
|
|
156 |
openMenuItem.setAccelerator(KeyStroke.getKeyStroke('O',
|
|
157 |
java.awt.Event.CTRL_MASK,
|
159 |
158 |
false));
|
160 |
|
openMenuItem.addActionListener(this);
|
161 |
|
fileMenu.add(openMenuItem);
|
|
159 |
openMenuItem.addActionListener(this);
|
|
160 |
fileMenu.add(openMenuItem);
|
162 |
161 |
|
163 |
|
saveMenuItem.setAccelerator(KeyStroke.getKeyStroke('S',
|
164 |
|
java.awt.Event.CTRL_MASK,
|
|
162 |
saveMenuItem.setAccelerator(KeyStroke.getKeyStroke('S',
|
|
163 |
java.awt.Event.CTRL_MASK,
|
165 |
164 |
false));
|
166 |
|
saveMenuItem.addActionListener(this);
|
|
165 |
saveMenuItem.addActionListener(this);
|
167 |
166 |
saveMenuItem.setEnabled(false);
|
168 |
|
fileMenu.add(saveMenuItem);
|
|
167 |
fileMenu.add(saveMenuItem);
|
169 |
168 |
|
170 |
|
saveAsMenuItem.setAccelerator(KeyStroke.getKeyStroke('A',
|
171 |
|
java.awt.Event.CTRL_MASK,
|
|
169 |
saveAsMenuItem.setAccelerator(KeyStroke.getKeyStroke('A',
|
|
170 |
java.awt.Event.CTRL_MASK,
|
172 |
171 |
false));
|
173 |
|
saveAsMenuItem.addActionListener(this);
|
174 |
|
fileMenu.add(saveAsMenuItem);
|
|
172 |
saveAsMenuItem.addActionListener(this);
|
|
173 |
fileMenu.add(saveAsMenuItem);
|
175 |
174 |
|
176 |
|
validateMenuItem.setAccelerator(KeyStroke.getKeyStroke('V',
|
177 |
|
java.awt.Event.CTRL_MASK,
|
|
175 |
validateMenuItem.setAccelerator(KeyStroke.getKeyStroke('V',
|
|
176 |
java.awt.Event.CTRL_MASK,
|
178 |
177 |
false));
|
179 |
|
validateMenuItem.addActionListener(this);
|
180 |
|
fileMenu.add(validateMenuItem);
|
|
178 |
validateMenuItem.addActionListener(this);
|
|
179 |
fileMenu.add(validateMenuItem);
|
181 |
180 |
|
182 |
|
exitMenuItem.setAccelerator(KeyStroke.getKeyStroke('X',
|
183 |
|
java.awt.Event.CTRL_MASK,
|
|
181 |
exitMenuItem.setAccelerator(KeyStroke.getKeyStroke('X',
|
|
182 |
java.awt.Event.CTRL_MASK,
|
184 |
183 |
false));
|
185 |
|
exitMenuItem.addActionListener(this);
|
186 |
|
fileMenu.add(exitMenuItem);
|
|
184 |
exitMenuItem.addActionListener(this);
|
|
185 |
fileMenu.add(exitMenuItem);
|
187 |
186 |
|
188 |
|
menuBar.add(fileMenu); // Add the File menu to the menu bar
|
189 |
|
setJMenuBar(menuBar); // Set the frame's menu bar to this menu bar
|
|
187 |
menuBar.add(fileMenu); // Add the File menu to the menu bar
|
|
188 |
setJMenuBar(menuBar); // Set the frame's menu bar to this menu bar
|
190 |
189 |
|
191 |
190 |
//table = new JTable(numRows, numColumns);
|
192 |
191 |
table = new JTable(new HarvestListTableModel());
|
... | ... | |
289 |
288 |
copyButton.setEnabled(false);
|
290 |
289 |
pasteButton.setEnabled(false);
|
291 |
290 |
pasteDefaultsButton.setEnabled(false);
|
292 |
|
buttonPanel.add(cutButton);
|
293 |
|
buttonPanel.add(copyButton);
|
294 |
|
buttonPanel.add(pasteButton);
|
295 |
|
buttonPanel.add(pasteDefaultsButton);
|
296 |
|
buttonPanel.setOpaque(true);
|
297 |
|
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
|
|
291 |
buttonPanel.add(cutButton);
|
|
292 |
buttonPanel.add(copyButton);
|
|
293 |
buttonPanel.add(pasteButton);
|
|
294 |
buttonPanel.add(pasteDefaultsButton);
|
|
295 |
buttonPanel.setOpaque(true);
|
|
296 |
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
|
298 |
297 |
|
299 |
298 |
// If the default Harvest List option has a value, and the file exists,
|
300 |
299 |
// loads its contents.
|
... | ... | |
340 |
339 |
* @param e An ActionEvent object, determines the menu item that was
|
341 |
340 |
* selected.
|
342 |
341 |
*/
|
343 |
|
public void actionPerformed(ActionEvent e) {
|
344 |
|
if ((e.getActionCommand()).equals("New")) {
|
|
342 |
public void actionPerformed(ActionEvent e) {
|
|
343 |
if ((e.getActionCommand()).equals("New")) {
|
345 |
344 |
fileNew();
|
346 |
|
}
|
347 |
|
else if ((e.getActionCommand()).equals("Open...")) {
|
|
345 |
}
|
|
346 |
else if ((e.getActionCommand()).equals("Open...")) {
|
348 |
347 |
fileOpen();
|
349 |
348 |
}
|
350 |
349 |
else if ((e.getActionCommand()).equals("Save")) {
|
351 |
350 |
fileSave();
|
352 |
351 |
}
|
353 |
|
else if ((e.getActionCommand()).equals("Save As...")) {
|
|
352 |
else if ((e.getActionCommand()).equals("Save As...")) {
|
354 |
353 |
fileSaveAs();
|
355 |
354 |
}
|
356 |
|
else if ((e.getActionCommand()).equals("Validate")) {
|
|
355 |
else if ((e.getActionCommand()).equals("Validate")) {
|
357 |
356 |
fileValidate();
|
358 |
357 |
}
|
359 |
358 |
else if ((e.getActionCommand()).equals("Exit")) {
|
360 |
359 |
fileExit();
|
361 |
360 |
}
|
362 |
|
}
|
|
361 |
}
|
363 |
362 |
|
364 |
363 |
|
365 |
364 |
/**
|
... | ... | |
749 |
748 |
defaultScope = properties.getProperty("defaultScope");
|
750 |
749 |
}
|
751 |
750 |
catch (IOException ioe) {
|
752 |
|
System.out.println("Error loading properties file: " + ioe.getMessage());
|
|
751 |
System.out.println("Error loading properties file: " +
|
|
752 |
ioe.getMessage());
|
753 |
753 |
}
|
754 |
754 |
}
|
755 |
755 |
}
|
... | ... | |
860 |
860 |
* @param out the PrintWriter to write the Harvest List to
|
861 |
861 |
*/
|
862 |
862 |
void writeHarvestList(PrintWriter out) {
|
863 |
|
out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
|
864 |
|
out.println("");
|
865 |
|
out.println(
|
|
863 |
out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
|
|
864 |
out.println("");
|
|
865 |
out.println(
|
866 |
866 |
"<hrv:harvestList xmlns:hrv=\"eml://ecoinformatics.org/harvestList\" >");
|
867 |
867 |
|
868 |
|
for (int i = 0; i < numRows; i++) {
|
869 |
|
if (!isEmptyRow(i)) {
|
870 |
|
writeRow(out, i);
|
871 |
|
}
|
|
868 |
for (int i = 0; i < numRows; i++) {
|
|
869 |
if (!isEmptyRow(i)) {
|
|
870 |
writeRow(out, i);
|
872 |
871 |
}
|
|
872 |
}
|
873 |
873 |
|
874 |
|
out.println("");
|
875 |
|
out.println("</hrv:harvestList>");
|
876 |
|
out.close();
|
|
874 |
out.println("");
|
|
875 |
out.println("</hrv:harvestList>");
|
|
876 |
out.close();
|
877 |
877 |
}
|
878 |
878 |
|
879 |
879 |
|
Remove DOS end-of-line carriage returns.
Other minor formatting improvements to the code.