package smart_gs.util;

import java.awt.Component;
import java.awt.event.MouseEvent;

import smart_gs.debugprint.Debugprint;
import smart_gs.drawing_tool.ImageLabel;
import smart_gs.drawing_tool.SpreadCanvas;
import smart_gs.smleditor.swingui.GSEditor;
import smart_gs.swingui.GSMouseEvent;
import smart_gs.swingui.WorkspaceWindow;
import smart_gs.swingui.toolbar.ImageToolBar;

public class ImageToolBarSetModeByMouseEvent {

	public void setMode(MouseEvent e, int mode) {
		GSEditor gseditor = null;
		SpreadCanvas spreadcanvas = null;
		ImageToolBar imagetoolbar = null;
		Component component = e.getComponent();
		if (!(component instanceof ImageLabel)) {
			System.out.println("A fatal bug in DefaultState.java");
			return;
		}
		ImageLabel imageLabel = (ImageLabel)component;
		spreadcanvas = imageLabel.getSpreadCanvas();
		gseditor = spreadcanvas.getGSEditor();
		if (gseditor != null){
			imagetoolbar = gseditor.getImageToolBar();
		} else {
			imagetoolbar = WorkspaceWindow.getInstance().getImageToolBar();
		}
		imagetoolbar.setMode(mode);
	}
}
