public void actionPerformed(ActionEvent evt) { final PluginDefinition def = model.getPluginDefinitionAt(table.getSelectedRow()); status1Text.setText("Updating " + def.getName()); statusIcon.setIcon(LARGE_UPDATE_ICON); Plugin sel = def.getPlugin(); Properties selPr = def.getLocalProperties(); String selRes = selPr.getProperty(PluginManager.PLUGIN_RESOURCE); if (selRes.equals("")) { JOptionPane.showMessageDialog( PluginManagerPane.this, "Plugin cannot be updated in this version of " + context.getPluginHostName(), "Error", JOptionPane.ERROR_MESSAGE, LARGE_REMOVE_ICON); return; } // Check what other plugins are in the same archive Vector allPlugins = getAllPluginsInResource(selRes); HashMap removeJars = getJarsToRemove(allPlugins); try { removeJars(removeJars); install(def); } catch (IOException ioe) { JOptionPane.showMessageDialog( PluginManagerPane.this, "Could not create remove list. " + ioe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } }
public void reload() { definitions.removeAllElements(); int c = manager.getPluginCount(); for (int i = 0; i < c; i++) { Plugin p = manager.getPluginAt(i); PluginDefinition def = new PluginDefinition(p, manager.getPluginProperties(p), null); Plugin sel = def.getPlugin(); Properties selPr = def.getLocalProperties(); String selRes = selPr.getProperty(PluginManager.PLUGIN_RESOURCE); if (showBuiltInPlugins || (selRes != null && !selRes.equals(""))) { definitions.addElement(def); } } fireTableDataChanged(); }
public void actionPerformed(ActionEvent evt) { PluginDefinition def = model.getPluginDefinitionAt(table.getSelectedRow()); Plugin sel = def.getPlugin(); Properties selPr = def.getLocalProperties(); String selRes = selPr.getProperty(PluginManager.PLUGIN_RESOURCE); if (selRes == null || selRes.equals("")) { JOptionPane.showMessageDialog( PluginManagerPane.this, "Plugin cannot be removed in this version of " + context.getPluginHostName(), "Error", JOptionPane.ERROR_MESSAGE, LARGE_REMOVE_ICON); return; } // Check what other plugins are in the same archive Vector allPlugins = getAllPluginsInResource(selRes); StringBuffer buf = new StringBuffer(); if (allPlugins.size() > 1) { buf.append( "This plugin is 1 of " + allPlugins.size() + " that are contained in the\n" + "same archive. Removal of this plugin will also\n" + "cause the removal of ...\n\n"); for (int i = 1; i < allPlugins.size(); i++) { buf.append(" "); Plugin p = (Plugin) allPlugins.elementAt(i); Properties pr = manager.getPluginProperties(p); buf.append(pr.getProperty(PluginManager.PLUGIN_SHORT_DESCRIPTION)); buf.append("\n"); } } // Get the jars to remove HashMap removeJars = getJarsToRemove(allPlugins); // buf.append("\nThe following files will be removed from your\n"); buf.append("plugin directory .. \n\n"); for (Iterator i = removeJars.keySet().iterator(); i.hasNext(); ) { String key = (String) i.next(); buf.append(" "); buf.append(key.substring(key.lastIndexOf(File.separator) + 1)); buf.append("\n"); } buf.append("\n"); buf.append("Are you sure you wish to continue?"); // The jars are not actually removed until the application restarts if (JOptionPane.showConfirmDialog( PluginManagerPane.this, buf.toString(), "Remove plugin", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { try { removeJars(removeJars); JOptionPane.showMessageDialog( PluginManagerPane.this, "You should now restart " + context.getPluginHostName(), "Information", JOptionPane.INFORMATION_MESSAGE, LARGE_REMOVE_ICON); } catch (IOException ioe) { JOptionPane.showMessageDialog( PluginManagerPane.this, "Could not create remove list. " + ioe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } }