source MCPXutils;

global string $MCPXLastAdapterUuid;

global proc AEMCPXAdapterTemplate( string $nodeName ){

    editorTemplate -beginScrollLayout;

	editorTemplate -beginLayout "Data sources" -collapse false;

	   editorTemplate -callCustom "MCPXDataSourceNew" "MCPXDataSourceReplace" "dnSetMembers";

	editorTemplate -endLayout;

    AEobjectSetNoScroll $nodeName;

	editorTemplate -addExtraControls;

	editorTemplate -endScrollLayout;
}

global proc MCPXDataSourceNew(string $dnSetMembers){
    python("from mocapx.ui.ae.adapter import adapter_datasouces_create_view");
    string $par = `setParent -q`;

    python("adapter_datasouces_create_view('" + $par + "', '" + $dnSetMembers + "')");

    global string $MCPXLastAdapterUuid;
    $MCPXLastAdapterUuid = MCPXGetNodeUUID($dnSetMembers);

}

global proc MCPXDataSourceReplace(string $dnSetMembers){
    python("from mocapx.ui.ae.adapter import adapter_datasouces_update_view");
    string $par = `setParent -q`;

    global string $MCPXLastAdapterUuid;

    python("adapter_datasouces_update_view('" + $par + "', '" + $dnSetMembers + "', '" + $MCPXLastAdapterUuid + "')");

    $MCPXLastAdapterUuid = MCPXGetNodeUUID($dnSetMembers);
}
