Changeset 4581
- Timestamp:
- 2003-06-11T16:35:29+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/PlugInManager.java
r4476 r4581 51 51 * @version 2.1 52 52 */ 53 import java.awt.BorderLayout; 54 import java.awt.Color; 55 import java.awt.Component; 56 import java.awt.Dimension; 57 import java.awt.GridLayout; 58 import java.awt.event.ActionEvent; 59 import java.awt.event.ActionListener; 60 import java.awt.event.KeyEvent; 61 import java.awt.event.MouseAdapter; 62 import java.awt.event.MouseEvent; 63 import java.io.BufferedReader; 64 import java.io.File; 65 import java.io.FileInputStream; 66 import java.io.FileOutputStream; 67 import java.io.InputStream; 68 import java.io.InputStreamReader; 69 import java.io.ObjectInputStream; 70 import java.io.ObjectOutputStream; 71 import java.io.StringReader; 72 import java.util.Collections; 73 import java.util.Vector; 74 import javax.swing.BorderFactory; 75 import javax.swing.Box; 76 import javax.swing.BoxLayout; 77 import javax.swing.ComboBoxModel; 78 import javax.swing.DefaultListCellRenderer; 79 import javax.swing.JButton; 80 import javax.swing.JComboBox; 81 import javax.swing.JLabel; 82 import javax.swing.JList; 83 import javax.swing.JOptionPane; 84 import javax.swing.JPanel; 85 import javax.swing.JPopupMenu; 86 import javax.swing.JScrollPane; 87 import javax.swing.JSeparator; 88 import javax.swing.JTextArea; 89 import javax.swing.event.ListSelectionEvent; 90 import javax.swing.event.ListSelectionListener; 53 import java.awt.*; 54 import java.awt.event.*; 55 import java.io.*; 56 import java.util.*; 57 import javax.swing.*; 58 import javax.swing.event.*; 91 59 import javax.swing.plaf.basic.BasicArrowButton; 92 60 import org.apache.xerces.parsers.DOMParser; … … 98 66 import org.greenstone.gatherer.cdm.PlugIn; 99 67 import org.greenstone.gatherer.util.Utility; 100 import org.w3c.dom.Document; 101 import org.w3c.dom.Node; 68 import org.w3c.dom.*; 102 69 import org.xml.sax.InputSource; 103 70 /** This class is resposible for maintaining a list of known plug-ins, and importing new plugins using the parser. */ … … 217 184 args[2] = getPlugInName(plugin); 218 185 } 219 for(int i = 0; i < args.length; i++) { 220 ///ystem.out.print(args[i] + " "); 221 } 222 ///ystem.out.print("\n"); 223 // Create the process. 186 // Create the process. 224 187 Runtime runtime = Runtime.getRuntime(); 225 188 Process process = runtime.exec(args); 226 189 //InputStream input_stream = process.getErrorStream(); 227 190 BufferedReader error_in = new BufferedReader(new InputStreamReader(process.getErrorStream())); 228 191 String line = ""; 229 192 StringBuffer xml = new StringBuffer(""); 193 boolean xml_content = false; 230 194 while((line = error_in.readLine()) != null) { 231 xml.append(line); 232 xml.append("\n"); 233 } 234 line = null; 195 if(xml_content) { 196 xml.append(line); 197 xml.append("\n"); 198 } 199 else if(line.trim().startsWith("<?xml")) { 200 xml_content = true; 201 xml.append(line); 202 xml.append("\n"); 203 } 204 } 235 205 error_in = null; 236 ///ystem.out.println("\n"); 237 // Then read the xml from the piped input stream. 238 InputSource source = new InputSource(new StringReader(xml.toString())); 239 DOMParser parser = new DOMParser(); 240 parser.parse(source); 241 document = parser.getDocument(); 206 process = null; 207 runtime = null; 208 args = null; 209 // If something has gone horribly wrong then xml will be empty. 210 if(xml.length() != 0) { 211 // Then read the xml from the piped input stream. 212 InputSource source = new InputSource(new StringReader(xml.toString())); 213 DOMParser parser = new DOMParser(); 214 parser.parse(source); 215 document = parser.getDocument(); 216 parser = null; 217 source = null; 218 } 219 else { 220 String plugin_name = getPlugInName(plugin); 221 Gatherer.println("Zero length argument xml detected for: " + plugin_name); 222 JOptionPane.showMessageDialog(Gatherer.g_man, get("PlugIn_XML_Parse_Failed", plugin_name), get("General.Error"), JOptionPane.ERROR_MESSAGE); 223 } 242 224 } 243 225 catch (Exception error) { … … 462 444 */ 463 445 private String get(String key) { 464 return get(key, null); 465 } 446 return get(key, (String[])null); 447 } 448 449 private String get(String key, String arg) { 450 String args[] = new String[1]; 451 args[0] = arg; 452 return get(key, args); 453 } 454 466 455 /* Retrieve a phrase from the dictionary based on a certain key and arguments. 467 456 * @param key The search <strong>String</strong>.
Note:
See TracChangeset
for help on using the changeset viewer.