com.pepper.platform.program
Class AbstractPepperProgram

java.lang.Object
  extended by com.pepper.platform.program.AbstractPepperProgram
All Implemented Interfaces:
PackageInstance, PageChangeListener, ProgramChangeListener, SectionChangeListener, ActionListener, EventListener

public abstract class AbstractPepperProgram
extends Object
implements SectionChangeListener, ActionListener, PageChangeListener, ProgramChangeListener, PackageInstance

Abstract base class for all Pepper Programs. Programmers should subclass this class when writing new applications. AbstractPepperProgram has the following life cycle methods:

Initialization

AbstractPepperProgram(Integer pid) constructor is called by the framework followed by a call to the init(PepperProgramConfig config) method.

Destruction

AbstractPepperProgram.destroy() will be called when the program is to be stopped. This give the program an opportunity to clean up.


Field Summary
static int USE_DEFAULT_SECTION
          The default insertion index for a newly created section
 
Constructor Summary
AbstractPepperProgram(Integer pid)
          Constructor that gets called by the Pepper framework when a package is launched from the Keeper.
 
Method Summary
 void actionPerformed(ActionEvent ae)
          Default actionListener implementation.
 void addPage(Page page)
          Add and displays a Page in current Section, or simply displays a Page if it currently exists.
 void addPage(Section section, Page page, boolean show)
          Adds a Page to the specified Section.
 Page createNewPage(String pageId, String pageName, String pageType, Object initData)
          Creates a new Page object that is not attached to any Section
 Page createNewPage(String sectionId, String pageId, String pageName, String pageType, Object initData, boolean showWhenCreated)
          Creates and new Page object and permanently saves it to disk and in the specified Section.
 Section createNewSection(String sectionName, String initURL, boolean selectOnCreation, boolean transientSection)
          Create a new section and optionally load the initial url, select the section and make it transient
 SectionPage createNewSection(String parentId, String name, String type, int index, Object initData, boolean selectOnCreation, String initTabTitle)
          Create a new SectionPage and save it to disk.
 void createPage(Object data, List metadata, PageChangeListener listener)
          Default no-op implementation of PackageInstance interface
 WebSection createWebSection(String initTabTitle)
          Create new web section of type PageXML.WEB_SESSION_TYPE for this package and save it to disk.
 WebSection createWebSection(String initTabTitle, String initURL, boolean selectOnCreation)
          Create a web section and optionally load the initial url and select the section
 void destroy()
          This method is called when the program is about to be stopped.
 void enableAction(String command, boolean enable)
          Enable/disable an action registered via registerAction().
 boolean enableTabControls()
          Packages can override to return false if they don't want to enable tab controls (new tab, move, delete, rename).
 void errorOccurred(Exception e)
          Default implemenation of the PageChangeListener interface
 List findPages(String type, String expression)
          Default no-op implementation of PackageInstance interface
 Action getAction(String command)
          Return the specified action command.
 boolean getAllowSharing()
          If this is true, the package can be shared with other users.
 boolean getAllowSync()
          If this is true, the package can be synced with other users.
 String getBaseDir()
          Get the base directory where the package is running from.
 String getBaseDirPath()
          Return the base dir with the file separator char at the end
 WebBrowserContainer getBrowserContainer()
          Return the web browser container
 CommonActionMgr getCommonActionManager()
          Get the CommonAction manager.
static String getCommonBase()
          Returns the url string specifying the location of "common-resources.zip" If design.mode=true, this will return file://// else it will return jar:file:////design-common.zip!
 URL getCommonResource(String resourceName)
          Get a resource out of /common-resources.zip
 Page getCurrentPage()
          Return the currently displayed page.
 PageInfo getCurrentPageInfo()
          Return the PageInfo object for the currently displayed page.
 Section getCurrentSection()
          Get the currently displayed Section.
 String getCurrentSectionId()
          Get the current Section id.
 String getCurrentSectionName()
          Get the current Section name.
 String getDataDir()
          Get the file url for the data directory for the pagackage
 URL getDataResource(String resourceName)
          Returns a URL representing the specified resource contained in a package's data.zip file or in the data subdirectlry
 String getDesignBase()
          Gets the name of the design.zip url path.
 URL getDesignResource(String resourceName)
          Returns a URL representing the specified resource contained in a package's design.zip file or in the design subdirectlry
 GuiServicesProvider getGSP()
          Return the GuiServicesProvider object that provides UI services to packages running in the Keeper.
 MessageCatalog getMessageCatalog()
          Return the package's message catalog which is the union of package-specific catalog ( PackageStrings.properties ) and the platform catalog ( CommonStrings.properties ).
