/* $Id: WysiwygDocumentListener.java 125 2011-03-09 09:49:51Z ohura $ */
package sml_editor.swingui.wysiwyg;

import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;

import org.xml.sax.SAXException;

import sml_editor.swingui.EditorTextPane;
import sml_editor.swingui.GSHTMLEditorTextPane;


public class WysiwygDocumentListener implements DocumentListener{
	
	private Document document;
	private EditorTextPane textPane;
	private GSHTMLEditorTextPane gsHTMLEditorTextPane;
	
	public WysiwygDocumentListener(EditorTextPane textPane){
		this.textPane = textPane;
		this.document = textPane.getGSHTMLEditorTextPane().getStyledDocument();
		this.gsHTMLEditorTextPane = textPane.getGSHTMLEditorTextPane();
	}
	public void changedUpdate(DocumentEvent e) {
	}

	public void insertUpdate(DocumentEvent e) {
//		try {
//			controller.setSource("<SML><![CDATA[" + gsHTMLEditorTextPane.getText() + "]]></SML>");
//		} catch (SAXException e1) {
//			// TODO 自動生成された catch ブロック
//			e1.printStackTrace();
//		}
/*		int offset = e.getOffset();
		int length = e.getLength();
		try {
			String text = document.getText(offset,length);
			this.controller.insertString(offset,text);
			
		} catch (BadLocationException e1) {
			e1.printStackTrace();
		} */
	}

	public void removeUpdate(DocumentEvent e) {
//		try {
//			controller.setSource("<SML><![CDATA[" + gsHTMLEditorTextPane.getText() + "]]></SML>");
//		} catch (SAXException e1) {
			// TODO 自動生成された catch ブロック
//			e1.printStackTrace();
//		}

/*		int offset = e.getOffset();
		int length = e.getLength();
		this.controller.delete(offset,offset+length); */
	}
	
}
