1 /*****************************************************/
\r
2 /* This java file is a part of the */
\r
4 /* - Plouf's Java IRC Client - */
\r
6 /* Copyright (C) 2002 - 2004 Philippe Detournay */
\r
8 /* All contacts : theplouf@yahoo.com */
\r
10 /* PJIRC is free software; you can redistribute */
\r
11 /* it and/or modify it under the terms of the GNU */
\r
12 /* General Public License as published by the */
\r
13 /* Free Software Foundation; version 2 or later of */
\r
16 /* PJIRC is distributed in the hope that it will */
\r
17 /* be useful, but WITHOUT ANY WARRANTY; without */
\r
18 /* even the implied warranty of MERCHANTABILITY or */
\r
19 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
\r
20 /* General Public License for more details. */
\r
22 /* You should have received a copy of the GNU */
\r
23 /* General Public License along with PJIRC; if */
\r
24 /* not, write to the Free Software Foundation, */
\r
25 /* Inc., 59 Temple Place, Suite 330, Boston, */
\r
26 /* MA 02111-1307 USA */
\r
28 /*****************************************************/
\r
30 package irc.gui.pixx;
\r
32 import irc.EventDispatcher;
\r
33 import irc.dcc.DCCFile;
\r
34 import irc.dcc.DCCFileListener;
\r
36 import java.awt.BorderLayout;
\r
37 import java.awt.Color;
\r
38 import java.awt.Frame;
\r
39 import java.awt.Label;
\r
40 import java.awt.event.WindowEvent;
\r
41 import java.awt.event.WindowListener;
\r
44 * The AWT dcc file interface.
\r
46 public class AWTDCCFile implements DCCFileListener, WindowListener {
\r
50 protected DCCFile _file;
\r
52 * The displayed frame.
\r
54 protected Frame _frame;
\r
58 protected AWTProgressBar _bar;
\r
59 private PixxConfiguration _pixxConfiguration;
\r
62 * Create a new AWTDCCFile.
\r
65 * the global irc configuration.
\r
67 * the source DCCFile.
\r
69 public AWTDCCFile(PixxConfiguration config, DCCFile file) {
\r
70 _pixxConfiguration = config;
\r
72 _file.addDCCFileListener(this);
\r
75 if (file.isDownloading())
\r
76 str = _pixxConfiguration.getText(PixxTextProvider.GUI_RETREIVING_FILE, _file.getSize() + "");
\r
78 str = _pixxConfiguration.getText(PixxTextProvider.GUI_SENDING_FILE, _file.getSize() + "");
\r
80 Label label = new Label(str);
\r
82 _frame = new Frame();
\r
83 _frame.setBackground(Color.white);
\r
85 _frame.setLayout(new BorderLayout());
\r
86 _frame.addWindowListener(this);
\r
88 _bar = new AWTProgressBar();
\r
89 _frame.add(label, BorderLayout.NORTH);
\r
90 _frame.add(_bar, BorderLayout.CENTER);
\r
92 _frame.setTitle(_file.getName());
\r
93 _frame.setSize(400, 80);
\r
98 * Release this object.
\r
100 public void release() {
\r
101 _frame.removeAll();
\r
102 _file.removeDCCFileListener(this);
\r
104 _frame.removeWindowListener(this);
\r
110 * Get the source DCCFile.
\r
112 * @return source DCCFile.
\r
114 public DCCFile getFile() {
\r
119 * Close this transfert.
\r
121 public void close() {
\r
126 public void transmitted(Integer icount, DCCFile file) {
\r
128 int count = icount.intValue();
\r
129 if ((count & 32767) == 0) {
\r
131 pc /= _file.getSize();
\r
132 _bar.setColor(Color.blue);
\r
139 public void finished(DCCFile file) {
\r
140 _frame.setTitle(_pixxConfiguration.getText(PixxTextProvider.GUI_TERMINATED, _file.getName()));
\r
141 _bar.setColor(Color.green);
\r
147 public void failed(DCCFile file) {
\r
148 _frame.setTitle(_pixxConfiguration.getText(PixxTextProvider.GUI_FAILED, _file.getName()));
\r
149 _bar.setColor(Color.red);
\r
155 public void windowActivated(WindowEvent e) {
\r
159 public void windowClosed(WindowEvent e) {
\r
163 public void windowClosing(WindowEvent e) {
\r
164 EventDispatcher.dispatchEventAsync(_file, "leave", new Object[0]);
\r
168 public void windowDeactivated(WindowEvent e) {
\r
172 public void windowDeiconified(WindowEvent e) {
\r
176 public void windowIconified(WindowEvent e) {
\r
180 public void windowOpened(WindowEvent e) {
\r