コード例 #1
0
ファイル: Attachment.java プロジェクト: jdhuayta/libertya
  /** Descripción de Método */
  private void loadAttachments() {
    log.config("");

    // Set Text/Description

    String sText = m_attachment.getTextMsg();

    if (sText == null) {
      text.setText("");
    } else {
      text.setText(sText);
    }

    // Set Combo

    int size = m_attachment.getEntryCount();

    for (int i = 0; i < size; i++) {
      cbContent.addItem(m_attachment.getEntryName(i));
    }

    if (size > 0) {
      cbContent.setSelectedIndex(0);
    } else {
      displayData(0);
    }
  } // loadAttachment
コード例 #2
0
ファイル: Attachment.java プロジェクト: jdhuayta/libertya
  /**
   * Descripción de Método
   *
   * @return
   */
  private boolean openAttachment() {
    int index = cbContent.getSelectedIndex();
    byte[] data = m_attachment.getEntryData(index);

    if (data == null) {
      return false;
    }

    try {
      String fileName = System.getProperty("java.io.tmpdir") + m_attachment.getEntryName(index);
      File tempFile = new File(fileName);

      m_attachment.getEntryFile(index, tempFile);

      if (isWindows()) {

        // Runtime.getRuntime().exec ("rundll32 url.dll,FileProtocolHandler " + url);

        Process p =
            Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL \"" + tempFile + "\"");

        // p.waitFor();

        return true;
      } else if (isMac()) {
        String[] cmdArray = new String[] {"open", tempFile.getAbsolutePath()};
        Process p = Runtime.getRuntime().exec(cmdArray);

        // p.waitFor();

        return true;
      } else // other OS
      {
      }
    } catch (Exception e) {
      log.log(Level.SEVERE, "openFile", e);
    }

    return false;
  } // openFile