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

Last change on this file since 6160 was 5795, checked in by kjdon, 21 years ago

two new prompts for opening a non-gatherer collection. NewMetaSetPrompt is not currently used, and is basically a copy of an inner class of MEM (AddSetActionListener). maybe these two classes could be merged.

  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1package org.greenstone.gatherer.gui;
2
3import java.awt.*;
4import java.awt.event.*;
5import java.io.*;
6import java.util.*;
7import javax.swing.*;
8import javax.swing.event.*;
9import org.greenstone.gatherer.Dictionary;
10import org.greenstone.gatherer.Gatherer;
11import org.greenstone.gatherer.checklist.CheckList;
12import org.greenstone.gatherer.checklist.Entry;
13import org.greenstone.gatherer.gui.SimpleMenuBar;
14import org.greenstone.gatherer.gui.ModalDialog;
15import org.greenstone.gatherer.cdm.ElementWrapper;
16import org.greenstone.gatherer.msm.MetadataSet;
17import org.greenstone.gatherer.util.StaticStrings;
18import org.greenstone.gatherer.util.Utility;
19import org.w3c.dom.*;
20
21// this has been changed to not offer the choice of a new metadata set, cos I haven't made this work properly.
22/** 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 */
23public class ExternalCollectionPrompt
24 extends ModalDialog {
25
26 public static int ERROR = 0;
27 public static int NEW_META_SET = 1;
28 public static int EXISTING_META_SET = 2;
29
30 private boolean cancelled = true;
31 private JDialog self;
32 private JRadioButton new_mds_button;
33 private JRadioButton existing_mds_button;
34
35
36 static private Dimension size = new Dimension(600, 250);
37
38 public ExternalCollectionPrompt() {
39 super(Gatherer.g_man, true);
40 this.self = this;
41 setJMenuBar(new SimpleMenuBar("loadinganexternalcollection"));
42 setModal(true);
43 setSize(size);
44 Dictionary.setText(this, "ExternalCollectionPrompt.Title");
45
46 // Creation
47 JPanel content_pane = (JPanel) getContentPane();
48 JPanel center_pane = new JPanel();
49
50 JPanel instructions_panel = new JPanel();
51 JTextArea instructions_textarea;
52 instructions_textarea = new JTextArea();
53 instructions_textarea.setCaretPosition(0);
54 instructions_textarea.setEditable(false);
55 instructions_textarea.setLineWrap(true);
56 instructions_textarea.setRows(6);
57 instructions_textarea.setWrapStyleWord(true);
58 Dictionary.registerText(instructions_textarea, "ExternalCollectionPrompt.Instructions_1"); // change to instructions_2 when add the other choice back in
59
60 /* new_mds_button = new JRadioButton();
61 new_mds_button.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
62 //new_mds_button.setMnemonic(KeyEvent.VK_I);
63 new_mds_button.setOpaque(false);
64 Dictionary.registerText(new_mds_button, "ExternalCollectionPrompt.NewMDS");
65 existing_mds_button = new JRadioButton();
66 existing_mds_button.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
67 //existing_mds_button.setMnemonic(KeyEvent.VK_X);
68 existing_mds_button.setOpaque(false);
69 Dictionary.registerText(existing_mds_button, "ExternalCollectionPrompt.ExistingMDS");
70
71 ButtonGroup bg = new ButtonGroup();
72 bg.add(new_mds_button);
73 bg.add(existing_mds_button);
74 new_mds_button.setSelected(true);
75
76 JPanel selection_pane = new JPanel();
77 selection_pane.setLayout(new GridLayout(2,1));
78 selection_pane.add(new_mds_button);
79 selection_pane.add(existing_mds_button);
80 */
81 JPanel button_pane = new JPanel();
82 JButton ok_button = new JButton();
83 ok_button.setMnemonic(KeyEvent.VK_O);
84 Dictionary.setBoth(ok_button, "General.OK", "General.OK_Tooltip");
85 JButton cancel_button = new JButton();
86 cancel_button.setMnemonic(KeyEvent.VK_C);
87 Dictionary.setBoth(cancel_button, "General.Cancel", "General.Pure_Cancel_Tooltip");
88
89 // Connection
90 ok_button.addActionListener(new OKButtonListener());
91 cancel_button.addActionListener(new CancelButtonListener());
92 //sets_list.addListSelectionListener(new MetadataListSelectionListener());
93
94 // Display
95 instructions_panel.setLayout(new GridLayout(1,1));
96 instructions_panel.add(instructions_textarea);
97
98
99 //center_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
100 //center_pane.setLayout(new GridLayout(2,1,0,5));
101 //center_pane.add(selection_pane);
102
103 button_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
104 button_pane.setLayout(new GridLayout(1,2,5,0));
105 button_pane.add(ok_button);
106 button_pane.add(cancel_button);
107
108 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
109 content_pane.setLayout(new BorderLayout());
110 content_pane.add(instructions_panel, BorderLayout.NORTH);
111 //content_pane.add(center_pane, BorderLayout.CENTER);
112 content_pane.add(button_pane, BorderLayout.SOUTH);
113
114 // Show
115 Dimension screen_size = Gatherer.config.screen_size;
116 setLocation((screen_size.width - size.width) / 2, (screen_size.height - size.height) / 2);
117 setVisible(true);
118 }
119
120 public int getMetadataChoice() {
121 return NEW_META_SET;
122
123 /*if (existing_mds_button.isSelected()) {
124 return EXISTING_META_SET;
125 }
126 if (new_mds_button.isSelected()) {
127 return NEW_META_SET;
128 }
129 // something wrong
130 return ERROR;*/
131 }
132 public boolean isCancelled() {
133 return cancelled;
134 }
135 private class CancelButtonListener
136 implements ActionListener {
137 public void actionPerformed(ActionEvent event) {
138 cancelled = true;
139 self.dispose();
140 }
141 }
142 public class OKButtonListener
143 implements ActionListener {
144 public void actionPerformed(ActionEvent event) {
145 cancelled = false;
146 self.dispose();
147
148 }
149 }
150}
Note: See TracBrowser for help on using the repository browser.