1/**
2 * WebCola layout plugin.
3 */
4Draw.loadPlugin(function(ui)
5{
6	mxscript("plugins/webcola/cola.min.js", null, null, null, true);
7	mxscript("plugins/webcola/mxWebColaAdaptor.js", null, null, null, true);
8	mxscript("plugins/webcola/mxWebColaLayout.js", null, null, null, true);
9
10	// Adds resource for action
11	mxResources.parse('webColaLayout=WebCola Layout...');
12
13	// Adds action
14	ui.actions.addAction('webColaLayout', function()
15	{
16		// TODO: set mxWebColaAdaptor's doAnimations to the value of editorUi.allowAnimation
17		// TODO: don't record all animation steps as undo states
18		var graph = ui.editor.graph;
19		var layout = new mxWebColaLayout(graph);
20		var parent = graph.getDefaultParent();
21		layout.execute(parent);
22	});
23
24	var menu = ui.menus.get('layout');
25
26	if (menu != null)
27	{
28		var oldFunct = menu.funct;
29
30		menu.funct = function(menu, parent)
31		{
32			oldFunct.apply(this, arguments);
33
34			if (typeof window.mxWebColaLayout === 'function')
35			{
36				ui.menus.addMenuItems(menu, ['-', 'webColaLayout'], parent);
37			}
38		};
39	}
40});
41