protected  Page getNextPage()
          Gets the next page contained in the current section
 String getPackageId()
          Gets the Unique Package Id for this package (ie Journal-12345).
 String getPackageTitle()
          Gets the title of the current package
 Page getPage(String pageId)
          Get a specific page in the current Section
 Page getPage(String pageId, String sectionId)
          Get a specific page in the specified Section
 String getPageBase()
          Get the base url used by templates.
 Properties getPageProperties()
          Get the Properties object that contains key/values that get set as XSL page attributes when a Pepper page is loaded
 Page getParentPage(Page page)
          Get the parent of a page.
 Integer getPID()
          Get the unique process ID for the package
protected  Page getPrefsPage()
          Get the package's preferences page
protected  Page getPreviousPage()
          Gets the previous Page contained in the current Section
 PepperProgramConfig getProgramConfig()
          Get the configuration associated with this program
 Object getProperty(String propertyName)
          Subclass should implement to expose certain properties to Javascript.
 Object getProperty(String propertyName, String param)
          Subclass should implement to expose certain properties to Javascript.
 Object getProperty(String propertyName, String[] params)
          Subclass should implement to expose certain properties to Javascript.
 Section getSection(String sectionId)
          Returns the Section specified by the given id.
 Section getSectionByName(String sectionName)
          Returns the Section specified by the given name.
 Section getSectionForPage(String pageId)
          Find the Section object for a given page
 SectionPage getSectionPage(String sectionId)
          Get the SectionPage with the specified id
 SectionList getSections()
          Get the sections that this program supports
 List getTypes()
          Default no-op implementation of PackageInstance interface
 void init(PepperProgramConfig config)
          This method is called by the program framework after a program is instantiated.
protected  void initPrefs()
          Initialize preferences for the package.
 boolean isLoading()
          Returns true if a page load is in progress
 boolean isLoadingWeb()
          Returns true if a web page is loading, false if a pepper page is loading
 boolean isPepperPageShowing()
          Returns true if a pepper page is showing, false if a web page is showing
 boolean isStopping()
          Returns true if program is in process of being destoryed/stopped
 boolean needsRefresh()
          Return true if the program has been flagged as needing to refresh the current page.
 void pageCreated(PageChangeEvent event)
          Default implemenation of the PageChangeListener interface.
 void pageDisplayed(PageChangeEvent event)
          Default implemenation of the PageChangeListener interface.
 void pageModified(PageChangeEvent event)
          Default implemenation of the PageChangeListener interface.
 void pageMoved(PageChangeEvent event)
          Default implemenation of the PageChangeListener interface.
 void pageRemoved(PageChangeEvent event)
          Default implemenation of the PageChangeListener interface.
 void pageReordered(PageChangeEvent event)
          Default implemenation of the PageChangeListener interface.
 void programChanged(ProgramChangeEvent event)
          Default no-op implementation of the ProgramChangeListener interface Called when the currently visible program changes.
 void refreshCurrentPage()
          Refresh the currently displayed page
 void refreshCurrentPage(boolean deepRefresh)
          Refresh the currently displayed page, and optionally clear any cached XSL Transforms stored for the page.
 void registerAction(String commandName, Action a)
          Register an Action with the specified name.
 void removeEmptySections(boolean webOnly)
          Called during destroy to clean up empty web sections or sections marked as deleteOnClose
 void removeEmptyWebSections()
          Called during destroy to clean up empty web sections
