use of org.apache.wicket.markup.html.image.NonCachingImage in project syncope by apache.
the class BinaryPDFPreviewer method preview.
@Override
public Component preview(final byte[] uploadedBytes) {
firstPage = null;
try (InputStream bais = new ByteArrayInputStream(uploadedBytes);
PDDocument document = PDDocument.load(bais, MemoryUsageSetting.setupTempFileOnly())) {
document.setResourceCache(new DefaultResourceCache() {
@Override
public void put(final COSObject indirect, final PDXObject xobject) throws IOException {
}
});
if (document.isEncrypted()) {
LOG.info("Document is encrypted, no preview is possible");
} else {
firstPage = new PDFRenderer(document).renderImageWithDPI(0, DPI, IMAGE_TYPE);
}
} catch (IOException e) {
LOG.error("While generating thumbnail from first page", e);
}
Fragment fragment;
if (firstPage == null) {
fragment = new Fragment("preview", "noPreviewFragment", this);
} else {
fragment = new Fragment("preview", "previewFragment", this);
fragment.add(new NonCachingImage("previewImage", new ThumbnailImageResource(firstPage)));
}
WebMarkupContainer previewContainer = new WebMarkupContainer("previewContainer");
previewContainer.setOutputMarkupId(true);
previewContainer.add(fragment);
return this.addOrReplace(previewContainer);
}
use of org.apache.wicket.markup.html.image.NonCachingImage in project midpoint by Evolveum.
the class AbstractSummaryPanel method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
box = new WebMarkupContainer(ID_BOX);
add(box);
IModel<String> archetypePolicyAdditionalCssClassModel = () -> {
String archetypePolicyAdditionalCssClass = getArchetypePolicyAdditionalCssClass();
if (archetypePolicyAdditionalCssClass == null) {
return "";
}
return "border-color: " + archetypePolicyAdditionalCssClass + ";";
};
box.add(new AttributeModifier("class", BOX_CSS_CLASS + " " + getBoxAdditionalCssClass()));
box.add(AttributeModifier.append("style", archetypePolicyAdditionalCssClassModel));
if (getDisplayNameModel() != null) {
box.add(new Label(ID_DISPLAY_NAME, getDisplayNameModel()));
} else if (getDisplayNamePropertyName() != null) {
box.add(new Label(ID_DISPLAY_NAME, createLabelModel(getDisplayNamePropertyName(), SummaryPanelSpecificationType.F_DISPLAY_NAME)));
} else {
box.add(new Label(ID_DISPLAY_NAME, " "));
}
WebMarkupContainer identifierPanel = new WebMarkupContainer(ID_IDENTIFIER_PANEL);
identifierPanel.add(new Label(ID_IDENTIFIER, createLabelModel(getIdentifierPropertyName(), SummaryPanelSpecificationType.F_IDENTIFIER)));
identifierPanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isIdentifierVisible();
}
});
box.add(identifierPanel);
AjaxButton navigateToObject = new AjaxButton(ID_NAVIGATE_TO_OBJECT_BUTTON) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
ObjectReferenceType ort = getReferencedObjectToNavigate();
WebComponentUtil.dispatchToObjectDetailsPage(ort, AbstractSummaryPanel.this, false);
}
};
navigateToObject.add(AttributeAppender.append("title", getReferenceObjectTitleModel()));
navigateToObject.add(new VisibleBehaviour(() -> {
ObjectReferenceType ort = getReferencedObjectToNavigate();
Class refType = !isReferencedObjectNull() ? WebComponentUtil.qnameToClass(AbstractSummaryPanel.this.getPageBase().getPrismContext(), ort.getType()) : null;
return ort != null && refType != null && WebComponentUtil.getObjectDetailsPage(refType) != null;
}));
navigateToObject.setOutputMarkupId(true);
box.add(navigateToObject);
if (getTitleModel() != null) {
box.add(new Label(ID_TITLE, getTitleModel()));
} else if (getTitlePropertyName() != null) {
box.add(new Label(ID_TITLE, createLabelModel(getTitlePropertyName(), SummaryPanelSpecificationType.F_TITLE_1)));
} else {
box.add(new Label(ID_TITLE, " "));
}
if (getTitle2Model() != null) {
box.add(new Label(ID_TITLE2, getTitle2Model()));
} else if (getTitle2PropertyName() != null) {
box.add(new Label(ID_TITLE, createLabelModel(getTitle2PropertyName(), SummaryPanelSpecificationType.F_TITLE_2)));
} else {
Label label = new Label(ID_TITLE2, " ");
label.setVisible(false);
box.add(label);
}
if (getTitle3Model() != null) {
box.add(new Label(ID_TITLE3, getTitle3Model()));
} else if (getTitle3PropertyName() != null) {
box.add(new Label(ID_TITLE, createLabelModel(getTitle3PropertyName(), SummaryPanelSpecificationType.F_TITLE_3)));
} else {
Label label = new Label(ID_TITLE3, " ");
label.setVisible(false);
box.add(label);
}
final IModel<String> parentOrgModel = getParentOrgModel();
Label parentOrgLabel = new Label(ID_ORGANIZATION, parentOrgModel);
parentOrgLabel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return parentOrgModel.getObject() != null;
}
});
box.add(parentOrgLabel);
iconBox = new WebMarkupContainer(ID_ICON_BOX);
box.add(iconBox);
String iconAdditionalCssClass = getIconBoxAdditionalCssClass();
if (StringUtils.isNotEmpty(iconAdditionalCssClass)) {
iconBox.add(new AttributeModifier("class", ICON_BOX_CSS_CLASS + " " + iconAdditionalCssClass));
}
iconBox.add(AttributeModifier.append("style", createArchetypeBackgroundModel()));
Label icon = new Label(ID_ICON, "");
icon.add(AttributeModifier.append("class", getIconCssClass()));
// String archetypeIconCssClass = getArchetypeIconCssClass();
// if (StringUtils.isNotEmpty(archetypeIconCssClass)) {
// icon.add(AttributeModifier.append("class", archetypeIconCssClass));
// icon.add(AttributeModifier.append("style", ARCHETYPE_ICON_FONT_SIZE));
// } else {
// icon.add(AttributeModifier.append("class", getDefaultIconCssClass()));
// }
icon.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getPhotoModel().getObject() == null;
}
});
iconBox.add(icon);
NonCachingImage img = new NonCachingImage(ID_PHOTO, getPhotoModel());
img.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getPhotoModel().getObject() != null;
}
});
iconBox.add(img);
tagBox = new RepeatingView(ID_TAG_BOX);
List<SummaryTag<C>> summaryTags = getSummaryTagComponentList();
// if (getArchetypeSummaryTag() != null) {
summaryTags.add(getArchetypeSummaryTag());
// }
summaryTags.forEach(summaryTag -> {
WebMarkupContainer summaryTagPanel = new WebMarkupContainer(tagBox.newChildId());
summaryTagPanel.setOutputMarkupId(true);
summaryTagPanel.add(summaryTag);
tagBox.add(summaryTagPanel);
});
if (getTagBoxCssClass() != null) {
tagBox.add(new AttributeModifier("class", getTagBoxCssClass()));
}
tagBox.add(new VisibleBehaviour(() -> CollectionUtils.isNotEmpty(summaryTags)));
box.add(tagBox);
}
use of org.apache.wicket.markup.html.image.NonCachingImage in project midpoint by Evolveum.
the class AbstractSummaryPanel method initLayoutCommon.
protected void initLayoutCommon() {
box = new WebMarkupContainer(ID_BOX);
add(box);
box.add(new AttributeModifier("class", BOX_CSS_CLASS + " " + getBoxAdditionalCssClass()));
box.add(new Label(ID_DISPLAY_NAME, new PrismPropertyRealValueFromContainerableModel<>(getModel(), getDisplayNamePropertyName())));
WebMarkupContainer identifierPanel = new WebMarkupContainer(ID_IDENTIFIER_PANEL);
identifierPanel.add(new Label(ID_IDENTIFIER, new PrismPropertyRealValueFromContainerableModel<>(getModel(), getIdentifierPropertyName())));
identifierPanel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return isIdentifierVisible();
}
});
box.add(identifierPanel);
if (getTitlePropertyName() != null) {
box.add(new Label(ID_TITLE, new PrismPropertyRealValueFromContainerableModel<>(getModel(), getTitlePropertyName())));
} else if (getTitleModel() != null) {
box.add(new Label(ID_TITLE, getTitleModel()));
} else {
box.add(new Label(ID_TITLE, " "));
}
if (getTitle2PropertyName() != null) {
box.add(new Label(ID_TITLE2, new PrismPropertyRealValueFromContainerableModel<>(getModel(), getTitle2PropertyName())));
} else if (getTitle2Model() != null) {
box.add(new Label(ID_TITLE2, getTitle2Model()));
} else {
Label label = new Label(ID_TITLE2, " ");
label.setVisible(false);
box.add(label);
}
if (getTitle3PropertyName() != null) {
box.add(new Label(ID_TITLE3, new PrismPropertyRealValueFromContainerableModel<>(getModel(), getTitle3PropertyName())));
} else if (getTitle3Model() != null) {
box.add(new Label(ID_TITLE3, getTitle3Model()));
} else {
Label label = new Label(ID_TITLE3, " ");
label.setVisible(false);
box.add(label);
}
Label parentOrgLabel = new Label(ID_ORGANIZATION, getParentOrgModel());
parentOrgLabel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getParentOrgModel().getObject() != null;
}
});
box.add(parentOrgLabel);
iconBox = new WebMarkupContainer(ID_ICON_BOX);
box.add(iconBox);
if (getIconBoxAdditionalCssClass() != null) {
iconBox.add(new AttributeModifier("class", ICON_BOX_CSS_CLASS + " " + getIconBoxAdditionalCssClass()));
}
Label icon = new Label(ID_ICON, "");
icon.add(new AttributeModifier("class", getIconCssClass()));
icon.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getPhotoModel().getObject() == null;
}
});
iconBox.add(icon);
NonCachingImage img = new NonCachingImage(ID_PHOTO, getPhotoModel());
img.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getPhotoModel().getObject() != null;
}
});
iconBox.add(img);
tagBox = new WebMarkupContainer(ID_TAG_BOX);
if (getTagBoxCssClass() != null) {
tagBox.add(new AttributeModifier("class", getTagBoxCssClass()));
}
box.add(tagBox);
}
use of org.apache.wicket.markup.html.image.NonCachingImage in project midpoint by Evolveum.
the class UserMenuPanel method initLayout.
private void initLayout() {
WebMarkupContainer iconBox = new WebMarkupContainer(ID_ICON_BOX);
add(iconBox);
IModel<AbstractResource> jpegPhotoModel = loadJpegPhotoModel();
NonCachingImage img = new NonCachingImage(ID_PHOTO, jpegPhotoModel);
iconBox.add(img);
Label usernameLink = new Label(ID_USERNAME_LINK, (IModel<String>) this::getShortUserName);
add(usernameLink);
WebMarkupContainer panelIconBox = new WebMarkupContainer(ID_PANEL_ICON_BOX);
add(panelIconBox);
NonCachingImage panelImg = new NonCachingImage(ID_PANEL_PHOTO, jpegPhotoModel);
panelIconBox.add(panelImg);
Label username = new Label(ID_USERNAME, (IModel<String>) this::getShortUserName);
username.setRenderBodyOnly(true);
add(username);
Label focusType = new Label(ID_FOCUS_TYPE, getPageBase().createStringResource("PageTemplate." + getFocusType()));
add(focusType);
MidpointForm<?> form = new MidpointForm<>(ID_LOGOUT_FORM);
form.add(AttributeModifier.replace("action", (IModel<String>) () -> SecurityUtils.getPathForLogoutWithContextPath(getRequest().getContextPath(), getAuthenticatedModule().getPrefix())));
add(form);
WebMarkupContainer csrfField = SecurityUtils.createHiddenInputForCsrf(ID_CSRF_FIELD);
form.add(csrfField);
}
Aggregations