Changeset 7454


Ignore:
Timestamp:
2004-05-27T10:51:18+12:00 (20 years ago)
Author:
mdewsnip
Message:

Changing format statements now saves the collection configuration file immediately, to work better with the web library version of Greenstone. (For the Local Library, you still need to reload the collection configuration files, so going to Build and clicking the Preview button is required).

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
2 edited

Legend:

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

    r7453 r7454  
    295295        // Create Collection Manager
    296296        c_man = new CollectionManager();
    297         // If there was an open collection last session, reopen it.
    298297       
    299298        if (GS3) {
     
    306305        }
    307306        }
    308         if(open_collection == null) {
     307
     308        // If there was an open collection last session, reopen it.
     309        if (open_collection == null) {
    309310        open_collection = config.getString("general.open_collection", true);
    310311        }
    311         if(!no_load && open_collection.length() > 0) {
     312        if (!no_load && open_collection.length() > 0) {
    312313        c_man.loadCollection(open_collection);
    313314        }
     315
    314316        // Create GUI Manager (last) or else suffer the death of a thousand NPE's
    315317        splash.toFront();
  • trunk/gli/src/org/greenstone/gatherer/cdm/FormatManager.java

    r7151 r7454  
    8383
    8484    // Ensure the default formats for DateList, HList and VList are assigned
    85     if(getFormat("DateList") == null) {
    86        addFormat(new Format("","DateList","<td>[link][icon][/link]</td><td>[highlight]{Or}{[dls.Title],[dc.Title],[Title],Untitled}[/highlight]</td><td>[Date]</td>"));
    87     }
    88    
    89     if(getFormat("HList") == null) {
    90        addFormat(new Format("","HList","[link][highlight]{Or}{[dls.Title],[dc.Title],[Title],Untitled}[/highlight][/link]"));
    91     }
    92    
    93     if(getFormat("VList") == null) {
    94        addFormat(new Format("","VList","<td valign=top>[link][icon][/link]</td><td valign=top>[srclink]{Or}{[thumbicon],[srcicon]}[/srclink]</td><td valign=top>[highlight]{Or}{[dls.Title],[dc.Title],[Title],Untitled}[/highlight]{If}{[Source],<br><i>([Source])</i>}</td>"));
     85    if (getFormat("DateList") == null) {
     86        addFormat(new Format("","DateList","<td>[link][icon][/link]</td><td>[highlight]{Or}{[dls.Title],[dc.Title],[Title],Untitled}[/highlight]</td><td>[Date]</td>"));
     87    }
     88
     89    if (getFormat("HList") == null) {
     90        addFormat(new Format("","HList","[link][highlight]{Or}{[dls.Title],[dc.Title],[Title],Untitled}[/highlight][/link]"));
     91    }
     92
     93    if (getFormat("VList") == null) {
     94        addFormat(new Format("","VList","<td valign=top>[link][icon][/link]</td><td valign=top>[srclink]{Or}{[thumbicon],[srcicon]}[/srclink]</td><td valign=top>[highlight]{Or}{[dls.Title],[dc.Title],[Title],Untitled}[/highlight]{If}{[Source],<br><i>([Source])</i>}</td>"));
    9595    }
    9696    }
     
    117117    }
    118118
    119    /** Have the formats changed since the last save. */
    120    public boolean formatsChanged() {
    121       return formats_changed;
    122    }
    123    
     119    /** Have the formats changed since the last save. */
     120    public boolean formatsChanged() {
     121    return formats_changed;
     122    }
     123
    124124    /** Gets the format indicated by the index.
    125125     * @param index The location of the desired format, as an <i>int</i>.
     
    163163    }
    164164
    165    /** Set the state of the formats changed flag.
    166     * @param state the new state as a boolean
    167     */
    168    public void setFormatsChanged(boolean state) {
    169       formats_changed = state;
    170    }
    171    
     165    /** Set the state of the formats changed flag.
     166     * @param state the new state as a boolean
     167     */
     168    public void setFormatsChanged(boolean state) {
     169    formats_changed = state;
     170    }
     171
    172172    private HashMap buildDefaultMappings(ArrayList features_model, ArrayList parts_model) {
    173        Gatherer.println("buildDefaultMappings(): replace me with something that reads in a data xml file.");
     173    Gatherer.println("buildDefaultMappings(): replace me with something that reads in a data xml file.");
    174174    return new HashMap();
    175175    }
     
    232232    private HashMap default_mappings;
    233233    private JButton add_button;
    234        //private JButton default_button;
    235        private JButton insert_button;
     234    //private JButton default_button;
     235    private JButton insert_button;
    236236    private JButton remove_button;
    237237    private JButton replace_button;
     
    243243    private JTextArea instructions_textarea;
    244244    private JTextArea editor_textarea;
    245        private JPanel blank_pane;
    246        private JPanel control_pane;
     245    private JPanel blank_pane;
     246    private JPanel control_pane;
    247247    private JPanel part_pane;
    248248    private JPanel selection_pane;
     
    459459    private class AddListener
    460460        implements ActionListener {
    461         public void actionPerformed(ActionEvent event) {
     461
     462        public void actionPerformed(ActionEvent event)
     463        {
    462464        ignore_event = true; // Prevent format_list excetera propagating events
    463         Entry entry = (Entry)feature_combobox.getSelectedItem();
     465
     466        Entry entry = (Entry) feature_combobox.getSelectedItem();
    464467        Object f = entry.getFeature();
    465468        String p = "";
     
    467470            p = part_combobox.getSelectedItem().toString();
    468471        }
     472
     473        // Add a new format string of the appropriate type
    469474        Format format = null;
    470         if(view_type.equals(FLAG)) {
     475        if (view_type.equals(FLAG)) {
    471476            format = new Format(f, p, enabled_checkbox.isSelected());
    472477        }
     
    475480        }
    476481        addFormat(format);
     482
     483        // Save the collection configuration file immediately
     484        Gatherer.g_man.design_pane.saveConfiguration();
     485
    477486        add_button.setEnabled(false);
    478487        replace_button.setEnabled(false);
    479488        remove_button.setEnabled(true);
     489
    480490        // Update list selection
    481491        format_list.setSelectedValue(format, true);
     
    770780    private class RemoveListener
    771781        implements ActionListener {
    772         public void actionPerformed(ActionEvent event) {
    773         if(!format_list.isSelectionEmpty()) {
     782
     783        public void actionPerformed(ActionEvent event)
     784        {
     785        if (!format_list.isSelectionEmpty()) {
     786            // Remove the current format
    774787            removeFormat((Format)format_list.getSelectedValue());
     788
     789            // Save the collection configuration file immediately
     790            Gatherer.g_man.design_pane.saveConfiguration();
     791
    775792            // Change buttons
    776793            add_button.setEnabled(true);
    777794            replace_button.setEnabled(false);
    778795        }
     796
    779797        remove_button.setEnabled(false);
    780798        }
     
    784802        implements ActionListener {
    785803
    786        public void actionPerformed(ActionEvent event) {
    787           ignore_event = true; // Prevent format_list excetera propagating events
    788 
    789           if(!format_list.isSelectionEmpty()) {
    790 
    791          // Remove the current format
    792          removeFormat((Format)format_list.getSelectedValue());
    793          
    794          Entry entry = (Entry)feature_combobox.getSelectedItem();
    795          Object f = entry.getFeature();
    796          String p =  "";
    797          if (entry.canHavePart()) {
    798             p = part_combobox.getSelectedItem().toString();
    799          }
    800          Format format = null;
    801          if(view_type.equals(FLAG)) {
    802             format = new Format(f, p, enabled_checkbox.isSelected());
    803          }
    804          else {
    805             format = new Format(f, p, editor_textarea.getText());
    806          }
    807          addFormat(format);
    808          add_button.setEnabled(false);
    809          remove_button.setEnabled(true);
    810          // Update list selection
    811          format_list.setSelectedValue(format, true);
    812          format = null;
    813          p = null;
    814          f = null;
    815          entry = null;
    816           }
    817           replace_button.setEnabled(false);
    818           ignore_event = false;
    819        }
     804        public void actionPerformed(ActionEvent event)
     805        {
     806        ignore_event = true; // Prevent format_list excetera propagating events
     807
     808        if (!format_list.isSelectionEmpty()) {
     809            // Remove the current format
     810            removeFormat((Format) format_list.getSelectedValue());
     811
     812            Entry entry = (Entry) feature_combobox.getSelectedItem();
     813            Object f = entry.getFeature();
     814            String p = "";
     815            if (entry.canHavePart()) {
     816            p = part_combobox.getSelectedItem().toString();
     817            }
     818
     819            // Add a new format string of the appropriate type
     820            Format format = null;
     821            if (view_type.equals(FLAG)) {
     822            format = new Format(f, p, enabled_checkbox.isSelected());
     823            }
     824            else {
     825            format = new Format(f, p, editor_textarea.getText());
     826            }
     827            addFormat(format);
     828
     829            // Save the collection configuration file immediately
     830            Gatherer.g_man.design_pane.saveConfiguration();
     831
     832            add_button.setEnabled(false);
     833            remove_button.setEnabled(true);
     834            // Update list selection
     835            format_list.setSelectedValue(format, true);
     836            format = null;
     837            p = null;
     838            f = null;
     839            entry = null;
     840        }
     841
     842        replace_button.setEnabled(false);
     843        ignore_event = false;
     844        }
    820845    }
    821846    }
Note: See TracChangeset for help on using the changeset viewer.