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