<#assign licenseFirst = "/*">
<#assign licensePrefix = " * ">
<#assign licenseLast = " */">
<#include "../Licenses/license-${project.license}.txt">

package ${PACKAGENAME};

import com.sun.tools.visualvm.application.Application;
import com.sun.tools.visualvm.core.datasource.DataSource;
import com.sun.tools.visualvm.core.snapshot.Snapshot;
import com.sun.tools.visualvm.core.ui.DataSourceView;
import com.sun.tools.visualvm.core.ui.DataSourceViewProvider;
import com.sun.tools.visualvm.core.ui.DataSourceViewsManager;
import com.sun.tools.visualvm.core.ui.PluggableDataSourceViewProvider;
import com.sun.tools.visualvm.coredump.CoreDump;
import com.sun.tools.visualvm.heapdump.HeapDump;
import com.sun.tools.visualvm.host.Host;
import com.sun.tools.visualvm.threaddump.ThreadDump;
import java.util.Set;

public class ${TEMPLATENAME}ViewProvider extends PluggableDataSourceViewProvider<${DISPLAYNAME}> {
    private static class Singleton {
        final private static ${TEMPLATENAME}ViewProvider INSTANCE = new ${TEMPLATENAME}ViewProvider();
    }

    private ${TEMPLATENAME}ViewProvider() {}

    // TODO adjust the view visibility
    @Override
    public boolean supportsViewFor(${DISPLAYNAME} my${DISPLAYNAME}) {
        //Always shown:
        return true;
    }

    @Override
    public synchronized DataSourceView createView(final ${DISPLAYNAME} my${DISPLAYNAME}) {
        return new ${TEMPLATENAME}View(my${DISPLAYNAME}) ;
    }
    
    public static ${TEMPLATENAME}ViewProvider getInstance() {
        return Singleton.INSTANCE;
    }

    /**
     * TODO Call this method from the module Installer#restored()
     **/
    public static void install() {
        DataSourceViewsManager.sharedInstance().addViewProvider(Singleton.INSTANCE, ${DISPLAYNAME}.class);
    }
    
    /**
     * TODO Call this method from the module Installer#uninstalled()
     **/
    public static void uninstall() {
        DataSourceViewsManager.sharedInstance().removeViewProvider(Singleton.INSTANCE);
    }

    @Override
    public Set<Integer> getPluggableLocations(DataSourceView arg0) {
        // TODO update the view supported locations (DataViewComponent.TOP_LEFT, DataViewComponent.TOP_RIGHT, DataViewComponent.BOTTOM_LEFT, DataViewComponent.BOTTOM_RIGHT)
        return ALL_LOCATIONS;
    }

}

