plugins.wlx
Class SwingWLXPlugin

java.lang.Object
  extended by plugins.wlx.WLXPluginAdapter
      extended by plugins.wlx.SwingWLXPlugin
All Implemented Interfaces:
WLXPluginInterface

public abstract class SwingWLXPlugin
extends WLXPluginAdapter

Author:
Ken This class makes it possible to embed Swing javax.swing.JFrame as lister plugin contents.

Field Summary
 
Fields inherited from interface plugins.wlx.WLXPluginInterface
LC_COPY, LC_NEWPARAMS, LC_SELECT_ALL, LC_SETPERCENT, LCP_ANSI, LCP_ASCII, LCP_CENTER, LCP_FITLARGERONLY, LCP_FITTOWINDOW, LCP_FORCESHOW, LCP_VARIABLE, LCP_WRAPTEXT, LCS_BACKWARDS, LCS_FINDFIRST, LCS_MATCHCASE, LCS_WHOLEWORDS, LISTPLUGIN_ERROR, LISTPLUGIN_OK
 
Constructor Summary
SwingWLXPlugin()
          Create a plugin with variable lister window size.
SwingWLXPlugin(boolean fixedSize)
          Create a plugin with fixed/variable lister window size.
 
Method Summary
abstract  javax.swing.JFrame createJFrame()
          Create a new JFrame window.
protected  int getHeight(javax.swing.JFrame frame)
          If the plugin was created with fixed lister window size.
protected  int getWidth(javax.swing.JFrame frame)
          If the plugin was created with fixed lister window size.
 void listCloseWindow(int listWin)
          ListCloseWindow is called when a user closes lister, or loads a different file.
abstract  void listCloseWindow(javax.swing.JFrame frame)
          ListCloseWindow is called when a user closes lister, or loads a different file.
 int listLoad(int parentWin, java.lang.String input, int showFlags)
          ListLoad is called when a user opens lister with F3 or the Quick View Panel with Ctrl+Q, and when the definition string either doesn't exist, or its evaluation returns true.
abstract  void listLoad(javax.swing.JFrame frame, java.lang.String input, int showFlags)
          ListLoad is called when a user opens lister with F3 or the Quick View Panel with Ctrl+Q, and when the definition string either doesn't exist, or its evaluation returns true.
 
Methods inherited from class plugins.wlx.WLXPluginAdapter
getHWND, getHWND2, listDefaultGetParams, listGetDetectString, listGetPreviewBitmap, listLoadNext, listNotificationReceived, listPrint, listSearchDialog, listSearchText, listSendCommand, setSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwingWLXPlugin

public SwingWLXPlugin()
Create a plugin with variable lister window size.


SwingWLXPlugin

public SwingWLXPlugin(boolean fixedSize)
Create a plugin with fixed/variable lister window size.

Parameters:
fixedSize - true - use a fixed sized lister window according to getWidth() and getHeight(), otherwise variable size.
Method Detail

listLoad

public final int listLoad(int parentWin,
                          java.lang.String input,
                          int showFlags)
ListLoad is called when a user opens lister with F3 or the Quick View Panel with Ctrl+Q, and when the definition string either doesn't exist, or its evaluation returns true.
Please note that multiple Lister windows can be open at the same time! Therefore you cannot save settings in global variables. You can call RegisterClass with the parameter cbWndExtra to reserve extra space for your data, which you can then access via GetWindowLong(). Or use an internal list, and store the list parameter via SetWindowLong(hwnd,GWL_ID,...). Lister will subclass your window to catch some hotkeys like 'n' or 'p'.
When lister is activated, it will set the focus to your window. If your window contains child windows, then make sure that you set the focus to the correct child when your main window receives the focus!
If lcp_forceshow is defined, you may try to load the file even if the plugin wasn't made for it. Example: A plugin with line numbers may only show the file as such when the user explicitly chooses 'Image/Multimedia' from the menu. Lister plugins which only create thumbnail images do not need to implement this function.

