Changeset 12681


Ignore:
Timestamp:
2006-09-05T16:40:14+12:00 (18 years ago)
Author:
kjdon
Message:

added in a no_set_loaded pane, and a card layout to switch between it and the main metadata set details pane. file-> close now works.

File:
1 edited

Legend:

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

    r12665 r12681  
    7777    static final private Dimension SIZE = new Dimension(800,550);
    7878
     79    // we have a card pane to switch between the no set loaded view, and the
     80    // set loaded view
     81    private CardLayout card_layout = null;
     82    private JPanel card_pane = null;
     83    /** The name of the panel containing the "set loaded" card. */
     84    private String SET_LOADED_CARD = "";
     85    /** The name of the panel containing the "no set loaded" placeholder */
     86    private String NO_SET_LOADED_CARD = "No set loaded";
     87
    7988    private GEMS self = null;
    8089
     
    8392    private NewMetadataSetPrompt new_prompt;   
    8493   
    85     private JSplitPane splitPane = null;
    86     private JSplitPane rightPane = null;
     94    // this is the main panel that gets switched in once a set is loaded
     95    private JSplitPane metadata_set_details_split_pane = null;
     96    // this is the split with the attribute tables in it
     97    private JSplitPane attribute_tables_split_pane = null;
    8798     
    8899    /** Um, the size of the screen I'd guess. */
     
    154165    addWindowFocusListener(this);
    155166
     167    card_layout = new CardLayout();
     168    card_pane = new JPanel();
     169
    156170        metadata_set_model = new MetadataSetModel(msm);
    157171        msm.setMetadataSetModel(metadata_set_model);
     
    204218    JScrollPane langTablePane =  new JScrollPane(language_dependent_attribute_table);
    205219
     220    // no set loaded pane
     221    JPanel no_set_loaded_pane = new JPanel();
     222    no_set_loaded_pane.setBackground(Color.lightGray);
     223    JLabel no_set_loaded_label = new JLabel(Dictionary.get("GEMS.No_Set_Loaded"));
     224    no_set_loaded_label.setHorizontalAlignment(JLabel.CENTER);
     225    no_set_loaded_label.setVerticalAlignment(JLabel.CENTER);
     226
     227    no_set_loaded_pane.setLayout(new BorderLayout());
     228    no_set_loaded_pane.add(no_set_loaded_label, BorderLayout.CENTER);
    206229
    207230        JPanel buttonPane = new JPanel(new GridLayout(1,2));
     
    269292    mainAttributePane.add(tablePane, BorderLayout.CENTER);
    270293   
    271     rightPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,mainAttributePane,languageAttributePane);
    272    
    273     splitPane =  new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,leftPane,rightPane);   
    274     getContentPane().add(splitPane,BorderLayout.CENTER);
     294    attribute_tables_split_pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,mainAttributePane,languageAttributePane);
     295   
     296    metadata_set_details_split_pane =  new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,leftPane,attribute_tables_split_pane);   
     297
     298    card_pane.setLayout(card_layout);
     299    card_pane.add(no_set_loaded_pane, NO_SET_LOADED_CARD);
     300    card_pane.add(metadata_set_details_split_pane, SET_LOADED_CARD);
     301
     302    getContentPane().add(card_pane,BorderLayout.CENTER);
    275303
    276304    setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2);
     
    281309    public void setVisible(boolean visible) {
    282310    super.setVisible(visible);
    283     rightPane.setDividerLocation(0.3);
     311    attribute_tables_split_pane.setDividerLocation(0.3);
    284312    }
    285313   
     314    // called from GLI
    286315    public void displayMetadataSet(String metadata_path){
    287316    open_prompt.openMetadataSet(metadata_path);
     
    289318    }   
    290319
     320    // called from GLI
    291321    public void newMetadataSet(){
    292322    new_prompt.display();
     
    312342    public void exit(){
    313343    //clean up things
     344    cleanUpListeners();
     345    }
     346   
     347    protected void cleanUpListeners() {
    314348    MetadataSetInfo msti= new MetadataSetInfo();
    315349    msti.removeAllMetadataSetListeners();
    316350    MetadataElementModel mem= new MetadataElementModel();
    317351    mem.removeAllMetadataElementListeners();
     352
    318353    }
    319354   
     
    329364    }
    330365
     366    protected void updateCardLayout(boolean set_loaded) {
     367    if (set_loaded) {
     368        card_layout.show(card_pane, SET_LOADED_CARD);
     369    } else {
     370        card_layout.show(card_pane, NO_SET_LOADED_CARD);
     371    }
     372    }
    331373   
    332374    private class GEMSMenuBar
     
    419461        // File -> New
    420462        if (event_source == file_new) {
    421         new_prompt.display();   
     463        new_prompt.display();
     464        if (!new_prompt.isCancelled()) {
     465            updateCardLayout(true);
     466        }
    422467        return;
    423468        }
     
    426471        if (event_source == file_open) {               
    427472        open_prompt.display();
     473        if (!open_prompt.isCancelled()) {
     474            updateCardLayout(true);
     475        }
    428476        return;
    429477        }
     
    431479        // File -> Close
    432480        if (event_source == file_close) {
    433        
     481        metadata_set_model.save(true);
     482        updateCardLayout(false);
     483        return;
    434484        }
    435485              // File -> Delete
Note: See TracChangeset for help on using the changeset viewer.