/** Handle the import action request. */
  public void onImport() {

    String finalFile = ""; // $NON-NLS-1$

    if (file == null) {
      UIFileFilter filter =
          new UIFileFilter(new String[] {"xml"}, "XML Files"); // $NON-NLS-1$ //$NON-NLS-2$

      UIFileChooser fileDialog = new UIFileChooser();
      fileDialog.setDialogTitle(
          LanguageProperties.getString(
              LanguageProperties.DIALOGS_BUNDLE,
              "UIImportFlashMeetingXMLDialog.chooseFile2")); //$NON-NLS-1$
      fileDialog.setFileFilter(filter);
      fileDialog.setApproveButtonText(
          LanguageProperties.getString(
              LanguageProperties.DIALOGS_BUNDLE,
              "UIImportFlashMeetingXMLDialog.importButton")); //$NON-NLS-1$
      fileDialog.setRequiredExtension(".xml"); // $NON-NLS-1$

      // FIX FOR MAC - NEEDS '/' ON END TO DENOTE A FOLDER
      if (!UIImportFlashMeetingXMLDialog.lastFileDialogDir.equals("")) { // $NON-NLS-1$
        File file =
            new File(UIImportFlashMeetingXMLDialog.lastFileDialogDir + ProjectCompendium.sFS);
        if (file.exists()) {
          fileDialog.setCurrentDirectory(file);
        }
      }

      UIUtilities.centerComponent(fileDialog, ProjectCompendium.APP);
      int retval = fileDialog.showOpenDialog(ProjectCompendium.APP);
      if (retval == JFileChooser.APPROVE_OPTION) {
        if ((fileDialog.getSelectedFile()) != null) {

          String fileName = fileDialog.getSelectedFile().getAbsolutePath();
          File fileDir = fileDialog.getCurrentDirectory();
          String dir = fileDir.getPath();

          if (fileName != null) {
            UIImportFlashMeetingXMLDialog.lastFileDialogDir = dir;
            finalFile = fileName;
          }
        }
      }
    } else {
      finalFile = file.getAbsolutePath();
    }

    if (finalFile != null) {
      if ((new File(finalFile)).exists()) {
        setVisible(false);
        Vector choices = new Vector();

        if (cbIncludeKeywords.isSelected()) {
          choices.addElement(FlashMeetingXMLImport.KEYWORDS_LABEL);
        }
        if (cbIncludeAttendees.isSelected()) {
          choices.addElement(FlashMeetingXMLImport.ATTENDEE_LABEL);
        }
        if (cbIncludePlayList.isSelected()) {
          choices.addElement(FlashMeetingXMLImport.PLAYLIST_LABEL);
        }
        if (cbIncludeURLs.isSelected()) {
          choices.addElement(FlashMeetingXMLImport.URL_LABEL);
        }
        if (cbIncludeChats.isSelected()) {
          choices.addElement(FlashMeetingXMLImport.CHAT_LABEL);
        }
        if (cbIncludeWhiteboard.isSelected()) {
          choices.addElement(FlashMeetingXMLImport.WHITEBOARD_LABEL);
        }
        if (cbIncludeFileData.isSelected()) {
          choices.addElement(FlashMeetingXMLImport.FILEDATA_LABEL);
        }
        if (cbIncludeAnnotations.isSelected()) {
          choices.addElement(FlashMeetingXMLImport.ANNOTATIONS_LABEL);
        }
        if (cbIncludeVotes.isSelected()) {
          choices.addElement(FlashMeetingXMLImport.VOTING_LABEL);
        }

        DBNode.setNodesMarkedSeen(cbMarkSeen.isSelected());

        FlashMeetingXMLImport xmlImport =
            new FlashMeetingXMLImport(finalFile, ProjectCompendium.APP.getModel(), choices);
        xmlImport.start();

        dispose();
        ProjectCompendium.APP.setStatus(""); // $NON-NLS-1$
      }
    }
  }
