source: trunk/gli/src/org/greenstone/gatherer/gui/RenamePrompt.java@ 11246

Last change on this file since 11246 was 11246, checked in by mdewsnip, 18 years ago

User interface for the new ability to rename files in the collection tree. Note that extracted metadata will not be displayed for renamed files (until the collection is rebuilt) -- this is fair because some of this metadata (eg. Source) will be incorrect anyway.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1/**
2 *############################################################################
3 * A component of the Greenstone Librarian Interface, part of the Greenstone
4 * digital library suite from the New Zealand Digital Library Project at the
5 * University of Waikato, New Zealand.
6 *
7 * Author: Michael Dewsnip, NZDL Project, University of Waikato, NZ
8 *
9 * Copyright (C) 2006 New Zealand Digital Library Project
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *############################################################################
25 */
26package org.greenstone.gatherer.gui;
27
28import java.awt.*;
29import java.awt.event.*;
30import java.io.*;
31import javax.swing.*;
32import org.greenstone.gatherer.Dictionary;
33import org.greenstone.gatherer.Gatherer;
34import org.greenstone.gatherer.collection.CollectionTreeNode;
35
36
37public class RenamePrompt
38 extends JDialog
39 implements ActionListener
40{
41 private JButton cancel_button;
42 private JButton ok_button;
43 private JTextField name_textfield;
44 private String name;
45
46 static final private Dimension SIZE = new Dimension(350, 80);
47
48
49 public RenamePrompt(CollectionTreeNode collection_tree_node)
50 {
51 super(Gatherer.g_man, true);
52 setTitle(Dictionary.get("RenamePrompt.Title"));
53 name = collection_tree_node.getFile().getName();
54 }
55
56
57 public void actionPerformed(ActionEvent event)
58 {
59 if (event.getSource() == ok_button) {
60 name = name_textfield.getText();
61 }
62 else if (event.getSource() == cancel_button) {
63 name = null;
64 }
65 dispose();
66 }
67
68
69 public String display()
70 {
71 setSize(SIZE);
72 JPanel content_pane = (JPanel) getContentPane();
73
74 JPanel info_pane = new JPanel();
75
76 JLabel name_label = new JLabel();
77 Dictionary.setText(name_label, "RenamePrompt.Name");
78 name_textfield = new JTextField(name);
79
80 JPanel button_pane = new JPanel();
81 ok_button = new GLIButton();
82 ok_button.setMnemonic(KeyEvent.VK_O);
83 Dictionary.setBoth(ok_button, "General.OK", "General.OK_Tooltip");
84 cancel_button = new GLIButton();
85 cancel_button.setMnemonic(KeyEvent.VK_C);
86 Dictionary.setBoth(cancel_button, "General.Cancel", "General.Pure_Cancel_Tooltip");
87
88 // Connection
89 cancel_button.addActionListener(this);
90 ok_button.addActionListener(this);
91
92 // Layout
93 info_pane.setLayout(new BorderLayout(5,0));
94 info_pane.add(name_label, BorderLayout.WEST);
95 info_pane.add(name_textfield, BorderLayout.CENTER);
96
97 button_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
98 button_pane.setLayout(new GridLayout(1,2,0,5));
99 button_pane.add(ok_button);
100 button_pane.add(cancel_button);
101
102 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
103 content_pane.setLayout(new BorderLayout());
104 content_pane.add(info_pane, BorderLayout.CENTER);
105 content_pane.add(button_pane, BorderLayout.SOUTH);
106
107 // Display
108 Rectangle frame_bounds = Gatherer.g_man.getBounds();
109 setLocation(frame_bounds.x + (frame_bounds.width - SIZE.width) / 2, frame_bounds.y + (frame_bounds.height - SIZE.height) / 2);
110 setVisible(true);
111 return name;
112 }
113}
Note: See TracBrowser for help on using the repository browser.