public class SwingContentBuilder extends java.lang.Object implements ContentBuilder
Modifier and Type | Class and Description |
---|---|
static class |
SwingContentBuilder.XMLPanel |
Constructor and Description |
---|
SwingContentBuilder(AppContext conn,
javax.swing.JComponent content,
javax.swing.JFrame frame) |
SwingContentBuilder(AppContext conn,
javax.swing.JFrame frame) |
Modifier and Type | Method and Description |
---|---|
void |
addActionButtons(Form f,
java.lang.String legend,
java.util.Set<java.lang.String> actions)
A a set of action buttons to the content
|
void |
addButton(AppContext c,
java.lang.String text,
FormResult action)
Add an action button to the Content
|
void |
addButton(AppContext c,
java.lang.String text,
java.lang.String hover,
FormResult action)
Add an action button to the Content
|
<C,R> void |
addColumn(AppContext conn,
Table<C,R> t,
C col)
Add the data from a single column of a
Table formatted in
2 columns (key and data). |
<I,T> void |
addFormInput(AppContext conn,
Field<I> f,
T radio_selector)
Add the input for a form
Field
If the input is a RadioButtonInput then the item parameter
selects which item the input is for. |
<I,T> void |
addFormLabel(AppContext conn,
Field<I> f,
T item)
Add the label for a form
Field |
void |
addFormTable(AppContext conn,
java.lang.Iterable<Field> f)
Add a set of
Field s as a table of labels and inputs. |
void |
addFormTable(AppContext conn,
java.lang.Iterable<Field> f,
boolean validate) |
void |
addHeading(int level,
java.lang.String text)
Convenience routine to add a heading containing unformatted text.
|
void |
addHtml(java.lang.String text) |
void |
addImage(AppContext conn,
java.lang.String alt,
java.lang.String hover,
java.lang.Integer width,
java.lang.Integer height,
ServeDataResult image)
Add an image served by a
ServeDataResult |
void |
addLink(AppContext c,
java.lang.String text,
FormResult action)
Add an action link to the Content
|
void |
addLink(AppContext c,
java.lang.String text,
java.lang.String hover,
FormResult action)
Add an action link to the Content
|
<X> void |
addList(java.lang.Iterable<X> list)
add a bullet list of objects to the content.
|
<X> void |
addList(java.util.Map<java.lang.String,java.lang.String> attr,
java.lang.Iterable<X> list)
add a bullet list of objects to the content.
|
<X> void |
addList(X[] list)
add a bullet list of objects to the content.
|
<X> void |
addNumberedList(int start,
java.lang.Iterable<X> list)
add a numbered list of objects to the content.
|
<X> void |
addObject(X target)
Add an object depending on its type.
|
ContentBuilder |
addParent()
append a nested panel to its parent content.
|
<C,R> void |
addTable(AppContext conn,
java.text.NumberFormat nf,
Table<C,R> t)
Add a table to the content.
|
<C,R> void |
addTable(AppContext conn,
Table<C,R> t)
Add a table to the content.
|
<C,R> void |
addTable(AppContext conn,
Table<C,R> t,
java.text.NumberFormat nf,
java.lang.String style)
Add a table to the content.
|
<C,R> void |
addTable(AppContext conn,
Table<C,R> t,
java.lang.String style)
Add a table to the content.
|
void |
addText(java.lang.String text)
Add unformatted text.
|
<X> boolean |
canAdd(X target)
Does this ContentBuilder have special handling for the object
beyond adding the string representation.
|
boolean |
cleanFormatted(int max,
java.lang.String s)
add a pre-formatted string as a text section.
|
void |
closeDetails()
finish a section started by
ContentBuilder.getDetails(Object)
this may be a no-op if expended section are not supported |
int |
getAlign() |
javax.swing.border.Border |
getBorder() |
javax.swing.JComponent |
getComponent() |
ContentBuilder |
getDetails(java.lang.Object summary_text)
get an expanding/folding section if supported
This method can either return a new
ContentBuilder or
the current object. |
java.awt.Font |
getFont() |
ContentBuilder |
getHeading(int level)
create a
ContentBuilder that appends its contents as a
heading when the ContentBuilder.addParent() method is called. |
Logger |
getLogger() |
ContentBuilder |
getPanel(java.lang.String... type)
create a nested content panel
|
ExtendedXMLBuilder |
getSpan()
create a
ExtendedXMLBuilder that appends its contents as XML
text when the SimpleXMLBuilder.appendParent() method is called. |
ExtendedXMLBuilder |
getText()
create a
ExtendedXMLBuilder that appends its contents as XML
text when the SimpleXMLBuilder.appendParent() method is called. |
void |
setAlign(int align) |
void |
setBorder(javax.swing.border.Border border) |
void |
setComponentValues() |
void |
setFont(java.awt.Font f) |
boolean |
validate(Form form) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addActionButtons, addFormLabel, getSpan
public SwingContentBuilder(AppContext conn, javax.swing.JFrame frame)
public SwingContentBuilder(AppContext conn, javax.swing.JComponent content, javax.swing.JFrame frame)
public void setFont(java.awt.Font f)
public java.awt.Font getFont()
public void setAlign(int align)
public int getAlign()
public void setBorder(javax.swing.border.Border border)
public javax.swing.border.Border getBorder()
public javax.swing.JComponent getComponent()
public void addButton(AppContext c, java.lang.String text, FormResult action)
ContentBuilder
addButton
in interface ContentBuilder
c
- AppContextpublic void addButton(AppContext c, java.lang.String text, java.lang.String hover, FormResult action)
ContentBuilder
addButton
in interface ContentBuilder
c
- AppContexthover
- tooltip textpublic void addLink(AppContext c, java.lang.String text, FormResult action)
ContentBuilder
addLink
in interface ContentBuilder
c
- AppContexttext
- link textaction
- FormResult to navigate to.public void addLink(AppContext c, java.lang.String text, java.lang.String hover, FormResult action)
ContentBuilder
addLink
in interface ContentBuilder
c
- AppContexttext
- link texthover
- tooltip textaction
- FormResult to navigate to.public <C,R> void addTable(AppContext conn, Table<C,R> t)
ContentBuilder
UIGenerator
should be added via UIGenerator.addContent(ContentBuilder)
addTable
in interface ContentBuilder
public <C,R> void addTable(AppContext conn, java.text.NumberFormat nf, Table<C,R> t)
ContentBuilder
UIGenerator
should be added via UIGenerator.addContent(ContentBuilder)
addTable
in interface ContentBuilder
public ExtendedXMLBuilder getText()
ContentBuilder
ExtendedXMLBuilder
that appends its contents as XML
text when the SimpleXMLBuilder.appendParent()
method is called.
Normally this represents a separate paragraph of text but this can be mapped
onto ContentBuilder.getSpan()
where this does not make sense for example where the
ContentBuilder
represents a heading or table cell.getText
in interface ContentBuilder
public ExtendedXMLBuilder getSpan()
ContentBuilder
ExtendedXMLBuilder
that appends its contents as XML
text when the SimpleXMLBuilder.appendParent()
method is called.
This is intended for in-line text rather than creating a paragraph.getSpan
in interface ContentBuilder
ExtendedXMLBuilder
public ContentBuilder getHeading(int level)
ContentBuilder
ContentBuilder
that appends its contents as a
heading when the ContentBuilder.addParent()
method is called.
If the heading is to only contain text use the ContentBuilder.addHeading(int, String)
method.getHeading
in interface ContentBuilder
level
- level of headingpublic ContentBuilder getPanel(java.lang.String... type) throws java.lang.UnsupportedOperationException
ContentBuilder
getPanel
in interface ContentBuilder
type
- Strings specifying a formatting types for the panel.java.lang.UnsupportedOperationException
public ContentBuilder addParent() throws java.lang.UnsupportedOperationException
ContentBuilder
addParent
in interface ContentBuilder
java.lang.UnsupportedOperationException
public <C,R> void addColumn(AppContext conn, Table<C,R> t, C col)
ContentBuilder
Table
formatted in
2 columns (key and data).addColumn
in interface ContentBuilder
public void addText(java.lang.String text)
ContentBuilder
ContentBuilder.getText()
.clean(text).appendParent().addText
in interface ContentBuilder
text
- string to add to contentpublic void addHtml(java.lang.String text)
public void addHeading(int level, java.lang.String text)
ContentBuilder
ContentBuilder.getHeading(int)
.addText(text).addHeading
in interface ContentBuilder
public boolean cleanFormatted(int max, java.lang.String s)
ContentBuilder
cleanFormatted
in interface ContentBuilder
max
- max line lengthpublic <C,R> void addTable(AppContext conn, Table<C,R> t, java.lang.String style)
ContentBuilder
UIGenerator
should be added via UIGenerator.addContent(ContentBuilder)
addTable
in interface ContentBuilder
public <C,R> void addTable(AppContext conn, Table<C,R> t, java.text.NumberFormat nf, java.lang.String style)
ContentBuilder
UIGenerator
should be added via UIGenerator.addContent(ContentBuilder)
addTable
in interface ContentBuilder
public void addFormTable(AppContext conn, java.lang.Iterable<Field> f)
ContentBuilder
Field
s as a table of labels and inputs.addFormTable
in interface ContentBuilder
public void addFormTable(AppContext conn, java.lang.Iterable<Field> f, boolean validate)
public <I,T> void addFormLabel(AppContext conn, Field<I> f, T item)
ContentBuilder
Field
addFormLabel
in interface ContentBuilder
f
- Fielditem
- item (only used by RadioInputs)public <I,T> void addFormInput(AppContext conn, Field<I> f, T radio_selector)
ContentBuilder
Field
If the input is a RadioButtonInput
then the item parameter
selects which item the input is for. If item is null then
a RadioButtonInput
will output all inputs in a block.addFormInput
in interface ContentBuilder
conn
- AppContextf
- Fieldradio_selector
- item (only used by RadioInputs)public void addActionButtons(Form f, java.lang.String legend, java.util.Set<java.lang.String> actions)
ContentBuilder
addActionButtons
in interface ContentBuilder
f
- Form
legend
- optional legend for the button setactions
- Set
of action namespublic void setComponentValues()
public boolean validate(Form form) throws ValidateException
ValidateException
public <X> void addList(X[] list)
ContentBuilder
UIGenerator
s will generate their content otherwise
a suitable text representation will be used.addList
in interface ContentBuilder
public <X> void addObject(X target)
ContentBuilder
ContentBuilder.addParent()
on child objects.addObject
in interface ContentBuilder
public <X> boolean canAdd(X target)
ContentBuilder
canAdd
in interface ContentBuilder
public <X> void addList(java.lang.Iterable<X> list)
ContentBuilder
UIGenerator
s will generate their content otherwise
a suitable text representation will be used.addList
in interface ContentBuilder
public <X> void addList(java.util.Map<java.lang.String,java.lang.String> attr, java.lang.Iterable<X> list)
ContentBuilder
UIGenerator
s will generate their content otherwise
a suitable text representation will be used.addList
in interface ContentBuilder
public ContentBuilder getDetails(java.lang.Object summary_text)
ContentBuilder
ContentBuilder
or
the current object. Once content has been added the ContentBuilder.closeDetails()
method should be called on whichever object was returned which will
perform any additional actions necessary.
If expanded/folding sections are not supported this will map to
ContentBuilder.addObject(Object)
on the summary text
and the current ContentBuilder
will be returned.getDetails
in interface ContentBuilder
public void closeDetails()
ContentBuilder
ContentBuilder.getDetails(Object)
this may be a no-op if expended section are not supportedcloseDetails
in interface ContentBuilder
public <X> void addNumberedList(int start, java.lang.Iterable<X> list)
ContentBuilder
UIGenerator
s will generate their content otherwise
a suitable text representation will be used.addNumberedList
in interface ContentBuilder
public void addImage(AppContext conn, java.lang.String alt, java.lang.String hover, java.lang.Integer width, java.lang.Integer height, ServeDataResult image)
ContentBuilder
ServeDataResult
addImage
in interface ContentBuilder
width
- (optional, ignored if <= 0)height
- (optional, ignored if <= 0)public Logger getLogger()