Package xtwm.plugins
Class PluginWidget
- java.lang.Object
-
- jexer.TWidget
-
- xtwm.plugins.PluginWidget
-
- All Implemented Interfaces:
java.lang.Comparable<TWidget>
- Direct Known Subclasses:
Calendar
,DesktopPager
,HtopPlugin
,QuickNotes
,ScreensaverPlugin
,SystemMonitor
public abstract class PluginWidget extends TWidget
A PluginWidget is a plugin that can be optionally be instantiated in a separate window and/or as part of a tiled panel.
-
-
Field Summary
Fields Modifier and Type Field Description protected XTWMApplication
app
The XTWMApplication using this plugin.protected boolean
loadOnStartup
If true, this plugin will load on startup.protected boolean
pluginEnabled
If true, this plugin will be enabled.
-
Constructor Summary
Constructors Modifier Constructor Description protected
PluginWidget(TWidget parent)
Constructor for subclasses.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
closeFromMenu()
Called when the user selects Terminal | Close from the menu.abstract java.lang.String
getApplicationCommand()
Get the command line to execute if this is an "Application" plugin.abstract java.lang.String
getMenuMnemonic()
Get the translated menu label for this plugin.protected java.lang.String
getOption(java.lang.String key)
Get an option value for this plugin.protected java.lang.String
getOption(java.lang.String key, java.lang.String defaultValue)
Get an option value for this plugin.abstract java.lang.String
getPluginDescription()
Get the translated full description for this plugin.abstract java.lang.String
getPluginName()
Get the translated short name for this plugin.TWidget
getPluginSettingsEditor(TWidget parent)
Get an interface for editing the plugin settings.abstract int
getPreferredHeight()
Get the desired height when rendering this plugin.abstract int
getPreferredWidth()
Get the desired width when rendering this plugin.TWindow
getWindow(XTWMApplication application)
Get the window that will be used for this plugin when isWindowed() is true.abstract java.lang.String
getWindowTitle()
Get the translated window title for this plugin.void
initialize(XTWMApplication app)
Initialize the plugin.abstract boolean
isApplication()
See if this is an "Application" plugin.boolean
isLoadOnStartup()
See if this plugin will load on startup.boolean
isOnAllDesktops()
Whether or not this plugin should be on all desktops when loaded as a widget at startup.boolean
isPluginEnabled()
See if this plugin is enabled.boolean
isResizable()
Check if widget should be in a resizable window.abstract boolean
isWidget()
See if this is a "Widget" plugin.protected boolean
isWindowed()
Check if this widget is in a window.protected java.io.File
makeDataFile(java.lang.String pathname)
Obtain a File relative to the plugin data directory.void
onMenu(TMenuEvent event)
Process menu events.void
setLoadOnStartup(boolean loadOnStartup)
Set plugin load on startup.protected void
setOption(java.lang.String key, java.lang.String value)
Set an option value for this plugin.void
setPluginEnabled(boolean pluginEnabled)
Set plugin enabled.-
Methods inherited from class jexer.TWidget
activate, activate, activate, activateAll, addButton, addCalendar, addCheckBox, addCheckBox, addComboBox, addDirectoryList, addDirectoryList, addDirectoryList, addDirectoryList, addEditor, addField, addField, addField, addField, addImage, addImage, addLabel, addLabel, addLabel, addLabel, addLabel, addLabel, addList, addList, addList, addList, addPanel, addPasswordField, addPasswordField, addPasswordField, addProgressBar, addRadioGroup, addRadioGroup, addSpinner, addSplitPane, addTable, addTable, addText, addText, addTreeViewWidget, addTreeViewWidget, close, compareTo, doRepaint, draw, drawBox, drawBox, drawBoxShadow, drawChildren, fileOpenBox, fileOpenBox, fileOpenBox, fileOpenBox, fileSaveBox, getAbsoluteX, getAbsoluteY, getActiveChild, getApplication, getAttrXY, getChildren, getClipboard, getCursorAbsoluteX, getCursorAbsoluteY, getCursorX, getCursorY, getHeight, getLayoutManager, getParent, getScreen, getTheme, getWidth, getWindow, getX, getY, handleEvent, hasChild, hLineXY, inputBox, inputBox, inputBox, isAbsoluteActive, isActive, isCursorVisible, isDrawable, isEchoKeystrokes, isEnabled, isVisible, messageBox, messageBox, mouseWouldHit, onCommand, onIdle, onKeypress, onMouseDoubleClick, onMouseDown, onMouseMotion, onMouseUp, onResize, putAll, putAttrXY, putAttrXY, putCharXY, putCharXY, putCharXY, putStringXY, putStringXY, remove, remove, remove, remove, removeAll, resetTabOrder, setActive, setCursorVisible, setCursorX, setCursorY, setDimensions, setEchoKeystrokes, setEchoKeystrokes, setEnabled, setHeight, setLayoutManager, setParent, setupForTWindow, setVisible, setWidth, setWindow, setX, setY, splitHorizontal, splitVertical, switchWidget, toPrettyString, toPrettyString, toString, vLineXY
-
-
-
-
Field Detail
-
app
protected XTWMApplication app
The XTWMApplication using this plugin.
-
pluginEnabled
protected boolean pluginEnabled
If true, this plugin will be enabled.
-
loadOnStartup
protected boolean loadOnStartup
If true, this plugin will load on startup.
-
-
Constructor Detail
-
PluginWidget
protected PluginWidget(TWidget parent)
Constructor for subclasses.- Parameters:
parent
- parent widget
-
-
Method Detail
-
onMenu
public void onMenu(TMenuEvent event)
Process menu events.
-
getMenuMnemonic
public abstract java.lang.String getMenuMnemonic()
Get the translated menu label for this plugin.- Returns:
- a mnemonic string that will be populated in the menu
-
getPluginName
public abstract java.lang.String getPluginName()
Get the translated short name for this plugin.- Returns:
- a short name, e.g. "Calendar"
-
getPluginDescription
public abstract java.lang.String getPluginDescription()
Get the translated full description for this plugin.- Returns:
- a short name, e.g. "A simple calendar."
-
isApplication
public abstract boolean isApplication()
See if this is an "Application" plugin.- Returns:
- true if this plugin should be listed the Application | Programs menu
-
getApplicationCommand
public abstract java.lang.String getApplicationCommand()
Get the command line to execute if this is an "Application" plugin.- Returns:
- a command line
-
isWidget
public abstract boolean isWidget()
See if this is a "Widget" plugin.- Returns:
- true if this plugin should be available in the Application | Widgets meny and the Panel | "Switch to" dialog
-
getWindowTitle
public abstract java.lang.String getWindowTitle()
Get the translated window title for this plugin.- Returns:
- the title for the window when this widget is opened in the Application | Widgets menu, or null if this widget should have no title for its window.
-
isPluginEnabled
public boolean isPluginEnabled()
See if this plugin is enabled.- Returns:
- true if this plugin should be enabled
-
setPluginEnabled
public void setPluginEnabled(boolean pluginEnabled)
Set plugin enabled.- Parameters:
pluginEnabled
- if true, this plugin will be enabled
-
isLoadOnStartup
public boolean isLoadOnStartup()
See if this plugin will load on startup.- Returns:
- true if this plugin will load on startup
-
setLoadOnStartup
public void setLoadOnStartup(boolean loadOnStartup)
Set plugin load on startup.- Parameters:
loadOnStartup
- if true, this plugin will load on startup
-
isOnAllDesktops
public boolean isOnAllDesktops()
Whether or not this plugin should be on all desktops when loaded as a widget at startup.- Returns:
- true if this plugin should be on all desktops
-
initialize
public void initialize(XTWMApplication app)
Initialize the plugin. Since plugins are required to have a no-argument constructor, this method is called to provide a hook for the plugin to perform initialization. Subclasses that override initialize should call super.initialize() to set the XTWMApplication reference.- Parameters:
app
- the application that will be using this plugin
-
getPluginSettingsEditor
public TWidget getPluginSettingsEditor(TWidget parent)
Get an interface for editing the plugin settings.- Parameters:
parent
- parent widget- Returns:
- a widget that has settings
-
getPreferredWidth
public abstract int getPreferredWidth()
Get the desired width when rendering this plugin.- Returns:
- the width
-
getPreferredHeight
public abstract int getPreferredHeight()
Get the desired height when rendering this plugin.- Returns:
- the height
-
isResizable
public boolean isResizable()
Check if widget should be in a resizable window.- Returns:
- true if the widget should be resizable when in a window
-
getWindow
public TWindow getWindow(XTWMApplication application)
Get the window that will be used for this plugin when isWindowed() is true. The plugin will be reparented inside this window.- Parameters:
application
- the application- Returns:
- the window
-
isWindowed
protected boolean isWindowed()
Check if this widget is in a window.- Returns:
- true if the widget is in a window
-
getOption
protected java.lang.String getOption(java.lang.String key)
Get an option value for this plugin.- Parameters:
key
- name of the option- Returns:
- the option value, or null if it is undefined
-
getOption
protected java.lang.String getOption(java.lang.String key, java.lang.String defaultValue)
Get an option value for this plugin.- Parameters:
key
- name of the optiondefaultValue
- the value to return if the option is not defined- Returns:
- the option value, or defaultValue
-
setOption
protected void setOption(java.lang.String key, java.lang.String value)
Set an option value for this plugin.- Parameters:
key
- name of the optionvalue
- the new the option value
-
makeDataFile
protected java.io.File makeDataFile(java.lang.String pathname)
Obtain a File relative to the plugin data directory. Note that there is a single plugin data directory for all plugins.- Parameters:
pathname
- a pathname string- Returns:
- a File instance
-
closeFromMenu
public void closeFromMenu()
Called when the user selects Terminal | Close from the menu. The default implementation behaves like a TiledTerminal close.
-
-