public abstract class StaticMetawidget extends BaseStaticWidget
Although Metawidget focuses on runtime UI generation, there are a category of applications that require static code generation instead. It is still possible to make full use of Metawidget's 5 stage pipeline (inspectors, inspection result processors, widget builders, widget processors, layouts) during static code generation.
An important requirement for static code generation is the Metawidget should not rely on the
technology being generated being available. For example, a static JSF Metawidget should not rely
on FacesContext.getCurrentInstance
. Architectually, this makes all static
Metawidgets more similar to each other than to their corresponding runtime version. For example,
the static JSF Metawidget is more similar to the static Spring Metawidget than it is to the
runtime JSF Metawidget. Therefore, it makes sense to have a StaticMetawidget
base
class.
Modifier and Type | Class and Description |
---|---|
protected class |
StaticMetawidget.Pipeline
Internal Metawidget pipeline.
|
Constructor and Description |
---|
StaticMetawidget() |
Modifier and Type | Method and Description |
---|---|
<W extends StaticWidget,M extends W> |
addWidgetProcessor(WidgetProcessor<W,M> widgetProcessor) |
protected void |
beforeBuildCompoundWidget(Element element) |
String |
getConfig() |
ConfigReader |
getConfigReader() |
protected abstract String |
getDefaultConfiguration() |
Inspector |
getInspector() |
String |
getLabelString(Map<String,String> attributes) |
Layout<StaticWidget,StaticWidget,StaticMetawidget> |
getLayout()
Useful for WidgetBuilders.
|
String |
getPath() |
WidgetBuilder<StaticWidget,StaticMetawidget> |
getWidgetBuilder() |
<T> T |
getWidgetProcessor(Class<T> widgetProcessorClass) |
List<WidgetProcessor<StaticWidget,StaticMetawidget>> |
getWidgetProcessors() |
void |
initNestedMetawidget(StaticMetawidget nestedMetawidget,
Map<String,String> attributes)
Useful for WidgetBuilders to setup nested Metawidgets (eg.
|
protected Element |
inspect() |
String |
inspect(Object toInspect,
String type,
String... names)
Useful for WidgetBuilders to perform nested inspections (eg.
|
boolean |
isReadOnly() |
protected StaticMetawidget.Pipeline |
newPipeline()
Instantiate the Pipeline used by this Metawidget.
|
<W extends StaticWidget,M extends W> |
removeWidgetProcessor(WidgetProcessor<W,M> widgetProcessor) |
void |
setConfig(String config) |
void |
setConfigReader(ConfigReader configReader) |
void |
setInspectionResultProcessors(InspectionResultProcessor<? extends StaticMetawidget>... inspectionResultProcessors) |
void |
setInspector(Inspector inspector) |
<W extends StaticWidget,C extends W,M extends C> |
setLayout(Layout<W,C,M> layout) |
void |
setMaximumInspectionDepth(int maximumInspectionDepth) |
void |
setPath(String path) |
void |
setReadOnly(boolean readOnly) |
<W extends StaticWidget,M extends W> |
setWidgetBuilder(WidgetBuilder<W,M> widgetBuilder) |
<W extends StaticWidget,M extends W> |
setWidgetProcessors(WidgetProcessor<W,M>... widgetProcessors) |
protected void |
startBuild() |
void |
write(Writer writer)
Clients should override the version that takes initialIndent instead.
|
void |
write(Writer writer,
int initialIndent)
Write the Metawidget output using the given Writer.
|
getChildren, getClientProperty, getParent, putClientProperty, toString
public void setPath(String path)
public String getPath()
public ConfigReader getConfigReader()
public void setConfigReader(ConfigReader configReader)
public String getConfig()
public void setConfig(String config)
public void setMaximumInspectionDepth(int maximumInspectionDepth)
public boolean isReadOnly()
public void setReadOnly(boolean readOnly)
public Inspector getInspector()
public void setInspector(Inspector inspector)
public String inspect(Object toInspect, String type, String... names)
public void initNestedMetawidget(StaticMetawidget nestedMetawidget, Map<String,String> attributes)
public void setInspectionResultProcessors(InspectionResultProcessor<? extends StaticMetawidget>... inspectionResultProcessors)
public WidgetBuilder<StaticWidget,StaticMetawidget> getWidgetBuilder()
public <W extends StaticWidget,M extends W> void setWidgetBuilder(WidgetBuilder<W,M> widgetBuilder)
public <W extends StaticWidget,M extends W> void addWidgetProcessor(WidgetProcessor<W,M> widgetProcessor)
public List<WidgetProcessor<StaticWidget,StaticMetawidget>> getWidgetProcessors()
public <W extends StaticWidget,M extends W> void setWidgetProcessors(WidgetProcessor<W,M>... widgetProcessors)
public <T> T getWidgetProcessor(Class<T> widgetProcessorClass)
public <W extends StaticWidget,M extends W> void removeWidgetProcessor(WidgetProcessor<W,M> widgetProcessor)
public Layout<StaticWidget,StaticWidget,StaticMetawidget> getLayout()
public <W extends StaticWidget,C extends W,M extends C> void setLayout(Layout<W,C,M> layout)
public final void write(Writer writer)
write
in interface StaticWidget
write
in class BaseStaticWidget
public void write(Writer writer, int initialIndent)
initialIndent
- the initialIndent that will be applied to every line. 0 for no initial indent. -1
for no subsequent indenting eitherprotected StaticMetawidget.Pipeline newPipeline()
Subclasses wishing to use their own Pipeline should override this method to instantiate their version.
protected void startBuild()
protected void beforeBuildCompoundWidget(Element element)
element
- the parent element that will be iterated overprotected Element inspect()
protected abstract String getDefaultConfiguration()
Copyright © 2015. All Rights Reserved.