source: trunk/gli/src/org/greenstone/gatherer/shell/GShell.java@ 8313

Last change on this file since 8313 was 8313, checked in by mdewsnip, 20 years ago

Finally committing the (many) changes to the GLI to use the new metadata code... I hope this doesn't have too many bugs in it and committing it now doesn't stuff anyone up! (Katherine said I could commit it, so blame her if anything goes wrong).

  • Property svn:keywords set to Author Date Id Revision
File size: 23.6 KB
Line 
1/**
2 *#########################################################################
3 *
4 * A component of the Gatherer application, part of the Greenstone digital
5 * library suite from the New Zealand Digital Library Project at the
6 * University of Waikato, New Zealand.
7 *
8 * <BR><BR>
9 *
10 * Author: John Thompson, Greenstone Digital Library, University of Waikato
11 *
12 * <BR><BR>
13 *
14 * Copyright (C) 1999 New Zealand Digital Library Project
15 *
16 * <BR><BR>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * <BR><BR>
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * <BR><BR>
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 *########################################################################
36 */
37package org.greenstone.gatherer.shell;
38
39import java.io.*;
40import java.net.*;
41import java.util.ArrayList;
42import java.util.Enumeration;
43import javax.swing.*;
44import javax.swing.event.*;
45import javax.swing.tree.*;
46import org.greenstone.gatherer.Configuration;
47import org.greenstone.gatherer.DebugStream;
48import org.greenstone.gatherer.Dictionary;
49import org.greenstone.gatherer.Gatherer;
50import org.greenstone.gatherer.GathererApplet;
51import org.greenstone.gatherer.cdm.CollectionConfiguration;
52import org.greenstone.gatherer.cdm.CollectionDesignManager;
53import org.greenstone.gatherer.cdm.CollectionMetaManager;
54import org.greenstone.gatherer.cdm.CollectionMeta;
55import org.greenstone.gatherer.metadata.DocXMLFileManager;
56import org.greenstone.gatherer.util.StaticStrings;
57import org.greenstone.gatherer.util.Utility;
58
59/** The <strong>GShell</strong> is reponsible for running a separately threaded process in the command shell. This is necessary for executing the Perl Scripts and also for other system related funcitonality.
60 */
61public class GShell
62 extends Thread {
63 /** A flag used to determine if this process has been asked to cancel. */
64 private boolean cancel = false;
65 /** The list of listeners associated with this class. */
66 private EventListenerList listeners = null;
67 /** The current status of this shell process. */
68 private int status = -1;
69 /** The type of message being sent. */
70 private int msg_type = -1;
71 /** The type of shell process. */
72 private int type = -1;
73 /** The caller of this process, and thus the class most interested in messages. */
74 private GShellListener caller = null;
75 /** The progress monitor associated with this process. */
76 private GShellProgressMonitor progress = null;
77 /** Arguments to be given to the process (including the executable you are calling. */
78 private String args[] = null;
79 /** Element in process type enumeration. */
80 static final public int BUILD = 0;
81 /** Element in process type enumeration. */
82 static final public int IMPORT = 1;
83 /** Element in process type enumeration. */
84 static final public int NEW = 2;
85 /** Element in process type enumeration. */
86 static final public int EXPORT = 3;
87 /** Element in process type enumeration. */
88 static final public int CONVERT = 4;
89 /** Element in process type enumeration. */
90 static final public int OTHER = 5;
91 /** Element in status type enumeration. */
92 static final public int ERROR = 0;
93 /** Element in status type enumeration. */
94 static final public int OK = 1;
95 static final public int CANCELLED = 2;
96 /** Element in process type name enumeration. */
97 static public String GSHELL_BUILD = "gshell_build";
98 /** Element in process type name enumeration. */
99 static public String GSHELL_IMPORT = "gshell_import";
100 /** Element in process type name enumeration. */
101 static public String GSHELL_NEW = "gshell_new";
102 /** Element in process type name enumeration */
103 static public String GSHELL_EXPORT = "gshell_export";
104 /** Element in process type name enumeration */
105 static public String GSHELL_CONVERT = "gshell_convert";
106
107 /** Determine if the given process is still executing. It does this by attempting to throw an exception - not the most efficient way, but the only one as far as I know
108 * @param process the Process to test
109 * @return true if it is still executing, false otherwise
110 */
111 static public boolean processRunning(Process process) {
112 boolean process_running = false;
113
114 try {
115 process.exitValue(); // This will throw an exception if the process hasn't ended yet.
116 }
117 catch(IllegalThreadStateException itse) {
118 process_running = true;
119 }
120 catch(Exception exception) {
121 DebugStream.printStackTrace(exception);
122 }
123 return process_running;
124 }
125
126 /** Constructor gatherer all the data required to create a new process, and emit meaningfull messages.
127 * @param args A <strong>String[]</strong> containing the arguments to the process thread, including the name of the executable.
128 * @param type An <strong>int</strong> that indicates what group of processes this process belongs to, as some are treated slightly differently (i.e an IMPORT type process is always followed by a BUILD one).
129 * @param msg_type As process threads may be background (like a makecol.pl call) or important processes in their own right (such as an IMPORT-BUILD) we must be able to set what level messages posted by this class will have by usings this <strong>int</strong>.
130 * @param caller The default <i>GShellListener</i> that is interested in the progress of this process.
131 * @param progress The <i>GShellProgressMonitor</i> associated with this process.
132 * @param name A <strong>String</strong> identifier given to the process, for convience and debug reasons.
133 */
134 public GShell(String args[], int type, int msg_type, GShellListener caller, GShellProgressMonitor progress, String name) {
135 super(name);
136 this.args = args;
137 this.msg_type = msg_type;
138 this.type = type;
139 this.caller = caller;
140 this.progress = progress;
141 this.status = 0;
142 // Lower this jobs priority
143 this.setPriority(Thread.MIN_PRIORITY);
144 listeners = new EventListenerList();
145 listeners.add(GShellListener.class, caller);
146 }
147 /** This method adds another shell listener to this process.
148 * @param listener The new <i>GShellListener</i>.
149 */
150 public void addGShellListener(GShellListener listener) {
151 listeners.add(GShellListener.class, listener);
152 }
153 /** This method removes a certain shell listener from this process.
154 * @param listener The <i>GShellListener</i> to be removed.
155 */
156 /* private void removeGShellListener(GShellListener listener) {
157 listeners.remove(GShellListener.class, listener);
158 } */
159
160
161
162 protected boolean got_stream_char(InputStreamReader isr, StringBuffer line_buffer,
163 BufferedOutputStream bos) throws IOException
164 {
165 // Hopefully this doesn't block if the process is trying to write to STDOUT/STDERR.
166
167 boolean input_status = false;
168
169 if(isr.ready()) {
170 input_status = true;
171 int c = isr.read();
172 if(c == '\n' || c == '\r') {
173 if(line_buffer.length() > 0) {
174 String line = line_buffer.toString();
175 DebugStream.println("* " + line + " *");
176 fireMessage(type, typeAsString(type) + "> " + line, status, bos);
177 line = null;
178 line_buffer = new StringBuffer();
179 }
180 }
181 else {
182 line_buffer.append((char)c);
183 }
184 }
185
186 return input_status;
187 }
188
189
190 protected StringBuffer get_stream_char(InputStreamReader isr, StringBuffer line_buffer,
191 BufferedOutputStream bos) throws IOException
192 {
193 int c = isr.read();
194 ///atherer.println("isr: '" + (char) c + "'");
195 if(c == '\n' || c == '\r') {
196 if(line_buffer.length() > 0) {
197 String line = line_buffer.toString();
198 // DebugStream.println("* " + line + " *");
199 fireMessage(type, typeAsString(type) + "> " + line, status, bos);
200 line_buffer = new StringBuffer();
201 }
202 }
203 else {
204 line_buffer.append((char)c);
205 }
206
207 return line_buffer;
208 }
209
210
211 protected int check_for_error(String line, StringBuffer error_list,
212 int error_count)
213 {
214 if (line.startsWith("ERROR:")) {
215 error_count++;
216 if (error_count<10) {
217 error_list.append(line);
218 }
219 else if (error_count==10) {
220 error_list.append("...\n");
221 }
222 }
223 return error_count;
224 }
225
226
227 protected void runRemote(String[] args, BufferedOutputStream bos)
228 {
229 try {
230
231 String perl_cmd = args[0];
232 int perl_cmd_root = perl_cmd.lastIndexOf(File.separator);
233
234 if (perl_cmd_root > 0) {
235 String perl_cmd_cut = perl_cmd.substring(perl_cmd_root+1);
236 perl_cmd = perl_cmd_cut;
237 }
238
239 String launch = Gatherer.cgiBase + "launch";
240 launch = launch + "?cmd=" + perl_cmd;
241
242 for(int i = 1; i<args.length; i++) {
243
244 String arg = args[i];
245
246 if (arg.equals("-collectdir") || arg.equals("-importdir")
247 || arg.equals("-builddir")) {
248 // skip it
249 i++;
250 continue;
251 }
252
253 launch += "&";
254
255 if(arg.startsWith(StaticStrings.MINUS_CHARACTER)) {
256 String name = arg.substring(1);
257 launch = launch + name + "=";
258 if (i+1<args.length-1) {
259 if (!args[i+1].startsWith(StaticStrings.MINUS_CHARACTER)) {
260 i++;
261 String val = URLEncoder.encode(args[i],"UTF-8");
262 launch = launch + val;
263 }
264 }
265 }
266 else {
267 launch = launch + "c=" + arg;
268 }
269 }
270
271 System.err.println("**** launch url = " + launch);
272 // fireMessage(type, Dictionary.get("GShell.Command") + ": " + launch, status, null); // ****
273
274 URL launch_url = new URL(launch);
275 URLConnection launch_connection = launch_url.openConnection();
276 InputStream stdis = launch_connection.getInputStream();
277 InputStreamReader stdisr = new InputStreamReader(stdis, "UTF-8");
278
279 BufferedReader stdbr = new BufferedReader(stdisr);
280
281 StringBuffer error_list = new StringBuffer();
282 int error_count = 0;
283
284 if (type == GShell.NEW) {
285 while(true) {
286 String line = stdbr.readLine();
287 if (line == null) { break; }
288 error_count = check_for_error(line,error_list,error_count);
289 }
290 }
291 else {
292 while(!hasSignalledStop()) {
293 String line = stdbr.readLine();
294 if (line == null) { break; }
295 error_count = check_for_error(line,error_list,error_count);
296 fireMessage(type, typeAsString(type) + "> " + line, status, bos);
297 }
298 }
299 stdbr.close();
300
301 if (error_count>0) {
302 status = ERROR;
303 System.err.println(error_list);
304 if (type != GShell.NEW) {
305 fireMessage(type, typeAsString(type) + "> " + error_list, status, null);
306 }
307 }
308 else {
309 status = OK;
310 fireMessage(type, typeAsString(type) + "> " + Dictionary.get("GShell.Success"), status, null);
311 }
312
313
314 }
315 // Exception
316 catch (Exception exception) {
317 System.err.println("Exception in GShell.runRemote() - unexpected");
318 DebugStream.printStackTrace(exception);
319 status = ERROR;
320 }
321 }
322
323
324 protected void runLocal(String[] args, BufferedOutputStream bos)
325 {
326 try {
327 String command = "";
328 for(int i = 0; i < args.length; i++) {
329 command = command + args[i] + " ";
330 }
331
332 DebugStream.println("Command: "+command);
333 ///ystem.err.println("Command: " + command);
334 fireMessage(type, Dictionary.get("GShell.Command") + ": " + command, status, null);
335
336 Runtime rt = Runtime.getRuntime();
337 Process prcs = rt.exec(args);
338
339 InputStreamReader eisr = new InputStreamReader( prcs.getErrorStream(), "UTF-8" );
340 InputStreamReader stdisr = new InputStreamReader( prcs.getInputStream(), "UTF-8" );
341
342 StringBuffer eline_buffer = new StringBuffer();
343 StringBuffer stdline_buffer = new StringBuffer();
344
345 while(type != GShell.NEW && processRunning(prcs) && !hasSignalledStop()) {
346 // Hopefully this doesn't block if the process is trying to write to STDOUT.
347 if((eisr!=null) && eisr.ready()) {
348 eline_buffer = get_stream_char(eisr,eline_buffer,bos);
349 }
350 // Hopefully this won't block if the process is trying to write to STDERR
351 else if(stdisr.ready()) {
352 stdline_buffer = get_stream_char(stdisr,stdline_buffer,bos);
353 }
354 else {
355 try {
356 sleep(100);
357 }
358 catch(Exception exception) {
359 }
360 }
361 }
362
363 if(!hasSignalledStop()) {
364 // Of course, just because the process is finished doesn't
365 // mean the incoming streams are empty. Unfortunately I've
366 // got no chance of preserving order, so I'll process the
367 // error stream first, then the out stream
368 while(eisr.ready()) {
369 eline_buffer = get_stream_char(eisr,eline_buffer,bos);
370 }
371
372 while(stdisr.ready()) {
373 stdline_buffer = get_stream_char(stdisr,stdline_buffer,bos);
374 }
375
376 // Ensure that any messages still remaining in the string buffers are fired off.
377 if(eline_buffer.length() > 0) {
378 String eline = eline_buffer.toString();
379 //DebugStream.println("Last bit of eline: " + eline);
380 fireMessage(type, typeAsString(type) + "> " + eline, status, bos);
381 eline = null;
382 }
383
384 if(stdline_buffer.length() > 0) {
385 String stdline = stdline_buffer.toString();
386 //DebugStream.println("Last bit of stdline: " + stdline);
387 fireMessage(type, typeAsString(type) + "> " + stdline, status, null);
388 stdline = null;
389 }
390 }
391 else {
392 System.err.println("We've been asked to stop.");
393 }
394
395
396 if(!hasSignalledStop()) {
397 // Now display final message based on exit value
398
399 prcs.waitFor();
400
401 if(prcs.exitValue() == 0) {
402 status = OK;
403 fireMessage(type, typeAsString(type) + "> " + Dictionary.get("GShell.Success"), status, null);
404 }
405 else {
406 status = ERROR;
407 fireMessage(type, typeAsString(type) + "> " + Dictionary.get("GShell.Failure"), status, null);
408 }
409
410 eisr.close();
411 stdisr.close();
412 }
413 else {
414 // I need to somehow kill the child process. Unfortunately
415 // Thread.stop() and Process.destroy() both fail to do
416 // this. But now, thankx to the magic of Michaels 'close the
417 // stream suggestion', it works fine (no it doesn't!)
418 prcs.getInputStream().close();
419 prcs.getErrorStream().close();
420 prcs.getOutputStream().close();
421 prcs.destroy();
422 status = CANCELLED;
423 }
424 }
425 // Exception
426 catch (Exception exception) {
427 DebugStream.println("Exception in GShell.runLocal() - unexpected");
428 DebugStream.printStackTrace(exception);
429 status = ERROR;
430 }
431 }
432
433
434
435 /** Any threaded class must include this method to allow the thread body to be run. */
436 public void run() {
437
438 String col_name = args[args.length-1];
439
440 // Determine if the user has asked for an outfile.
441 String out_name = null;
442 BufferedOutputStream bos = null;
443 if(type == IMPORT || type == BUILD) {
444 if(type == IMPORT) {
445 out_name = (String) Gatherer.c_man.getCollection().build_options.getImportValue("out");
446 }
447 else {
448 out_name = (String) Gatherer.c_man.getCollection().build_options.getBuildValue("out");
449 }
450 if(out_name != null && out_name.length() > 0) {
451 try {
452 bos = new BufferedOutputStream(new FileOutputStream(new File(out_name), true));
453 }
454 catch (Exception error) {
455 DebugStream.printStackTrace(error);
456 }
457 }
458 }
459
460 if (Gatherer.isGsdlRemote) {
461 if (type == IMPORT) {
462 if (progress!=null) {
463 progress.messageOnProgressBar("Uploading data to server");
464 }
465
466 // zip up import folder
467 Utility.zipup(col_name,"import");
468 // upload it to gsdl server
469 GathererApplet.upload_url_zip(col_name,"import");
470
471 // upload etc folder to server (need collect.cfg and any hfiles)
472 Utility.zipup(col_name, "etc");
473 GathererApplet.upload_url_zip(col_name,"etc");
474
475 String col_dir = Utility.getCollectionDir(Configuration.gsdl_path, col_name);
476 File img_dir = new File(Utility.getImagesDir(col_dir));
477 if (img_dir.exists()) {
478 // upload images/ directory to server
479 Utility.zipup(col_name,"images");
480 GathererApplet.upload_url_zip(col_name,"images");
481 }
482
483 // see if collection specific image needs uploading
484 CollectionMetaManager cmm
485 = CollectionDesignManager.collectionmeta_manager;
486
487 CollectionMeta icon_collection_collectionmeta
488 = cmm.getMetadatum(CollectionConfiguration.COLLECTIONMETADATA_ICONCOLLECTION_STR);
489 CollectionMeta icon_collection_small_collectionmeta
490 = cmm.getMetadatum(CollectionConfiguration.COLLECTIONMETADATA_ICONCOLLECTIONSMALL_STR);
491
492 String ics_text = icon_collection_collectionmeta.getValue(CollectionMeta.TEXT);
493 String icsc_text = icon_collection_small_collectionmeta.getValue(CollectionMeta.TEXT);
494 if ((ics_text != null) && (ics_text != "")) {
495 // Stub code for detecting when collectoin image changed
496 // => need to upload images
497 // System.err.println("**** ics_text = " + ics_text);
498 }
499
500
501 if (progress!=null) {
502 progress.messageOnProgressBar("");
503 }
504
505 }
506 }
507
508
509 // Issue a processBegun event
510 fireProcessBegun(type, status);
511 if (Gatherer.isGsdlRemote) {
512 runRemote(args,bos);
513 }
514 else {
515 runLocal(args,bos);
516 }
517
518 if(status == OK) {
519 if (type == NEW) {
520 if (Gatherer.isGsdlRemote) {
521 GathererApplet.download_url_zip(col_name,".");
522 Utility.unzip(col_name);
523 }
524 }
525 else if(type == IMPORT) {
526
527 // download the archives directory (if gsdl server is remote)
528 if (Gatherer.isGsdlRemote) {
529
530 if (progress!=null) {
531 progress.messageOnProgressBar("Downloading archive data from server");
532 }
533
534
535 Utility.delete(Gatherer.c_man.getCollectionArchive()); // remove current archives
536 GathererApplet.download_url_zip(col_name,"archives");
537 Utility.unzip(col_name);
538
539 if (progress!=null) {
540 progress.messageOnProgressBar("");
541 }
542 }
543
544 // Refresh the DocXMLFileManager
545 fireMessage(type, typeAsString(type) + "> " + Dictionary.get("GShell.Parsing_Metadata_Start"), status, null);
546 DocXMLFileManager.clearDocXMLFiles();
547 DocXMLFileManager.loadDocXMLFiles(new File(Gatherer.c_man.getCollectionArchive()));
548 fireMessage(type, typeAsString(type) + "> " + Dictionary.get("GShell.Parsing_Metadata_Complete"), status, null);
549 }
550
551// else if(type == BUILD) {
552
553// // download the building directory (if gsdl server is remote)
554// if (Gatherer.isGsdlRemote) {
555// if (progress!=null) {
556// progress.messageOnProgressBar("Downloading index data from server");
557// }
558
559// Utility.delete(Gatherer.c_man.getCollectionBuild()); // remove current build dir
560// GathererApplet.download_url_zip(col_name,"building");
561// Utility.unzip(col_name);
562
563// if (progress!=null) {
564// progress.messageOnProgressBar("");
565// }
566
567// }
568
569// }
570 }
571
572 if(hasSignalledStop()) {
573 status = CANCELLED;
574 }
575 // We're done.
576 fireProcessComplete(type, status);
577 // Close bos
578 if(bos != null) {
579 try {
580 bos.close();
581 bos = null;
582 }
583 catch(Exception error) {
584 DebugStream.printStackTrace(error);
585 }
586 }
587 }
588 /** Method for firing a message to all interested listeners.
589 * @param type An <strong>int</strong> indicating the process type.
590 * @param message The message as a <strong>String</strong>.
591 * @param status An <strong>int</strong> specifying the current status of the process.
592 */
593 public void fireMessage(int type, String message, int status, BufferedOutputStream bos) {
594 GShellEvent event = new GShellEvent(this, 0, type, message, status);
595 // If there is a progress monitor attached, pass the event to it first. Note that we pass a queue of messages as the processing may cause one message to be split into several.
596 ArrayList message_queue = new ArrayList();
597 message_queue.add(event);
598 if(progress != null) {
599 progress.process(message_queue);
600 }
601 for(int j = 0; j < message_queue.size(); j++) {
602 GShellEvent current_event = (GShellEvent) message_queue.get(j);
603 // If the event hasn't been vetoed, pass it on to other listeners
604 if(!current_event.isVetoed()) {
605 Object[] concerned = listeners.getListenerList();
606 for(int i = 0; i < concerned.length ; i++) {
607 if(concerned[i] == GShellListener.class) {
608 ((GShellListener)concerned[i+1]).message(current_event);
609 }
610 }
611 concerned = null;
612 }
613 }
614 // And if we have a buffered output stream from error messages, send the message there
615 if(bos != null) {
616 try {
617 bos.write(message.getBytes(), 0, message.length());
618 }
619 catch(Exception exception) {
620 DebugStream.println("Exception in GShell.fireMessage() - unexpected");
621 DebugStream.printStackTrace(exception);
622 }
623 }
624 message_queue = null;
625 event = null;
626 }
627
628 /** Method for firing a process begun event which is called, strangly enough, when the process begins.
629 * @param type An <strong>int</strong> indicating the process type.
630 * @param status An <strong>int</strong> specifying the current status of the process.
631 */
632 protected void fireProcessBegun(int type, int status) {
633 // Start the progres monitor if available
634 if(progress != null) {
635 progress.start();
636 }
637 // Fire an event
638 GShellEvent event = new GShellEvent(this, 0, type, "", status);
639 Object[] concerned = listeners.getListenerList();
640 for(int i = 0; i < concerned.length ; i++) {
641 if(concerned[i] == GShellListener.class) {
642 ((GShellListener)concerned[i+1]).processBegun(event);
643 }
644 }
645 }
646 /** Method for firing a process complete event which is called, no surprise here, when the process ends.
647 * @param type An <strong>int</strong> indicating the process type.
648 * @param status An <strong>int</strong> specifying the current status of the process.
649 */
650 protected void fireProcessComplete(int type, int status) {
651 // Tidy up by stopping the progress bar. If it was cancelled then the cancel command has arrived via the progress bars and they don't need to be told again (it actually causes problems).
652 if(progress != null && status != CANCELLED) {
653 progress.stop();
654 }
655
656 // If we were cancelled, and we are lower details modes, fire off one last message.
657 if(status == CANCELLED && Configuration.getMode() <= Configuration.SYSTEMS_MODE) {
658 GShellEvent current_event = new GShellEvent(this, 0, type, Dictionary.get("GShell.Build.BuildCancelled"), status);
659 Object[] concerned = listeners.getListenerList();
660 for(int i = 0; i < concerned.length ; i++) {
661 if(concerned[i] == GShellListener.class) {
662 ((GShellListener)concerned[i+1]).message(current_event);
663 }
664 }
665 concerned = null;
666 }
667 // And firing off an event
668 GShellEvent event = new GShellEvent(this, 0, type, "", status);
669 Object[] concerned = listeners.getListenerList();
670 for(int i = 0; i < concerned.length ; i++) {
671 if(concerned[i] == GShellListener.class) {
672 ((GShellListener)concerned[i+1]).processComplete(event);
673 }
674 }
675 }
676
677 /** Method to determine if the user, via the progress monitor, has signalled stop.
678 * @return A <strong>boolean</strong> indicating if the user wanted to stop.
679 */
680 private boolean hasSignalledStop() {
681 boolean has_signalled_stop = false;
682 if(progress != null) {
683 has_signalled_stop = progress.hasSignalledStop();
684 }
685 return has_signalled_stop;
686 }
687
688 /** Converts a type into a text representation.
689 * @param type An <strong>int</strong> which maps to a shell process type.
690 * @return A <strong>String</strong> which is the thread process's text name.
691 */
692 public String typeAsString(int type) {
693 String name = null;
694 switch(type) {
695 case BUILD:
696 name = Dictionary.get("GShell.Build");
697 break;
698 case IMPORT:
699 name = Dictionary.get("GShell.Import");
700 break;
701 case NEW:
702 name = Dictionary.get("GShell.New");
703 break;
704 case EXPORT:
705 name= Dictionary.get("GShell.Export");
706 break;
707 case CONVERT:
708 name = Dictionary.get("GShell.Convert");
709 break;
710 default:
711 name = Dictionary.get("GShell.Other");
712 }
713 return name;
714 }
715}
Note: See TracBrowser for help on using the repository browser.