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

Last change on this file since 12592 was 12119, checked in by kjdon, 18 years ago

Changed text handling to use Dictionary.get rather than Dictionary.setText or Dictionary.registerBoth etc. also removed mnemonics cos they suck for other languages

  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 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, 100);
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(Dictionary.get("RenamePrompt.Name"));
77 name_textfield = new JTextField(name);
78
79 JPanel button_pane = new JPanel();
80 ok_button = new GLIButton(Dictionary.get("General.OK"), Dictionary.get("General.OK_Tooltip"));
81 cancel_button = new GLIButton(Dictionary.get("General.Cancel"), Dictionary.get("General.Pure_Cancel_Tooltip"));
82
83 // Connection
84 cancel_button.addActionListener(this);
85 ok_button.addActionListener(this);
86
87 // Layout
88 info_pane.setLayout(new BorderLayout(5,0));
89 info_pane.add(name_label, BorderLayout.WEST);
90 info_pane.add(name_textfield, BorderLayout.CENTER);
91
92 button_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
93 button_pane.setLayout(new GridLayout(1,2,0,5));
94 button_pane.add(ok_button);
95 button_pane.add(cancel_button);
96
97 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
98 content_pane.setLayout(new BorderLayout());
99 content_pane.add(info_pane, BorderLayout.CENTER);
100 content_pane.add(button_pane, BorderLayout.SOUTH);
101
102 // Display
103 Rectangle frame_bounds = Gatherer.g_man.getBounds();
104 setLocation(frame_bounds.x + (frame_bounds.width - SIZE.width) / 2, frame_bounds.y + (frame_bounds.height - SIZE.height) / 2);
105 setVisible(true);
106 return name;
107 }
108}
Note: See TracBrowser for help on using the repository browser.