- Timestamp:
- 2005-01-13T11:52:44+13:00 (19 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/gems
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java
r8881 r8896 1 /**1 /** 2 2 *######################################################################### 3 3 * … … 86 86 /** The default size of the editor dialog. */ 87 87 static final private Dimension ADD_ELEMENT_SIZE = new Dimension(400,125); 88 static final private Dimension RENAME_ELEMENT_SIZE = new Dimension(400, 95); 88 89 static final private Dimension ADD_FILE_SIZE = new Dimension(400,125); 89 90 static final private Dimension ADD_SET_SIZE = new Dimension(400,150); 91 static final private Dimension RENAME_SET_SIZE = new Dimension(400,120); 90 92 static final private Dimension OPEN_SETS_SIZE = new Dimension(400,135); 91 93 static final private Dimension ADD_OR_EDIT_ATTRIBUTE_SIZE = new Dimension(600,325); … … 319 321 set_attributes.setSelectedTextColor(config.getColor("coloring.collection_selection_foreground", false)); 320 322 set_attributes.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 321 set_attributes.addMouseListener(popupListener); 323 set_attributes.addMouseListener(popupListener); 324 set_attributes.addMouseListener(new AddOrEditAttributeActionListener()); 322 325 set_attributes.addKeyListener(new RemoveAttributeActionListener()); //Listen for DELETE key 323 326 JPanel element_details_pane = new JPanel(); … … 351 354 element_attributes.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 352 355 element_attributes.addMouseListener(popupListener); 356 element_attributes.addMouseListener(new AddOrEditAttributeActionListener()); 353 357 element_attributes.addKeyListener(new RemoveAttributeActionListener()); //For the DELETE key 354 358 … … 976 980 private class AddOrEditAttributeActionListener 977 981 extends ModalDialog 978 implements ActionListener {979 980 981 982 983 984 985 986 987 private Vector attributeLists= null;988 982 implements ActionListener, MouseListener { 983 private boolean add_type = true; 984 private ComboArea value = null; 985 private JButton cancel_button = null; 986 private JButton ok_button = null; 987 private JComboBox language_box = null; 988 private GComboBox name = null; 989 private HashMap name_to_values = null; 990 private JLabel target = null; 991 private JLabel target_label = null; 992 private Vector attributeLists = null; 989 993 990 994 //org.w3c.dom.Document lang = Utility.parse("/home/arosmain/gsdl/gli/classes/xml/languages.xml", false); … … 1030 1034 JPanel boxes_pane = new JPanel(); 1031 1035 1032 JLabeltarget_label = new JLabel();1036 target_label = new JLabel(); 1033 1037 target_label.setOpaque(false); 1034 1038 Dictionary.setText(target_label, "GEMS.Target"); 1035 1039 target = new JLabel(); 1036 1040 target.setOpaque(false); 1041 //Dictionary.setText(target, "this is the target"); //debug 1037 1042 1038 1043 JLabel name_label = new JLabel(); … … 1125 1130 // create dom object for language_Box 1126 1131 //GEMSLanguageManager GemsLangManager = new GEMSLanguageManager("/home/arosmain/gsdl/gli/classes/xml/languages.xml"); 1127 1132 GEMSLanguageManager GemsLangManager = new GEMSLanguageManager(Configuration.gsdl_path + "/gli/classes/xml/languages.xml"); 1128 1133 1129 1134 Vector languagecodes = GemsLangManager.getLanguageCodes(); … … 1138 1143 //System.out.println(code); 1139 1144 } 1145 1146 //Handle double clicks in the table. 1147 public void mouseClicked(MouseEvent e) 1148 { 1149 if(e.getSource() == element_attributes || e.getSource() == set_attributes) 1150 { 1151 if(e.getClickCount() == 2) //Double click 1152 { 1153 //Show the Edit Attribute dialog 1154 this.menuEditValue(); 1155 this.editAttribute(); 1156 } 1157 } 1158 } 1159 //required by MouseListener 1160 public void mouseEntered(MouseEvent e) 1161 { 1162 } 1163 //required by MouseListener 1164 public void mouseExited(MouseEvent e) 1165 { 1166 } 1167 //required by MouseListener 1168 public void mousePressed(MouseEvent e) 1169 { 1170 } 1171 //required by MouseListener 1172 public void mouseReleased(MouseEvent e) 1173 { 1174 } 1175 1140 1176 /** 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. 1141 1177 * @param event An <strong>ActionEvent</strong> containing information about the event. 1142 1178 */ 1143 1144 1145 1179 public void actionPerformed(ActionEvent event) { 1146 1180 Object source = event.getSource(); 1147 AttributeTableModel tablemodel; 1181 AttributeTableModel tablemodel = null; 1182 AttributeTableModel model = null; 1148 1183 String prevLang = new String(""); 1149 1184 String prevValue = new String(""); 1150 1185 1186 if(current_element != null) 1187 { 1188 target.setText(current_element.getName()); 1189 } 1190 else if(current_set != null) 1191 { 1192 Dictionary.setText(target_label, "GEMS.Set"); 1193 target.setText(current_set.toString()); 1194 } 1195 1151 1196 //allow user to choose language when they create attr 1152 1153 1154 1155 1197 /* 1156 1198 if(source == popupListener.menuAddAttributeAttribute) { 1157 1199 add_type = true; 1158 language_box.setEnabled(true); 1200 language_box.setEnabled(true); 1201 System.err.println("source is menuAddAttributeAttribute"); //Debug 1159 1202 }//end if source== menuaddattributeattribute 1160 else if (source == popupListener.menuEditValue){ 1161 add_type = false; 1162 //grab the table model based on what is currently selected 1163 switch(current_attribute_type) { 1164 case GEMSNode.COLLECTION: 1165 tablemodel = (AttributeTableModel) profile_attributes.getModel(); 1166 //String prevLang = tablemodel.getValueAt(current_attribute,0).toString(); 1167 //String prevValue = tablemodel.getValueAt(current_attribute,1).toString(); 1168 1169 break; 1170 case GEMSNode.SET: 1171 tablemodel = (AttributeTableModel) set_attributes.getModel(); 1172 //grab value in table( 1173 prevLang = tablemodel.getValueAt(current_attribute,0).toString(); 1174 prevValue = tablemodel.getValueAt(current_attribute,1).toString(); 1175 1176 break; 1177 case GEMSNode.ELEMENT: 1178 tablemodel = (AttributeTableModel) element_attributes.getModel(); 1179 //grab values in table( lang and value) 1180 prevLang = tablemodel.getValueAt(current_attribute,1).toString(); 1181 prevValue = tablemodel.getValueAt(current_attribute,2).toString(); 1182 1183 break; 1184 default: 1185 //by default grab element_attr's 1186 tablemodel = (AttributeTableModel) element_attributes.getModel(); 1187 prevLang = tablemodel.getValueAt(current_attribute,1).toString(); 1188 prevValue = tablemodel.getValueAt(current_attribute,2).toString(); 1189 1190 break; 1191 } 1192 language_box.setEnabled(false); 1193 1194 //if a set attr is selected, then do not do any lang operations, other than setting index to -1 1195 if(current_attribute_type != GEMSNode.SET) { 1196 1197 //set the current language to show up in language_box(no lang if no lang specified) 1198 if(prevLang == null || prevLang.compareTo(" ")==0 || prevLang.compareTo("") == 0 || prevLang.compareTo(" ")==0) { 1199 language_box.setSelectedIndex(-1); 1200 1201 } 1202 else { 1203 language_box.setSelectedItem(prevLang.toLowerCase()); 1204 } 1205 }// end currattr != GEMSnode.set 1206 else { 1207 1208 language_box.setSelectedIndex(-1); 1209 1210 }// end currattr == GEMSnode.set 1211 1212 value.setText(prevValue); 1203 else*/ if (source == popupListener.menuEditValue){ 1204 this.menuEditValue(); 1213 1205 1214 1206 }//end if source == popupListener.menuEditValue) … … 1216 1208 if(source == ok_button) { 1217 1209 boolean success = true; 1218 AttributeTableModel model;1219 1210 1220 1211 // Add or edit a collect/set/element attribute … … 1238 1229 // Hide dialog 1239 1230 1231 atLeastOneSetChanged = true; 1240 1232 setVisible(false); 1241 1233 return; 1242 1234 } 1235 else //debug 1236 { 1237 System.err.println("No success by OK button."); //debug 1238 } 1243 1239 } 1244 1240 else if(source == cancel_button) { … … 1248 1244 } 1249 1245 else if(source == name) { 1246 //System.err.println("source is name"); 1250 1247 Object object = name.getSelectedItem(); 1251 1248 if(object != null) { … … 1262 1259 } 1263 1260 } 1264 } 1265 else if (source == popupListener.menuAddAttributeAttribute){ 1266 1267 for(int i = 0; i < attributeLists.size(); i++) { 1268 name.add(attributeLists.get(i).toString()); 1261 //setVisible(true); 1262 } 1263 else if (source == popupListener.menuAddAttributeAttribute || source == popupListener.menuAddAttributeSet || source == popupListener.menuAddAttributeElement){ 1264 1265 Dictionary.setText(this, "GEMS.AddAttribute"); 1266 for(int i = 0; i < attributeLists.size(); i++) { 1267 name.add(attributeLists.get(i).toString()); 1269 1268 1270 } 1271 name.setEnabled(true); 1269 } 1270 1271 1272 name.setEnabled(true); 1273 setVisible(true); 1272 1274 } 1273 1275 /* else if (source == popupListener.menuAddAttributeAttribute){ … … 1393 1395 // }*/ 1394 1396 else if(current_attribute != -1) { 1395 1396 //System.out.println(source.toString()+"\n"); 1397 AttributeTableModel model = null; 1398 switch(current_attribute_type) { 1399 case GEMSNode.COLLECTION: 1400 model = (AttributeTableModel) profile_attributes.getModel(); 1401 break; 1402 case GEMSNode.ELEMENT: 1403 model = (AttributeTableModel) element_attributes.getModel(); 1404 break; 1405 case GEMSNode.SET: 1406 model = (AttributeTableModel) set_attributes.getModel(); 1407 break; 1408 } 1409 add_type = false; 1410 Dictionary.setText(this, "GEMS.EditAttribute"); 1411 String name_str = (String) model.getValueAt(current_attribute, 0); 1412 String value_str = (String) model.getValueAt(current_attribute, model.getColumnCount() - 1); 1413 model = null; 1414 // Retrieve the appropriate value model 1415 java.util.List values = (java.util.List) name_to_values.get(name_str); 1416 // Only possible for collection file selections. 1417 if(values == null) { 1418 values = msm.getElements(); 1419 } 1420 name.setSelectedItem(name_str); 1421 name_str = null; 1422 for(int i = 0; i < values.size(); i++) { 1423 Object temp_value = values.get(i); 1424 if(temp_value instanceof ElementWrapper) { 1425 value.add(new NameElementWrapperEntry(temp_value)); 1426 } 1427 else { 1428 value.add(temp_value); 1429 } 1430 } 1431 values = null; 1432 value.setSelectedItem(value_str); 1433 value_str = null; 1434 1435 } 1436 // } 1437 setVisible(true); 1397 this.editAttribute(); 1398 } 1399 1438 1400 source = null; 1439 1401 } 1402 1403 private void menuEditValue() 1404 { 1405 AttributeTableModel tablemodel = null; 1406 1407 String prevLang = new String(""); 1408 String prevValue = new String(""); 1409 1410 add_type = false; 1411 //grab the table model based on what is currently selected 1412 switch(current_attribute_type) { 1413 case GEMSNode.COLLECTION: 1414 tablemodel = (AttributeTableModel) profile_attributes.getModel(); 1415 //String prevLang = tablemodel.getValueAt(current_attribute,0).toString(); 1416 //String prevValue = tablemodel.getValueAt(current_attribute,1).toString(); 1417 1418 break; 1419 case GEMSNode.SET: 1420 tablemodel = (AttributeTableModel) set_attributes.getModel(); 1421 //grab value in table( 1422 prevLang = tablemodel.getValueAt(current_attribute,0).toString(); 1423 prevValue = tablemodel.getValueAt(current_attribute,1).toString(); 1424 1425 break; 1426 case GEMSNode.ELEMENT: 1427 tablemodel = (AttributeTableModel) element_attributes.getModel(); 1428 //grab values in table( lang and value) 1429 prevLang = tablemodel.getValueAt(current_attribute,1).toString(); 1430 prevValue = tablemodel.getValueAt(current_attribute,2).toString(); 1431 1432 break; 1433 default: 1434 //by default grab element_attr's 1435 tablemodel = (AttributeTableModel) element_attributes.getModel(); 1436 prevLang = tablemodel.getValueAt(current_attribute,1).toString(); 1437 prevValue = tablemodel.getValueAt(current_attribute,2).toString(); 1438 1439 break; 1440 } 1441 language_box.setEnabled(false); 1442 1443 //if a set attr is selected, then do not do any lang operations, other than setting index to -1 1444 if(current_attribute_type != GEMSNode.SET) { 1445 1446 //set the current language to show up in language_box(no lang if no lang specified) 1447 if(prevLang == null || prevLang.compareTo(" ")==0 || prevLang.compareTo("") == 0 || prevLang.compareTo(" ")==0) { 1448 language_box.setSelectedIndex(-1); 1449 1450 } 1451 else { 1452 language_box.setSelectedItem(prevLang.toLowerCase()); 1453 } 1454 }// end currattr != GEMSnode.set 1455 else { 1456 1457 language_box.setSelectedIndex(-1); 1458 1459 }// end currattr == GEMSnode.set 1460 1461 value.setText(prevValue); 1462 1463 } 1464 1465 private void editAttribute() 1466 { 1467 AttributeTableModel model = null; 1468 Dictionary.setText(this, "GEMS.EditAttribute"); 1469 //System.out.println(source.toString()+"\n"); 1470 1471 switch(current_attribute_type) { 1472 case GEMSNode.COLLECTION: 1473 model = (AttributeTableModel) profile_attributes.getModel(); 1474 break; 1475 case GEMSNode.ELEMENT: 1476 model = (AttributeTableModel) element_attributes.getModel(); 1477 break; 1478 case GEMSNode.SET: 1479 model = (AttributeTableModel) set_attributes.getModel(); 1480 break; 1481 } 1482 add_type = false; 1483 String name_str = (String) model.getValueAt(current_attribute, 0); 1484 String value_str = (String) model.getValueAt(current_attribute, model.getColumnCount() - 1); 1485 model = null; 1486 // Retrieve the appropriate value model 1487 java.util.List values = (java.util.List) name_to_values.get(name_str); 1488 // Only possible for collection file selections. 1489 if(values == null) { 1490 values = msm.getElements(); 1491 } 1492 name.setSelectedItem(name_str); 1493 name_str = null; 1494 for(int i = 0; i < values.size(); i++) { 1495 Object temp_value = values.get(i); 1496 if(temp_value instanceof ElementWrapper) { 1497 value.add(new NameElementWrapperEntry(temp_value)); 1498 } 1499 else { 1500 value.add(temp_value); 1501 } 1502 } 1503 values = null; 1504 value.setSelectedItem(value_str); 1505 value_str = null; 1506 setVisible(true); 1507 } 1440 1508 1441 1509 private boolean addOrEditCollectionAttribute(AttributeTableModel model) … … 2664 2732 2665 2733 2734 2666 2735 /** 2667 Class to hand renaming of a set. 2668 2669 Author: Matthew Whyte 2670 Date last modified: 22/12/04 2671 */ 2672 private class RenameSetActionListener extends AddSetActionListener implements ActionListener { 2673 /** 2674 To do: everything!!!!! --Matthew 2675 */ 2676 2677 2678 //Constructor 2679 public RenameSetActionListener() 2680 { 2681 } 2682 2683 /** 2684 Any implementation of ActionListener must include this method so that we can be informed when an action has occured. 2685 @param event An <string>ActionEvent</strong> containing information about the event. 2686 */ 2687 public void actionPerformed(ActionEvent event) 2688 { 2689 System.err.println("You chose to rename a set!!"); //debug 2690 } 2691 } 2692 2693 2694 /** 2695 Class to hand renaming of an element. 2736 Class to handle renaming of a set and/or it's namespace. 2696 2737 2697 2738 Author: Matthew Whyte 2698 2739 Date last modified: 10/01/05 2699 2740 */ 2700 private class Rename ElementActionListener extends ModalDialog implements ActionListener {2741 private class RenameSetActionListener extends ModalDialog implements ActionListener { 2701 2742 2702 2743 private JButton cancel_button = null; 2703 2744 private JButton ok_button = null; 2704 private JLabel label = null; 2705 private NonWhitespaceField name_field = null; 2706 2707 2708 public RenameElementActionListener() { 2745 private JTextField name_field = null; 2746 private JTextField namespace_field = null; 2747 2748 public RenameSetActionListener() { 2709 2749 super(self); 2710 2750 setModal(true); 2711 setSize(ADD_ELEMENT_SIZE); 2751 setSize(RENAME_SET_SIZE); 2752 Dictionary.setText(this, "GEMS.Rename_Set"); 2753 2712 2754 // Creation 2713 2755 JPanel content_pane = (JPanel) getContentPane(); … … 2716 2758 center_pane.setOpaque(false); 2717 2759 2760 JPanel label_pane = new JPanel(); 2761 JPanel boxes_pane = new JPanel(); 2762 2763 JLabel namespace_label = new JLabel(); 2764 namespace_label.setOpaque(false); 2765 Dictionary.setText(namespace_label, "GEMS.Namespace"); 2766 namespace_field = TransformCharacterTextField.createNamespaceTextField(); 2767 namespace_field.setBackground(config.getColor("coloring.collection_tree_background", false)); 2768 namespace_field.setForeground(config.getColor("coloring.collection_tree_foreground", false)); 2769 namespace_field.setSelectionColor(config.getColor("coloring.collection_selection_background", false)); 2770 namespace_field.setSelectedTextColor(config.getColor("coloring.collection_selection_foreground", false)); 2771 Dictionary.setTooltip(namespace_field, "GEMS.Rename_Namespace_Tooltip"); 2772 2773 JLabel name_label = new JLabel(); 2774 name_label.setOpaque(false); 2775 Dictionary.setText(name_label, "GEMS.Name"); 2776 name_field = new JTextField(); 2777 name_field.setBackground(config.getColor("coloring.collection_tree_background", false)); 2778 name_field.setForeground(config.getColor("coloring.collection_tree_foreground", false)); 2779 name_field.setSelectionColor(config.getColor("coloring.collection_selection_background", false)); 2780 name_field.setSelectedTextColor(config.getColor("coloring.collection_selection_foreground", false)); 2781 Dictionary.setTooltip(name_field, "GEMS.Rename_Name_Tooltip"); 2782 2783 JPanel button_pane = new JPanel(); 2784 button_pane.setOpaque(false); 2785 2786 ok_button = new GLIButton(); 2787 ok_button.setMnemonic(KeyEvent.VK_O); 2788 Dictionary.setBoth(ok_button, "General.OK", "General.OK_Tooltip"); 2789 cancel_button = new GLIButton(); 2790 cancel_button.setMnemonic(KeyEvent.VK_C); 2791 Dictionary.setBoth(cancel_button, "General.Cancel", "General.Pure_Cancel_Tooltip"); 2792 TextFieldEnabler ok_button_enabler = new TextFieldEnabler(ok_button); 2793 2794 // Connection 2795 cancel_button.addActionListener(this); 2796 ok_button.addActionListener(this); 2797 ok_button_enabler.add(name_field); 2798 ok_button_enabler.add(namespace_field); 2799 2800 // Layout 2801 label_pane.setLayout(new GridLayout(2,1)); 2802 label_pane.add(name_label); 2803 label_pane.add(namespace_label); 2804 boxes_pane.setLayout(new GridLayout(2,1)); 2805 boxes_pane.add(name_field); 2806 boxes_pane.add(namespace_field); 2807 2808 center_pane.setLayout(new BorderLayout(5,0)); 2809 center_pane.add(label_pane, BorderLayout.WEST); 2810 center_pane.add(boxes_pane, BorderLayout.CENTER); 2811 2812 button_pane.setLayout(new GridLayout(1,2,0,5)); 2813 button_pane.add(ok_button); 2814 button_pane.add(cancel_button); 2815 2816 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 2817 content_pane.setLayout(new BorderLayout()); 2818 content_pane.add(center_pane, BorderLayout.CENTER); 2819 content_pane.add(button_pane, BorderLayout.SOUTH); 2820 2821 setLocation((config.screen_size.width - RENAME_SET_SIZE.width) / 2, (config.screen_size.height - RENAME_SET_SIZE.height) / 2); 2822 } 2823 2824 private boolean a_set_exists_with_this_namespace(String namespace){ 2825 Vector p = msm.getSets(); 2826 boolean flag = false; 2827 for(int k = 0; k < p.size(); k++){ 2828 MetadataSet s = (MetadataSet)p.get(k); 2829 2830 if(s.getNamespace().compareTo(namespace) == 0){ 2831 flag = true; 2832 } 2833 2834 2835 } 2836 2837 return flag; 2838 } 2839 2840 2841 /** 2842 Any implementation of ActionListener must include this method so that we can be informed when an action as occured on our registered component, 2843 allowing us to 2844 * @param event An <strong>ActionEvent</strong> containing information about the event. 2845 */ 2846 public void actionPerformed(ActionEvent event) { 2847 Object source = event.getSource(); 2848 2849 if(source == ok_button) 2850 { 2851 String namespace_str = namespace_field.getText(); 2852 String name_str = Codec.transform(Codec.transformUnicode(name_field.getText()), Codec.TEXT_TO_DOM); 2853 //Note: The name in name_str is language dependent. However, currently GEMS does not create new sets with different names for different languages. 2854 String current_set_namespace = current_set.getNamespace(); 2855 2856 //System.err.println("namespace_str is: " + namespace_str); 2857 //System.err.println("name_str is: " + name_str); 2858 //System.err.println("current_set_namespace is: " + current_set_namespace); 2859 2860 //Ensure that the namespace is unique. 2861 if(!(a_set_exists_with_this_namespace(namespace_str)) || (namespace_str.equals(current_set_namespace))) 2862 { 2863 //Hide the set that are about to rename 2864 mds_tree.clearSelection(); 2865 model.remove(current_set.toString(), GEMSNode.SET); 2866 2867 //Rename set & namespace 2868 msm.renameSet(current_set, namespace_str, name_str); 2869 2870 //Add (renamed) set back to tree 2871 model.add(null, current_set, GEMSNode.SET); 2872 2873 //Clean up 2874 card_layout.show(details_pane, BLANK); // Show a blank panel. 2875 ignore = false; 2876 atLeastOneSetChanged = true; 2877 setVisible(false); 2878 } 2879 2880 // Otherwise show an error message and do not proceed. 2881 else 2882 { 2883 JOptionPane.showMessageDialog(self, Dictionary.get("GEMS.Set_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 2884 } 2885 name_str = null; 2886 2887 } 2888 2889 else if(source == cancel_button) 2890 { 2891 setVisible(false); //hide dialog 2892 } 2893 else 2894 { 2895 name_field.setText(current_set.getName()); //getName() doesn't work properly. Need to update MetadataSet.java 2896 //getName() only doesn't work when the name is exactly the same as the namespace. 2897 namespace_field.setText(current_set.getNamespace()); 2898 setVisible(true); //Show the dialog 2899 } 2900 2901 source = null; 2902 } 2903 2904 2905 public void dispose() { 2906 cancel_button = null; 2907 ok_button = null; 2908 name_field = null; 2909 //System.err.println("Dispose AddElementActionListener"); 2910 super.dispose(); 2911 } 2912 2913 } 2914 2915 /** 2916 Class to hand renaming of an element. 2917 2918 Author: Matthew Whyte 2919 Date last modified: 10/01/05 2920 */ 2921 private class RenameElementActionListener extends ModalDialog implements ActionListener { 2922 2923 private JButton cancel_button = null; 2924 private JButton ok_button = null; 2925 //private JLabel label = null; 2926 private NonWhitespaceField name_field = null; 2927 2928 2929 public RenameElementActionListener() { 2930 super(self); 2931 setModal(true); 2932 setSize(RENAME_ELEMENT_SIZE); 2933 // Creation 2934 JPanel content_pane = (JPanel) getContentPane(); 2935 content_pane.setBackground(config.getColor("coloring.collection_heading_background", false)); 2936 JPanel center_pane = new JPanel(); 2937 center_pane.setOpaque(false); 2938 2718 2939 JPanel labels_pane = new JPanel(); 2719 2940 labels_pane.setOpaque(false); 2720 JLabel set_label = new JLabel();2721 set_label.setOpaque(false);2722 Dictionary.setText(set_label, "GEMS.Rename_Element");2723 label = new JLabel();2724 label.setOpaque(false);2941 //JLabel set_label = new JLabel(); 2942 //set_label.setOpaque(false); 2943 //Dictionary.setText(set_label, "GEMS.Rename_Element"); 2944 //label = new JLabel(); 2945 //label.setOpaque(false); 2725 2946 2726 2947 JPanel values_pane = new JPanel(); … … 2748 2969 TextFieldEnabler ok_button_enabler = new TextFieldEnabler(ok_button); 2749 2970 2971 Dictionary.setText(this, "GEMS.Rename_Element"); 2972 2750 2973 // Connection 2751 2974 cancel_button.addActionListener(this); … … 2755 2978 // Layout 2756 2979 labels_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0)); 2757 labels_pane.setLayout(new GridLayout( 2,1));2758 labels_pane.add(set_label);2980 labels_pane.setLayout(new GridLayout(1,1)); 2981 //labels_pane.add(set_label); 2759 2982 labels_pane.add(name_label); 2760 2983 2761 2984 values_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0)); 2762 values_pane.setLayout(new GridLayout( 2,1));2763 values_pane.add(label);2985 values_pane.setLayout(new GridLayout(1,1)); 2986 //values_pane.add(label); 2764 2987 values_pane.add(name_field); 2765 2988 … … 2833 3056 else 2834 3057 { 2835 name_field.setText( ""); //remove old text3058 name_field.setText(current_element.getName()); //show old name 2836 3059 setVisible(true); //Show the dialog 2837 3060 } … … 2845 3068 ok_button = null; 2846 3069 name_field = null; 2847 label = null;3070 //label = null; 2848 3071 //System.err.println("Dispose AddElementActionListener"); 2849 3072 super.dispose(); … … 2851 3074 2852 3075 } 3076 3077 2853 3078 2854 3079 … … 3213 3438 } 3214 3439 3440 3215 3441 //PopupListener is our main manager for all right-click popups 3216 3442 class PopupListener extends MouseAdapter implements ActionListener{ -
trunk/gli/src/org/greenstone/gatherer/gems/MetadataSet.java
r8881 r8896 407 407 return root.getAttribute("lastchanged"); 408 408 } 409 /** Method to get this metadata sets name. Note that this is language specific, so we determine the desired language from the Dictionary. If no such entry exists, first try returning the english version and failing that the first name found. 409 410 /** Method to get this metadata sets name. Note that this is language specific, so we determine the desired language from the Dictionary. 411 If no such entry exists, first try returning the english version and failing that the first name found. 410 412 * @return A <strong>String</strong> which contains its name. 411 413 */ … … 430 432 return root.getAttribute("namespace"); 431 433 } 434 435 /** 436 Method to change this metadata set's namespace 437 @param: The new namespace as a <strong>String</strong> 438 */ 439 public void setNamespace(String new_namespace) 440 { 441 root.setAttribute("namespace", new_namespace); 442 } 443 432 444 /** Method to retrieve the root element, i.e. the Document Element, of the DOM model behind this metadata set. 433 445 * @return An <strong>Element</strong> which is at the root of the modal. -
trunk/gli/src/org/greenstone/gatherer/gems/MetadataSetManager.java
r8881 r8896 103 103 return mds; 104 104 } 105 106 /** 107 Method to rename a metadata set. 108 @param: current_set: The metadata set to rename 109 @param: new_namspace: The new namespace for the current_set 110 @param: new_name: The new (language-dependent) name for the current_set. Multiple names in different languages is not yet implemented in GEMS, but when it is, this method will need to be updated. 111 112 @Pre: There is not another metadata set with namespace new_namespace. Ie namespaces are unique. 113 @Post: The Name and namespace in the metadata file will have been updated. The filename will stay the same. 114 115 @author Matthew Whyte 116 Date last modified: 10/01/12 117 */ 118 public void renameSet(MetadataSet current_set, String new_namespace, String new_name) 119 { 120 if(current_set != null) 121 { 122 //Update the namespace 123 current_set.setNamespace(new_namespace); 124 125 //Update the name 126 //Element name = new Element(current_set.getElement(Name)); 127 current_set.setName(new_name); 128 } 129 130 else 131 { 132 System.err.println("No such set " + current_set); 133 } 134 } 135 136 105 137 public Vector getVectorSets() { 106 138 Vector sets = new Vector();
Note:
See TracChangeset
for help on using the changeset viewer.