/**
 * i-net software provides programming examples for illustration only, without warranty
 * either expressed or implied, including, but not limited to, the implied warranties
 * of merchantability and/or fitness for a particular purpose. This programming example
 * assumes that you are familiar with the programming language being demonstrated and
 * the tools used to create and debug procedures. i-net software support professionals
 * can help explain the functionality of a particular procedure, but they will not modify
 * these examples to provide added functionality or construct procedures to meet your
 * specific needs.
 *
 * Copyright © 1999-2026 i-net software GmbH, Berlin, Germany.
**/
package com.inet.dashboard.openweathermap;

import javax.annotation.Nonnull;

import com.inet.classloader.I18nMessages;
import com.inet.dashboard.api.DashboardWidget;
import com.inet.file.CombinedFileDescription;
import com.inet.file.JavaScriptModule;
import com.inet.file.FileCombiner.CombinedFile;
import com.inet.logging.LogManager;
import com.inet.logging.Logger;
import com.inet.plugin.PluginInfo;
import com.inet.plugin.ServerPlugin;
import com.inet.plugin.ServerPluginManager;
import com.inet.theme.server.ThemeResource;

/**
 * Server plugin for openweathermap dashboard plugin.<br>
 * This instance is required to register the dashboard widget for openweathermap.org.
 */
@PluginInfo( //
id = "dashboard.openweathermap", //
dependencies = "dashboard", //
optionalDependencies = "theme", //
packages = "", //
group = "samples", // 
version = "26.4.216", //
icon = "com/inet/dashboard/openweathermap/dashboard_openweather_48.png", //
flags = "" //
)
public class DashboardOpenWeatherMapServerPlugin implements ServerPlugin {

    /**
     * Print output to the Dashboard logger.
     */
    @Nonnull
    public static final Logger       LOGGER = LogManager.getLogger( "Dashboard" );
    /**
     * Localization of messages
     */
    @Nonnull
    public static final I18nMessages MSG    = new I18nMessages( "com.inet.dashboard.openweathermap.structure.i18n.ConfigStructure", DashboardOpenWeatherMapServerPlugin.class );

    /**
     * {@inheritDoc}
     */
    @Override
    public void registerExtension( ServerPluginManager spm ) {
        // Register the own dashboard widget implementation
        spm.register( DashboardWidget.class, new OpenWeatherMapWidget() );
        // Register a javascript dashboard widget element
        JavaScriptModule.registerJavaScriptModule( spm, getClass(), "/com/inet/dashboard/openweathermap/dashboard-widget-openweathermap.js" );
        // add styles - uncompiled
        if( spm.isPluginLoaded( "theme" ) ) {
            spm.register( ThemeResource.class, new ThemeResource( 100, "remotegui", getClass().getResource( "openweathermapwidget.less" ) ) );
        }
        // add styles - precompiled
        final CombinedFile css = new CombinedFile( "text/css; charset=utf-8" );
        css.add( getClass(), "openweathermapwidget.css" );
        spm.register( CombinedFileDescription.class, new CombinedFileDescription( "remotegui", 100, "defaulttheme.css", css ) );
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void init( ServerPluginManager spm ) {
        // nothing
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void reset() {
        // nothing
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void restart() {
        // nothing
    }
}