protected  void removePage(Section section, Page page, boolean showPrevious)
          Remove page from specified section, and optionally show the previous page in the section.
 void saveData()
          Save the current page's data using the auto-save framework.
 void savePage(Page page, boolean showPage)
          Save the Page.
 void savePage(Page page, Section section, boolean showPage)
          Save the Page.
 void savePrefs(boolean saveToDisk)
          Save common preferences to the preferences page.
 boolean search(FindConfig findConfig)
          Perform a search operation using the FindConfig object passed in.
 void sectionChanged(SectionEvent event)
          Default no-op implementation of the SectionChangeListener interface
 void sectionChanging(SectionEvent event)
          Default no-op implementation of the SectionChangeListener interface
 void setAllowSharing(boolean allowSharing)
          Allow or prevent sharing this package with other users.
 void setAllowSync(boolean allowSync)
          Allow or prevent syncing this package with other users.
 void setIsLoading(boolean loading, boolean isPepperPage)
          Set when a page load is in progress
 void setNeedsRefresh(boolean state)
          Mark this program as needing to refresh the current page when the program comes to the foreground.
 void setPackageActive()
          Make this package the active package by selecting it in the flag toolbar
 void showContentSectionPage()
          Show the content section page
 void showNextPage()
          This method is called when the "Next Page" button is selected.
 void showPage(PageInfo pageInfo, boolean saveCurrentPage)
          Show the Page in the Section specified by the PageInfo object passed in.
 void showPage(String pageId, String sectionId)
          Show the page in the specified section
 void showPage(URL pepperURL, boolean saveCurrentPage)
          Show page with specified pepper url and optionally save the current page
 void showPreviousPage()
          This method is called when the "Prev Page" button is selected.
 void showSection(Section section)
          Show the specified section.
 void showSection(String sectionId)
          Show the specified section.
 boolean supportsWebPages()
          Returns true if this package supports web pages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USE_DEFAULT_SECTION

public static final int USE_DEFAULT_SECTION
The default insertion index for a newly created section

Since:
3.2
See Also:
Constant Field Values
Constructor Detail

AbstractPepperProgram

public AbstractPepperProgram(Integer pid)
Constructor that gets called by the Pepper framework when a package is launched from the Keeper. This call is followed by a call to the init() method.

Parameters:
pid - an Integer specifying the process id.
Method Detail

init

public void init(PepperProgramConfig config)
          throws PepperProgramException
This method is called by the program framework after a program is instantiated. Subclasses should override to perform specific intialization logic, but must make sure to call super.init() first.

Parameters:
config - Program configuration info
Throws:
PepperProgramException - thrown on Exception

getProperty

public Object getProperty(String propertyName)
Subclass should implement to expose certain properties to Javascript. This gets exposed via the Bridge object

Parameters:
propertyName - a String value
Returns:
an Object value

getProperty

public Object getProperty(String propertyName,
                          String param)
Subclass should implement to expose certain properties to Javascript. This gets exposed via the Bridge object

Parameters:
propertyName - a String value
param - A String parameter to pass to the getProperty method
Returns:
an Object value

getProperty

public Object getProperty(String propertyName,
                          String[] params)
Subclass should implement to expose certain properties to Javascript. This gets exposed via the Bridge object

Parameters:
propertyName - a String value
params - A String[] of arguments to pass to the getProperty method
Returns:
an Object value

enableTabControls

public boolean enableTabControls()
Packages can override to return false if they don't want to enable tab controls (new tab, move, delete, rename). Tab controls are enabled by default

Returns:
true if tab controls should be enabled by the package, false otherwise.

initPrefs

protected void initPrefs()
Initialize preferences for the package. Subclass can override to perform package specific implementation.


savePrefs

public void savePrefs(boolean saveToDisk)
               throws Exception
Save common preferences to the preferences page. Subclass can override to save additional data.

Parameters:
saveToDisk - a boolean value
Throws:
Exception

getPrefsPage

protected Page getPrefsPage()
Get the package's preferences page

Returns:
a Page value

setIsLoading

public void setIsLoading(boolean loading,
                         boolean isPepperPage)
Set when a page load is in progress

Parameters:
loading - a boolean value
isPepperPage - true if a pepper page is loading, false if not

isLoading

public boolean isLoading()
Returns true if a page load is in progress

Returns:
a boolean value

isLoadingWeb

public boolean isLoadingWeb()
Returns true if a web page is loading, false if a pepper page is loading

