Plugins: ISharedPlugins;
Plugins: Prognoz.Platform.Interop.KeFore.ISharedPlugins;
The Plugins property returns an object used to work with plugins.
The returned object enables the user to set up general parameters of plugins. To set up parameters of the specific plugin, use the ISharedAdhocPlugin interface.
Executing the example requires that the repository contains:
The Resources object with the RESOURCE identifier.
Visualizer forms with the OBJ_ViewForm identifier. This form contains components that form plugin appearance, and the code that describes logic of component work in the plugin. Visualizer form must inherit from the AdhocUserViewForm class.
Master form with the OBJ_MasterForm identifier. This form contains components that form side panel tabs used to set up plugin, and the code that describes logic of applying settings to the plugin. Master form must inherit from the AdhocUserMasterForm class.
The file system must contain two icons: C:\Icon_small.ico sized 16x16 pixels and C:\Icon_large.ico sized 32x32 pixels. The Build folder contained in the folder with installed Foresight Analytics Platform web application must contain the PP.SamplePlugin.js script. This script must describe the plugin analog used in the web application.
Add links to the Drawing, Fore, Io, Metabase system assemblies.
Sub UserProc;
Var
mb: IMetabase;
plugins: ISharedPlugins;
cont: ISharedPluginsContainer;
adhoc_plugs: ISharedAdhocPlugins;
plugin: ISharedAdhocPlugin;
Res: IResourceObject;
ImgLst: IGxImageList;
Icon: IGxIcon;
Begin
// Get an object used to work with the current repository
mb := MetabaseClass.Active;
// Get an object used work with plugin container
cont := mb.SpecialObject(MetabaseSpecialObject.SharedParams).Edit As ISharedPluginsContainer;
// Get an object used to work with plugins
plugins := cont.Plugins;
// Set the Resources object for plugins
Res := mb.ItemById("RESOURCE").Edit As IResourceObject;
plugins.Resource := Res;
// Set small icons for plugins
ImgLst := New GxImageList.Create;
ImgLst.Height := 16;
ImgLst.Width := 16;
Icon := New GxIcon.CreateFromFile("C:\Icon_small.ico");
ImgLst.AddIcon(Icon);
plugins.SmallImages := ImgLst;
// Set large icons for plugins
ImgLst.Clear;
ImgLst.Height := 32;
ImgLst.Width := 32;
Icon := New GxIcon.CreateFromFile("C:\Icon_large.ico");
ImgLst.AddIcon(Icon);
plugins.LargeImages := ImgLst;
// Get collection of plugins of the Dashboards tool
adhoc_plugs := plugins.AdhocPlugins;
// Create a new plugin
plugin := plugins.AdhocPlugins.Add;
// Determine identifier in upper case matching with identifier in JS script of plugin
plugin.Id := "SAMPLEPLUGIN";
// Determine plugin name
plugin.Name := "Example of plugin";
plugin.IconIndex := 0;
// Set visualizer form and master form
plugin.ViewForm := mb.ItemById("OBJ_ViewForm");
plugin.MasterForm := mb.ItemById("OBJ_MasterForm");
// Determine relative path of plugin from web application root folder
plugin.WebUrl := "../plugins/PP.SamplePlugin.js";
// Save created plugin
(cont As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the plugin is connected to the Dashboards tool.
The requirements and result of the Fore.NET Example execution match with those in the Fore Example. Use Fore.NET analogs instead of Fore components.
Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.KeFore;
Imports Prognoz.Platform.Interop.ForeIO;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
plugins: ISharedPlugins;
cont: ISharedPluginsContainer;
adhoc_plugs: ISharedAdhocPlugins;
plugin: ISharedAdhocPlugin;
Res: IResourceObject;
ImgLst: GxImageList;
Icon: GxIcon;
Begin
// Get an object used to work with the current repository
mb := Params.Metabase;
// Get an object used work with plugin container
cont := mb.SpecialObject[MetabaseSpecialObject.msoSharedParams].Edit() As ISharedPluginsContainer;
// Get an object used to work with plugins
plugins := cont.Plugins;
// Set the Resources object for plugins
Res := mb.ItemById["RESOURCE"].Edit() As IResourceObject;
plugins.Resource := Res;
// Set small icons for plugins
ImgLst := New GxImageList.Create();
ImgLst.Height := 16;
ImgLst.Width := 16;
Icon := New GxIconClass.Create();
Icon.CreateFromFile("C:\Icon_small.ico");
ImgLst.AddIcon(Icon);
plugins.SmallImages := ImgLst;
// Set large icons for plugins
ImgLst.Clear();
ImgLst.Height := 32;
ImgLst.Width := 32;
Icon := New GxIconClass.Create();
Icon.CreateFromFile("C:\Icon_large.ico");
ImgLst.AddIcon(Icon);
plugins.LargeImages := ImgLst;
// Get collection of plugins of the Dashboards tool
adhoc_plugs := plugins.AdhocPlugins;
// Create a new plugin
plugin := plugins.AdhocPlugins.Add();
// Determine identifier in upper case matching with identifier in JS script of plugin
plugin.Id := "SAMPLEPLUGIN";
// Determine plugin name
plugin.Name := "Example of plugin";
plugin.IconIndex := 0;
// Set visualizer form and master form
plugin.ViewForm := mb.ItemById["OBJ_ViewForm"];
plugin.MasterForm := mb.ItemById["OBJ_MasterForm"];
// Determine relative path of plugin from web application root folder
plugin.WebUrl := "../plugins/PP.SamplePlugin.js";
// Save created plugin
(cont As IMetabaseObject).Save();
End Sub;
See also: