org.faceless.pdf2.viewer2
Class ViewerWidget

java.lang.Object
  extended by org.faceless.pdf2.viewer2.ViewerFeature
      extended by org.faceless.pdf2.viewer2.ViewerWidget
Direct Known Subclasses:
About, Close, Coordinates, FullScreenMode, Info, InvisiblySignDocument, ManageIdentities, NetworkSave, Open, PageFirst, PageLast, PageNext, PageNumber, PagePrevious, Print, Quit, RotateClockwise, Save, SearchField, ShowConsole, ToggleViewerWidget, TotalPages, XFA, ZoomIn, ZoomLevel, ZoomOut

public class ViewerWidget
extends ViewerFeature

A type of ViewerFeature that adds a "widget" to a PDFViewer. Widgets are typically buttons on the toolbar, menu items and so on.

This code is copyright the Big Faceless Organization. You're welcome to use, modify and distribute it in any form in your own projects, provided those projects continue to make use of the Big Faceless PDF library.

Since:
2.8
See Also:
ToggleViewerWidget

Constructor Summary
ViewerWidget(String name)
          Create a new Widget
 
Method Summary
 void action(ViewerEvent event)
          The method that's run when this feature is activated
protected  ActionListener createActionListener()
          Return an ActionListener that will be called when this Widget is activated.
 JComponent getComponent()
          Return the component representing this Widget.
 PDFViewer getViewer()
          Get the Viewer this Feature has been added to.
 void initialize(PDFViewer viewer)
          Called when the feature is first added to a viewer
 boolean isButtonEnabledByDefault()
          Return true if the button component for this widget is enabled by default.
 boolean isDocumentRequired()
          Return whether this widget should be inactive if no Document is selected.
 boolean isMenuEnabledByDefault()
          Return true if the menu component for this widget is enabled by default.
protected  void setButton(String toolbar, String icon, String tooltip)
          Set this feature to use a regular button in the toolbar.
protected  void setComponent(String toolbar, JComponent component)
          Set a custom component to be displayed in the ToolBar for this feature.
protected  void setDocumentRequired(boolean required)
          Set whether this feature requires a PDF to be loaded.
protected  void setMenu(String menu)
          Set a menu item for this feature.
protected  void setMenu(String menu, char mnemonic)
          Set a menu item for this feature, with an optional keyboard shortcut.
protected  void setToolBarEnabled(boolean enabled)
          Set whether the toolbar this feature is stored in is enabled by default
protected  void setToolBarEnabledAlways(boolean always)
          Set whether the toolbar this feature is stored in can be enabled or disabled
protected  void setToolBarFloatable(boolean floatable)
          Set whether the toolbar this feature is stored in can be floated
protected  void setToolBarFloating(boolean floating)
          Set whether this toolbar is always floating or not.
 String toString()
           
 
Methods inherited from class org.faceless.pdf2.viewer2.ViewerFeature
getAllEnabledFeatures, getAllFeatures, getCustomJavaScript, getFeatureProperty, getFeatureURLProperty, getName, isEnabledByDefault, setFeatureName, teardown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ViewerWidget

public ViewerWidget(String name)
Create a new Widget

Method Detail

toString

public String toString()
Overrides:
toString in class ViewerFeature

createActionListener

protected ActionListener createActionListener()
Return an ActionListener that will be called when this Widget is activated. Subclasses will typically not need to override this method except in special cases.

Returns:
ActionListener the ActionListener to be notified when an event fires
See Also:
Quit.createActionListener()

initialize

public void initialize(PDFViewer viewer)
Description copied from class: ViewerFeature
Called when the feature is first added to a viewer

Overrides:
initialize in class ViewerFeature

getViewer

public final PDFViewer getViewer()
Get the Viewer this Feature has been added to.


setDocumentRequired

protected final void setDocumentRequired(boolean required)
Set whether this feature requires a PDF to be loaded. Most features except for the "Open" widget do, so the default is "true"


isDocumentRequired

public boolean isDocumentRequired()
Return whether this widget should be inactive if no Document is selected.

Since:
2.11.7
See Also:
setDocumentRequired(boolean)

setComponent

protected final void setComponent(String toolbar,
                                  JComponent component)
Set a custom component to be displayed in the ToolBar for this feature.

Parameters:
toolbar - the name of the toolbar to put the component in
component - the component

getComponent

public JComponent getComponent()
Return the component representing this Widget.

Since:
2.8.5

isButtonEnabledByDefault

public boolean isButtonEnabledByDefault()
Return true if the button component for this widget is enabled by default. The default is "true"

Since:
2.10.3

isMenuEnabledByDefault

public boolean isMenuEnabledByDefault()
Return true if the menu component for this widget is enabled by default. The default is "true"

Since:
2.10.3

setButton

protected final void setButton(String toolbar,
                               String icon,
                               String tooltip)
Set this feature to use a regular button in the toolbar. The button will be created using the specified icon and with the specified tooltip.

Parameters:
toolbar - the name of the toolbar to put the component in
icon - the URL of the icon to use
tooltip - the tooltip to display for this button

setToolBarEnabled

protected final void setToolBarEnabled(boolean enabled)
Set whether the toolbar this feature is stored in is enabled by default


setToolBarEnabledAlways

protected final void setToolBarEnabledAlways(boolean always)
Set whether the toolbar this feature is stored in can be enabled or disabled

See Also:
ToolbarDisabling

setToolBarFloatable

protected final void setToolBarFloatable(boolean floatable)
Set whether the toolbar this feature is stored in can be floated


setToolBarFloating

protected final void setToolBarFloating(boolean floating)
Set whether this toolbar is always floating or not. Toolbars with this set are implemented as JInternalFrame objects, and are never attached to the regular tool bar

Since:
2.8.3

setMenu

protected final void setMenu(String menu)
Set a menu item for this feature. Activating the menu item is the same as pressing the button.

Parameters:
menu - the menu hierarchy to use, separated with tabs - eg "File\tOpen"

setMenu

protected final void setMenu(String menu,
                             char mnemonic)
Set a menu item for this feature, with an optional keyboard shortcut.

Parameters:
menu - the menu hierarchy to use, separated with tabs - eg "File\tOpen"
mnemonic - the keyboard shortcut to activate the menu - a lowercase or uppercase character to activate the menu.
Since:
2.10.2

action

public void action(ViewerEvent event)
The method that's run when this feature is activated



Copyright © 2001-2013 Big Faceless Organization