Returns:
a boolean value

getGSP

public GuiServicesProvider getGSP()
Return the GuiServicesProvider object that provides UI services to packages running in the Keeper.

Returns:
a GuiServicesProvider instance
See Also:
GuiServicesProvider

getPageBase

public String getPageBase()
Get the base url used by templates. It will return either jar:file://// if not design mode or file:///
Returns:
a String value

getDesignBase

public String getDesignBase()
Gets the name of the design.zip url path. This will return either "getPageBase() + design.zip!" in non-design mode or "getPageBase()" in design mode

Returns:
a String value

getCommonBase

public static String getCommonBase()
Returns the url string specifying the location of "common-resources.zip" If design.mode=true, this will return file://// else it will return jar:file:////design-common.zip!

Returns:
a String value

getDataDir

public String getDataDir()
Get the file url for the data directory for the pagackage

Returns:
a String value representing a file url path to the data directory of the package. For example: file:///opt/pepper/WebBrowser-0/data

getDesignResource

public URL getDesignResource(String resourceName)
Returns a URL representing the specified resource contained in a package's design.zip file or in the design subdirectlry

Parameters:
resourceName - a String specifying the resource to to retrieve. For example getDesignResource("design/images/close.jpg")
Returns:
a URL instance.

getCommonResource

public URL getCommonResource(String resourceName)
Get a resource out of /common-resources.zip

Parameters:
resourceName - a String value
Returns:
an URL value

getDataResource

public URL getDataResource(String resourceName)
Returns a URL representing the specified resource contained in a package's data.zip file or in the data subdirectlry

Parameters:
resourceName - a String specifying the resource to to retrieve. For example getDataResource("data/foo");
Returns:
a URL instance.

getBaseDirPath

public String getBaseDirPath()
Return the base dir with the file separator char at the end

Returns:
a String value

getAction

public Action getAction(String command)
Return the specified action command. This will first look for a CommonAction then return package action if no common action found.

Parameters:
command - a String value
Returns:
an Action value

getCommonActionManager

public CommonActionMgr getCommonActionManager()
Get the CommonAction manager.

Returns:
a CommonActionMgr value

getBaseDir

public String getBaseDir()
Get the base directory where the package is running from. For example /opt/pepper/WebBrowser-0.

Returns:
a String value

getParentPage

public Page getParentPage(Page page)
Get the parent of a page.

Parameters:
page - The Page to check
Returns:
The Page which is a parent of the specified Page

saveData

public void saveData()
              throws Exception
Save the current page's data using the auto-save framework. This will cause PageChangeListener.pageModified(PageChangeEvent) event to be fired to listeners if the page had outstanding edits which would cause it to be modified.

Throws:
Exception

errorOccurred

public void errorOccurred(Exception e)
Default implemenation of the PageChangeListener interface

Specified by:
errorOccurred in interface PageChangeListener
Parameters:
e - an Exception value

pageCreated

public void pageCreated(PageChangeEvent event)
Default implemenation of the PageChangeListener interface. Program gets notified when a new page is created.

Specified by:
pageCreated in interface PageChangeListener
Parameters:
event - a PageChangeEvent value

pageModified

public void pageModified(PageChangeEvent event)
Default implemenation of the PageChangeListener interface. Program gets notified when an existing page is modified and saved via saveData() method

Specified by:
pageModified in interface PageChangeListener
Parameters:
event - a PageChangeEvent value
See Also:
AbstractPepperProgram.saveData()

pageRemoved

public void pageRemoved(PageChangeEvent event)
Default implemenation of the PageChangeListener interface. Program gets notified when an existing page is deleted.

Specified by:
pageRemoved in interface PageChangeListener
Parameters:
event - a PageChangeEvent value

pageMoved

public void pageMoved(PageChangeEvent event)
Default implemenation of the PageChangeListener interface. Program gets notified when an existing page is moved

Specified by:
pageMoved in interface PageChangeListener
Parameters:
event - a PageChangeEvent value

pageReordered

public void pageReordered(PageChangeEvent event)
Default implemenation of the PageChangeListener interface. Page reordered event.

Specified by:
pageReordered in interface PageChangeListener
Parameters:
event - a PageChangeEvent value

