[9243] | 1 | /**
|
---|
| 2 | *#########################################################################
|
---|
| 3 | *
|
---|
| 4 | * A component of the Gatherer application, part of the Greenstone digital
|
---|
| 5 | * library suite from the New Zealand Digital Library Project at the
|
---|
| 6 | * University of Waikato, New Zealand.
|
---|
| 7 | *
|
---|
| 8 | * <BR><BR>
|
---|
| 9 | *
|
---|
| 10 | * Author: John Thompson, Greenstone Digital Library, University of Waikato
|
---|
| 11 | *
|
---|
| 12 | * <BR><BR>
|
---|
| 13 | *
|
---|
| 14 | * Copyright (C) 1999 New Zealand Digital Library Project
|
---|
| 15 | *
|
---|
| 16 | * <BR><BR>
|
---|
| 17 | *
|
---|
| 18 | * This program is free software; you can redistribute it and/or modify
|
---|
| 19 | * it under the terms of the GNU General Public License as published by
|
---|
| 20 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 21 | * (at your option) any later version.
|
---|
| 22 | *
|
---|
| 23 | * <BR><BR>
|
---|
| 24 | *
|
---|
| 25 | * This program is distributed in the hope that it will be useful,
|
---|
| 26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 28 | * GNU General Public License for more details.
|
---|
| 29 | *
|
---|
| 30 | * <BR><BR>
|
---|
| 31 | *
|
---|
| 32 | * You should have received a copy of the GNU General Public License
|
---|
| 33 | * along with this program; if not, write to the Free Software
|
---|
| 34 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 35 | *########################################################################
|
---|
| 36 | */
|
---|
| 37 | package org.greenstone.gatherer.gui;
|
---|
| 38 |
|
---|
| 39 | import java.awt.*;
|
---|
| 40 | import java.awt.event.*;
|
---|
| 41 | import java.io.*;
|
---|
| 42 | import java.util.ArrayList;
|
---|
[12336] | 43 | import java.util.HashMap;
|
---|
[9243] | 44 | import javax.swing.*;
|
---|
| 45 | import javax.swing.event.*;
|
---|
[12336] | 46 |
|
---|
[9243] | 47 | import org.greenstone.gatherer.Configuration;
|
---|
| 48 | import org.greenstone.gatherer.DebugStream;
|
---|
| 49 | import org.greenstone.gatherer.Dictionary;
|
---|
| 50 | import org.greenstone.gatherer.Gatherer;
|
---|
| 51 | import org.greenstone.gatherer.collection.BasicCollectionConfiguration;
|
---|
[13594] | 52 | import org.greenstone.gatherer.greenstone.LocalGreenstone;
|
---|
[9243] | 53 | import org.greenstone.gatherer.shell.GShell;
|
---|
| 54 | import org.greenstone.gatherer.shell.GShellEvent;
|
---|
| 55 | import org.greenstone.gatherer.shell.GShellListener;
|
---|
[12336] | 56 | import org.greenstone.gatherer.shell.GDefaultProgressMonitor;
|
---|
[9243] | 57 | import org.greenstone.gatherer.util.ArrayTools;
|
---|
| 58 | import org.greenstone.gatherer.util.CheckList;
|
---|
| 59 | import org.greenstone.gatherer.util.CheckListEntry;
|
---|
| 60 | import org.greenstone.gatherer.util.StaticStrings;
|
---|
| 61 | import org.greenstone.gatherer.util.Utility;
|
---|
| 62 |
|
---|
| 63 | /** This class provides the functionality to export a set of current
|
---|
| 64 | * collections from the GSDLHOME/collect/ directory to various formats
|
---|
| 65 | * (hence ExportAs) using export.pl. The user chooses the collection from a
|
---|
| 66 | * list, where each entry also displays details about itself, confirms the
|
---|
| 67 | * delete of a collection by checking a checkbox then presses the ok button
|
---|
| 68 | * to actually delete the collection.
|
---|
| 69 | * Copied from WriteCDImagePrompt
|
---|
| 70 | * @author John Thompson, Greenstone Digital Library, University of Waikato
|
---|
| 71 | * @version 2.3
|
---|
| 72 | */
|
---|
| 73 | public class ExportAsPrompt
|
---|
| 74 | extends ModalDialog
|
---|
| 75 | implements GShellListener {
|
---|
| 76 |
|
---|
| 77 | static final private Dimension LABEL_SIZE = new Dimension(120, 25);
|
---|
| 78 |
|
---|
| 79 | private OKButtonListener ok_button_listener;
|
---|
| 80 |
|
---|
| 81 | private JLabel saveas_label = null;
|
---|
| 82 | private JComboBox saveas_combobox = null;
|
---|
| 83 |
|
---|
| 84 | private ArrayList all_collections = null;
|
---|
[17145] | 85 | private BasicCollectionConfiguration selected_collection = null;
|
---|
| 86 | /** The list of collections to export */
|
---|
| 87 | private JList list = null;
|
---|
[9243] | 88 | /** The currently selected collection for deletion. */
|
---|
| 89 | private BasicCollectionConfiguration collection = null;
|
---|
| 90 | /** A reference to ourself so any inner-classes can dispose of us. */
|
---|
| 91 | private ExportAsPrompt prompt = null;
|
---|
| 92 | /** The close button, which exits the prompt without deleting anything. */
|
---|
| 93 | private JButton cancel_button = null;
|
---|
| 94 | /** The ok button which causes the selected collection to be deleted. */
|
---|
| 95 | private JButton ok_button = null;
|
---|
| 96 | /** The label above details. */
|
---|
| 97 | private JLabel details_label = null;
|
---|
| 98 | /** The label above the list. */
|
---|
| 99 | private JLabel list_label = null;
|
---|
| 100 | /** The text area used to display details about the collection selected. */
|
---|
| 101 | private JTextArea details_textarea = null;
|
---|
| 102 | /** The text area used to display instructions for the cd-rom/dvd export */
|
---|
| 103 | private JTextArea instructions_textarea;
|
---|
| 104 | /** A string array used to pass arguments to the phrase retrieval method. */
|
---|
| 105 | private JTextField title_field = null;
|
---|
| 106 | private JLabel title_label = null;
|
---|
| 107 | private String args[] = null;
|
---|
| 108 | private String cd_title = null;
|
---|
| 109 | /** whether the exporting was successful or not */
|
---|
| 110 | private boolean successful = false;
|
---|
| 111 | /** whether we are trying to export or not */
|
---|
| 112 | private boolean exporting = false;
|
---|
| 113 | /** the error message if any */
|
---|
| 114 | private StringBuffer error_message = null;
|
---|
| 115 | /** The size of the export prompt screen. */
|
---|
[13320] | 116 | public static final Dimension SIZE = new Dimension(500, 540);
|
---|
[12336] | 117 | private GDefaultProgressMonitor progress_monitor;
|
---|
[9243] | 118 |
|
---|
[12336] | 119 | private JButton convert_xml_button1 = null;
|
---|
| 120 | private JButton convert_xml_button2 = null;
|
---|
[12592] | 121 | private JButton convert_xml_button3 = null;
|
---|
[13320] | 122 | private JButton folder_button = null;
|
---|
[12336] | 123 |
|
---|
| 124 | private JPanel instructions_pane = null;
|
---|
| 125 |
|
---|
| 126 | private JPanel convert_xml_pane1 = null;
|
---|
| 127 | private JPanel convert_xml_pane2 = null;
|
---|
[12592] | 128 | private JPanel mapping_xml_pane = null;
|
---|
[12336] | 129 |
|
---|
| 130 | private JCheckBox convert_xml_checkbox1 = null;
|
---|
[12592] | 131 | private JCheckBox convert_xml_checkbox2 = null;
|
---|
| 132 | private JCheckBox mapping_xml_checkbox = null;
|
---|
| 133 |
|
---|
[12336] | 134 | private JCheckBox output_single_checkbox = null;
|
---|
| 135 |
|
---|
| 136 | private JTextField convert_xml_field1 = null;
|
---|
| 137 | private JTextField convert_xml_field2 = null;
|
---|
[12592] | 138 | private JTextField mapping_xml_field = null;
|
---|
[12336] | 139 |
|
---|
[12592] | 140 |
|
---|
[12336] | 141 | private File xsl_file1 = null;
|
---|
| 142 | private File xsl_file2 = null;
|
---|
[12592] | 143 | private File mapping_file = null;
|
---|
[12336] | 144 |
|
---|
| 145 | private JPanel convert_xml_pane = null;
|
---|
| 146 |
|
---|
| 147 | private HashMap plugoutMap = new HashMap();
|
---|
| 148 |
|
---|
| 149 |
|
---|
[9243] | 150 | /** Constructor.
|
---|
| 151 | * @see org.greenstone.gatherer.collection.ExportAsPrompt.CancelButtonListener
|
---|
| 152 | * @see org.greenstone.gatherer.collection.ExportAsPrompt.CollectionListListener
|
---|
| 153 | * @see org.greenstone.gatherer.collection.ExportAsPrompt.OKButtonListener
|
---|
| 154 | */
|
---|
| 155 | public ExportAsPrompt() {
|
---|
| 156 | super(Gatherer.g_man, true);
|
---|
[18370] | 157 | this.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12336] | 158 | plugoutMap.clear();
|
---|
| 159 | plugoutMap.put("DSpace","dublin-core.xml");
|
---|
| 160 | plugoutMap.put("MARCXML","doc.xml");
|
---|
[17132] | 161 | plugoutMap.put("GreenstoneMETS","doctxt.xml,docmets.xml");
|
---|
| 162 | plugoutMap.put("FedoraMETS","doctxt.xml,docmets.xml");
|
---|
[12336] | 163 |
|
---|
[17132] | 164 | // this is the order we want them to appear in the list
|
---|
[17145] | 165 | String [] saveas_formats = {"GreenstoneMETS", "FedoraMETS", "MARCXML", "DSpace"};
|
---|
[12336] | 166 | cancel_button = new GLIButton(Dictionary.get("General.Close"), Dictionary.get("General.Close_Tooltip"));
|
---|
| 167 |
|
---|
[12119] | 168 | details_textarea = new JTextArea(Dictionary.get("DeleteCollectionPrompt.No_Collection"));
|
---|
[9243] | 169 | details_textarea.setEditable(false);
|
---|
[18370] | 170 | details_textarea.setComponentOrientation(Dictionary.getOrientation());
|
---|
| 171 |
|
---|
[12119] | 172 | details_label = new JLabel(Dictionary.get("DeleteCollectionPrompt.Collection_Details"));
|
---|
[18372] | 173 | details_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
[9243] | 174 |
|
---|
[12119] | 175 | instructions_textarea = new JTextArea(Dictionary.get("ExportAsPrompt.Instructions"));
|
---|
[9243] | 176 | instructions_textarea.setCaretPosition(0);
|
---|
| 177 | instructions_textarea.setEditable(false);
|
---|
| 178 | instructions_textarea.setLineWrap(true);
|
---|
| 179 | instructions_textarea.setRows(4);
|
---|
| 180 | instructions_textarea.setWrapStyleWord(true);
|
---|
[18370] | 181 | instructions_textarea.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12336] | 182 |
|
---|
| 183 |
|
---|
[18412] | 184 | saveas_label = new JLabel(Dictionary.get("ExportAsPrompt.SaveAs"));
|
---|
[18370] | 185 | saveas_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
[9243] | 186 | //saveas_label.setPreferredSize(LABEL_SIZE);
|
---|
[12119] | 187 |
|
---|
[17132] | 188 | saveas_combobox = new JComboBox(saveas_formats);
|
---|
[13195] | 189 | saveas_combobox.setOpaque(false);
|
---|
[12119] | 190 | saveas_combobox.setToolTipText(Dictionary.get("ExportAsPrompt.SaveAs_Tooltip"));
|
---|
[18370] | 191 | saveas_combobox.setComponentOrientation(Dictionary.getOrientation());
|
---|
[9243] | 192 |
|
---|
[12336] | 193 | // Add xml conversion feature
|
---|
| 194 | convert_xml_button1 = new GLIButton(Dictionary.get("ExportAsPrompt.Browse"),Dictionary.get("ExportAsPrompt.Browse_Tooltip"));
|
---|
| 195 | convert_xml_button1.setEnabled(false);
|
---|
| 196 |
|
---|
| 197 | convert_xml_button2 = new GLIButton(Dictionary.get("ExportAsPrompt.Browse"),Dictionary.get("ExportAsPrompt.Browse_Tooltip"));
|
---|
| 198 | convert_xml_button2.setEnabled(false);
|
---|
[12592] | 199 |
|
---|
| 200 | convert_xml_button3 = new GLIButton(Dictionary.get("ExportAsPrompt.Browse"),Dictionary.get("ExportAsPrompt.Browse_Tooltip"));
|
---|
| 201 | convert_xml_button3.setEnabled(false);
|
---|
[12336] | 202 |
|
---|
| 203 | convert_xml_checkbox1 = new JCheckBox();
|
---|
| 204 | convert_xml_checkbox1.setText(Dictionary.get("ExportAsPrompt.ApplyXSL","doc.xml"));
|
---|
| 205 | convert_xml_checkbox1.setToolTipText(Dictionary.get("ExportAsPrompt.ApplyXSL_Tooltip"));
|
---|
[18370] | 206 | convert_xml_checkbox1.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12336] | 207 |
|
---|
| 208 | convert_xml_checkbox2 = new JCheckBox();
|
---|
| 209 | convert_xml_checkbox2.setToolTipText(Dictionary.get("ExportAsPrompt.ApplyXSL_Tooltip"));
|
---|
[18370] | 210 | convert_xml_checkbox2.setComponentOrientation(Dictionary.getOrientation());
|
---|
| 211 |
|
---|
[12336] | 212 | output_single_checkbox = new JCheckBox();
|
---|
[18370] | 213 | output_single_checkbox.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12336] | 214 | output_single_checkbox.setText(Dictionary.get("ExportAsPrompt.MARCXMLGroup"));
|
---|
| 215 | output_single_checkbox.setToolTipText(Dictionary.get("ExportAsPrompt.MARCXMLGroup_Tooltip"));
|
---|
| 216 |
|
---|
[12592] | 217 |
|
---|
| 218 | mapping_xml_checkbox = new JCheckBox();
|
---|
[18370] | 219 | mapping_xml_checkbox.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12592] | 220 | mapping_xml_checkbox.setText(Dictionary.get("ExportAsPrompt.MappingXML"));
|
---|
| 221 | mapping_xml_checkbox.setToolTipText(Dictionary.get("ExportAsPrompt.MappingXML_Tooltip"));
|
---|
| 222 |
|
---|
[12336] | 223 | convert_xml_field1 = new JTextField();
|
---|
[18370] | 224 | convert_xml_field1.setComponentOrientation(Dictionary.getOrientation());
|
---|
[17252] | 225 | convert_xml_field1.setEnabled(false);
|
---|
[18370] | 226 |
|
---|
[12336] | 227 | convert_xml_field2 = new JTextField();
|
---|
[18370] | 228 | convert_xml_field2.setComponentOrientation(Dictionary.getOrientation());
|
---|
[17252] | 229 | convert_xml_field2.setEnabled(false);
|
---|
[18370] | 230 |
|
---|
[12592] | 231 | mapping_xml_field = new JTextField();
|
---|
[18370] | 232 | mapping_xml_field.setComponentOrientation(Dictionary.getOrientation());
|
---|
[17252] | 233 | mapping_xml_field.setEnabled(false);
|
---|
[12336] | 234 |
|
---|
| 235 | convert_xml_pane1 = new JPanel(new BorderLayout());
|
---|
[18370] | 236 | convert_xml_pane1.setComponentOrientation(Dictionary.getOrientation());
|
---|
| 237 |
|
---|
[12336] | 238 | convert_xml_pane2 = new JPanel(new BorderLayout());
|
---|
[18370] | 239 | convert_xml_pane2.setComponentOrientation(Dictionary.getOrientation());
|
---|
| 240 |
|
---|
[12592] | 241 | mapping_xml_pane = new JPanel(new BorderLayout());
|
---|
[18370] | 242 | mapping_xml_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
| 243 |
|
---|
[12592] | 244 | convert_xml_pane = new JPanel(new GridLayout(3,1));
|
---|
[18370] | 245 | convert_xml_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
| 246 |
|
---|
[9243] | 247 | all_collections = new ArrayList();
|
---|
[17145] | 248 | //list = new CheckList(true);
|
---|
| 249 | list = new JList(getCollectionListModel());
|
---|
[18372] | 250 | list.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12119] | 251 | list_label = new JLabel(Dictionary.get("DeleteCollectionPrompt.Collection_List"));
|
---|
[18370] | 252 | list_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
| 253 |
|
---|
[12119] | 254 | ok_button = new GLIButton(Dictionary.get("ExportAsPrompt.Export"), Dictionary.get("ExportAsPrompt.Export_Tooltip"));
|
---|
| 255 |
|
---|
[9243] | 256 | title_field = new JTextField();
|
---|
[18370] | 257 | title_field.setComponentOrientation(Dictionary.getOrientation());
|
---|
[13076] | 258 | title_field.setToolTipText(Dictionary.get("ExportAsPrompt.Export_Name_Tooltip"));
|
---|
[12119] | 259 | title_label = new JLabel(Dictionary.get("ExportAsPrompt.Export_Name"));
|
---|
[18370] | 260 | title_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
| 261 |
|
---|
[13320] | 262 | folder_button = new GLIButton(Dictionary.get("ExportAsPrompt.Browse"),Dictionary.get("ExportAsPrompt.Browse_Tooltip"));
|
---|
| 263 | folder_button.addActionListener(new FolderButtonListener());
|
---|
| 264 |
|
---|
[17145] | 265 |
|
---|
[9243] | 266 | prompt = this;
|
---|
| 267 | setSize(SIZE);
|
---|
[12119] | 268 | setTitle(Dictionary.get("ExportAsPrompt.Title"));
|
---|
[9243] | 269 |
|
---|
[12730] | 270 | setJMenuBar(new SimpleMenuBar("exporting"));
|
---|
[9243] | 271 | cancel_button.addActionListener(new CancelButtonListener());
|
---|
| 272 | list.addListSelectionListener(new CollectionListListener());
|
---|
| 273 | list.clearSelection();
|
---|
| 274 | list.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
---|
| 275 | ok_button_listener = new OKButtonListener();
|
---|
| 276 | ok_button.addActionListener(ok_button_listener);
|
---|
| 277 | ok_button.setEnabled(false);
|
---|
| 278 | //title.getDocument().addDocumentListener(new DocumentListener());
|
---|
[12336] | 279 |
|
---|
| 280 | convert_xml_button1.addActionListener(new ConvertXMLButtonListener());
|
---|
| 281 | convert_xml_checkbox1.addActionListener(new ConvertXMLCheckboxListener());
|
---|
[12592] | 282 | mapping_xml_checkbox.addActionListener(new ConvertXMLCheckboxListener());
|
---|
| 283 | convert_xml_button3.addActionListener(new ConvertXMLButtonListener());
|
---|
[12336] | 284 |
|
---|
| 285 | convert_xml_button2.addActionListener(new ConvertXMLButtonListener());
|
---|
| 286 | convert_xml_checkbox2.addActionListener(new ConvertXMLCheckboxListener());
|
---|
| 287 |
|
---|
| 288 | saveas_combobox.addActionListener(new SaveasListener());
|
---|
| 289 |
|
---|
[9243] | 290 | }
|
---|
| 291 |
|
---|
| 292 | /** Destructor. */
|
---|
| 293 | public void destroy() {
|
---|
| 294 | saveas_label = null;
|
---|
| 295 | saveas_combobox = null;
|
---|
| 296 | all_collections.clear();
|
---|
| 297 | all_collections = null;
|
---|
| 298 | cancel_button = null;
|
---|
| 299 | details_textarea = null;
|
---|
| 300 | details_label = null;
|
---|
| 301 | list = null;
|
---|
| 302 | ok_button = null;
|
---|
| 303 | prompt = null;
|
---|
[17145] | 304 | selected_collection = null;
|
---|
[9243] | 305 | title_field = null;
|
---|
| 306 | title_label = null;
|
---|
| 307 | }
|
---|
| 308 |
|
---|
| 309 | /** This method causes the modal prompt to be displayed.
|
---|
| 310 | * returns true if it has exported the collections that are currently selected */
|
---|
| 311 | public boolean display() {
|
---|
[18370] | 312 | JScrollPane scrol_tmp;
|
---|
[9243] | 313 | // Top pane
|
---|
[12336] | 314 | instructions_pane = new JPanel(new BorderLayout());
|
---|
[18370] | 315 | instructions_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
| 316 | instructions_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,5));
|
---|
| 317 | scrol_tmp = new JScrollPane(instructions_textarea);
|
---|
| 318 | scrol_tmp.setComponentOrientation(Dictionary.getOrientation());
|
---|
| 319 | instructions_pane.add(scrol_tmp, BorderLayout.CENTER);
|
---|
[9243] | 320 |
|
---|
| 321 | title_label.setBorder(BorderFactory.createEmptyBorder(0,5,0,15));
|
---|
| 322 |
|
---|
| 323 | JPanel title_pane = new JPanel(new BorderLayout());
|
---|
[18370] | 324 | title_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
| 325 | title_pane.add(title_label, BorderLayout.LINE_START);
|
---|
[9243] | 326 | title_pane.add(title_field, BorderLayout.CENTER);
|
---|
[18370] | 327 | title_pane.add(folder_button, BorderLayout.LINE_END);
|
---|
[12336] | 328 | //apply xsl pane
|
---|
| 329 |
|
---|
| 330 | convert_xml_pane1.removeAll();
|
---|
| 331 | convert_xml_pane2.removeAll();
|
---|
[12592] | 332 | mapping_xml_pane.removeAll();
|
---|
[12336] | 333 | convert_xml_pane.removeAll();
|
---|
[9243] | 334 |
|
---|
[18370] | 335 | convert_xml_pane1.add(convert_xml_checkbox1, BorderLayout.LINE_START);
|
---|
[12336] | 336 | convert_xml_pane1.add(convert_xml_field1, BorderLayout.CENTER);
|
---|
[18370] | 337 | convert_xml_pane1.add(convert_xml_button1, BorderLayout.LINE_END);
|
---|
[12336] | 338 |
|
---|
[18370] | 339 | convert_xml_pane2.add(convert_xml_checkbox2, BorderLayout.LINE_START);
|
---|
[12336] | 340 | convert_xml_pane2.add(convert_xml_field2, BorderLayout.CENTER);
|
---|
[18370] | 341 | convert_xml_pane2.add(convert_xml_button2, BorderLayout.LINE_END);
|
---|
[12336] | 342 |
|
---|
[18370] | 343 | mapping_xml_pane.add(mapping_xml_checkbox, BorderLayout.LINE_START);
|
---|
[12592] | 344 | mapping_xml_pane.add(mapping_xml_field, BorderLayout.CENTER);
|
---|
[18370] | 345 | mapping_xml_pane.add(convert_xml_button3, BorderLayout.LINE_END);
|
---|
[12592] | 346 |
|
---|
[12336] | 347 | convert_xml_pane.add(convert_xml_pane1);
|
---|
| 348 |
|
---|
| 349 | String saveas = (String)saveas_combobox.getSelectedItem();
|
---|
[17252] | 350 | // force the updating of which fields we are displaying
|
---|
| 351 | saveas_combobox.setSelectedIndex(0);
|
---|
[12336] | 352 |
|
---|
| 353 | // Save as pane
|
---|
[9243] | 354 | JPanel saveas_pane = new JPanel(new BorderLayout());
|
---|
[18370] | 355 | saveas_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12336] | 356 | saveas_label.setBorder(BorderFactory.createEmptyBorder(0,5,0,15));
|
---|
[18370] | 357 | saveas_pane.add(saveas_label, BorderLayout.LINE_START);
|
---|
[9243] | 358 | saveas_pane.add(saveas_combobox, BorderLayout.CENTER);
|
---|
| 359 |
|
---|
[12336] | 360 | JPanel tmp_pane = new JPanel(new BorderLayout());
|
---|
[18370] | 361 | tmp_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
[13320] | 362 | tmp_pane.add(saveas_pane, BorderLayout.NORTH);
|
---|
[12336] | 363 | tmp_pane.add(title_pane, BorderLayout.CENTER);
|
---|
| 364 |
|
---|
| 365 | instructions_pane.add(tmp_pane, BorderLayout.NORTH);
|
---|
| 366 |
|
---|
| 367 | instructions_pane.add(convert_xml_pane, BorderLayout.CENTER);
|
---|
| 368 |
|
---|
[9243] | 369 | // Central pane
|
---|
| 370 | JPanel list_pane = new JPanel(new BorderLayout());
|
---|
[18370] | 371 | list_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
[9243] | 372 | list_pane.add(list_label, BorderLayout.NORTH);
|
---|
[18370] | 373 | scrol_tmp = new JScrollPane(list);
|
---|
| 374 | scrol_tmp.setComponentOrientation(Dictionary.getOrientation());
|
---|
| 375 | list_pane.add(scrol_tmp, BorderLayout.CENTER);
|
---|
[9243] | 376 | list_pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
|
---|
| 377 |
|
---|
| 378 | JPanel details_pane = new JPanel(new BorderLayout());
|
---|
[18370] | 379 | details_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
[9243] | 380 | details_pane.add(details_label, BorderLayout.NORTH);
|
---|
[18370] | 381 | scrol_tmp = new JScrollPane(details_textarea);
|
---|
| 382 | scrol_tmp.setComponentOrientation(Dictionary.getOrientation());
|
---|
| 383 | details_pane.add(scrol_tmp, BorderLayout.CENTER);
|
---|
[9243] | 384 | details_pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
|
---|
| 385 |
|
---|
| 386 | JPanel central_pane = new JPanel(new GridLayout(2, 1));
|
---|
[18370] | 387 | central_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
[9243] | 388 | central_pane.add(list_pane);
|
---|
| 389 | central_pane.add(details_pane);
|
---|
| 390 | central_pane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
---|
| 391 |
|
---|
| 392 | // Lower pane
|
---|
| 393 | JPanel button_pane = new JPanel(new GridLayout(1, 2));
|
---|
[18370] | 394 | button_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
[9243] | 395 | button_pane.add(ok_button);
|
---|
| 396 | button_pane.add(cancel_button);
|
---|
| 397 | button_pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
|
---|
| 398 |
|
---|
| 399 | JPanel lower_pane = new JPanel(new BorderLayout());
|
---|
[18370] | 400 | lower_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
[9243] | 401 | lower_pane.add(button_pane, BorderLayout.SOUTH);
|
---|
| 402 | lower_pane.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5));
|
---|
| 403 |
|
---|
| 404 | // Final.
|
---|
| 405 | JPanel content_pane = (JPanel)this.getContentPane();
|
---|
[18370] | 406 | content_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
[9243] | 407 | content_pane.setLayout(new BorderLayout());
|
---|
| 408 | content_pane.add(instructions_pane, BorderLayout.NORTH);
|
---|
| 409 | content_pane.add(central_pane, BorderLayout.CENTER);
|
---|
| 410 | content_pane.add(lower_pane, BorderLayout.SOUTH);
|
---|
| 411 |
|
---|
| 412 | // Center and display.
|
---|
| 413 | Dimension screen_size = Configuration.screen_size;
|
---|
| 414 | this.setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2);
|
---|
| 415 | this.setVisible(true); // blocks until the dialog is killed
|
---|
| 416 | return true;
|
---|
| 417 |
|
---|
| 418 | }
|
---|
| 419 |
|
---|
| 420 |
|
---|
| 421 | /** This method calls the builcol.pl scripts via a GShell so as to not lock up the processor.
|
---|
| 422 | * @see org.greenstone.gatherer.Configuration
|
---|
| 423 | * @see org.greenstone.gatherer.Gatherer
|
---|
| 424 | * @see org.greenstone.gatherer.collection.Collection
|
---|
| 425 | * @see org.greenstone.gatherer.gui.BuildOptions
|
---|
| 426 | * @see org.greenstone.gatherer.shell.GShell
|
---|
| 427 | * @see org.greenstone.gatherer.shell.GShellListener
|
---|
| 428 | * @see org.greenstone.gatherer.shell.GShellProgressMonitor
|
---|
| 429 | * @see org.greenstone.gatherer.util.Utility
|
---|
| 430 | */
|
---|
| 431 | public void exportAsCollections() {
|
---|
| 432 | DebugStream.println("ExportAsPrompt.exportAsCollections()");
|
---|
| 433 |
|
---|
[17145] | 434 | if (selected_collection == null) return;
|
---|
| 435 |
|
---|
[9243] | 436 | cd_title = title_field.getText();
|
---|
| 437 |
|
---|
[9755] | 438 | String export_type = (String) saveas_combobox.getSelectedItem();
|
---|
[12336] | 439 |
|
---|
[9755] | 440 | // Generate the export.pl command
|
---|
| 441 | ArrayList command_parts_list = new ArrayList();
|
---|
[20924] | 442 | if (!Gatherer.isGsdlRemote) {
|
---|
[9755] | 443 | command_parts_list.add(Configuration.perl_path);
|
---|
| 444 | command_parts_list.add("-S");
|
---|
[9243] | 445 | }
|
---|
[10370] | 446 | command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "export.pl");
|
---|
[9755] | 447 | command_parts_list.add("-gli");
|
---|
| 448 | command_parts_list.add("-language");
|
---|
| 449 | command_parts_list.add(Configuration.getLanguage());
|
---|
| 450 | command_parts_list.add("-removeold");
|
---|
| 451 | command_parts_list.add("-saveas");
|
---|
| 452 | command_parts_list.add(export_type);
|
---|
[22848] | 453 | // we want to be able to export items from other collect directories too
|
---|
| 454 | String collectDir = Gatherer.getCollectDirectoryPath();
|
---|
| 455 | if(collectDir != Gatherer.getDefaultGSCollectDirectoryPath(true)) {
|
---|
| 456 | command_parts_list.add("-collectdir");
|
---|
| 457 | command_parts_list.add(collectDir);
|
---|
| 458 | }
|
---|
[9755] | 459 | command_parts_list.add("-exportdir");
|
---|
[11753] | 460 | String export_dir = LocalGreenstone.getTmpDirectoryPath();
|
---|
[13320] | 461 | if (cd_title.equals("")) {
|
---|
| 462 | export_dir += "exported_" + export_type;
|
---|
[9755] | 463 | }
|
---|
| 464 | else {
|
---|
[13320] | 465 | File cd_file = new File(cd_title);
|
---|
| 466 | if (cd_file.isAbsolute())
|
---|
| 467 | export_dir = cd_title + File.separator + "exported_" + export_type;
|
---|
| 468 | else{
|
---|
| 469 | cd_title = cd_title.replaceAll("\\s+","");
|
---|
| 470 | cd_title = cd_title.replaceAll("\\\\+","/");
|
---|
| 471 | cd_title = cd_title.replaceAll("/+","/");
|
---|
| 472 | export_dir +=cd_title;
|
---|
| 473 | }
|
---|
[9755] | 474 | }
|
---|
[11753] | 475 |
|
---|
[13320] | 476 | command_parts_list.add(export_dir);
|
---|
| 477 |
|
---|
[17132] | 478 | if (!export_type.endsWith("METS") && xsl_file1 !=null){
|
---|
[12336] | 479 | command_parts_list.add("-xsltfile");
|
---|
| 480 | command_parts_list.add(xsl_file1.getPath());
|
---|
| 481 | }
|
---|
| 482 |
|
---|
[12592] | 483 | //add command specific to MARCXML
|
---|
| 484 | if (export_type.equals("MARCXML")){
|
---|
| 485 | //add default transformation file
|
---|
| 486 | if (xsl_file1 == null){
|
---|
| 487 | command_parts_list.add("-xsltfile");
|
---|
| 488 | command_parts_list.add(Configuration.gsdl_path+"etc"+File.separator+"dc2marc.xsl");
|
---|
| 489 | }
|
---|
| 490 |
|
---|
| 491 | command_parts_list.add("-mapping_file");
|
---|
| 492 | //default mapping file
|
---|
| 493 | if (mapping_file == null){
|
---|
| 494 | command_parts_list.add(Configuration.gsdl_path+"etc"+File.separator+"dc2marc-mapping.xml");
|
---|
| 495 | }
|
---|
| 496 | else{
|
---|
| 497 | command_parts_list.add(mapping_file.getPath());
|
---|
| 498 | }
|
---|
| 499 |
|
---|
| 500 | if (output_single_checkbox.isSelected()){
|
---|
| 501 | command_parts_list.add("-group_marc");
|
---|
| 502 | }
|
---|
| 503 |
|
---|
[12336] | 504 | }
|
---|
| 505 |
|
---|
[12592] | 506 |
|
---|
[17132] | 507 | if (export_type.endsWith("METS") && xsl_file1 !=null){
|
---|
[12336] | 508 | command_parts_list.add("-xslt_txt");
|
---|
| 509 | command_parts_list.add(xsl_file1.getPath());
|
---|
| 510 | }
|
---|
| 511 |
|
---|
[17132] | 512 | if (export_type.endsWith("METS") && xsl_file2 !=null){
|
---|
[12336] | 513 | command_parts_list.add("-xslt_mets");
|
---|
| 514 | command_parts_list.add(xsl_file2.getPath());
|
---|
| 515 | }
|
---|
| 516 |
|
---|
[17145] | 517 | command_parts_list.add( selected_collection.getShortName());
|
---|
| 518 |
|
---|
[9243] | 519 |
|
---|
| 520 | DebugStream.print("export command = ");
|
---|
[13062] | 521 | for (int i = 0; i < command_parts_list.size(); i++) {
|
---|
[9755] | 522 | DebugStream.print(command_parts_list.get(i) + " ");
|
---|
[13066] | 523 | //System.err.print(command_parts_list.get(i) + " ");
|
---|
[9243] | 524 | }
|
---|
| 525 | DebugStream.println("");
|
---|
| 526 |
|
---|
[9755] | 527 | // Run the export.pl command
|
---|
| 528 | String[] command_parts = (String[]) command_parts_list.toArray(new String[0]);
|
---|
[12336] | 529 |
|
---|
| 530 | progress_monitor = new GDefaultProgressMonitor();
|
---|
| 531 |
|
---|
| 532 | GShell process = new GShell(command_parts, GShell.EXPORTAS, 3, this,progress_monitor , GShell.GSHELL_EXPORTAS);
|
---|
[9243] | 533 | process.start();
|
---|
| 534 | //process.run();
|
---|
| 535 | DebugStream.println("ExportAsPrompt.exportAsCollections().return");
|
---|
| 536 |
|
---|
| 537 | }
|
---|
| 538 |
|
---|
[12336] | 539 |
|
---|
| 540 | public void cancelExporting(){
|
---|
| 541 | progress_monitor.setStop(true);
|
---|
| 542 | }
|
---|
| 543 |
|
---|
| 544 |
|
---|
[9243] | 545 | /** Shows an export complete prompt.
|
---|
| 546 | * @param success A <strong>boolean</strong> indicating if the collection was successfully deleted.
|
---|
| 547 | * @see org.greenstone.gatherer.collection.Collection
|
---|
| 548 | */
|
---|
| 549 | public void resultPrompt(boolean success, String extra) {
|
---|
| 550 | args = new String[2];
|
---|
| 551 |
|
---|
[17145] | 552 | // coll name
|
---|
| 553 | args[0] = selected_collection.getName() + StaticStrings.SPACE_CHARACTER + StaticStrings.OPEN_PARENTHESIS_CHARACTER + selected_collection.getShortName() + StaticStrings.CLOSE_PARENTHESIS_CHARACTER;
|
---|
[13320] | 554 |
|
---|
| 555 | String export_type = (String) saveas_combobox.getSelectedItem();
|
---|
| 556 | args[1] = LocalGreenstone.getTmpDirectoryPath();
|
---|
| 557 | if (cd_title.equals("")) {
|
---|
| 558 | args[1] += "exported_" + export_type;
|
---|
[9243] | 559 | }
|
---|
[13320] | 560 | else {
|
---|
| 561 | File cd_file = new File(cd_title);
|
---|
| 562 | if (cd_file.isAbsolute())
|
---|
| 563 | args[1] = cd_title + File.separator + "exported_" + export_type;
|
---|
| 564 | else{
|
---|
| 565 | cd_title = cd_title.replaceAll("\\s+","");
|
---|
| 566 | cd_title = cd_title.replaceAll("\\\\+","/");
|
---|
| 567 | cd_title = cd_title.replaceAll("/+","/");
|
---|
| 568 | args[1] +=cd_title;
|
---|
| 569 | }
|
---|
| 570 | }
|
---|
| 571 |
|
---|
[9243] | 572 |
|
---|
| 573 | String title;
|
---|
| 574 | String label;
|
---|
| 575 | String details;
|
---|
| 576 |
|
---|
| 577 | if (success) {
|
---|
[17145] | 578 | String successMessage = "ExportAsPrompt.Successful_ExportOne";
|
---|
| 579 | title = Dictionary.get("ExportAsPrompt.Successful_Title");
|
---|
| 580 | label = Dictionary.get(successMessage, args);
|
---|
| 581 | details = Dictionary.get("ExportAsPrompt.Successful_Details", args);
|
---|
[9243] | 582 | } else {
|
---|
[17145] | 583 | String failedMessage = "ExportAsPrompt.Failed_ExportOne";
|
---|
| 584 | title = Dictionary.get("ExportAsPrompt.Failed_Title");
|
---|
| 585 | label = Dictionary.get(failedMessage, args);
|
---|
| 586 | details = Dictionary.get("ExportAsPrompt.Failed_Details", args);
|
---|
[9243] | 587 | }
|
---|
[17132] | 588 | SimpleResultDialog result_dialog = new SimpleResultDialog(this, title, label, details);
|
---|
[9243] | 589 | result_dialog.setVisible(true); // Blocks
|
---|
| 590 | result_dialog.dispose();
|
---|
| 591 | result_dialog = null;
|
---|
| 592 | }
|
---|
| 593 |
|
---|
| 594 | /** Method to scan the collect directory retrieving and reloading each collection it finds, while building the list of known collections.
|
---|
| 595 | * @see org.greenstone.gatherer.Configuration
|
---|
| 596 | * @see org.greenstone.gatherer.Gatherer
|
---|
| 597 | * @see org.greenstone.gatherer.util.ArrayTools
|
---|
| 598 | * @see org.greenstone.gatherer.util.Utility
|
---|
| 599 | */
|
---|
[17145] | 600 | private ListModel getCollectionListModel() {
|
---|
| 601 | DefaultListModel model = new DefaultListModel();
|
---|
[9243] | 602 | // Start at the collect dir.
|
---|
| 603 | File collect_directory = new File(Gatherer.getCollectDirectoryPath());
|
---|
[14045] | 604 | String file_name = (Gatherer.GS3)? Utility.CONFIG_GS3_FILE : Utility.CONFIG_FILE;
|
---|
[9243] | 605 | if (collect_directory.exists()) {
|
---|
| 606 | // Now for each child directory see if it contains a .col file and
|
---|
| 607 | // if so try to load it..
|
---|
| 608 | File collections[] = collect_directory.listFiles();
|
---|
| 609 | ArrayTools.sort(collections);
|
---|
| 610 | for(int i = 0; collections != null && i < collections.length; i++) {
|
---|
| 611 | if(collections[i].isDirectory() && !collections[i].getName().equals(StaticStrings.MODEL_COLLECTION_NAME)) {
|
---|
[14045] | 612 | File config_file = new File(collections[i], file_name);
|
---|
[9243] | 613 | if (config_file.exists()) {
|
---|
| 614 | BasicCollectionConfiguration config = new BasicCollectionConfiguration(config_file);
|
---|
[17145] | 615 | model.addElement(config);
|
---|
[9243] | 616 | config = null;
|
---|
| 617 | }
|
---|
| 618 | }
|
---|
| 619 | }
|
---|
| 620 | }
|
---|
[17145] | 621 | return model;
|
---|
[9243] | 622 | // Otherwise the collect directory doesn't actually exist, so there ain't much we can do.
|
---|
[17145] | 623 | }
|
---|
[9243] | 624 |
|
---|
| 625 |
|
---|
| 626 | /** All implementation of GShellListener must include this method so the listener can be informed of messages from the GShell.
|
---|
| 627 | * @param event A <strong>GShellEvent</strong> that contains, amoung other things, the message.
|
---|
| 628 | */
|
---|
| 629 | public synchronized void message(GShellEvent event) {
|
---|
| 630 | // Ignore the messages from RecPlug with 'show_progress' set (used for progress bars)
|
---|
| 631 | String message = event.getMessage();
|
---|
| 632 | if (message.startsWith("export.pl>")) {
|
---|
| 633 | message = message.substring(13);
|
---|
| 634 | //DebugStream.println("message = "+event.getMessage());
|
---|
| 635 | error_message.append(message);
|
---|
| 636 | error_message.append("\n");
|
---|
| 637 | }
|
---|
| 638 | }
|
---|
| 639 |
|
---|
| 640 | /** All implementation of GShellListener must include this method so the listener can be informed when a GShell begins its task. Implementation side-effect, not actually used.
|
---|
| 641 | * @param event A <strong>GShellEvent</strong> that contains details of the initial state of the <strong>GShell</strong> before task comencement.
|
---|
| 642 | */
|
---|
| 643 | public synchronized void processBegun(GShellEvent event) {
|
---|
| 644 | // We don't care.
|
---|
| 645 | }
|
---|
| 646 | /** All implementation of GShellListener must include this method so the listener can be informed when a GShell completes its task.
|
---|
| 647 | * @param event A <strong>GShellEvent</strong> that contains details of the final state of the <strong>GShell</strong> after task completion.
|
---|
| 648 | */
|
---|
| 649 | public synchronized void processComplete(GShellEvent event) {
|
---|
| 650 | successful = false;
|
---|
| 651 | if(event.getStatus() == GShell.OK) {
|
---|
| 652 | if(event.getType() == GShell.EXPORTAS) {
|
---|
| 653 | successful = true;
|
---|
| 654 | }
|
---|
| 655 | }
|
---|
| 656 | ok_button_listener.processComplete();
|
---|
| 657 | }
|
---|
| 658 |
|
---|
| 659 | /** A button listener implementation, which listens for actions on the close button and disposes of the dialog when detected. */
|
---|
| 660 | private class CancelButtonListener
|
---|
| 661 | implements ActionListener {
|
---|
| 662 | /** Any implementation of ActionListener must include this method so we can be informed when the button is actioned.
|
---|
| 663 | * @param event An <strong>ActionEvent</strong> containing all the relevant information garnered from the event itself.
|
---|
| 664 | */
|
---|
| 665 | public void actionPerformed(ActionEvent event) {
|
---|
| 666 | prompt.dispose();
|
---|
| 667 | }
|
---|
| 668 | }
|
---|
| 669 |
|
---|
| 670 | /** This private class listens for selection events in from the list and then displays the appropriate details for that collection.
|
---|
| 671 | */
|
---|
| 672 | private class CollectionListListener
|
---|
[9249] | 673 | implements ListSelectionListener
|
---|
| 674 | {
|
---|
[9243] | 675 | /** Any implementation of ListSelectionListener must include this method so we can be informed when the list selection changes.
|
---|
| 676 | * @param event a <strong>ListSelectionEvent</strong> containing all the relevant information garnered from the event itself
|
---|
| 677 | */
|
---|
[9249] | 678 | public void valueChanged(ListSelectionEvent event)
|
---|
| 679 | {
|
---|
| 680 | // Can only export when something is ticked
|
---|
[17145] | 681 | //ok_button.setEnabled(!list.isNothingTicked());
|
---|
[9249] | 682 |
|
---|
| 683 | if (list.isSelectionEmpty()) {
|
---|
[12119] | 684 | details_textarea.setText(Dictionary.get("DeleteCollectionPrompt.No_Collection"));
|
---|
[17145] | 685 | ok_button.setEnabled(false);
|
---|
[9243] | 686 | }
|
---|
[17145] | 687 | else {
|
---|
| 688 | BasicCollectionConfiguration collection = (BasicCollectionConfiguration) list.getSelectedValue();
|
---|
| 689 | args = new String[3];
|
---|
| 690 | args[0] = collection.getCreator();
|
---|
| 691 | args[1] = collection.getMaintainer();
|
---|
| 692 | args[2] = collection.getDescription();
|
---|
| 693 | details_textarea.setText(Dictionary.get("DeleteCollectionPrompt.Details", args));
|
---|
| 694 | details_textarea.setCaretPosition(0);
|
---|
| 695 | ok_button.setEnabled(true);
|
---|
| 696 | }
|
---|
| 697 | }
|
---|
[9249] | 698 |
|
---|
[9243] | 699 | }
|
---|
[9249] | 700 | /** The OK button listener implementation. */
|
---|
[9243] | 701 | private class OKButtonListener
|
---|
| 702 | implements ActionListener {
|
---|
| 703 | private Component glass_pane;
|
---|
| 704 | private MouseListener mouse_blocker_listener;
|
---|
| 705 | private ProgressDialog progress_dialog;
|
---|
| 706 |
|
---|
| 707 | /** Any implementation of ActionListener must include this method so we can be informed when the button is actioned.
|
---|
| 708 | * @param event An <strong>ActionEvent</strong> containing all the relevant information garnered from the event itself.
|
---|
| 709 | * @see org.greenstone.gatherer.Configuration
|
---|
| 710 | * @see org.greenstone.gatherer.Gatherer
|
---|
| 711 | * @see org.greenstone.gatherer.util.Utility
|
---|
| 712 | */
|
---|
| 713 | public void actionPerformed(ActionEvent event) {
|
---|
| 714 | ///ystem.err.println("OK Clicked");
|
---|
| 715 | // Make sure there are some colls specified
|
---|
[17145] | 716 | selected_collection = (BasicCollectionConfiguration)list.getSelectedValue();
|
---|
[9243] | 717 | error_message = new StringBuffer();
|
---|
| 718 |
|
---|
| 719 | // Set the cursor to hourglass
|
---|
| 720 | glass_pane = getGlassPane();
|
---|
| 721 | mouse_blocker_listener = new MouseAdapter() {};
|
---|
| 722 | glass_pane.addMouseListener(mouse_blocker_listener);
|
---|
| 723 | glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
---|
| 724 | glass_pane.setVisible(true);
|
---|
| 725 |
|
---|
| 726 | // Export the selected collection.
|
---|
| 727 | ///ystem.err.println("Exporting As for named collections");
|
---|
| 728 | exportAsCollections();
|
---|
| 729 |
|
---|
| 730 | // Show progress dialog
|
---|
| 731 | ///ystem.err.println("Showing progress dialog");
|
---|
| 732 | progress_dialog = new ProgressDialog();
|
---|
| 733 | progress_dialog.setVisible(true);
|
---|
| 734 | }
|
---|
| 735 |
|
---|
| 736 | public void processComplete() {
|
---|
| 737 | ///ystem.err.println("Process complete");
|
---|
| 738 | // Dispose of progress dialog
|
---|
[12336] | 739 |
|
---|
| 740 |
|
---|
[9243] | 741 | progress_dialog.setVisible(false);
|
---|
| 742 | progress_dialog.dispose();
|
---|
| 743 | progress_dialog = null;
|
---|
| 744 |
|
---|
| 745 | // unset the cursor
|
---|
| 746 | glass_pane.setVisible(false);
|
---|
| 747 | glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
---|
| 748 | glass_pane.removeMouseListener(mouse_blocker_listener);
|
---|
| 749 | glass_pane = null;
|
---|
| 750 | mouse_blocker_listener= null;
|
---|
| 751 |
|
---|
| 752 | if (successful) {
|
---|
| 753 | resultPrompt(true, error_message.toString());
|
---|
| 754 | } else {
|
---|
| 755 | resultPrompt(false, error_message.toString());
|
---|
| 756 | }
|
---|
| 757 | error_message = null;
|
---|
[12336] | 758 |
|
---|
| 759 | convert_xml_button1.setEnabled(false);
|
---|
| 760 | xsl_file1 = null;
|
---|
| 761 | convert_xml_field1.setText("");
|
---|
| 762 | convert_xml_checkbox1.setSelected(false);
|
---|
| 763 |
|
---|
| 764 | convert_xml_button2.setEnabled(false);
|
---|
| 765 | xsl_file2 = null;
|
---|
| 766 | convert_xml_field2.setText("");
|
---|
| 767 | convert_xml_checkbox2.setSelected(false);
|
---|
[12592] | 768 |
|
---|
| 769 | mapping_xml_checkbox.setSelected(false);
|
---|
| 770 | output_single_checkbox.setSelected(false);
|
---|
| 771 | convert_xml_button3.setEnabled(false);
|
---|
| 772 | mapping_xml_field.setText("");
|
---|
| 773 | mapping_file = null;
|
---|
| 774 |
|
---|
[9243] | 775 | }
|
---|
| 776 |
|
---|
| 777 | private class ProgressDialog
|
---|
| 778 | extends ModalDialog {
|
---|
| 779 |
|
---|
[12336] | 780 | private Dimension size = new Dimension(400,110);
|
---|
[9243] | 781 |
|
---|
| 782 | public ProgressDialog() {
|
---|
| 783 | super(Gatherer.g_man, Dictionary.get("ExportAsPrompt.Title"), true);
|
---|
| 784 | setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
---|
| 785 | setSize(size);
|
---|
| 786 | JPanel content_pane = (JPanel) getContentPane();
|
---|
[12119] | 787 | JLabel progress_label = new JLabel(Dictionary.get("ExportAsPrompt.Progress_Label"));
|
---|
| 788 |
|
---|
[9243] | 789 | JProgressBar progress_bar = new JProgressBar();
|
---|
| 790 | progress_bar.setIndeterminate(true);
|
---|
| 791 | content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
[12336] | 792 | GLIButton cancel_button = new GLIButton(Dictionary.get("ExportAsPrompt.Cancel"),Dictionary.get("ExportAsPrompt.Cancel_Tooltip"));
|
---|
| 793 | cancel_button.setMnemonic(KeyEvent.VK_C);
|
---|
| 794 |
|
---|
| 795 | cancel_button.addActionListener(new ActionListener(){
|
---|
| 796 | public void actionPerformed(ActionEvent e){
|
---|
| 797 | cancelExporting();
|
---|
| 798 | }
|
---|
| 799 |
|
---|
| 800 | });
|
---|
| 801 |
|
---|
| 802 | JPanel cancel_panel = new JPanel(new FlowLayout(FlowLayout.CENTER,0,0));
|
---|
| 803 | cancel_panel.add(cancel_button);
|
---|
| 804 |
|
---|
| 805 | content_pane.setLayout(new BorderLayout(0,5));
|
---|
[9243] | 806 | content_pane.add(progress_label, BorderLayout.NORTH);
|
---|
| 807 | content_pane.add(progress_bar, BorderLayout.CENTER);
|
---|
[12336] | 808 | content_pane.add(cancel_panel, BorderLayout.SOUTH);
|
---|
| 809 |
|
---|
[9243] | 810 | // Position
|
---|
| 811 | Rectangle frame_bounds = Gatherer.g_man.getBounds();
|
---|
| 812 | setLocation(frame_bounds.x + (frame_bounds.width - size.width) / 2, frame_bounds.y + (frame_bounds.height - size.height) / 2);
|
---|
| 813 | }
|
---|
| 814 | }
|
---|
| 815 | }
|
---|
| 816 |
|
---|
[12336] | 817 | private class ConvertXMLCheckboxListener implements ActionListener {
|
---|
| 818 | public void actionPerformed(ActionEvent event) {
|
---|
[12592] | 819 |
|
---|
| 820 | convert_xml_button1.setEnabled(convert_xml_checkbox1.isSelected());
|
---|
[17252] | 821 | convert_xml_field1.setEnabled(convert_xml_checkbox1.isSelected());
|
---|
[12592] | 822 | convert_xml_button2.setEnabled(convert_xml_checkbox2.isSelected());
|
---|
[17252] | 823 | convert_xml_field2.setEnabled(convert_xml_checkbox2.isSelected());
|
---|
[12592] | 824 | convert_xml_button3.setEnabled(mapping_xml_checkbox.isSelected());
|
---|
[17252] | 825 | mapping_xml_field.setEnabled(mapping_xml_checkbox.isSelected());
|
---|
[12592] | 826 |
|
---|
[12336] | 827 | }
|
---|
| 828 | }
|
---|
| 829 |
|
---|
| 830 |
|
---|
| 831 |
|
---|
| 832 | private class SaveasListener implements ActionListener {
|
---|
| 833 |
|
---|
| 834 | public void actionPerformed(ActionEvent event) {
|
---|
| 835 |
|
---|
| 836 | convert_xml_checkbox1.setSelected(false);
|
---|
| 837 | convert_xml_checkbox2.setSelected(false);
|
---|
[12592] | 838 | mapping_xml_checkbox.setSelected(false);
|
---|
[12336] | 839 | output_single_checkbox.setSelected(false);
|
---|
| 840 |
|
---|
| 841 | convert_xml_button1.setEnabled(false);
|
---|
| 842 | convert_xml_button2.setEnabled(false);
|
---|
[12592] | 843 | convert_xml_button3.setEnabled(false);
|
---|
[12336] | 844 |
|
---|
| 845 | convert_xml_field1.setText("");
|
---|
| 846 | convert_xml_field2.setText("");
|
---|
[12592] | 847 | mapping_xml_field.setText("");
|
---|
[12336] | 848 |
|
---|
| 849 | String saveas = (String)saveas_combobox.getSelectedItem();
|
---|
| 850 |
|
---|
| 851 | if (convert_xml_pane.getComponentCount() > 1){
|
---|
| 852 | convert_xml_pane.remove(1);
|
---|
[12592] | 853 | if (convert_xml_pane.getComponentCount() > 1){
|
---|
| 854 | convert_xml_pane.remove(1);
|
---|
| 855 | }
|
---|
[12336] | 856 | }
|
---|
| 857 |
|
---|
[17132] | 858 | if (!saveas.endsWith("METS")){
|
---|
[12336] | 859 |
|
---|
| 860 | convert_xml_checkbox1.setText(Dictionary.get("ExportAsPrompt.ApplyXSL",(String)plugoutMap.get(saveas)));
|
---|
| 861 | if (saveas.equals("MARCXML")){
|
---|
[12592] | 862 | convert_xml_pane.add(mapping_xml_pane);
|
---|
[12336] | 863 | convert_xml_pane.add(output_single_checkbox);
|
---|
| 864 | }
|
---|
| 865 | }
|
---|
| 866 | else{
|
---|
| 867 | String[] docs = ((String)plugoutMap.get(saveas)).split(",");
|
---|
| 868 | convert_xml_checkbox1.setText(Dictionary.get("ExportAsPrompt.ApplyXSL",docs[0]));
|
---|
| 869 | convert_xml_checkbox2.setText(Dictionary.get("ExportAsPrompt.ApplyXSL",docs[1]));
|
---|
| 870 | convert_xml_pane.add(convert_xml_pane2);
|
---|
| 871 | }
|
---|
| 872 |
|
---|
| 873 | convert_xml_pane.revalidate();
|
---|
| 874 | convert_xml_pane.repaint();
|
---|
| 875 | instructions_pane.revalidate();
|
---|
| 876 | instructions_pane.repaint();
|
---|
| 877 |
|
---|
| 878 | }
|
---|
| 879 |
|
---|
| 880 | }
|
---|
| 881 |
|
---|
| 882 | private class ConvertXMLButtonListener implements ActionListener {
|
---|
| 883 | public void actionPerformed(ActionEvent event) {
|
---|
| 884 | JFileChooser chooser = new JFileChooser();
|
---|
| 885 | // Note: source for ExampleFileFilter can be found in FileChooserDemo,
|
---|
| 886 | // under the demo/jfc directory in the Java 2 SDK, Standard Edition.
|
---|
| 887 | javax.swing.filechooser.FileFilter filter = new javax.swing.filechooser.FileFilter(){
|
---|
| 888 | public boolean accept(File f){
|
---|
[13046] | 889 | return f.getPath().endsWith(".xsl")||f.isDirectory()||f.getPath().endsWith(".xml");
|
---|
[12336] | 890 | }
|
---|
| 891 |
|
---|
| 892 | public String getDescription(){
|
---|
[13046] | 893 | return "XSL or XML file";
|
---|
[12336] | 894 | }
|
---|
| 895 | };
|
---|
| 896 |
|
---|
| 897 | chooser.setFileFilter(filter);
|
---|
| 898 | int returnVal = chooser.showOpenDialog(prompt);
|
---|
| 899 |
|
---|
| 900 | if(returnVal == JFileChooser.APPROVE_OPTION) {
|
---|
| 901 | if (event.getSource() == convert_xml_button1){
|
---|
| 902 |
|
---|
| 903 | xsl_file1 = chooser.getSelectedFile();
|
---|
| 904 | convert_xml_field1.setText(xsl_file1.getPath());
|
---|
| 905 | }
|
---|
[13025] | 906 | else if (event.getSource() == convert_xml_button2){
|
---|
[12336] | 907 | xsl_file2 = chooser.getSelectedFile();
|
---|
[12592] | 908 | convert_xml_field2.setText(xsl_file2.getPath());
|
---|
| 909 |
|
---|
[12336] | 910 | }
|
---|
[12592] | 911 | else {
|
---|
| 912 | mapping_file = chooser.getSelectedFile();
|
---|
| 913 | mapping_xml_field.setText(mapping_file.getPath());
|
---|
| 914 | }
|
---|
[12336] | 915 | }
|
---|
| 916 | }
|
---|
| 917 | }
|
---|
| 918 |
|
---|
[13320] | 919 | private class FolderButtonListener implements ActionListener {
|
---|
| 920 | public void actionPerformed(ActionEvent event) {
|
---|
| 921 | JFileChooser chooser = new JFileChooser();
|
---|
| 922 | chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
---|
| 923 |
|
---|
| 924 | int returnVal = chooser.showOpenDialog(prompt);
|
---|
| 925 |
|
---|
| 926 | if(returnVal == JFileChooser.APPROVE_OPTION) {
|
---|
| 927 | File folder_name = chooser.getSelectedFile();
|
---|
| 928 | title_field.setText(folder_name.getPath());
|
---|
| 929 | }
|
---|
| 930 |
|
---|
| 931 | }
|
---|
| 932 | }
|
---|
[9243] | 933 | }
|
---|
| 934 |
|
---|
| 935 |
|
---|
| 936 |
|
---|
| 937 |
|
---|
[13320] | 938 |
|
---|