Esempio n. 2
0
  /**
   * Get the contents of a URL and return it as an image.
   *
   * @return a String representing the path the file was actually saved to, or empty string if
   *     something failed.
   */
  public static String loadWebImageToLinkedFiles(String address, String sFileName, String sPath)
      throws Exception {

    ProjectCompendium.APP.setWaitCursor();

    File newFile = new File(sPath + sFileName);

    String imgAddress = address.toLowerCase();

    if ((imgAddress.startsWith("www")
            || imgAddress.startsWith("http")
            || imgAddress.startsWith("https")) // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        && isImage(imgAddress)) { // $NON-NLS-1$

      if (newFile.exists()) {
        int response =
            JOptionPane.showConfirmDialog(
                ProjectCompendium.APP,
                LanguageProperties.getString(
                        LanguageProperties.UI_GENERAL_BUNDLE, "UIImages.nameExistsMessage1a")
                    + "\n"
                    + //$NON-NLS-1$ //$NON-NLS-2$
                    LanguageProperties.getString(
                        LanguageProperties.UI_GENERAL_BUNDLE, "UIImages.nameExistsMessage1b")
                    + "\n\n"
                    + //$NON-NLS-1$ //$NON-NLS-2$
                    "("
                    + LanguageProperties.getString(
                        LanguageProperties.UI_GENERAL_BUNDLE, "UIImages.nameExistsMessage1c")
                    + ")\n\n", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                LanguageProperties.getString(
                    LanguageProperties.UI_GENERAL_BUNDLE, "UIImages.externalDragAndDrop"),
                JOptionPane.YES_NO_OPTION); // $NON-NLS-1$

        if (response == JOptionPane.YES_OPTION) {

          UIFileChooser fileDialog = new UIFileChooser();
          fileDialog.setDialogType(JFileChooser.SAVE_DIALOG);
          fileDialog.setDialogTitle(
              LanguageProperties.getString(
                  LanguageProperties.UI_GENERAL_BUNDLE, "UIImages.changeFileName")); // $NON-NLS-1$
          fileDialog.setApproveButtonText(
              LanguageProperties.getString(
                  LanguageProperties.UI_GENERAL_BUNDLE, "UIImages.saveButton")); // $NON-NLS-1$
          fileDialog.setCurrentDirectory(new File(newFile.getParent() + ProjectCompendium.sFS));
          fileDialog.setSelectedFile(newFile);
          UIUtilities.centerComponent(fileDialog, ProjectCompendium.APP);
          int retval = fileDialog.showSaveDialog(ProjectCompendium.APP);
          if (retval == JFileChooser.APPROVE_OPTION) {
            if ((fileDialog.getSelectedFile()) != null) {

              String fileName2 = fileDialog.getSelectedFile().getName();
              if (fileName2 != null) {
                sFileName = fileName2;
                File fileDir = fileDialog.getCurrentDirectory();

                if (ProjectCompendium.isMac)
                  sPath = fileDir.getAbsolutePath() + ProjectCompendium.sFS;
                else sPath = fileDir.getPath();
              }
            }
          } else {
            return new String(""); // $NON-NLS-1$
          }
        }
      }

      URL url = new URL(address);
      URLConnection conn = url.openConnection();
      conn.connect();

      DataInputStream stream = new DataInputStream(new BufferedInputStream(conn.getInputStream()));
      FileOutputStream output = new FileOutputStream(sPath + sFileName);
      int count = conn.getContentLength();
      if (count > 0) {
        for (int i = 0; i < count; i++) {
          output.write(stream.read());
        }
      } else {
        sFileName = ""; // $NON-NLS-1$
      }

      stream.close();
      output.flush();
      output.close();

      ProjectCompendium.APP.setDefaultCursor();
      return sPath + sFileName;

    } else {
      ProjectCompendium.APP.setDefaultCursor();
      return new String(""); // $NON-NLS-1$
    }
  }