Changeset 6565
- Timestamp:
- 2004-01-21T11:18:33+13:00 (20 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/help/HelpFrame.java
r5597 r6565 47 47 import org.apache.xerces.parsers.DOMParser; 48 48 import org.greenstone.gatherer.Dictionary; 49 import org.greenstone.gatherer.util.StaticStrings; 49 50 import org.greenstone.gatherer.util.Utility; 50 51 import org.w3c.dom.*; … … 58 59 extends JFrame { 59 60 61 static private final String NULL_STRING = "<null>"; 62 /** The size of the frame */ 63 static private final Dimension SIZE = new Dimension(760, 560); 64 60 65 /** The HTML rendering pane */ 61 66 private CalHTMLPane view = null; … … 67 72 private JSplitPane split_pane = null; 68 73 69 /** The size of the frame */70 static final Dimension SIZE = new Dimension(760, 560);71 74 72 75 … … 79 82 view = new CalHTMLPane(new CalHTMLPreferences(), new Observer(), "Help Pages"); 80 83 81 HelpItem rootNode = new HelpItem(Dictionary.get("Help.Contents"), "<null>");84 HelpItem rootNode = new HelpItem(Dictionary.get("Help.Contents"), NULL_STRING); 82 85 model = new ContentsModel(rootNode); 83 86 contents = new JTree((DefaultTreeModel) model); … … 141 144 try { 142 145 DOMParser parser = new DOMParser(); 143 parser.parse(Utility. HELP_DIR + "help.xml");146 parser.parse(Utility.getHelpIndex()); 144 147 Document document = parser.getDocument(); 145 148 … … 151 154 for (int i = 0; i < children.getLength(); i++) { 152 155 Node child = children.item(i); 153 if (child.getNodeName().equals( "Section")) {156 if (child.getNodeName().equals(StaticStrings.SECTION_ELEMENT)) { 154 157 sectionNum++; 155 buildContentsHierarchy(rootNode, sectionNum + "", child);158 buildContentsHierarchy(rootNode, sectionNum + StaticStrings.EMPTY_STR, child); 156 159 } 157 160 } … … 166 169 { 167 170 // Determine the section name 168 String sectionName = ((Element) node).getAttribute( "name");171 String sectionName = ((Element) node).getAttribute(StaticStrings.NAME_ATTRIBUTE); 169 172 170 173 // Determine the section title 171 String sectionTitle = "";174 String sectionTitle = StaticStrings.EMPTY_STR; 172 175 NodeList children = node.getChildNodes(); 173 176 for (int i = 0; i < children.getLength(); i++) { 174 177 Node child = children.item(i); 175 if (child.getNodeName().equals( "Title")) {176 sectionTitle = pos + ": "+ child.getFirstChild().getNodeValue();178 if (child.getNodeName().equals(StaticStrings.TITLE_ELEMENT)) { 179 sectionTitle = pos + StaticStrings.COLON_CHARACTER + StaticStrings.SPACE_CHARACTER + child.getFirstChild().getNodeValue(); 177 180 } 178 181 } … … 186 189 for (int i = 0; i < children.getLength(); i++) { 187 190 Node child = children.item(i); 188 if (child.getNodeName().equals( "Section")) {191 if (child.getNodeName().equals(StaticStrings.SECTION_ELEMENT)) { 189 192 sectionNum++; 190 buildContentsHierarchy(item, pos + "."+ sectionNum, child);193 buildContentsHierarchy(item, pos + StaticStrings.STOP_CHARACTER + sectionNum, child); 191 194 } 192 195 } … … 260 263 public URL getURL() 261 264 { 262 if (name != null && !name.equals( "<null>")) {265 if (name != null && !name.equals(NULL_STRING)) { 263 266 try { 264 File file = new File(Utility.HELP_DIR + name + ".htm");267 File file = new File(Utility.HELP_DIR + name + StaticStrings.HTM_FILE_EXTENSION); 265 268 return file.toURL(); 266 269 } -
trunk/gli/src/org/greenstone/gatherer/util/StaticStrings.java
r6549 r6565 119 119 static final public String HTTP_PROTOCOL_STR = "http://"; 120 120 static final public String HELP_ARGUMENT = "-help"; 121 static final public String HELP_INDEX_FILENAME = "help_index.xml"; 122 static final public String HTM_FILE_EXTENSION = ".htm"; 121 123 static final public String IDENTIFIER_VALUE = "identifier"; 122 124 static final public String IMAGES_FOLDER = "images"; … … 152 154 static final public String MAPPING_ELEMENT = "Mapping"; 153 155 static final public String MARC_EXTENSION = ".marc"; 156 static final public String MDS_ATTRIBUTE = "mds"; 154 157 static final public String METADATA_ARGUMENT = "-metadata"; 155 158 static final public String METADATA_BAK = "~metadata.xml"; … … 190 193 static final public String SEARCHTYPE_ELEMENT = "SearchType"; 191 194 static final public String SEARCHTYPE_STR = "searchtype"; 195 static final public String SECTION_ELEMENT = "Section"; 192 196 static final public String SECTION_STR = "section"; 193 197 static final public String SEPARATOR_ATTRIBUTE = "separator"; … … 216 220 static final public String TEXT_STR = "text"; 217 221 static final public String TIMESTAMP_ARGUMENT = "&uq="; 222 static final public String TITLE_ELEMENT = "Title"; 218 223 static final public String TRUE_STR = "true"; 219 static final public String TRUNCATED_STRING 224 static final public String TRUNCATED_STRING = "..."; 220 225 static final public String TYPE_ATTRIBUTE = "type"; 221 226 static final public String UNDERSCORE_CHARACTER = "_"; -
trunk/gli/src/org/greenstone/gatherer/util/Utility.java
r6539 r6565 370 370 // If the token is bigger than two thirds width, before we've even started break it down. 371 371 if(current_width + 1 + token.length() > width && token.length() > threshold) { 372 String prefix = token.substring(0, width - 1 - current_width);373 token = token.substring(prefix.length());374 if(current_width == 0) {375 line = line + prefix;372 if(width == current_width) { 373 lines.push(line); 374 line = token; 375 current_width = token.length(); 376 376 } 377 377 else { 378 line = line + " " + prefix; 378 String prefix = token.substring(0, width - 1 - current_width); 379 token = token.substring(prefix.length()); 380 if(current_width == 0) { 381 line = line + prefix; 382 } 383 else { 384 line = line + " " + prefix; 385 } 386 lines.push(line); 387 line = ""; 388 current_width = 0; 379 389 } 380 lines.push(line);381 line = "";382 current_width = 0;383 390 } 384 391 // If adding the next token would push us over the maximum line width. … … 547 554 return col_dir + ETC_DIR; 548 555 } 556 557 /** Retrieve the full file path to the help index xml file. 558 * @return the full path as a String 559 */ 560 static public String getHelpIndex() { 561 String help_index = HELP_DIR + Gatherer.config.getLanguage() + File.separator + StaticStrings.HELP_INDEX_FILENAME; 562 File help_index_file = new File(help_index); 563 // If that file can't be found, default to english 564 if(!help_index_file.exists()) { 565 help_index = HELP_DIR + StaticStrings.ENGLISH_LANGUAGE_STR + File.separator + StaticStrings.HELP_INDEX_FILENAME; 566 } 567 return help_index; 568 } 569 570 549 571 /** Method to retrieve an image icon with the given filename found in classpath or the resouces directory. 550 572 * @return The specified <strong>ImageIcon</strong>, or an error image replacement if no such images exists.
Note:
See TracChangeset
for help on using the changeset viewer.