|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jdesktop.swingx.renderer.ComponentProvider<WrappingIconPanel>
org.jdesktop.swingx.renderer.WrappingProvider
public class WrappingProvider
Wrapping ComponentProvider for usage in tree rendering. Handles the icon
itself, delegates the node content to the wrappee. Value-based icon and
content mapping can be configured by custom IconValue
s and
StringValue, respectively.
An example of how to configure a file tree by using the system icons and display names
StringValue sv = new StringValue() {
public String getString(Object value) {
if (value instanceof File) {
return FileSystemView.getFileSystemView().getSystemDisplayName(
(File) value);
}
return TO_STRING.getString(value);
}
};
IconValue iv = new IconValue() {
public Icon getIcon(Object value) {
if (value instanceof File) {
return FileSystemView.getFileSystemView().getSystemIcon(
(File) value);
}
return null;
}
};
TreeCellRenderer r = new DefaultTreeRenderer(iv, sv);
tree.setCellRenderer(r);
treeTable.setTreeCellRenderer(r);
PENDING: ui specific focus rect variation (draw rect around icon) missing
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
void |
doClick()
Same as AbstractButton.doClick(). |
WrappingIconPanel |
getRendererComponent(CellContext context)
Configures and returns an appropriate component to render a cell in the given context. |
java.lang.String |
getString(java.lang.Object value)
Returns a string representation of the content. |
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. |
ComponentProvider |
getWrappee()
Returns the delegate provider used to render the node content. |
boolean |
isEnabled()
|
void |
setUnwrapUserObject(boolean unwrap)
Sets the unwrapUserObject property. |
void |
setWrappee(ComponentProvider delegate)
Sets the given provider as delegate for the node content. |
Methods inherited from class org.jdesktop.swingx.renderer.ComponentProvider |
---|
getHorizontalAlignment, getStringValue, setHorizontalAlignment, setStringValue |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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.Method Detail |
---|
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 java.lang.String getString(java.lang.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 WrappingIconPanel getRendererComponent(CellContext context)
getRendererComponent
in class ComponentProvider<WrappingIconPanel>
context
- the cell context to configure from
public void doClick()
doClick
in interface RolloverRenderer
public boolean isEnabled()
isEnabled
in interface RolloverRenderer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |