Class HyperlinkProvider
- java.lang.Object
-
- org.jdesktop.swingx.renderer.ComponentProvider<JXHyperlink>
-
- org.jdesktop.swingx.renderer.HyperlinkProvider
-
- All Implemented Interfaces:
- java.io.Serializable, UIDependent, RolloverRenderer
public class HyperlinkProvider extends ComponentProvider<JXHyperlink> implements RolloverRenderer
Renderer for hyperlinks".The renderer is configured with a LinkAction
. It's mostly up to the developer to guarantee that the all values which are passed into the getXXRendererComponent(...) are compatible with T: she can provide a runtime class to check against. If it isn't the renderer will configure the action with a null target. It's recommended to not use the given Action anywhere else in code, as it is updated on each getXXRendererComponent() call which might lead to undesirable side-effects.
Internally uses JXHyperlink as rendering component.
PENDING: can go from ButtonProvider?
PENDING: make renderer respect selected cell state.
PENDING: TreeCellRenderer has several issues
- no icons
- usual background highlighter issues
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description HyperlinkProvider()Instantiate a LinkRenderer with null LinkAction and null targetClass.HyperlinkProvider(AbstractHyperlinkAction linkAction)Instantiate a LinkRenderer with the LinkAction to use with target values.HyperlinkProvider(AbstractHyperlinkAction linkAction, java.lang.Class<?> targetClass)Instantiate a LinkRenderer with a LinkAction to use with target values and the type of values the action can cope with.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voiddoClick()Same as AbstractButton.doClick().java.lang.StringgetString(java.lang.Object value)Returns a string representation of the content.booleanisEnabled()booleanisTargetable(java.lang.Object target)decides if the given target is acceptable for setTarget.voidsetLinkAction(AbstractHyperlinkAction linkAction)Sets the LinkAction for handling the values.voidsetLinkAction(AbstractHyperlinkAction linkAction, java.lang.Class<?> targetClass)Sets the LinkAction for handling the values and the class the action can handle.voidsetTargetClass(java.lang.Class<?> targetClass)Sets the class the action is supposed to handle.-
Methods inherited from class org.jdesktop.swingx.renderer.ComponentProvider
getHorizontalAlignment, getRendererComponent, getStringValue, setHorizontalAlignment, setStringValue, updateUI
-
-
-
-
Constructor Detail
-
HyperlinkProvider
public HyperlinkProvider()
Instantiate a LinkRenderer with null LinkAction and null targetClass.
-
HyperlinkProvider
public HyperlinkProvider(AbstractHyperlinkAction linkAction)
Instantiate a LinkRenderer with the LinkAction to use with target values.- Parameters:
linkAction- the action that acts on values.
-
HyperlinkProvider
public HyperlinkProvider(AbstractHyperlinkAction linkAction, java.lang.Class<?> targetClass)
Instantiate a LinkRenderer with a LinkAction to use with target values and the type of values the action can cope with.It's up to developers to take care of matching types.
- Parameters:
linkAction- the action that acts on values.targetClass- the type of values the action can handle.
-
-
Method Detail
-
setTargetClass
public void setTargetClass(java.lang.Class<?> targetClass)
Sets the class the action is supposed to handle.PENDING: make sense to set independently of LinkAction?
- Parameters:
targetClass- the type of values the action can handle.
-
setLinkAction
public void setLinkAction(AbstractHyperlinkAction linkAction)
Sets the LinkAction for handling the values.The action is assumed to be able to cope with any type, that is this method is equivalent to setLinkAction(linkAction, null).
- Parameters:
linkAction-
-
setLinkAction
public void setLinkAction(AbstractHyperlinkAction linkAction, java.lang.Class<?> targetClass)
Sets the LinkAction for handling the values and the class the action can handle.PENDING: in the general case this is not independent of the targetClass. Need api to set them combined?
- Parameters:
linkAction-
-
isTargetable
public boolean isTargetable(java.lang.Object target)
decides if the given target is acceptable for setTarget.target == null is acceptable for all types. targetClass == null is the same as Object.class
- Parameters:
target- the target to set.- Returns:
- true if setTarget can cope with the object, false otherwise.
-
isEnabled
public boolean isEnabled()
- Specified by:
isEnabledin interfaceRolloverRenderer- Returns:
- true if rollover effects are on and clickable.
-
doClick
public void doClick()
Description copied from interface:RolloverRendererSame as AbstractButton.doClick(). It's up to client code to prepare the renderer's component before calling this method.- Specified by:
doClickin interfaceRolloverRenderer
-
getString
public java.lang.String getString(java.lang.Object value)
Returns a string representation of the content.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())
This implementation simply delegates to its StringValue. Subclasses might need to override to comply.if (equals(value, context.getValue()) { assertEquals(provider.getString(value), provider.getRenderingComponent(context).getText()); }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 ...
PENDING JW: Needs to be overridden - doesn't comply to contract!. Not sure how to do it without disturbing the hyperlinks current setting? All hyperlink properties are defined by the LinkAction configured with the target ...
- Overrides:
getStringin classComponentProvider<JXHyperlink>- Parameters:
value- the object to represent as string.- Returns:
- a appropriate string representation of the cell's content.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG