[Jsxe-cvs] SF.net SVN: jsxe: [960] trunk/jsxe
Status: Inactive
Brought to you by:
ian_lewis
From: <ian...@us...> - 2006-06-15 17:30:34
|
Revision: 960 Author: ian_lewis Date: 2006-06-15 10:30:21 -0700 (Thu, 15 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=960&view=rev Log Message: ----------- Added a new status column to the plugin manager dialog Added new plugin properties for the plugin author and release date Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/messages/messages.en trunk/jsxe/src/net/sourceforge/jsxe/JARClassLoader.java trunk/jsxe/src/net/sourceforge/jsxe/PluginDependencyException.java trunk/jsxe/src/net/sourceforge/jsxe/gui/PluginManagerDialog.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-06-15 13:11:53 UTC (rev 959) +++ trunk/jsxe/Changelog 2006-06-15 17:30:21 UTC (rev 960) @@ -1,3 +1,8 @@ +06/15/2006 Ian Lewis <Ian...@me...> + + * Added a new Status column to the Plugin Manager dialog + * Added new plugin properties for the plugin author and release date + 06/14/2006 Ian Lewis <Ian...@me...> * Added the EditAction class for future actions in jsXe. Modified: trunk/jsxe/messages/messages.en =================================================================== --- trunk/jsxe/messages/messages.en 2006-06-15 13:11:53 UTC (rev 959) +++ trunk/jsxe/messages/messages.en 2006-06-15 17:30:21 UTC (rev 960) @@ -87,6 +87,16 @@ Document.Options.Soft.Tabs.ToolTip=If this box is checked then tab characters are replaced by spaces. #}}} +#{{{ Plugin Manager +Plugin.Manager.Title=Plugin Manager +Plugin.Manager.Name.Column.Header=Name +Plugin.Manager.Version.Column.Header=Version +Plugin.Manager.Status.Column.Header=Status +Plugin.Manager.Loaded.Status=Loaded +Plugin.Manager.Not.Loaded.Status=Not Loaded +Plugin.Manager.Broken.Status=Error +#}}} + #{{{ Menu Items File.Menu=File @@ -113,7 +123,6 @@ Tools.Document.Options=Document Options... Tools.Plugin=Plugin Manager... Tools.ValidationErrors=Validation Errors... -Plugin.Manager.Title=Plugin Manager Help.About=About jsXe... #}}} @@ -142,6 +151,9 @@ Plugin.Load.Already.Loaded=Plugin {0} already loaded. Plugin.Load.Wrong.Main.Class=Main class is not a plugin class. Plugin.Load.No.Plugin.Class=No plugin class defined. +Plugin.Load.No.Plugin.Name=No plugin name defined. +Plugin.Load.No.Plugin.HR.Name=No plugin human-readable name defined. +Plugin.Load.No.Plugin.Version=No plugin version defined. # {0} plugin name # {1} requirement name Modified: trunk/jsxe/src/net/sourceforge/jsxe/JARClassLoader.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/JARClassLoader.java 2006-06-15 13:11:53 UTC (rev 959) +++ trunk/jsxe/src/net/sourceforge/jsxe/JARClassLoader.java 2006-06-15 17:30:21 UTC (rev 960) @@ -52,24 +52,36 @@ //{{{ Public static members /** * The manifest property that specifies the plugin name. + * Note: This property is required */ public static final String PLUGIN_NAME = "jsxe-plugin-name"; /** * The manifest property that specifies the plugin class + * Note: This property is required */ public static final String PLUGIN_CLASS = "jsxe-plugin-class"; /** * The manifest property that specifies the plugin version + * Note: This property is required */ public static final String PLUGIN_VERSION = "jsxe-plugin-version"; /** + * The manifest property that specifies a human readable name for the plugin + * Note: This property is required + */ + public static final String PLUGIN_HUMAN_READABLE_NAME = "jsxe-plugin-human-readable-name"; + /** + * The manifest property that specifies the plugin Author + */ + public static final String PLUGIN_AUTHOR = "jsxe-plugin-author"; + /** * The manifest property that specifies the plugin URL */ - public static final String PLUGIN_URL = "jsxe-plugin-url"; + public static final String PLUGIN_RELEASE_DATE = "jsxe-plugin-release-date"; /** - * The manifest property that specifies a human readable name for the plugin + * The manifest property that specifies the plugin URL */ - public static final String PLUGIN_HUMAN_READABLE_NAME = "jsxe-plugin-human-readable-name"; + public static final String PLUGIN_URL = "jsxe-plugin-url"; /** * The manifest property that specifies the plugin description */ @@ -605,6 +617,8 @@ String url = getManifestAttribute(jarFile, PLUGIN_URL); String humanReadableName = getManifestAttribute(jarFile, PLUGIN_HUMAN_READABLE_NAME); String description = getManifestAttribute(jarFile, PLUGIN_DESCRIPTION); + String author = getManifestAttribute(jarFile, PLUGIN_AUTHOR); + String releaseDate = getManifestAttribute(jarFile, PLUGIN_RELEASE_DATE); //prefix with both the plugin name and class m_pluginProperties.setProperty(propPrefix1+PLUGIN_NAME, pluginName); @@ -621,6 +635,14 @@ m_pluginProperties.setProperty(propPrefix1+PLUGIN_URL, url); m_pluginProperties.setProperty(propPrefix2+PLUGIN_URL, url); } + if (author != null) { + m_pluginProperties.setProperty(propPrefix1+PLUGIN_AUTHOR, author); + m_pluginProperties.setProperty(propPrefix2+PLUGIN_AUTHOR, author); + } + if (releaseDate != null) { + m_pluginProperties.setProperty(propPrefix1+PLUGIN_RELEASE_DATE, releaseDate); + m_pluginProperties.setProperty(propPrefix2+PLUGIN_RELEASE_DATE, releaseDate); + } if (humanReadableName != null) { m_pluginProperties.setProperty(propPrefix1+PLUGIN_HUMAN_READABLE_NAME, humanReadableName); m_pluginProperties.setProperty(propPrefix2+PLUGIN_HUMAN_READABLE_NAME, humanReadableName); @@ -656,78 +678,87 @@ String mainPluginClass = getManifestAttribute(jarfile, PLUGIN_CLASS); String pluginName = getManifestAttribute(jarfile, PLUGIN_NAME); + String humanReadableName = getManifestAttribute(jarfile, PLUGIN_HUMAN_READABLE_NAME); + String version = getManifestAttribute(jarfile, PLUGIN_VERSION); if (getPlugin(pluginName) != null) { throw new PluginLoadException(jarfile, Messages.getMessage("Plugin.Load.Already.Loaded", new Object[] { pluginName })); } - if (mainPluginClass != null && pluginName != null) { + if (mainPluginClass == null) { + throw new PluginLoadException(jarfile, Messages.getMessage("Plugin.Load.No.Plugin.Class")); + } + if (pluginName == null) { + throw new PluginLoadException(jarfile, Messages.getMessage("Plugin.Load.No.Plugin.Name")); + } + if (humanReadableName == null) { + throw new PluginLoadException(jarfile, Messages.getMessage("Plugin.Load.No.Plugin.HR.Name")); + } + if (version == null) { + throw new PluginLoadException(jarfile, Messages.getMessage("Plugin.Load.No.Plugin.Version")); + } + try { + + checkDependencies(jarfile); + + //load the plugin's localized messages + Log.log(Log.NOTICE, this, "Loading localized messages for plugin: "+pluginName); + Properties pluginMessages = new Properties(); try { + InputStream stream = jarfile.getInputStream(jarfile.getEntry("messages/messages.en")); + pluginMessages.load(stream); + Messages.loadPluginMessages(pluginMessages); + } catch (IOException e) { + Log.log(Log.WARNING, this, "Plugin "+pluginName+" does not have default messages.en"); + } + try { + InputStream stream = jarfile.getInputStream(jarfile.getEntry("messages/messages."+Messages.getLanguage())); + pluginMessages.load(stream); + Messages.loadPluginMessages(pluginMessages); + } catch (IOException e) { + Log.log(Log.WARNING, this, "Plugin "+pluginName+" does not have localized messages."+Messages.getLanguage()); + } + + Class pluginClass = loadClass(mainPluginClass); + + int modifiers = pluginClass.getModifiers(); + if (!Modifier.isInterface(modifiers) + && !Modifier.isAbstract(modifiers) + && ActionPlugin.class.isAssignableFrom(pluginClass)) { - checkDependencies(jarfile); + Object plugin = pluginClass.newInstance(); - //load the plugin's localized messages - Log.log(Log.NOTICE, this, "Loading localized messages for plugin: "+pluginName); - Properties pluginMessages = new Properties(); - try { - InputStream stream = jarfile.getInputStream(jarfile.getEntry("messages/messages.en")); - pluginMessages.load(stream); - Messages.loadPluginMessages(pluginMessages); - } catch (IOException e) { - Log.log(Log.WARNING, this, "Plugin "+pluginName+" does not have default messages.en"); - } - try { - InputStream stream = jarfile.getInputStream(jarfile.getEntry("messages/messages."+Messages.getLanguage())); - pluginMessages.load(stream); - Messages.loadPluginMessages(pluginMessages); - } catch (IOException e) { - Log.log(Log.WARNING, this, "Plugin "+pluginName+" does not have localized messages."+Messages.getLanguage()); - } - - Class pluginClass = loadClass(mainPluginClass); - - int modifiers = pluginClass.getModifiers(); - if (!Modifier.isInterface(modifiers) - && !Modifier.isAbstract(modifiers) - && ActionPlugin.class.isAssignableFrom(pluginClass)) { - - Object plugin = pluginClass.newInstance(); - - if (ViewPlugin.class.isAssignableFrom(pluginClass)) { - //It's a view plugin - Log.log(Log.NOTICE, this, "Started View Plugin: "+pluginName); - ViewPlugin viewPlugin = (ViewPlugin)plugin; - m_viewPlugins.put(pluginName, viewPlugin); - } else { - //It's an Action plugin - Log.log(Log.NOTICE, this, "Started Action Plugin: "+pluginName); - ActionPlugin actionPlugin = (ActionPlugin)plugin; - m_actionPlugins.put(pluginName, actionPlugin); - } + if (ViewPlugin.class.isAssignableFrom(pluginClass)) { + //It's a view plugin + Log.log(Log.NOTICE, this, "Started View Plugin: "+pluginName); + ViewPlugin viewPlugin = (ViewPlugin)plugin; + m_viewPlugins.put(pluginName, viewPlugin); } else { - /* - It's not a plugin. No biggie. We needed it to be loaded - anyway. - */ - throw new PluginLoadException(jarfile, Messages.getMessage("Plugin.Load.Wrong.Main.Class")); + //It's an Action plugin + Log.log(Log.NOTICE, this, "Started Action Plugin: "+pluginName); + ActionPlugin actionPlugin = (ActionPlugin)plugin; + m_actionPlugins.put(pluginName, actionPlugin); } - } catch (ClassNotFoundException e) { - throw new IOException(e.getMessage()); - } catch (InstantiationException e) { - throw new IOException(e.getMessage()); - } catch (IllegalAccessException e) { - throw new IOException(e.getMessage()); - } catch (PluginDependencyException e) { - m_actionPlugins.put(pluginName, new ActionPlugin.Broken()); - throw e; - } catch (IOException e) { - m_actionPlugins.put(pluginName, new ActionPlugin.Broken()); - throw e; + } else { + /* + It's not a plugin. No biggie. We needed it to be loaded + anyway. + */ + throw new PluginLoadException(jarfile, Messages.getMessage("Plugin.Load.Wrong.Main.Class")); } - - } else { - throw new PluginLoadException(jarfile, Messages.getMessage("Plugin.Load.No.Plugin.Class")); + } catch (ClassNotFoundException e) { + throw new IOException(e.getMessage()); + } catch (InstantiationException e) { + throw new IOException(e.getMessage()); + } catch (IllegalAccessException e) { + throw new IOException(e.getMessage()); + } catch (PluginDependencyException e) { + m_actionPlugins.put(pluginName, new ActionPlugin.Broken()); + throw e; + } catch (IOException e) { + m_actionPlugins.put(pluginName, new ActionPlugin.Broken()); + throw e; } }//}}} Modified: trunk/jsxe/src/net/sourceforge/jsxe/PluginDependencyException.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/PluginDependencyException.java 2006-06-15 13:11:53 UTC (rev 959) +++ trunk/jsxe/src/net/sourceforge/jsxe/PluginDependencyException.java 2006-06-15 17:30:21 UTC (rev 960) @@ -45,7 +45,7 @@ * @param versionFound the version that was found. */ public PluginDependencyException(String pluginName, String requiredName, String versionRequired, String versionFound) { - super(Messages.getMessage("Plugin.Dependency.Message", new Object[] { pluginName, requiredName, versionRequired, versionFound })); + super(pluginName+": "+Messages.getMessage("Plugin.Dependency.Message", new Object[] { pluginName, requiredName, versionRequired, versionFound })); m_pluginName = pluginName; m_requiredName = requiredName; m_versionRequired = versionRequired; @@ -62,9 +62,9 @@ * @param versionRequired the required version of the required component or plugin */ public PluginDependencyException(String pluginName, String requiredName, String versionRequired) { - super((versionRequired != null) ? + super(pluginName+": "+((versionRequired != null) ? Messages.getMessage("Plugin.Dependency.Not.Found", new Object[] { pluginName, requiredName, versionRequired }) : - Messages.getMessage("Plugin.Dependency.Not.Found2", new Object[] { pluginName, requiredName })); + Messages.getMessage("Plugin.Dependency.Not.Found2", new Object[] { pluginName, requiredName }))); m_pluginName = pluginName; m_requiredName = requiredName; m_versionRequired = versionRequired; @@ -78,7 +78,7 @@ * @param message the message */ public PluginDependencyException(String pluginName, String message) { - super(message); + super(pluginName+": "+message); m_pluginName = pluginName; m_requiredName = null; m_versionRequired = null; Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/PluginManagerDialog.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/PluginManagerDialog.java 2006-06-15 13:11:53 UTC (rev 959) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/PluginManagerDialog.java 2006-06-15 17:30:21 UTC (rev 960) @@ -103,7 +103,33 @@ DefaultListSelectionModel model = (DefaultListSelectionModel)e.getSource(); for (int i=0;i<m_pluginNames.size();i++) { if (model.isSelectedIndex(i)) { - descArea.setText(jsXe.getPluginLoader().getPluginProperty(m_pluginNames.get(i).toString(), JARClassLoader.PLUGIN_DESCRIPTION)); + JARClassLoader loader = jsXe.getPluginLoader(); + String releaseDate = loader.getPluginProperty(m_pluginNames.get(i).toString(), JARClassLoader.PLUGIN_RELEASE_DATE); + String author = loader.getPluginProperty(m_pluginNames.get(i).toString(), JARClassLoader.PLUGIN_AUTHOR); + String url = loader.getPluginProperty(m_pluginNames.get(i).toString(), JARClassLoader.PLUGIN_URL); + String desc = loader.getPluginProperty(m_pluginNames.get(i).toString(), JARClassLoader.PLUGIN_DESCRIPTION); + + StringBuffer text = new StringBuffer(); + if (author != null && !author.equals("")) { + text.append("Author: "); + text.append(author); + text.append("\n"); + } + if (releaseDate != null && !releaseDate.equals("")) { + text.append("Release Date: "); + text.append(releaseDate); + text.append("\n"); + } + if (url != null && !url.equals("")) { + text.append("URL: "); + text.append(url); + text.append("\n"); + } + if (desc != null) { + text.append(desc); + } + + descArea.setText(text.toString()); } } } @@ -163,62 +189,65 @@ } //}}} //{{{ PluginManagerTableModel class - private class PluginManagerTableModel implements TableModel { //{{{ addTableModelListener() - public void addTableModelListener(TableModelListener l) { //nothing }//}}} //{{{ getColumnClass() - public Class getColumnClass(int columnIndex) { return "".getClass(); }//}}} //{{{ getColumnCount() - public int getColumnCount() { - return 2; + return 3; }//}}} //{{{ getColumnName() - public String getColumnName(int columnIndex) { String name = null; - if (columnIndex == 0) { - name = "Name"; + switch (columnIndex) { + case 0: + return Messages.getMessage("Plugin.Manager.Name.Column.Header"); + case 1: + return Messages.getMessage("Plugin.Manager.Version.Column.Header"); + case 2: + return Messages.getMessage("Plugin.Manager.Status.Column.Header"); + default: + throw new Error("Column out of range"); } - if (columnIndex == 1) { - name = "Version"; - } - return name; }//}}} //{{{ getRowCount() - public int getRowCount() { return m_pluginNames.size(); }//}}} //{{{ getValueAt() - public Object getValueAt(int rowIndex, int columnIndex) { String value = null; JARClassLoader loader = jsXe.getPluginLoader(); - if (columnIndex == 0) { - value = loader.getPluginProperty(m_pluginNames.get(rowIndex).toString(), JARClassLoader.PLUGIN_HUMAN_READABLE_NAME); + switch (columnIndex) { + case 0: + return loader.getPluginProperty(m_pluginNames.get(rowIndex).toString(), JARClassLoader.PLUGIN_HUMAN_READABLE_NAME); + case 1: + return loader.getPluginProperty(m_pluginNames.get(rowIndex).toString(), JARClassLoader.PLUGIN_VERSION); + case 2: + ActionPlugin plugin = loader.getPlugin(m_pluginNames.get(rowIndex).toString()); + if (plugin instanceof ActionPlugin.Broken) { + return Messages.getMessage("Plugin.Manager.Broken.Status"); + } else { + return Messages.getMessage("Plugin.Manager.Loaded.Status"); + } + default: + throw new Error("Column out of range"); } - if (columnIndex == 1) { - value = loader.getPluginProperty(m_pluginNames.get(rowIndex).toString(), JARClassLoader.PLUGIN_VERSION); - } - return value; }//}}} //{{{ isCellEditable() - public boolean isCellEditable(int rowIndex, int columnIndex) { return false; }//}}} @@ -230,7 +259,6 @@ }//}}} //{{{ setValueAt() - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { // nothing. not supported. }//}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |