use of de.agilecoders.wicket.core.markup.html.bootstrap.image.IconType in project syncope by apache.
the class RealmChoicePanel method reloadRealmTree.
public final void reloadRealmTree() {
final Label realmLabel = new Label("realmLabel", new Model<>());
realmLabel.setOutputMarkupId(true);
container.addOrReplace(realmLabel);
if (model.getObject().getFullPath().startsWith(SyncopeConstants.ROOT_REALM)) {
realmLabel.setDefaultModel(new ResourceModel("realmLabel", "Realm"));
} else {
realmLabel.setDefaultModel(new ResourceModel("dynRealmLabel", "Dynamic Realm"));
}
final Label label = new Label("realm", model.getObject().getFullPath());
label.setOutputMarkupId(true);
container.addOrReplace(label);
final DropDownButton realms = new DropDownButton("realms", new ResourceModel("select", ""), new Model<IconType>(GlyphIconType.folderopen)) {
private static final long serialVersionUID = -5560086780455361131L;
@Override
protected List<AbstractLink> newSubMenuButtons(final String buttonMarkupId) {
RealmChoicePanel.this.links.clear();
RealmChoicePanel.this.links.add(new BootstrapAjaxLink<RealmTO>(ButtonList.getButtonMarkupId(), new Model<RealmTO>(), Buttons.Type.Link, new ResourceModel("realms", "Realms")) {
private static final long serialVersionUID = -7978723352517770744L;
@Override
public void onClick(final AjaxRequestTarget target) {
}
@Override
public boolean isEnabled() {
return false;
}
@Override
protected void onComponentTag(final ComponentTag tag) {
tag.put("class", "panel box box-primary box-header with-border");
tag.put("style", "margin: 20px 5px 0px 5px; width: 90%");
}
});
for (Pair<String, RealmTO> link : realmTree.getObject()) {
final RealmTO realmTO = link.getValue();
RealmChoicePanel.this.links.add(new BootstrapAjaxLink<RealmTO>(ButtonList.getButtonMarkupId(), Model.of(realmTO), Buttons.Type.Link, new Model<>(link.getKey())) {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
model.setObject(realmTO);
label.setDefaultModelObject(model.getObject().getFullPath());
realmLabel.setDefaultModel(new ResourceModel("realmLabel", "Realm"));
target.add(label);
send(pageRef.getPage(), Broadcast.EXACT, new ChosenRealm<>(realmTO, target));
}
@Override
public boolean isEnabled() {
return availableRealms.stream().anyMatch(availableRealm -> realmTO.getFullPath().startsWith(availableRealm));
}
});
}
if (!dynRealmTree.getObject().isEmpty()) {
RealmChoicePanel.this.links.add(new BootstrapAjaxLink<RealmTO>(ButtonList.getButtonMarkupId(), new Model<RealmTO>(), Buttons.Type.Link, new ResourceModel("dynrealms", "Dynamic Realms")) {
private static final long serialVersionUID = -7978723352517770744L;
@Override
public void onClick(final AjaxRequestTarget target) {
}
@Override
public boolean isEnabled() {
return false;
}
@Override
protected void onComponentTag(final ComponentTag tag) {
tag.put("class", "panel box box-primary box-header with-border");
tag.put("style", "margin: 20px 5px 0px 5px; width: 90%");
}
});
for (DynRealmTO dynRealmTO : dynRealmTree.getObject()) {
final RealmTO realmTO = new RealmTO();
realmTO.setKey(dynRealmTO.getKey());
realmTO.setName(dynRealmTO.getKey());
realmTO.setFullPath(dynRealmTO.getKey());
RealmChoicePanel.this.links.add(new BootstrapAjaxLink<RealmTO>(ButtonList.getButtonMarkupId(), new Model<RealmTO>(), Buttons.Type.Link, new Model<>(realmTO.getKey())) {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
model.setObject(realmTO);
label.setDefaultModelObject(realmTO.getKey());
realmLabel.setDefaultModel(new ResourceModel("dynRealmLabel", "Dynamic Realm"));
target.add(label);
send(pageRef.getPage(), Broadcast.EXACT, new ChosenRealm<>(realmTO, target));
}
@Override
public boolean isEnabled() {
return availableRealms.stream().anyMatch(availableRealm -> {
return SyncopeConstants.ROOT_REALM.equals(availableRealm) || realmTO.getKey().equals(availableRealm);
});
}
});
}
}
return RealmChoicePanel.this.links;
}
};
realms.setOutputMarkupId(true);
realms.setAlignment(AlignmentBehavior.Alignment.RIGHT);
realms.setType(Buttons.Type.Menu);
MetaDataRoleAuthorizationStrategy.authorize(realms, ENABLE, StandardEntitlement.REALM_LIST);
container.addOrReplace(realms);
}
Aggregations