/* $Id: GSMarkupAction.java 783 2013-10-22 13:07:54Z ohura $ */
package smart_gs.swingui.toolbar;

import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.PointerInfo;
import java.awt.event.ActionEvent;

import smart_gs.smleditor.swingui.GSEditorTextPane;
import smart_gs.smleditor.swingui.GSMarkupDialog;
import smart_gs.spread_selection.MarkupUtil;
import sml_editor.swingui.toolbar.action.MarkupAction;


public class GSMarkupAction extends MarkupAction {
	
	public GSMarkupAction() {
		super();
	}
	public void setEditorTextPane(GSEditorTextPane textPane){
		this.textPane = textPane;
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		MarkupUtil markupUtil = new MarkupUtil(this.textPane,textPane.getSource().length());
		int start = this.textPane.getSGSHTMLEditorTextPane().getSelectionStart();
		int end = this.textPane.getSGSHTMLEditorTextPane().getSelectionEnd();
//		if(markupUtil.check(start,end)){
//			while(markupUtil.check(start,end)){
//				markupUtil.releasMakup();
//			}
//			return;
//		}
//		if(start == end){
//			return;
//		}
		this.dialog = new GSMarkupDialog((GSEditorTextPane)this.textPane,start,end);
		
    	PointerInfo pointerInfo = MouseInfo.getPointerInfo();
    	Point p = pointerInfo.getLocation();
    	this.dialog.setLocation(p.x-200,p.y-80);
    	
		this.dialog.show();
	}
}
