Logo Search packages:      
Sourcecode: fex version File versions  Download package

void fix::AppletFrame::actionPerformed ( ActionEvent  arg0  )  [inline]

Called by button click or shortcuts.

Definition at line 194 of file AppletFrame.java.

References fix::ZipFactory::add(), fix::ZipFactory::create(), getInfoFrame(), isFieldSet(), resetAllGUIElements(), fix::Sender::send(), setFileText(), fix::ErrorWindow::setMess(), setStatusLabel(), updateFileSize(), and fix::ZipFactory::updateSum().

                                                    {
            String c = arg0.getActionCommand();
            if (c.equals("reset")) { //ResetItem pressed
                  resetAllGUIElements();
                  if ((tempFile != null) && (tempFile.exists())) {
                        tempFile.delete();
                  }
            } else if (c.equals("exit")) { //ExitItem pressed
                  if ((tempFile != null) && (tempFile.exists())) {
                        tempFile.delete();
                  }
                  this.dispose();
            } else if (c.equals("browse")) { //fileButton pressed
                  browser.setDialogTitle("Open - Use Ctrl/Strg key to select multiple files/dirs");
                  browser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
                  browser.setMultiSelectionEnabled(true);
                  browser.setCurrentDirectory(homeDir);
                  browser.setSelectedFile(new File(""));
                  int returnVal = browser.showOpenDialog(this);
                  if (returnVal == JFileChooser.APPROVE_OPTION) {
                        if ((tempFile != null) && tempFile.exists()) {
                              tempFile.delete();
                        }
                        homeDir = browser.getCurrentDirectory();
                        File []selectedFiles = browser.getSelectedFiles();
                        if (selectedFiles.length == 1 && selectedFiles[0].isFile()) { 
                              setFileText(selectedFiles[0].getAbsolutePath());
                              setStatusLabel("ready to send");
                              sendButton.setEnabled(true);
                        }
                        else {
                              if (tempFile == null) {
                                    tempFile = new File(System.getProperty("user.home") 
                                          + File.separator + "fex.zip");
                                    tempFile.deleteOnExit();
                              }
                              browser.setDialogTitle("Multiple files selected, where shall I save the ZIP archive?");
                              browser.setFileSelectionMode(JFileChooser.FILES_ONLY);
                              browser.setMultiSelectionEnabled(false);
                              browser.setSelectedFile(tempFile);
                              while (browser.showDialog(this, "Save & Send") == JFileChooser.APPROVE_OPTION) {
                                    tempFile = browser.getSelectedFile();
                                    int overwriteReturnValue = JOptionPane.YES_OPTION;
                                    if (tempFile.exists()) {
                                          overwriteReturnValue = JOptionPane.NO_OPTION;
                                          overwriteReturnValue = JOptionPane.showConfirmDialog(null,
                                                      tempFile.toString() + " already exists." + System.getProperty("line.separator")
                                                  + "Do you want to replace it?", "File Already Exists",
                                                  JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                                    }
                                    if (overwriteReturnValue == JOptionPane.YES_OPTION) {
                                          setStatusLabel("creating ZIP file, please wait");
                                          setFileText("...");
                                          RepaintManager.currentManager(this).markCompletelyDirty(jContentPane);
                                          RepaintManager.currentManager(this).markCompletelyDirty(mainMenuBar);
                                          RepaintManager.currentManager(this).paintDirtyRegions();
                                          try {
                                                ZipFactory zip = new ZipFactory(progressBar);
                                                for (int i = 0; i < selectedFiles.length; i++) {
                                                      zip.add(selectedFiles[i]);
                                                }
                                                if (zip.updateSum(selectedFiles) >= ((long)4096 * 1024 * 1024)) {  // ZIP files larger than 4 GB are not supported yet
                                                      resetAllGUIElements();
                                                      er.setMess("Sorry ZIP files larger than 4 GB cannot be created. " + 
                                                                  "We have to wait for Java 1.7...", null);
                                                      break;
                                                }
                                                progressBar.setValue(0);
                                                progressBar.setVisible(true);
                                                zip.create(new FileOutputStream(tempFile));
                                                progressBar.setVisible(false);
                                                progressBar.setValue(0);
                                                setFileText(tempFile.getAbsolutePath());
                                                setStatusLabel("ZIP created, ready to send");
                                                RepaintManager.currentManager(dataPanel).paintDirtyRegions();
                                                sendButton.setEnabled(true);
                                                sendButton.doClick(2);
                                          } catch (FileNotFoundException e) {
                                                er.setMess("Unable to add a file to the temporary ZIP archive.", null);
                                                if ((tempFile != null) && (tempFile.exists())) {
                                                      tempFile.delete();
                                                }
                                          } catch (IOException e) {
                                                er.setMess("Unable to create temporary ZIP file: " + e.getMessage(), null);
                                                if ((tempFile != null) && (tempFile.exists())) {
                                                      tempFile.delete();
                                                }
                                          }
                                          break;
                                    }
                              }
                        }
                  }
            } else if (c.equals("send")) { //sendButton pressed
                  if (isFieldSet(recField)) {
                        if (isFieldSet(fileField)) {
                              if (new File(fileField.getText()).length() > 0) {
                                    setStatusLabel("sending");
                                    s = new Sender(recField.getText(), fileField.getText(),
                                                commentField.getText(), viewCheck.isSelected(),
                                                host, use, auth, akey, skey, er, debug);
                                    if (s.send(progressBar, statusLabel)) {
                                          if (tempFile != null && tempFile.exists()) {
                                                tempFile.delete();
                                          }
                                          resetAllGUIElements();
                                    }
                                    else {
                                          setStatusLabel("error...");
                                    }
                              } else {
                                    er.setMess("Your file is empty.", null);
                              }
                        } else {
                              er.setMess("Enter or choose file please.", null);
                        }
                  } else {
                        er.setMess("Enter recipients E-Mail please.", null);
                  }
            } else if (c.equals("info")) { //infoItem pressed
                  getInfoFrame();
            } else if (c.equals("change")) { //fileField changed
                  File f = new File(fileField.getText());
                  updateFileSize(f.length());
            } else if (c.equals("closeinfo")) { // InfoFrame closing
                  infoFrame.dispose();
            } else {
                  System.out.println(c);
            }

      }


Generated by  Doxygen 1.6.0   Back to index