Specified by:
listLoad in interface WLXPluginInterface
Specified by:
listLoad in class WLXPluginAdapter
Parameters:
parentWin - This is lister's window. Create your plugin window as a child of this window.
input - The name of the file which has to be loaded.
showFlags - A combination of the following flags:
  • lcp_wraptext Text: Word wrap mode is checked
  • lcp_fittowindow Images: Fit image to window is checked
  • lcp_ansi Ansi charset is checked
  • lcp_ascii Ascii(DOS) charset is checked
  • lcp_variable Variable width charset is checked
  • lcp_forceshow User chose 'Image/Multimedia' from the menu. See remarks.
You may ignore these parameters if they don't apply to your document type.
Returns:
Return a handle to your window if load succeeds, NULL otherwise. If NULL is returned, Lister will try the next plugin.

listCloseWindow

public final void listCloseWindow(int listWin)
ListCloseWindow is called when a user closes lister, or loads a different file. If ListCloseWindow isn't present, DestroyWindow() is called.
You can use this function to close open files, free buffers etc.

Specified by:
listCloseWindow in interface WLXPluginInterface
Overrides:
listCloseWindow in class WLXPluginAdapter
Parameters:
listWin - This is the window handle which needs to be destroyed.

createJFrame

public abstract javax.swing.JFrame createJFrame()
Create a new JFrame window. This method is called first. Do not create contents here, listLoad is the right place to create contents.
Important Note:
Set a title string for the JFrame, otherwise the frame cannot be embedded into the lister window.
e.g. return new JFrame("My Demo");

Returns:
the JFrame instance of the lister window contents.

listLoad

public abstract void listLoad(javax.swing.JFrame frame,
                              java.lang.String input,
                              int showFlags)
ListLoad is called when a user opens lister with F3 or the Quick View Panel with Ctrl+Q, and when the definition string either doesn't exist, or its evaluation returns true.
Please note that multiple Lister windows can be open at the same time! Therefore you cannot save settings in global variables. You can call RegisterClass with the parameter cbWndExtra to reserve extra space for your data, which you can then access via GetWindowLong(). Or use an internal list, and store the list parameter via SetWindowLong(hwnd,GWL_ID,...). Lister will subclass your window to catch some hotkeys like 'n' or 'p'.
When lister is activated, it will set the focus to your window. If your window contains child windows, then make sure that you set the focus to the correct child when your main window receives the focus!
If lcp_forceshow is defined, you may try to load the file even if the plugin wasn't made for it. Example: A plugin with line numbers may only show the file as such when the user explicitly chooses 'Image/Multimedia' from the menu. Lister plugins which only create thumbnail images do not need to implement this function.

Parameters:
frame - This is the JFrame instance created by createFrame().
input - The name of the file which has to be loaded.
showFlags - A combination of the following flags:
  • lcp_wraptext Text: Word wrap mode is checked
  • lcp_fittowindow Images: Fit image to window is checked
  • lcp_ansi Ansi charset is checked
  • lcp_ascii Ascii(DOS) charset is checked
  • lcp_variable Variable width charset is checked
  • lcp_forceshow User chose 'Image/Multimedia' from the menu. See remarks.
You may ignore these parameters if they don't apply to your document type.

listCloseWindow

public abstract void listCloseWindow(javax.swing.JFrame frame)
ListCloseWindow is called when a user closes lister, or loads a different file. If ListCloseWindow isn't present, DestroyWindow() is called.
You can use this function to close open files, free buffers etc.
Important Note:
Do not dispose the JFrame instance, it will be disposed elsewhere.

Parameters:
frame - This is the JFrame instance created by createFrame().

getHeight

protected int getHeight(javax.swing.JFrame frame)
If the plugin was created with fixed lister window size. Return the client area height here.

Parameters:
frame - This is the JFrame instance created by createFrame().
Returns:
the client area height

getWidth

protected int getWidth(javax.swing.JFrame frame)
If the plugin was created with fixed lister window size. Return the client area width here.

Parameters:
frame - This is the JFrame instance created by createFrame().
Returns:
the client area width