use of org.apache.wicket.markup.repeater.RepeatingView in project gitblit by gitblit.
the class BasePage method addBottomScriptInline.
/**
* Adds a HTML script element containing the given code.
*
* @param code
* inline script code
*/
protected void addBottomScriptInline(String code) {
RepeatingView bottomScripts = getBottomScriptContainer();
Label script = new Label(bottomScripts.newChildId(), "<script type='text/javascript'>/*<![CDATA[*/\n" + code + "\n//]]>\n</script>\n");
bottomScripts.add(script.setEscapeModelStrings(false).setRenderBodyOnly(true));
}
use of org.apache.wicket.markup.repeater.RepeatingView in project midpoint by Evolveum.
the class DynamicFieldGroupPanel method initLayout.
private void initLayout(String groupName, List<AbstractFormItemType> formItems, Form<?> mainForm) {
Label header = new Label(ID_HEADER, groupName);
add(header);
RepeatingView itemView = new RepeatingView(ID_PROPERTY);
add(itemView);
int i = 0;
for (AbstractFormItemType formItem : formItems) {
if (formItem instanceof FormFieldGroupType) {
DynamicFieldGroupPanel<O> dynamicFieldGroupPanel = new DynamicFieldGroupPanel<O>(itemView.newChildId(), formItem.getName(), getModel(), FormTypeUtil.getFormItems(((FormFieldGroupType) formItem).getFormItems()), mainForm, getPageBase());
dynamicFieldGroupPanel.setOutputMarkupId(true);
itemView.add(dynamicFieldGroupPanel);
continue;
}
ItemWrapper itemWrapper = createItemWrapper(formItem, getObjectWrapper());
if (itemWrapper instanceof ContainerWrapper) {
PrismContainerPanel containerPanel = new PrismContainerPanel(itemView.newChildId(), Model.of((ContainerWrapper) itemWrapper), true, mainForm, getPageBase());
containerPanel.setOutputMarkupId(true);
itemView.add(containerPanel);
} else {
PrismPropertyPanel<?> propertyPanel = new PrismPropertyPanel<>(itemView.newChildId(), Model.of(itemWrapper), mainForm, getPageBase());
propertyPanel.setOutputMarkupId(true);
propertyPanel.add(AttributeModifier.append("class", ((i % 2) == 0) ? "" : "stripe"));
itemView.add(propertyPanel);
}
i++;
}
}
use of org.apache.wicket.markup.repeater.RepeatingView in project midpoint by Evolveum.
the class OrgMemberPanel method createManagerContainer.
private WebMarkupContainer createManagerContainer() {
WebMarkupContainer managerContainer = new WebMarkupContainer(ID_CONTAINER_MANAGER);
managerContainer.setOutputMarkupId(true);
managerContainer.setOutputMarkupPlaceholderTag(true);
RepeatingView view = new RepeatingView(ID_MANAGER_TABLE);
view.setOutputMarkupId(true);
ObjectQuery managersQuery = createManagerQuery();
OperationResult searchManagersResult = new OperationResult(OPERATION_SEARCH_MANAGERS);
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(FocusType.F_JPEG_PHOTO, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
List<PrismObject<FocusType>> managers = WebModelServiceUtils.searchObjects(FocusType.class, managersQuery, options, searchManagersResult, getPageBase());
Task task = getPageBase().createSimpleTask(OPERATION_LOAD_MANAGERS);
for (PrismObject<FocusType> manager : managers) {
ObjectWrapper<FocusType> managerWrapper = ObjectWrapperUtil.createObjectWrapper(WebComponentUtil.getEffectiveName(manager, RoleType.F_DISPLAY_NAME), "", manager, ContainerStatus.MODIFYING, task, getPageBase());
WebMarkupContainer managerMarkup = new WebMarkupContainer(view.newChildId());
AjaxLink<String> link = new AjaxLink<String>(ID_EDIT_MANAGER) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
FocusSummaryPanel<FocusType> summary = (FocusSummaryPanel<FocusType>) getParent().get(ID_MANAGER_SUMMARY);
detailsPerformed(target, summary.getModelObject());
}
};
link.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
boolean isVisible = false;
try {
isVisible = getPageBase().getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_READ_ACTION_URL, AuthorizationPhaseType.REQUEST, managerWrapper.getObject(), null, null, null);
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Failed to check authorization for #read operation on object " + managerWrapper.getObject(), ex);
}
return isVisible;
}
});
if (manager.getCompileTimeClass().equals(UserType.class)) {
managerMarkup.add(new UserSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<UserType>>((ObjectWrapper) managerWrapper)));
} else if (manager.getCompileTimeClass().equals(RoleType.class)) {
managerMarkup.add(new RoleSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<RoleType>>((ObjectWrapper) managerWrapper)));
} else if (manager.getCompileTimeClass().equals(OrgType.class)) {
managerMarkup.add(new OrgSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<OrgType>>((ObjectWrapper) managerWrapper)));
} else if (manager.getCompileTimeClass().equals(ServiceType.class)) {
managerMarkup.add(new ServiceSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<ServiceType>>((ObjectWrapper) managerWrapper)));
}
link.setOutputMarkupId(true);
managerMarkup.setOutputMarkupId(true);
managerMarkup.add(link);
view.add(managerMarkup);
AjaxButton removeManager = new AjaxButton(ID_REMOVE_MANAGER) {
@Override
public void onClick(AjaxRequestTarget target) {
FocusSummaryPanel<FocusType> summary = (FocusSummaryPanel<FocusType>) getParent().get(ID_MANAGER_SUMMARY);
removeManagerPerformed(summary.getModelObject(), target);
getParent().setVisible(false);
target.add(OrgMemberPanel.this);
}
};
removeManager.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
boolean isVisible = false;
try {
isVisible = getPageBase().getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_UNASSIGN_ACTION_URL, null, managerWrapper.getObject(), null, getModelObject().asPrismObject(), null);
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Failed to check authorization for #unassign operation on object " + managerWrapper.getObject(), ex);
}
return isVisible;
}
});
removeManager.setOutputMarkupId(true);
managerMarkup.add(removeManager);
AjaxButton deleteManager = new AjaxButton(ID_DELETE_MANAGER) {
@Override
public void onClick(AjaxRequestTarget target) {
FocusSummaryPanel<FocusType> summary = (FocusSummaryPanel<FocusType>) getParent().get(ID_MANAGER_SUMMARY);
deleteManagerPerformed(summary.getModelObject(), this, target);
}
};
deleteManager.setOutputMarkupId(true);
deleteManager.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
boolean isVisible = false;
try {
isVisible = getPageBase().getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_DELETE_ACTION_URL, null, managerWrapper.getObject(), null, null, null);
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Failed to check authorization for #delete operation on object " + managerWrapper.getObject(), ex);
}
return isVisible;
}
});
managerMarkup.add(deleteManager);
}
managerContainer.add(view);
InlineMenu menupanel = new InlineMenu(ID_MANAGER_MENU, new Model<Serializable>((Serializable) createManagersHeaderInlineMenu()));
add(menupanel);
menupanel.setOutputMarkupId(true);
managerContainer.add(menupanel);
return managerContainer;
}
use of org.apache.wicket.markup.repeater.RepeatingView in project midpoint by Evolveum.
the class MultiButtonTable method initLayout.
private void initLayout() {
itemsCount = getModel() != null ? (getModel().getObject() != null ? getModel().getObject().size() : 0) : 0;
RepeatingView rows = new RepeatingView(ID_ROW);
rows.setOutputMarkupId(true);
if (itemsCount > 0 && itemsPerRow > 0) {
int index = 0;
List<AssignmentEditorDto> assignmentsList = getModelObject();
long rowCount = itemsCount % itemsPerRow == 0 ? (itemsCount / itemsPerRow) : (itemsCount / itemsPerRow + 1);
for (int rowNumber = 0; rowNumber < rowCount; rowNumber++) {
WebMarkupContainer rowContainer = new WebMarkupContainer(rows.newChildId());
rows.add(rowContainer);
RepeatingView columns = new RepeatingView(ID_CELL);
columns.setOutputMarkupId(true);
rowContainer.add(columns);
for (int colNumber = 0; colNumber < itemsPerRow; colNumber++) {
WebMarkupContainer colContainer = new WebMarkupContainer(columns.newChildId());
columns.add(colContainer);
WebMarkupContainer itemButtonContainer = new WebMarkupContainer(ID_ITEM_BUTTON_CONTAINER);
itemButtonContainer.setOutputMarkupId(true);
itemButtonContainer.add(new AttributeAppender("class", getBackgroundClass(assignmentsList.get(index))));
colContainer.add(itemButtonContainer);
populateCell(itemButtonContainer, assignmentsList.get(index));
index++;
if (index >= assignmentsList.size()) {
break;
}
}
}
}
add(rows);
}
use of org.apache.wicket.markup.repeater.RepeatingView in project midpoint by Evolveum.
the class MultiButtonPanel method initLayout.
protected void initLayout() {
RepeatingView buttons = new RepeatingView(ID_BUTTONS);
add(buttons);
for (int id = 0; id < numberOfButtons; id++) {
final int finalId = getButtonId(id);
AjaxButton button = new AjaxButton(String.valueOf(finalId), createStringResource(getCaption(finalId))) {
@Override
public void onClick(AjaxRequestTarget target) {
clickPerformed(finalId, target, MultiButtonPanel.this.getModel());
}
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE);
}
@Override
public boolean isEnabled() {
return MultiButtonPanel.this.isButtonEnabled(finalId, MultiButtonPanel.this.getModel());
}
@Override
public boolean isVisible() {
return MultiButtonPanel.this.isButtonVisible(finalId, MultiButtonPanel.this.getModel());
}
};
button.add(new AttributeAppender("class", getButtonCssClass(finalId)));
button.add(new AttributeAppender("title", getButtonTitle(finalId)));
buttons.add(button);
buttons.add(new Label("label" + finalId, " "));
}
}
Aggregations