From 2235996ede045f771c3ad57ad10980df82e64e5f Mon Sep 17 00:00:00 2001 From: Wolf Posdorfer Date: Wed, 8 Jun 2011 11:27:59 +0000 Subject: [PATCH] SPARK-1351, remove plugins from install directory so they wont be loaded again changed X-icon to another X-icon ;-) git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12461 b35dd754-fafc-0310-a699-88a17e54d16e --- .../transfer/ui/ReceiveMessage.java | 2 +- .../filetransfer/transfer/ui/SendMessage.java | 2 +- .../sparkimpl/plugin/viewer/PluginViewer.java | 168 ++++++++++-------- 3 files changed, 94 insertions(+), 78 deletions(-) diff --git a/src/java/org/jivesoftware/sparkimpl/plugin/filetransfer/transfer/ui/ReceiveMessage.java b/src/java/org/jivesoftware/sparkimpl/plugin/filetransfer/transfer/ui/ReceiveMessage.java index 30f5f2c9..c2734f4a 100644 --- a/src/java/org/jivesoftware/sparkimpl/plugin/filetransfer/transfer/ui/ReceiveMessage.java +++ b/src/java/org/jivesoftware/sparkimpl/plugin/filetransfer/transfer/ui/ReceiveMessage.java @@ -588,7 +588,7 @@ public class ReceiveMessage extends JPanel { cancelButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); cancelButton.setForeground(new Color(73, 113, 196)); cancelButton.setFont(new Font("Dialog", Font.BOLD, 11)); - cancelButton.setIcon(SparkRes.getImageIcon(SparkRes.CANCEL_IMAGE)); + cancelButton.setIcon(SparkRes.getImageIcon(SparkRes.SMALL_DELETE)); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { diff --git a/src/java/org/jivesoftware/sparkimpl/plugin/filetransfer/transfer/ui/SendMessage.java b/src/java/org/jivesoftware/sparkimpl/plugin/filetransfer/transfer/ui/SendMessage.java index 3b7d5f67..80dfc702 100644 --- a/src/java/org/jivesoftware/sparkimpl/plugin/filetransfer/transfer/ui/SendMessage.java +++ b/src/java/org/jivesoftware/sparkimpl/plugin/filetransfer/transfer/ui/SendMessage.java @@ -94,7 +94,7 @@ public class SendMessage extends JPanel { cancelButton.setText(Res.getString("cancel")); retryButton.setText(Res.getString("retry")); - cancelButton.setIcon(SparkRes.getImageIcon(SparkRes.CANCEL_IMAGE)); + cancelButton.setIcon(SparkRes.getImageIcon(SparkRes.SMALL_DELETE)); retryButton.setIcon(SparkRes.getImageIcon(SparkRes.REFRESH_IMAGE)); add(cancelButton, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); diff --git a/src/java/org/jivesoftware/sparkimpl/plugin/viewer/PluginViewer.java b/src/java/org/jivesoftware/sparkimpl/plugin/viewer/PluginViewer.java index 858143df..6191a6e6 100644 --- a/src/java/org/jivesoftware/sparkimpl/plugin/viewer/PluginViewer.java +++ b/src/java/org/jivesoftware/sparkimpl/plugin/viewer/PluginViewer.java @@ -19,6 +19,41 @@ */ package org.jivesoftware.sparkimpl.plugin.viewer; +import java.awt.Color; +import java.awt.Component; +import java.awt.EventQueue; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.protocol.Protocol; @@ -27,6 +62,7 @@ import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.Node; import org.dom4j.io.SAXReader; +import org.jivesoftware.Spark; import org.jivesoftware.resource.Default; import org.jivesoftware.resource.Res; import org.jivesoftware.resource.SparkRes; @@ -44,42 +80,9 @@ import org.jivesoftware.spark.util.log.Log; import org.jivesoftware.sparkimpl.settings.JiveInfo; import org.jivesoftware.sparkimpl.updater.EasySSLProtocolSocketFactory; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JProgressBar; -import javax.swing.JScrollPane; -import javax.swing.JTabbedPane; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import java.awt.Color; -import java.awt.Component; -import java.awt.EventQueue; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - +/** + * Class to handle the viewing of installed and downloadable Plugins + */ public class PluginViewer extends JPanel implements Plugin { private static final long serialVersionUID = -4249017716988031394L; @@ -97,41 +100,47 @@ public class PluginViewer extends JPanel implements Plugin { public PluginViewer() { - EventQueue.invokeLater(new Runnable() { - public void run() { - - tabbedPane = new JTabbedPane(); - installedPanel = new JPanel(); - availablePanel = new JPanel(); - setLayout(new GridBagLayout()); - - installedPanel.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, false)); - installedPanel.setBackground(Color.white); - - availablePanel.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, false)); - availablePanel.setBackground(Color.white); - - // Add TabbedPane - add(tabbedPane, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); - - // Add Tabs - tabbedPane.addTab(Res.getString("tab.installed.plugins"), new JScrollPane(installedPanel)); - if(!Default.getBoolean(Default.INSTALL_PLUGINS_DISABLED)){ - tabbedPane.addTab(Res.getString("tab.available.plugins"), new JScrollPane(availablePanel)); - } - - loadInstalledPlugins(); - - tabbedPane.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent changeEvent) { - if (tabbedPane.getSelectedIndex() == 1) { - loadAvailablePlugins(); - loaded = true; - } - } - }); - } - }); + EventQueue.invokeLater(new Runnable() { + public void run() { + + tabbedPane = new JTabbedPane(); + installedPanel = new JPanel(); + availablePanel = new JPanel(); + setLayout(new GridBagLayout()); + + installedPanel.setLayout(new VerticalFlowLayout( + VerticalFlowLayout.TOP, 0, 0, true, false)); + installedPanel.setBackground(Color.white); + + availablePanel.setLayout(new VerticalFlowLayout( + VerticalFlowLayout.TOP, 0, 0, true, false)); + availablePanel.setBackground(Color.white); + + // Add TabbedPane + add(tabbedPane, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, + GridBagConstraints.WEST, GridBagConstraints.BOTH, + new Insets(5, 5, 5, 5), 0, 0)); + + // Add Tabs + tabbedPane.addTab(Res.getString("tab.installed.plugins"), + new JScrollPane(installedPanel)); + if (!Default.getBoolean(Default.INSTALL_PLUGINS_DISABLED)) { + tabbedPane.addTab(Res.getString("tab.available.plugins"), + new JScrollPane(availablePanel)); + } + + loadInstalledPlugins(); + + tabbedPane.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent changeEvent) { + if (tabbedPane.getSelectedIndex() == 1) { + loadAvailablePlugins(); + loaded = true; + } + } + }); + } + }); } private void loadInstalledPlugins() { @@ -177,7 +186,10 @@ public class PluginViewer extends JPanel implements Plugin { // Delete main jar. File pluginDir = plugin.getPluginDir(); File pluginJAR = new File(plugin.getPluginDir().getParentFile(), pluginDir.getName() + ".jar"); + File mainpluginJar = new File(Spark.getBinDirectory().getParent()+"/plugins/"+pluginJAR.getName()); + pluginJAR.delete(); + mainpluginJar.delete(); JOptionPane.showMessageDialog(this, Res.getString("message.restart.spark.changes"), Res.getString("title.reminder"), JOptionPane.INFORMATION_MESSAGE); PluginManager.getInstance().removePublicPlugin(plugin); @@ -475,7 +487,7 @@ public class PluginViewer extends JPanel implements Plugin { } catch (Exception e) { - System.out.println("We can ignore these."); + Log.error("Error retrieving PluginInformation from xml.",e); } pluginList.add(publicPlugin); } @@ -555,22 +567,26 @@ public class PluginViewer extends JPanel implements Plugin { ui.setSelected(true); final PluginManager pluginManager = PluginManager.getInstance(); - ui.getInstallButton().addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent actionEvent) { - boolean isInstalled = pluginManager.isInstalled(ui.getPlugin()); + ui.getInstallButton().addMouseListener(new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent e) { + + boolean isInstalled = pluginManager.isInstalled(ui.getPlugin()); if (isInstalled) { boolean uninstalled = uninstall(ui.getPlugin()); if (uninstalled) { installedPanel.remove(ui); installedPanel.invalidate(); installedPanel.repaint(); + installedPanel.revalidate(); } } else { downloadPlugin(ui.getPlugin()); } } - }); + }); } }); }