pageDisplayed

public void pageDisplayed(PageChangeEvent event)
Default implemenation of the PageChangeListener interface. Notification that a Page has been completely displayed by the Keeper. This event will be fired each time a page's content is fully loaded by the browser.

Specified by:
pageDisplayed in interface PageChangeListener
Parameters:
event - a PageChangeEvent value

getBrowserContainer

public WebBrowserContainer getBrowserContainer()
Return the web browser container

Returns:
a WebBrowserContainer value

isPepperPageShowing

public boolean isPepperPageShowing()
Returns true if a pepper page is showing, false if a web page is showing

Returns:
a boolean value

setPackageActive

public void setPackageActive()
Make this package the active package by selecting it in the flag toolbar


sectionChanged

public void sectionChanged(SectionEvent event)
Default no-op implementation of the SectionChangeListener interface

Specified by:
sectionChanged in interface SectionChangeListener
Parameters:
event - a SectionEvent value
See Also:
SectionChangeListener

sectionChanging

public void sectionChanging(SectionEvent event)
Default no-op implementation of the SectionChangeListener interface

Specified by:
sectionChanging in interface SectionChangeListener
Parameters:
event - a SectionEvent value
See Also:
SectionChangeListener

getSectionForPage

public Section getSectionForPage(String pageId)
Find the Section object for a given page

Parameters:
pageId - The pageId of the page to search for
Returns:
The Section object that contains the specified page

showPage

public void showPage(String pageId,
                     String sectionId)
Show the page in the specified section

Parameters:
pageId - the pageId of the Page to show
sectionId - the sectionId of the Section that contains the specified pageId

showPage

public void showPage(URL pepperURL,
                     boolean saveCurrentPage)
Show page with specified pepper url and optionally save the current page

Parameters:
pepperURL - an URL value
saveCurrentPage - true to first save the current page

showPage

public void showPage(PageInfo pageInfo,
                     boolean saveCurrentPage)
Show the Page in the Section specified by the PageInfo object passed in. The currently displayed page is optionally saved

Parameters:
pageInfo - a PageInfo value
saveCurrentPage - a boolean value

showNextPage

public void showNextPage()
This method is called when the "Next Page" button is selected. Default implementation is to show next page in Section (if it exists). Subclasses can override to implement different behavior.


showPreviousPage

public void showPreviousPage()
This method is called when the "Prev Page" button is selected. Default implementation is to show previous page in Section (if it exists). Subclasses can override to implement different behavior.


addPage

public void addPage(Page page)
Add and displays a Page in current Section, or simply displays a Page if it currently exists. Note - this method does not permanetly add the Page to the section but just updates the in memory data structure. To permanently add the page, use createNewPage() method.

Parameters:
page - The feature to be added to the Page attribute

addPage

public void addPage(Section section,
                    Page page,
                    boolean show)
Adds a Page to the specified Section. Note - this method does not permanetly add the Page to the section but just updates the in memory data structure. To permanently add the page, use createNewPage method.

Parameters:
section - The Section to contain the page
page - The Page to be added to the specified section
show - true to display the page after it's added, false to not show it

createNewPage

public Page createNewPage(String sectionId,
                          String pageId,
                          String pageName,
                          String pageType,
                          Object initData,
                          boolean showWhenCreated)
                   throws Exception
Creates and new Page object and permanently saves it to disk and in the specified Section. Optionally shows the page in the UI.

Parameters:
sectionId - a String specifying the id of the containing section.
pageId - a String containing the page id; also used as a relative path to the serialized page on disk.
pageName - a String containing the displayable name of the page.
pageType - a String containing the page type, if null, 'default' is assumed.
initData - an Object containing the values to be used by the page data initialization plugin to initialize the page's data. The default plugin assumes initData is a HashMap of XPath/Value pairs. type, if null, 'default' is assumed.
showWhenCreated - a boolean value that indicates that the page is displayed on creation.
Returns:
a new Page instance.
Throws:
Exception - if an error occurs.

createNewPage

public Page createNewPage(String pageId,
                          String pageName,
                          String pageType,
                          Object initData)
                   throws Exception
Creates a new Page object that is not attached to any Section

