Changeset 10007
- Timestamp:
- 2005-06-03T14:40:55+12:00 (19 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/file/FileQueue.java
r9855 r10007 156 156 cancel_action = true; 157 157 } 158 159 160 /** Format the given filename path string so that it is no longer than the given width. If it is wider replace starting directories with ... 161 * @param key The key <strong>String</Strong> used to retrieve a phrase from the dictionary for this item. 162 * @param raw The raw filename path <strong>String</strong>. 163 * @param width The maximum width as an <i>int</i>. 164 * @return A path <strong>String</strong> no longer than width. 165 */ 166 private String formatPath(String key, String raw, int width) 167 { 168 JLabel label = new JLabel(Dictionary.get(key, raw)); 169 int position = -1; 170 while(label.getPreferredSize().width > width && (position = raw.indexOf(File.separator)) != -1) { 171 raw = "..." + raw.substring(position + 1); 172 label.setText(Dictionary.get(key, raw)); 173 } 174 if(raw.indexOf(File.separator) == -1 && raw.startsWith("...")) { 175 raw = raw.substring(3); 176 } 177 return raw; 178 } 179 180 158 181 /** Access to the file state label. */ 159 182 public JLabel getFileStatus() { … … 285 308 args[0] = "" + (queue.size() + 1) + ""; 286 309 if(job.type == FileJob.COPY) { 287 args[0] = Utility.formatPath("FileActions.Copying", source_file.getAbsolutePath(), file_status.getSize().width);310 args[0] = formatPath("FileActions.Copying", source_file.getAbsolutePath(), file_status.getSize().width); 288 311 file_status.setText(Dictionary.get("FileActions.Copying", args)); 289 312 } 290 313 else { 291 args[0] = Utility.formatPath("FileActions.Moving", source_file.getAbsolutePath(), file_status.getSize().width);314 args[0] = formatPath("FileActions.Moving", source_file.getAbsolutePath(), file_status.getSize().width); 292 315 file_status.setText(Dictionary.get("FileActions.Moving", args)); 293 316 } … … 443 466 // Update status area 444 467 String args[] = new String[1]; 445 args[0] = Utility.formatPath("FileActions.Deleting", source_file.getAbsolutePath(), file_status.getSize().width);468 args[0] = formatPath("FileActions.Deleting", source_file.getAbsolutePath(), file_status.getSize().width); 446 469 file_status.setText(Dictionary.get("FileActions.Deleting", args)); 447 470 -
trunk/gli/src/org/greenstone/gatherer/util/Utility.java
r10006 r10007 333 333 return result; 334 334 } 335 /** Format the given filename path string so that it is no longer than the given width. If it is wider replace starting directories with ...336 * @param key The key <strong>String</Strong> used to retrieve a phrase from the dictionary for this item.337 * @param raw The raw filename path <strong>String</strong>.338 * @param width The maximum width as an <i>int</i>.339 * @return A path <strong>String</strong> no longer than width.340 */341 static public String formatPath(String key, String raw, int width) {342 JLabel label = new JLabel(Dictionary.get(key, raw));343 int position = -1;344 while(label.getPreferredSize().width > width && (position = raw.indexOf(File.separator)) != -1) {345 raw = "..." + raw.substring(position + 1);346 label.setText(Dictionary.get(key, raw));347 }348 if(raw.indexOf(File.separator) == -1 && raw.startsWith("...")) {349 raw = raw.substring(3);350 }351 return raw;352 }353 335 354 336
Note:
See TracChangeset
for help on using the changeset viewer.