Refactor avatar updating.

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@9067 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Derek DeMoro
2007-09-06 16:57:10 +00:00
committed by derek
parent a1ed95f6c9
commit f07d6bce84
3 changed files with 53 additions and 71 deletions

View File

@ -15,13 +15,14 @@ import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smackx.debugger.EnhancedDebuggerWindow;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.ui.ChatFrame;
import org.jivesoftware.spark.util.BrowserLauncher;
import org.jivesoftware.spark.util.GraphicUtils;
import org.jivesoftware.spark.util.ResourceUtils;
import org.jivesoftware.spark.util.SwingTimerTask;
import org.jivesoftware.spark.util.SwingWorker;
import org.jivesoftware.spark.util.TaskEngine;
import org.jivesoftware.spark.util.URLFileSystem;
import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.plugin.alerts.InputTextAreaDialog;
@ -30,6 +31,20 @@ import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
import org.jivesoftware.sparkimpl.updater.CheckUpdates;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowFocusListener;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import java.util.TimerTask;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ImageIcon;
@ -44,22 +59,6 @@ import javax.swing.JSplitPane;
import javax.swing.JTextPane;
import javax.swing.JToolBar;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowFocusListener;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
/**
* The <code>MainWindow</code> class acts as both the DockableHolder and the proxy
* to the Workspace in Spark.
@ -272,7 +271,7 @@ public final class MainWindow extends ChatFrame implements ActionListener {
if (con.isConnected() && sendStatus) {
final InputTextAreaDialog inputTextDialog = new InputTextAreaDialog();
status = inputTextDialog.getInput(Res.getString("title.status.message"), Res.getString("message.current.status"),
SparkRes.getImageIcon(SparkRes.USER1_MESSAGE_24x24), this);
SparkRes.getImageIcon(SparkRes.USER1_MESSAGE_24x24), this);
}
// Notify all MainWindowListeners
@ -382,7 +381,7 @@ public final class MainWindow extends ChatFrame implements ActionListener {
if (!Spark.isMac()) {
connectMenu.add(exitMenuItem);
}
Action updateAction = new AbstractAction() {
public void actionPerformed(ActionEvent actionEvent) {
@ -465,15 +464,14 @@ public final class MainWindow extends ChatFrame implements ActionListener {
}
});
int delay = 15000; // 15 sec
Date timeToRun = new Date(System.currentTimeMillis() + delay);
Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
// Execute spark update checker after one minute.
final TimerTask task = new SwingTimerTask() {
public void doRun() {
checkForUpdates(false);
}
}, timeToRun);
};
TaskEngine.getInstance().schedule(task, 60000);
}
@ -578,7 +576,7 @@ public final class MainWindow extends ChatFrame implements ActionListener {
*/
private static void showAboutBox() {
JOptionPane.showMessageDialog(SparkManager.getMainWindow(), Default.getString(Default.APPLICATION_NAME) + " " + JiveInfo.getVersion(),
"About", JOptionPane.INFORMATION_MESSAGE);
"About", JOptionPane.INFORMATION_MESSAGE);
}
/**