Class PluginServices

java.lang.Object
org.gvsig.andami.PluginServices

public class PluginServices extends Object
Provides services to Plugins. Each plugin has an associated PluginServices object, which provides specific services. Main of them: translations, logging, access to plugin's resources, background tasks, clipboard access and data persistence.
  • Constructor Details

    • PluginServices

      public PluginServices(PluginClassLoader loader)
      Creates a new PluginServices objetct.
      Parameters:
      loader - The Plugin's ClassLoader.
    • PluginServices

      public PluginServices(PluginClassLoader loader, String[] alternativeNames)
  • Method Details

    • getAlternativeNames

      public String[] getAlternativeNames()
    • getText

      public String getText(String key)
      Returns the message in the current's locale language corresponding to the provided translation key. The key-message pairs are obtained from the plugin's translation files (text_xx.properties files).
      Parameters:
      key - Translation key whose associated message is to be obtained
      Returns:
      The message associated with the provided key, in one of the current locale languages, or the key if the translation is not found.
    • getClassLoader

      public PluginClassLoader getClassLoader()
      Gets the plugin's classloader.
      Returns:
      Returns the loader.
    • getPluginName

      public String getPluginName()
      Gets the plugin's name
      Returns:
      The plugin's name
    • getPluginServices

      @Deprecated public static PluginServices getPluginServices(Object pluginClassInstance)
      Deprecated.
      Gets a reference to the PluginServices object associated with the plugin containing the provided class. Obtienen una referencia al PluginServices del plugin cuyo nombre se pasa como par�metro
      Parameters:
      pluginClassInstance - An instance of a class. This class is contained in a plugin, whose services are to be obtained
      Returns:
      The PluginServices object associated to the containing plugin
      Throws:
      RuntimeException - If the parameter was not loaded from a plugin
    • getPluginServices

      @Deprecated public static PluginServices getPluginServices(String pluginName)
      Deprecated.
      Gets a reference to the PluginServices object associated with the provided plugin.
      Parameters:
      pluginName - Plugin's name whose services are going to be used
      Returns:
      The PluginServices object associated with the provided plugin.
    • getMDIManager

      @Deprecated public static MDIManager getMDIManager()
      Deprecated.
      Gets the window manager (MDIManager).
      Returns:
      A reference to the window manager (MDIManager).
    • getMainFrame

      @Deprecated public static MainFrame getMainFrame()
      Deprecated.
      Gets the application's main frame.
      Returns:
      A reference to the application's main window
    • registerKeyStroke

      public static void registerKeyStroke(KeyStroke key, KeyEventDispatcher a)
    • unRegisterKeyStroke

      public static void unRegisterKeyStroke(KeyStroke key)
    • getExtension

      @Deprecated public static IExtension getExtension(Class extensionClass)
      Deprecated.
      Gets the instance of the extension whose class is provided.
      Parameters:
      extensionClass - Class of the extension whose instance is to be returned
      Returns:
      The instance of the extension, or null if the instance does not exist.Instancia de la extensi�n o null en caso de que no haya una
    • getDecoratedExtension

      @Deprecated public static ExtensionDecorator getDecoratedExtension(Class extensionClass)
      Deprecated.
      Gets a reference to the Extension Decorator which adds some extra options to the basic extension interface.
      Parameters:
      extensionClass - The class of the extension whose decorator is to be returned
      Returns:
      The ExtensionDecorator associated with the provided extension, or null if the extension does not exist.
    • getDecoratedExtensions

      @Deprecated public static ExtensionDecorator[] getDecoratedExtensions()
      Deprecated.
      Returns an array containing references to all the loaded extensions.
      Returns:
      ExtensionDecorator[] An array of ExtensionDecorators (each Decorator contains one extension).
    • getExtensions

      @Deprecated public static Iterator getExtensions()
      Deprecated.
      Gets an iterator with all the loaded Extensions.
      Returns:
      Iterator over the decorated extensions (each member of the iterator is an ExtensionDecorator, which in turn contains one IExtension object).
    • getText

      public static String getText(Object pluginObject, String key)
      Returns the message in the current's locale language corresponding to the provided translation key. The key-message pairs are obtained from the plugin's translation files (text_xx.properties files).
      Parameters:
      pluginObject - Any object which was loaded from a plugin
      key - Translation key whose associated message is to be obtained
      Returns:
      The message associated with the provided key, in one of the current locale languages, or the key if the translation is not found.
    • setPersistentXML

      public void setPersistentXML(org.gvsig.utils.XMLEntity entity)
      Sets the XML data which should be saved on disk for this plugin. This data can be retrieved on following sessions.
      Parameters:
      The - XMLEntity object containing the data to be persisted.
      See Also:
      • XMLEntity
    • getPersistentXML

      @Deprecated public org.gvsig.utils.XMLEntity getPersistentXML()
      Deprecated.
      Gets the XML data which was saved on previous sessions for this plugins.
      Returns:
      An XMLEntity object containing the persisted data
    • addPopupMenuListener

      public void addPopupMenuListener(String name, Component c, ActionListener listener)
      A�ade un listener a un popup menu registrado en el config.xml de alg�n plugin
      Parameters:
      name - Nombre del men� contextual
      c - Componente que desplegar� el men� cuando se haga click con el bot�n derecho
      listener - Listener que se ejecutar� cuando se seleccione cualquier entrada del men�
      Throws:
      RuntimeException - Si la interfaz no est� preparada todav�a. S�lo puede darse durante el arranque
    • getPluginDirectory

      public File getPluginDirectory()
      Gets the plugin's root directory.
      Returns:
      A File pointing to the plugin's root directory.
    • backgroundExecution

      public static Thread backgroundExecution(Runnable r)
      Runs a background task. The events produced on the main frame will be inhibited.
      Parameters:
      r - The task to run.
      Returns:
      The Thread on which the task is executed.
    • cancelableBackgroundExecution

      public static void cancelableBackgroundExecution(org.gvsig.utils.swing.threads.IMonitorableTask task)
      Runs a backbround task. This task may be monitored and canceled, and does not inhibit any event.
      Parameters:
      task - The task to run.
    • closeApplication

      public static void closeApplication()
      Closes the application. Cleanly exits from the application: terminates all the extensions, then exits.
    • getArguments

      @Deprecated public static String[] getArguments()
      Deprecated.
      Gets an array containing the application's startup arguments.

      Usually: appName plugins-directory [locale] [other args]
      Returns:
      the original arguments that Andami received. (app-name plugins-directory, locale, etc)
    • setArguments

      @Deprecated public static void setArguments(String[] arguments)
      Deprecated.
      Replaces the original Andami arguments with the provided arguments.
      Parameters:
      arguments - An array of String, each element of the array represents one argument.
    • getArgumentByName

      public static String getArgumentByName(String name)
      Returns the value of a command line named argument.

      The argument format is:
      -{argumentName}={argumentValue}

      example:
      ' -language=en '
      Returns:
      String The value of the argument
    • getLogger

      @Deprecated public static org.slf4j.Logger getLogger()
      Deprecated.
      Gets the logger. The logger is used to register important events (errors, etc), which are stored on a file which can be checked later.
      Returns:
      A Logger object.
      See Also:
      • object from the Log4j library.
    • getDlgPreferences

      @Deprecated public static DlgPreferences getDlgPreferences()
      Deprecated.
    • putInClipboard

      public static void putInClipboard(String data)
      Stores the provided text data on the clipboard.
      Parameters:
      data - An String containing the data to be stored on the clipboard.
    • getFromClipboard

      @Deprecated public static String getFromClipboard()
      Deprecated.
      Gets text data from the Clipboard, if available.
      Returns:
      An String containing the clipboard's data, or null if the data was not available.
    • getExclusiveUIExtension

      @Deprecated public static ExclusiveUIExtension getExclusiveUIExtension()
      Deprecated.
      Gets the ExclusiveUIExtension, an special extension which will take control over the UI and will decide which extensions may be enable/disabled or visible/hidden.
      Returns:
      If an ExclusiveUIExtension was set, return this extension. Otherwise, return null.
      See Also:
      • Launcher.initializeExclusiveUIExtension()
      • invalid reference
        org.gvsig.andami.plugins.IExtension#isEnabled(IExtension extension)
      • invalid reference
        org.gvsig.andami.plugins.IExtension#isVisible(IExtension extension)
    • setExclusiveUIExtension

      @Deprecated public static void setExclusiveUIExtension(ExclusiveUIExtension extension)
      Deprecated.
      Sets the ExclusiveUIExtension, an special extension which will take control over the UI and will decide which extensions may be enable/disabled or visible/hidden.

      The ExclusiveUIExtension is normally set by the following Andami startup argument:

      ExclusiveUIExtension=ExtensionName
      See Also:
      • Launcher.initializeExclusiveUIExtension()
      • invalid reference
        org.gvsig.andami.plugins.IExtension#isEnabled(IExtension extension)
      • invalid reference
        org.gvsig.andami.plugins.IExtension#isVisible(IExtension extension)
    • addLoaders

      public static void addLoaders(ArrayList classLoaders)
    • getIconThemeManager

      public static org.gvsig.tools.swing.icontheme.IconThemeManager getIconThemeManager()
    • getIconTheme

      public static org.gvsig.tools.swing.icontheme.IconTheme getIconTheme()
    • runningInDevelopment

      public static boolean runningInDevelopment()
      Try to detect if the application is running in a development environment.
      This look for .project and .classpath files in the starts path of the application.
      Returns:
      true if .project and .classpath are in the development path
    • getManager

      @Deprecated public PluginsManager getManager()
      Deprecated.
    • getPluginProperties

      public org.gvsig.tools.dynobject.DynObject getPluginProperties()
    • savePluginProperties

      public void savePluginProperties()
    • getPluginHomeFolder

      public File getPluginHomeFolder()
      Returns the folder where the plugin stores its resources. That folder will be usually a subfolder into the application folder in the user home folder.
      Returns:
      the folder where the plugin stores its resources
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • addDependencyWithPlugin

      public void addDependencyWithPlugin(PluginServices otherPlugin)