mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
SPARK-1351,
Plugins cannot be removed anymore, they can only be deactivated!
on deactivation it will set a deactivated flag in your properties
also added a "Deactivatet Plugins" tab, so you can reactivate them
new locale:
tab.deactivated.plugins = Deactivated plugins
changed locale:
from:
message.prompt.plugin.uninstall = Are you sure you want to uninstall {0}?
to:
message.prompt.plugin.uninstall = Are you sure you want to deactivate {0}?
fixed bug, where timer wouldn't stop running
git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12466 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
committed by
wolf.posdorfer
parent
7ff34287ee
commit
f39666dee9
@ -59,6 +59,7 @@ import org.jivesoftware.spark.util.StringUtils;
|
||||
import org.jivesoftware.spark.util.URLFileSystem;
|
||||
import org.jivesoftware.spark.util.log.Log;
|
||||
import org.jivesoftware.sparkimpl.settings.JiveInfo;
|
||||
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
|
||||
|
||||
/**
|
||||
* This manager is responsible for the loading of all Plugins and Workspaces within Spark environment.
|
||||
@ -289,11 +290,12 @@ public class PluginManager implements MainWindowListener {
|
||||
|
||||
name = plugin1.selectSingleNode("name").getText();
|
||||
clazz = plugin1.selectSingleNode("class").getText();
|
||||
|
||||
|
||||
try {
|
||||
String lower = name.replace(" ","").toLowerCase();
|
||||
String lower = name.replaceAll("[^0-9a-zA-Z]","").toLowerCase();
|
||||
// Dont load the plugin if its on the Blacklist
|
||||
if(_blacklistPlugins.contains(lower) || _blacklistPlugins.contains(clazz))
|
||||
if(_blacklistPlugins.contains(lower) || _blacklistPlugins.contains(clazz)
|
||||
|| SettingsManager.getLocalPreferences().getDeactivatedPlugins().contains(name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -250,7 +250,8 @@ public class ReceiveMessage extends JPanel {
|
||||
if (transfer.getAmountWritten() >= request.getFileSize()
|
||||
|| transfer.getStatus() == FileTransfer.Status.error
|
||||
|| transfer.getStatus() == FileTransfer.Status.refused
|
||||
|| transfer.getStatus() == FileTransfer.Status.cancelled)
|
||||
|| transfer.getStatus() == FileTransfer.Status.cancelled
|
||||
|| transfer.getStatus() == FileTransfer.Status.complete)
|
||||
{
|
||||
this.cancel();
|
||||
_endtime = System.currentTimeMillis();
|
||||
@ -277,7 +278,8 @@ public class ReceiveMessage extends JPanel {
|
||||
if (transfer.getAmountWritten() >= request.getFileSize()
|
||||
|| transfer.getStatus() == FileTransfer.Status.error
|
||||
|| transfer.getStatus() == FileTransfer.Status.refused
|
||||
|| transfer.getStatus() == FileTransfer.Status.cancelled)
|
||||
|| transfer.getStatus() == FileTransfer.Status.cancelled
|
||||
|| transfer.getStatus() == FileTransfer.Status.complete)
|
||||
{
|
||||
this.cancel();
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ 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;
|
||||
@ -62,7 +63,6 @@ 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;
|
||||
@ -78,6 +78,8 @@ import org.jivesoftware.spark.util.SwingWorker;
|
||||
import org.jivesoftware.spark.util.URLFileSystem;
|
||||
import org.jivesoftware.spark.util.log.Log;
|
||||
import org.jivesoftware.sparkimpl.settings.JiveInfo;
|
||||
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
|
||||
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
|
||||
import org.jivesoftware.sparkimpl.updater.EasySSLProtocolSocketFactory;
|
||||
|
||||
/**
|
||||
@ -96,16 +98,24 @@ public class PluginViewer extends JPanel implements Plugin {
|
||||
private JProgressBar progressBar;
|
||||
|
||||
private JPanel installedPanel;
|
||||
private JPanel availablePanel;
|
||||
private JPanel availablePanel;
|
||||
private JPanel deactivatedPanel;
|
||||
private LocalPreferences _prefs;
|
||||
private List<String> _deactivatedPlugins;
|
||||
|
||||
public PluginViewer() {
|
||||
_prefs = SettingsManager.getLocalPreferences();
|
||||
_deactivatedPlugins = _prefs.getDeactivatedPlugins();
|
||||
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
|
||||
|
||||
public void run() {
|
||||
|
||||
tabbedPane = new JTabbedPane();
|
||||
installedPanel = new JPanel();
|
||||
availablePanel = new JPanel();
|
||||
deactivatedPanel = new JPanel();
|
||||
setLayout(new GridBagLayout());
|
||||
|
||||
installedPanel.setLayout(new VerticalFlowLayout(
|
||||
@ -115,6 +125,7 @@ public class PluginViewer extends JPanel implements Plugin {
|
||||
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,
|
||||
@ -128,8 +139,9 @@ public class PluginViewer extends JPanel implements Plugin {
|
||||
tabbedPane.addTab(Res.getString("tab.available.plugins"),
|
||||
new JScrollPane(availablePanel));
|
||||
}
|
||||
|
||||
|
||||
loadInstalledPlugins();
|
||||
loadDeactivatedPlugins();
|
||||
|
||||
tabbedPane.addChangeListener(new ChangeListener() {
|
||||
public void stateChanged(ChangeEvent changeEvent) {
|
||||
@ -154,6 +166,27 @@ public class PluginViewer extends JPanel implements Plugin {
|
||||
addSparkPlugUIListener(ui);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the Deactivated Plugins Tab
|
||||
*/
|
||||
private void loadDeactivatedPlugins() {
|
||||
deactivatedPanel.setLayout(new VerticalFlowLayout(
|
||||
VerticalFlowLayout.TOP, 0, 0, true, false));
|
||||
|
||||
tabbedPane.addTab(Res.getString("tab.deactivated.plugins"), new JScrollPane(deactivatedPanel));
|
||||
|
||||
for (final String s : _deactivatedPlugins) {
|
||||
PublicPlugin plg = new PublicPlugin();
|
||||
plg.setName(s);
|
||||
final SparkPlugUI ui = new SparkPlugUI(plg);
|
||||
ui.useLocalIcon();
|
||||
deactivatedPanel.add(ui);
|
||||
addDeactivatedListener(ui);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void initialize() {
|
||||
@ -180,17 +213,30 @@ public class PluginViewer extends JPanel implements Plugin {
|
||||
sparkMenu.insert(viewPluginsMenu, 2);
|
||||
}
|
||||
|
||||
private boolean uninstall(PublicPlugin plugin) {
|
||||
private boolean uninstall(final PublicPlugin plugin) {
|
||||
int ok = JOptionPane.showConfirmDialog(installedPanel, Res.getString("message.prompt.plugin.uninstall", plugin.getName()), Res.getString("title.confirmation"), JOptionPane.YES_NO_OPTION);
|
||||
if (ok == JOptionPane.YES_OPTION) {
|
||||
// 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();
|
||||
|
||||
// DOENST DELETE ANYMORE, Plugin will be added to a 'do-not-load-list'
|
||||
// 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();
|
||||
|
||||
List<String> deact = _prefs.getDeactivatedPlugins();
|
||||
deact.add(plugin.getName());
|
||||
_prefs.setDeactivatedPlugins(deact);
|
||||
_deactivatedPlugins = deact;
|
||||
|
||||
final SparkPlugUI ui = new SparkPlugUI(plugin);
|
||||
deactivatedPanel.add(ui);
|
||||
addDeactivatedListener(ui);
|
||||
|
||||
|
||||
JOptionPane.showMessageDialog(this, Res.getString("message.restart.spark.changes"), Res.getString("title.reminder"), JOptionPane.INFORMATION_MESSAGE);
|
||||
PluginManager.getInstance().removePublicPlugin(plugin);
|
||||
return true;
|
||||
@ -590,6 +636,40 @@ public class PluginViewer extends JPanel implements Plugin {
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Adds the MouseClick Listener to the PluginPreview <br>
|
||||
* Adds the MouseClick Listener to the InstallButton
|
||||
* @param ui
|
||||
*/
|
||||
private void addDeactivatedListener(final SparkPlugUI ui) {
|
||||
|
||||
ui.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
|
||||
for(Component c : deactivatedPanel.getComponents())
|
||||
{
|
||||
if (c instanceof SparkPlugUI)
|
||||
{
|
||||
((SparkPlugUI)c).setSelected(false);
|
||||
}
|
||||
}
|
||||
ui.setSelected(true);
|
||||
}
|
||||
});
|
||||
|
||||
ui.getInstallButton().addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
deactivatedPanel.remove(ui);
|
||||
_deactivatedPlugins.remove(ui.getPlugin().getName());
|
||||
_prefs.setDeactivatedPlugins(_deactivatedPlugins);
|
||||
deactivatedPanel.repaint();
|
||||
deactivatedPanel.revalidate();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void uninstall() {
|
||||
// Do nothing.
|
||||
|
||||
@ -25,8 +25,11 @@ import org.jivesoftware.resource.Default;
|
||||
import org.jivesoftware.resource.Res;
|
||||
import org.jivesoftware.spark.SparkManager;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javax.swing.UIManager;
|
||||
|
||||
@ -1071,6 +1074,37 @@ public class LocalPreferences {
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public List<String> getDeactivatedPlugins()
|
||||
{
|
||||
String plugs = getString("deactivatedPlugins", "");
|
||||
ArrayList<String> liste = new ArrayList<String>();
|
||||
|
||||
StringTokenizer tokenz = new StringTokenizer(plugs, ",");
|
||||
|
||||
while(tokenz.hasMoreTokens())
|
||||
{
|
||||
String x = tokenz.nextToken();
|
||||
liste.add(x);
|
||||
}
|
||||
return liste;
|
||||
}
|
||||
|
||||
public void setDeactivatedPlugins(List<String> list) {
|
||||
|
||||
// [hallo, hallo, hallo, hallo, hallo]
|
||||
// =
|
||||
// hallo,hallo,hallo,hallo,hallo
|
||||
if (list.size() > 0) {
|
||||
String liste = list.toString().substring(1,
|
||||
list.toString().length() - 1);
|
||||
liste = liste.replace(", ", ",");
|
||||
setString("deactivatedPlugins", liste);
|
||||
} else {
|
||||
setString("deactivatedPlugins", "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -731,7 +731,7 @@ message.password.private.room.error = Specify password for the private room
|
||||
message.passwords.no.match = Passwords do not match
|
||||
message.please.join.in.conference = Please join me in a conference
|
||||
message.plugins.not.available = Unable to contact the plugin repository
|
||||
message.prompt.plugin.uninstall = Are you sure you want to uninstall {0}?
|
||||
message.prompt.plugin.uninstall = Are you sure you want to deactivate {0}?
|
||||
message.received.file = You have received a file from {0}
|
||||
message.receiving.file = You are receiving a file from {0}
|
||||
message.reconnect.attempting = Attempting...
|
||||
@ -855,6 +855,7 @@ tab.contacts = Contacts
|
||||
tab.general = General
|
||||
tab.home = Home
|
||||
tab.installed.plugins = Installed plugins
|
||||
tab.deactivated.plugins = Deactivated plugins
|
||||
tab.personal = Personal
|
||||
tab.proxy = Proxy
|
||||
tab.sso = SSO
|
||||
|
||||
@ -498,7 +498,7 @@ message.calling = Rufe {0}
|
||||
message.number.to.call = Bitte eine Nummer eingeben
|
||||
message.no.caller.id = Keine Ruf-ID verf<72>gbar.
|
||||
message.no.history.found = Es sind keine weiteren Nachrichten verf<72>gbar.
|
||||
message.prompt.plugin.uninstall = Dieses Plugin {0} wirklich deinstallieren?
|
||||
message.prompt.plugin.uninstall = Dieses Plugin {0} wirklich deaktivieren?
|
||||
message.restart.spark = Das Programm muss neugestartet werden damit die <20>nderungen aktiviert werden.
|
||||
message.loading.please.wait = Lade. Bitte warten...
|
||||
message.plugins.not.available = Konnte keine Verbindung mit der Pluginliste herstellen.
|
||||
@ -779,6 +779,7 @@ tab.proxy = Proxy
|
||||
tab.contacts = Kontakte
|
||||
tab.installed.plugins = Installierte Plugins
|
||||
tab.available.plugins = Verf<EFBFBD>gbare Plugins
|
||||
tab.deactivated.plugins = Deaktivierte Plugins
|
||||
tab.personal = Pers<EFBFBD>nlich
|
||||
tab.business = Gesch<EFBFBD>ftlich
|
||||
tab.home = Privat
|
||||
|
||||
Reference in New Issue
Block a user