renaming SendMessage to SendFileTransfer

renaming ReceiveMessage to ReceiveFileTransfer for better understanding
commented Downloads.java

fixed ReceiveMessage not cancelling Timers

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12502 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Wolf Posdorfer
2011-06-17 07:48:08 +00:00
committed by wolf.posdorfer
parent dac0bd831c
commit 7683cb5835
4 changed files with 50 additions and 35 deletions

View File

@ -102,8 +102,8 @@ import org.jivesoftware.spark.util.ResourceUtils;
import org.jivesoftware.spark.util.SwingWorker;
import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.plugin.filetransfer.transfer.Downloads;
import org.jivesoftware.sparkimpl.plugin.filetransfer.transfer.ui.ReceiveMessage;
import org.jivesoftware.sparkimpl.plugin.filetransfer.transfer.ui.SendMessage;
import org.jivesoftware.sparkimpl.plugin.filetransfer.transfer.ui.ReceiveFileTransfer;
import org.jivesoftware.sparkimpl.plugin.filetransfer.transfer.ui.SendFileTransfer;
import org.jivesoftware.sparkimpl.plugin.filetransfer.transfer.ui.TransferUtils;
import org.jivesoftware.sparkimpl.plugin.manager.Enterprise;
@ -312,7 +312,7 @@ public class SparkTransferManager {
// The image must first be wrapped in a style
Style style = doc.addStyle("StyleName", null);
final ReceiveMessage receivingMessageUI = new ReceiveMessage();
final ReceiveFileTransfer receivingMessageUI = new ReceiveFileTransfer();
receivingMessageUI.acceptFileTransfer(request);
chatRoom.addClosingListener(new ChatRoomClosingListener() {
@ -611,7 +611,7 @@ public class SparkTransferManager {
// The image must first be wrapped in a style
Style style = doc.addStyle("StyleName", null);
SendMessage sendingUI = new SendMessage();
SendFileTransfer sendingUI = new SendFileTransfer();
try {
transfer.sendFile(file, "Sending file");
}

View File

@ -28,28 +28,43 @@ import org.jivesoftware.spark.util.WindowsFileSystemView;
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
/**
* Provides Acces to the DownloadDirectory and a JFileChooser starting at the
* DownloadDirectory
*
*/
public class Downloads {
private static File downloadedDir;
private static JFileChooser chooser;
private static LocalPreferences _localPreferences;
private static File downloadedDir;
private static JFileChooser chooser;
private static LocalPreferences _localPreferences;
public static File getDownloadDirectory() {
LocalPreferences pref = SettingsManager.getLocalPreferences();
downloadedDir = new File(pref.getDownloadDir());
return downloadedDir;
}
public static JFileChooser getFileChooser() {
if (chooser == null) {
_localPreferences = SettingsManager.getLocalPreferences();
downloadedDir = new File(_localPreferences.getDownloadDir());
chooser = new JFileChooser(downloadedDir);
if (Spark.isWindows()) {
chooser.setFileSystemView(new WindowsFileSystemView());
}
}
return chooser;
/**
* Returns the Downloaddirectory
*
* @return
*/
public static File getDownloadDirectory() {
LocalPreferences pref = SettingsManager.getLocalPreferences();
downloadedDir = new File(pref.getDownloadDir());
return downloadedDir;
}
/**
* Returns a {@link JFileChooser} starting at the DownloadDirectory
*
* @return
*/
public static JFileChooser getFileChooser() {
if (chooser == null) {
_localPreferences = SettingsManager.getLocalPreferences();
downloadedDir = new File(_localPreferences.getDownloadDir());
chooser = new JFileChooser(downloadedDir);
if (Spark.isWindows()) {
chooser.setFileSystemView(new WindowsFileSystemView());
}
}
return chooser;
}
}

View File

@ -73,7 +73,7 @@ import org.jivesoftware.spark.util.URLFileSystem;
import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.plugin.filetransfer.transfer.Downloads;
public class ReceiveMessage extends JPanel {
public class ReceiveFileTransfer extends JPanel {
private static final long serialVersionUID = -2974192409566650923L;
private FileDragLabel imageLabel = new FileDragLabel();
@ -90,7 +90,7 @@ public class ReceiveMessage extends JPanel {
private long _starttime;
private long _endtime;
public ReceiveMessage() {
public ReceiveFileTransfer() {
setLayout(new GridBagLayout());
setBackground(new Color(250, 249, 242));
@ -243,7 +243,7 @@ public class ReceiveMessage extends JPanel {
progressBar.setStringPainted(true);
final Timer timer = new Timer();
TimerTask updateProgessBar = new TimerTask() {
@Override
public void run() {
@ -254,6 +254,7 @@ public class ReceiveMessage extends JPanel {
|| transfer.getStatus() == FileTransfer.Status.complete)
{
this.cancel();
timer.cancel();
_endtime = System.currentTimeMillis();
updateonFinished(request, downloadedFile);
}else
@ -267,7 +268,7 @@ public class ReceiveMessage extends JPanel {
}
};
final Timer timer2 = new Timer();
TimerTask updatePrograssBarText = new TimerTask() {
long timenow;
long timeearlier;
@ -282,6 +283,7 @@ public class ReceiveMessage extends JPanel {
|| transfer.getStatus() == FileTransfer.Status.complete)
{
this.cancel();
timer2.cancel();
}
else{
@ -315,10 +317,8 @@ public class ReceiveMessage extends JPanel {
};
Timer timer = new Timer();
timer.scheduleAtFixedRate(updateProgessBar, 10, 10);
Timer timer2 = new Timer();
timer.scheduleAtFixedRate(updateProgessBar, 10, 10);
timer2.scheduleAtFixedRate(updatePrograssBarText, 10, 500);
}
@ -619,7 +619,7 @@ public class ReceiveMessage extends JPanel {
if (e.isPopupTrigger()) {
final JPopupMenu popup = new JPopupMenu();
final ReceiveMessage ui = this;
final ReceiveFileTransfer ui = this;
Action saveAsAction = new AbstractAction() {
private static final long serialVersionUID = -3010501340128285438L;

View File

@ -60,7 +60,7 @@ import org.jivesoftware.spark.util.GraphicUtils;
import org.jivesoftware.spark.util.SwingWorker;
import org.jivesoftware.spark.util.log.Log;
public class SendMessage extends JPanel {
public class SendFileTransfer extends JPanel {
private static final long serialVersionUID = -4403839897649365671L;
private FileDragLabel imageLabel = new FileDragLabel();
@ -81,7 +81,7 @@ public class SendMessage extends JPanel {
private JLabel progressLabel = new JLabel();
private long _starttime;
public SendMessage() {
public SendFileTransfer() {
setLayout(new GridBagLayout());
setBackground(new Color(250, 249, 242));