mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
improve plugin loading
patch provided by mirceac http://community.igniterealtime.org/message/211959#211959 git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12313 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
committed by
wolf.posdorfer
parent
bf54ac673d
commit
bfbfb95671
@ -41,6 +41,7 @@ import javax.swing.UIDefaults;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import org.jivesoftware.resource.Default;
|
||||
import org.jivesoftware.spark.PluginManager;
|
||||
import org.jivesoftware.spark.ui.themes.ColorSettingManager;
|
||||
import org.jivesoftware.spark.ui.themes.ColorSettings;
|
||||
import org.jivesoftware.spark.util.ModelUtil;
|
||||
@ -201,6 +202,11 @@ public final class Spark {
|
||||
new Spark();
|
||||
}
|
||||
});
|
||||
|
||||
//load plugins before Workspace initialization to avoid any UI delays
|
||||
//during plugin rendering
|
||||
final PluginManager pluginManager = PluginManager.getInstance();
|
||||
pluginManager.loadPlugins();
|
||||
|
||||
try {
|
||||
EventQueue.invokeAndWait(new Runnable(){
|
||||
|
||||
@ -107,7 +107,6 @@ public class PluginManager implements MainWindowListener {
|
||||
movePlugins();
|
||||
}
|
||||
|
||||
SparkManager.getMainWindow().addMainWindowListener(this);
|
||||
|
||||
// Create the extension directory if one does not exist.
|
||||
if (!PLUGINS_DIRECTORY.exists()) {
|
||||
|
||||
@ -268,14 +268,14 @@ public class Workspace extends JPanel implements PacketListener {
|
||||
TaskEngine.getInstance().schedule(new TimerTask() {
|
||||
public void run() {
|
||||
final PluginManager pluginManager = PluginManager.getInstance();
|
||||
pluginManager.loadPlugins();
|
||||
SparkManager.getMainWindow().addMainWindowListener(pluginManager);
|
||||
pluginManager.initializePlugins();
|
||||
|
||||
// Subscriptions are always manual
|
||||
Roster roster = SparkManager.getConnection().getRoster();
|
||||
roster.setSubscriptionMode(Roster.SubscriptionMode.manual);
|
||||
}
|
||||
}, 2000);
|
||||
}, 1000);
|
||||
|
||||
// Check URI Mappings
|
||||
SparkManager.getChatManager().handleURIMapping(Spark.ARGUMENTS);
|
||||
|
||||
@ -1796,6 +1796,10 @@ public final class ContactList extends JPanel implements ActionListener,
|
||||
}
|
||||
|
||||
private void loadContactList() {
|
||||
|
||||
// Load all plugins
|
||||
SparkManager.getWorkspace().loadPlugins();
|
||||
|
||||
// Build the initial contact list.
|
||||
buildContactList();
|
||||
|
||||
@ -1810,8 +1814,7 @@ public final class ContactList extends JPanel implements ActionListener,
|
||||
// Add a subscription listener.
|
||||
addSubscriptionListener();
|
||||
|
||||
// Load all plugins
|
||||
SparkManager.getWorkspace().loadPlugins();
|
||||
|
||||
}
|
||||
|
||||
public void addSubscriptionListener() {
|
||||
|
||||
@ -457,11 +457,13 @@ public class StatusBar extends JPanel implements VCardListener {
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
double scaleX = getWidth() / (double)backgroundImage.getWidth(null);
|
||||
double scaleY = getHeight() / (double)backgroundImage.getHeight(null);
|
||||
AffineTransform xform = AffineTransform.getScaleInstance(scaleX, scaleY);
|
||||
((Graphics2D)g).drawImage(backgroundImage, xform, this);
|
||||
|
||||
super.paintComponent(g);
|
||||
if (backgroundImage != null) {
|
||||
double scaleX = getWidth() / (double)backgroundImage.getWidth(null);
|
||||
double scaleY = getHeight() / (double)backgroundImage.getHeight(null);
|
||||
AffineTransform xform = AffineTransform.getScaleInstance(scaleX, scaleY);
|
||||
((Graphics2D)g).drawImage(backgroundImage, xform, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -66,25 +66,6 @@ public class JabberBrowser implements Plugin {
|
||||
private XMPPConnection con;
|
||||
private JPanel browsePanel;
|
||||
|
||||
public JabberBrowser() {
|
||||
|
||||
this.con = SparkManager.getConnection();
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
addressLabel = new JLabel();
|
||||
addressField = new JComboBox();
|
||||
|
||||
|
||||
addressField.setEditable(true);
|
||||
addressField.addItem(con.getHost());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void display() {
|
||||
final JPanel mainPanel = new JPanel();
|
||||
mainPanel.setLayout(new GridBagLayout());
|
||||
@ -233,6 +214,17 @@ public class JabberBrowser implements Plugin {
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
this.con = SparkManager.getConnection();
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
addressLabel = new JLabel();
|
||||
addressField = new JComboBox();
|
||||
addressField.setEditable(true);
|
||||
addressField.addItem(con.getHost());
|
||||
}
|
||||
|
||||
});
|
||||
SparkManager.getWorkspace().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F8"), "showBrowser");
|
||||
SparkManager.getWorkspace().getActionMap().put("showBrowser", new AbstractAction("showBrowser") {
|
||||
private static final long serialVersionUID = 341826581565007606L;
|
||||
|
||||
@ -627,6 +627,9 @@ public class VCardManager {
|
||||
* @param vcard the users vcard.
|
||||
*/
|
||||
private void persistVCard(String jid, VCard vcard) {
|
||||
if (jid == null || vcard == null) {
|
||||
return;
|
||||
}
|
||||
String fileName = Base64.encodeBytes(jid.getBytes());
|
||||
|
||||
byte[] bytes = vcard.getAvatar();
|
||||
@ -677,6 +680,9 @@ public class VCardManager {
|
||||
* @return the VCard if found, otherwise null.
|
||||
*/
|
||||
private VCard loadFromFileSystem(String jid) {
|
||||
if (jid == null) {
|
||||
return null;
|
||||
}
|
||||
// Unescape JID
|
||||
String fileName = Base64.encodeBytes(jid.getBytes());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user