Parameters:
pageId - a String containing the page id; also used as a relative path to the serialized page on disk.
pageName - a String containing the displayable name of the page.
pageType - a String containing the page type, if null, 'default' is assumed.
initData - an Object containing the values to be used by the page data initialization plugin to initialize the page's data. The default plugin assumes initData is a HashMap of XPath/Value pairs. type, if null, 'default' is assumed.
Returns:
a new Page instance.
Throws:
Exception - if an error occurs.

createWebSection

public WebSection createWebSection(String initTabTitle)
Create new web section of type PageXML.WEB_SESSION_TYPE for this package and save it to disk. The section is not selected by default.

Parameters:
initTabTitle - the initial title of the tab. If null then the title will be set to WebXX where XX is the number of web tabs currently displayed in the package
Returns:
a WebSection value
See Also:
AbstractPepperProgram.createNewSection(String, String, String, int, Object, boolean, String)

createWebSection

public WebSection createWebSection(String initTabTitle,
                                   String initURL,
                                   boolean selectOnCreation)
Create a web section and optionally load the initial url and select the section

Parameters:
initTabTitle - Initial title of the tab
initURL - URL to load into the section
selectOnCreation - true to select the section
Returns:
a WebSection value
Since:
3.2

createNewSection

public Section createNewSection(String sectionName,
                                String initURL,
                                boolean selectOnCreation,
                                boolean transientSection)
Create a new section and optionally load the initial url, select the section and make it transient

Parameters:
sectionName - The name of the section
initURL - URL to load into the section
selectOnCreation - true to select the section
transientSection - If true, the tab will show the close button, will not be syncable, and will be automatically deleted when the package is closed.
Returns:
a Section value
Since:
3.2

createNewSection

public SectionPage createNewSection(String parentId,
                                    String name,
                                    String type,
                                    int index,
                                    Object initData,
                                    boolean selectOnCreation,
                                    String initTabTitle)
                             throws Exception
Create a new SectionPage and save it to disk. A tab will be added to the UI and optionally selected upon creation. The section page is created with the specified cache instructions and page data. The section is given an Id of the form:

data/Section_ + >System.currentTimeMillis()<

Parameters:
parentId - The section id of the new section's parent. If null, "data/package.xml" is used.
name - a String specifying the displayable name of the section ( eg. Personal ).
type - a String specifying the type of section to create; section types are defined in a package's page template file. type, if null, 'default' is assumed.
index - an int specifying the section index to insert the newly created section into. index if USE_DEFAULT_SECTION, page is inserted to the default new section location.
initData - an Object containing the values to be used by the page data initialization plugin to initialize the page's data. The default plugin assumes initData is a HashMap of XPath/Value pairs.
selectOnCreation - true to select that section after it's been created
initTabTitle - for web sections only, this value will be used as the tab title. If null or not a web section, the name passed in will be used as the tab title, as well as being set as the Section name.
Returns:
a new SectionPage instance. The Section object can be obtained by calling SectionPage.getSection().
Throws:
Exception - if an error occurs.

removePage

protected void removePage(Section section,
                          Page page,
                          boolean showPrevious)
Remove page from specified section, and optionally show the previous page in the section. Note - this method does not permanetly remove the Page from the section but just updates the in memory data structure. To permanently remove the page, use DeletePageAction

Parameters:
section - The section containing the page to be removed.
page - The page to be removed.
showPrevious - whether or not to show the previous page in the section

getCurrentSection

public Section getCurrentSection()
Get the currently displayed Section.

Returns:
a Section value

getCurrentSectionId

public String getCurrentSectionId()
Get the current Section id.

Returns:
a String containing the section's id.

getCurrentSectionName

public String getCurrentSectionName()
Get the current Section name.

Returns:
a String containing the section's name.

showContentSectionPage

public void showContentSectionPage()
Show the content section page


getSectionPage

public SectionPage getSectionPage(String sectionId)
Get the SectionPage with the specified id

Parameters:
sectionId - a String value
Returns:
a SectionPage value

getSection

public Section getSection(String sectionId)
Returns the Section specified by the given id.

Parameters:
sectionId - a String specifying the id of the the section to return.
Returns:
the Section instance for the given id.

