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 actionPerformed(ActionEvent evt) {
   /** @todo install should warn about dependencies */
   final PluginDefinition def = model.getPluginDefinitionAt(table.getSelectedRow());
   status1Text.setText("Installing " + def.getName());
   statusIcon.setIcon(LARGE_INSTALL_ICON);
   install(def);
 }
 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 Object getValueAt(int r, int c) {
   PluginDefinition def = getPluginDefinitionAt(r);
   switch (c) {
     case 0:
       switch (def.getStatus()) {
         case NOT_INSTALLED:
           return "Not installed";
         case UPDATE_AVAILABLE:
           return "Update available";
         default:
           return "Installed";
       }
     case 1:
       return def.getName();
     case 2:
       String local = def.getLocalVersion();
       return local == null ? "<N/A>" : local;
     case 3:
       String remote = def.getRemoteVersion();
       return remote == null ? "<Unknown>" : remote;
     case 4:
       return def.getShortDescription();
     default:
       return def.getAuthor();
   }
 }
 public void setRemoteProperties(String name, Properties p) {
   context.log(
       PluginHostContext.LOG_INFORMATION, "Looking if " + name + " is already installed");
   for (int i = 0; i < getRowCount(); i++) {
     PluginDefinition def = getPluginDefinitionAt(i);
     context.log(PluginHostContext.LOG_DEBUG, "Found " + def.getName());
     if (name.equals(def.getName())) {
       context.log(PluginHostContext.LOG_DEBUG, name + " is installed");
       def.setRemoteProperties(p);
       fireTableRowsUpdated(i, i);
       return;
     }
   }
   context.log(PluginHostContext.LOG_DEBUG, name + " is not installed");
   int r = getRowCount();
   definitions.addElement(new PluginDefinition(p));
   fireTableRowsInserted(r, r);
 }
 /** Set what actions are available depending on state */
 private void setAvailableActions() {
   int sel = table.getSelectedRow();
   if (sel != -1) {
     PluginDefinition def = model.getPluginDefinitionAt(sel);
     info.setText(def.getInformation());
     url.setText(def.getURL());
     removeAction.setEnabled(def.getStatus() != NOT_INSTALLED);
     installAction.setEnabled(def.getStatus() == NOT_INSTALLED);
     updateAction.setEnabled(def.getStatus() == UPDATE_AVAILABLE);
     configureAction.setEnabled(
         def.getStatus() != NOT_INSTALLED && def.getPlugin() instanceof ConfigurablePlugin);
   } else {
     info.setText(" ");
     url.setText(" ");
     removeAction.setEnabled(false);
     installAction.setEnabled(false);
     updateAction.setEnabled(false);
     configureAction.setEnabled(false);
   }
   refresh.setEnabled(!updating);
 }
    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);
        }
      }
    }
 public void actionPerformed(ActionEvent evt) {
   PluginDefinition def = model.getPluginDefinitionAt(table.getSelectedRow());
   ConfigurablePlugin sel = (ConfigurablePlugin) def.getPlugin();
   sel.configure(PluginManagerPane.this);
 }