package be.iminds.ilabt.jfed.experimenter_gui.util;

import javafx.application.HostServices;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import java.net.URL;

/**
 * User: twalcari
 * Date: 2/4/2015
 * Time: 10:16
 */
@Singleton
public class BrowserUtil {
    private static final Logger LOG = LoggerFactory.getLogger(BrowserUtil.class);

    private final Provider<HostServices> hostServicesProvider;

    @Inject
    public BrowserUtil(Provider<HostServices> hostServicesProvider) {
        this.hostServicesProvider = hostServicesProvider;
    }

    public boolean openUrlInBrowser(URL url){
        //open browser
        hostServicesProvider.get().showDocument(url.toExternalForm());
        return true;
    }

}
