Changeset 6042
- Timestamp:
- 2003-11-28T17:48:54+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/mem/MetadataEditorManager.java
r5667 r6042 54 54 import org.greenstone.gatherer.gui.ModalDialog; 55 55 import org.greenstone.gatherer.gui.NonWhitespaceField; 56 import org.greenstone.gatherer.gui.TransformCharacterTextField; 56 57 import org.greenstone.gatherer.mem.Attribute; 57 58 import org.greenstone.gatherer.mem.AttributeTableModel; … … 59 60 import org.greenstone.gatherer.msm.ElementWrapper; 60 61 import org.greenstone.gatherer.msm.MetadataSet; 62 import org.greenstone.gatherer.util.Codec; 61 63 import org.greenstone.gatherer.util.Utility; 62 64 import org.greenstone.gatherer.valuetree.GValueModel; … … 713 715 else { 714 716 // Name combo box is enabled except when attributes are edited 715 name.setEnabled((source != edit_attribute));717 //name.setEnabled((source != edit_attribute)); 716 718 name_to_values.clear(); 717 719 name.clear(); … … 865 867 { 866 868 String name_str = name.getSelectedItem().toString(); 867 String value_str = value.getText();869 String value_str = Codec.transform(Codec.transformUnicode(value.getText()), Codec.TEXT_TO_DOM); 868 870 869 871 // Remove the existing attribute if this is an edit … … 898 900 { 899 901 String name_str = name.getSelectedItem().toString(); 900 String value_str = value.getText();902 String value_str = Codec.transform(Codec.transformUnicode(value.getText()), Codec.TEXT_TO_DOM); 901 903 902 904 // Remove the existing attribute if this is an edit … … 932 934 String name_str = name.getSelectedItem().toString(); 933 935 String language_code = (String) language_box.getSelectedItem(); 934 String value_str = value.getText();936 String value_str = Codec.transform(Codec.transformUnicode(value.getText()), Codec.TEXT_TO_DOM); 935 937 936 938 // Remove the existing attribute if this is an edit … … 980 982 setModal(true); 981 983 setSize(ADD_ELEMENT_SIZE); 982 984 // Creation 983 985 JPanel content_pane = (JPanel) getContentPane(); 984 986 content_pane.setBackground(Gatherer.config.getColor("coloring.collection_heading_background", false)); … … 1057 1059 if(source == ok_button) { 1058 1060 // Add then dispose 1059 String name_str = name_field.getText();1061 String name_str = Codec.transform(Codec.transformUnicode(name_field.getText()), Codec.TEXT_TO_DOM); 1060 1062 // If this element doesn't already exist. 1061 1063 if(!current_set.containsElement(name_str)) { … … 1191 1193 Object source = event.getSource(); 1192 1194 if(source == ok_button) { 1193 String name_str = name_field.getText();1195 String name_str = Codec.transform(Codec.transformUnicode(name_field.getText()), Codec.TEXT_TO_DOM); 1194 1196 // Ensure that this source doesn't already exist. 1195 1197 if(!Gatherer.c_man.msm.profiler.containsSource(name_str)) { … … 1250 1252 namespace_label.setPreferredSize(LABEL_SIZE); 1251 1253 Dictionary.setText(namespace_label, "MEM.Namespace"); 1252 namespace_field = new JTextField();1254 namespace_field = TransformCharacterTextField.createNamespaceTextField(); 1253 1255 namespace_field.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false)); 1254 1256 namespace_field.setForeground(Gatherer.config.getColor("coloring.collection_tree_foreground", false)); … … 1318 1320 if(source == ok_button) { 1319 1321 String namespace_str = namespace_field.getText(); 1320 String name_str = name_field.getText();1322 String name_str = Codec.transform(Codec.transformUnicode(name_field.getText()), Codec.TEXT_TO_DOM); 1321 1323 // Ensure the set doesn't already exist 1322 1324 if(Gatherer.c_man.msm.getSet(name_str) == null) { … … 1362 1364 private JButton ok_button = null; 1363 1365 private JTextArea value = null; 1364 private JTextField alias = null;1365 1366 private SmarterTree subject_tree = null; 1366 1367 … … 1400 1401 Dictionary.setTooltip(value, "MEM.Value_Tooltip"); 1401 1402 1402 JPanel alias_pane = new JPanel();1403 alias_pane.setOpaque(false);1404 JLabel alias_label = new JLabel();1405 alias_label.setOpaque(false);1406 alias_label.setPreferredSize(LABEL_SIZE);1407 Dictionary.setText(alias_label, "MEM.Alias");1408 1409 alias = new JTextField();1410 alias.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));1411 alias.setForeground(Gatherer.config.getColor("coloring.collection_tree_foreground", false));1412 alias.setSelectionColor(Gatherer.config.getColor("coloring.collection_selection_background", false));1413 alias.setSelectedTextColor(Gatherer.config.getColor("coloring.collection_selection_foreground", false));1414 Dictionary.setText(alias, "MEM.Alias_Tooltip");1415 1416 1403 JPanel button_pane = new JPanel(); 1417 1404 button_pane.setOpaque(false); … … 1445 1432 inner_pane.add(value_pane); 1446 1433 1447 alias_pane.setBorder(BorderFactory.createEmptyBorder(0,5,5,5));1448 alias_pane.setLayout(new BorderLayout());1449 alias_pane.add(alias_label, BorderLayout.WEST);1450 alias_pane.add(alias, BorderLayout.CENTER);1451 1452 center_pane.setLayout(new BorderLayout());1453 center_pane.add(inner_pane, BorderLayout.CENTER);1454 center_pane.add(alias_pane, BorderLayout.SOUTH);1455 1456 1434 button_pane.setBorder(BorderFactory.createEmptyBorder(0,5,5,5)); 1457 1435 button_pane.setLayout(new GridLayout(1,2,5,5)); … … 1460 1438 1461 1439 content_pane.setLayout(new BorderLayout()); 1462 content_pane.add( center_pane, BorderLayout.CENTER);1440 content_pane.add(inner_pane, BorderLayout.CENTER); 1463 1441 content_pane.add(button_pane, BorderLayout.SOUTH); 1464 1442 setLocation((Gatherer.config.screen_size.width - ADD_OR_EDIT_VALUE_SIZE.width) / 2, (Gatherer.config.screen_size.height - ADD_OR_EDIT_VALUE_SIZE.height) / 2); … … 1470 1448 Object source = event.getSource(); 1471 1449 if(source == ok_button) { 1450 String value_str = Codec.transform(Codec.transformUnicode(value.getText()), Codec.TEXT_TO_DOM); 1472 1451 // Now we action as necessary 1473 1452 GValueModel model = Gatherer.c_man.msm.getValueTree(current_element); … … 1475 1454 ///ystem.err.println("Add type - insert node: " + value.getText() + " into " + subject_node); 1476 1455 // Add this value to the tree. 1477 model.addValue(value .getText(), subject_node, alias.getText());1456 model.addValue(value_str, subject_node); 1478 1457 } 1479 1458 else { 1480 1459 // Rewrite this value in the DOM model. Note that this will automatically rewrite all assignments as they are live references. 1481 current_value_node.setValue(value.getText()); 1482 current_value_node.setAlias(alias.getText()); 1460 current_value_node.setValue(value_str); 1483 1461 // Now insert the node into the currently selected subject, but only if the parent has changed. 1484 1462 if(subject_node != current_value_node.getParent()) { … … 1551 1529 } 1552 1530 value.setText(""); 1553 alias.setText("");1554 1531 Dictionary.setText(this, "MEM.AddValue"); 1555 1532 } … … 1562 1539 subject_node = (GValueNode) model.getRoot(); 1563 1540 } 1564 value.setText(current_value_node.toString()); 1565 alias.setText(current_value_node.getAlias()); 1541 value.setText(Codec.transform(current_value_node.toString(), Codec.DOM_TO_TEXT)); 1566 1542 Dictionary.setText(this, "MEM.EditValue"); 1567 1543 } … … 1579 1555 1580 1556 public void dispose() { 1581 alias = null;1582 1557 cancel_button = null; 1583 1558 ok_button = null; … … 1635 1610 /** Invoked after nodes have been inserted into the tree. */ 1636 1611 public void treeNodesInserted(TreeModelEvent e) { 1637 element_values.expandPath(new TreePath(element_values.getModel().getRoot())); 1612 if(element_values != null && element_values.getModel() != null && element_values.getModel().getRoot() != null) { 1613 element_values.expandPath(new TreePath(element_values.getModel().getRoot())); 1614 } 1638 1615 } 1639 1616 /** Invoked after nodes have been removed from the tree. */
Note:
See TracChangeset
for help on using the changeset viewer.