Changeset 12642
- Timestamp:
- 2006-09-01T11:55:59+12:00 (18 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r12636 r12642 39 39 import org.greenstone.gatherer.GAuthenticator; 40 40 import org.greenstone.gatherer.cdm.ClassifierManager; 41 import org.greenstone.gatherer.cdm.PluginManager;42 41 import org.greenstone.gatherer.collection.CollectionManager; 43 42 import org.greenstone.gatherer.feedback.ActionRecorderDialog; … … 45 44 import org.greenstone.gatherer.file.FileAssociationManager; 46 45 import org.greenstone.gatherer.file.RecycleBin; 46 import org.greenstone.gatherer.greenstone.Plugins; 47 47 import org.greenstone.gatherer.gui.GUIManager; 48 48 import org.greenstone.gatherer.gui.URLField; … … 437 437 // Get a list of the core Greenstone classifiers and plugins 438 438 ClassifierManager.loadClassifiersList(); 439 Plugin Manager.loadPluginsList();439 Plugins.loadPluginsList(); 440 440 } 441 441 -
trunk/gli/src/org/greenstone/gatherer/cdm/Plugin.java
r12637 r12642 30 30 import java.util.*; 31 31 import org.greenstone.gatherer.DebugStream; 32 import org.greenstone.gatherer.greenstone.Plugins; 32 33 import org.greenstone.gatherer.util.StaticStrings; 33 34 import org.w3c.dom.*; … … 71 72 String plugin_name = element.getAttribute(StaticStrings.TYPE_ATTRIBUTE); 72 73 // Determine the base plugin from the plugin name 73 Plugin base_plugin = Plugin Manager.getPlugin(plugin_name, true);74 Plugin base_plugin = Plugins.getPlugin(plugin_name, true); 74 75 Plugin plugin = new Plugin(element, base_plugin); 75 76 if (base_plugin == null) { … … 85 86 public boolean doesExplodeMetadataDatabases() 86 87 { 87 Plugin base_plugin = Plugin Manager.getPlugin(getName(), false);88 Plugin base_plugin = Plugins.getPlugin(getName(), false); 88 89 if (base_plugin == null) { 89 90 return false; -
trunk/gli/src/org/greenstone/gatherer/cdm/PluginManager.java
r12641 r12642 43 43 import org.greenstone.gatherer.LocalGreenstone; 44 44 import org.greenstone.gatherer.collection.CollectionContentsChangedListener; 45 import org.greenstone.gatherer.greenstone.Plugins; 45 46 import org.greenstone.gatherer.gui.DesignPaneHeader; 46 47 import org.greenstone.gatherer.gui.GComboBox; … … 62 63 implements CollectionContentsChangedListener 63 64 { 64 // A list of all the plugins in the core Greenstone "perllib/plugins" folder (arguments may not be loaded)65 static private ArrayList core_greenstone_plugins_list = null;66 67 65 /** When asking how many rows are in the model, and if this variables value is true, then this modifier alters the number returned. This funtionality is used to hide the last three rows of the list in low detail modes. */ 68 66 private boolean modify_row_count = false; … … 92 90 93 91 94 // --------------------------------------------------------------------------------------------------------95 96 97 92 /** Retrieve a list of the plugins that are available to be added to the collection. */ 98 93 private Object[] getAvailablePlugins() … … 101 96 102 97 // Add all the non-abstract core Greenstone plugins, except for ArcPlug and RecPlug 103 for (int i = 0; i < core_greenstone_plugins_list.size(); i++) { 104 Plugin plugin = (Plugin) core_greenstone_plugins_list.get(i); 98 ArrayList plugins_list = Plugins.getPluginsList(); 99 for (int i = 0; i < plugins_list.size(); i++) { 100 Plugin plugin = (Plugin) plugins_list.get(i); 105 101 if (!plugin.isAbstract()) { 106 102 String plugin_name = plugin.getName(); … … 126 122 { 127 123 ArrayList exploder_plugins = new ArrayList(); 128 for (int i = 0; i < core_greenstone_plugins_list.size(); i++) { 129 Plugin plugin = (Plugin) core_greenstone_plugins_list.get(i); 124 ArrayList plugins_list = Plugins.getPluginsList(); 125 for (int i = 0; i < plugins_list.size(); i++) { 126 Plugin plugin = (Plugin) plugins_list.get(i); 130 127 if (plugin.doesExplodeMetadataDatabases() == true && plugin.doesProcessFile(file)) { 131 128 exploder_plugins.add(plugin); … … 134 131 135 132 return exploder_plugins; 136 }137 138 139 static public Plugin getPlugin(String plugin_name, boolean arguments_required)140 {141 for (int i = 0; i < core_greenstone_plugins_list.size(); i++) {142 Plugin plugin = (Plugin) core_greenstone_plugins_list.get(i);143 if (plugin.getName().equals(plugin_name)) {144 if (arguments_required) {145 if (plugin.getArguments().size() == 0) {146 loadPluginInfo(plugin);147 }148 else {149 DebugStream.println("Already loaded arguments for " + plugin_name + "!");150 }151 }152 return plugin;153 }154 }155 156 return null;157 133 } 158 134 … … 160 136 public boolean isFileExplodable(File file) 161 137 { 162 for (int i = 0; i < core_greenstone_plugins_list.size(); i++) { 163 Plugin plugin = (Plugin) core_greenstone_plugins_list.get(i); 138 ArrayList plugins_list = Plugins.getPluginsList(); 139 for (int i = 0; i < plugins_list.size(); i++) { 140 Plugin plugin = (Plugin) plugins_list.get(i); 164 141 if (plugin.doesExplodeMetadataDatabases() == true && plugin.doesProcessFile(file) == true) { 165 142 return true; … … 169 146 return false; 170 147 } 171 172 173 static private void loadPluginInfo(Plugin plugin)174 {175 DebugStream.println("Loading arguments for " + plugin.getName() + "...");176 177 // Run pluginfo.pl to get the list of plugins178 try {179 StringBuffer xml = null;180 if (Gatherer.isGsdlRemote) {181 String pluginfo_output = RemoteGreenstoneServer.getScriptOptions("pluginfo.pl", "&plugin=" + plugin);182 xml = new StringBuffer(pluginfo_output);183 }184 else {185 ArrayList args = new ArrayList();186 if (Utility.isWindows()) {187 args.add(Configuration.perl_path);188 args.add("-S");189 }190 args.add(LocalGreenstone.getBinScriptDirectoryPath() + "pluginfo.pl");191 args.add("-xml");192 args.add("-language");193 args.add(Configuration.getLanguage());194 args.add(plugin.getName());195 196 // Run the pluginfo.pl process197 Runtime runtime = Runtime.getRuntime();198 Process process = runtime.exec((String[]) args.toArray(new String[] { }));199 InputStream input_stream = process.getErrorStream();200 xml = XMLTools.readXMLStream(input_stream);201 }202 203 if (xml.length() > 0) {204 parsePluginInfoXML(plugin, xml.toString());205 }206 else {207 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.PlugInManager.PlugIn_XML_Parse_Failed", plugin.getName()), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);208 }209 }210 catch (Exception exception) {211 DebugStream.printStackTrace(exception);212 }213 }214 215 216 static public void loadPluginsList()217 {218 DebugStream.println("In loadPluginsList()...");219 220 // Run pluginfo.pl to get the list of plugins221 try {222 StringBuffer xml = null;223 if (Gatherer.isGsdlRemote) {224 String pluginfo_output = RemoteGreenstoneServer.getScriptOptions("pluginfo.pl", "&listall");225 xml = new StringBuffer(pluginfo_output);226 }227 else {228 ArrayList args = new ArrayList();229 if (Utility.isWindows()) {230 args.add(Configuration.perl_path);231 args.add("-S");232 }233 args.add(LocalGreenstone.getBinScriptDirectoryPath() + "pluginfo.pl");234 args.add("-listall");235 args.add("-xml");236 237 // Run the pluginfo.pl process238 Runtime runtime = Runtime.getRuntime();239 Process process = runtime.exec((String[]) args.toArray(new String[] { }));240 InputStream input_stream = process.getErrorStream();241 xml = XMLTools.readXMLStream(input_stream);242 }243 244 if (xml.length() > 0) {245 core_greenstone_plugins_list = parsePluginsListXML(xml.toString());246 }247 else {248 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.PluginManager.Plugin_List_XML_Parse_Failed"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);249 }250 }251 catch (Exception exception) {252 DebugStream.println("Failed when trying to list plugins.");253 DebugStream.printStackTrace(exception);254 }255 }256 257 258 static private void parsePluginInfoXML(Plugin plugin, String xml)259 {260 Document document = XMLTools.parseXML(new StringReader(xml));261 parsePluginInfoXMLNode(plugin, document.getDocumentElement());262 }263 264 265 static private void parsePluginInfoXMLNode(Plugin plugin, Node root_node)266 {267 for (Node node = root_node.getFirstChild(); node != null; node = node.getNextSibling()) {268 String node_name = node.getNodeName();269 270 if (node_name.equalsIgnoreCase("Name")) {271 plugin.setName(XMLTools.getValue(node));272 }273 else if (node_name.equals("Desc")) {274 plugin.setDescription(XMLTools.getValue(node));275 }276 else if (node_name.equals("Abstract")) {277 plugin.setIsAbstract(XMLTools.getValue(node).equalsIgnoreCase(StaticStrings.YES_STR));278 }279 else if (node_name.equalsIgnoreCase("Explodes")) {280 plugin.setDoesExplodeMetadataDatabases(XMLTools.getValue(node).equalsIgnoreCase(StaticStrings.YES_STR));281 }282 else if (node_name.equalsIgnoreCase("Processes")) {283 plugin.setDefaultProcessExpression(XMLTools.getValue(node));284 }285 else if (node_name.equalsIgnoreCase("Blocks")) {286 plugin.setDefaultBlockExpression(XMLTools.getValue(node));287 }288 // Parse the plugin arguments289 else if (node_name.equalsIgnoreCase("Arguments")) {290 for (Node argument_node = node.getFirstChild(); argument_node != null; argument_node = argument_node.getNextSibling()) {291 // An option292 if (argument_node.getNodeName().equalsIgnoreCase("Option")) {293 Argument argument = new Argument();294 argument.parseXML((Element) argument_node);295 plugin.addArgument(argument);296 }297 }298 }299 // A super plugin class300 else if (node_name.equalsIgnoreCase("PlugInfo")) {301 Plugin super_plugin = new Plugin();302 parsePluginInfoXMLNode(super_plugin, node);303 plugin.setSuper(super_plugin);304 }305 }306 }307 308 309 static private ArrayList parsePluginsListXML(String xml)310 {311 ArrayList plugins_list = new ArrayList();312 313 Document document = XMLTools.parseXML(new StringReader(xml));314 Node root = document.getDocumentElement();315 for (Node node = root.getFirstChild(); node != null; node = node.getNextSibling()) {316 String node_name = node.getNodeName();317 318 if (node_name.equals("PlugInfo")) {319 Plugin plugin = new Plugin();320 parsePluginInfoXMLNode(plugin, node);321 plugins_list.add(plugin);322 }323 }324 325 return plugins_list;326 }327 328 329 // --------------------------------------------------------------------------------------------------------330 148 331 149 … … 763 581 { 764 582 // Retrieve the plugin 765 Plugin plugin = getPlugin(plugin_name, true);583 Plugin plugin = Plugins.getPlugin(plugin_name, true); 766 584 if (plugin == null) { 767 585 System.err.println("Error: getPlugin() returned null."); … … 1130 948 { 1131 949 // Retrieve the plugin 1132 Plugin plugin = getPlugin(plugin_name, true);950 Plugin plugin = Plugins.getPlugin(plugin_name, true); 1133 951 if (plugin == null) { 1134 952 System.err.println("Error: getPlugin() returned null.");
Note:
See TracChangeset
for help on using the changeset viewer.