package com.nomagic.magicdraw.examples.customdraganddrop;

import com.nomagic.magicdraw.plugins.Plugin;
import com.nomagic.magicdraw.ui.dnd.CustomDragAndDropHandler;
import com.nomagic.magicdraw.ui.dnd.CustomDropDiagramHandlerFactory;
import com.nomagic.magicdraw.ui.dnd.CustomShapeMoveHandlerFactory;

/**
 * Drag and Drop plugin, to show custom Drag and Drop capabilities.
 * Plugin registers custom handlers for Drag and Drop actions.
 * <p/>
 * Drag and Drop handlers have two types.
 * First on is used for Drag and Drop from diagram Browser.
 * Second on is used for Drag and Drop in diagram.
 * To use same Drag and Drop in browser and diagram it is needed to register both handlers.
 *
 * @author Rolandas Kasinskas
 */
public class CustomDragAndDropPlugin extends Plugin
{
	@Override
	public void init()
	{
		//Create implementation object for custom Drag and Drop handler.
		//The main implementation of the Drag and Drop functionality for custom Drag and Drop behavior.
		CustomDragAndDropHandler handlerImpl = new CustomDragAndDropImpl();

		//Registers custom Drag and Drop handler only for browser.
		CustomDropDiagramHandlerFactory.register(handlerImpl);

		//Registers custom Drag and Drop handler only for diagram.
		CustomShapeMoveHandlerFactory.register(handlerImpl);
	}

	@Override
	public boolean close()
	{
		return true;
	}

	@Override
	public boolean isSupported()
	{
		return true;
	}
}