package transformation;

import com.nomagic.actions.AMConfigurator;
import com.nomagic.actions.ActionsManager;
import com.nomagic.magicdraw.actions.ActionsConfiguratorsManager;
import com.nomagic.magicdraw.actions.DiagramContextAMConfigurator;
import com.nomagic.magicdraw.actions.MDActionsCategory;
import com.nomagic.magicdraw.uml.DiagramTypeConstants;
import com.nomagic.magicdraw.uml.symbols.DiagramPresentationElement;
import com.nomagic.magicdraw.uml.symbols.PresentationElement;

import transformation.associationtags.ShowAssociationTags;
import transformation.su_transformationplugin.SU_Transformation;
import transformation.us_transformationplugin.US_Transformation;
import transformation.wizards.SecureUML_WizardDiagramAction;
import transformation.wizards.UMLsec_WizardDiagramAction;

public class TransformationPlugin  extends com.nomagic.magicdraw.plugins.Plugin {
	
		public void init() {
		
			final SU_Transformation su_transformation = new SU_Transformation();
			final SecureUML_WizardDiagramAction su_wizard = new SecureUML_WizardDiagramAction();
			final US_Transformation us_transformation = new US_Transformation();
			final UMLsec_WizardDiagramAction us_wizard = new UMLsec_WizardDiagramAction();
			final ShowAssociationTags showAssociationTags = new ShowAssociationTags();
			ActionsConfiguratorsManager.getInstance().addDiagramContextConfigurator
			(DiagramTypeConstants.UML_ANY_DIAGRAM, new DiagramContextAMConfigurator() {
		
			// Add the created action to class diagram.
			public void configure(ActionsManager mngr, DiagramPresentationElement diagram, 
					PresentationElement selected[], PresentationElement requestor) {
			
				// actions must be added into some category.
				// so create the new one, or add action into existing category.
				MDActionsCategory su_category = new MDActionsCategory("", "");
				su_category.addAction(su_transformation);
				su_category.addAction(su_wizard);
				// add category into manager.
				// Category isn’t displayed in context menu.
				mngr.addCategory(su_category);
				
				MDActionsCategory us_category = new MDActionsCategory("", "");
				us_category.addAction(us_transformation);
				us_category.addAction(us_wizard);
				// add category into manager.
				// Category isn’t displayed in context menu.
				mngr.addCategory(us_category);
				
				MDActionsCategory tags_category = new MDActionsCategory("", "");
				tags_category.addAction(showAssociationTags);
				// add category into manager.
				// Category isn’t displayed in context menu.
				mngr.addCategory(tags_category);
			}
			
			public int getPriority() {
				return AMConfigurator.MEDIUM_PRIORITY;
			}
		});
	}

		public boolean close() {
			return true;
		}
		
		public boolean isSupported() {
			return true;
		}
}
