Search in sources :

Example 1 with MimeToHtmlAdapter

use of com.kyj.fx.voeditor.visual.framework.word.MimeToHtmlAdapter in project Gargoyle by callakrsos.

the class SimpleTextView method miOpenNamoWebViewOnAction.

/**
	 * Mime 데이터타입을 Html컨텐츠형태로 조회하기 위한 웹 뷰를 오픈함.
	 * @작성자 : KYJ
	 * @작성일 : 2016. 12. 29.
	 */
@FXML
public void miOpenNamoWebViewOnAction() {
    String content = codeArea.getText();
    try {
        WebView webView = new WebView();
        //			new ContentMimeHtmlAdapter(content)
        //			String encodeToString = Base64.getEncoder().encodeToString(content.getBytes());
        //
        //			byte[] decode = Base64.getDecoder().decode(encodeToString);
        //			String string = new String(decode);
        //			MimeBodyPart part = new MimeBodyPart(new ByteArrayInputStream(content.getBytes()));
        //			Enumeration allHeaders = part.getAllHeaders();
        //			while(allHeaders.hasMoreElements())
        //			{
        //				javax.mail.Header nextElement = (Header) allHeaders.nextElement();
        //
        //				System.out.println(nextElement.getName());
        //				System.out.println(nextElement.getValue());
        //			}
        //
        //			DataHandler dataHandler = part.getDataHandler();
        //			Object transferData = dataHandler.getTransferData(new DataFlavor("text/html"));
        //			System.out.println(transferData);
        //			ContentMimeHtmlAdapter adapter = new ContentMimeHtmlAdapter(content);
        //			File tempFile = adapter.toTempFile();
        //			byte[] decode = Base64.getMimeDecoder().decode(content.getBytes("UTF-8"));
        //			String string = new String(decode);
        FxUtil.createStageAndShow(webView, stage -> {
            stage.setAlwaysOnTop(true);
            stage.initOwner(getScene().getWindow());
            stage.focusedProperty().addListener((oba, o, n) -> {
                if (!n)
                    stage.close();
            });
        });
        javafx.application.Platform.runLater(() -> {
            try {
                MimeToHtmlAdapter adapter = new MimeToHtmlAdapter(content);
                webView.getEngine().loadContent(adapter.getContent());
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : MimeToHtmlAdapter(com.kyj.fx.voeditor.visual.framework.word.MimeToHtmlAdapter) WebView(javafx.scene.web.WebView) FXML(javafx.fxml.FXML)

Aggregations

MimeToHtmlAdapter (com.kyj.fx.voeditor.visual.framework.word.MimeToHtmlAdapter)1 FXML (javafx.fxml.FXML)1 WebView (javafx.scene.web.WebView)1