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;
|
---|
28 |
|
---|
29 | import java.awt.*;
|
---|
30 | import java.awt.event.*;
|
---|
31 | import java.io.*;
|
---|
32 | import java.util.regex.*;
|
---|
33 | import javax.swing.*;
|
---|
34 | import javax.swing.filechooser.*;
|
---|
35 | import javax.swing.event.*;
|
---|
36 | import org.greenstone.gatherer.Configuration;
|
---|
37 | import org.greenstone.gatherer.DebugStream;
|
---|
38 | import org.greenstone.gatherer.Dictionary;
|
---|
39 | import org.greenstone.gatherer.Gatherer;
|
---|
40 | import org.greenstone.gatherer.collection.CollectionManager;
|
---|
41 | import org.greenstone.gatherer.gui.DesignPaneHeader;
|
---|
42 | import org.greenstone.gatherer.gui.EmailField;
|
---|
43 | import org.greenstone.gatherer.gui.GLIButton;
|
---|
44 | import org.greenstone.gatherer.gui.GUIUtils;
|
---|
45 | import org.greenstone.gatherer.remote.RemoteGreenstoneServer;
|
---|
46 | import org.greenstone.gatherer.util.StaticStrings;
|
---|
47 | import org.greenstone.gatherer.Gatherer;
|
---|
48 |
|
---|
49 | /** This class provides a graphical interface for editing general metadata for the collection, such as name, description, icons etc.
|
---|
50 | */
|
---|
51 | public class GeneralManager {
|
---|
52 |
|
---|
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() {
|
---|
61 | if (controls != null) {
|
---|
62 | controls.destroy();
|
---|
63 | controls = null;
|
---|
64 | }
|
---|
65 | }
|
---|
66 |
|
---|
67 | public void loseFocus() {
|
---|
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 | */
|
---|
76 | public Control getControls() {
|
---|
77 | if (controls == null) {
|
---|
78 | controls = new GeneralControl();
|
---|
79 | }
|
---|
80 | return controls;
|
---|
81 | }
|
---|
82 |
|
---|
83 |
|
---|
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 |
|
---|
91 | /** This class represents the visual component of the general options stored in the CollectionDesignManager. */
|
---|
92 | private class GeneralControl
|
---|
93 | extends JPanel
|
---|
94 | implements Control {
|
---|
95 |
|
---|
96 | private boolean ready = false;
|
---|
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;
|
---|
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;
|
---|
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 | this.setComponentOrientation(Dictionary.getOrientation());
|
---|
132 | // Retrieve some of the model elements, those we know aren't language dependant
|
---|
133 | public_collectionmeta = new CollectionMeta(CollectionDesignManager.collect_config.getPublic());
|
---|
134 |
|
---|
135 | // Creation
|
---|
136 | JPanel header_panel = new DesignPaneHeader("CDM.GUI.General", "generalsettings");
|
---|
137 |
|
---|
138 | JPanel all_details_panel = new JPanel();
|
---|
139 | JPanel details_panel = new JPanel();
|
---|
140 | JPanel fields_panel = new JPanel();
|
---|
141 |
|
---|
142 | all_details_panel.setComponentOrientation(Dictionary.getOrientation());
|
---|
143 | details_panel.setComponentOrientation(Dictionary.getOrientation());
|
---|
144 | fields_panel.setComponentOrientation(Dictionary.getOrientation());
|
---|
145 |
|
---|
146 | creator_label = new JLabel(Dictionary.get("CDM.General.Email.Creator"));
|
---|
147 | creator_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
148 |
|
---|
149 | creator_emailfield = new EmailField(Configuration.getColor("coloring.error_background", false));
|
---|
150 | creator_emailfield.setToolTipText(Dictionary.get("CDM.General.Email.Creator_Tooltip"));
|
---|
151 |
|
---|
152 | maintainer_label = new JLabel(Dictionary.get("CDM.General.Email.Maintainer"));
|
---|
153 | maintainer_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
154 |
|
---|
155 | maintainer_emailfield = new EmailField(Configuration.getColor("coloring.error_background", false));
|
---|
156 | maintainer_emailfield.setToolTipText(Dictionary.get("CDM.General.Email.Maintainer_Tooltip"));
|
---|
157 |
|
---|
158 | name_label = new JLabel(Dictionary.get("CDM.General.Collection_Name"));
|
---|
159 | name_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
160 | name_textfield = new JTextField();
|
---|
161 | name_textfield.setComponentOrientation(Dictionary.getOrientation());
|
---|
162 | name_textfield.setToolTipText(Dictionary.get("CDM.General.Collection_Name_Tooltip"));
|
---|
163 |
|
---|
164 | JLabel short_name_label = new JLabel(Dictionary.get("NewCollectionPrompt.Collection_Name"));
|
---|
165 | short_name_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
166 | JTextField short_name_textfield = new JTextField(CollectionManager.getLoadedCollectionName());
|
---|
167 | short_name_textfield.setComponentOrientation(Dictionary.getOrientation());
|
---|
168 | short_name_textfield.setEditable(false);
|
---|
169 | short_name_textfield.setBackground(Configuration.getColor("coloring.collection_tree_background", false));
|
---|
170 | JPanel icon_panel = new JPanel();
|
---|
171 | icon_panel.setComponentOrientation(Dictionary.getOrientation());
|
---|
172 | icon_label = new JLabel(Dictionary.get("CDM.General.Icon_Collection"));
|
---|
173 | icon_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
174 | icon_textfield = new JTextField();
|
---|
175 | icon_textfield.setComponentOrientation(Dictionary.getOrientation());
|
---|
176 | icon_textfield.setToolTipText(Dictionary.get("CDM.General.Icon_Collection_Tooltip"));
|
---|
177 | browse_about_icon_button = new GLIButton(Dictionary.get("General.Browse"));
|
---|
178 | JPanel small_icon_panel = new JPanel();
|
---|
179 | small_icon_panel.setComponentOrientation(Dictionary.getOrientation());
|
---|
180 | small_icon_label = new JLabel(Dictionary.get("CDM.General.Icon_Collection_Small"));
|
---|
181 | small_icon_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
182 | small_icon_textfield = new JTextField();
|
---|
183 | small_icon_textfield.setComponentOrientation(Dictionary.getOrientation());
|
---|
184 | small_icon_textfield.setToolTipText(Dictionary.get("CDM.General.Icon_Collection_Small_Tooltip"));
|
---|
185 | browse_home_icon_button = new GLIButton(Dictionary.get("General.Browse"));
|
---|
186 |
|
---|
187 | // public
|
---|
188 | JPanel box_panel = new JPanel();
|
---|
189 | box_panel.setComponentOrientation(Dictionary.getOrientation());
|
---|
190 | public_checkbox = new JCheckBox(Dictionary.get("CDM.General.Access"), public_collectionmeta.getValue(CollectionMeta.TEXT).equals(StaticStrings.TRUE_STR));
|
---|
191 | public_checkbox.setComponentOrientation(Dictionary.getOrientation());
|
---|
192 |
|
---|
193 | JPanel description_panel = new JPanel();
|
---|
194 | description_panel.setComponentOrientation(Dictionary.getOrientation());
|
---|
195 | description_label = new JLabel(Dictionary.get("CDM.General.Collection_Extra"));
|
---|
196 | description_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
197 |
|
---|
198 | description_textarea = new JTextArea();
|
---|
199 | description_textarea.setComponentOrientation(Dictionary.getOrientation());
|
---|
200 | description_textarea.setBackground(Configuration.getColor("coloring.editable_background", false));
|
---|
201 | description_textarea.setToolTipText(Dictionary.get("CDM.General.Collection_Extra_Tooltip"));
|
---|
202 |
|
---|
203 | // Connection
|
---|
204 | BrowseListener browse_listener = new BrowseListener(StaticStrings.IMAGES_PATH_RELATIVE_TO_GSDL_PREFIX);
|
---|
205 | browse_about_icon_button.addActionListener(browse_listener);
|
---|
206 | browse_home_icon_button.addActionListener(browse_listener);
|
---|
207 | browse_listener = null;
|
---|
208 | public_checkbox.addActionListener(CollectionDesignManager.change_listener);
|
---|
209 | creator_emailfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener);
|
---|
210 | description_textarea.getDocument().addDocumentListener(CollectionDesignManager.change_listener);
|
---|
211 | icon_textfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener);
|
---|
212 | maintainer_emailfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener);
|
---|
213 | name_textfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener);
|
---|
214 | name_textfield.getDocument().addDocumentListener(new CollectionTitleUpdater());
|
---|
215 | small_icon_textfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener);
|
---|
216 |
|
---|
217 | // Layout
|
---|
218 | fields_panel.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
|
---|
219 | fields_panel.setLayout(new BorderLayout(5,2));
|
---|
220 |
|
---|
221 | JPanel fields_label_panel = new JPanel();
|
---|
222 | fields_label_panel.setComponentOrientation(Dictionary.getOrientation());
|
---|
223 | fields_label_panel.setLayout(new GridLayout(6,1));
|
---|
224 |
|
---|
225 | JPanel fields_box_panel = new JPanel();
|
---|
226 | fields_box_panel.setComponentOrientation(Dictionary.getOrientation());
|
---|
227 | fields_box_panel.setLayout(new GridLayout(6,1));
|
---|
228 |
|
---|
229 | // creator
|
---|
230 | fields_label_panel.add(creator_label);
|
---|
231 | fields_box_panel.add(creator_emailfield);
|
---|
232 |
|
---|
233 | // maintainer
|
---|
234 | fields_label_panel.add(maintainer_label);
|
---|
235 | fields_box_panel.add(maintainer_emailfield);
|
---|
236 |
|
---|
237 | // title
|
---|
238 | fields_label_panel.add(name_label);
|
---|
239 | fields_box_panel.add(name_textfield);
|
---|
240 |
|
---|
241 | // collection short name
|
---|
242 | fields_label_panel.add(short_name_label);
|
---|
243 | fields_box_panel.add(short_name_textfield);
|
---|
244 |
|
---|
245 | // icon
|
---|
246 | fields_label_panel.add(icon_label);
|
---|
247 | fields_box_panel.add(icon_panel);
|
---|
248 |
|
---|
249 | // small icon
|
---|
250 | fields_label_panel.add(small_icon_label);
|
---|
251 | fields_box_panel.add(small_icon_panel);
|
---|
252 |
|
---|
253 | fields_panel.add(fields_label_panel, BorderLayout.LINE_START);
|
---|
254 | fields_panel.add(fields_box_panel, BorderLayout.CENTER);
|
---|
255 |
|
---|
256 | icon_panel.setLayout(new BorderLayout());
|
---|
257 | icon_panel.add(icon_textfield, BorderLayout.CENTER);
|
---|
258 | icon_panel.add(browse_about_icon_button, BorderLayout.LINE_END);
|
---|
259 |
|
---|
260 | small_icon_panel.setLayout(new BorderLayout());
|
---|
261 | small_icon_panel.add(small_icon_textfield, BorderLayout.CENTER);
|
---|
262 | small_icon_panel.add(browse_home_icon_button, BorderLayout.LINE_END);
|
---|
263 |
|
---|
264 | box_panel.setLayout(new GridLayout(1,1,5,2));
|
---|
265 | box_panel.add(public_checkbox);
|
---|
266 |
|
---|
267 | description_panel.setLayout(new BorderLayout());
|
---|
268 | description_panel.add(description_label, BorderLayout.NORTH);
|
---|
269 | description_panel.add(new JScrollPane(description_textarea), BorderLayout.CENTER);
|
---|
270 |
|
---|
271 | details_panel.setLayout(new BorderLayout());
|
---|
272 | details_panel.add(fields_panel, BorderLayout.NORTH);
|
---|
273 | details_panel.add(box_panel, BorderLayout.CENTER);
|
---|
274 |
|
---|
275 | all_details_panel.setLayout(new BorderLayout());
|
---|
276 | all_details_panel.add(details_panel, BorderLayout.NORTH);
|
---|
277 | all_details_panel.add(description_panel, BorderLayout.CENTER);
|
---|
278 |
|
---|
279 | setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
|
---|
280 | setLayout(new BorderLayout());
|
---|
281 | add(header_panel, BorderLayout.NORTH);
|
---|
282 | add(all_details_panel, BorderLayout.CENTER);
|
---|
283 | }
|
---|
284 |
|
---|
285 | /** Destructor. */
|
---|
286 | public void destroy() {
|
---|
287 | }
|
---|
288 |
|
---|
289 | /** Called to refresh the components. */
|
---|
290 | public void gainFocus() {
|
---|
291 | // Retrieve all of the elements that are dependant on default language.
|
---|
292 | collection_extra_collectionmeta = CollectionDesignManager.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_COLLECTIONEXTRA_STR);
|
---|
293 | collection_name_collectionmeta = CollectionDesignManager.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_COLLECTIONNAME_STR);
|
---|
294 |
|
---|
295 | creator_collectionmeta = new CollectionMeta(CollectionDesignManager.collect_config.getCreator());
|
---|
296 | icon_collection_collectionmeta = CollectionDesignManager.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_ICONCOLLECTION_STR);
|
---|
297 | icon_collection_small_collectionmeta = CollectionDesignManager.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_ICONCOLLECTIONSMALL_STR);
|
---|
298 | maintainer_collectionmeta = new CollectionMeta(CollectionDesignManager.collect_config.getMaintainer());
|
---|
299 | // Make sure the components are up to date
|
---|
300 | creator_emailfield.setText(creator_collectionmeta.getValue(CollectionMeta.TEXT));
|
---|
301 | creator_emailfield.setCaretPosition(0);
|
---|
302 | description_textarea.setText(collection_extra_collectionmeta.getValue(CollectionMeta.TEXT));
|
---|
303 | description_textarea.setCaretPosition(0);
|
---|
304 | icon_textfield.setText(icon_collection_collectionmeta.getValue(CollectionMeta.TEXT));
|
---|
305 | icon_textfield.setCaretPosition(0);
|
---|
306 | maintainer_emailfield.setText(maintainer_collectionmeta.getValue(CollectionMeta.TEXT));
|
---|
307 | maintainer_emailfield.setCaretPosition(0);
|
---|
308 | name_textfield.setText(collection_name_collectionmeta.getValue(CollectionMeta.TEXT));
|
---|
309 | name_textfield.setCaretPosition(0);
|
---|
310 | small_icon_textfield.setText(icon_collection_small_collectionmeta.getValue(CollectionMeta.TEXT));
|
---|
311 | small_icon_textfield.setCaretPosition(0);
|
---|
312 | public_checkbox.setSelected(public_collectionmeta.getValue(CollectionMeta.TEXT).equals(StaticStrings.TRUE_STR));
|
---|
313 | ready = true;
|
---|
314 | }
|
---|
315 |
|
---|
316 | /** Called to store the current value of the components. */
|
---|
317 | public void loseFocus() {
|
---|
318 | // String values. Have to test if this component has actually ever recieved focus anyway.
|
---|
319 |
|
---|
320 | if (!ready) return;
|
---|
321 |
|
---|
322 | boolean preserveTags = true; // for coll description, allow HTML tags to be saved as HTML tags
|
---|
323 | public_collectionmeta.setValue((public_checkbox.isSelected() ? StaticStrings.TRUE_STR : StaticStrings.FALSE_STR));
|
---|
324 | String creator_email_str = creator_emailfield.getText();
|
---|
325 | creator_collectionmeta.setValue(creator_email_str);
|
---|
326 | collection_extra_collectionmeta.setValue(description_textarea.getText(), preserveTags);
|
---|
327 | icon_collection_collectionmeta.setValue(icon_textfield.getText());
|
---|
328 | maintainer_collectionmeta.setValue(maintainer_emailfield.getText());
|
---|
329 | icon_collection_small_collectionmeta.setValue(small_icon_textfield.getText());
|
---|
330 | collection_name_collectionmeta.setValue(name_textfield.getText());
|
---|
331 |
|
---|
332 | }
|
---|
333 |
|
---|
334 | /** 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 */
|
---|
335 | private class BrowseListener
|
---|
336 | implements ActionListener {
|
---|
337 |
|
---|
338 | private String prefix;
|
---|
339 |
|
---|
340 | public BrowseListener(String prefix_raw) {
|
---|
341 | this.prefix = prefix_raw.replaceAll(StaticStrings.COLNAME_PATTERN, CollectionManager.getLoadedCollectionName());
|
---|
342 | }
|
---|
343 |
|
---|
344 | public void actionPerformed(ActionEvent event) {
|
---|
345 | // Open an almost standard file browser to the images folder of the current collection
|
---|
346 | File images_folder = new File(CollectionManager.getLoadedCollectionImagesDirectoryPath());
|
---|
347 | // If images isn't already there, create it
|
---|
348 | if(!images_folder.exists()) {
|
---|
349 | images_folder.mkdirs();
|
---|
350 | }
|
---|
351 | JFileChooser file_chooser = new JFileChooser(images_folder);
|
---|
352 | file_chooser.setAcceptAllFileFilterUsed(false);
|
---|
353 | file_chooser.setDialogTitle(Dictionary.get("CDM.General.Browser_Title"));
|
---|
354 | file_chooser.setFileFilter(new ImageFilter());
|
---|
355 | file_chooser.setSize(400,300);
|
---|
356 | GUIUtils.disableRename(file_chooser);
|
---|
357 | int value = file_chooser.showOpenDialog(Gatherer.g_man);
|
---|
358 | // If the user hasn't cancelled, retrieve the file path selected
|
---|
359 | if(value == JFileChooser.APPROVE_OPTION) {
|
---|
360 | // If the file isn't in the images folder, then ask the user if they want to copy it there
|
---|
361 | File file = file_chooser.getSelectedFile();
|
---|
362 | if (!file.getParentFile().equals(images_folder)) {
|
---|
363 | // Copy the file
|
---|
364 | try {
|
---|
365 | File collection_image_file = new File(images_folder, file.getName());
|
---|
366 | Gatherer.f_man.getQueue().copyFile(file, collection_image_file, true);
|
---|
367 |
|
---|
368 | // If we're using a remote Greenstone server, upload the image
|
---|
369 | if (Gatherer.isGsdlRemote) {
|
---|
370 | Gatherer.remoteGreenstoneServer.uploadCollectionFile(
|
---|
371 | CollectionManager.getLoadedCollectionName(), collection_image_file);
|
---|
372 | }
|
---|
373 | }
|
---|
374 | catch(Exception exception) {
|
---|
375 | DebugStream.printStackTrace(exception);
|
---|
376 | // Show warning
|
---|
377 | String[] args = new String[] {file.getAbsolutePath(), images_folder.getAbsolutePath()};
|
---|
378 | JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.General.Image_Copy_Failed", args), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
|
---|
379 | // Nothing else we can do.
|
---|
380 | return;
|
---|
381 | }
|
---|
382 | }
|
---|
383 |
|
---|
384 | // Create the path starting _httpcollection_/images/<filename>
|
---|
385 | String path = prefix + file.getName();
|
---|
386 | if (Gatherer.GS3){
|
---|
387 | path = file.getName();
|
---|
388 | }
|
---|
389 | if(event.getSource() == browse_about_icon_button) {
|
---|
390 | icon_textfield.setText(path);
|
---|
391 | icon_collection_collectionmeta.setValue(icon_textfield.getText());
|
---|
392 | }
|
---|
393 | else {
|
---|
394 | small_icon_textfield.setText(path);
|
---|
395 | icon_collection_small_collectionmeta.setValue(small_icon_textfield.getText());
|
---|
396 | }
|
---|
397 | path = null;
|
---|
398 | }
|
---|
399 | }
|
---|
400 |
|
---|
401 | /** ImageFilter.java is a 1.4 example used by FileChooserDemo2.java. */
|
---|
402 | private class ImageFilter
|
---|
403 | extends javax.swing.filechooser.FileFilter {
|
---|
404 |
|
---|
405 | private Pattern pattern = null;
|
---|
406 |
|
---|
407 | public ImageFilter() {
|
---|
408 | pattern = Pattern.compile(".*\\.(gif|png|jpe?g)");
|
---|
409 | }
|
---|
410 |
|
---|
411 | // Accept all directories and all .col files
|
---|
412 | public boolean accept(File f) {
|
---|
413 | String filename = f.getName().toLowerCase();
|
---|
414 | Matcher matcher = pattern.matcher(filename);
|
---|
415 | return f.isDirectory() || matcher.matches();
|
---|
416 | }
|
---|
417 |
|
---|
418 | // The description of this filter
|
---|
419 | public String getDescription() {
|
---|
420 | return Dictionary.get("CDM.General.Image_Filter");
|
---|
421 | }
|
---|
422 | }
|
---|
423 | }
|
---|
424 |
|
---|
425 | private class CollectionTitleUpdater
|
---|
426 | implements DocumentListener {
|
---|
427 | /** Gives notification that an attribute or set of attributes changed. */
|
---|
428 | public void changedUpdate(DocumentEvent e) {
|
---|
429 | setTitle();
|
---|
430 | }
|
---|
431 | /** Gives notification that there was an insert into the document. */
|
---|
432 | public void insertUpdate(DocumentEvent e) {
|
---|
433 | setTitle();
|
---|
434 | }
|
---|
435 | /** Gives notification that a portion of the document has been removed. */
|
---|
436 | public void removeUpdate(DocumentEvent e) {
|
---|
437 | setTitle();
|
---|
438 | }
|
---|
439 |
|
---|
440 | private void setTitle() {
|
---|
441 | // Set the title
|
---|
442 | String collection_title = name_textfield.getText();
|
---|
443 | String collection_name = CollectionManager.getLoadedCollectionName(true);
|
---|
444 | Gatherer.g_man.setTitle(collection_title, collection_name);
|
---|
445 | collection_name_collectionmeta.setValue(collection_title);
|
---|
446 | collection_title = null;
|
---|
447 | collection_name = null;
|
---|
448 | }
|
---|
449 | }
|
---|
450 | }
|
---|
451 | }
|
---|