Пример #1
0
 public static String getV2DataDirPath() {
   File f =
       new File(
           FileUtil.getWorkingDirPath() + File.separator + "data" + File.separator + "v2Meta");
   if ((!f.exists()) || (!f.isDirectory())) f.mkdirs();
   return f.getAbsolutePath();
   // return getV2DataDirPath(null);
 }
Пример #2
0
  public static String getV2DataDirPath(Component parent) {
    File f =
        new File(
            FileUtil.getWorkingDirPath() + File.separator + "data" + File.separator + "v2Meta");
    if ((!f.exists()) || (!f.isDirectory())) {
      if (parent == null) return null;

      String display =
          "HL7 v2 meta Directory isn't created yet.\nPress 'Yes' button if you want to create directory.\nIt may takes some minutes.";
      // JOptionPane.showMessageDialog(parent, "Making V2 Meta Directory", display,
      // JOptionPane.WARNING_MESSAGE);
      // System.out.println("CCCCV : " + display);
      int res =
          JOptionPane.showConfirmDialog(
              parent,
              display,
              "Create v2 Meta Directory",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.INFORMATION_MESSAGE);

      if (res != JOptionPane.YES_OPTION) return "";

      ClassLoaderUtil loaderUtil = null;
      try {
        loaderUtil = new ClassLoaderUtil("v2Meta");
      } catch (IOException ie) {
        JOptionPane.showMessageDialog(
            parent,
            ie.getMessage() + ".\n Check the resourceV2.zip file in the library.",
            "Creating V2 Meta Directory failure",
            JOptionPane.WARNING_MESSAGE);
        // System.err.println("Make V2 Meta Directory : " + ie.getMessage());
        return null;
      }

      for (int i = 0; i < loaderUtil.getSizeOfFiles(); i++) {
        String path = loaderUtil.getPath(i);
        if (!path.trim().toLowerCase().endsWith(".dat")) continue;
        path = path.replace("/", File.separator);
        path = FileUtil.getWorkingDirPath() + File.separator + "data" + File.separator + path;
        int index = -1;
        for (int j = path.length(); j > 0; j--) {
          String achar = path.substring(j - 1, j);
          if (achar.equals(File.separator)) {
            index = j;
            break;
          }
        }
        // System.out.println("V2 Meta : " + path);
        if (index <= 0) {
          JOptionPane.showMessageDialog(
              parent,
              "V2 Meta file is invalid : " + path,
              "Creating V2 Meta Directory failure",
              JOptionPane.WARNING_MESSAGE);

          // System.err.println("V2 Meta file is invalid : " + path);
          return null;
        }
        File dir = new File(path.substring(0, (index - 1)));
        if ((!dir.exists()) || (!dir.isDirectory())) {
          if (!dir.mkdirs()) {
            JOptionPane.showMessageDialog(
                parent,
                "V2 Meta directory making failure : " + dir,
                "Creating V2 Meta Directory failure",
                JOptionPane.WARNING_MESSAGE);

            // System.err.println("V2 Meta directory making failure : " + dir);
            return null;
          }
        }
        File datFile = new File(loaderUtil.getFileName(i));
        if ((!datFile.exists()) || (!datFile.isFile())) {
          JOptionPane.showMessageDialog(
              parent,
              "Not Found This V2 Meta temporary file : " + path,
              "Creating V2 Meta Directory failure",
              JOptionPane.WARNING_MESSAGE);

          continue;
        }
        if (!datFile.renameTo(new File(path)))
          System.err.println("V2 Meta rename failure : " + path);
      }
    }
    return f.getAbsolutePath();
  }
Пример #3
0
  @Override
  protected boolean doAction(ActionEvent e) throws Exception {
    // TODO Auto-generated method stub

    String location = ActionConstants.CMTS_HELP_MENU_CONTENT_URL;

    try {
      URL ur = new URL(location);
      URLConnection ct = ur.openConnection();
      ct.getInputStream();
    } catch (Exception ee) {
      location = null;
    }

    if (mainFrame.getMainApplet() != null) {
      try {
        if (location == null) {
          location = mainFrame.getMainApplet().getCodeBase() + "/help/CMTS_User_Guide_Document.pdf";
        }
        mainFrame.getMainApplet().getAppletContext().showDocument(new URL(location), "_blank");
      } catch (Exception me) {
        // System.out.println("CCCCX : " + me.getMessage());
        JOptionPane.showMessageDialog(
            mainFrame.getAssociatedUIComponent(),
            "Sorry, Help content is not found.",
            "Not found Help Content",
            JOptionPane.ERROR_MESSAGE);
        return false;
      }
    } else {
      BrowserLauncher browserLauncher = null;
      boolean c2 = true;
      try {
        browserLauncher = new BrowserLauncher();
      } catch (BrowserLaunchingInitializingException e1) {
        c2 = false;
      } catch (UnsupportedOperatingSystemException e2) {
        c2 = false;
      }

      while (c2) {
        c2 = false;

        if (location != null) {
          browserLauncher.openURLinBrowser(location);
          c2 = true;
          break;
        }
        String str = FileUtil.searchFile("CMTS_User_Guide_Document.pdf");
        if ((str == null) || (str.trim().equals(""))) break;
        File f = new File(str.trim());
        if ((!f.exists()) || (!f.isFile())) break;
        URL url = f.toURI().toURL();
        browserLauncher.openURLinBrowser(url.toString());
        c2 = true;
        break;
      }

      if (!c2) {
        JOptionPane.showMessageDialog(
            mainFrame.getAssociatedUIComponent(),
            "Sorry, Help Content is not found.",
            "Not found Help Content",
            JOptionPane.ERROR_MESSAGE);
        return false;
      }
    }
    return true;
  }