Changeset 6042


Ignore:
Timestamp:
2003-11-28T17:48:54+13:00 (20 years ago)
Author:
jmt12
Message:

All typed in values are correctly handled by the various Codec transforms

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/mem/MetadataEditorManager.java

    r5667 r6042  
    5454import org.greenstone.gatherer.gui.ModalDialog;
    5555import org.greenstone.gatherer.gui.NonWhitespaceField;
     56import org.greenstone.gatherer.gui.TransformCharacterTextField;
    5657import org.greenstone.gatherer.mem.Attribute;
    5758import org.greenstone.gatherer.mem.AttributeTableModel;
     
    5960import org.greenstone.gatherer.msm.ElementWrapper;
    6061import org.greenstone.gatherer.msm.MetadataSet;
     62import org.greenstone.gatherer.util.Codec;
    6163import org.greenstone.gatherer.util.Utility;
    6264import org.greenstone.gatherer.valuetree.GValueModel;
     
    713715        else {
    714716        // Name combo box is enabled except when attributes are edited
    715         name.setEnabled((source != edit_attribute));
     717        //name.setEnabled((source != edit_attribute));
    716718        name_to_values.clear();
    717719        name.clear();
     
    865867    {
    866868        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);
    868870
    869871        // Remove the existing attribute if this is an edit
     
    898900    {
    899901        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);
    901903
    902904        // Remove the existing attribute if this is an edit
     
    932934        String name_str = name.getSelectedItem().toString();
    933935        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);
    935937
    936938        // Remove the existing attribute if this is an edit
     
    980982        setModal(true);
    981983        setSize(ADD_ELEMENT_SIZE);
    982                 // Creation
     984        // Creation
    983985        JPanel content_pane = (JPanel) getContentPane();
    984986        content_pane.setBackground(Gatherer.config.getColor("coloring.collection_heading_background", false));
     
    10571059        if(source == ok_button) {
    10581060        // 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);
    10601062        // If this element doesn't already exist.
    10611063        if(!current_set.containsElement(name_str)) {
     
    11911193        Object source = event.getSource();
    11921194        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);
    11941196        // Ensure that this source doesn't already exist.
    11951197        if(!Gatherer.c_man.msm.profiler.containsSource(name_str)) {
     
    12501252        namespace_label.setPreferredSize(LABEL_SIZE);
    12511253        Dictionary.setText(namespace_label, "MEM.Namespace");
    1252         namespace_field = new JTextField();
     1254        namespace_field = TransformCharacterTextField.createNamespaceTextField();
    12531255        namespace_field.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
    12541256        namespace_field.setForeground(Gatherer.config.getColor("coloring.collection_tree_foreground", false));
     
    13181320        if(source == ok_button) {
    13191321        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);
    13211323        // Ensure the set doesn't already exist
    13221324        if(Gatherer.c_man.msm.getSet(name_str) == null) {
     
    13621364    private JButton ok_button = null;
    13631365    private JTextArea value = null;
    1364     private JTextField alias = null;
    13651366    private SmarterTree subject_tree = null;
    13661367
     
    14001401        Dictionary.setTooltip(value, "MEM.Value_Tooltip");
    14011402
    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 
    14161403        JPanel button_pane = new JPanel();
    14171404        button_pane.setOpaque(false);
     
    14451432        inner_pane.add(value_pane);
    14461433
    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 
    14561434        button_pane.setBorder(BorderFactory.createEmptyBorder(0,5,5,5));
    14571435        button_pane.setLayout(new GridLayout(1,2,5,5));
     
    14601438
    14611439        content_pane.setLayout(new BorderLayout());
    1462         content_pane.add(center_pane, BorderLayout.CENTER);
     1440        content_pane.add(inner_pane, BorderLayout.CENTER);
    14631441        content_pane.add(button_pane, BorderLayout.SOUTH);
    14641442        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);
     
    14701448        Object source = event.getSource();
    14711449        if(source == ok_button) {
     1450        String value_str = Codec.transform(Codec.transformUnicode(value.getText()), Codec.TEXT_TO_DOM);
    14721451        // Now we action as necessary
    14731452        GValueModel model = Gatherer.c_man.msm.getValueTree(current_element);
     
    14751454            ///ystem.err.println("Add type - insert node: " + value.getText() + " into " + subject_node);
    14761455            // Add this value to the tree.
    1477             model.addValue(value.getText(), subject_node, alias.getText());
     1456            model.addValue(value_str, subject_node);
    14781457        }
    14791458        else {
    14801459            // 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);
    14831461            // Now insert the node into the currently selected subject, but only if the parent has changed.
    14841462            if(subject_node != current_value_node.getParent()) {
     
    15511529            }
    15521530            value.setText("");
    1553             alias.setText("");
    15541531            Dictionary.setText(this, "MEM.AddValue");
    15551532        }
     
    15621539            subject_node = (GValueNode) model.getRoot();
    15631540            }
    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));
    15661542            Dictionary.setText(this, "MEM.EditValue");
    15671543        }
     
    15791555
    15801556    public void dispose() {
    1581         alias = null;
    15821557        cancel_button = null;
    15831558        ok_button = null;
     
    16351610        /** Invoked after nodes have been inserted into the tree. */
    16361611    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        }
    16381615    }
    16391616    /** Invoked after nodes have been removed from the tree. */
Note: See TracChangeset for help on using the changeset viewer.