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

Last change on this file since 9334 was 8243, checked in by mdewsnip, 20 years ago

Removed all occurrences of classes explicitly importing other classes in the same package.

  • Property svn:keywords set to Author Date Id Revision
File size: 6.0 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.Configuration;
46import org.greenstone.gatherer.Dictionary;
47import org.greenstone.gatherer.Gatherer;
48
49// this has been changed to not offer the choice of a new metadata set, cos I haven't made this work properly.
50/** 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 */
51public class ExternalCollectionPrompt
52 extends ModalDialog {
53
54 public static int ERROR = 0;
55 public static int NEW_META_SET = 1;
56 public static int EXISTING_META_SET = 2;
57
58 private boolean cancelled = true;
59 private JDialog self;
60 private JRadioButton new_mds_button;
61 private JRadioButton existing_mds_button;
62
63
64 static private Dimension size = new Dimension(600, 250);
65
66 public ExternalCollectionPrompt() {
67 super(Gatherer.g_man, true);
68 this.self = this;
69 setJMenuBar(new SimpleMenuBar("loadinganexternalcollection"));
70 setModal(true);
71 setSize(size);
72 Dictionary.setText(this, "ExternalCollectionPrompt.Title");
73
74 // Creation
75 JPanel content_pane = (JPanel) getContentPane();
76 JPanel center_pane = new JPanel();
77
78 JPanel instructions_panel = new JPanel();
79 JTextArea instructions_textarea;
80 instructions_textarea = new JTextArea();
81 instructions_textarea.setCaretPosition(0);
82 instructions_textarea.setEditable(false);
83 instructions_textarea.setLineWrap(true);
84 instructions_textarea.setRows(6);
85 instructions_textarea.setWrapStyleWord(true);
86 Dictionary.registerText(instructions_textarea, "ExternalCollectionPrompt.Instructions_1"); // change to instructions_2 when add the other choice back in
87
88 /* new_mds_button = new JRadioButton();
89 new_mds_button.setBackground(Configuration.getColor("coloring.collection_tree_background", false));
90 //new_mds_button.setMnemonic(KeyEvent.VK_I);
91 new_mds_button.setOpaque(false);
92 Dictionary.registerText(new_mds_button, "ExternalCollectionPrompt.NewMDS");
93 existing_mds_button = new JRadioButton();
94 existing_mds_button.setBackground(Configuration.getColor("coloring.collection_tree_background", false));
95 //existing_mds_button.setMnemonic(KeyEvent.VK_X);
96 existing_mds_button.setOpaque(false);
97 Dictionary.registerText(existing_mds_button, "ExternalCollectionPrompt.ExistingMDS");
98
99 ButtonGroup bg = new ButtonGroup();
100 bg.add(new_mds_button);
101 bg.add(existing_mds_button);
102 new_mds_button.setSelected(true);
103
104 JPanel selection_pane = new JPanel();
105 selection_pane.setLayout(new GridLayout(2,1));
106 selection_pane.add(new_mds_button);
107 selection_pane.add(existing_mds_button);
108 */
109 JPanel button_pane = new JPanel();
110 JButton ok_button = new GLIButton();
111 ok_button.setMnemonic(KeyEvent.VK_O);
112 Dictionary.setBoth(ok_button, "General.OK", "General.OK_Tooltip");
113 JButton cancel_button = new GLIButton();
114 cancel_button.setMnemonic(KeyEvent.VK_C);
115 Dictionary.setBoth(cancel_button, "General.Cancel", "General.Pure_Cancel_Tooltip");
116
117 // Connection
118 ok_button.addActionListener(new OKButtonListener());
119 cancel_button.addActionListener(new CancelButtonListener());
120 //sets_list.addListSelectionListener(new MetadataListSelectionListener());
121
122 // Display
123 instructions_panel.setLayout(new GridLayout(1,1));
124 instructions_panel.add(instructions_textarea);
125
126
127 //center_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
128 //center_pane.setLayout(new GridLayout(2,1,0,5));
129 //center_pane.add(selection_pane);
130
131 button_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
132 button_pane.setLayout(new GridLayout(1,2,5,0));
133 button_pane.add(ok_button);
134 button_pane.add(cancel_button);
135
136 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
137 content_pane.setLayout(new BorderLayout());
138 content_pane.add(instructions_panel, BorderLayout.NORTH);
139 //content_pane.add(center_pane, BorderLayout.CENTER);
140 content_pane.add(button_pane, BorderLayout.SOUTH);
141
142 // Show
143 Dimension screen_size = Configuration.screen_size;
144 setLocation((screen_size.width - size.width) / 2, (screen_size.height - size.height) / 2);
145 setVisible(true);
146 }
147
148 public int getMetadataChoice() {
149 return NEW_META_SET;
150
151 /*if (existing_mds_button.isSelected()) {
152 return EXISTING_META_SET;
153 }
154 if (new_mds_button.isSelected()) {
155 return NEW_META_SET;
156 }
157 // something wrong
158 return ERROR;*/
159 }
160 public boolean isCancelled() {
161 return cancelled;
162 }
163 private class CancelButtonListener
164 implements ActionListener {
165 public void actionPerformed(ActionEvent event) {
166 cancelled = true;
167 self.dispose();
168 }
169 }
170 public class OKButtonListener
171 implements ActionListener {
172 public void actionPerformed(ActionEvent event) {
173 cancelled = false;
174 self.dispose();
175
176 }
177 }
178}
Note: See TracBrowser for help on using the repository browser.