@Override public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); IdeaPluginDescriptor[] selection = getPluginTable().getSelectedObjects(); boolean enabled = (selection != null); if (enabled) { for (IdeaPluginDescriptor descr : selection) { presentation.setText(IdeBundle.message("action.download.and.install.plugin")); presentation.setDescription(IdeBundle.message("action.download.and.install.plugin")); enabled &= !ourInstallingNodes.contains(descr); if (descr instanceof PluginNode) { enabled &= !PluginManagerColumnInfo.isDownloaded((PluginNode) descr); if (((PluginNode) descr).getStatus() == PluginNode.STATUS_INSTALLED) { presentation.setText(IdeBundle.message("action.update.plugin")); presentation.setDescription(IdeBundle.message("action.update.plugin")); enabled &= ourState.hasNewerVersion(descr.getPluginId()); } } else if (descr instanceof IdeaPluginDescriptorImpl) { presentation.setText(IdeBundle.message("action.update.plugin")); presentation.setDescription(IdeBundle.message("action.update.plugin")); PluginId id = descr.getPluginId(); enabled = enabled && ourState.hasNewerVersion(id); } } } presentation.setEnabled(enabled); }
public InstalledPluginsTableRenderer(IdeaPluginDescriptor pluginDescriptor) { myPluginDescriptor = pluginDescriptor; myNameLabel.setFont(PluginManagerColumnInfo.getNameFont()); myBundledLabel.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL)); myPanel.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 1)); myNameLabel.setOpaque(true); myPanel.add(myNameLabel, BorderLayout.WEST); myPanel.add(myBundledLabel, BorderLayout.EAST); }
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; }