use of org.apache.wicket.model.ResourceModel in project syncope by apache.
the class Security method buildTabList.
private List<ITab> buildTabList() {
final List<ITab> tabs = new ArrayList<>();
tabs.add(new AbstractTab(new ResourceModel("roles")) {
private static final long serialVersionUID = -6815067322125799251L;
@Override
public Panel getPanel(final String panelId) {
return new RoleDirectoryPanel.Builder(getPageReference()) {
private static final long serialVersionUID = -5960765294082359003L;
}.addNewItemPanelBuilder(new RoleWizardBuilder(new RoleTO(), getPageReference()), true).build(panelId);
}
});
tabs.add(new AbstractTab(new ResourceModel("dynRealms")) {
private static final long serialVersionUID = -6815067322125799251L;
@Override
public Panel getPanel(final String panelId) {
return new DynRealmDirectoryPanel.Builder(getPageReference()) {
private static final long serialVersionUID = -5960765294082359003L;
}.build(panelId);
}
});
tabs.add(new AbstractTab(new ResourceModel("applications")) {
private static final long serialVersionUID = -6815067322125799251L;
@Override
public Panel getPanel(final String panelId) {
return new ApplicationDirectoryPanel.Builder(getPageReference()) {
private static final long serialVersionUID = -5960765294082359003L;
}.build(panelId);
}
});
tabs.add(new AbstractTab(new ResourceModel("securityQuestions")) {
private static final long serialVersionUID = -6815067322125799251L;
@Override
public Panel getPanel(final String panelId) {
return new SecurityQuestionsPanel(panelId, getPageReference());
}
});
return tabs;
}
use of org.apache.wicket.model.ResourceModel in project syncope by apache.
the class Reports method buildTabList.
private List<ITab> buildTabList() {
final List<ITab> tabs = new ArrayList<>();
tabs.add(new AbstractTab(new ResourceModel("reports")) {
private static final long serialVersionUID = -6815067322125799251L;
@Override
public Panel getPanel(final String panelId) {
final MultilevelPanel mlp = new MultilevelPanel(panelId);
mlp.setFirstLevel(new ReportDirectoryPanel(mlp, getPageReference()) {
private static final long serialVersionUID = -2195387360323687302L;
@Override
protected void viewTask(final ReportTO reportTO, final AjaxRequestTarget target) {
mlp.next(new StringResourceModel("report.view", this, new Model<>(reportTO)).getObject(), new ReportExecutionDetails(reportTO, getPageReference()), target);
}
});
return mlp;
}
});
tabs.add(new AbstractTab(new ResourceModel("report.templates")) {
private static final long serialVersionUID = -6815067322125799251L;
@Override
public Panel getPanel(final String panelId) {
return new ReportTemplateDirectoryPanel(panelId, getPageReference());
}
});
return tabs;
}
use of org.apache.wicket.model.ResourceModel in project syncope by apache.
the class AjaxPalettePanel method initialize.
private void initialize(final IModel<List<T>> model, final Builder<T> builder) {
setOutputMarkupId(true);
this.palette = new NonI18nPalette<T>("paletteField", model, choicesModel, builder.renderer, 8, builder.allowOrder, builder.allowMoveAll) {
private static final long serialVersionUID = -3074655279011678437L;
@Override
protected Component newAvailableHeader(final String componentId) {
return new Label(componentId, new ResourceModel("palette.available", builder.availableLabel));
}
@Override
protected Component newSelectedHeader(final String componentId) {
return new Label(componentId, new ResourceModel("palette.selected", builder.selectedLabel));
}
@Override
protected Recorder<T> newRecorderComponent() {
return new Recorder<T>("recorder", this) {
private static final long serialVersionUID = -9169109967480083523L;
@Override
public List<T> getUnselectedList() {
final IChoiceRenderer<? super T> renderer = getPalette().getChoiceRenderer();
final Collection<? extends T> choices = getPalette().getChoices();
final List<T> unselected = new ArrayList<>(choices.size());
final List<String> ids = Arrays.asList(getValue().split(","));
choices.forEach(choice -> {
final String choiceId = renderer.getIdValue(choice, 0);
if (!ids.contains(choiceId)) {
unselected.add(choice);
}
});
return unselected;
}
@Override
public List<T> getSelectedList() {
final IChoiceRenderer<? super T> renderer = getPalette().getChoiceRenderer();
final Collection<? extends T> choices = getPalette().getChoices();
final List<T> selected = new ArrayList<>(choices.size());
// reduce number of method calls by building a lookup table
final Map<T, String> idForChoice = new HashMap<>(choices.size());
choices.forEach(choice -> {
idForChoice.put(choice, renderer.getIdValue(choice, 0));
});
final String value = getValue();
int start = value.indexOf(';') + 1;
for (final String id : Strings.split(value.substring(start), ',')) {
for (final T choice : choices) {
final String idValue = idForChoice.get(choice);
if (id.equals(idValue)) {
selected.add(choice);
break;
}
}
}
return selected;
}
};
}
};
add(palette.setOutputMarkupId(true));
final Form<?> form = new Form<>("form");
add(form.setEnabled(builder.filtered).setVisible(builder.filtered));
final AjaxTextFieldPanel filter = new AjaxTextFieldPanel("filter", "filter", queryFilter, false);
filter.hideLabel().setOutputMarkupId(true);
form.add(filter);
form.add(new AjaxSubmitLink("search") {
private static final long serialVersionUID = -1765773642975892072L;
@Override
protected void onAfterSubmit(final AjaxRequestTarget target, final Form<?> form) {
super.onAfterSubmit(target, form);
target.add(palette);
}
});
}
use of org.apache.wicket.model.ResourceModel 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);
}
use of org.apache.wicket.model.ResourceModel in project syncope by apache.
the class SchemaTypePanel method getColumns.
@Override
protected List<IColumn<SchemaTO, String>> getColumns() {
final List<IColumn<SchemaTO, String>> columns = new ArrayList<>();
for (final String field : COL_NAMES.get(schemaType)) {
final Field clazzField = ReflectionUtils.findField(schemaType.getToClass(), field);
if (clazzField != null) {
if (clazzField.getType().equals(Boolean.class) || clazzField.getType().equals(boolean.class)) {
columns.add(new BooleanPropertyColumn<>(new ResourceModel(field), field, field));
} else {
final IColumn<SchemaTO, String> column = new PropertyColumn<SchemaTO, String>(new ResourceModel(field), field, field) {
private static final long serialVersionUID = 3282547854226892169L;
@Override
public String getCssClass() {
String css = super.getCssClass();
if ("key".equals(field)) {
css = StringUtils.isBlank(css) ? "col-xs-1" : css + " col-xs-1";
}
return css;
}
};
columns.add(column);
}
}
}
return columns;
}
Aggregations