コード例 #1
0
  @Override
  protected void installTableActions(final PluginTable pluginTable) {
    super.installTableActions(pluginTable);
    new DoubleClickListener() {
      @Override
      protected boolean onDoubleClick(MouseEvent e) {
        if (pluginTable.columnAtPoint(e.getPoint()) < 0) return false;
        if (pluginTable.rowAtPoint(e.getPoint()) < 0) return false;
        return installSelected(pluginTable);
      }
    }.installOn(pluginTable);

    pluginTable.registerKeyboardAction(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            installSelected(pluginTable);
          }
        },
        KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0),
        JComponent.WHEN_FOCUSED);
  }
コード例 #2
0
 private boolean installSelected(PluginTable pluginTable) {
   IdeaPluginDescriptor[] selection = pluginTable.getSelectedObjects();
   if (selection != null) {
     boolean enabled = true;
     for (IdeaPluginDescriptor descr : selection) {
       if (descr instanceof PluginNode) {
         enabled &= !PluginManagerColumnInfo.isDownloaded((PluginNode) descr);
         if (((PluginNode) descr).getStatus() == PluginNode.STATUS_INSTALLED) {
           enabled &= InstalledPluginsTableModel.hasNewerVersion(descr.getPluginId());
         }
       } else if (descr instanceof IdeaPluginDescriptorImpl) {
         PluginId id = descr.getPluginId();
         enabled &= InstalledPluginsTableModel.hasNewerVersion(id);
       }
     }
     if (enabled) {
       new ActionInstallPlugin(this, installed).install();
     }
     return true;
   }
   return false;
 }