getSectionByName

public Section getSectionByName(String sectionName)
Returns the Section specified by the given name. Note - if multiple sections exist with the same name, this method will only return the first in the list of sections.

Parameters:
sectionName - a String specifying the name of the the section to return.
Returns:
the Section instance for the given name.

showSection

public void showSection(String sectionId)
Show the specified section.

Parameters:
sectionId - a String containing the id of the desired section.

showSection

public void showSection(Section section)
Show the specified section.

Parameters:
section - the Section to display.

getCurrentPage

public Page getCurrentPage()
Return the currently displayed page.

Returns:
the current Page instance.

getCurrentPageInfo

public PageInfo getCurrentPageInfo()
Return the PageInfo object for the currently displayed page.

Returns:
a PageInfo value

getNextPage

protected Page getNextPage()
Gets the next page contained in the current section

Returns:
The nextPage value

getPreviousPage

protected Page getPreviousPage()
Gets the previous Page contained in the current Section

Returns:
The previousPage value

getPage

public Page getPage(String pageId)
Get a specific page in the current Section

Parameters:
pageId - an int value
Returns:
a Page value

getPage

public Page getPage(String pageId,
                    String sectionId)
Get a specific page in the specified Section

Parameters:
pageId - an int value
sectionId - an int value
Returns:
a Page value

savePage

public void savePage(Page page,
                     boolean showPage)
              throws Exception
Save the Page. This will cause cache rules to be run on the Page and it's parents so the change can be propogated up the hierarchy.

Parameters:
page - Page to be saved
showPage - a boolean value that indicates that the new page should be displayed.
Throws:
Exception - if an error occurs

savePage

public void savePage(Page page,
                     Section section,
                     boolean showPage)
              throws Exception
Save the Page. This will cause cache rules to be run on the Page and it's parents so the change can be propogated up the hierarchy.

Parameters:
page - Page to be saved
section - Section the page is in
showPage - a boolean value that indicates that the new page should be displayed.
Throws:
Exception - if an error occurs

needsRefresh

public boolean needsRefresh()
Return true if the program has been flagged as needing to refresh the current page. This bit is only set when the program is in the background; refreshCurrentPage() doesn't work there.

Returns:
true if the program should refresh the current page when it comes to the foreground.

setNeedsRefresh

public void setNeedsRefresh(boolean state)
Mark this program as needing to refresh the current page when the program comes to the foreground. Called if refreshCurrentPage() is invoked when the program isn't showing.

Parameters:
state - true if the program should be refreshed when it comes to the foreground.

refreshCurrentPage

public void refreshCurrentPage()
Refresh the currently displayed page


refreshCurrentPage

public void refreshCurrentPage(boolean deepRefresh)
Refresh the currently displayed page, and optionally clear any cached XSL Transforms stored for the page.

Parameters:
deepRefresh - true to refresh cache

getPageProperties

public Properties getPageProperties()
Get the Properties object that contains key/values that get set as XSL page attributes when a Pepper page is loaded

Returns:
The page properties obect

getPackageId

public String getPackageId()
Gets the Unique Package Id for this package (ie Journal-12345). This will be null until the init() method of the package is called so don't expect to use it in the constructor code.

Returns:
a String value

getPackageTitle

public String getPackageTitle()
Gets the title of the current package

Returns:
a String value

getPID

public Integer getPID()
Get the unique process ID for the package

Returns:
The pID value

programChanged

public void programChanged(ProgramChangeEvent event)
Default no-op implementation of the ProgramChangeListener interface Called when the currently visible program changes.

Specified by:
programChanged in interface ProgramChangeListener
Parameters:
event - the event.
See Also:
ProgramChangeListener

search

public boolean search(FindConfig findConfig)
Perform a search operation using the FindConfig object passed in.

Parameters:
findConfig - a FindConfig value
Returns:
true if the search string was found

actionPerformed

public void actionPerformed(ActionEvent ae)
Default actionListener implementation. Subclasses should override this method if they need to override built in action behavior.

Specified by:
actionPerformed in interface ActionListener
Parameters:
ae - ActionEvent to handle

getMessageCatalog

