Changeset 5564 for trunk/gli/src/org/greenstone/gatherer/shell
- Timestamp:
- 2003-10-03T14:07:35+12:00 (21 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/shell
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/shell/GImportProgressMonitor.java
r5325 r5564 1 package org.greenstone.gatherer.shell;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.shell; 38 38 39 import java.awt.Component; 39 40 import java.util.StringTokenizer; 40 41 import javax.swing.JProgressBar; 42 import org.greenstone.gatherer.Dictionary; 41 43 import org.greenstone.gatherer.Gatherer; 42 44 import org.greenstone.gatherer.shell.GShellProgressMonitor; 45 43 46 /** This implementation of <i>GShellProgressMonitor</i> is designed to parse and translate the progress of a import.pl call. 44 47 * @author John Thompson, Greenstone Digital Library, University of Waikato … … 156 159 157 160 public void saving() { 158 progress_bar.setString( Gatherer.dictionary.get("SaveProgressDialog.Title", (String)null));161 progress_bar.setString(Dictionary.newget("SaveProgressDialog.Title")); 159 162 progress_bar.setValue(MAX / (10 * 2)); 160 163 } … … 171 174 */ 172 175 public void start() { 173 progress_bar.setString( Gatherer.dictionary.get("FileActions.Calculating_Size", (String)null));176 progress_bar.setString(Dictionary.newget("FileActions.Calculating_Size")); 174 177 progress_bar.setValue(MAX / 10); 175 178 num_files = Gatherer.c_man.getCollection().getDocumentCount(); -
trunk/gli/src/org/greenstone/gatherer/shell/GShell.java
r5349 r5564 1 package org.greenstone.gatherer.shell;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.shell; 38 38 39 import java.io.*; 39 40 import javax.swing.*; 40 41 import javax.swing.event.*; 41 42 import javax.swing.tree.*; 43 import org.greenstone.gatherer.Dictionary; 42 44 import org.greenstone.gatherer.Gatherer; 43 import org.greenstone.gatherer.Message;44 45 import org.greenstone.gatherer.msm.GreenstoneArchiveParser; 45 46 import org.greenstone.gatherer.shell.GShellListener; … … 106 107 } 107 108 /** This method adds another shell listener to this process. 108 109 109 * @param listener The new <i>GShellListener</i>. 110 */ 110 111 public void addGShellListener(GShellListener listener) { 111 112 listeners.add(GShellListener.class, listener); 112 113 } 113 114 /** This method removes a certain shell listener from this process. 114 115 115 * @param listener The <i>GShellListener</i> to be removed. 116 */ 116 117 public void removeGShellListener(GShellListener listener) { 117 118 listeners.remove(GShellListener.class, listener); … … 150 151 } 151 152 ///ystem.err.println("Command: " + command); 152 fireMessage(type, get("GShell.Command") + ": " + command, status);153 fireMessage(type, Dictionary.newget("GShell.Command") + ": " + command, status); 153 154 154 155 Runtime rt = Runtime.getRuntime(); … … 188 189 if(prcs.exitValue() == 0) { 189 190 status = OK; 190 fireMessage(type, typeAsString(type) + "> " + get("GShell.Success"), status);191 fireMessage(type, typeAsString(type) + "> " + Dictionary.newget("GShell.Success"), status); 191 192 192 193 } else { 193 194 status = ERROR; 194 fireMessage(type, typeAsString(type) + "> " + get("GShell.Failure"), status);195 fireMessage(type, typeAsString(type) + "> " + Dictionary.newget("GShell.Failure"), status); 195 196 196 197 } … … 211 212 // If no error occured, and this was an import process we now extract any new metadata from the archive directory. 212 213 if(status == OK && type == IMPORT) { 213 fireMessage(type, typeAsString(type) + "> " + get("GShell.Parsing_Metadata_Start"), status);214 fireMessage(type, typeAsString(type) + "> " + Dictionary.newget("GShell.Parsing_Metadata_Start"), status); 214 215 new GreenstoneArchiveParser(progress, this); 215 fireMessage(type, typeAsString(type) + "> " + get("GShell.Parsing_Metadata_Complete"), status);216 fireMessage(type, typeAsString(type) + "> " + Dictionary.newget("GShell.Parsing_Metadata_Complete"), status); 216 217 } 217 218 // Tidy up. … … 233 234 } 234 235 /** Method for firing a message to all interested listeners. 235 236 237 238 236 * @param type An <strong>int</strong> indicating the process type. 237 * @param message The message as a <strong>String</strong>. 238 * @param status An <strong>int</strong> specifying the current status of the process. 239 */ 239 240 public void fireMessage(int type, String message, int status) { 240 241 GShellEvent event = new GShellEvent(this, 0, type, message, status); … … 248 249 249 250 /** Method for firing a process begun event which is called, strangly enough, when the process begins. 250 251 252 251 * @param type An <strong>int</strong> indicating the process type. 252 * @param status An <strong>int</strong> specifying the current status of the process. 253 */ 253 254 protected void fireProcessBegun(int type, int status) { 254 255 GShellEvent event = new GShellEvent(this, 0, type, "", status); … … 261 262 } 262 263 /** Method for firing a process complete event which is called, no surprise here, when the process ends. 263 264 265 264 * @param type An <strong>int</strong> indicating the process type. 265 * @param status An <strong>int</strong> specifying the current status of the process. 266 */ 266 267 protected void fireProcessComplete(int type, int status) { 267 268 GShellEvent event = new GShellEvent(this, 0, type, "", status); … … 273 274 } 274 275 } 275 /** Retrieve a phrase from the dictionary based on the given key. 276 * @param key A <strong>String</strong> used to match against a phrase from the <strong>Dictionary</strong>. 277 * @return The phrase as a <strong>String</strong>. 278 */ 279 private String get(String key) { 280 if(key.indexOf('.') == -1) { 281 key = "GShell." + key; 282 } 283 return Gatherer.dictionary.get(key); 284 } 276 285 277 /** Method to determine if the user, via the progress monitor, has signalled stop. 286 287 278 * @return A <strong>boolean</strong> indicating if the user wanted to stop. 279 */ 288 280 private boolean hasSignalledStop() { 289 281 boolean has_signalled_stop = false; … … 295 287 296 288 /** Converts a type into a text representation. 297 298 299 289 * @param type An <strong>int</strong> which maps to a shell process type. 290 * @return A <strong>String</strong> which is the thread process's text name. 291 */ 300 292 public String typeAsString(int type) { 301 293 String name = null; 302 294 switch(type) { 303 295 case BUILD: 304 name = get("GShell.Build");296 name = Dictionary.newget("GShell.Build"); 305 297 break; 306 298 case IMPORT: 307 name = get("GShell.Import");299 name = Dictionary.newget("GShell.Import"); 308 300 break; 309 301 case NEW: 310 name = get("GShell.New");302 name = Dictionary.newget("GShell.New"); 311 303 break; 312 304 default: 313 name = get("GShell.Other");305 name = Dictionary.newget("GShell.Other"); 314 306 } 315 307 return name;
Note:
See TracChangeset
for help on using the changeset viewer.