org.jmeterplugins.repository.PluginManagerDialog Maven / Gradle / Ivy
package org.jmeterplugins.repository;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.LinkedList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextPane;
import javax.swing.JEditorPane;
import javax.swing.SwingUtilities;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import org.apache.jmeter.gui.GuiPackage;
import org.apache.jmeter.gui.action.ActionNames;
import org.apache.jmeter.gui.action.ActionRouter;
import org.apache.jorphan.gui.ComponentUtil;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
import org.jmeterplugins.repository.exception.DownloadException;
public class PluginManagerDialog extends JDialog implements ActionListener, ComponentListener, HyperlinkListener {
/**
*
*/
private static final long serialVersionUID = 888467568782611707L;
private static final Logger log = LoggingManager.getLoggerForClass();
public static final Border SPACING = BorderFactory.createEmptyBorder(5, 5, 5, 5);
private final PluginManager manager;
private final JTextPane modifs = new JTextPane();
private final JButton apply = new JButton("Apply Changes and Restart JMeter");
private final PluginsList installed;
private final PluginsList available;
private final PluginUpgradesList upgrades;
private final JSplitPane topAndDown = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
private JLabel statusLabel = new JLabel("");
private JEditorPane failureLabel = new JEditorPane();
private JScrollPane failureScrollPane = new JScrollPane(failureLabel);
private final ChangeListener cbNotifier;
private final ChangeListener cbUpgradeNotifier;
public PluginManagerDialog(PluginManager aManager) {
super((JFrame) null, "JMeter Plugins Manager", true);
setLayout(new BorderLayout());
addComponentListener(this);
manager = aManager;
Dimension size = new Dimension(1024, 768);
setSize(size);
setPreferredSize(size);
setIconImage(PluginManagerMenuItem.getPluginsIcon(manager.hasAnyUpdates()).getImage());
ComponentUtil.centerComponentInWindow(this);
failureLabel.setContentType("text/html");
failureLabel.addHyperlinkListener(this);
final GenericCallback