Changeset 2225
- Timestamp:
- 2001-03-26T19:07:55+12:00 (23 years ago)
- Location:
- trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient
- Files:
-
- 9 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/CSFrame.java
r2222 r2225 88 88 searchPanel = new SearchPanel(csModel, this); 89 89 90 JPanel centerPanel = new JPanel(); 91 QueryHistoryPanel queryHistoryPanel = new QueryHistoryPanel(csModel); 92 centerPanel.add(queryHistoryPanel); 93 90 94 content.setLayout(new BoxLayout(content, BoxLayout.X_AXIS)); 91 95 content.add(searchPanel); 96 content.add(centerPanel); 92 97 93 98 addWindowListener(new WindowHandler()); -
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/CSModel.java
r2184 r2225 19 19 package org.nzdl.gsdl.SimpleGraphicalClient; 20 20 21 import java.util.*; 21 22 import java.util.Set; 22 23 import java.util.TreeSet; … … 28 29 import org.nzdl.gsdl.service.NzdlService; 29 30 import org.nzdl.gsdl.service.NzdlCollectionInfo; 31 30 32 /** 31 33 * Class … … 43 45 44 46 Vector collectionList; 47 TreeMap collectionInfoMap; 48 HashMap collectionNameMap; 45 49 String currentCollection; 46 50 ResultModel results; 47 51 NzdlService nzdl; 52 QueryHistoryModel queryHistoryModel; 48 53 49 54 … … 53 58 results = new ResultModel(); 54 59 collectionList = new Vector(); 60 collectionInfoMap = new TreeMap(); 61 collectionNameMap = new HashMap(); 62 queryHistoryModel = new QueryHistoryModel(); 55 63 currentCollection = ""; 56 64 initialiseCollection(); … … 63 71 } 64 72 65 73 public QueryHistoryModel getQueryHistoryModel() { 74 return queryHistoryModel; 75 } 66 76 67 77 … … 86 96 /* collectionList methods */ 87 97 88 public Vector getCollectionList() 89 { 90 return collectionList; 91 } 98 public Vector getCollectionList() { 99 return new Vector(collectionInfoMap.keySet()); 100 } 92 101 93 public int getCollectionListSize() 94 { 95 return collectionList.size(); 96 } 97 98 public void addCollection(String collection) 99 { 100 collectionList.add(collection); 101 } 102 public Collection getCollectionAsCollection() { 103 return (Collection)collectionInfoMap; 104 } 102 105 103 public void setCurrentCollection(String collection ) 104 { 105 currentCollection = collection; 106 } 106 public int getCollectionListSize() { 107 return collectionInfoMap.size(); 108 } 107 109 108 public String getCurrentCollection() 109 { 110 return currentCollection; 111 } 110 public NzdlCollectionInfo getCollectionInfo(String collectionName) { 111 return (NzdlCollectionInfo) collectionInfoMap.get(collectionName); 112 } 112 113 113 public String getFirstCollection()114 {115 if (collectionList.size() > 0)116 return (String)collectionList.get(0);117 else118 return "no collections";119 }120 /**121 *122 */123 public void initialiseCollection()124 {125 Set collectionSet = nzdl.getCollectionSet(); // set of strings of collection titles126 TreeSet orderedCollectionSet = new TreeSet(collectionSet);127 // TreeSet automatically puts strings in alphabetical order128 System.out.println("Number of collections on the server: " +129 orderedCollectionSet.size());130 Iterator collectionSetIterator = orderedCollectionSet.iterator();131 while (collectionSetIterator.hasNext() ) {132 // object -> String133 String collectionName = (String)collectionSetIterator.next();134 NzdlCollectionInfo info = nzdl.getCollectionInfo(collectionName);135 //System.err.println(info);136 if (info != null &&137 info.getBuildDate() != 0) {138 addCollection(collectionName);139 System.err.println("Adding " + collectionName + " to collection list...");140 } // end if141 else {142 System.err.println("Collection " + collectionName + " getBuildDate() returned 0");143 } // end else144 } // end while145 114 115 public String getLongCollectionName(String collectionName) { 116 return (String) collectionNameMap.get(collectionName); 117 } 118 119 120 public String getCollectionDescription(String collectionName) { 121 Set descSet = nzdl.getMetaData(collectionName, "collection", "collectionextra"); 122 if (descSet.size() == 1) 123 return (String) descSet.toArray()[0]; 124 else 125 return "collectionName has more than 1 collectionextra entry"; 126 } 127 128 129 public void setCurrentCollection(String collection ) 130 { 131 currentCollection = collection; 132 } 133 134 public String getCurrentCollection() 135 { 136 return currentCollection; 137 } 138 139 public String getFirstCollection() 140 { 141 if (getCollectionListSize() > 0) 142 return (String)collectionInfoMap.firstKey(); 143 else 144 return "no collections"; 145 } 146 /** 147 * 148 */ 149 public void initialiseCollection() 150 { 151 Set collectionSet = nzdl.getCollectionSet(); // set of strings of collection titles 152 TreeSet orderedCollectionSet = new TreeSet(collectionSet); 153 // TreeSet automatically puts strings in alphabetical order 154 System.out.println("Number of collections on the server: " + 155 orderedCollectionSet.size()); 156 Iterator collectionSetIterator = orderedCollectionSet.iterator(); 157 while (collectionSetIterator.hasNext() ) { 158 // object -> String 159 String collectionName = (String)collectionSetIterator.next(); 160 NzdlCollectionInfo info = nzdl.getCollectionInfo(collectionName); 161 if (info != null && 162 info.getBuildDate() != 0) { 163 collectionInfoMap.put(collectionName, info); 164 String longCollectionName = ""; 165 Set n = nzdl.getMetaData(collectionName, "collection", "collectionname"); 166 if (n.size() == 1) 167 longCollectionName = (String) n.toArray()[0]; 168 else 169 longCollectionName = collectionName + " has more than 1 collectionname"; 170 collectionNameMap.put(collectionName,longCollectionName ); 171 System.err.println("Adding " + collectionName + " to collection list..."); 172 } // end if 173 else { 174 System.err.println("Collection " + collectionName + " getBuildDate() returned 0"); 175 } // end else 176 } // end while 177 setCurrentCollection(getFirstCollection()); //assume at least one collection 146 178 147 148 setCurrentCollection(getFirstCollection()); //assume at least one collection 149 150 } 179 } 151 180 152 181 153 }182 } -
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/CollectionInfoDialog.java
r2222 r2225 58 58 private NumberFormat numFormat = NumberFormat.getInstance(); 59 59 60 CollectionInfoDialog(Frame f, String collectionName, NzdlService nzdl) { 61 super(f, "Collection Information" ); 62 63 contentPanel = new JPanel(new GridLayout(0,2, 5, 4));; 64 buttonPanel = new JPanel(); 65 66 NzdlCollectionInfo collectionInfo = nzdl.getCollectionInfo(collectionName); 67 Set n = nzdl.getMetaData(collectionName, "collection", "collectionname"); 68 if (n.size() == 1) { 69 fullCollectionName = (String) n.toArray()[0]; 70 } 71 else { 72 System.err.println(collectionName + " has more than 1 collectionname"); 73 } 74 n.clear(); 75 76 collectionNamePanel = new JPanel(); 77 // collectionNamePanel.setBorder(BorderFactory.createEmptyBorder(2,2,2,2)); 78 collectionNamePanel.add(new JLabel(fullCollectionName)); 79 80 contentPanel.add(new JLabel("Short collection name:")); 81 JLabel collectionLabel = new JLabel(collectionName); 82 contentPanel.add(collectionLabel); 83 contentPanel.add(new JLabel("Number of Documents:")); 84 85 long numOfDocs = collectionInfo.getNumOfDocs(); 86 if (numOfDocs == 0) 87 numOfDocsString = "unknown"; 88 else 89 numOfDocsString = numFormat.format(numOfDocs); 90 contentPanel.add(new JLabel(numOfDocsString)); 91 contentPanel.add(new JLabel("Number of Words:")); 92 93 long numOfWords = collectionInfo.getNumOfWords(); 94 if (numOfWords == 0) 95 numOfWordsString = "unknown"; 96 else 97 numOfWordsString = numFormat.format(numOfWords); 98 contentPanel.add(new JLabel(numOfWordsString)); 99 contentPanel.add(new JLabel("Size:")); 100 long numOfBytes = collectionInfo.getNumOfBytes(); 101 contentPanel.add(new JLabel(formatByteSize(numOfBytes))); 102 contentPanel.add(new JLabel("Last built on:")); 103 // waiting for API to return a correct Date object ... 104 Date buildDate = new Date( collectionInfo.getBuildDate()*1000); 105 contentPanel.add(new JLabel(DateFormat.getDateTimeInstance().format(buildDate))); 106 contentPanel.add(new JLabel("Is it Public?")); 107 108 if (collectionInfo.isPublic()) 109 publicString = "yes"; 110 else 111 publicString = "no"; 112 contentPanel.add(new JLabel(publicString)); 113 contentPanel.add(new JLabel("Is it beta?")); 114 if (collectionInfo.isBeta()) 115 betaString = "yes"; 116 else 117 betaString = "no"; 118 contentPanel.add(new JLabel(betaString)); 119 120 JPanel descPanel = new JPanel(); 121 Set descSet = nzdl.getMetaData(collectionName, "collection", "collectionextra"); 122 if (descSet.size() == 1) { 123 descString = (String) descSet.toArray()[0]; 60 CollectionInfoDialog(Frame f, String collectionName, CSModel csModel) { 61 super(f, "Collection Information" ); 62 63 contentPanel = new JPanel(new GridLayout(0,2, 5, 4));; 64 buttonPanel = new JPanel(); 65 66 NzdlCollectionInfo collectionInfo = csModel.getCollectionInfo(collectionName); 67 /* 68 Set n = nzdl.getMetaData(collectionName, "collection", "collectionname"); 69 if (n.size() == 1) { 70 fullCollectionName = (String) n.toArray()[0]; 71 } 72 else { 73 System.err.println(collectionName + " has more than 1 collectionname"); 74 } 75 n.clear(); 76 */ 77 collectionNamePanel = new JPanel(); 78 // collectionNamePanel.setBorder(BorderFactory.createEmptyBorder(2,2,2,2)); 79 collectionNamePanel.add(new JLabel(csModel.getLongCollectionName(collectionName))); 80 81 contentPanel.add(new JLabel("Short collection name:")); 82 JLabel collectionLabel = new JLabel(collectionName); 83 contentPanel.add(collectionLabel); 84 contentPanel.add(new JLabel("Number of Documents:")); 85 86 long numOfDocs = collectionInfo.getNumOfDocs(); 87 if (numOfDocs == 0) 88 numOfDocsString = "unknown"; 89 else 90 numOfDocsString = numFormat.format(numOfDocs); 91 contentPanel.add(new JLabel(numOfDocsString)); 92 contentPanel.add(new JLabel("Number of Words:")); 93 94 long numOfWords = collectionInfo.getNumOfWords(); 95 if (numOfWords == 0) 96 numOfWordsString = "unknown"; 97 else 98 numOfWordsString = numFormat.format(numOfWords); 99 contentPanel.add(new JLabel(numOfWordsString)); 100 contentPanel.add(new JLabel("Size:")); 101 long numOfBytes = collectionInfo.getNumOfBytes(); 102 contentPanel.add(new JLabel(formatByteSize(numOfBytes))); 103 contentPanel.add(new JLabel("Last built on:")); 104 // waiting for API to return a correct Date object ... 105 Date buildDate = new Date( collectionInfo.getBuildDate()*1000); 106 contentPanel.add(new JLabel(DateFormat.getDateTimeInstance().format(buildDate))); 107 contentPanel.add(new JLabel("Is it Public?")); 108 109 if (collectionInfo.isPublic()) 110 publicString = "yes"; 111 else 112 publicString = "no"; 113 contentPanel.add(new JLabel(publicString)); 114 contentPanel.add(new JLabel("Is it beta?")); 115 if (collectionInfo.isBeta()) 116 betaString = "yes"; 117 else 118 betaString = "no"; 119 contentPanel.add(new JLabel(betaString)); 120 121 JPanel descPanel = new JPanel(); 122 descString = csModel.getCollectionDescription(collectionName); 124 123 //System.err.println(descString); 125 124 if (descString.length() > 0) { … … 143 142 descPanel.add(scrollPane); 144 143 } // if 145 } // if 146 descSet.clear(); 147 148 okButton = new JButton("Ok"); 149 okButton.setPreferredSize(new Dimension(80,20)); 150 okButton.addActionListener(this); 151 buttonPanel.add( okButton ); 152 getRootPane().setDefaultButton(okButton); 144 145 okButton = new JButton("Ok"); 146 okButton.setPreferredSize(new Dimension(80,20)); 147 okButton.addActionListener(this); 148 buttonPanel.add( okButton ); 149 getRootPane().setDefaultButton(okButton); 153 150 154 155 156 157 158 159 160 holderPanel.add(Box.createVerticalStrut(10));161 holderPanel.add(descPanel); // only if we have a description to show162 163 164 165 166 167 151 holderPanel = new JPanel(); 152 holderPanel.setBorder(BorderFactory.createEmptyBorder(10,10,2,10)); 153 holderPanel.setLayout( new BoxLayout(holderPanel, BoxLayout.Y_AXIS)); 154 holderPanel.add(collectionNamePanel); 155 holderPanel.add(contentPanel); 156 if (descString.length() > 0) { 157 holderPanel.add(Box.createVerticalStrut(10)); 158 holderPanel.add(descPanel); // only if we have a description to show 159 } 160 holderPanel.add(Box.createVerticalStrut(5)); 161 holderPanel.add(buttonPanel); 162 getContentPane().add(holderPanel); 163 pack(); 164 setVisible(true); 168 165 } //end CollectionInfoDialog constructor 169 166 -
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/Constants.java
r2222 r2225 64 64 Cursor WAIT_CURSOR = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); 65 65 66 66 /* Query History Table Column Titles */ 67 68 String[] QUERY_HISTORY_COLUMN_TITLES = {"Collection", "Terms"}; 67 69 68 70 -
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/SearchPanel.java
r2222 r2225 116 116 117 117 collectionList = new JComboBox(csModel.getCollectionList()){ 118 public boolean isFocusTraversable() { 119 return false; 120 } 121 }; 122 collectionInfoButton = new JButton("Info..."); 118 public boolean isFocusTraversable() { 119 return false; 120 } 121 }; 122 collectionList.setEditable(false); 123 124 collectionInfoButton = new JButton("Info...") { 125 public String getToolTipText(MouseEvent e) { 126 //return "more information on " + collectionList.getSelectedItem(); 127 return "More information on " + csModel.getLongCollectionName((String)collectionList.getSelectedItem()); 128 } 129 }; 130 ToolTipManager.sharedInstance().registerComponent(collectionInfoButton); 123 131 collectionInfoButton.addActionListener(this); 124 132 … … 194 202 195 203 public void actionPerformed(ActionEvent e) { 204 String collectionName = collectionList.getSelectedItem().toString(); 196 205 if (e.getSource() == searchButton ) { 197 206 // cursor not set when RETURN pressed, only when button clicked ? 198 207 windowParent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 199 208 String queryString = searchTextField.getText(); 200 String collectionName = collectionList.getSelectedItem().toString();201 209 System.err.println("Search started (" + collectionName + "): \"" + queryString + "\" ..." ); 202 210 //send query to collection … … 240 248 resultsList.setSelectedIndex(0); // should be under Preference control! 241 249 } // end else 250 251 252 csModel.getQueryHistoryModel().add( new QueryHistoryItem(new Query(queryString), new Date(), collectionName, "user")); 253 242 254 titleMap.clear(); 243 255 titleMetaData.clear(); … … 247 259 else { 248 260 if (e.getSource() == collectionInfoButton) { 249 CollectionInfoDialog cid = new CollectionInfoDialog(windowParent, collection List.getSelectedItem().toString(), nzdl);261 CollectionInfoDialog cid = new CollectionInfoDialog(windowParent, collectionName, csModel); 250 262 } 251 263 else { … … 287 299 // treat as HTML 288 300 displayAsHTML(sr); 289 htmlDoc.getImageData(nzdl, result.getCollectionName());301 //htmlDoc.getImageData(nzdl, result.getCollectionName()); 290 302 } 291 303
Note:
See TracChangeset
for help on using the changeset viewer.