public abstract class Plugin extends Object implements Marker, ContextMenuIf, ProgramReceiveIf
To create a plugin do the following:
myplugin.MyPlugin
.MyPlugin.jar
.
plugin
directory of your TV-Browser
installation.
Modifier and Type | Field and Description |
---|---|
static String |
BIG_ICON
The name to use for the big icon (the 24x24 one for the toolbar) of the
button action.
|
static String |
DISABLED_ON_TASK_MENU
The name to use for disabling a menu part for
showing in ProgramInfo.
|
protected Frame |
parent
Deprecated.
Use method
getParentFrame() instead. |
static int |
SINGLE_CLICK_WAITING_TIME
The waiting time for single click performing.
|
Constructor and Description |
---|
Plugin() |
Modifier and Type | Method and Description |
---|---|
boolean |
canReceivePrograms()
Deprecated.
Since 2.5 Use
canReceiveProgramsWithTarget() instead. |
boolean |
canReceiveProgramsWithTarget()
Gets whether the ProgramReceiveIf supports receiving programs from other plugins with a special target.
|
boolean |
canUseProgramTree()
Signal whether this plugin participates in the plugin tree view or not.
|
protected ImageIcon |
createImageIcon(String fileName)
Helper method that loads an ImageIcon from the plugin jar file and returns
it.
|
ImageIcon |
createImageIcon(String category,
String icon,
int size)
Helper method that Loads an ImageIcon from the IconTheme
|
ImageIcon |
createImageIcon(ThemeIcon icon)
Helper method that Loads an ImageIcon from the IconTheme
|
protected ImageIcon |
createImageIconForFileName(String fileName)
Helper method that loads an ImageIcon from the file system and returns
it.
|
void |
execute()
Deprecated.
Since 1.1. Use
getButtonAction() instead. |
void |
execute(Program program)
Deprecated.
Since 1.1. Use
getContextMenuActions(Program) instead. |
void |
execute(Program[] programArr)
Deprecated.
Since 1.1. Use
receivePrograms(Program[]) instead. |
PluginsProgramFilter[] |
getAvailableFilter()
Returns the available program filters that the plugin supports.
|
Class<? extends PluginsFilterComponent>[] |
getAvailableFilterComponentClasses()
Returns the available plugins filter component classes.
|
ActionMenu |
getButtonAction()
Gets the action to use for the main menu and the toolbar.
|
protected String |
getButtonIconName()
Deprecated.
Since 1.1. Use
getButtonAction() instead. |
protected String |
getButtonText()
Deprecated.
Since 1.1. Use
getButtonAction() instead. |
ActionMenu |
getContextMenuActions(Program program)
Gets the actions for the context menu of a program.
|
String |
getContextMenuItemText()
Deprecated.
Since 1.1. Use
getContextMenuActions(Program) instead. |
String |
getId()
Gets the ID of this plugin.
|
PluginInfo |
getInfo()
Gets the meta information about the plugin.
|
protected JarFile |
getJarFile()
Gets the jar file of this plugin.
|
Icon |
getMarkIcon()
Gets the icon used for marking programs in the program table.
|
ThemeIcon |
getMarkIconFromTheme()
This gets the ThemeIcon containg your mark icon.
|
protected String |
getMarkIconName()
Gets the name of the file, containing your mark icon (in the jar-File).
|
Icon[] |
getMarkIcons(Program p)
Gets the icons used for marking programs in the program table.
|
Icon[] |
getMarkIconsForProgram(Program p)
This gets the mark icons for a Program.
|
int |
getMarkPriorityForProgram(Program p)
Gets the mark priority for the given program that this Plugin uses.
|
protected Frame |
getParentFrame()
Gets the parent frame.
|
static PluginManager |
getPluginManager()
Use this method to call methods of the plugin manager.
|
protected Program |
getProgramFromContextMenuActionEvent(ActionEvent evt)
Gets the Program from the ActionEvent that was passed to a context menu
action
NOTE: At the moment the Program is passed as ActionEvent source.
|
ProgramReceiveTarget[] |
getProgramReceiveTargets()
Returns an array of receive target or
null if there is no target |
Icon[] |
getProgramTableIcons(Program program)
Gets the icons this Plugin provides for the given program.
|
String |
getProgramTableIconText()
Gets the description text for the program table icons provided by this
Plugin.
|
ProgramRatingIf[] |
getRatingInterfaces()
If this plugin can rate programs, this interface makes it possible to offer this ratings
to other plugins.
|
PluginTreeNode |
getRootNode()
Gets the root node of the plugin for the plugin tree.
|
SettingsTab |
getSettingsTab()
Gets the SettingsTab object, which is added to the settings-window.
|
static Version |
getVersion()
Gets the version of this plugin.
|
void |
handleTvBrowserStartFinished()
This method is called when the TV-Browser start is finished.
|
void |
handleTvDataAdded(ChannelDayProgram newProg)
This method is automatically called, when TV data was added.
|
void |
handleTvDataAdded(MutableChannelDayProgram newProg)
This method is automatically called, when TV data was added.
|
void |
handleTvDataChanged()
Deprecated.
Since 1.1. Use
handleTvDataUpdateFinished() instead. |
void |
handleTvDataChanged(ChannelDayProgram newProg)
Deprecated.
Since 0.9.7.2. Use
handleTvDataAdded(ChannelDayProgram) instead. |
void |
handleTvDataDeleted(ChannelDayProgram oldProg)
This method is automatically called, when TV data was deleted.
|
void |
handleTvDataTouched(ChannelDayProgram removedDayProgram,
ChannelDayProgram addedDayProgram)
This method is automatically called, when TV data was touched (that means something was done with it).
|
void |
handleTvDataUpdateFinished()
This method is automatically called, when the TV data update is finished.
|
boolean |
isAllowedToDeleteProgramFilter(PluginsProgramFilter programFilter)
Is used to track if a program filter be deleted.
|
void |
layoutWindow(String windowId,
Window window)
Sets the window position and size for the given window from remembered values for that id.
|
void |
layoutWindow(String windowId,
Window window,
Dimension defaultSize)
Sets the window position and size for the given window from remembered values for that id.
|
void |
loadSettings(Properties settings)
Called by the host-application during start-up.
|
void |
onActivation()
This method is automatically called immediatly before the plugin gets
activated.
|
void |
onDeactivation()
This method is automatically called immediatly after deactivating
the plugin.
|
void |
readData(ObjectInputStream in)
Called by the host-application during start-up.
|
void |
receivePrograms(Program[] programArr)
Deprecated.
Since 2.5 Use
receivePrograms(Program[],ProgramReceiveTarget) instead. |
boolean |
receivePrograms(Program[] programArr,
ProgramReceiveTarget receiveTarget)
Receives a list of programs from another plugin with a target.
|
boolean |
receiveValues(String[] values,
ProgramReceiveTarget receiveTarget)
Receives a list of Strings from another plugin with a target.
|
protected boolean |
saveMe()
Says the plugin proxy manager to store the settings and data of this plugin.
|
void |
setJarFile(File jarFile)
Called by the host-application to provide the jar file.
|
void |
setParent(Frame parent)
Called by the host-application to provide the parent frame.
|
static void |
setPluginManager(PluginManager manager)
Called by the host-application to provide access to the plugin manager.
|
void |
storeRootNode()
Saves the entries under the root node in a file.
|
Properties |
storeSettings()
Called by the host-application during shut-down.
|
boolean |
supportMultipleProgramExecution()
Deprecated.
Since 1.1. Use
canReceivePrograms() instead. |
String |
toString() |
void |
writeData(ObjectOutputStream out)
Counterpart to loadData.
|
public static final String BIG_ICON
getButtonAction()
,
Constant Field Valuespublic static final String DISABLED_ON_TASK_MENU
public static final int SINGLE_CLICK_WAITING_TIME
protected Frame parent
getParentFrame()
instead.Some old plugin may still directly access it.
public static final void setPluginManager(PluginManager manager)
manager
- The plugin manager the plugins should use.public static final PluginManager getPluginManager()
The plugin manager is your connection to TV-Browser. Every communication between TV-Browser and the plugin is either initiated by TV-Browser or made by using the plugin manager.
public final void setJarFile(File jarFile) throws TvBrowserException
jarFile
- The jar file of this plugin.TvBrowserException
- If the given file is no jar file.protected final JarFile getJarFile()
public final String getId()
getId
in interface ContextMenuIf
getId
in interface Marker
getId
in interface ProgramReceiveIf
public final void setParent(Frame parent)
parent
- The parent frame.protected final Frame getParentFrame()
The parent frame may be used for showing dialogs.
protected final ImageIcon createImageIcon(String fileName)
fileName
- The name of the icon file.protected final ImageIcon createImageIconForFileName(String fileName)
fileName
- The name of the icon file.public final ImageIcon createImageIcon(String category, String icon, int size)
category
- Category the Icon resists inicon
- Icon to load (without extension)size
- Size of the Iconpublic final ImageIcon createImageIcon(ThemeIcon icon)
icon
- Icon to loadpublic void readData(ObjectInputStream in) throws IOException, ClassNotFoundException
Override this method to load any objects from the file system.
in
- The stream to read the objects from.IOException
- If reading failed.ClassNotFoundException
- If an object could not be casted correctly.writeData(ObjectOutputStream)
public void writeData(ObjectOutputStream out) throws IOException
Override this method to store any objects to the file system. ATTENTION: Don't use any logger, thread or access to Frames in this method.
out
- The stream to write the objects toIOException
- If writing failed.readData(ObjectInputStream)
public void loadSettings(Properties settings)
Override this method to load your plugins settings from the file system.
settings
- The settings for this plugin (May be empty).public Properties storeSettings()
Override this method to store your plugins settings to the file system. ATTENTION: Don't use any logger, thread or access to Frames in this method.
null
if this plugin
does not need to save any settings.public static Version getVersion()
Override this to provide a check of the plugin for the version to load from main plugins dir or the user plugins dir. The plugin with the highest version will be loaded.
public PluginInfo getInfo()
Override this method to provide information about your plugin.
public boolean canReceivePrograms()
canReceiveProgramsWithTarget()
instead.
Override this method and return true
, if your plugin is able
to receive programs from other plugins.
canReceivePrograms
in interface ProgramReceiveIf
receivePrograms(Program[])
public void receivePrograms(Program[] programArr)
receivePrograms(Program[],ProgramReceiveTarget)
instead.Override this method to receive programs from other plugins.
receivePrograms
in interface ProgramReceiveIf
programArr
- The programs passed from the other plugin.canReceivePrograms()
public ActionMenu getContextMenuActions(Program program)
Override this method to provide context menu items for programs (e.g. in
the program table). If your plugin shows a context menu only for some
programs, but not for all, then you should explicitly return a non-null
menu for the example program. Otherwise your context menu will not be shown
in the settings dialog for the context menu order.
The following action values will be used:
Action.NAME
: The text for the context menu item.Action.SMALL_ICON
: The icon for the context menu item.
Should be 16x16.getContextMenuActions
in interface ContextMenuIf
program
- The program the context menu will be shown for.null
if the plugin does not provide this feature.getProgramFromContextMenuActionEvent(ActionEvent)
protected final Program getProgramFromContextMenuActionEvent(ActionEvent evt)
NOTE: At the moment the Program is passed as ActionEvent source. Please use this method to get the program and not directly the ActionEvent source. Because in future versions of TV-Browser the Program may be passed in another way!!
evt
- The ActionEvent to get the Program from.getContextMenuActions(Program)
public ActionMenu getButtonAction()
Override this method to provide a menu item in the main menu and a toolbar button.
The following action values will be used:
Action.NAME
: The text for the main menu item and the
toolbar button.Action.SHORT_DESCRIPTION
: The description for the button
action. Used as tooltip and for the status bar.Action.SMALL_ICON
: The icon for the main menu item. Should
be 16x16.BIG_ICON
: The icon for the toolbar button. Should be
24x24.null
if the plugin does not provide this feature.public String getProgramTableIconText()
Override this method if your plugin provides icons for the program table (shown below the start time). The returned String will be shown in settings dialog (german: Aussehen->Sendungsanzeige->Plugin-Icons).
null
if the plugin does not provide this feature.getProgramTableIcons(Program)
public Icon[] getProgramTableIcons(Program program)
Override this method to return the icons for the program table (shown below the start time).
This method is only called, if the option to show program table icons for this plugin is set in the options.
program
- The programs to get the icons for.null
if the plugin
does not provide this feature.getProgramTableIconText()
public SettingsTab getSettingsTab()
Override this method to provide a settings tab. The settings tab will be shown in the settings dialog in the plugin section.
null
if the plugin does not
provide this feature.public final Icon getMarkIcon()
getMarkIcon
in interface Marker
getMarkIconName()
public final Icon[] getMarkIcons(Program p)
getMarkIcons
in interface Marker
public Icon[] getMarkIconsForProgram(Program p)
p
- The Program to get the icons for.public ThemeIcon getMarkIconFromTheme()
PluginManager.getIconFromTheme(Plugin, String, String, int)
protected String getMarkIconName()
This icon is used for marking programs in the program table.
Override this method if your plugin is able to mark programs
As an alternative you can use an Icon from the Icon-Theme using getMarkIconFromTheme()
null
if the plugin does not provide this feature.getMarkIcon()
,
Program.mark(Plugin)
,
Program.unmark(Plugin)
public void handleTvDataUpdateFinished()
Override this method to react on this event. If you want to read data from the internet use this method to track if a connection was established. ATTENTION: If you do so take care of the TV-Browser start, at the start this method mustn't use an internet connection. Use the method handleTvBrowserStartFinished() to track if the TV-Browser start was finished before allowing access to the internet in this method.
public void handleTvDataAdded(MutableChannelDayProgram newProg)
The TV data can be modified by the plugin!
Override this method if you want to change/add data.
Don't do other things than changing/adding data,
use handleTvDataAdded(ChannelDayProgram)
istead.
newProg
- The new ChannelDayProgram.handleTvDataDeleted(ChannelDayProgram)
,
handleTvDataChanged()
public void handleTvDataAdded(ChannelDayProgram newProg)
The TV data cannot be changed in here because the saving of the data was allready done.
So use this method if you want to mark or do something else
than changing with the program. If you want to change/add data
use handleTvDataAdded(MutableChannelDayProgram)
instead.
newProg
- The new ChannelDayProgram.handleTvDataDeleted(ChannelDayProgram)
,
handleTvDataChanged()
public void handleTvDataDeleted(ChannelDayProgram oldProg)
Override this method to react on this event.
oldProg
- The old ChannelDayProgram which was deleted.handleTvDataAdded(ChannelDayProgram)
,
handleTvDataChanged()
public void handleTvDataTouched(ChannelDayProgram removedDayProgram, ChannelDayProgram addedDayProgram)
removedDayProgram
- The old ChannelDayProgram.addedDayProgram
- The new ChannelDayProgram.handleTvDataAdded(ChannelDayProgram)
,
handleTvDataDeleted(ChannelDayProgram)
,
handleTvDataUpdateFinished()
public boolean supportMultipleProgramExecution()
canReceivePrograms()
instead.execute(Program[])
public void execute(Program[] programArr)
receivePrograms(Program[])
instead.programArr
- The programs to execute this plugins with.supportMultipleProgramExecution()
public String getContextMenuItemText()
getContextMenuActions(Program)
instead.This method is called by the host-application to show the plugin in the context menu.
Return null
if your plugin does not provide this feature.
null
if the
plugin does not provide this feature.public void execute(Program program)
getContextMenuActions(Program)
instead.program
- The program from whichs context menu the plugin was chosen.protected String getButtonText()
getButtonAction()
instead.This method is called by the host-application to show the plugin in the menu or in the toolbar.
null
if
the plugin does not provide this feature.protected String getButtonIconName()
getButtonAction()
instead.
This icon is used for the toolbar and the menu. Return null
if your plugin does not provide this feature.
public void execute()
getButtonAction()
instead.public void handleTvDataChanged()
handleTvDataUpdateFinished()
instead.Does by default nothing.
public void handleTvDataChanged(ChannelDayProgram newProg)
handleTvDataAdded(ChannelDayProgram)
instead.The TV data may be modified by the plugin!
Does by default nothing.
newProg
- The new ChannelDayProgram.public void onActivation()
public void onDeactivation()
public boolean canUseProgramTree()
getRootNode()
public void handleTvBrowserStartFinished()
public PluginTreeNode getRootNode()
canUseProgramTree()
public void storeRootNode()
public boolean canReceiveProgramsWithTarget()
canReceiveProgramsWithTarget
in interface ProgramReceiveIf
receivePrograms(Program[],ProgramReceiveTarget)
public boolean receivePrograms(Program[] programArr, ProgramReceiveTarget receiveTarget)
receivePrograms
in interface ProgramReceiveIf
programArr
- The programs passed from the other plugin.receiveTarget
- The receive target of the programs.canReceiveProgramsWithTarget()
public boolean receiveValues(String[] values, ProgramReceiveTarget receiveTarget)
receiveValues
in interface ProgramReceiveIf
values
- The value array passed from the other plugin.receiveTarget
- The receive target of the programs.True
if the value array was handled correct,
false otherwise.canReceiveProgramsWithTarget()
public ProgramReceiveTarget[] getProgramReceiveTargets()
null
if there is no targetgetProgramReceiveTargets
in interface ProgramReceiveIf
canReceiveProgramsWithTarget()
,
receivePrograms(Program[],ProgramReceiveTarget)
public PluginsProgramFilter[] getAvailableFilter()
null
if it supports no filter.public boolean isAllowedToDeleteProgramFilter(PluginsProgramFilter programFilter)
programFilter
- The program filter to delete.public Class<? extends PluginsFilterComponent>[] getAvailableFilterComponentClasses()
(Class extends PluginsFilterComponent>[]) new Class[] {MyFilterComponent1.class,MyFilterComponent2.class};
because the creation of a class array with generic type didn't work.null
if no plugins filter components are supported.public int getMarkPriorityForProgram(Program p)
The mark priority can be Program.NO_MARK_PRIORITY
, Program.MIN_MARK_PRIORITY
, Program.LOWER_MEDIUM_MARK_PRIORITY
,
Program.MEDIUM_MARK_PRIORITY
, Program.HIGHER_MEDIUM_MARK_PRIORITY
or
Program.MAX_MARK_PRIORITY
.
getMarkPriorityForProgram
in interface Marker
p
- The program to get the mark prioriy for.protected final boolean saveMe()
True
if the settings could be saved successfully.public final void layoutWindow(String windowId, Window window)
windowId
- The relative id of the window. The ID only needs to unique for this plugin.window
- The window to layout.public final void layoutWindow(String windowId, Window window, Dimension defaultSize)
windowId
- The relative id of the window. The ID only needs to unique for this plugin.window
- The window to layout.defaultSize
- The default size for the window.public ProgramRatingIf[] getRatingInterfaces()
PluginManager.getAllProgramRatingIfs()
The plugin can return more than one ratingif, e.g. average ratings, user rating ...TV-Browser 2.7.6, Copyright (C) 04-2003 Martin Oberhauser (martin@tvbrowser.org)