Changeset 8581
- Timestamp:
- 2004-11-17T10:42:21+13:00 (19 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/gems
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java
r8394 r8581 3 3 * 4 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. 5 * library suite from the New Zealand Digital Library Project at th * University of Waikato, New Zealand. 7 6 * 8 7 * <BR><BR> … … 37 36 package org.greenstone.gatherer.gems; 38 37 38 39 39 40 import java.awt.*; 40 41 import java.awt.event.*; 41 42 import java.io.File; 43 import java.io.PrintStream; 44 import java.io.FileInputStream; 45 import java.io.FileOutputStream; 46 import java.io.DataInputStream; 47 import java.io.IOException; 42 48 import java.util.*; 43 49 import javax.swing.*; … … 54 60 import org.greenstone.gatherer.gui.GComboBox; 55 61 import org.greenstone.gatherer.gui.GLIButton; 56 import org.greenstone.gatherer.gui.SmarterTable;62 //import org.greenstone.gatherer.gui.SmarterTable; 57 63 import org.greenstone.gatherer.gui.ModalDialog; 58 64 import org.greenstone.gatherer.gui.NonWhitespaceField; 59 65 import org.greenstone.gatherer.gui.TransformCharacterTextField; 60 import org.greenstone.gatherer. help.HelpFrame;61 //import org.greenstone.gatherer.cdm.*;66 import org.greenstone.gatherer.gui.HelpFrame; 67 import org.greenstone.gatherer.cdm.*; 62 68 import org.greenstone.gatherer.util.Codec; 63 69 import org.greenstone.gatherer.util.Utility; 64 70 import org.w3c.dom.*; 71 72 65 73 66 74 /** Provides a GUI and relevant suite of tools for the editing of the metadata set associated with this collection. Again I have tried to capture a file manager type feel, with a tree showing the various set-element relations to the left of the dialog, and the right side showing details on the current tree selection. When a set is selected these details include a list of attributes, while when an element is selected this list is joined by another showing assigned values. In order for the editor to be stable and consistant with the rest of the tool, care must be taken for fire appropriate events whenever the sets are changed. There is also the addded complexity of determining what actions have to occur in order for a users edit of an assigned value to be completed, i.e. if the user chooses to remove a value then a call must be made to record_set.root.removeMetadata() to ensure all such values are actually removed, so it is not enough just to remove the value from the value model. … … 77 85 static final private Dimension ADD_ELEMENT_SIZE = new Dimension(400,125); 78 86 static final private Dimension ADD_FILE_SIZE = new Dimension(400,125); 79 static final private Dimension ADD_SET_SIZE = new Dimension(400,1 25);87 static final private Dimension ADD_SET_SIZE = new Dimension(400,150); 80 88 static final private Dimension ADD_OR_EDIT_ATTRIBUTE_SIZE = new Dimension(600,325); 81 89 static final private Dimension ADD_OR_EDIT_VALUE_SIZE = new Dimension(600,440); … … 141 149 private SmarterTable set_attributes = null; 142 150 private SmarterTree element_values = null; 151 public org.w3c.dom.Element rootelement; 152 153 // public LanguageManager languageManager = new LanguageManager(rootelement); 143 154 //PopupListener provides right-click functionality to any component that needs it 144 155 //It is a centralized manager for all popups, then we use evt.Source() and determine where the 145 156 //event was performed 146 private PopupListener popupListener = new PopupListener(); 147 private boolean set_changed = false; 157 private PopupListener popupListener = new PopupListener(this); 148 158 /** A tree that represents the current metadata sets associated with this collection. */ 149 159 private SmarterTree mds_tree = null; 150 160 private String current_collection_file = null; 151 161 private String dialog_options[] = null; 152 162 private boolean atLeastOneSetChanged = false; 153 163 154 164 static public void main(String[] args) … … 166 176 // } 167 177 // Debugging control 178 // Configuration.setLocale("general.locale", true, new Locale("ar")); 179 168 180 if (go.debug) { 169 181 DebugStream.enableDebugging(); … … 185 197 DebugStream.printStackTrace(exception); 186 198 } 187 GEMS gems;188 gems= new GEMS();199 GEMS GEMS; 200 GEMS = new GEMS(); 189 201 } 190 202 … … 213 225 setSize(SIZE); 214 226 setJMenuBar(new GEMSMenuBar()); 215 Dictionary.setText(this, " MEM.Title");227 Dictionary.setText(this, "GEMS.Title"); 216 228 217 229 JPanel content_pane = (JPanel) getContentPane(); … … 241 253 mds_tree_pane.setPreferredSize(new Dimension(300,500)); 242 254 mds_tree = new SmarterTree(model); 243 mds_tree.setCellRenderer(new MEMTreeCellRenderer());255 mds_tree.setCellRenderer(new GEMSTreeCellRenderer()); 244 256 mds_tree.setRootVisible(false); 245 257 mds_tree.setBackground(config.getColor("coloring.collection_tree_background", false)); … … 262 274 JLabel set_name_label = new JLabel(); 263 275 set_name_label.setOpaque(false); 264 //Dictionary.setText(set_name_label, " MEM.Name");276 //Dictionary.setText(set_name_label, "GEMS.Name"); 265 277 set_name = new JLabel(); 266 278 //set_name.setBorder(BorderFactory.createLoweredBevelBorder()); … … 290 302 JLabel element_name_label = new JLabel(); 291 303 element_name_label.setOpaque(false); 292 //Dictionary.setText(element_name_label, " MEM.Name");304 //Dictionary.setText(element_name_label, "GEMS.Name"); 293 305 //element_name = new JLabel(); 294 306 //element_name.setBorder(BorderFactory.createLoweredBevelBorder()); … … 334 346 JLabel profile_name_label = new JLabel(); 335 347 profile_name_label.setOpaque(false); 336 //Dictionary.setText(profile_name_label, " MEM.Name");348 //Dictionary.setText(profile_name_label, "GEMS.Name"); 337 349 profile_name = new JLabel(); 338 350 profile_name.setBorder(BorderFactory.createLoweredBevelBorder()); … … 362 374 JLabel attribute_label = new JLabel(); 363 375 attribute_label.setOpaque(false); 364 Dictionary.setText(attribute_label, " MEM.Attribute");376 Dictionary.setText(attribute_label, "GEMS.Attribute"); 365 377 366 378 JLabel element_label = new JLabel(); 367 379 element_label.setOpaque(false); 368 Dictionary.setText(element_label, " MEM.Element");380 Dictionary.setText(element_label, "GEMS.Element"); 369 381 370 382 JLabel file_label = new JLabel(); 371 383 file_label.setOpaque(false); 372 Dictionary.setText(file_label, " MEM.File");384 Dictionary.setText(file_label, "GEMS.File"); 373 385 374 386 JLabel set_label = new JLabel(); 375 387 set_label.setOpaque(false); 376 Dictionary.setText(set_label, " MEM.Set");388 Dictionary.setText(set_label, "GEMS.Set"); 377 389 378 390 JLabel value_label = new JLabel(); 379 391 value_label.setOpaque(false); 380 Dictionary.setText(value_label, " MEM.Value");392 Dictionary.setText(value_label, "GEMS.Value"); 381 393 382 394 JPanel inner_button_pane = new JPanel(); … … 384 396 add_attribute = new GLIButton(); 385 397 add_attribute.setMnemonic(KeyEvent.VK_4); 386 Dictionary.setBoth(add_attribute, " MEM.Add", "MEM.Add_Attribute_Tooltip");398 Dictionary.setBoth(add_attribute, "GEMS.Add", "GEMS.Add_Attribute_Tooltip"); 387 399 add_element = new GLIButton(); 388 400 add_element.setMnemonic(KeyEvent.VK_3); 389 Dictionary.setBoth(add_element, " MEM.Add", "MEM.Add_Element_Tooltip");401 Dictionary.setBoth(add_element, "GEMS.Add", "GEMS.Add_Element_Tooltip"); 390 402 add_file = new GLIButton(); 391 403 add_file.setMnemonic(KeyEvent.VK_2); 392 Dictionary.setBoth(add_file, " MEM.Add", "MEM.Add_File_Tooltip");404 Dictionary.setBoth(add_file, "GEMS.Add", "GEMS.Add_File_Tooltip"); 393 405 add_set = new GLIButton(); 394 406 add_set.setMnemonic(KeyEvent.VK_1); 395 Dictionary.setBoth(add_set, " MEM.Add", "MEM.Add_Set_Tooltip");407 Dictionary.setBoth(add_set, "GEMS.Add", "GEMS.Add_Set_Tooltip"); 396 408 add_value = new GLIButton(); 397 409 add_value.setMnemonic(KeyEvent.VK_5); 398 Dictionary.setBoth(add_value, " MEM.Add", "MEM.Add_Value_Tooltip");410 Dictionary.setBoth(add_value, "GEMS.Add", "GEMS.Add_Value_Tooltip"); 399 411 400 412 edit_attribute = new GLIButton(); 401 413 edit_attribute.setMnemonic(KeyEvent.VK_6); 402 Dictionary.setBoth(edit_attribute, " MEM.Edit", "MEM.Edit_Attribute_Tooltip");414 Dictionary.setBoth(edit_attribute, "GEMS.Edit", "GEMS.Edit_Attribute_Tooltip"); 403 415 edit_value = new GLIButton(); 404 416 edit_value.setMnemonic(KeyEvent.VK_7); 405 Dictionary.setBoth(edit_value, " MEM.Edit", "MEM.Edit_Value_Tooltip");417 Dictionary.setBoth(edit_value, "GEMS.Edit", "GEMS.Edit_Value_Tooltip"); 406 418 407 419 remove_attribute = new GLIButton(); 408 420 remove_attribute.setMnemonic(KeyEvent.VK_MINUS); 409 Dictionary.setBoth(remove_attribute, " MEM.Remove", "MEM.Remove_Attribute_Tooltip");421 Dictionary.setBoth(remove_attribute, "GEMS.Remove", "GEMS.Remove_Attribute_Tooltip"); 410 422 remove_element = new GLIButton(); 411 423 remove_element.setMnemonic(KeyEvent.VK_0); 412 Dictionary.setBoth(remove_element, " MEM.Remove", "MEM.Remove_Element_Tooltip");424 Dictionary.setBoth(remove_element, "GEMS.Remove", "GEMS.Remove_Element_Tooltip"); 413 425 remove_file = new GLIButton(); 414 426 remove_file.setMnemonic(KeyEvent.VK_9); 415 Dictionary.setBoth(remove_file, " MEM.Remove", "MEM.Remove_File_Tooltip");427 Dictionary.setBoth(remove_file, "GEMS.Remove", "GEMS.Remove_File_Tooltip"); 416 428 remove_set = new GLIButton(); 417 429 remove_set.setMnemonic(KeyEvent.VK_8); 418 Dictionary.setBoth(remove_set, " MEM.Remove", "MEM.Remove_Set_Tooltip");430 Dictionary.setBoth(remove_set, "GEMS.Remove", "GEMS.Remove_Set_Tooltip"); 419 431 remove_value = new GLIButton(); 420 432 remove_value.setMnemonic(KeyEvent.VK_EQUALS); 421 Dictionary.setBoth(remove_value, " MEM.Remove", "MEM.Remove_Value_Tooltip");422 setControls(false, false, false, false, false, false, false, false, false, false, false, false);433 Dictionary.setBoth(remove_value, "GEMS.Remove", "GEMS.Remove_Value_Tooltip"); 434 //setControls(false, false, false, false, false, false, false, false, false, false, false, false); 423 435 424 436 add_element_action_listener = new AddElementActionListener(); 425 437 add_file_action_listener = new AddFileActionListener(); 426 438 add_set_action_listener = new AddSetActionListener(); 439 440 441 427 442 add_or_edit_attribute_action_listener = new AddOrEditAttributeActionListener(); 428 443 add_or_edit_value_action_listener = new AddOrEditValueActionListener(); … … 467 482 set_attributes_scroll.setViewportView(set_attributes); 468 483 469 set_attributes_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Dictionary.get(" MEM.Attributes")), BorderFactory.createEmptyBorder(2,2,2,2)));484 set_attributes_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Dictionary.get("GEMS.Attributes")), BorderFactory.createEmptyBorder(2,2,2,2))); 470 485 set_attributes_pane.setLayout(new BorderLayout()); 471 486 set_attributes_pane.add(set_attributes_scroll, BorderLayout.CENTER); 472 487 473 set_details_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Dictionary.get(" MEM.Set_Details")), BorderFactory.createEmptyBorder(2,2,2,2)));488 set_details_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Dictionary.get("GEMS.Set_Details")), BorderFactory.createEmptyBorder(2,2,2,2))); 474 489 set_details_pane.setLayout(new BorderLayout()); 475 490 set_details_pane.add(set_name_pane, BorderLayout.NORTH); … … 482 497 element_attributes_scroll.setViewportView(element_attributes); 483 498 484 element_attributes_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Dictionary.get(" MEM.Attributes")), BorderFactory.createEmptyBorder(2,2,2,2)));499 element_attributes_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Dictionary.get("GEMS.Attributes")), BorderFactory.createEmptyBorder(2,2,2,2))); 485 500 element_attributes_pane.setLayout(new BorderLayout()); 486 501 element_attributes_pane.add(element_attributes_scroll, BorderLayout.CENTER); 487 502 488 element_values_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Dictionary.get(" MEM.Values")), BorderFactory.createEmptyBorder(2,2,2,2)));503 element_values_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Dictionary.get("GEMS.Values")), BorderFactory.createEmptyBorder(2,2,2,2))); 489 504 element_values_pane.setLayout(new BorderLayout()); 490 505 element_values_pane.add(new JScrollPane(element_values), BorderLayout.CENTER); … … 497 512 //element_inner_pane.add(element_values_pane); 498 513 499 element_details_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Dictionary.get(" MEM.Element_Details")), BorderFactory.createEmptyBorder(2,2,2,2)));514 element_details_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Dictionary.get("GEMS.Element_Details")), BorderFactory.createEmptyBorder(2,2,2,2))); 500 515 element_details_pane.setLayout(new BorderLayout()); 501 516 //element_details_pane.add(element_name_pane, BorderLayout.NORTH); … … 508 523 profile_attributes_scroll.setViewportView(profile_attributes); 509 524 510 profile_attributes_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Dictionary.get(" MEM.Profiles")), BorderFactory.createEmptyBorder(2,2,2,2)));525 profile_attributes_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Dictionary.get("GEMS.Profiles")), BorderFactory.createEmptyBorder(2,2,2,2))); 511 526 profile_attributes_pane.setLayout(new BorderLayout()); 512 527 profile_attributes_pane.add(profile_attributes_scroll, BorderLayout.CENTER); 513 528 514 profile_details_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Dictionary.get(" MEM.Profile_Details")), BorderFactory.createEmptyBorder(2,2,2,2)));529 profile_details_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Dictionary.get("GEMS.Profile_Details")), BorderFactory.createEmptyBorder(2,2,2,2))); 515 530 profile_details_pane.setLayout(new BorderLayout()); 516 531 //profile_details_pane.add(profile_name_pane, BorderLayout.NORTH); … … 578 593 //System.out.println("Final exit func"); 579 594 DebugStream.closeDebugStream(); 580 if( set_changed == true) {581 582 int result = JOptionPane.showOptionDialog(self, Dictionary.get("G ems.Menu.Confirm_Exit_Save", Dictionary.get("MEM.Element")), Dictionary.get("Gems.Menu.Confirm_Exit_Save_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]);595 if(atLeastOneSetChanged == true) { 596 597 int result = JOptionPane.showOptionDialog(self, Dictionary.get("GEMS.Menu.Confirm_Exit_Save", Dictionary.get("GEMS.Element")), Dictionary.get("GEMS.Menu.Confirm_Exit_Save_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]); 583 598 584 599 // System.out.println("Exit: "+result); … … 615 630 file = new JMenu(); 616 631 file.setMnemonic(KeyEvent.VK_F); 617 Dictionary.registerText(file, " Gems.Menu.File");632 Dictionary.registerText(file, "Menu.File"); 618 633 619 634 file_exit = new JMenuItem(); 620 635 file_exit.addActionListener(this); 621 636 file_exit.setMnemonic(KeyEvent.VK_X); 622 Dictionary.registerText(file_exit, " Gems.Menu.File_Exit");637 Dictionary.registerText(file_exit, "Menu.File_Exit"); 623 638 624 639 file_new = new JMenuItem(); 625 640 file_new.addActionListener(this); 626 641 file_new.setMnemonic(KeyEvent.VK_N); 627 Dictionary.registerText(file_new, " Gems.Menu.File_New");642 Dictionary.registerText(file_new, "Menu.File_New"); 628 643 629 644 file_open = new JMenuItem(); 630 645 file_open.addActionListener(this); 631 646 file_open.setMnemonic(KeyEvent.VK_O); 632 Dictionary.registerText(file_open, " Gems.Menu.File_Open");647 Dictionary.registerText(file_open, "Menu.File_Open"); 633 648 634 649 file_save = new JMenuItem(); 635 650 file_save.addActionListener(this); 636 651 file_save.setMnemonic(KeyEvent.VK_S); 637 Dictionary.registerText(file_save, "Gems.Menu.File_Save"); 652 // Dictionary.registerText(file_save, "GEMS.Menu.File_Save"); 653 Dictionary.registerText(file_save, "Menu.File_Save"); 638 654 639 655 file_delete = new JMenuItem(); 640 656 file_delete.addActionListener(new RemoveSetActionListener()); 641 657 file_delete.setMnemonic(KeyEvent.VK_S); 642 Dictionary.registerText(file_delete, "Gems.Menu.File_Delete"); 658 // Dictionary.registerText(file_delete, "GEMS.Menu.File_Delete"); 659 Dictionary.registerText(file_delete, "Menu.File_Delete"); 643 660 644 661 file_preferences = new JMenuItem(); 645 662 file_preferences.addActionListener(this); 646 663 file_preferences.setMnemonic(KeyEvent.VK_S); 647 Dictionary.registerText(file_preferences, "Gems.Menu.File_Preferences"); 664 //Dictionary.registerText(file_preferences, "GEMS.Menu.File_Preferences"); 665 Dictionary.registerText(file_preferences, "Menu.File_Options"); 648 666 649 667 // Layout (file menu) … … 652 670 file.add(file_save); 653 671 file.add(file_delete); 654 //file.add(new JSeparator());655 //file.add(file_preferences);672 file.add(new JSeparator()); 673 file.add(file_preferences); 656 674 file.add(new JSeparator()); 657 675 file.add(file_exit); … … 660 678 edit = new JMenu(); 661 679 edit.setMnemonic(KeyEvent.VK_E); 662 Dictionary.registerText(edit, " Gems.Menu.Edit");680 Dictionary.registerText(edit, "Menu.Edit"); 663 681 664 682 edit_cut = new JMenuItem(); 665 683 edit_cut.addActionListener(this); 666 684 edit_cut.setMnemonic(KeyEvent.VK_X); 667 Dictionary.registerText(edit_cut, " Gems.Menu.Edit_Cut");685 Dictionary.registerText(edit_cut, "Menu.Edit_Cut"); 668 686 669 687 edit_copy = new JMenuItem(); 670 688 edit_copy.addActionListener(this); 671 689 edit_copy.setMnemonic(KeyEvent.VK_C); 672 Dictionary.registerText(edit_copy, " Gems.Menu.Edit_Copy");690 Dictionary.registerText(edit_copy, "Menu.Edit_Copy"); 673 691 674 692 edit_paste = new JMenuItem(); 675 693 edit_paste.addActionListener(this); 676 694 edit_paste.setMnemonic(KeyEvent.VK_V); 677 Dictionary.registerText(edit_paste, " Gems.Menu.Edit_Paste");695 Dictionary.registerText(edit_paste, "Menu.Edit_Paste"); 678 696 679 697 // Layout (edit menu) … … 685 703 help = new JMenu(); 686 704 help.setIcon(Utility.HELP_ICON); 687 Dictionary.setText(help, "G ems.Menu.Help");705 Dictionary.setText(help, "GEMS.Menu.Help"); 688 706 689 707 help_help = new JMenuItem(); 690 708 help_help.addActionListener(this); 691 Dictionary.registerText(help_help, "G ems.Menu.Help");709 Dictionary.registerText(help_help, "GEMS.Menu.Help"); 692 710 693 711 // Layout (help menu) … … 699 717 this.add(edit); 700 718 this.add(Box.createHorizontalGlue()); 701 this.add(help);719 //this.add(help); 702 720 } 703 721 … … 710 728 if (event_source == file_new) { 711 729 add_set.doClick(); 712 set_changed = true;730 // set_changed = true; 713 731 return; 714 732 } … … 734 752 if (event_source == file_save) { 735 753 msm.save(); 736 set_changed = false;754 atLeastOneSetChanged = false; 737 755 return; 738 756 } … … 743 761 /* 744 762 if(set_changed == true) { 745 int result = JOptionPane.showOptionDialog(self, Dictionary.get("G ems.Menu.Confirm_Exit_Save", Dictionary.get("MEM.Element")), Dictionary.get("Gems.Menu.Confirm_Exit_Save_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]);763 int result = JOptionPane.showOptionDialog(self, Dictionary.get("GEMS.Menu.Confirm_Exit_Save", Dictionary.get("GEMS.Element")), Dictionary.get("GEMS.Menu.Confirm_Exit_Save_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]); 746 764 747 765 // System.out.println("Exit: "+result); … … 762 780 763 781 // Edit -> Cut 782 if(event_source == file_preferences){ 783 GEMSPreferences GemsPreferences = new GEMSPreferences(); 784 785 786 } 764 787 if (event_source == edit_cut) { 765 788 try { … … 838 861 839 862 840 private class ActionTask841 extends Thread {842 private int action;843 public ActionTask(int action) {844 this.action = action;845 }846 public void run() {847 boolean complete = false;848 while(!complete) {849 if(self.isVisible()) {850 switch(action) {851 case ADD_SET:852 add_set_action_listener.actionPerformed(new ActionEvent(this, 0, "Blarg!"));853 break;854 case REMOVE_SET:855 if(!mds_tree.isSelectionEmpty()) {856 remove_set_action_listener.actionPerformed(new ActionEvent(this, 0, "Blarg!"));857 }858 break;859 }860 complete = true;861 }862 else {863 try {864 synchronized(this) {865 wait(100);866 }867 }868 catch(Exception exception) {869 }870 }871 }872 }873 }874 863 //callback method 875 864 protected void processWindowEvent(WindowEvent evt){ … … 885 874 886 875 public void warn_cant_load_set(){ 887 JOptionPane.showMessageDialog(self, Dictionary.get("Gems.Already_Loaded_Set_Error"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 888 876 JOptionPane.showMessageDialog(self, Dictionary.get("GEMS.Already_Loaded_Set_Error"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 889 877 } 890 878 public void dispose() { … … 892 880 893 881 //if anything has changed, warn user that they should save 894 if( set_changed == true) {895 896 int result = JOptionPane.showOptionDialog(self, Dictionary.get("G ems.Menu.Confirm_Exit_Save", Dictionary.get("MEM.Element")), Dictionary.get("Gems.Menu.Confirm_Exit_Save_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]);882 if(atLeastOneSetChanged == true) { 883 884 int result = JOptionPane.showOptionDialog(self, Dictionary.get("GEMS.Menu.Confirm_Exit_Save", Dictionary.get("GEMS.Element")), Dictionary.get("GEMS.Menu.Confirm_Exit_Save_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]); 897 885 // System.out.println("Exit: "+result); 898 886 if(result == 0) { … … 901 889 } 902 890 } 903 set_changed = false;891 atLeastOneSetChanged = false; 904 892 // Destructor 905 893 card_layout = null; … … 963 951 } 964 952 965 953 private class AddOrEditAttributeActionListener 966 954 extends ModalDialog 967 955 implements ActionListener { … … 974 962 private HashMap name_to_values = null; 975 963 private JLabel target = null; 964 private Vector attributeLists = null; 965 966 967 //org.w3c.dom.Document lang = Utility.parse("/home/arosmain/gsdl/gli/classes/xml/languages.xml", false); 968 org.w3c.dom.Document lang = Utility.parse(Configuration.gsdl_path + "/gli/classes/xml/languages.xml", false); 969 976 970 /** Constructor. */ 977 971 public AddOrEditAttributeActionListener() { 978 972 super(self); 979 973 setModal(true); 974 attributeLists = new Vector(); 975 // 976 attributeLists.add("identifier"); 977 attributeLists.add("comment"); 978 attributeLists.add("definition"); 979 attributeLists.add("name"); 980 981 attributeLists.add("creator"); 982 attributeLists.add("date"); 983 attributeLists.add("contact"); 984 attributeLists.add("family"); 985 986 attributeLists.add("lastchanged"); 987 attributeLists.add("language_dependant"); 988 attributeLists.add("version"); 989 attributeLists.add("datatype"); 990 991 attributeLists.add("obligation"); 992 attributeLists.add("maximum_occurence"); 993 attributeLists.add("registration_authority"); 994 995 996 // 980 997 setSize(ADD_OR_EDIT_ATTRIBUTE_SIZE); 981 998 name_to_values = new HashMap(); … … 992 1009 JLabel target_label = new JLabel(); 993 1010 target_label.setOpaque(false); 994 Dictionary.setText(target_label, " MEM.Target");1011 Dictionary.setText(target_label, "GEMS.Target"); 995 1012 target = new JLabel(); 996 1013 target.setOpaque(false); … … 998 1015 JLabel name_label = new JLabel(); 999 1016 name_label.setOpaque(false); 1000 Dictionary.setText(name_label, " MEM.Name");1017 Dictionary.setText(name_label, "GEMS.Name"); 1001 1018 name = new GComboBox(); 1002 1019 name.setEditable(true); 1003 Dictionary.setTooltip(name, " MEM.Attribute_Name_Tooltip");1020 Dictionary.setTooltip(name, "GEMS.Attribute_Name_Tooltip"); 1004 1021 1005 1022 JLabel language_label = new JLabel(); 1006 1023 language_label.setOpaque(false); 1007 Dictionary.setText(language_label, " MEM.Language");1024 Dictionary.setText(language_label, "GEMS.Language"); 1008 1025 language_box = new JComboBox(); // !!! Gatherer.g_man.design_pane.getLanguageCodes().toArray()); 1009 //LanguageManager languageManager = new LanguageManager(org.w3c.dom.Element()); 1026 1027 1028 for(int n = 0; n < attributeLists.size(); n++){ 1029 1030 name.add(attributeLists.get(n)); 1031 1032 } 1033 // org.w3c.dom.Element myelem = new org.w3c.dom.Element(); 1034 1035 // LanguageManager languageManager = new LanguageManager(myelem); 1010 1036 1011 1037 1012 1038 // !!! language_box.setRenderer(new LanguageListCellRenderer()); 1013 Dictionary.setTooltip(language_box, " MEM.Attribute_Language_Tooltip");1039 Dictionary.setTooltip(language_box, "GEMS.Attribute_Language_Tooltip"); 1014 1040 1015 1041 JPanel center_pane = new JPanel(); 1016 1042 center_pane.setOpaque(false); 1017 value = new ComboArea(Dictionary.get(" MEM.Values"), COMPONENT_SIZE);1043 value = new ComboArea(Dictionary.get("GEMS.Values"), COMPONENT_SIZE); 1018 1044 value.setOpaque(false); 1019 1045 … … 1023 1049 v_text_area.setSelectionColor(config.getColor("coloring.collection_selection_background", false)); 1024 1050 v_text_area.setSelectedTextColor(config.getColor("coloring.collection_selection_foreground", false)); 1025 Dictionary.setTooltip(v_text_area, " MEM.Attribute_Value_Tooltip");1051 Dictionary.setTooltip(v_text_area, "GEMS.Attribute_Value_Tooltip"); 1026 1052 1027 1053 JPanel button_pane = new JPanel(); … … 1072 1098 1073 1099 setLocation((config.screen_size.width - ADD_OR_EDIT_ATTRIBUTE_SIZE.width) / 2, (config.screen_size.height - ADD_OR_EDIT_ATTRIBUTE_SIZE.height) / 2); 1074 } 1100 1101 1102 // create dom object for language_Box 1103 //GEMSLanguageManager GemsLangManager = new GEMSLanguageManager("/home/arosmain/gsdl/gli/classes/xml/languages.xml"); 1104 GEMSLanguageManager GemsLangManager = new GEMSLanguageManager(Configuration.gsdl_path + "/gli/classes/xml/languages.xml"); 1105 1106 Vector languagecodes = GemsLangManager.getLanguageCodes(); 1107 1108 for(int p = 0; p < languagecodes.size(); p++){ 1109 1110 language_box.addItem(languagecodes.get(p).toString()); 1111 } 1112 1113 } 1075 1114 /** Any implementation of ActionListener must include this method so that we can be informed when an action as occured on our registered component, allowing us to add a new attribute to the selected set or element. 1076 1115 * @param event An <strong>ActionEvent</strong> containing information about the event. 1077 1116 */ 1117 1118 1078 1119 public void actionPerformed(ActionEvent event) { 1079 1120 Object source = event.getSource(); 1080 if(source == ok_button) { 1121 AttributeTableModel tablemodel; 1122 String prevLang = new String(""); 1123 String prevValue = new String(""); 1124 1125 //allow user to choose language when they create attr 1126 1127 1128 if(source == popupListener.menuAddAttributeAttribute) { 1129 add_type = true; 1130 language_box.setEnabled(true); 1131 }//end if source== menuaddattributeattribute 1132 else if (source == popupListener.menuEditValue){ 1133 add_type = false; 1134 //grab the table model based on what is currently selected 1135 switch(current_attribute_type) { 1136 case GEMSNode.COLLECTION: 1137 tablemodel = (AttributeTableModel) profile_attributes.getModel(); 1138 //String prevLang = tablemodel.getValueAt(current_attribute,0).toString(); 1139 //String prevValue = tablemodel.getValueAt(current_attribute,1).toString(); 1140 1141 break; 1142 case GEMSNode.SET: 1143 tablemodel = (AttributeTableModel) set_attributes.getModel(); 1144 //grab value in table( 1145 prevLang = tablemodel.getValueAt(current_attribute,0).toString(); 1146 prevValue = tablemodel.getValueAt(current_attribute,1).toString(); 1147 1148 break; 1149 case GEMSNode.ELEMENT: 1150 tablemodel = (AttributeTableModel) element_attributes.getModel(); 1151 //grab values in table( lang and value) 1152 prevLang = tablemodel.getValueAt(current_attribute,1).toString(); 1153 prevValue = tablemodel.getValueAt(current_attribute,2).toString(); 1154 1155 break; 1156 default: 1157 //by default grab element_attr's 1158 tablemodel = (AttributeTableModel) element_attributes.getModel(); 1159 prevLang = tablemodel.getValueAt(current_attribute,1).toString(); 1160 prevValue = tablemodel.getValueAt(current_attribute,2).toString(); 1161 1162 break; 1163 } 1164 language_box.setEnabled(false); 1165 1166 //if a set attr is selected, then do not do any lang operations, other than setting index to -1 1167 if(current_attribute_type != GEMSNode.SET) { 1168 1169 //set the current language to show up in language_box(no lang if no lang specified) 1170 if(prevLang == null || prevLang.compareTo(" ")==0 || prevLang.compareTo("") == 0 || prevLang.compareTo(" ")==0) { 1171 language_box.setSelectedIndex(-1); 1172 1173 } 1174 else { 1175 language_box.setSelectedItem(prevLang.toLowerCase()); 1176 } 1177 }// end currattr != GEMSnode.set 1178 else { 1179 1180 language_box.setSelectedIndex(-1); 1181 1182 }// end currattr == GEMSnode.set 1183 1184 value.setText(prevValue); 1185 1186 }//end if source == popupListener.menuEditValue) 1187 /////////////////////////////////////////////// 1188 if(source == ok_button) { 1081 1189 boolean success = true; 1082 1190 AttributeTableModel model; … … 1090 1198 case GEMSNode.SET: 1091 1199 model = (AttributeTableModel) set_attributes.getModel(); 1092 success = addOrEditSetAttribute(model); 1200 success = addOrEditSetAttribute(model); 1201 1093 1202 break; 1094 1203 case GEMSNode.ELEMENT: … … 1097 1206 break; 1098 1207 } 1099 1208 1100 1209 if (success) { 1101 1210 // Hide dialog 1102 set_changed = true;1211 1103 1212 setVisible(false); 1213 return; 1104 1214 } 1105 1215 } … … 1107 1217 // Hide dialog 1108 1218 setVisible(false); 1219 return; 1109 1220 } 1110 1221 else if(source == name) { 1111 1222 Object object = name.getSelectedItem(); 1112 1223 if(object != null) { 1113 1224 java.util.List values = (java.util.List) name_to_values.get(object.toString()); … … 1115 1226 values = msm.getElements(); 1116 1227 } 1117 value.clear(); 1118 for(int i = 0; i < values.size(); i++) { 1119 value.add(values.get(i)); 1120 } 1121 } 1122 } 1123 else { 1228 1229 if(value != null && values != null){ 1230 value.clear(); 1231 for(int i = 0; i < values.size(); i++) { 1232 value.add(values.get(i)); 1233 } 1234 } 1235 } 1236 } 1237 else if (source == popupListener.menuAddAttributeAttribute){ 1238 1239 for(int i = 0; i < attributeLists.size(); i++) { 1240 name.add(attributeLists.get(i).toString()); 1241 1242 } 1243 name.setEnabled(true); 1244 } 1245 /* else if (source == popupListener.menuAddAttributeAttribute){ 1246 System.out.println("add attr\n"); 1247 1248 name.setEnabled(true); 1249 1250 }*/ 1251 /* else{ 1124 1252 // Name combo box is enabled except when attributes are edited 1125 //name.setEnabled((source != edit_attribute));1253 //name.setEnabled((source != popupListener.menuEditValue)); 1126 1254 //System.out.println("elsed"); 1127 1255 name_to_values.clear(); … … 1217 1345 if(source == add_attribute || source == popupListener.menuAddAttributeSet || source == popupListener.menuAddAttributeElement || source == popupListener.menuAddAttributeAttribute) { 1218 1346 add_type = true; 1219 Dictionary.setText(this, " MEM.AddAttribute");1347 Dictionary.setText(this, "GEMS.AddAttribute"); 1220 1348 if(current_collection_file != null) { 1221 1349 // Name is empty in this one, however values must be the current elements in the collection. … … 1227 1355 } 1228 1356 setVisible(true); 1229 } 1357 }*/ 1230 1358 // else if(source == popupListener.menuAddAttributeAttribute){ 1231 1359 … … 1235 1363 1236 1364 // System.out.println("from elements"); 1237 // } 1365 // }*/ 1238 1366 else if(current_attribute != -1) { 1367 1368 //System.out.println(source.toString()+"\n"); 1239 1369 AttributeTableModel model = null; 1240 1370 switch(current_attribute_type) { … … 1250 1380 } 1251 1381 add_type = false; 1252 Dictionary.setText(this, " MEM.EditAttribute");1382 Dictionary.setText(this, "GEMS.EditAttribute"); 1253 1383 String name_str = (String) model.getValueAt(current_attribute, 0); 1254 1384 String value_str = (String) model.getValueAt(current_attribute, model.getColumnCount() - 1); … … 1274 1404 value.setSelectedItem(value_str); 1275 1405 value_str = null; 1276 setVisible(true); 1277 } 1278 } 1406 1407 } 1408 // } 1409 setVisible(true); 1279 1410 source = null; 1280 1411 } 1281 1282 1412 1283 1413 private boolean addOrEditCollectionAttribute(AttributeTableModel model) … … 1305 1435 else { 1306 1436 cont = false; 1307 JOptionPane.showMessageDialog(self, Dictionary.get(" MEM.Attribute_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);1437 JOptionPane.showMessageDialog(self, Dictionary.get("GEMS.Attribute_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 1308 1438 } 1309 1439 … … 1320 1450 1321 1451 // Remove the existing attribute if this is an edit 1452 1322 1453 if(!add_type && current_attribute != -1) { 1454 1323 1455 current_set.removeAttribute(name_str); 1324 1456 // Update attribute table 1325 model.removeRow(current_attribute); 1326 } 1327 1457 model.removeRow(current_attribute); 1458 } 1459 current_set.addAttribute(name_str, value_str); 1460 // Update the attribute table 1461 model.add(new Attribute(name_str, value_str)); 1328 1462 boolean cont = true; 1329 // Check that there isn't already an entry for this attribute 1463 1464 /* // Check that there isn't already an entry for this attribute 1465 * 1466 1330 1467 if (!model.contains(name_str, 0)) { 1331 1468 // Add the new attribute … … 1337 1474 else { 1338 1475 cont = false; 1339 JOptionPane.showMessageDialog(self, Dictionary.get(" MEM.Attribute_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);1340 } 1476 JOptionPane.showMessageDialog(self, Dictionary.get("GEMS.Attribute_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 1477 }*/ 1341 1478 1342 1479 value_str = null; … … 1351 1488 String name_str = name.getSelectedItem().toString(); 1352 1489 String language_code = (String) language_box.getSelectedItem(); 1490 1353 1491 String value_str = Codec.transform(Codec.transformUnicode(value.getText()), Codec.TEXT_TO_DOM); 1354 1492 1355 1493 // Remove the existing attribute if this is an edit 1356 1494 if(!add_type && current_attribute != -1) { … … 1409 1547 JLabel set_label = new JLabel(); 1410 1548 set_label.setOpaque(false); 1411 Dictionary.setText(set_label, " MEM.Set");1549 Dictionary.setText(set_label, "GEMS.Set"); 1412 1550 set_field = new JLabel(); 1413 1551 set_field.setOpaque(false); … … 1417 1555 JLabel name_label = new JLabel(); 1418 1556 name_label.setOpaque(false); 1419 Dictionary.setText(name_label, " MEM.Name");1557 Dictionary.setText(name_label, "GEMS.Name"); 1420 1558 name_field = new NonWhitespaceField(); 1421 1559 name_field.setBackground(config.getColor("coloring.collection_tree_background", false)); … … 1423 1561 name_field.setSelectionColor(config.getColor("coloring.collection_selection_background", false)); 1424 1562 name_field.setSelectedTextColor(config.getColor("coloring.collection_selection_foreground", false)); 1425 Dictionary.setTooltip(name_field, " MEM.Element_Name_Tooltip");1563 Dictionary.setTooltip(name_field, "GEMS.Element_Name_Tooltip"); 1426 1564 1427 1565 JPanel button_pane = new JPanel(); … … 1490 1628 element = null; 1491 1629 setVisible(false); 1492 set_changed = true; 1630 1631 //mark as changed 1632 atLeastOneSetChanged = true; 1633 current_set.setSetChanged(true); 1634 1493 1635 } 1494 1636 // Otherwise show an error message and do not proceed. 1495 1637 else { 1496 JOptionPane.showMessageDialog(self, Dictionary.get("G ems.Element_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);1638 JOptionPane.showMessageDialog(self, Dictionary.get("GEMS.Element_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 1497 1639 } 1498 1640 name_str = null; … … 1513 1655 // Warn the user that they can't do that dave. 1514 1656 else { 1515 set_changed = false;1516 JOptionPane.showMessageDialog(self, Dictionary.get(" MEM.Cannot_Add_Elements_To_Greenstone_MDS"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);1657 1658 JOptionPane.showMessageDialog(self, Dictionary.get("GEMS.Cannot_Add_Elements_To_Greenstone_MDS"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 1517 1659 } 1518 1660 } … … 1550 1692 JLabel profile_label = new JLabel(); 1551 1693 profile_label.setOpaque(false); 1552 Dictionary.setText(profile_label, " MEM.Profile");1694 Dictionary.setText(profile_label, "GEMS.Profile"); 1553 1695 1554 1696 JPanel name_pane = new JPanel(); … … 1556 1698 JLabel name_label = new JLabel(); 1557 1699 name_label.setOpaque(false); 1558 Dictionary.setText(name_label, " MEM.Name");1700 Dictionary.setText(name_label, "GEMS.Name"); 1559 1701 name_field = new JTextField(); 1560 1702 name_field.setBackground(config.getColor("coloring.collection_tree_background", false)); … … 1562 1704 name_field.setSelectionColor(config.getColor("coloring.collection_selection_background", false)); 1563 1705 name_field.setSelectedTextColor(config.getColor("coloring.collection_selection_foreground", false)); 1564 Dictionary.setTooltip(name_field, " MEM.Profile_Name_Tooltip");1706 Dictionary.setTooltip(name_field, "GEMS.Profile_Name_Tooltip"); 1565 1707 1566 1708 JPanel button_pane = new JPanel(); … … 1623 1765 // Otherwise warn the user and don't hide the prompt. 1624 1766 // else { 1625 JOptionPane.showMessageDialog(self, Dictionary.get(" MEM.File_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);1767 JOptionPane.showMessageDialog(self, Dictionary.get("GEMS.File_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 1626 1768 // } 1627 1769 name_str = null; … … 1653 1795 private JTextField name_field = null; 1654 1796 private JTextField namespace_field = null; 1797 private JComboBox existingSetJComboBox = new JComboBox(); 1798 1655 1799 public AddSetActionListener() { 1656 1800 super(self); 1657 1801 setModal(true); 1658 1802 setSize(ADD_SET_SIZE); 1659 Dictionary.setText(this, " MEM.AddSet");1803 Dictionary.setText(this, "GEMS.AddSet"); 1660 1804 1661 1805 // Creation … … 1670 1814 JLabel namespace_label = new JLabel(); 1671 1815 namespace_label.setOpaque(false); 1672 Dictionary.setText(namespace_label, " MEM.Namespace");1816 Dictionary.setText(namespace_label, "GEMS.Namespace"); 1673 1817 namespace_field = TransformCharacterTextField.createNamespaceTextField(); 1674 1818 namespace_field.setBackground(config.getColor("coloring.collection_tree_background", false)); … … 1676 1820 namespace_field.setSelectionColor(config.getColor("coloring.collection_selection_background", false)); 1677 1821 namespace_field.setSelectedTextColor(config.getColor("coloring.collection_selection_foreground", false)); 1678 Dictionary.setTooltip(namespace_field, " MEM.Set_Namespace_Tooltip");1822 Dictionary.setTooltip(namespace_field, "GEMS.Set_Namespace_Tooltip"); 1679 1823 1680 1824 JLabel name_label = new JLabel(); 1681 1825 name_label.setOpaque(false); 1682 Dictionary.setText(name_label, " MEM.Name");1826 Dictionary.setText(name_label, "GEMS.Name"); 1683 1827 name_field = new JTextField(); 1684 1828 name_field.setBackground(config.getColor("coloring.collection_tree_background", false)); … … 1686 1830 name_field.setSelectionColor(config.getColor("coloring.collection_selection_background", false)); 1687 1831 name_field.setSelectedTextColor(config.getColor("coloring.collection_selection_foreground", false)); 1688 Dictionary.setTooltip(name_field, " MEM.Set_Name_Tooltip");1832 Dictionary.setTooltip(name_field, "GEMS.Set_Name_Tooltip"); 1689 1833 1690 1834 JPanel button_pane = new JPanel(); … … 1706 1850 1707 1851 // Layout 1708 label_pane.setLayout(new GridLayout( 2,1,0,5));1852 label_pane.setLayout(new GridLayout(3,1)); 1709 1853 label_pane.add(name_label); 1710 1854 label_pane.add(namespace_label); 1711 1712 boxes_pane.setLayout(new GridLayout(2,1,0,5)); 1855 // label_pane.add 1856 // boxes_pane.setLayout(new GridLayout(2,1,0,5)); 1857 boxes_pane.setLayout(new GridLayout(3,1)); 1713 1858 boxes_pane.add(name_field); 1714 1859 boxes_pane.add(namespace_field); 1715 1860 1861 JLabel inheritJLabel = new JLabel(); 1862 Dictionary.setText(inheritJLabel, "GEMS.inheritMetadataSet"); 1863 1864 label_pane.add(inheritJLabel); 1865 1866 1867 //add inherit metadata set functionality 1868 // String[] s = msm.getSets().toArray(); 1869 1870 //JComboBox existingSetJComboBox = new JComboBox(new String(msm.getSetsForInherit().toArray())); 1871 1872 int getSetsLen = msm.getSets().toArray().length; 1873 Vector theSets = msm.getSets(); 1874 1875 for(int k = 0; k < theSets.size(); k++){ 1876 MetadataSet ms = (MetadataSet)theSets.elementAt(k); 1877 1878 existingSetJComboBox.addItem(new String(ms.getName() + " #% " + ms.getFile().toString())); 1879 1880 } 1881 //add sets to existingSetJComboBox 1882 1883 1884 //String tempstr = new String(); 1885 JLabel dummyl = new JLabel(); 1886 Dictionary.setText(dummyl, "GEMS.Add_Set.No_Inherit"); 1887 1888 1889 1890 existingSetJComboBox.addItem("Do not inherit"); 1891 existingSetJComboBox.setSelectedIndex(getSetsLen); 1892 boxes_pane.add(existingSetJComboBox); 1893 1716 1894 center_pane.setLayout(new BorderLayout(5,0)); 1717 1895 center_pane.add(label_pane, BorderLayout.WEST); … … 1726 1904 content_pane.add(center_pane, BorderLayout.CENTER); 1727 1905 content_pane.add(button_pane, BorderLayout.SOUTH); 1728 1906 1729 1907 setLocation((config.screen_size.width - ADD_SET_SIZE.width) / 2, (config.screen_size.height - ADD_SET_SIZE.height) / 2); 1730 1908 } … … 1732 1910 * @param event An <strong>ActionEvent</strong> containing information about the event. 1733 1911 */ 1912 private boolean a_set_exists_with_this_namespace(String namespace){ 1913 Vector p = msm.getSets(); 1914 boolean flag = false; 1915 for(int k = 0; k < p.size(); k++){ 1916 MetadataSet s = (MetadataSet)p.get(k); 1917 1918 if(s.getNamespace().compareTo(namespace) == 0){ 1919 flag = true; 1920 } 1921 1922 } 1923 1924 return flag; 1925 } 1734 1926 public void actionPerformed(ActionEvent event) { 1735 1927 Object source = event.getSource(); 1928 1929 1930 // if(a_set_exists_with_this_namespace(namespace_field.getText()) == false){ 1736 1931 if(source == ok_button) { 1737 String namespace_str = namespace_field.getText(); 1932 //this code below handles whether we inherit from an existing set or not 1933 1934 String namespace_str = namespace_field.getText(); 1738 1935 String name_str = Codec.transform(Codec.transformUnicode(name_field.getText()), Codec.TEXT_TO_DOM); 1936 1937 1938 1939 if (existingSetJComboBox.getSelectedItem().toString().trim().compareTo("Do not inherit") == 0){ 1940 1739 1941 // Ensure the set doesn't already exist 1740 if(msm.getSet(namespace_str) == null) { 1942 //if(msm.getSet(namespace_str) == null) { 1943 if(a_set_exists_with_this_namespace(namespace_str) == false){ 1944 1945 1946 1741 1947 MetadataSet set = msm.addSet(namespace_str, name_str); 1948 1949 //mark as set changed = true 1950 set.setSetChanged(true); 1951 atLeastOneSetChanged = true; 1952 1742 1953 // Update tree. 1743 1954 model.add(null, set, GEMSNode.SET); … … 1745 1956 set = null; 1746 1957 setVisible(false); 1747 set_changed = true; 1748 } 1958 1959 } 1960 else{ 1961 1962 JOptionPane.showMessageDialog(self, Dictionary.get("GEMS.Set_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 1963 1964 } 1965 //do not inherit == 0 1749 1966 // Otherwise show a warning. 1750 else { 1751 JOptionPane.showMessageDialog(self, Dictionary.get("Gems.Set_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 1752 } 1967 //else { 1968 // JOptionPane.showMessageDialog(self, Dictionary.get("GEMS.Set_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 1969 //} 1970 1971 1753 1972 name_str = null; 1754 1973 namespace_str = null; 1974 }//end do not inherit 1975 else { 1976 //lets grab the metadata we want to inherit from... 1977 String anitem = existingSetJComboBox.getSelectedItem().toString(); 1978 1979 // if(msm.getSet(namespace_str) == null) { 1980 if(a_set_exists_with_this_namespace(namespace_field.getText()) == false){ 1981 1982 //setup to read the filename from mds file 1983 String [] items = anitem.split("#%"); 1984 try { 1985 1986 FileInputStream fstream = new FileInputStream(items[1].trim()); 1987 DataInputStream in = new DataInputStream(fstream); 1988 /////////////// 1989 1990 FileOutputStream out; 1991 PrintStream p; 1992 //setup to write to filename from existing file 1993 try { 1994 out = new FileOutputStream(Utility.METADATA_DIR + "/"+ namespace_str + ".mds"); 1995 p = new PrintStream(out); 1996 1997 //cycle through all lines in IN and print to OUT 1998 while(in.available() != 0){ 1999 2000 //System.out.println(in.readLine()+ "\n" 2001 String nextline = in.readLine(); 2002 2003 if(nextline.matches(".+namespace=\".+\".*") == true){ 2004 2005 nextline = nextline.replaceFirst("namespace=\".+\"","namespace=\"" + namespace_str+ "\""); 2006 } 2007 else{ 2008 nextline = nextline.replaceFirst(">.+</Name>",">" + name_str + "</Name>"); 2009 2010 } 2011 2012 2013 2014 2015 p.print(nextline + "\n"); 2016 } 2017 2018 2019 // 2020 p.close(); 2021 2022 MetadataSet loadedset = msm.loadMetadataSet(new File(Utility.METADATA_DIR + "/" + namespace_str + ".mds")); 2023 model.add(null, loadedset, GEMSNode.SET); 2024 } 2025 catch(Exception e){ 2026 System.out.println("Print file error"); 2027 2028 } 2029 2030 2031 2032 /////////////// 2033 2034 2035 } 2036 catch(Exception e){ 2037 2038 System.out.println("File Input error"); 2039 2040 } 2041 2042 }//msm.getset(namespacE) == null 2043 else{ 2044 2045 JOptionPane.showMessageDialog(self, Dictionary.get("GEMS.Set_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 2046 2047 2048 } 2049 } 2050 //}//if a_set_exists_with_this_namespace 2051 //set = null; 2052 setVisible(false); 1755 2053 } 1756 2054 else if(source == cancel_button) { … … 1800 2098 JLabel subject_tree_label = new JLabel(); 1801 2099 subject_tree_label.setOpaque(false); 1802 Dictionary.setText(subject_tree_label, " MEM.Subject");2100 Dictionary.setText(subject_tree_label, "GEMS.Subject"); 1803 2101 subject_tree = new SmarterTree(); 1804 2102 subject_tree.setBackground(config.getColor("coloring.collection_tree_background", false)); … … 1810 2108 JLabel value_label = new JLabel(); 1811 2109 value_label.setOpaque(false); 1812 Dictionary.setText(value_label, " MEM.Value");2110 Dictionary.setText(value_label, "GEMS.Value"); 1813 2111 value = new JTextArea(); 1814 2112 value.setBackground(config.getColor("coloring.collection_tree_background", false)); … … 1816 2114 value.setSelectionColor(config.getColor("coloring.collection_selection_background", false)); 1817 2115 value.setSelectedTextColor(config.getColor("coloring.collection_selection_foreground", false)); 1818 Dictionary.setTooltip(value, " MEM.Value_Tooltip");2116 Dictionary.setTooltip(value, "GEMS.Value_Tooltip"); 1819 2117 1820 2118 JPanel button_pane = new JPanel(); … … 1926 2224 // Hide dialog 1927 2225 setVisible(false); 1928 set_changed = true;2226 atLeastOneSetChanged = true; 1929 2227 } 1930 2228 else if(source == cancel_button) { … … 1948 2246 } 1949 2247 value.setText(""); 1950 Dictionary.setText(this, " MEM.AddValue");2248 Dictionary.setText(this, "GEMS.AddValue"); 1951 2249 } 1952 2250 else { … … 1959 2257 } 1960 2258 value.setText(Codec.transform(current_value_node.toString(), Codec.DOM_TO_TEXT)); 1961 Dictionary.setText(this, " MEM.EditValue");2259 Dictionary.setText(this, "GEMS.EditValue"); 1962 2260 } 1963 2261 model = null; … … 2034 2332 public void actionPerformed(ActionEvent event) { 2035 2333 if(current_attribute != -1) { 2036 int result = JOptionPane.showOptionDialog(self, Dictionary.get(" MEM.Confirm_Removal", Dictionary.get("MEM.Attribute")), Dictionary.get("MEM.Confirm_Removal_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]);2334 int result = JOptionPane.showOptionDialog(self, Dictionary.get("GEMS.Confirm_Removal", Dictionary.get("GEMS.Attribute")), Dictionary.get("GEMS.Confirm_Removal_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]); 2037 2335 // Remove this attribute 2038 2336 if(result == 0) { … … 2067 2365 } 2068 2366 // Disable buttons 2069 edit_attribute.setEnabled(false);2367 // edit_attribute.setEnabled(false); 2070 2368 remove_attribute.setEnabled(false); 2071 2369 ignore = false; 2072 set_changed = true; 2370 2371 atLeastOneSetChanged= true; 2073 2372 } 2074 2373 } … … 2082 2381 */ 2083 2382 public void actionPerformed(ActionEvent event) { 2383 2084 2384 if(current_element != null) { 2085 int result = JOptionPane.showOptionDialog(self, Dictionary.get(" MEM.Confirm_Removal", Dictionary.get("MEM.Element")), Dictionary.get("MEM.Confirm_Removal_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]);2385 int result = JOptionPane.showOptionDialog(self, Dictionary.get("GEMS.Confirm_Removal", Dictionary.get("GEMS.Element")), Dictionary.get("GEMS.Confirm_Removal_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]); 2086 2386 // Remove this attribute 2087 2387 if(result == 0) { … … 2096 2396 card_layout.show(details_pane, BLANK); 2097 2397 ignore = false; 2098 set_changed = true; 2398 2399 atLeastOneSetChanged = true; 2099 2400 } 2100 2401 } … … 2112 2413 public void actionPerformed(ActionEvent event) { 2113 2414 if(current_collection_file != null) { 2114 int result = JOptionPane.showOptionDialog(self, Dictionary.get(" MEM.Confirm_Removal", Dictionary.get("MEM.File")), Dictionary.get("MEM.Confirm_Removal_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]);2415 int result = JOptionPane.showOptionDialog(self, Dictionary.get("GEMS.Confirm_Removal", Dictionary.get("GEMS.File")), Dictionary.get("GEMS.Confirm_Removal_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]); 2115 2416 // Remove the current collection file profile from the profiler. 2116 2417 if(result == 0) { … … 2138 2439 if(current_set != null) { 2139 2440 2140 //If the current_set_filename is dls or d cor ex and in the METADATA_DIR, then do2441 //If the current_set_filename is dls or dublin or ex and in the METADATA_DIR, then do 2141 2442 //not let anyone remove them --Attila 2142 2443 // System.out.println(current_set.getName()); … … 2145 2446 File current_set_filename = current_set.getFile(); 2146 2447 // System.out.println(current_set_filename.toString()); 2147 2448 2148 2449 if(current_set_filename.toString().compareTo(new String(Utility.METADATA_DIR+"dls.mds")) == 0 || 2149 current_set_filename.toString().compareTo(new String(Utility.METADATA_DIR+"d c.mds")) == 0 ||2450 current_set_filename.toString().compareTo(new String(Utility.METADATA_DIR+"dublin.mds")) == 0 || 2150 2451 current_set_filename.toString().compareTo(new String(Utility.METADATA_DIR+"ex.mds")) == 0){ 2151 2452 2152 JOptionPane.showMessageDialog(self, Dictionary.get("G ems.Cannot_Delete_Core_Sets_Error"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);2453 JOptionPane.showMessageDialog(self, Dictionary.get("GEMS.Cannot_Delete_Core_Sets_Error"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 2153 2454 return; 2154 2455 } 2155 2456 2156 2457 2157 int result = JOptionPane.showOptionDialog(self, Dictionary.get(" MEM.Confirm_Removal", Dictionary.get("MEM.Set")), Dictionary.get("MEM.Confirm_Removal_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]);2458 int result = JOptionPane.showOptionDialog(self, Dictionary.get("GEMS.Confirm_Removal", Dictionary.get("GEMS.Set")), Dictionary.get("GEMS.Confirm_Removal_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]); 2158 2459 // Remove the currently selected set 2159 2460 if(result == 0) { 2461 2160 2462 ignore = true; 2161 2463 msm.removeSet(current_set); … … 2168 2470 card_layout.show(details_pane, BLANK); 2169 2471 ignore = false; 2170 set_changed = true; 2472 2473 2474 //We do not need to set the following var because by this point the set was 2475 //completetely removed 2476 //atLeastOneSetChanged 2477 2478 2171 2479 } 2172 2480 } … … 2181 2489 public void actionPerformed(ActionEvent event) { 2182 2490 if(current_value_node != null) { 2183 int result = JOptionPane.showOptionDialog(self, Dictionary.get(" MEM.Confirm_Removal", Dictionary.get("MEM.Value")), Dictionary.get("MEM.Confirm_Removal_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]);2491 int result = JOptionPane.showOptionDialog(self, Dictionary.get("GEMS.Confirm_Removal", Dictionary.get("GEMS.Value")), Dictionary.get("GEMS.Confirm_Removal_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]); 2184 2492 // Remove the current selected value 2185 2493 if(result == 0) { … … 2191 2499 remove_value.setEnabled(false); 2192 2500 ignore = false; 2193 set_changed = true; 2501 2502 //does this every get called? 2503 System.out.println("\nGEMS.RemovevalueActionListener called"); 2504 atLeastOneSetChanged = true; 2194 2505 } 2195 2506 } … … 2257 2568 if(!event.getValueIsAdjusting()) { 2258 2569 if((current_attribute = table.getSelectedRow()) != -1) { 2259 edit_attribute.setEnabled(true); 2260 remove_attribute.setEnabled(true); 2570 // edit_attribute.setEnabled(true); 2571 // remove_attribute.setEnabled(true); 2572 // System.out.println("curr_attr != -1"); 2573 2261 2574 } 2262 2575 else { 2576 // System.out.println("curr_attr = -1"); 2263 2577 current_attribute = -1; 2264 edit_attribute.setEnabled(false);2265 remove_attribute.setEnabled(false);2578 // edit_attribute.setEnabled(false); 2579 // remove_attribute.setEnabled(false); 2266 2580 } 2267 2581 } … … 2313 2627 // !!! String action = msm.profiler.getAction(current_collection_file, source); 2314 2628 // if (action == null) { 2315 // action = Dictionary.get(" MEM.Ignore");2629 // action = Dictionary.get("GEMS.Ignore"); 2316 2630 // } 2317 2631 // attributes.add(new Attribute(source, action)); 2318 2632 // } 2319 atm = new AttributeTableModel(attributes, Dictionary.get(" MEM.Source"), Dictionary.get("MEM.Target"), Dictionary.get("MEM.Ignore"));2633 atm = new AttributeTableModel(attributes, Dictionary.get("GEMS.Source"), Dictionary.get("GEMS.Target"), Dictionary.get("GEMS.Ignore")); 2320 2634 //current_node.setModel(atm); 2321 2635 } … … 2325 2639 2326 2640 card_layout.show(details_pane, PROFILE); 2327 setControls(true, false, false, true, false, false, true, false, false, false, false, false);2641 // setControls(true, false, false, true, false, false, true, false, false, false, false, false); 2328 2642 break; 2329 2643 case GEMSNode.ELEMENT: … … 2331 2645 atm = current_node.getModel(); 2332 2646 if(atm == null) { 2333 atm = new AttributeTableModel(current_element.getAttributes(), Dictionary.get(" MEM.Name"), Dictionary.get("MEM.Language_Code"), Dictionary.get("MEM.Value"), "");2647 atm = new AttributeTableModel(current_element.getAttributes(), Dictionary.get("GEMS.Name"), Dictionary.get("GEMS.Language_Code"), Dictionary.get("GEMS.Value"), ""); 2334 2648 //current_node.setModel(atm); 2335 2649 } … … 2346 2660 element_values_layout.show(element_values_pane, VALUES); 2347 2661 // Meanwhile disable/enable controls depending on this Element selection. 2348 setControls(true, false, false, false, false, true, true, false, false, true, false, false);2662 //setControls(true, false, false, false, false, true, true, false, false, true, false, false); 2349 2663 } 2350 2664 else { 2351 2665 element_values_layout.show(element_values_pane, BLANK); 2352 2666 // Meanwhile disable/enable controls depending on this Element selection. 2353 setControls(true, false, false, false, false, false, true, false, false, false, false, false);2667 //setControls(true, false, false, false, false, false, true, false, false, false, false, false); 2354 2668 } 2355 2669 card_layout.show(details_pane, ELEMENT); … … 2369 2683 attribute = null; 2370 2684 } 2371 atm = new AttributeTableModel(attributes, Dictionary.get(" MEM.Name"), Dictionary.get("MEM.Value"), "");2685 atm = new AttributeTableModel(attributes, Dictionary.get("GEMS.Name"), Dictionary.get("GEMS.Value"), ""); 2372 2686 //current_node.setModel(atm); 2373 2687 temp = null; … … 2380 2694 attributes = null; 2381 2695 // Meanwhile disable/enable controls depending on this Element selection. 2382 setControls(true, true, false, false, true, false, true, false, false, false, false, false);2696 // setControls(true, true, false, false, true, false, true, false, false, false, false, false); 2383 2697 break; 2384 2698 case GEMSNode.PROFILER: 2385 2699 // Meanwhile disable/enable controls depending on this Element selection. 2386 setControls(true, false, true, false, false, false, false, false, false, false, false, false);2700 //setControls(true, false, true, false, false, false, false, false, false, false, false, false); 2387 2701 default: 2388 2702 // Show a blank panel. … … 2392 2706 path = null; 2393 2707 atm = null; 2708 2709 //System.out.println("Tree eventselection"); 2394 2710 } 2395 2711 } 2396 2712 } 2397 2713 2398 private class MEMTreeCellRenderer2714 private class GEMSTreeCellRenderer 2399 2715 extends DefaultTreeCellRenderer { 2400 2716 public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { … … 2437 2753 static final public int ROOT = 3; 2438 2754 static final public int SET = 4; 2439 PopupListener() { 2755 2756 GEMS GEMSRef = null; 2757 PopupListener(GEMS g) { 2440 2758 setPopup = new JPopupMenu(); 2441 2759 subfieldPopup = new JPopupMenu(); 2442 2760 elementPopup = new JPopupMenu(); 2443 2761 attributePopup = new JPopupMenu(); 2444 2762 2763 //reference to our parent(GEMS), because some of the actionlisteners would not 2764 //work unless they were declared in GEMS, and I need a way to reference GEMS 2765 2766 GEMSRef = g; 2445 2767 2446 2768 //create the MenuItems … … 2448 2770 //set related popups 2449 2771 menuAddSet = new JMenuItem(); 2450 Dictionary.setText(menuAddSet,"Gems.Popup.menuAddSet"); 2772 //Dictionary.setText(menuAddSet,"GEMS.Popup.menuAddSet"); 2773 Dictionary.setText(menuAddSet,"GEMS.Add_Set_Tooltip"); 2451 2774 2452 2775 menuRenameSet = new JMenuItem(); 2453 Dictionary.setText(menuRenameSet,"G ems.Popup.menuRenameSet");2776 Dictionary.setText(menuRenameSet,"GEMS.Popup.menuRenameSet"); 2454 2777 2455 2778 menuAddElement =new JMenuItem(); 2456 Dictionary.setText(menuAddElement,"Gems.Popup.menuAddElement"); 2779 // Dictionary.setText(menuAddElement,"GEMS.Popup.menuAddElement"); 2780 Dictionary.setText(menuAddElement,"GEMS.Add_Element_Tooltip"); 2457 2781 2458 2782 menuAddAttributeSet = new JMenuItem(); 2459 Dictionary.setText(menuAddAttributeSet, "Gems.Popup.menuAddAttribute"); 2460 menuRemoveSet = new JMenuItem(); 2461 Dictionary.setText(menuRemoveSet,"Gems.Popup.menuRemoveSet"); 2462 //subfield related Gems.Popups 2783 // Dictionary.setText(menuAddAttributeSet, "GEMS.Popup.menuAddAttribute"); 2784 Dictionary.setText(menuAddAttributeSet, "GEMS.Add_Attribute_Tooltip"); 2785 2786 2787 menuRemoveSet = new JMenuItem(); 2788 //Dictionary.setText(menuRemoveSet,"GEMS.Popup.menuRemoveSet"); 2789 Dictionary.setText(menuRemoveSet,"GEMS.Remove_Set_Tooltip"); 2790 2791 //subfield related GEMS.Popups 2463 2792 menuRenameSubfield = new JMenuItem(); 2464 Dictionary.setText(menuRenameSubfield,"G ems.Popup.menuRenameSubfield");2793 Dictionary.setText(menuRenameSubfield,"GEMS.Popup.menuRenameSubfield"); 2465 2794 2466 2795 menuDeleteSubfield=new JMenuItem(); 2467 Dictionary.setText(menuDeleteSubfield,"G ems.Popup.menuRemoveSubfield");2796 Dictionary.setText(menuDeleteSubfield,"GEMS.Popup.menuRemoveSubfield"); 2468 2797 2469 2798 menuAddAttributeSubfield=new JMenuItem(); 2470 Dictionary.setText(menuAddAttributeSubfield,"Gems.Popup.menuAddAttribute"); 2471 2472 //element related Gems.Popups 2799 // Dictionary.setText(menuAddAttributeSubfield,"GEMS.Popup.menuAddAttribute"); 2800 Dictionary.setText(menuAddAttributeSubfield,"GEMS.Add_Attribute_Tooltip"); 2801 2802 //element related GEMS.Popups 2473 2803 menuRenameElement=new JMenuItem(); 2474 Dictionary.setText(menuRenameElement,"Gems.Popup.menuRenameElement"); 2804 // Dictionary.setText(menuRenameElement,"GEMS.Popup.menuRenameElement"); 2805 //Dictionary.setText(menuRenameElement,"GEMS.Rename_Element_Tooltip"); 2475 2806 2476 2807 menuDeleteElement=new JMenuItem(); 2477 Dictionary.setText(menuDeleteElement,"Gems.Popup.menuRemoveElement"); 2808 // Dictionary.setText(menuDeleteElement,"GEMS.Popup.menuRemoveElement"); 2809 Dictionary.setText(menuDeleteElement,"GEMS.Remove_Element_Tooltip"); 2478 2810 2479 2811 menuAddAttributeElement=new JMenuItem(); 2480 Dictionary.setText(menuAddAttributeElement,"Gems.Popup.menuAddAttribute"); 2812 //Dictionary.setText(menuAddAttributeElement,"GEMS.Popup.menuAddAttribute"); 2813 Dictionary.setText(menuAddAttributeElement,"GEMS.Add_Attribute_Tooltip"); 2481 2814 2482 2815 menuAddSubfield=new JMenuItem(); 2483 Dictionary.setText(menuAddSubfield,"Gems.Popup.menuAddSubfield"); 2816 Dictionary.setText(menuAddSubfield,"GEMS.Popup.menuAddSubfield"); 2817 //Dictionary.setText(menuAddSubfield,"GEMS.Add_Subfield"); 2484 2818 2485 //attribute related G ems.Popups2819 //attribute related GEMS.Popups 2486 2820 menuEditValue=new JMenuItem(); 2487 Dictionary.setText(menuEditValue,"Gems.Popup.menuEditValue"); 2821 //Dictionary.setText(menuEditValue,"GEMS.Popup.menuEditValue"); 2822 Dictionary.setText(menuEditValue,"GEMS.Edit_Value_Tooltip"); 2488 2823 2489 2824 menuDeleteAttribute=new JMenuItem(); 2490 Dictionary.setText(menuDeleteAttribute,"Gems.Popup.menuRemoveAttribute"); 2825 // Dictionary.setText(menuDeleteAttribute,"GEMS.Popup.menuRemoveAttribute"); 2826 Dictionary.setText(menuDeleteAttribute,"GEMS.Remove_Attribute_Tooltip"); 2491 2827 2492 2828 menuAddAttributeAttribute=new JMenuItem(); 2493 Dictionary.setText(menuAddAttributeAttribute,"Gems.Popup.menuAddAttribute"); 2829 // Dictionary.setText(menuAddAttributeAttribute,"GEMS.Popup.menuAddAttribute"); 2830 Dictionary.setText(menuAddAttributeAttribute,"GEMS.Add_Attribute_Tooltip"); 2494 2831 2495 2832 //start Associate the menu items with the appropriate popups: 2496 2833 //setPopup.add(menuRenameSet); 2497 //setPopup.add(menuAddSet);2834 setPopup.add(menuAddSet); 2498 2835 setPopup.add(menuAddAttributeSet); 2499 2836 setPopup.add(menuAddElement); … … 2528 2865 menuAddSubfield.addActionListener(this); 2529 2866 2867 // menuEditValue.addActionListener(new AddOrEditAttributeActionListener()); 2868 AddOrEditAttributeActionListener tes = new AddOrEditAttributeActionListener(); 2869 2530 2870 menuEditValue.addActionListener(new AddOrEditAttributeActionListener()); 2871 2872 //menuEditValue.addActionListener(this); 2873 2531 2874 menuDeleteAttribute.addActionListener(new RemoveAttributeActionListener()); 2532 2875 menuAddAttributeAttribute.addActionListener(new AddOrEditAttributeActionListener()); … … 2552 2895 // setPopup.show(e.getComponent(), 2553 2896 // e.getX(), e.getY()); 2554 2897 //System.out.println(e.getSource().toString()); 2898 2899 //SmarterTable table = (SmarterTable) e.getSource(); 2900 2901 /* if(table.getSelectedRow() <= -1) { 2902 2903 System.out.println("blahasdf"); 2904 } 2905 2906 table.getComponent(0) 2907 2908 System.out.println(.get); 2909 2910 2911 */ 2912 2555 2913 if(e.getSource() == mds_tree) { 2556 2914 try { … … 2607 2965 2608 2966 public void actionPerformed(ActionEvent e) { 2609 System.out.println("dsf"); 2967 // GEMSRef.add_or_edit_attribute_action_listener.actionPerformed(e); 2968 System.out.println("NO way hose"); 2610 2969 } 2611 2970 -
trunk/gli/src/org/greenstone/gatherer/gems/MSMUtils.java
r8270 r8581 297 297 static public TreeSet getAttributes(Element element) { 298 298 TreeSet attribute_tree = new TreeSet(); 299 300 301 // GemsLanguageManager gemsLangManager = new GemsLanguageManager("/home/arosmain/gsdl/gli/classes/xml/languages.xml"); 302 GEMSLanguageManager gemsLangManager = new GEMSLanguageManager(Configuration.gsdl_path + "/gli/classes/xml/languages.xml"); 303 304 String[] enabled_langs = gemsLangManager.getEnabledLanguageCodesToArray(); 305 299 306 for(Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) { 300 307 if(node instanceof Element) { … … 303 310 if(some_element_name.equals(StaticStrings.ATTRIBUTE_ELEMENT)) { 304 311 attribute_tree.add(new Attribute(some_element.getAttribute(StaticStrings.NAME_ATTRIBUTE), some_element.getAttribute(StaticStrings.LANGUAGE_ATTRIBUTE), MSMUtils.getValue(some_element))); 305 } 312 // System.out.println(some_element_name + "<- some_element nodes' value"); 313 314 315 } 306 316 else if(some_element_name.equals(StaticStrings.LANGUAGE_ELEMENT)) { 317 ///Added by Attila on Nov 05 04 318 // System.out.println(some_element_name + "<- some_element nodes' value"); 319 320 321 //// 322 307 323 String language_code = some_element.getAttribute(StaticStrings.CODE_ATTRIBUTE); 308 324 NodeList attribute_elements = some_element.getElementsByTagName(StaticStrings.ATTRIBUTE_ELEMENT); 325 309 326 for(int i = 0; i < attribute_elements.getLength(); i++) { 310 327 Element attribute_element = (Element) attribute_elements.item(i); 311 attribute_tree.add(new Attribute(attribute_element.getAttribute(StaticStrings.NAME_ATTRIBUTE), language_code, MSMUtils.getValue(attribute_element))); 328 329 330 //System.out.println("code is:" + language_code); 331 332 333 for(int k = 0; k < enabled_langs.length; k++){ 334 335 if(enabled_langs[k].trim().compareTo(some_element.getAttributes().item(0).getNodeValue().toString()) == 0){ 336 337 338 339 attribute_tree.add(new Attribute(attribute_element.getAttribute(StaticStrings.NAME_ATTRIBUTE), language_code, MSMUtils.getValue(attribute_element))); 340 attribute_element = null; 341 342 break; 343 } 344 //else { 345 // System.out.println(enabled_langs[k].trim().toString() + some_element.getAttributes().item(0).getNodeValue().toString()); 346 // } 347 348 } 349 // enabled_languages_split[k].toLowerCase().trim(); 350 351 352 // if(match_exit_flag == false) 353 // break; 354 //add language specific attr's: 355 //attribute_tree.add(new Attribute(attribute_element.getAttribute(StaticStrings.NAME_ATTRIBUTE), language_code, MSMUtils.getValue(attribute_element))); 312 356 attribute_element = null; 313 357 } … … 319 363 } 320 364 } 365 // attribute_tree. 321 366 return attribute_tree; 322 367 } -
trunk/gli/src/org/greenstone/gatherer/gems/MetadataSet.java
r8392 r8581 66 66 // the nmae of the collection if this set is collection-specific 67 67 private String collection = null; 68 //I realize I should be using getters and setters, but for a quick fix 69 public boolean set_changed = false; 68 //set_changed is check in msm(metadatasetmanager).save() and if this is true then we save 69 //the collection, otherwise we leave it as is 70 private boolean setChanged = false; 70 71 private String current_language_code; 71 72 /** The description of this metadata set. Cached as it takes more computation time. */ … … 124 125 } 125 126 } 126 /** Conditional copy constructor. 127 128 public boolean getSetChanged() { 129 130 return setChanged; 131 } 132 public void setSetChanged(boolean val) { 133 134 setChanged = val; 135 } 136 /** Conditional copy constructor. 127 137 * @param original The original metadata set to copy from. 128 138 * @param condition An <i>int</i> which matches one of the tree pruning filter types. -
trunk/gli/src/org/greenstone/gatherer/gems/MetadataSetManager.java
r8393 r8581 102 102 return mds; 103 103 } 104 104 public Vector getVectorSets() { 105 Vector sets = new Vector(); 106 107 File metadata_directory = new File(Utility.METADATA_DIR); 108 if (metadata_directory.exists()) { 109 // Load just those .mds files in this directory, and return them 110 File[] directory_files = metadata_directory.listFiles(); 111 for (int i = 0; i < directory_files.length; i++) { 112 File child_file = directory_files[i]; 113 if (!child_file.isDirectory() && child_file.getName().endsWith(".mds")) { 114 System.err.println("Found mds file: " + child_file); 115 MetadataSet metadata_set = loadMetadataSet(child_file); 116 // metadata_set.getName(); 117 sets.add(new String(child_file.toString() + " ^ " + metadata_set.getName())); 118 //model.add(null, metadata_set, GEMSNode.SET); 119 } 120 } 121 } 122 return sets; 123 } 124 public Object [] getVectorSetsToStringArray() { 125 126 return getSets().toArray(); 127 } 105 128 /** Add a value tree to a given metadata element represented as a GValueModel 106 129 * @param model The <strong>GValueTree</strong> model … … 288 311 return result; 289 312 } 290 313 291 314 292 315 /** Get the value tree that matches the given element. … … 465 488 //set has not changed(or has been recently saved 466 489 467 //if(set.set_changed == false){ 468 // continue; 469 //} 490 491 /* 492 if(set.getSetChanged() == false){ 493 continue; 494 }*/ 470 495 471 496 // just use the existing file path … … 477 502 478 503 479 504 // System.out.println("::: " + mds_file.toString()); 480 505 Utility.export(set.getDocument(), mds_file); 506 507 set.setSetChanged(false); 481 508 //What does setfile do? 482 509 //set.setFile(mds_file); … … 512 539 public void removeSet(MetadataSet set) { 513 540 mds_hashtable.remove(set.getNamespace()); 541 File f = set.getFile(); 542 f.delete(); 543 //System.out.println(f.toString() + Utility.METADATA_DIR); 514 544 // fireSetChanged(set); 515 545 }
Note:
See TracChangeset
for help on using the changeset viewer.