[4932] | 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 | * Author: John Thompson, Greenstone Digital Library, University of Waikato
|
---|
| 9 | *
|
---|
| 10 | * Copyright (C) 1999 New Zealand Digital Library Project
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or modify
|
---|
| 13 | * it under the terms of the GNU General Public License as published by
|
---|
| 14 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 15 | * (at your option) any later version.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful,
|
---|
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 20 | * GNU General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, write to the Free Software
|
---|
| 24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 25 | *########################################################################
|
---|
| 26 | */
|
---|
| 27 | package org.greenstone.gatherer.cdm;
|
---|
[5529] | 28 |
|
---|
[4932] | 29 | import java.awt.*;
|
---|
| 30 | import java.awt.event.*;
|
---|
[6003] | 31 | import java.io.*;
|
---|
| 32 | import java.util.regex.*;
|
---|
[4932] | 33 | import javax.swing.*;
|
---|
[6003] | 34 | import javax.swing.filechooser.*;
|
---|
[4932] | 35 | import javax.swing.event.*;
|
---|
| 36 | import org.greenstone.gatherer.Configuration;
|
---|
[8236] | 37 | import org.greenstone.gatherer.DebugStream;
|
---|
[4932] | 38 | import org.greenstone.gatherer.Dictionary;
|
---|
| 39 | import org.greenstone.gatherer.Gatherer;
|
---|
[13586] | 40 | import org.greenstone.gatherer.collection.CollectionManager;
|
---|
[11031] | 41 | import org.greenstone.gatherer.gui.DesignPaneHeader;
|
---|
[4932] | 42 | import org.greenstone.gatherer.gui.EmailField;
|
---|
[6323] | 43 | import org.greenstone.gatherer.gui.GLIButton;
|
---|
[12093] | 44 | import org.greenstone.gatherer.gui.GUIUtils;
|
---|
[10374] | 45 | import org.greenstone.gatherer.remote.RemoteGreenstoneServer;
|
---|
[6003] | 46 | import org.greenstone.gatherer.util.StaticStrings;
|
---|
[5536] | 47 |
|
---|
[12093] | 48 | /** This class provides a graphical interface for editing general metadata for the collection, such as name, description, icons etc.
|
---|
[4932] | 49 | */
|
---|
[12093] | 50 | public class GeneralManager {
|
---|
| 51 |
|
---|
[4932] | 52 | /** The controls used to modify the general options. */
|
---|
| 53 | private Control controls;
|
---|
| 54 | /** Constructor. */
|
---|
| 55 | public GeneralManager() {
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | /** Destructor. */
|
---|
| 59 | public void destroy() {
|
---|
[12093] | 60 | if (controls != null) {
|
---|
| 61 | controls.destroy();
|
---|
| 62 | controls = null;
|
---|
| 63 | }
|
---|
[4932] | 64 | }
|
---|
| 65 |
|
---|
[12093] | 66 | public void loseFocus() {
|
---|
[4932] | 67 | }
|
---|
| 68 |
|
---|
| 69 | public void gainFocus() {
|
---|
| 70 |
|
---|
| 71 | }
|
---|
| 72 | /** This class is resposible for generating the controls for the editing of general options.
|
---|
| 73 | * @return the Control for editing the general options
|
---|
| 74 | */
|
---|
[12093] | 75 | public Control getControls() {
|
---|
| 76 | if (controls == null) {
|
---|
| 77 | controls = new GeneralControl();
|
---|
| 78 | }
|
---|
[4932] | 79 | return controls;
|
---|
| 80 | }
|
---|
[12093] | 81 |
|
---|
[4932] | 82 |
|
---|
[12093] | 83 | /** Called when the detail mode has changed which in turn may cause several design elements to be available/hidden
|
---|
| 84 | * @param mode the new mode as an int
|
---|
| 85 | */
|
---|
| 86 | public void modeChanged(int mode) {
|
---|
| 87 |
|
---|
| 88 | }
|
---|
| 89 |
|
---|
[4932] | 90 | /** This class represents the visual component of the general options stored in the CollectionDesignManager. */
|
---|
| 91 | private class GeneralControl
|
---|
[6051] | 92 | extends JPanel
|
---|
[4932] | 93 | implements Control {
|
---|
[6662] | 94 |
|
---|
[13453] | 95 | private boolean ready = false;
|
---|
[4932] | 96 | private CollectionMeta collection_extra_collectionmeta;
|
---|
| 97 | private CollectionMeta collection_name_collectionmeta;
|
---|
| 98 | private CollectionMeta creator_collectionmeta;
|
---|
| 99 | private CollectionMeta icon_collection_collectionmeta;
|
---|
| 100 | private CollectionMeta icon_collection_small_collectionmeta;
|
---|
| 101 | private CollectionMeta maintainer_collectionmeta;
|
---|
| 102 | private CollectionMeta public_collectionmeta;
|
---|
| 103 | /** The creators email. */
|
---|
| 104 | private EmailField creator_emailfield;
|
---|
| 105 | /** The maintainers email. */
|
---|
| 106 | private EmailField maintainer_emailfield;
|
---|
[6003] | 107 | /** Button to browse for the collection about page icon. */
|
---|
| 108 | private JButton browse_about_icon_button;
|
---|
| 109 | /** Button to browse for the collection home page icon. */
|
---|
| 110 | private JButton browse_home_icon_button;
|
---|
[4932] | 111 | /** The checkbox controlling public access to the collection. */
|
---|
| 112 | private JCheckBox public_checkbox;
|
---|
| 113 | private JLabel creator_label;
|
---|
| 114 | private JLabel description_label;
|
---|
| 115 | private JLabel icon_label;
|
---|
| 116 | private JLabel maintainer_label;
|
---|
| 117 | private JLabel name_label;
|
---|
| 118 | private JLabel small_icon_label;
|
---|
| 119 | /** The text field used to edit the file name of the collections icon. */
|
---|
| 120 | private JTextField icon_textfield;
|
---|
| 121 | /** The text field used to edit the collections title. */
|
---|
| 122 | private JTextField name_textfield;
|
---|
| 123 | /** The text field used to edit the file name of the collections small icon. */
|
---|
| 124 | private JTextField small_icon_textfield;
|
---|
| 125 | /** A text area used to modify the collection description. */
|
---|
| 126 | private JTextArea description_textarea;
|
---|
| 127 | /** Constructor. */
|
---|
| 128 | public GeneralControl() {
|
---|
| 129 | super();
|
---|
| 130 | // Retrieve some of the model elements, those we know aren't language dependant
|
---|
[5086] | 131 | public_collectionmeta = new CollectionMeta(CollectionDesignManager.collect_config.getPublic());
|
---|
[5529] | 132 |
|
---|
[4932] | 133 | // Creation
|
---|
[11031] | 134 | JPanel header_panel = new DesignPaneHeader("CDM.GUI.General", "generalsettings");
|
---|
[5529] | 135 |
|
---|
[4932] | 136 | JPanel all_details_panel = new JPanel();
|
---|
| 137 | JPanel details_panel = new JPanel();
|
---|
[6843] | 138 | JPanel fields_panel = new JPanel();
|
---|
| 139 |
|
---|
[12123] | 140 | creator_label = new JLabel(Dictionary.get("CDM.General.Email.Creator"));
|
---|
| 141 |
|
---|
[8231] | 142 | creator_emailfield = new EmailField(Configuration.getColor("coloring.error_background", false));
|
---|
[12123] | 143 | creator_emailfield.setToolTipText(Dictionary.get("CDM.General.Email.Creator_Tooltip"));
|
---|
| 144 |
|
---|
| 145 | maintainer_label = new JLabel(Dictionary.get("CDM.General.Email.Maintainer"));
|
---|
| 146 |
|
---|
[8231] | 147 | maintainer_emailfield = new EmailField(Configuration.getColor("coloring.error_background", false));
|
---|
[12123] | 148 | maintainer_emailfield.setToolTipText(Dictionary.get("CDM.General.Email.Maintainer_Tooltip"));
|
---|
| 149 |
|
---|
| 150 | name_label = new JLabel(Dictionary.get("CDM.General.Collection_Name"));
|
---|
| 151 | name_textfield = new JTextField();
|
---|
| 152 | name_textfield.setToolTipText(Dictionary.get("CDM.General.Collection_Name_Tooltip"));
|
---|
| 153 |
|
---|
| 154 | JLabel short_name_label = new JLabel(Dictionary.get("NewCollectionPrompt.Collection_Name"));
|
---|
[13586] | 155 | JTextField short_name_textfield = new JTextField(CollectionManager.getLoadedCollectionName());
|
---|
[6152] | 156 | short_name_textfield.setEditable(false);
|
---|
[8231] | 157 | short_name_textfield.setBackground(Configuration.getColor("coloring.collection_tree_background", false));
|
---|
[4932] | 158 | JPanel icon_panel = new JPanel();
|
---|
[12123] | 159 | icon_label = new JLabel(Dictionary.get("CDM.General.Icon_Collection"));
|
---|
| 160 | icon_textfield = new JTextField();
|
---|
| 161 | icon_textfield.setToolTipText(Dictionary.get("CDM.General.Icon_Collection_Tooltip"));
|
---|
| 162 | browse_about_icon_button = new GLIButton(Dictionary.get("General.Browse"));
|
---|
[4932] | 163 | JPanel small_icon_panel = new JPanel();
|
---|
[12123] | 164 | small_icon_label = new JLabel(Dictionary.get("CDM.General.Icon_Collection_Small"));
|
---|
| 165 | small_icon_textfield = new JTextField();
|
---|
| 166 | small_icon_textfield.setToolTipText(Dictionary.get("CDM.General.Icon_Collection_Small_Tooltip"));
|
---|
| 167 | browse_home_icon_button = new GLIButton(Dictionary.get("General.Browse"));
|
---|
[6843] | 168 |
|
---|
[10552] | 169 | // public
|
---|
[6843] | 170 | JPanel box_panel = new JPanel();
|
---|
[12641] | 171 | public_checkbox = new JCheckBox(Dictionary.get("CDM.General.Access"), public_collectionmeta.getValue(CollectionMeta.TEXT).equals(StaticStrings.TRUE_STR));
|
---|
[12123] | 172 |
|
---|
[4932] | 173 | JPanel description_panel = new JPanel();
|
---|
[12123] | 174 | description_label = new JLabel(Dictionary.get("CDM.General.Collection_Extra"));
|
---|
| 175 |
|
---|
[4932] | 176 | description_textarea = new JTextArea();
|
---|
[8231] | 177 | description_textarea.setBackground(Configuration.getColor("coloring.editable_background", false));
|
---|
[12123] | 178 | description_textarea.setToolTipText(Dictionary.get("CDM.General.Collection_Extra_Tooltip"));
|
---|
| 179 |
|
---|
[4932] | 180 | // Connection
|
---|
[6152] | 181 | BrowseListener browse_listener = new BrowseListener(StaticStrings.IMAGES_PATH_RELATIVE_TO_GSDL_PREFIX);
|
---|
| 182 | browse_about_icon_button.addActionListener(browse_listener);
|
---|
| 183 | browse_home_icon_button.addActionListener(browse_listener);
|
---|
| 184 | browse_listener = null;
|
---|
[4932] | 185 | public_checkbox.addActionListener(CollectionDesignManager.change_listener);
|
---|
| 186 | creator_emailfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener);
|
---|
| 187 | description_textarea.getDocument().addDocumentListener(CollectionDesignManager.change_listener);
|
---|
| 188 | icon_textfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener);
|
---|
| 189 | maintainer_emailfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener);
|
---|
| 190 | name_textfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener);
|
---|
[6152] | 191 | name_textfield.getDocument().addDocumentListener(new CollectionTitleUpdater());
|
---|
[4932] | 192 | small_icon_textfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener);
|
---|
[5529] | 193 |
|
---|
[4932] | 194 | // Layout
|
---|
[6843] | 195 | fields_panel.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
|
---|
| 196 | fields_panel.setLayout(new BorderLayout(5,2));
|
---|
| 197 |
|
---|
| 198 | JPanel fields_label_panel = new JPanel();
|
---|
| 199 | fields_label_panel.setLayout(new GridLayout(6,1));
|
---|
[4932] | 200 |
|
---|
[6843] | 201 | JPanel fields_box_panel = new JPanel();
|
---|
| 202 | fields_box_panel.setLayout(new GridLayout(6,1));
|
---|
| 203 |
|
---|
| 204 | // creator
|
---|
| 205 | fields_label_panel.add(creator_label);
|
---|
| 206 | fields_box_panel.add(creator_emailfield);
|
---|
[4932] | 207 |
|
---|
[6843] | 208 | // maintainer
|
---|
| 209 | fields_label_panel.add(maintainer_label);
|
---|
| 210 | fields_box_panel.add(maintainer_emailfield);
|
---|
[4932] | 211 |
|
---|
[6843] | 212 | // title
|
---|
| 213 | fields_label_panel.add(name_label);
|
---|
| 214 | fields_box_panel.add(name_textfield);
|
---|
[6152] | 215 |
|
---|
[6843] | 216 | // collection short name
|
---|
| 217 | fields_label_panel.add(short_name_label);
|
---|
| 218 | fields_box_panel.add(short_name_textfield);
|
---|
| 219 |
|
---|
| 220 | // icon
|
---|
| 221 | fields_label_panel.add(icon_label);
|
---|
| 222 | fields_box_panel.add(icon_panel);
|
---|
| 223 |
|
---|
| 224 | // small icon
|
---|
| 225 | fields_label_panel.add(small_icon_label);
|
---|
| 226 | fields_box_panel.add(small_icon_panel);
|
---|
| 227 |
|
---|
| 228 | fields_panel.add(fields_label_panel, BorderLayout.WEST);
|
---|
| 229 | fields_panel.add(fields_box_panel, BorderLayout.CENTER);
|
---|
| 230 |
|
---|
[4932] | 231 | icon_panel.setLayout(new BorderLayout());
|
---|
| 232 | icon_panel.add(icon_textfield, BorderLayout.CENTER);
|
---|
[6003] | 233 | icon_panel.add(browse_about_icon_button, BorderLayout.EAST);
|
---|
[4932] | 234 |
|
---|
| 235 | small_icon_panel.setLayout(new BorderLayout());
|
---|
| 236 | small_icon_panel.add(small_icon_textfield, BorderLayout.CENTER);
|
---|
[6003] | 237 | small_icon_panel.add(browse_home_icon_button, BorderLayout.EAST);
|
---|
[4932] | 238 |
|
---|
[7365] | 239 | box_panel.setLayout(new GridLayout(1,1,5,2));
|
---|
[6843] | 240 | box_panel.add(public_checkbox);
|
---|
[4932] | 241 |
|
---|
| 242 | description_panel.setLayout(new BorderLayout());
|
---|
| 243 | description_panel.add(description_label, BorderLayout.NORTH);
|
---|
| 244 | description_panel.add(new JScrollPane(description_textarea), BorderLayout.CENTER);
|
---|
[6843] | 245 |
|
---|
| 246 | details_panel.setLayout(new BorderLayout());
|
---|
| 247 | details_panel.add(fields_panel, BorderLayout.NORTH);
|
---|
| 248 | details_panel.add(box_panel, BorderLayout.CENTER);
|
---|
[4932] | 249 |
|
---|
| 250 | all_details_panel.setLayout(new BorderLayout());
|
---|
| 251 | all_details_panel.add(details_panel, BorderLayout.NORTH);
|
---|
| 252 | all_details_panel.add(description_panel, BorderLayout.CENTER);
|
---|
| 253 |
|
---|
[11038] | 254 | setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
|
---|
[4932] | 255 | setLayout(new BorderLayout());
|
---|
[11031] | 256 | add(header_panel, BorderLayout.NORTH);
|
---|
[4932] | 257 | add(all_details_panel, BorderLayout.CENTER);
|
---|
| 258 | }
|
---|
[5529] | 259 |
|
---|
[4932] | 260 | /** Destructor. */
|
---|
| 261 | public void destroy() {
|
---|
| 262 | }
|
---|
[5529] | 263 |
|
---|
[4932] | 264 | /** Called to refresh the components. */
|
---|
| 265 | public void gainFocus() {
|
---|
[13453] | 266 | // Retrieve all of the elements that are dependant on default language.
|
---|
[12641] | 267 | collection_extra_collectionmeta = CollectionDesignManager.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_COLLECTIONEXTRA_STR);
|
---|
| 268 | collection_name_collectionmeta = CollectionDesignManager.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_COLLECTIONNAME_STR);
|
---|
[10556] | 269 |
|
---|
[5086] | 270 | creator_collectionmeta = new CollectionMeta(CollectionDesignManager.collect_config.getCreator());
|
---|
[12641] | 271 | icon_collection_collectionmeta = CollectionDesignManager.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_ICONCOLLECTION_STR);
|
---|
| 272 | icon_collection_small_collectionmeta = CollectionDesignManager.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_ICONCOLLECTIONSMALL_STR);
|
---|
[5086] | 273 | maintainer_collectionmeta = new CollectionMeta(CollectionDesignManager.collect_config.getMaintainer());
|
---|
[4932] | 274 | // Make sure the components are up to date
|
---|
[5255] | 275 | creator_emailfield.setText(creator_collectionmeta.getValue(CollectionMeta.TEXT));
|
---|
[4932] | 276 | creator_emailfield.setCaretPosition(0);
|
---|
[5255] | 277 | description_textarea.setText(collection_extra_collectionmeta.getValue(CollectionMeta.TEXT));
|
---|
[4932] | 278 | description_textarea.setCaretPosition(0);
|
---|
[5255] | 279 | icon_textfield.setText(icon_collection_collectionmeta.getValue(CollectionMeta.TEXT));
|
---|
[4932] | 280 | icon_textfield.setCaretPosition(0);
|
---|
[5255] | 281 | maintainer_emailfield.setText(maintainer_collectionmeta.getValue(CollectionMeta.TEXT));
|
---|
[4932] | 282 | maintainer_emailfield.setCaretPosition(0);
|
---|
[5255] | 283 | name_textfield.setText(collection_name_collectionmeta.getValue(CollectionMeta.TEXT));
|
---|
[4932] | 284 | name_textfield.setCaretPosition(0);
|
---|
[5255] | 285 | small_icon_textfield.setText(icon_collection_small_collectionmeta.getValue(CollectionMeta.TEXT));
|
---|
[4932] | 286 | small_icon_textfield.setCaretPosition(0);
|
---|
[12641] | 287 | public_checkbox.setSelected(public_collectionmeta.getValue(CollectionMeta.TEXT).equals(StaticStrings.TRUE_STR));
|
---|
[13453] | 288 | ready = true;
|
---|
[4932] | 289 | }
|
---|
[6662] | 290 |
|
---|
[4932] | 291 | /** Called to store the current value of the components. */
|
---|
| 292 | public void loseFocus() {
|
---|
| 293 | // String values. Have to test if this component has actually ever recieved focus anyway.
|
---|
[13453] | 294 |
|
---|
| 295 | if (!ready) return;
|
---|
| 296 |
|
---|
| 297 | public_collectionmeta.setValue((public_checkbox.isSelected() ? StaticStrings.TRUE_STR : StaticStrings.FALSE_STR));
|
---|
| 298 | String creator_email_str = creator_emailfield.getText();
|
---|
| 299 | creator_collectionmeta.setValue(creator_email_str);
|
---|
[6636] | 300 | // If the email is currently empty, store this email
|
---|
[13453] | 301 | if(Configuration.getEmail() == null) {
|
---|
| 302 | Configuration.setEmail(creator_email_str); // Store the email address in the configuration
|
---|
| 303 | }
|
---|
| 304 | collection_extra_collectionmeta.setValue(description_textarea.getText());
|
---|
| 305 | icon_collection_collectionmeta.setValue(icon_textfield.getText());
|
---|
| 306 | maintainer_collectionmeta.setValue(maintainer_emailfield.getText());
|
---|
| 307 | icon_collection_small_collectionmeta.setValue(small_icon_textfield.getText());
|
---|
| 308 | collection_name_collectionmeta.setValue(name_textfield.getText());
|
---|
| 309 |
|
---|
| 310 |
|
---|
| 311 | }
|
---|
[11477] | 312 |
|
---|
[6003] | 313 | /** Listens for a click on either browse button, and when detected opens a file browser window initially pointed at the images folder of the collection. Once a user has selected a path, does it's best to construct the best address to the resource, such as _httpcollection_/images/about.gif */
|
---|
| 314 | private class BrowseListener
|
---|
| 315 | implements ActionListener {
|
---|
[6051] | 316 |
|
---|
[6088] | 317 | private String prefix;
|
---|
| 318 |
|
---|
[6152] | 319 | public BrowseListener(String prefix_raw) {
|
---|
[13586] | 320 | this.prefix = prefix_raw.replaceAll(StaticStrings.COLNAME_PATTERN, CollectionManager.getLoadedCollectionName());
|
---|
[6088] | 321 | }
|
---|
| 322 |
|
---|
[6003] | 323 | public void actionPerformed(ActionEvent event) {
|
---|
| 324 | // Open an almost standard file browser to the images folder of the current collection
|
---|
[13591] | 325 | File images_folder = new File(CollectionManager.getLoadedCollectionImagesDirectoryPath());
|
---|
[6003] | 326 | // If images isn't already there, create it
|
---|
| 327 | if(!images_folder.exists()) {
|
---|
| 328 | images_folder.mkdirs();
|
---|
| 329 | }
|
---|
| 330 | JFileChooser file_chooser = new JFileChooser(images_folder);
|
---|
| 331 | file_chooser.setAcceptAllFileFilterUsed(false);
|
---|
| 332 | file_chooser.setDialogTitle(Dictionary.get("CDM.General.Browser_Title"));
|
---|
| 333 | file_chooser.setFileFilter(new ImageFilter());
|
---|
| 334 | file_chooser.setSize(400,300);
|
---|
[12093] | 335 | GUIUtils.disableRename(file_chooser);
|
---|
[6003] | 336 | int value = file_chooser.showOpenDialog(Gatherer.g_man);
|
---|
| 337 | // If the user hasn't cancelled, retrieve the file path selected
|
---|
| 338 | if(value == JFileChooser.APPROVE_OPTION) {
|
---|
| 339 | // If the file isn't in the images folder, then ask the user if they want to copy it there
|
---|
| 340 | File file = file_chooser.getSelectedFile();
|
---|
[11049] | 341 | if (!file.getParentFile().equals(images_folder)) {
|
---|
| 342 | // Copy the file
|
---|
| 343 | try {
|
---|
| 344 | File collection_image_file = new File(images_folder, file.getName());
|
---|
[11491] | 345 | Gatherer.f_man.getQueue().copyFile(file, collection_image_file, true);
|
---|
[10374] | 346 |
|
---|
[11049] | 347 | // If we're using a remote Greenstone server, upload the image
|
---|
| 348 | if (Gatherer.isGsdlRemote) {
|
---|
[13586] | 349 | RemoteGreenstoneServer.uploadCollectionFile(CollectionManager.getLoadedCollectionName(), collection_image_file);
|
---|
[6003] | 350 | }
|
---|
| 351 | }
|
---|
[11049] | 352 | catch(Exception exception) {
|
---|
| 353 | DebugStream.printStackTrace(exception);
|
---|
| 354 | // Show warning
|
---|
[11477] | 355 | String[] args = new String[] {file.getAbsolutePath(), images_folder.getAbsolutePath()};
|
---|
| 356 | JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.General.Image_Copy_Failed", args), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
|
---|
[11049] | 357 | // Nothing else we can do.
|
---|
[6003] | 358 | return;
|
---|
| 359 | }
|
---|
| 360 | }
|
---|
[11049] | 361 |
|
---|
[6003] | 362 | // Create the path starting _httpcollection_/images/<filename>
|
---|
[6088] | 363 | String path = prefix + file.getName();
|
---|
[6003] | 364 | if(event.getSource() == browse_about_icon_button) {
|
---|
| 365 | icon_textfield.setText(path);
|
---|
[13453] | 366 | icon_collection_collectionmeta.setValue(icon_textfield.getText());
|
---|
[6003] | 367 | }
|
---|
| 368 | else {
|
---|
| 369 | small_icon_textfield.setText(path);
|
---|
[13453] | 370 | icon_collection_small_collectionmeta.setValue(small_icon_textfield.getText());
|
---|
[6003] | 371 | }
|
---|
| 372 | path = null;
|
---|
| 373 | }
|
---|
| 374 | }
|
---|
[6051] | 375 |
|
---|
[6003] | 376 | /** ImageFilter.java is a 1.4 example used by FileChooserDemo2.java. */
|
---|
[6051] | 377 | private class ImageFilter
|
---|
[6003] | 378 | extends javax.swing.filechooser.FileFilter {
|
---|
[6051] | 379 |
|
---|
[6003] | 380 | private Pattern pattern = null;
|
---|
[6051] | 381 |
|
---|
[6003] | 382 | public ImageFilter() {
|
---|
| 383 | pattern = Pattern.compile(".*\\.(gif|png|jpe?g)");
|
---|
| 384 | }
|
---|
[6051] | 385 |
|
---|
[6003] | 386 | // Accept all directories and all .col files
|
---|
| 387 | public boolean accept(File f) {
|
---|
| 388 | String filename = f.getName().toLowerCase();
|
---|
| 389 | Matcher matcher = pattern.matcher(filename);
|
---|
| 390 | return f.isDirectory() || matcher.matches();
|
---|
| 391 | }
|
---|
[6051] | 392 |
|
---|
[6003] | 393 | // The description of this filter
|
---|
| 394 | public String getDescription() {
|
---|
| 395 | return Dictionary.get("CDM.General.Image_Filter");
|
---|
| 396 | }
|
---|
| 397 | }
|
---|
| 398 | }
|
---|
[6152] | 399 |
|
---|
| 400 | private class CollectionTitleUpdater
|
---|
| 401 | implements DocumentListener {
|
---|
| 402 | /** Gives notification that an attribute or set of attributes changed. */
|
---|
| 403 | public void changedUpdate(DocumentEvent e) {
|
---|
| 404 | setTitle();
|
---|
| 405 | }
|
---|
| 406 | /** Gives notification that there was an insert into the document. */
|
---|
| 407 | public void insertUpdate(DocumentEvent e) {
|
---|
| 408 | setTitle();
|
---|
| 409 | }
|
---|
| 410 | /** Gives notification that a portion of the document has been removed. */
|
---|
| 411 | public void removeUpdate(DocumentEvent e) {
|
---|
| 412 | setTitle();
|
---|
| 413 | }
|
---|
| 414 |
|
---|
| 415 | private void setTitle() {
|
---|
| 416 | // Set the title
|
---|
| 417 | String collection_title = name_textfield.getText();
|
---|
[13586] | 418 | String collection_name = CollectionManager.getLoadedCollectionName();
|
---|
[6152] | 419 | Gatherer.g_man.setTitle(collection_title, collection_name);
|
---|
[13453] | 420 | collection_name_collectionmeta.setValue(name_textfield.getText());
|
---|
[6152] | 421 | collection_title = null;
|
---|
| 422 | collection_name = null;
|
---|
| 423 | }
|
---|
| 424 | }
|
---|
[4932] | 425 | }
|
---|
| 426 | }
|
---|