/* $Id: GSMarkupAction.java 439 2011-10-19 12:50:30Z shayashi $ */
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.getGSHTMLEditorTextPane().getSelectionStart();
		int end = this.textPane.getGSHTMLEditorTextPane().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();
	}
}
