Package cl.obcom.desktopfx.layout
Class LayoutLoader
java.lang.Object
cl.obcom.desktopfx.layout.LayoutLoader
Collection of reusable
Layout
instances. If a required Layout
is not in the collection, it is loaded from the specified layoutURI
and added to the collection.
The layoutURI
must contain at least one occurrence of the marker
"*
". Before each download, all occurrences of this marker are
replaced with the name of the layout. In this way, the resulting URL
gets targeted specifically to the required layout. Examples of valid URLs:
http://www.netswitch.cl/layouts/*.jsp file:///C:/netswitch/layouts/*.asp
-
Constructor Summary
ConstructorDescriptionLayoutLoader
(Desktop desktop, URI layoutURI) Creates a newLayoutLoader
instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears (removes) all layouts from the cache.Downloads the specification of theLayout
with the givenname
.Returns theLayout
with the specifiedname
.boolean
Returnstrue
if the signatures of downloaded layouts are verified.layouts()
Returns an unmodifiable collection with the layouts contained in thisLayoutLoader
.void
Adds a layout to the collection of layouts of thisLayoutLoader
.void
setVerifyLayoutSignatures
(boolean value) Changes whether the signatures of downloaded layouts are verified.
-
Constructor Details
-
LayoutLoader
Creates a newLayoutLoader
instance.- Parameters:
desktop
- the Desktop application instance.layoutURI
- the URI used to download layouts.- Throws:
NullPointerException
- if an argument isnull
.IllegalArgumentException
- iflayoutURI
is invalid.
-
-
Method Details
-
layouts
Returns an unmodifiable collection with the layouts contained in thisLayoutLoader
.- Returns:
- an unmodifiable collection with the layouts contained in this
LayoutLoader
.
-
clear
public void clear()Clears (removes) all layouts from the cache. -
getVerifyLayoutSignatures
public boolean getVerifyLayoutSignatures()Returnstrue
if the signatures of downloaded layouts are verified.- Returns:
true
if the signatures of downloaded layouts are verified.
-
setVerifyLayoutSignatures
public void setVerifyLayoutSignatures(boolean value) Changes whether the signatures of downloaded layouts are verified.- Parameters:
value
- iftrue
the signatures of downloaded layouts will be verified. Otherwise the signatures will be assigned to layouts without verification.
-
getLayout
Returns theLayout
with the specifiedname
. If the layout is not available in the cache, it is downloaded, compiled, stored in the cache and returned to the caller of this method. The signature of the downloaded layout will be verified ifgetVerifyLayoutSignatures()
returnstrue
, otherwise the signature will be assigned to the layout without verification.- Parameters:
name
- name of the requiredLayout
.- Returns:
- the
Layout
with the specifiedname
. - Throws:
NullPointerException
- ifname
isnull
.Exception
- if an error occurs while loading the layout.
-
putLayout
Adds a layout to the collection of layouts of thisLayoutLoader
. Thelayout
must be non-null and complete as defined by theLayout.isComplete()
method.- Parameters:
layout
- the layout to add to thisLayoutLoader
.- Throws:
NullPointerException
- iflayout
is null.IllegalArgumentException
- iflayout
is not complete.
-
download
Downloads the specification of theLayout
with the givenname
. The layout spacification will be downloaded from the location specified by the specifiedlayoutURI
.- Parameters:
name
- the name of the requiredLayout
.- Returns:
- a string with the specification of the
Layout
. - Throws:
NullPointerException
- ifname
isnull
.Exception
- if an error occurs while loading the layout.
-