setToolTipText(null);
if (value instanceof Element)
{
final Element vr = (Element) value;
final ElementMetaData data = vr.getMetaData();
setText(formatElement(vr));
final Image icon = data.getIcon(Locale.getDefault(), BeanInfo.ICON_COLOR_32x32);
if (icon != null)
{
setIcon(new ImageIcon(icon));
}
setToolTipText(data.getDescription(Locale.getDefault()));
}
else if (value instanceof CompoundDataFactory)
{
setText(Messages.getString("StructureTreeCellRenderer.DataSets"));
setIcon(IconLoader.getInstance().getDataSetsIcon());
}
else if (value instanceof ReportEnvironmentDataRow)
{
setText(Messages.getString("StructureTreeCellRenderer.Environment"));
setIcon(IconLoader.getInstance().getPropertiesDataSetIcon());
}
else if (value instanceof ReportFunctionNode)
{
setText(Messages.getString("StructureTreeCellRenderer.Functions"));
setIcon(IconLoader.getInstance().getFunctionsIcon());
}
else if (value instanceof ReportParametersNode || value instanceof SubReportParametersNode)
{
setText(Messages.getString("StructureTreeCellRenderer.Parameters"));
setIcon(IconLoader.getInstance().getParameterIcon());
}
else if (value instanceof SubReportParametersNode.ExportParametersNode)
{
setText(Messages.getString("StructureTreeCellRenderer.ExportParameters"));
setIcon(IconLoader.getInstance().getParameterIcon());
}
else if (value instanceof SubReportParametersNode.ImportParametersNode)
{
setText(Messages.getString("StructureTreeCellRenderer.ImportParameters"));
setIcon(IconLoader.getInstance().getParameterIcon());
}
else if (value instanceof ParameterMapping)
{
final ParameterMapping mapping = (ParameterMapping) value;
setText(Messages.getString("StructureTreeCellRenderer.ParameterMappingMessage", mapping.getAlias(), mapping.getName()));
setIcon(IconLoader.getInstance().getParameterIcon());
}
else if (value instanceof ReportFieldNode)
{
final ReportFieldNode fieldNode = (ReportFieldNode) value;
final ContextAwareDataSchemaModel model = fieldNode.getDataSchemaModel();
final DataAttributes attributes = model.getDataSchema().getAttributes(fieldNode.getFieldName());
setToolTipText(fieldNode.getFieldClass().getSimpleName());
if (attributes == null)
{
setText(fieldNode.toString());
}
else
{
final String displayName = (String) attributes.getMetaAttribute
(MetaAttributeNames.Formatting.NAMESPACE, MetaAttributeNames.Formatting.LABEL,
String.class, model.getDataAttributeContext());
setText(formatFieldType(displayName, fieldNode.getFieldName(), fieldNode.getFieldClass()));
}
}
else if (value instanceof ReportQueryNode)
{
final ReportQueryNode queryNode = (ReportQueryNode) value;
setText(queryNode.getQueryName());
setToolTipText(queryNode.getDataFactory().getClass().getSimpleName());
}
else if (value instanceof Expression)
{
final Expression expression = (Expression) value;
if (ExpressionRegistry.getInstance().isExpressionRegistered(expression.getClass().getName()) == false)
{
setText(expression.getClass().getName());
}
else
{
final ExpressionMetaData expressionMetaData =
ExpressionRegistry.getInstance().getExpressionMetaData(expression.getClass().getName());
if (expression.getName() == null)
{
setText(expressionMetaData.getDisplayName(Locale.getDefault()));
}
else
{
setText(Messages.getString("StructureTreeCellRenderer.NamedExpressionMessage",
expressionMetaData.getDisplayName(Locale.getDefault()), expression.getName()));
}
}
}
else if (value instanceof ParameterDefinitionEntry)
{
final ParameterDefinitionEntry params = (ParameterDefinitionEntry) value;
setText(params.getName());
}
else if (value instanceof DataFactory)
{
final DataFactory dfac = (DataFactory) value;
final DataFactoryMetaData data = dfac.getMetaData();
final Image image = data.getIcon(Locale.getDefault(), BeanInfo.ICON_COLOR_32x32);
if (image != null)
{
setIcon(new ImageIcon(image));
}
final String connectionName = data.getDisplayConnectionName(dfac);
if (connectionName != null)
{
setText(Messages.getString("StructureTreeCellRenderer.NamedDataFactoryMessage",
data.getDisplayName(Locale.getDefault()), connectionName));
}
else
{
setText(data.getDisplayName(Locale.getDefault()));
}
}
else if (value instanceof ParentDataFactoryNode)
{
setText(Messages.getString("StructureTreeCellRenderer.InheritedDataFactories"));
}
else if (value instanceof InheritedDataFactoryWrapper)
{
final InheritedDataFactoryWrapper wrapper = (InheritedDataFactoryWrapper) value;
final DataFactory dfac = wrapper.getDataFactory();
if (DataFactoryRegistry.getInstance().isRegistered(dfac.getClass().getName()) == false)
{
setText(dfac.getClass().getSimpleName());
}
else
{
final DataFactoryMetaData data = dfac.getMetaData();
final Image image = data.getIcon(Locale.getDefault(), BeanInfo.ICON_COLOR_32x32);
if (image != null)
{
setIcon(new ImageIcon(image));
}
final String connectionName = data.getDisplayConnectionName(dfac);
if (connectionName != null)
{
setText(Messages.getString("StructureTreeCellRenderer.NamedDataFactoryMessage",
data.getDisplayName(Locale.getDefault()), connectionName));
}
else
{
setText(data.getDisplayName(Locale.getDefault()));
}
}
}
return this;
}