package edu.odu.icat.graphicsinterface.editor;

import com.mxgraph.swing.mxGraphComponent;
import edu.odu.icat.graphicsinterface.editor.EditorActions.HistoryAction;
import edu.odu.icat.graphicsinterface.editor.EditorActions.NewVertexAction;
import com.mxgraph.swing.util.mxGraphActions;
import com.mxgraph.util.mxResources;


import javax.swing.*;

public class EditorPopupMenu extends JPopupMenu
{

	/**
	 * 
	 */
	private static final long serialVersionUID = -3132749140550242191L;

	public EditorPopupMenu(BasicGraphEditor editor)
	{
		boolean selected = !editor.getGraphComponent().getGraph()
				.isSelectionEmpty();

        //add(editor.bind("Test", new EditorActions.TestAction()));
        add(editor.bind(mxResources.get("newVertex"), new NewVertexAction()));

        addSeparator();

        add(editor.bind(mxResources.get("zoomIn"), mxGraphActions.getZoomInAction()));
        add(editor.bind(mxResources.get("zoomOut"), mxGraphActions.getZoomOutAction()));
        add(editor.bind(mxResources.get("actualSize"),mxGraphActions.getZoomActualAction()));

		//add(editor.bind(mxResources.get("undo"), new HistoryAction(true),
		//		"/com/mxgraph/examples/swing/images/undo.gif"));

		addSeparator();

		add(
				editor.bind(mxResources.get("cut"), TransferHandler
						.getCutAction(),
						"/com/mxgraph/examples/swing/images/cut.gif"))
				.setEnabled(selected);
		add(
				editor.bind(mxResources.get("copy"), TransferHandler
						.getCopyAction(),
						"/com/mxgraph/examples/swing/images/copy.gif"))
				.setEnabled(selected);
		add(editor.bind(mxResources.get("paste"), TransferHandler
				.getPasteAction(),
				"/com/mxgraph/examples/swing/images/paste.gif"));

		addSeparator();

		add(
				editor.bind(mxResources.get("delete"), new EditorActions.DeleteVertexAction(),
						"/com/mxgraph/examples/swing/images/delete.gif"))
				.setEnabled(selected);

		//addSeparator();

		// Creates the format menu
		//JMenu menu = (JMenu) add(new JMenu(mxResources.get("format")));

		//EditorMenuBar.populateFormatMenu(menu, editor);

		// Creates the shape menu
		//menu = (JMenu) add(new JMenu(mxResources.get("shape")));

		//EditorMenuBar.populateShapeMenu(menu, editor);

		//addSeparator();

		//add(
		//		editor.bind(mxResources.get("edit"), mxGraphActions
		//				.getEditAction())).setEnabled(selected);

		//addSeparator();

		//add(editor.bind(mxResources.get("selectVertices"), mxGraphActions
		//		.getSelectVerticesAction()));
		//add(editor.bind(mxResources.get("selectEdges"), mxGraphActions
		//		.getSelectEdgesAction()));

		//addSeparator();

		//add(editor.bind(mxResources.get("selectAll"), mxGraphActions
		//		.getSelectAllAction()));
	}

}

@@ -1180,32 +1180,34 @@
 undo.gif%22));%0A%0A%09%09
+//
 addSeparator();%0A
@@ -1201,39 +1201,43 @@
 Separator();%0A%0A%09%09
+//
 add(%0A%09%09
+//
 %09%09editor.bind(mx
@@ -1268,32 +1268,34 @@
 ansferHandler%0A%09%09
+//
 %09%09%09%09.getCutActio
@@ -1293,32 +1293,34 @@
 tCutAction(),%0A%09%09
+//
 %09%09%09%09%22/com/mxgrap
@@ -1348,32 +1348,34 @@
 es/cut.gif%22))%0A%09%09
+//
 %09%09.setEnabled(se
@@ -1385,23 +1385,27 @@
 ted);%0A%09%09
+//
 add(%0A%09%09
+//
 %09%09editor
@@ -1453,16 +1453,18 @@
 ndler%0A%09%09
+//
 %09%09%09%09.get
@@ -1471,32 +1471,34 @@
 CopyAction(),%0A%09%09
+//
 %09%09%09%09%22/com/mxgrap
@@ -1527,32 +1527,34 @@
 s/copy.gif%22))%0A%09%09
+//
 %09%09.setEnabled(se
@@ -1564,16 +1564,18 @@
 ted);%0A%09%09
+//
 add(edit
@@ -1626,16 +1626,18 @@
 ndler%0A%09%09
+//
 %09%09.getPa
@@ -1651,16 +1651,18 @@
 on(),%0A%09%09
+//
 %09%09%22/com/

Remove cut, copy, and paste from the popup menu