mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
plugins: move manage repositories to browse repositories dialog; simplify update plugins list
This commit is contained in:
@@ -99,7 +99,7 @@ public class ActionInstallPlugin extends AnAction implements DumbAware {
|
||||
for (PluginNode pluginNode : list) {
|
||||
PluginManagerUISettings.getInstance().myInstalledPlugins.add(pluginNode.getPluginId().getIdString());
|
||||
}
|
||||
installed.getPluginsModel().modifyData(new ArrayList<IdeaPluginDescriptor>(list));
|
||||
installed.getPluginsModel().updatePluginsList(new ArrayList<IdeaPluginDescriptor>(list));
|
||||
installed.setRequireShutdown(true);
|
||||
}
|
||||
}
|
||||
|
||||
+23
-9
@@ -21,6 +21,7 @@ import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.updateSettings.impl.UpdateSettings;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
@@ -40,21 +41,25 @@ import java.util.LinkedHashSet;
|
||||
*/
|
||||
public class AvailablePluginsManagerMain extends PluginManagerMain {
|
||||
private PluginManagerMain installed;
|
||||
private JButton myHttpProxySettingsButton = new JButton(IdeBundle.message("button.http.proxy.settings"));
|
||||
|
||||
public AvailablePluginsManagerMain(PluginManagerMain installed, PluginManagerUISettings uiSettings) {
|
||||
super(uiSettings);
|
||||
this.installed = installed;
|
||||
init();
|
||||
}
|
||||
final JButton manageRepositoriesBtn = new JButton("Manage repositories...");
|
||||
manageRepositoriesBtn.setMnemonic('m');
|
||||
manageRepositoriesBtn.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (ShowSettingsUtil.getInstance().editConfigurable(myActionsPanel, new PluginHostsConfigurable())) {
|
||||
loadAvailablePlugins();
|
||||
}
|
||||
}
|
||||
});
|
||||
myActionsPanel.add(manageRepositoriesBtn);
|
||||
|
||||
@Override
|
||||
protected JScrollPane createTable() {
|
||||
pluginsModel = new AvailablePluginsTableModel();
|
||||
pluginTable = new PluginTable(pluginsModel);
|
||||
JScrollPane availableScrollPane = ScrollPaneFactory.createScrollPane(pluginTable);
|
||||
myActionsPanel.add(myHttpProxySettingsButton, BorderLayout.NORTH);
|
||||
myHttpProxySettingsButton.addActionListener(new ActionListener() {
|
||||
final JButton httpProxySettingsButton = new JButton(IdeBundle.message("button.http.proxy.settings"));
|
||||
httpProxySettingsButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
HTTPProxySettingsDialog settingsDialog = new HTTPProxySettingsDialog();
|
||||
settingsDialog.pack();
|
||||
@@ -64,6 +69,15 @@ public class AvailablePluginsManagerMain extends PluginManagerMain {
|
||||
}
|
||||
}
|
||||
});
|
||||
myActionsPanel.add(httpProxySettingsButton, BorderLayout.NORTH);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JScrollPane createTable() {
|
||||
pluginsModel = new AvailablePluginsTableModel();
|
||||
pluginTable = new PluginTable(pluginsModel);
|
||||
JScrollPane availableScrollPane = ScrollPaneFactory.createScrollPane(pluginTable);
|
||||
|
||||
|
||||
return availableScrollPane;
|
||||
}
|
||||
|
||||
+9
-37
@@ -22,13 +22,13 @@
|
||||
*/
|
||||
package com.intellij.ide.plugins;
|
||||
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import com.intellij.openapi.updateSettings.impl.UpdateSettings;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ui.ColumnInfo;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
@@ -38,7 +38,6 @@ import java.util.*;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class AvailablePluginsTableModel extends PluginTableModel {
|
||||
private final Map<PluginId, String> myUpdateVersions = new HashMap<PluginId, String>();
|
||||
|
||||
public static final String ALL = "All";
|
||||
private String myCategory = ALL;
|
||||
@@ -59,22 +58,6 @@ public class AvailablePluginsTableModel extends PluginTableModel {
|
||||
view = new ArrayList<IdeaPluginDescriptor>();
|
||||
}
|
||||
|
||||
public void addData(List<IdeaPluginDescriptor> list) {
|
||||
view.clear();
|
||||
myAvailableCategories.clear();
|
||||
// For each downloadable plugin we need to know whether its counterpart
|
||||
// is already installed, and if yes compare the difference in versions:
|
||||
// availability of newer versions will be indicated separately.
|
||||
for (IdeaPluginDescriptor descr : list) {
|
||||
updateStatus(descr);
|
||||
view.add(descr);
|
||||
myAvailableCategories.add(descr.getCategory());
|
||||
myUpdateVersions.put(descr.getPluginId(), descr.getVersion());
|
||||
}
|
||||
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSortMode(String sortMode) {
|
||||
if (REPOSITORY.equals(sortMode) && UpdateSettings.getInstance().myPluginHosts.isEmpty()) {
|
||||
@@ -132,28 +115,17 @@ public class AvailablePluginsTableModel extends PluginTableModel {
|
||||
}
|
||||
}
|
||||
|
||||
public void modifyData(List<IdeaPluginDescriptor> list) {
|
||||
public void updatePluginsList(List<IdeaPluginDescriptor> list) {
|
||||
view.clear();
|
||||
myAvailableCategories.clear();
|
||||
|
||||
// For each downloadable plugin we need to know whether its counterpart
|
||||
// is already installed, and if yes compare the difference in versions:
|
||||
// availability of newer versions will be indicated separately.
|
||||
for (IdeaPluginDescriptor descr : list) {
|
||||
updateStatus(descr);
|
||||
PluginId descrId = descr.getPluginId();
|
||||
if (myUpdateVersions.containsKey(descrId)) {
|
||||
String currVersion = myUpdateVersions.get(descrId);
|
||||
int state = StringUtil.compareVersionNumbers(descr.getVersion(), currVersion);
|
||||
if (state > 0) {
|
||||
for (int i = 0; i < view.size(); i++) {
|
||||
IdeaPluginDescriptor obsolete = view.get(i);
|
||||
if (obsolete.getPluginId() == descrId) view.remove(obsolete);
|
||||
}
|
||||
view.add(descr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
view.add(descr);
|
||||
myUpdateVersions.put(descr.getPluginId(), descr.getVersion());
|
||||
}
|
||||
view.add(descr);
|
||||
myAvailableCategories.add(descr.getCategory());
|
||||
}
|
||||
|
||||
fireTableDataChanged();
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.options.ex.SingleConfigurableEditor;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
@@ -100,16 +99,6 @@ public class InstalledPluginsManagerMain extends PluginManagerMain {
|
||||
}
|
||||
});
|
||||
myActionsPanel.add(installPluginFromFileSystem);
|
||||
|
||||
final JButton manageRepositoriesBtn = new JButton("Manage repositories...");
|
||||
manageRepositoriesBtn.setMnemonic('m');
|
||||
manageRepositoriesBtn.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ShowSettingsUtil.getInstance().editConfigurable(myActionsPanel, new PluginHostsConfigurable());
|
||||
}
|
||||
});
|
||||
myActionsPanel.add(manageRepositoriesBtn);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -96,10 +96,6 @@ public class InstalledPluginsTableModel extends PluginTableModel {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void addData(List<IdeaPluginDescriptor> list) {
|
||||
modifyData(list);
|
||||
}
|
||||
|
||||
private void reset(final List<IdeaPluginDescriptor> list) {
|
||||
for (IdeaPluginDescriptor ideaPluginDescriptor : list) {
|
||||
if (ideaPluginDescriptor instanceof IdeaPluginDescriptorImpl) {
|
||||
@@ -180,7 +176,7 @@ public class InstalledPluginsTableModel extends PluginTableModel {
|
||||
}
|
||||
}
|
||||
|
||||
public void modifyData(List<IdeaPluginDescriptor> list) {
|
||||
public void updatePluginsList(List<IdeaPluginDescriptor> list) {
|
||||
// For each downloadable plugin we need to know whether its counterpart
|
||||
// is already installed, and if yes compare the difference in versions:
|
||||
// availability of newer versions will be indicated separately.
|
||||
|
||||
@@ -100,7 +100,6 @@ public abstract class PluginManagerMain implements Disposable {
|
||||
protected PluginTableModel pluginsModel;
|
||||
protected PluginTable pluginTable;
|
||||
|
||||
private ArrayList<IdeaPluginDescriptor> pluginsList;
|
||||
private ActionToolbar myActionToolbar;
|
||||
|
||||
protected final MyPluginsFilter myFilter = new MyPluginsFilter();
|
||||
@@ -141,7 +140,6 @@ public abstract class PluginManagerMain implements Disposable {
|
||||
UiNotifyConnector.doWhenFirstShown(getPluginTable(), new Runnable() {
|
||||
public void run() {
|
||||
requireShutdown = false;
|
||||
pluginsList = null;
|
||||
TableUtil.ensureSelectionExists(getPluginTable());
|
||||
}
|
||||
});
|
||||
@@ -182,15 +180,9 @@ public abstract class PluginManagerMain implements Disposable {
|
||||
|
||||
protected void modifyPluginsList(ArrayList<IdeaPluginDescriptor> list) {
|
||||
IdeaPluginDescriptor[] selected = pluginTable.getSelectedObjects();
|
||||
if (pluginsList == null) {
|
||||
pluginsModel.addData(list);
|
||||
}
|
||||
else {
|
||||
pluginsModel.modifyData(list);
|
||||
}
|
||||
pluginsModel.updatePluginsList(list);
|
||||
pluginsModel.sort();
|
||||
pluginsModel.filter(myFilter.getFilter().toLowerCase());
|
||||
pluginsList = list;
|
||||
if (selected != null) {
|
||||
select(selected);
|
||||
}
|
||||
@@ -216,12 +208,18 @@ public abstract class PluginManagerMain implements Disposable {
|
||||
public Object construct() {
|
||||
try {
|
||||
list = RepositoryHelper.process(null);
|
||||
}
|
||||
catch (Exception e) {
|
||||
error = e;
|
||||
}
|
||||
try {
|
||||
for (String host : UpdateSettings.getInstance().myPluginHosts) {
|
||||
final ArrayList<PluginDownloader> downloaded = new ArrayList<PluginDownloader>();
|
||||
UpdateChecker.checkPluginsHost(host, downloaded, false);
|
||||
for (PluginDownloader downloader : downloaded) {
|
||||
final PluginNode pluginNode = PluginDownloader.createPluginNode(host, downloader);
|
||||
if (pluginNode != null) {
|
||||
if (list == null) list = new ArrayList<IdeaPluginDescriptor>();
|
||||
list.add(pluginNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,9 +120,7 @@ abstract public class PluginTableModel extends AbstractTableModel implements Sor
|
||||
return list;
|
||||
}
|
||||
|
||||
public abstract void addData(List<IdeaPluginDescriptor> list);
|
||||
|
||||
public abstract void modifyData(List<IdeaPluginDescriptor> list);
|
||||
public abstract void updatePluginsList(List<IdeaPluginDescriptor> list);
|
||||
|
||||
public void filter(List<IdeaPluginDescriptor> filtered){
|
||||
fireTableDataChanged();
|
||||
|
||||
Reference in New Issue
Block a user