// Render label content
if (null != labelContent) {
if (labelContent instanceof StyleList) {
StyleList contentList = (StyleList) labelContent;
if (contentList.getList().isEmpty()) {
throw new ProtocolException(exceptionLocalizer
.format("widget-tab-label-empty-content"));
}
labelContent = (StyleValue) contentList.getList().get(0);
if (labelContent.getStyleValueType() == StyleValueType.STRING) {
textLabel = ((StyleString)labelContent).getString();
} else {
textLabel = labelContent.getStandardCSS();
}
} else if (labelContent instanceof StyleComponentURI) {
// Get asset and policy resolvers, resolve component policy
PolicyReferenceResolver referenceResolver = protocol.getMarinerPageContext().getPolicyReferenceResolver();
AssetResolver assetResolver = protocol.getMarinerPageContext()
.getAssetResolver();
RuntimePolicyReference policyReference = referenceResolver
.resolvePolicyExpression(((StyleComponentURI)labelContent).getExpression());
// Create image asset from the policy and get fallback
DefaultComponentImageAssetReference imageAsset = new DefaultComponentImageAssetReference(
policyReference, assetResolver);
TextAssetReference textAsset = imageAsset.getTextFallback();
// If e.g policy file is missing and as consequence textAsset == null,
// throw suitable exception
if (null == textAsset) {
throw new ProtocolException(exceptionLocalizer.format(
"missing-policy-failure", policyReference.getName()));
}
// Return text in plain encoding, or empty string
textLabel = textAsset.getText(TextEncoding.PLAIN);