|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.pepper.platform.program.AbstractPepperProgram
public abstract class AbstractPepperProgram
Abstract base class for all Pepper Programs. Programmers should subclass this class when writing new applications. AbstractPepperProgram has the following life cycle methods:
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:/// |
URL |
getCommonResource(String resourceName)
Get a resource out of |
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 |
---|
public static final int USE_DEFAULT_SECTION
Constructor Detail |
---|
public AbstractPepperProgram(Integer pid)
pid
- an Integer
specifying the process id.Method Detail |
---|
public void init(PepperProgramConfig config) throws PepperProgramException
config
- Program configuration info
PepperProgramException
- thrown on Exceptionpublic Object getProperty(String propertyName)
propertyName
- a String
value
Object
valuepublic Object getProperty(String propertyName, String param)
propertyName
- a String
valueparam
- A String parameter to pass to the getProperty method
Object
valuepublic Object getProperty(String propertyName, String[] params)
propertyName
- a String
valueparams
- A String[] of arguments to pass to the getProperty method
Object
valuepublic boolean enableTabControls()
protected void initPrefs()
public void savePrefs(boolean saveToDisk) throws Exception
saveToDisk
- a boolean
value
Exception
protected Page getPrefsPage()
Page
valuepublic void setIsLoading(boolean loading, boolean isPepperPage)
loading
- a boolean
valueisPepperPage
- true if a pepper page is loading,
false if notpublic boolean isLoading()
boolean
valuepublic boolean isLoadingWeb()
boolean
valuepublic GuiServicesProvider getGSP()
GuiServicesProvider
public String getPageBase()
String
valuepublic String getDesignBase()
String
valuepublic static String getCommonBase()
String
valuepublic String getDataDir()
String
value representing a file url
path to the data directory of the package. For example:
file:///opt/pepper/WebBrowser-0/datapublic URL getDesignResource(String resourceName)
resourceName
- a String
specifying the resource to
to retrieve. For example getDesignResource("design/images/close.jpg")
URL
instance.public URL getCommonResource(String resourceName)
resourceName
- a String
value
URL
valuepublic URL getDataResource(String resourceName)
resourceName
- a String
specifying the resource to
to retrieve. For example getDataResource("data/foo");
URL
instance.public String getBaseDirPath()
String
valuepublic Action getAction(String command)
command
- a String
value
Action
valuepublic CommonActionMgr getCommonActionManager()
CommonActionMgr
valuepublic String getBaseDir()
String
valuepublic Page getParentPage(Page page)
page
- The Page to check
public void saveData() throws Exception
PageChangeListener.pageModified(PageChangeEvent)
event
to be fired to listeners if the page had outstanding edits which would
cause it to be modified.
Exception
public void errorOccurred(Exception e)
errorOccurred
in interface PageChangeListener
e
- an Exception
valuepublic void pageCreated(PageChangeEvent event)
pageCreated
in interface PageChangeListener
event
- a PageChangeEvent
valuepublic void pageModified(PageChangeEvent event)
pageModified
in interface PageChangeListener
event
- a PageChangeEvent
valueAbstractPepperProgram.saveData()
public void pageRemoved(PageChangeEvent event)
pageRemoved
in interface PageChangeListener
event
- a PageChangeEvent
valuepublic void pageMoved(PageChangeEvent event)
pageMoved
in interface PageChangeListener
event
- a PageChangeEvent
valuepublic void pageReordered(PageChangeEvent event)
pageReordered
in interface PageChangeListener
event
- a PageChangeEvent
valuepublic void pageDisplayed(PageChangeEvent event)
pageDisplayed
in interface PageChangeListener
event
- a PageChangeEvent
valuepublic WebBrowserContainer getBrowserContainer()
WebBrowserContainer
valuepublic boolean isPepperPageShowing()
boolean
valuepublic void setPackageActive()
public void sectionChanged(SectionEvent event)
sectionChanged
in interface SectionChangeListener
event
- a SectionEvent
valueSectionChangeListener
public void sectionChanging(SectionEvent event)
sectionChanging
in interface SectionChangeListener
event
- a SectionEvent
valueSectionChangeListener
public Section getSectionForPage(String pageId)
pageId
- The pageId of the page to search for
public void showPage(String pageId, String sectionId)
pageId
- the pageId of the Page to showsectionId
- the sectionId of the Section that contains
the specified pageIdpublic void showPage(URL pepperURL, boolean saveCurrentPage)
pepperURL
- an URL
valuesaveCurrentPage
- true to first save the current pagepublic void showPage(PageInfo pageInfo, boolean saveCurrentPage)
pageInfo
- a PageInfo
valuesaveCurrentPage
- a boolean
valuepublic void showNextPage()
public void showPreviousPage()
public void addPage(Page page)
page
- The feature to be added to the Page attributepublic void addPage(Section section, Page page, boolean show)
section
- The Section to contain the pagepage
- The Page to be added to the specified sectionshow
- true to display the page after it's added, false
to not show itpublic Page createNewPage(String sectionId, String pageId, String pageName, String pageType, Object initData, boolean showWhenCreated) throws Exception
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.
Page
instance.
Exception
- if an error occurs.public Page createNewPage(String pageId, String pageName, String pageType, Object initData) throws Exception
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.
Page
instance.
Exception
- if an error occurs.public WebSection createWebSection(String initTabTitle)
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
WebSection
valueAbstractPepperProgram.createNewSection(String, String, String, int, Object, boolean, String)
public WebSection createWebSection(String initTabTitle, String initURL, boolean selectOnCreation)
initTabTitle
- Initial title of the tabinitURL
- URL to load into the sectionselectOnCreation
- true to select the section
WebSection
valuepublic Section createNewSection(String sectionName, String initURL, boolean selectOnCreation, boolean transientSection)
sectionName
- The name of the sectioninitURL
- URL to load into the sectionselectOnCreation
- true to select the sectiontransientSection
- If true, the tab will show the close button, will not be syncable,
and will be automatically deleted when the package is closed.
Section
valuepublic SectionPage createNewSection(String parentId, String name, String type, int index, Object initData, boolean selectOnCreation, String initTabTitle) throws Exception
data/Section_ + >System.currentTimeMillis()<
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 createdinitTabTitle
- 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.
SectionPage
instance. The Section object
can be obtained by calling SectionPage.getSection().
Exception
- if an error occurs.protected void removePage(Section section, Page page, boolean showPrevious)
DeletePageAction
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 sectionpublic Section getCurrentSection()
Section
valuepublic String getCurrentSectionId()
String
containing the section's id.public String getCurrentSectionName()
String
containing the section's name.public void showContentSectionPage()
public SectionPage getSectionPage(String sectionId)
sectionId
- a String
value
SectionPage
valuepublic Section getSection(String sectionId)
Section
specified by the given id.
sectionId
- a String
specifying the id of the
the section to return.
Section
instance for the given id.public Section getSectionByName(String sectionName)
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.
sectionName
- a String
specifying the name of the
the section to return.
Section
instance for the given name.public void showSection(String sectionId)
sectionId
- a String
containing the id
of the desired section.public void showSection(Section section)
section
- the Section
to display.public Page getCurrentPage()
Page
instance.public PageInfo getCurrentPageInfo()
PageInfo
valueprotected Page getNextPage()
protected Page getPreviousPage()
public Page getPage(String pageId)
pageId
- an int
value
Page
valuepublic Page getPage(String pageId, String sectionId)
pageId
- an int
valuesectionId
- an int
value
Page
valuepublic void savePage(Page page, boolean showPage) throws Exception
page
- Page to be savedshowPage
- a boolean
value that indicates that the new
page should be displayed.
Exception
- if an error occurspublic void savePage(Page page, Section section, boolean showPage) throws Exception
page
- Page to be savedsection
- Section the page is inshowPage
- a boolean
value that indicates that the new
page should be displayed.
Exception
- if an error occurspublic boolean needsRefresh()
true
if the program should refresh the current
page when it comes to the foreground.public void setNeedsRefresh(boolean state)
state
- true
if the program should be refreshed when it
comes to the foreground.public void refreshCurrentPage()
public void refreshCurrentPage(boolean deepRefresh)
deepRefresh
- true to refresh cachepublic Properties getPageProperties()
public String getPackageId()
String
valuepublic String getPackageTitle()
String
valuepublic Integer getPID()
public void programChanged(ProgramChangeEvent event)
programChanged
in interface ProgramChangeListener
event
- the event.ProgramChangeListener
public boolean search(FindConfig findConfig)
findConfig
- a FindConfig
value
public void actionPerformed(ActionEvent ae)
actionPerformed
in interface ActionListener
ae
- ActionEvent to handlepublic MessageCatalog getMessageCatalog()
PackageStrings.properties
)
and the platform catalog ( CommonStrings.properties
).
MessageCatalog
instance.public void registerAction(String commandName, Action a)
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.
commandName
- String used as the key for the actiona
- The Action to registerAbstractPepperProgram.getAction(String)
public void enableAction(String command, boolean enable)
command
- command name of action to enable/disable. See
CommonActionMgr
for a list of common action namesenable
- true to enable the action, false to disable itAbstractPepperProgram.registerAction(String, Action)
public boolean isStopping()
boolean
valuepublic void destroy() throws Exception
Exception
public void removeEmptyWebSections()
public void removeEmptySections(boolean webOnly)
public PepperProgramConfig getProgramConfig()
public SectionList getSections()
public boolean supportsWebPages()
boolean
valuepublic void setAllowSharing(boolean allowSharing)
false
. As a side effect, updates the toolbar
share button to the appropriate state.
allowSharing
- true
to allow the package to be shared with
other users, false
to prevent it from being shared.public boolean getAllowSharing()
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.
true
, this package can be shared with other users.
If false
, the package must not be shared with other users.public void setAllowSync(boolean allowSync)
false
. As a side effect, updates the toolbar
sync button to the appropriate state.
allowSync
- true
to allow the package to be synced with
other users, false
to prevent it from being synced.public boolean getAllowSync()
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.
true
, this package can be synced with other users.
If false
, the package must not be synced with other users.public List getTypes()
getTypes
in interface PackageInstance
PackageInstance
public List findPages(String type, String expression)
findPages
in interface PackageInstance
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.
PackageInstance
public void createPage(Object data, List metadata, PageChangeListener listener) throws Exception
createPage
in interface PackageInstance
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
Exception
PackageInstance
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |