use of de.agilecoders.wicket.core.markup.html.bootstrap.components.PopoverConfig in project syncope by apache.
the class FieldPanel method setTitle.
public FieldPanel<T> setTitle(final String title, final boolean html) {
this.title = title;
field.add(new PopoverBehavior(Model.<String>of(), title == null ? Model.<String>of() : Model.of(title), new PopoverConfig().withHtml(html).withHoverTrigger().withPlacement(index.getObject() != null && index.getObject() == 0 ? TooltipConfig.Placement.bottom : this instanceof AjaxCheckBoxPanel ? TooltipConfig.Placement.right : TooltipConfig.Placement.top)));
return this;
}
use of de.agilecoders.wicket.core.markup.html.bootstrap.components.PopoverConfig in project hale by halestudio.
the class TemplatePage method addControls.
@SuppressWarnings("serial")
@Override
protected void addControls(boolean loggedIn) {
super.addControls(loggedIn);
StringValue idParam = getPageParameters().get(0);
if (!idParam.isNull() && !idParam.isEmpty()) {
String templateId = idParam.toString();
OrientGraph graph = DatabaseHelper.getGraph();
try {
Template template = null;
try {
template = Template.getByTemplateId(graph, templateId);
} catch (NonUniqueResultException e) {
log.error("Duplicate template representation: " + templateId, e);
}
if (template != null) {
// name
Label name = new Label("name", template.getName());
add(name);
// download
String href = TemplateLocations.getTemplateDownloadUrl(templateId);
ExternalLink download = new ExternalLink("download", href);
add(download);
// project location
WebMarkupContainer project = new WebMarkupContainer("project");
project.add(AttributeModifier.replace("value", TemplateLocations.getTemplateProjectUrl(scavenger, templateId)));
add(project);
// author
Label author = new Label("author", template.getAuthor());
add(author);
// edit-buttons container
WebMarkupContainer editButtons = new WebMarkupContainer("edit-buttons");
editButtons.setVisible(false);
add(editButtons);
// deleteDialog container
WebMarkupContainer deleteDialog = new WebMarkupContainer("deleteDialog");
deleteDialog.setVisible(false);
add(deleteDialog);
// user
String userName;
Vertex v = template.getV();
boolean showEditPart = UserUtil.isAdmin();
Iterator<Vertex> owners = v.getVertices(Direction.OUT, "owner").iterator();
if (owners.hasNext()) {
User user = new User(owners.next(), graph);
userName = UserUtil.getDisplayName(user);
showEditPart = loggedIn && UserUtil.getLogin().equals(user.getLogin());
} else {
userName = "Unregistered user";
}
// edit buttons
if (showEditPart) {
editButtons.setVisible(true);
deleteDialog.setVisible(true);
// edit
editButtons.add(new BookmarkablePageLink<>("edit", EditTemplatePage.class, new PageParameters().set(0, templateId)));
// update
editButtons.add(new BookmarkablePageLink<>("update", UpdateTemplatePage.class, new PageParameters().set(0, templateId)));
// delete
deleteDialog.add(new DeleteTemplateLink("delete", templateId));
}
Label user = new Label("user", userName);
add(user);
// description
String descr = template.getDescription();
String htmlDescr = null;
if (descr == null || descr.isEmpty()) {
descr = "No description for the project template available.";
} else {
// convert markdown to
htmlDescr = new PegDownProcessor(Extensions.AUTOLINKS | Extensions.SUPPRESS_ALL_HTML | Extensions.HARDWRAPS | Extensions.SMARTYPANTS).markdownToHtml(descr);
}
// description in pre
Label description = new Label("description", descr);
description.setVisible(htmlDescr == null);
add(description);
// description in div
Label htmlDescription = new Label("html-description", htmlDescr);
htmlDescription.setVisible(htmlDescr != null);
htmlDescription.setEscapeModelStrings(false);
add(htmlDescription);
// invalid
WebMarkupContainer statusInvalid = new WebMarkupContainer("invalid");
statusInvalid.setVisible(!template.isValid());
add(statusInvalid);
// resources
ResourcesPanel resources = new ResourcesPanel("resources", templateId);
add(resources);
// project popover
WebMarkupContainer projectPopover = new WebMarkupContainer("project-popover");
projectPopover.add(new HTMLPopoverBehavior(Model.of("Load template in HALE"), new PopoverConfig().withPlacement(Placement.bottom)) {
@Override
public Component newBodyComponent(String markupId) {
return new ProjectURLPopover(markupId);
}
});
add(projectPopover);
} else {
throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_NOT_FOUND, "Template not found.");
}
} finally {
graph.shutdown();
}
} else
throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_BAD_REQUEST, "Template identifier must be specified.");
}
Aggregations