source: trunk/gli/src/org/greenstone/gatherer/gui/ExternalCollectionPrompt.java@ 7183

Last change on this file since 7183 was 6318, checked in by jmt12, 20 years ago

Changed JButtons for GLIButtons, which know whether they should paint their background depending on what platform they are run on, and finished keyboard shortcuts

  • Property svn:keywords set to Author Date Id Revision
File size: 6.4 KB
Line 
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 * <BR><BR>
9 *
10 * Author: John Thompson, Greenstone Project, NZDL, University of Waikato
11 *
12 * <BR><BR>
13 *
14 * Copyright (C) 2003 New Zealand Digital Library Project
15 *
16 * <BR><BR>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * <BR><BR>
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * <BR><BR>
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 *########################################################################
36 */
37package org.greenstone.gatherer.gui;
38
39import java.awt.*;
40import java.awt.event.*;
41import java.io.*;
42import java.util.*;
43import javax.swing.*;
44import javax.swing.event.*;
45import org.greenstone.gatherer.Dictionary;
46import org.greenstone.gatherer.Gatherer;
47import org.greenstone.gatherer.checklist.CheckList;
48import org.greenstone.gatherer.checklist.Entry;
49import org.greenstone.gatherer.gui.GLIButton;
50import org.greenstone.gatherer.gui.SimpleMenuBar;
51import org.greenstone.gatherer.gui.ModalDialog;
52import org.greenstone.gatherer.cdm.ElementWrapper;
53import org.greenstone.gatherer.msm.MetadataSet;
54import org.greenstone.gatherer.util.StaticStrings;
55import org.greenstone.gatherer.util.Utility;
56import org.w3c.dom.*;
57
58// this has been changed to not offer the choice of a new metadata set, cos I haven't made this work properly.
59/** Prompt used when opening a non-gatherer built collection. We tell the user that they need to select metadata sets, and (in future) give them a choice between selecting an existing set or creating a new one */
60public class ExternalCollectionPrompt
61 extends ModalDialog {
62
63 public static int ERROR = 0;
64 public static int NEW_META_SET = 1;
65 public static int EXISTING_META_SET = 2;
66
67 private boolean cancelled = true;
68 private JDialog self;
69 private JRadioButton new_mds_button;
70 private JRadioButton existing_mds_button;
71
72
73 static private Dimension size = new Dimension(600, 250);
74
75 public ExternalCollectionPrompt() {
76 super(Gatherer.g_man, true);
77 this.self = this;
78 setJMenuBar(new SimpleMenuBar("loadinganexternalcollection"));
79 setModal(true);
80 setSize(size);
81 Dictionary.setText(this, "ExternalCollectionPrompt.Title");
82
83 // Creation
84 JPanel content_pane = (JPanel) getContentPane();
85 JPanel center_pane = new JPanel();
86
87 JPanel instructions_panel = new JPanel();
88 JTextArea instructions_textarea;
89 instructions_textarea = new JTextArea();
90 instructions_textarea.setCaretPosition(0);
91 instructions_textarea.setEditable(false);
92 instructions_textarea.setLineWrap(true);
93 instructions_textarea.setRows(6);
94 instructions_textarea.setWrapStyleWord(true);
95 Dictionary.registerText(instructions_textarea, "ExternalCollectionPrompt.Instructions_1"); // change to instructions_2 when add the other choice back in
96
97 /* new_mds_button = new JRadioButton();
98 new_mds_button.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
99 //new_mds_button.setMnemonic(KeyEvent.VK_I);
100 new_mds_button.setOpaque(false);
101 Dictionary.registerText(new_mds_button, "ExternalCollectionPrompt.NewMDS");
102 existing_mds_button = new JRadioButton();
103 existing_mds_button.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
104 //existing_mds_button.setMnemonic(KeyEvent.VK_X);
105 existing_mds_button.setOpaque(false);
106 Dictionary.registerText(existing_mds_button, "ExternalCollectionPrompt.ExistingMDS");
107
108 ButtonGroup bg = new ButtonGroup();
109 bg.add(new_mds_button);
110 bg.add(existing_mds_button);
111 new_mds_button.setSelected(true);
112
113 JPanel selection_pane = new JPanel();
114 selection_pane.setLayout(new GridLayout(2,1));
115 selection_pane.add(new_mds_button);
116 selection_pane.add(existing_mds_button);
117 */
118 JPanel button_pane = new JPanel();
119 JButton ok_button = new GLIButton();
120 ok_button.setMnemonic(KeyEvent.VK_O);
121 Dictionary.setBoth(ok_button, "General.OK", "General.OK_Tooltip");
122 JButton cancel_button = new GLIButton();
123 cancel_button.setMnemonic(KeyEvent.VK_C);
124 Dictionary.setBoth(cancel_button, "General.Cancel", "General.Pure_Cancel_Tooltip");
125
126 // Connection
127 ok_button.addActionListener(new OKButtonListener());
128 cancel_button.addActionListener(new CancelButtonListener());
129 //sets_list.addListSelectionListener(new MetadataListSelectionListener());
130
131 // Display
132 instructions_panel.setLayout(new GridLayout(1,1));
133 instructions_panel.add(instructions_textarea);
134
135
136 //center_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
137 //center_pane.setLayout(new GridLayout(2,1,0,5));
138 //center_pane.add(selection_pane);
139
140 button_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
141 button_pane.setLayout(new GridLayout(1,2,5,0));
142 button_pane.add(ok_button);
143 button_pane.add(cancel_button);
144
145 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
146 content_pane.setLayout(new BorderLayout());
147 content_pane.add(instructions_panel, BorderLayout.NORTH);
148 //content_pane.add(center_pane, BorderLayout.CENTER);
149 content_pane.add(button_pane, BorderLayout.SOUTH);
150
151 // Show
152 Dimension screen_size = Gatherer.config.screen_size;
153 setLocation((screen_size.width - size.width) / 2, (screen_size.height - size.height) / 2);
154 setVisible(true);
155 }
156
157 public int getMetadataChoice() {
158 return NEW_META_SET;
159
160 /*if (existing_mds_button.isSelected()) {
161 return EXISTING_META_SET;
162 }
163 if (new_mds_button.isSelected()) {
164 return NEW_META_SET;
165 }
166 // something wrong
167 return ERROR;*/
168 }
169 public boolean isCancelled() {
170 return cancelled;
171 }
172 private class CancelButtonListener
173 implements ActionListener {
174 public void actionPerformed(ActionEvent event) {
175 cancelled = true;
176 self.dispose();
177 }
178 }
179 public class OKButtonListener
180 implements ActionListener {
181 public void actionPerformed(ActionEvent event) {
182 cancelled = false;
183 self.dispose();
184
185 }
186 }
187}
Note: See TracBrowser for help on using the repository browser.