public MessageCatalog getMessageCatalog()
Return the package's message catalog which is the union of package-specific catalog ( PackageStrings.properties ) and the platform catalog ( CommonStrings.properties ).

Returns:
a MessageCatalog instance.

registerAction

public void registerAction(String commandName,
                           Action a)
Register an Action with the specified name. There are a set of common actions that are registered across all programs (see CommonActionMgr). Any actions registered here will be added to the program's action map in addition to the common actions. Registering an action by the same name as a common action will allow a program to override the behavior of the common action.

Parameters:
commandName - String used as the key for the action
a - The Action to register
See Also:
AbstractPepperProgram.getAction(String)

enableAction

public void enableAction(String command,
                         boolean enable)
Enable/disable an action registered via registerAction().

Parameters:
command - command name of action to enable/disable. See CommonActionMgr for a list of common action names
enable - true to enable the action, false to disable it
See Also:
AbstractPepperProgram.registerAction(String, Action)

isStopping

public boolean isStopping()
Returns true if program is in process of being destoryed/stopped

Returns:
a boolean value

destroy

public void destroy()
             throws Exception
This method is called when the program is about to be stopped. Any cleanup of finalization should be done in this method.

Throws:
Exception

removeEmptyWebSections

public void removeEmptyWebSections()
Called during destroy to clean up empty web sections


removeEmptySections

public void removeEmptySections(boolean webOnly)
Called during destroy to clean up empty web sections or sections marked as deleteOnClose

Since:
3.2

getProgramConfig

public PepperProgramConfig getProgramConfig()
Get the configuration associated with this program

Returns:
The PepperProgramConfig object

getSections

public SectionList getSections()
Get the sections that this program supports

Returns:
The sections value

supportsWebPages

public boolean supportsWebPages()
Returns true if this package supports web pages. This method will look at the package's section list and determine if there are any of type "webSession". Subclasses can override for specific behavior

Returns:
a boolean value

setAllowSharing

public void setAllowSharing(boolean allowSharing)
Allow or prevent sharing this package with other users. The default is to allow packages to be shared. To prevent a package from being shared, set this to false. As a side effect, updates the toolbar share button to the appropriate state.

Parameters:
allowSharing - true to allow the package to be shared with other users, false to prevent it from being shared.

getAllowSharing

public boolean getAllowSharing()
If this is true, the package can be shared with other users. If not, the package must not be shared with other users. The default is to allow packages to be shared.

Returns:
If true, this package can be shared with other users. If false, the package must not be shared with other users.

setAllowSync

public void setAllowSync(boolean allowSync)
Allow or prevent syncing this package with other users. The default is to allow packages to be synced. To prevent a package from being synced, set this to false. As a side effect, updates the toolbar sync button to the appropriate state.

Parameters:
allowSync - true to allow the package to be synced with other users, false to prevent it from being synced.

getAllowSync

public boolean getAllowSync()
If this is true, the package can be synced with other users. If not, the package must not be synced with other users. The default is to allow packages to be synced.

Returns:
If true, this package can be synced with other users. If false, the package must not be synced with other users.

getTypes

public List getTypes()
Default no-op implementation of PackageInstance interface

Specified by:
getTypes in interface PackageInstance
Returns:
list of page types as Strings
See Also:
PackageInstance

findPages

public List findPages(String type,
                      String expression)
Default no-op implementation of PackageInstance interface

Specified by:
findPages in interface PackageInstance
Parameters:
type - Type of page to search for. Must be one of the values returned by PackageInstance.getTypes().
expression - Expression to narrow down searches; format is program-specific.
Returns:
List of objects; type of object in the list is program-specific.
See Also:
PackageInstance

createPage

public void createPage(Object data,
                       List metadata,
                       PageChangeListener listener)
                throws Exception
Default no-op implementation of PackageInstance interface

Specified by:
createPage in interface PackageInstance
Parameters:
data - Data to create the page with.
metadata - NameValue pairs providing additional information about data, such as referrer URL.
listener - The listener that should be notified when the pageCreation finishes or an error occurs
Throws:
Exception
See Also:
PackageInstance


Copyright © 2006-2007 Pepper Computer, Inc. All Rights Reserved.