1 package rero.dialogs.dcc; 2 3 import java.awt.*; 4 import java.awt.event.*; 5 6 import javax.swing.*; 7 import javax.swing.event.*; 8 9 import java.util.*; 10 import java.io.*; 11 12 import rero.dialogs.toolkit.*; 13 import rero.dcc.*; 14 15 import rero.util.*; 16 17 public class ResumeRequest extends APanel 18 { 19 protected Receive receive; protected JComboBox options; 21 22 public static int showDialog(Component component, ConnectDCC connect) 23 { 24 ResumeRequest request = new ResumeRequest(); 25 request.setupDialog(connect); 26 27 ADialog dialog = new ADialog(component, "File Exists", request, null); 28 dialog.pack(); 29 30 Integer temp = (Integer )dialog.showDialog(component); 31 if (temp == null) { return -1; } 32 33 return temp.intValue(); 34 } 35 36 public void setupDialog(Object value) 37 { 38 JPanel space = new JPanel(); 39 space.setPreferredSize(new Dimension(0, 15)); 40 41 JPanel space2 = new JPanel(); 42 space2.setPreferredSize(new Dimension(0, 15)); 43 44 LabelGroup labels = new LabelGroup(); 45 JLabel file, size, action; 46 47 file = new JLabel("File: "); 48 size = new JLabel("Size: "); 49 action = new JLabel("Action: "); 50 51 labels.addLabel(file); labels.addLabel(size); labels.addLabel(action); 52 labels.sync(); 54 ConnectDCC info1 = (ConnectDCC)value; 55 Receive info2 = (Receive)info1.getImplementation(); 56 57 PlainLabel ifile, isize; 58 59 ifile = new PlainLabel(info2.getFile().getName()); 60 isize = new PlainLabel(ClientUtils.formatBytes((int)info2.getFile().length()) + " of " + ClientUtils.formatBytes(info2.getExpectedSize())); 61 62 addComponent(new PlainLabel("File already exists...")); 63 64 addComponent(space2); 65 66 addComponent(mergeComponents(file, ifile)); 67 addComponent(mergeComponents(size, isize)); 68 69 addComponent(space); 70 71 options = new JComboBox(new String [] { "Resume", "Rename", "Overwrite" }); 72 73 addComponent(mergeComponents(action, options)); 74 } 75 76 public Object getValue(Object defvalue) 77 { 78 return new Integer (options.getSelectedIndex()); 79 } 80 } 81 | Popular Tags |