Changeset 18180

Show
Ignore:
Timestamp:
11.12.2008 15:35:44 (11 years ago)
Author:
cc108
Message:

add a method to check whether the collection can be analysed or not

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • other-projects/trunk/greenstone3-extension/mat/src/org/greenstone/gsdl3_extension/mat/CollectionChooser.java

    r18093 r18180  
    33import java.awt.*; 
    44import java.awt.event.*; 
     5import java.io.File; 
     6 
    57import javax.swing.*; 
    68 
     
    1012 
    1113public class CollectionChooser extends JFrame { 
    12      
     14     
    1315    JPanel jPanel; 
    1416    JButton jButton1; 
    1517    JComboBox collectionComboBox; 
     18    String fileSeparator = File.separator; 
    1619     
    1720    public CollectionChooser(String collectionName){ 
     
    2023     
    2124    public CollectionChooser() { 
    22      
    2325    super(); 
    2426    this.setTitle("Choose a collection"); 
     
    2729        dm.describe(); 
    2830         
    29     Node cList = dm.getCollectionList(); 
     31        Node cList = dm.getCollectionList(); 
    3032        Element collectionList = (Element) cList; 
    3133        NodeList collectionNameList = collectionList.getElementsByTagName("collection"); 
    32         String[] collectionStrings = new String[collectionNameList.getLength()]; 
     34 
     35        String[] collectionTemp = new String[collectionNameList.getLength()]; 
    3336         
     37        int count =0;  
    3438        for(int i=0; i<collectionNameList.getLength(); i++){ 
    3539        Node nameNode = collectionNameList.item(i); 
    36         collectionStrings[i] = nameNode.getAttributes().item(0).getNodeValue(); 
     40        String collName = nameNode.getAttributes().item(0).getNodeValue();; 
     41        
     42         
     43        String path = dm.site_home+fileSeparator+"collect"+fileSeparator+collName+fileSeparator+"index"+fileSeparator+"text"+fileSeparator+collName+".ldb"; 
     44 
     45        File dbFile = new File(path); 
     46        if(dbFile.exists()){ 
     47            collectionTemp[count] = collName; 
     48            count++; 
     49        } 
    3750        } 
    3851     
     52        String[] collectionStrings = new String[count]; 
     53         
     54        for(int i = 0; i<count; i++){ 
     55            collectionStrings[i]= collectionTemp[i]; 
     56        } 
     57             
     58        if(collectionStrings.length==0){ 
     59            JOptionPane.showMessageDialog(new JFrame(),"No collections available."); 
     60            System.exit(0); 
     61        } 
    3962        jButton1 = new JButton("Enter"); 
    4063        jButton1.setPreferredSize(new Dimension(150,30));