--- edoc-applet/Upload.java 2003/06/17 10:38:55 1.1 +++ edoc-applet/Upload.java 2003/06/17 10:59:07 1.2 @@ -379,7 +379,7 @@ public class Upload extends JApplet impl System.out.println(doc.title); conPost.post(file,"new",doc.docID+"",doc.title,doc.locator,doc.comment); - // conPost.post(new File("./test2.jpg"),picture.elementAt(i).toString(),artist.elementAt(i).toString(),source.elementAt(i). + // conPost.post(new File("./test2.jpg"),picture.elementAt(i).toString(),artist.elementAt(i).toString(),source.elementAt(i).toString()); System.out.println(getMD5(md)); dialog.progress.setValue(100); count++; @@ -391,9 +391,10 @@ public class Upload extends JApplet impl int index = startFile.getAbsolutePath().lastIndexOf(File.separator); - String path =startFile.getAbsolutePath().substring(0,index+1); - System.out.println(path);mode = "new"; - boolean newVersionforAll = false; + String path = startFile.getAbsolutePath().substring(0,index+1); + System.out.println(path); + mode = "new"; + boolean newVersionforAll = false, keepAllFiles = false; Vector list=new Vector(); for(int k=0;k1) ? showDialog("Warning : several files exist on the server \n Press show list to see the list! \n What do you want to do?", "several Files exist!", options,list):showDialog("Warning : file "+doc.fileName+" exists on the server \n What do you want to do?", " File "+doc.fileName+" exists!", options2); +; + if(option == 0) break;// mode = "old"; if(option == 1) { mode ="old"; - newVersionforAll=true; + newVersionforAll = true; + keepAllFiles = false; } if(option == 2) { count++; System.out.println("Heh Document exists!"+ doc); System.out.println("Skipping"); + newVersionforAll = false; + keepAllFiles = true; continue; } } Bundle.Document refDoc= (Bundle.Document) bundleRef.docsLocator.get(doc.locator); doc.docID=refDoc.docID; - //count++; + if(keepAllFiles) + { + count++; + continue; + } + //count++; // System.out.println("Heh Document exists!"+ doc); // System.out.println("Skipping"); // continue; @@ -458,7 +469,7 @@ public class Upload extends JApplet impl conPost.dialog=dialog; conPost.post(path,doc,mode); String md5=getMD5(md); - System.out.println("MD5 is equal ?"+doc.md5cs.equals(md5)); + System.out.println("MD5 is equal ?"+doc.md5cs.equals(md5)+" doc_md5 "+doc.md5cs+" md5 "+md5); if(!doc.md5cs.equals(md5)) { Object[] options = { "Retry", "Cancel" }; @@ -602,40 +613,57 @@ public class Upload extends JApplet impl } public static int showDialog(String message, String title, Object[] options,Vector fileList) { - JOptionPane pane = new JOptionPane( message, JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); - pane.setMessageType(JOptionPane.WARNING_MESSAGE); // Configure - JDialog dialog = pane.createDialog(null, title); - JList list=null; + JOptionPane pane = new JOptionPane( message, JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); + pane.setMessageType(JOptionPane.WARNING_MESSAGE); // Configure + final JDialog dialog = pane.createDialog(null, title); + JList list=null; if(fileList==null) list= new JList(new String[]{"click","here","test","bla","world","hello"}); - else list = new JList(fileList); - JScrollPane scpane = new JScrollPane(list); - scpane.setPreferredSize(new Dimension(100,80)); - JLabel label= new JLabel("Files : "); - label.setPreferredSize(new Dimension(50,80)); - JPanel panel = new JPanel(); - panel.add(label); - panel.add(scpane); - dialog.getContentPane().add(panel,"East"); - dialog.pack(); - dialog.show(); + else list = new JList(fileList); + JScrollPane scpane = new JScrollPane(list); + scpane.setPreferredSize(new Dimension(150,150)); + + JLabel label = new JLabel("Files to be updated : "); + label.setPreferredSize(new Dimension(150,30)); + final JPanel panel = new JPanel(); + panel.setLayout(new BorderLayout()); + panel.add(label,"North"); + panel.add(scpane,"Center"); + JButton showList= new JButton("show List"); + showList.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + JDialog window = new JDialog(dialog); + window.getContentPane().add(panel); + window.pack(); + window.show(); + } + }); + JPanel buttonPanel = new JPanel(); + buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS)); + buttonPanel.add(Box.createRigidArea(new Dimension(0,30))); + buttonPanel.add(showList); + dialog.getContentPane().add(buttonPanel,"East"); + dialog.pack(); + dialog.show(); Object selectedValue = pane.getValue(); - if(selectedValue == null) - return 2; - //If there is not an array of option buttons: - if(options == null) { - if(selectedValue instanceof Integer) - return ((Integer)selectedValue).intValue(); - return 2; - } - //If there is an array of option buttons: - for(int counter = 0, maxCounter = options.length; - counter < maxCounter; counter++) { - if(options[counter].equals(selectedValue)) - return counter; - } - return 2; - + if(selectedValue == null) + return 2; + //If there is not an array of option buttons: + if(options == null) { + if(selectedValue instanceof Integer) + return ((Integer)selectedValue).intValue(); + return 2; + } + //If there is an array of option buttons: + for(int counter = 0, maxCounter = options.length;counter < maxCounter; counter++) + { + if(options[counter].equals(selectedValue)) + return counter; + } + return 2; + } public static void showDialog(String message, String title) @@ -1213,10 +1241,11 @@ public class Upload extends JApplet impl // getBundle("http://core.rz-berlin.mpg.de/edoctest/oi.epl?mm=list&grp=136"); // getBundle("http://core.rz-berlin.mpg.de/edoctest/oi.epl?mm=list&grp=136"); runningAsApplet=false; - // Object[] options = new Object[] { "New Version for this file","New Version for all files", "Skip file" }; + //Object[] options = new Object[] { "Cancel","Replace existing files", "Keep existing files" }; - // int option = showDialog("Warning exists! \n What do you want to do?", "Destination exists!", options,null); - + // int option = showDialog("Warning : several files exist on the server \n Press show list to see the list! \n What do you want to do?", "Files exist!", options,null); + //System.out.println("User selected "+options[option]); + // System.exit(0); // due to now internet long time = System.currentTimeMillis(); new Upload(); // bundle=getBundle("http://core.rz-berlin.mpg.de/edoctest/oi.epl?mm=list&grp=136&col=11"); @@ -1499,7 +1528,7 @@ public class Upload extends JApplet impl doc.docID=newDoc.docID; doc.ver=newDoc.ver; doc.fileVer=newDoc.fileVer; - bundle.exportToXML(new File("./metaout.xml")); + bundle.exportToXML(new File("./meta.xml")); } catch(Exception e7) { e7.printStackTrace();} }