public class WrappingProvider extends ComponentProvider<WrappingIconPanel> implements RolloverRenderer
IconValue
s and
StringValue, respectively.
An example of how to configure a file tree by using the system icons and display names
TreeCellRenderer r = new DefaultTreeRenderer(
IconValues.FILE_ICON, StringValues.FILE_NAME);
tree.setCellRenderer(r);
treeTable.setTreeCellRenderer(r);
PENDING: ui specific focus rect variation (draw rect around icon) missing
Modifier and Type | Field and Description |
---|---|
private boolean |
unwrapUserObject |
protected ComponentProvider<?> |
wrappee |
alignment, defaultVisuals, formatter, rendererComponent
Constructor and Description |
---|
WrappingProvider()
Instantiates a WrappingProvider with default delegate provider.
|
WrappingProvider(ComponentProvider<?> delegate)
Instantiates a WrappingProvider with the given delegate
provider for the node content.
|
WrappingProvider(ComponentProvider<?> delegate,
boolean unwrapUserObject)
Instantiates a WrappingProvider with the given delegate
provider for the node content and unwrapUserObject property.
|
WrappingProvider(IconValue iconValue)
Instantiates a WrappingProvider with default wrappee.
|
WrappingProvider(IconValue iv,
ComponentProvider<?> delegate,
boolean unwrapUserObject)
Instantiates a WrappingProvider with the given delegate
provider for the node content and unwrapUserObject property.
|
WrappingProvider(IconValue iconValue,
StringValue wrappeeStringValue)
Instantiates a WrappingProvider with default wrappee, configured
to use the wrappeeStringValue.
|
WrappingProvider(IconValue iv,
StringValue delegateStringValue,
boolean unwrapUserObject)
Instantiates a WrappingProvider with the given delegate
provider for the node content and unwrapUserObject property.
|
WrappingProvider(StringValue wrappeeStringValue)
Instantiates a WrappingProvider with default wrappee configured
with the given StringValue.
|
Modifier and Type | Method and Description |
---|---|
protected Object |
adjustContextValue(CellContext context)
Replace the context's value with the userobject if the value is a type
supporting the notion of userObject and this provider's unwrapUserObject
property is true.
|
protected void |
configureState(CellContext context)
Configures the rendering component's state from the
given cell context.
|
protected WrappingIconPanel |
createRendererComponent()
Factory method to create and return the component to use for rendering.
|
void |
doClick()
Same as AbstractButton.doClick().
|
protected void |
format(CellContext context)
Formats the renderering component's content from the
given cell context.
|
boolean |
getExtendsComponentOpacity() |
WrappingIconPanel |
getRendererComponent(CellContext context)
Configures and returns an appropriate component to render a cell
in the given context.
|
String |
getString(Object value)
Returns a string representation of the content.
|
protected Object |
getUnwrappedValue(Object value)
Returns the value as it should be passed to the delegate.
|
boolean |
getUnwrapUserObject()
Returns a boolean indicating whether this provider tries to unwrap
a userObject from a tree/table/node type value before delegating the
context.
|
protected Icon |
getValueAsIcon(CellContext context)
Returns a Icon representation of the content.
|
ComponentProvider<?> |
getWrappee()
Returns the delegate provider used to render the node content.
|
boolean |
isEnabled() |
protected void |
restoreContextValue(CellContext context,
Object oldValue)
Restores the context value to the old value.
|
void |
setExtendsComponentOpacity(boolean extendsComponentOpacity)
Sets a boolean indicating whether or not the main component's opacity
should be applied to the Icon region.
|
void |
setUnwrapUserObject(boolean unwrap)
Sets the unwrapUserObject property.
|
void |
setWrappee(ComponentProvider<?> delegate)
Sets the given provider as delegate for the node content.
|
configureContent, configureVisuals, createDefaultVisuals, getDefaultVisuals, getHorizontalAlignment, getStringValue, getValueAsString, setHorizontalAlignment, setStringValue, updateUI
protected ComponentProvider<?> wrappee
private boolean unwrapUserObject
public WrappingProvider()
public WrappingProvider(IconValue iconValue, StringValue wrappeeStringValue)
iconValue
- the IconValue to use for configuring the icon.wrappeeStringValue
- the StringValue to use in the wrappee.public WrappingProvider(IconValue iconValue)
iconValue
- the IconValue to use for configuring the icon.public WrappingProvider(StringValue wrappeeStringValue)
wrappeeStringValue
- the StringValue to use in the wrappee.public WrappingProvider(ComponentProvider<?> delegate)
delegate
- the provider to use as delegatepublic WrappingProvider(ComponentProvider<?> delegate, boolean unwrapUserObject)
delegate
- the provider to use as delegateunwrapUserObject
- a flag indicating whether this provider
should auto-unwrap the userObject from the context value.public WrappingProvider(IconValue iv, ComponentProvider<?> delegate, boolean unwrapUserObject)
iv
- the icon converter to use for this providerdelegate
- the provider to use as delegateunwrapUserObject
- a flag indicating whether this provider
should auto-unwrap the userObject from the context value.public WrappingProvider(IconValue iv, StringValue delegateStringValue, boolean unwrapUserObject)
iv
- the icon converter to use for this providerdelegateStringValue
- the StringValue to use in the wrappee.unwrapUserObject
- a flag indicating whether this provider
should auto-unwrap the userObject from the context value.public void setWrappee(ComponentProvider<?> delegate)
PENDING: rename to setDelegate?
delegate
- the provider to use as delegate.public ComponentProvider<?> getWrappee()
public void setUnwrapUserObject(boolean unwrap)
The default value is true.
unwrap
- getUnwrapUserObject()
public boolean getUnwrapUserObject()
setUnwrapUserObject(boolean)
public String getString(Object value)
This method guarantees to return the same string representation as would appear in the renderer, given that the corresponding cellContext has the same value as the parameter passed-in here. That is (assuming that the rendering component has a getText())
if (equals(value, context.getValue()) {
assertEquals(provider.getString(value),
provider.getRenderingComponent(context).getText());
}
This implementation simply delegates to its StringValue. Subclasses might
need to override to comply.
This is a second attempt - the driving force is the need for a consistent string representation across all (new and old) themes: rendering, (pattern) filtering/highlighting, searching, auto-complete ...
Overridden to comply to contract: returns the string representation as provided by the wrappee (as this level has no string rep). Must do the same unwrapping magic as in configuring the rendering component if the unwrapUserObject property is true.
getString
in class ComponentProvider<WrappingIconPanel>
value
- the Object to get a String representation for.setUnwrapUserObject(boolean)
,
getUnwrappedValue(Object)
public void setExtendsComponentOpacity(boolean extendsComponentOpacity)
The default value is false. This covers the main use case in a JTree.
extendsComponentOpacity
- public boolean getExtendsComponentOpacity()
protected Object getUnwrappedValue(Object value)
Here: unwraps userObject of DefaultMutableTreeNode and TreeTableNode.
value
- the value to possibly unwrapsetUnwrapUserObject(boolean)
,
getString(Object)
,
getRendererComponent(CellContext)
public WrappingIconPanel getRendererComponent(CellContext context)
getRendererComponent
in class ComponentProvider<WrappingIconPanel>
context
- the cell context to configure fromprotected void restoreContextValue(CellContext context, Object oldValue)
context
- the CellContext to restore.oldValue
- the value to restore the context to.protected Object adjustContextValue(CellContext context)
Subclasses may override but must guarantee to return the original value for restoring.
context
- the context to adjustsetUnwrapUserObject(boolean)
,
getString(Object)
protected void configureState(CellContext context)
ComponentProvider
configureState
in class ComponentProvider<WrappingIconPanel>
context
- the cell context to configure from, must not be null.protected WrappingIconPanel createRendererComponent()
ComponentProvider
createRendererComponent
in class ComponentProvider<WrappingIconPanel>
protected void format(CellContext context)
Here: implemented to set the icon.
format
in class ComponentProvider<WrappingIconPanel>
context
- the cell context to configure from, must not be null.protected Icon getValueAsIcon(CellContext context)
This method messages the
IconValue
to get the Icon rep. Meant as
a convenience for subclasses.
Overridden to fallback to the default icons supplied by the context if super returns null.
getValueAsIcon
in class ComponentProvider<WrappingIconPanel>
context
- the cell context, must not be null.public void doClick()
doClick
in interface RolloverRenderer
public boolean isEnabled()
isEnabled
in interface RolloverRenderer
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses