[12142] | 1 | package org.greenstone.gatherer.gui;
|
---|
| 2 |
|
---|
| 3 | import java.awt.*;
|
---|
| 4 | import java.awt.event.*;
|
---|
| 5 | import javax.swing.*;
|
---|
| 6 | import javax.swing.event.*;
|
---|
| 7 | import java.util.ArrayList;
|
---|
| 8 | import java.util.Vector;
|
---|
| 9 | import java.io.File;
|
---|
[12561] | 10 | import java.util.Observer;
|
---|
| 11 | import java.util.Observable;
|
---|
[12142] | 12 |
|
---|
| 13 | import org.greenstone.gatherer.Configuration;
|
---|
| 14 | import org.greenstone.gatherer.Dictionary;
|
---|
| 15 | import org.greenstone.gatherer.Gatherer;
|
---|
| 16 | import org.greenstone.gatherer.cdm.DynamicListModel;
|
---|
| 17 | import org.greenstone.gatherer.metadata.MetadataSet;
|
---|
| 18 | import org.greenstone.gatherer.metadata.MetadataSetManager;
|
---|
[12561] | 19 | import org.greenstone.gatherer.gems.*;
|
---|
[12142] | 20 |
|
---|
| 21 | public class MetadataSetDialog
|
---|
| 22 | extends ModalDialog {
|
---|
| 23 |
|
---|
| 24 | static private Dimension SIZE = new Dimension(600, 300);
|
---|
| 25 | static private Dimension ADD_SIZE = new Dimension(600, 500);
|
---|
| 26 |
|
---|
| 27 | private ArrayList current_metadata_sets;
|
---|
| 28 | private DynamicListModel current_metadata_model;
|
---|
| 29 |
|
---|
| 30 | private JButton add_button = null;
|
---|
| 31 | private JButton edit_button = null;
|
---|
| 32 | private JButton remove_button = null;
|
---|
| 33 |
|
---|
| 34 | private JButton close_button = null;
|
---|
| 35 |
|
---|
| 36 | private JList current_set_list = null;
|
---|
| 37 | private MetadataSetDialog set_dialog = null;
|
---|
| 38 | private boolean sets_changed = false;
|
---|
[12561] | 39 |
|
---|
| 40 | private GEMS gems = null;
|
---|
[12142] | 41 |
|
---|
| 42 | public MetadataSetDialog() {
|
---|
| 43 | super(Gatherer.g_man, true);
|
---|
| 44 | set_dialog = this;
|
---|
[18370] | 45 | this.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12241] | 46 | setJMenuBar(new SimpleMenuBar("selectingmetadatasets"));
|
---|
[12142] | 47 | setSize(SIZE);
|
---|
| 48 | setTitle(Dictionary.get("MetadataSetDialog.Title"));
|
---|
| 49 |
|
---|
| 50 | current_metadata_sets = MetadataSetManager.getMetadataSets();
|
---|
| 51 | current_metadata_model = new DynamicListModel();
|
---|
| 52 |
|
---|
| 53 | int current_size = current_metadata_sets.size();
|
---|
| 54 | for (int i=0; i<current_size; i++) {
|
---|
| 55 | current_metadata_model.addElement(current_metadata_sets.get(i));
|
---|
| 56 | }
|
---|
| 57 | JPanel content_pane = (JPanel) getContentPane();
|
---|
[18370] | 58 | content_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12142] | 59 | content_pane.setOpaque(true);
|
---|
| 60 |
|
---|
| 61 | JLabel current_metadata_sets_label = new JLabel(Dictionary.get("MetadataSetDialog.Current_Sets"));
|
---|
[18370] | 62 | current_metadata_sets_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
| 63 | current_metadata_sets_label.setOpaque(true);
|
---|
[12142] | 64 | current_set_list = new JList(current_metadata_model);
|
---|
[18370] | 65 | current_set_list.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12142] | 66 | current_set_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
---|
| 67 |
|
---|
| 68 | JPanel button_pane = new JPanel();
|
---|
[18370] | 69 | button_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12142] | 70 | add_button = new GLIButton(Dictionary.get("MetadataSetDialog.Add"), Dictionary.get("MetadataSetDialog.Add_Tooltip"));
|
---|
| 71 | add_button.setEnabled(true);
|
---|
| 72 |
|
---|
| 73 | edit_button = new GLIButton(Dictionary.get("MetadataSetDialog.Edit"), Dictionary.get("MetadataSetDialog.Edit_Tooltip"));
|
---|
| 74 | edit_button.setEnabled(false);
|
---|
| 75 |
|
---|
| 76 | remove_button = new GLIButton(Dictionary.get("MetadataSetDialog.Remove"), Dictionary.get("MetadataSetDialog.Remove_Tooltip"));
|
---|
| 77 | remove_button.setEnabled(false);
|
---|
| 78 |
|
---|
| 79 | close_button = new GLIButton(Dictionary.get("General.Close"), Dictionary.get("General.Close_Tooltip"));
|
---|
| 80 | close_button.setEnabled(true);
|
---|
| 81 |
|
---|
| 82 |
|
---|
| 83 | // Add listeners
|
---|
| 84 | add_button.addActionListener(new AddButtonListener());
|
---|
| 85 | edit_button.addActionListener(new EditButtonListener());
|
---|
| 86 | remove_button.addActionListener(new RemoveButtonListener());
|
---|
| 87 | close_button.addActionListener(new ActionListener() {
|
---|
| 88 | public void actionPerformed(ActionEvent event) {
|
---|
| 89 | set_dialog.dispose();
|
---|
| 90 | }
|
---|
| 91 | });
|
---|
| 92 | current_set_list.addListSelectionListener(new MetadataSetListSelectionListener());
|
---|
| 93 |
|
---|
| 94 | button_pane.setLayout(new GridLayout(2,3));
|
---|
| 95 | button_pane.add(add_button);
|
---|
| 96 | button_pane.add(edit_button);
|
---|
| 97 | button_pane.add(remove_button);
|
---|
| 98 | button_pane.add(new JPanel());
|
---|
| 99 | button_pane.add(new JPanel());
|
---|
| 100 | button_pane.add(close_button);
|
---|
| 101 |
|
---|
| 102 | content_pane.setLayout(new BorderLayout());
|
---|
| 103 | content_pane.add(current_metadata_sets_label, BorderLayout.NORTH);
|
---|
[18370] | 104 | JScrollPane scrol_tmp;
|
---|
| 105 | scrol_tmp = new JScrollPane(current_set_list);
|
---|
| 106 | scrol_tmp.setComponentOrientation(Dictionary.getOrientation());
|
---|
| 107 | content_pane.add(scrol_tmp, BorderLayout.CENTER);
|
---|
[12142] | 108 | content_pane.add(button_pane, BorderLayout.SOUTH);
|
---|
| 109 |
|
---|
| 110 | // Show
|
---|
| 111 | Dimension screen_size = Configuration.screen_size;
|
---|
| 112 | setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2);
|
---|
| 113 | setVisible(true);
|
---|
| 114 |
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | public boolean setsChanged() {
|
---|
| 118 | return sets_changed;
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 | private class AddButtonListener
|
---|
| 122 | implements ActionListener {
|
---|
| 123 |
|
---|
| 124 | public void actionPerformed(ActionEvent event) {
|
---|
| 125 | AddMetadataSetPrompt amsp = new AddMetadataSetPrompt();
|
---|
| 126 | if (!amsp.isCancelled()) {
|
---|
| 127 | sets_changed = true;
|
---|
| 128 | }
|
---|
| 129 | }
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | private class EditButtonListener
|
---|
[12763] | 133 | implements ActionListener, GEMSListener {
|
---|
[12142] | 134 |
|
---|
| 135 | public void actionPerformed(ActionEvent event) {
|
---|
| 136 | // do a pop up message
|
---|
[12561] | 137 | MetadataSet metadata_set = (MetadataSet) current_set_list.getSelectedValue();
|
---|
| 138 | String metadata_path = metadata_set.getMetadataSetFile().toString();
|
---|
| 139 | if (gems == null){
|
---|
[13681] | 140 | gems = new GEMS(Configuration.gsdl_path,Configuration.gsdl3_path,"", false, false);
|
---|
[12763] | 141 | gems.addGEMSListener(this);
|
---|
[12561] | 142 | }
|
---|
| 143 | gems.displayMetadataSet(metadata_path);
|
---|
[12142] | 144 | }
|
---|
[12763] | 145 |
|
---|
| 146 | public void gemsIsClosed()
|
---|
| 147 | {
|
---|
| 148 | // We assume that the selected metadata was edited, so reload it and remember to update the table
|
---|
| 149 | MetadataSet edited_metadata_set = (MetadataSet) current_set_list.getSelectedValue();
|
---|
| 150 | MetadataSetManager.unloadMetadataSet(edited_metadata_set);
|
---|
| 151 | MetadataSetManager.loadMetadataSet(edited_metadata_set.getMetadataSetFile());
|
---|
| 152 | sets_changed = true;
|
---|
| 153 | }
|
---|
[12142] | 154 | }
|
---|
| 155 |
|
---|
| 156 | private class RemoveButtonListener
|
---|
| 157 | implements ActionListener {
|
---|
| 158 |
|
---|
| 159 | public void actionPerformed(ActionEvent event) {
|
---|
| 160 | MetadataSet metadata_set = (MetadataSet) current_set_list.getSelectedValue();
|
---|
[12238] | 161 | current_metadata_model.removeElement(metadata_set);
|
---|
[12142] | 162 | Gatherer.c_man.removeMetadataSet(metadata_set);
|
---|
| 163 | sets_changed = true;
|
---|
| 164 |
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | }
|
---|
| 168 |
|
---|
| 169 |
|
---|
| 170 | private class MetadataSetListSelectionListener
|
---|
| 171 | implements ListSelectionListener {
|
---|
| 172 |
|
---|
| 173 | public void valueChanged(ListSelectionEvent event)
|
---|
| 174 | {
|
---|
| 175 | // Wait until we get a stable event
|
---|
| 176 | if (event.getValueIsAdjusting()) {
|
---|
| 177 | return;
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | // Now we can process it
|
---|
| 181 | if (!current_set_list.isSelectionEmpty() && !((MetadataSet)current_set_list.getSelectedValue()).getNamespace().equals(MetadataSetManager.EXTRACTED_METADATA_NAMESPACE)) {
|
---|
| 182 | remove_button.setEnabled(true);
|
---|
| 183 | edit_button.setEnabled(true);
|
---|
| 184 | }
|
---|
| 185 | else {
|
---|
| 186 | remove_button.setEnabled(false);
|
---|
| 187 | edit_button.setEnabled(false);
|
---|
| 188 | }
|
---|
| 189 |
|
---|
| 190 | }
|
---|
| 191 |
|
---|
| 192 | }
|
---|
| 193 |
|
---|
| 194 | private class AddMetadataSetPrompt
|
---|
[12561] | 195 | extends ModalDialog implements GEMSListener{
|
---|
[12142] | 196 |
|
---|
| 197 | private JDialog add_set_dialog;
|
---|
| 198 | private boolean cancelled = false;
|
---|
| 199 |
|
---|
| 200 | private JList elements_list;
|
---|
| 201 | private JList available_sets_list;
|
---|
| 202 |
|
---|
| 203 | private JButton add_button;
|
---|
| 204 |
|
---|
[12561] | 205 | private JButton new_button;
|
---|
| 206 |
|
---|
| 207 | private GEMSListener self;
|
---|
| 208 |
|
---|
[12142] | 209 | public AddMetadataSetPrompt() {
|
---|
| 210 | super(Gatherer.g_man, true);
|
---|
[18370] | 211 | this.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12142] | 212 | add_set_dialog = this;
|
---|
| 213 | setModal(true);
|
---|
| 214 | setJMenuBar(new SimpleMenuBar("choosingmetadatasets"));
|
---|
| 215 | setSize(ADD_SIZE);
|
---|
| 216 | setTitle(Dictionary.get("MetadataSetDialog.Add_Title"));
|
---|
[12561] | 217 | self = this;
|
---|
| 218 |
|
---|
[12142] | 219 |
|
---|
| 220 | JPanel center_pane = new JPanel();
|
---|
[18370] | 221 | center_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12142] | 222 | JPanel sets_pane = new JPanel();
|
---|
[18370] | 223 | sets_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12142] | 224 | JLabel sets_label = new JLabel(Dictionary.get("MetadataSetDialog.Available_Sets"));
|
---|
[18370] | 225 | sets_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12142] | 226 | sets_label.setOpaque(false);
|
---|
| 227 |
|
---|
[12561] | 228 | available_sets_list = new JList(getValidSetModel());
|
---|
[18370] | 229 | available_sets_list.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12142] | 230 | available_sets_list.addListSelectionListener(new AvailableSetListSelectionListener());
|
---|
| 231 | available_sets_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
---|
[18370] | 232 |
|
---|
[12142] | 233 | JPanel elements_pane = new JPanel();
|
---|
[18370] | 234 | elements_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12142] | 235 | JLabel elements_label = new JLabel(Dictionary.get("MetadataSetDialog.Elements"));
|
---|
[18370] | 236 | elements_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
| 237 |
|
---|
[12142] | 238 | elements_list = new JList();
|
---|
[18370] | 239 | elements_list.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12142] | 240 | elements_list.setCellRenderer(new MetadataElementListCellRenderer());
|
---|
| 241 | elements_list.setBackground(Configuration.getColor("coloring.collection_tree_background", false));
|
---|
| 242 | elements_list.setForeground(Configuration.getColor("coloring.collection_tree_foreground", false));
|
---|
| 243 | elements_list.setSelectionBackground(Configuration.getColor("coloring.collection_tree_background", false));
|
---|
| 244 | elements_list.setSelectionForeground(Configuration.getColor("coloring.collection_tree_foreground", false));
|
---|
| 245 |
|
---|
| 246 | JPanel button_pane = new JPanel();
|
---|
[18370] | 247 | button_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12142] | 248 | add_button = new GLIButton(Dictionary.get("MetadataSetDialog.Add_Set"), Dictionary.get("MetadataSetDialog.Add_Set_Tooltip"));
|
---|
| 249 | add_button.setEnabled(false);
|
---|
[12561] | 250 |
|
---|
| 251 | new_button = new GLIButton(Dictionary.get("MetadataSetDialog.New_Set"), Dictionary.get("MetadataSetDialog.New_Set_Tooltip"));
|
---|
| 252 |
|
---|
[12142] | 253 | JButton browse_button = new GLIButton(Dictionary.get("MetadataSetDialog.Browse"), Dictionary.get("MetadataSetDialog.Browse_Tooltip"));
|
---|
| 254 | browse_button.setEnabled(true);
|
---|
| 255 | JButton cancel_button = new GLIButton(Dictionary.get("General.Cancel"), Dictionary.get("General.Pure_Cancel_Tooltip"));
|
---|
| 256 |
|
---|
| 257 | add_button.addActionListener(new AddSetActionListener());
|
---|
| 258 | browse_button.addActionListener(new BrowseActionListener());
|
---|
| 259 | cancel_button.addActionListener(new ActionListener() {
|
---|
| 260 | public void actionPerformed(ActionEvent event) {
|
---|
| 261 | cancelled = true;
|
---|
[12762] | 262 | if (gems != null) {
|
---|
[12561] | 263 | gems.removeGEMSListener(self);
|
---|
[12762] | 264 | }
|
---|
[12142] | 265 | add_set_dialog.dispose();
|
---|
| 266 | }
|
---|
| 267 | });
|
---|
| 268 |
|
---|
[12561] | 269 | new_button.addActionListener(new ActionListener() {
|
---|
| 270 | public void actionPerformed(ActionEvent event) {
|
---|
[12762] | 271 | if (gems == null) {
|
---|
[13681] | 272 | gems = new GEMS(Configuration.gsdl_path, Configuration.gsdl3_path, "", false, false);
|
---|
[12561] | 273 | }
|
---|
| 274 | gems.newMetadataSet();
|
---|
| 275 | gems.addGEMSListener(self);
|
---|
| 276 | }
|
---|
| 277 | });
|
---|
| 278 |
|
---|
| 279 |
|
---|
[12142] | 280 | // Layout
|
---|
| 281 | sets_pane.setLayout(new BorderLayout());
|
---|
| 282 | sets_pane.add(sets_label, BorderLayout.NORTH);
|
---|
| 283 | sets_pane.add(new JScrollPane(available_sets_list), BorderLayout.CENTER);
|
---|
| 284 |
|
---|
| 285 | elements_pane.setLayout(new BorderLayout());
|
---|
| 286 | elements_pane.add(elements_label, BorderLayout.NORTH);
|
---|
| 287 | elements_pane.add(new JScrollPane(elements_list), BorderLayout.CENTER);
|
---|
| 288 |
|
---|
| 289 | center_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
|
---|
| 290 | center_pane.setLayout(new GridLayout(2,1,0,5));
|
---|
| 291 | center_pane.add(sets_pane);
|
---|
| 292 | center_pane.add(elements_pane);
|
---|
| 293 |
|
---|
| 294 | button_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
|
---|
[12561] | 295 | button_pane.setLayout(new GridLayout(1,4,5,0));
|
---|
[12142] | 296 | button_pane.add(add_button);
|
---|
[12561] | 297 | button_pane.add(new_button);
|
---|
[12142] | 298 | button_pane.add(browse_button);
|
---|
| 299 | button_pane.add(cancel_button);
|
---|
| 300 |
|
---|
| 301 | JPanel content_pane = (JPanel) getContentPane();
|
---|
[18370] | 302 | content_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12142] | 303 | content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
| 304 | content_pane.setLayout(new BorderLayout());
|
---|
| 305 | content_pane.add(center_pane, BorderLayout.CENTER);
|
---|
| 306 | content_pane.add(button_pane, BorderLayout.SOUTH);
|
---|
| 307 |
|
---|
| 308 | // Show
|
---|
| 309 | Dimension screen_size = Configuration.screen_size;
|
---|
| 310 | setLocation((screen_size.width - ADD_SIZE.width) / 2, (screen_size.height - ADD_SIZE.height) / 2);
|
---|
| 311 | setVisible(true);
|
---|
[18370] | 312 |
|
---|
[12142] | 313 | }
|
---|
[12561] | 314 |
|
---|
| 315 | public DynamicListModel getValidSetModel(){
|
---|
| 316 | // Show the metadata sets (except extracted, exploded, and currently assigned sets) in the GLI metadata folder
|
---|
| 317 | ArrayList all_metadata_sets = MetadataSetManager.listMetadataSets(new File(Gatherer.getGLIMetadataDirectoryPath()));
|
---|
| 318 | ArrayList current_metadata_sets = MetadataSetManager.getMetadataSets();
|
---|
| 319 | DynamicListModel valid_sets_model = new DynamicListModel();
|
---|
| 320 | for (int i=0; i<all_metadata_sets.size(); i++) {
|
---|
| 321 | MetadataSet set = (MetadataSet) all_metadata_sets.get(i);
|
---|
| 322 | if (set.getNamespace().equals(MetadataSetManager.EXTRACTED_METADATA_NAMESPACE) || set.getNamespace().equals(MetadataSetManager.EXPLODED_METADATA_NAMESPACE)) {
|
---|
| 323 | continue;
|
---|
| 324 | }
|
---|
| 325 | // indexOf uses the equals() method, which for MetadataSets compares the toString() output, not the objects
|
---|
| 326 | if (current_metadata_sets.indexOf(set)!=-1) {
|
---|
| 327 | continue;
|
---|
| 328 | }
|
---|
| 329 | valid_sets_model.addElement(set);
|
---|
| 330 | }
|
---|
| 331 |
|
---|
| 332 | return valid_sets_model;
|
---|
| 333 | }
|
---|
[12142] | 334 |
|
---|
[12561] | 335 |
|
---|
| 336 | public void gemsIsClosed(){
|
---|
| 337 | available_sets_list.setModel(getValidSetModel());
|
---|
| 338 | }
|
---|
| 339 |
|
---|
[12142] | 340 | public boolean isCancelled() {
|
---|
| 341 | return cancelled;
|
---|
| 342 | }
|
---|
| 343 |
|
---|
| 344 | private class AddSetActionListener
|
---|
| 345 | implements ActionListener {
|
---|
| 346 |
|
---|
| 347 | public void actionPerformed(ActionEvent event) {
|
---|
| 348 | if (available_sets_list.isSelectionEmpty()) {
|
---|
| 349 | return;
|
---|
| 350 | }
|
---|
| 351 | MetadataSet metadata_set = (MetadataSet) available_sets_list.getSelectedValue();
|
---|
[12238] | 352 | String namespace = metadata_set.getNamespace();
|
---|
| 353 | // have we got a variant already in the collection??
|
---|
| 354 | MetadataSet existing_set = null;
|
---|
| 355 | if ((existing_set = MetadataSetManager.getMetadataSet(namespace)) != null) {
|
---|
| 356 | // warn that we are replacing
|
---|
| 357 | String [] args = new String [] {metadata_set.toString(), existing_set.toString()};
|
---|
| 358 | WarningDialog namespace_clash_dialog = new WarningDialog("warning.MetadataSetNamespaceClash", Dictionary.get("MetadataSetNamespaceClash.Title"), Dictionary.get("MetadataSetNamespaceClash.Message", args), null, true);
|
---|
| 359 | if (namespace_clash_dialog.display()==JOptionPane.CANCEL_OPTION) {
|
---|
| 360 | namespace_clash_dialog.dispose();
|
---|
| 361 | return;
|
---|
| 362 | }
|
---|
| 363 | // if we have got here, then we remove the old set
|
---|
| 364 | current_metadata_model.removeElement(existing_set);
|
---|
| 365 | Gatherer.c_man.removeMetadataSet(existing_set);
|
---|
| 366 | sets_changed = true;
|
---|
| 367 | namespace_clash_dialog.dispose();
|
---|
| 368 | }
|
---|
| 369 |
|
---|
| 370 |
|
---|
[12142] | 371 | Gatherer.c_man.importMetadataSet(metadata_set);
|
---|
[12238] | 372 | metadata_set = MetadataSetManager.getMetadataSet(namespace);
|
---|
[12142] | 373 | current_metadata_model.addElement(metadata_set);
|
---|
[12238] | 374 | sets_changed = true;
|
---|
[12142] | 375 | cancelled = false;
|
---|
| 376 | add_set_dialog.dispose();
|
---|
| 377 |
|
---|
| 378 | }
|
---|
| 379 | }
|
---|
| 380 |
|
---|
| 381 | private class BrowseActionListener
|
---|
| 382 | implements ActionListener {
|
---|
| 383 |
|
---|
| 384 | public void actionPerformed(ActionEvent event) {
|
---|
| 385 | JFileChooser chooser = new JFileChooser(new File(Gatherer.getGLIMetadataDirectoryPath()));
|
---|
[18370] | 386 | chooser.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12142] | 387 | chooser.setFileFilter(new MetadataSet.MetadataSetFileFilter());
|
---|
| 388 | chooser.setDialogTitle(Dictionary.get("MetadataSetDialog.Add_Title"));
|
---|
| 389 | int return_val = chooser.showDialog(Gatherer.g_man, Dictionary.get("MetadataSetDialog.Add_Set"));
|
---|
| 390 | if (return_val == JFileChooser.APPROVE_OPTION) {
|
---|
| 391 | MetadataSet meta_set = new MetadataSet(chooser.getSelectedFile());
|
---|
| 392 | Gatherer.c_man.importMetadataSet(meta_set);
|
---|
| 393 | current_metadata_model.addElement(meta_set);
|
---|
| 394 | cancelled = false;
|
---|
| 395 | add_set_dialog.dispose();
|
---|
| 396 | } else {
|
---|
| 397 | // we do nothing - user may want to add from the other dialog
|
---|
| 398 | }
|
---|
| 399 | }
|
---|
| 400 | }
|
---|
| 401 |
|
---|
| 402 |
|
---|
| 403 | private class AvailableSetListSelectionListener
|
---|
| 404 | implements ListSelectionListener
|
---|
| 405 | {
|
---|
| 406 | public void valueChanged(ListSelectionEvent event)
|
---|
| 407 | {
|
---|
| 408 | // Wait until we get a stable event
|
---|
| 409 | if (event.getValueIsAdjusting()) {
|
---|
| 410 | return;
|
---|
| 411 | }
|
---|
| 412 |
|
---|
| 413 | if (!available_sets_list.isSelectionEmpty()) {
|
---|
| 414 | // Retrieve the selected set
|
---|
| 415 | MetadataSet metadata_set = (MetadataSet) available_sets_list.getSelectedValue();
|
---|
| 416 | elements_list.setListData(new Vector(metadata_set.getMetadataSetElements()));
|
---|
| 417 | add_button.setEnabled(true);
|
---|
| 418 | }
|
---|
| 419 | else {
|
---|
| 420 | elements_list.setListData(new String[0]);
|
---|
| 421 | add_button.setEnabled(false);
|
---|
| 422 | }
|
---|
| 423 | }
|
---|
| 424 | }
|
---|
| 425 |
|
---|
| 426 |
|
---|
| 427 | }
|
---|
| 428 | }
|
---|