use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.
the class PageSecurityQuestions method initQuestionsSection.
private void initQuestionsSection(MidpointForm form) {
WebMarkupContainer questionsContainer = new WebMarkupContainer(ID_INSIDE_FORM);
questionsContainer.setOutputMarkupId(true);
questionsContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return showedQuestions;
}
});
form.add(questionsContainer);
ListView<SecurityQuestionDto> questionsView = new ListView<SecurityQuestionDto>(ID_QUESTIONS, questionsModel) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<SecurityQuestionDto> item) {
SecurityQuestionDto question = item.getModelObject();
Label questionText = new Label(ID_QUESTION_TEXT, new PropertyModel<String>(item.getModel(), "questionText"));
item.add(questionText);
RequiredTextField<String> questionAnswer = new RequiredTextField<>(ID_QUESTION_ANSWER, new PropertyModel<String>(item.getModel(), "questionAnswer"));
questionAnswer.setOutputMarkupId(true);
questionAnswer.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
String answer = generateAnswer();
answerModel.setObject(answer);
target.add(getHiddenAnswer());
}
});
item.add(questionAnswer);
}
};
questionsView.setOutputMarkupId(true);
questionsContainer.add(questionsView);
AjaxButton back = new AjaxButton(ID_BACK_2_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
showedQuestions = false;
questionsModel.setObject(new ArrayList<SecurityQuestionDto>());
getHiddenUsername().getModel().setObject(null);
getHiddenAnswer().getModel().setObject(null);
target.add(getMainForm());
}
};
questionsContainer.add(back);
}
use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.
the class DropdownButtonPanel method initLayout.
private void initLayout() {
WebMarkupContainer buttonContainer = new WebMarkupContainer(ID_BUTTON_CONTAINER);
buttonContainer.setOutputMarkupId(true);
buttonContainer.add(AttributeAppender.append("class", getSpecialButtonClass()));
add(buttonContainer);
Label info = new Label(ID_INFO, new PropertyModel<>(getModel(), DropdownButtonDto.F_INFO));
info.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject() != null && getModelObject().getInfo() != null;
}
});
buttonContainer.add(info);
Label label = new Label(ID_LABEL, new PropertyModel<>(getModel(), DropdownButtonDto.F_LABEL));
label.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject() != null && getModelObject().getLabel() != null;
}
});
label.add(AttributeAppender.append("class", getSpecialLabelClass()));
buttonContainer.add(label);
WebMarkupContainer icon = new WebMarkupContainer(ID_ICON);
icon.add(AttributeModifier.append("class", new PropertyModel<>(getModel(), DropdownButtonDto.F_ICON)));
icon.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject() != null && getModelObject().getIcon() != null;
}
});
buttonContainer.add(icon);
WebMarkupContainer caret = new WebMarkupContainer(ID_CARET);
caret.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return visibleCaret();
}
});
buttonContainer.add(caret);
WebMarkupContainer dropdownMenuContainer = new WebMarkupContainer(ID_DROPDOWN_MENU);
dropdownMenuContainer.setOutputMarkupId(true);
dropdownMenuContainer.add(AttributeAppender.append("class", getSpecialDropdownMenuClass()));
add(dropdownMenuContainer);
ListView<InlineMenuItem> li = new ListView<>(ID_MENU_ITEM, new PropertyModel<>(getModel(), DropdownButtonDto.F_ITEMS)) {
@Override
protected void populateItem(ListItem<InlineMenuItem> item) {
populateMenuItem(ID_MENU_ITEM_BODY, item);
}
};
dropdownMenuContainer.add(li);
}
use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.
the class DisplayNamePanel method initLayout.
private void initLayout() {
WebMarkupContainer typeImage = createTypeImagePanel(ID_TYPE_IMAGE);
add(typeImage);
Label name = new Label(ID_DISPLAY_NAME, createHeaderModel());
name.setOutputMarkupId(true);
add(name);
Label identifier = new Label(ID_IDENTIFIER, createIdentifierModel());
identifier.setOutputMarkupId(true);
identifier.add(new VisibleBehaviour(() -> isIdentifierVisible()));
add(identifier);
AjaxButton navigateToObject = new AjaxButton(ID_NAVIGATE_TO_OBJECT) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
if (DisplayNamePanel.this.getModelObject() instanceof ObjectType) {
ObjectType o = (ObjectType) DisplayNamePanel.this.getModelObject();
ObjectReferenceType ort = new ObjectReferenceType();
ort.setOid(o.getOid());
ort.setType(WebComponentUtil.classToQName(DisplayNamePanel.this.getPageBase().getPrismContext(), o.getClass()));
WebComponentUtil.dispatchToObjectDetailsPage(ort, DisplayNamePanel.this, false);
}
}
};
navigateToObject.add(new VisibleBehaviour(() -> hasDetailsPage()));
navigateToObject.setOutputMarkupId(true);
add(navigateToObject);
Label relation = new Label(ID_RELATION, Model.of(getRelationLabel()));
relation.setOutputMarkupId(true);
relation.add(new VisibleBehaviour(() -> isRelationVisible()));
add(relation);
IModel<String> kindIntentLabelModel = getKindIntentLabelModel();
Label kindIntent = new Label(ID_KIND_INTENT, kindIntentLabelModel);
kindIntent.setOutputMarkupId(true);
kindIntent.add(new VisibleBehaviour(() -> isKindIntentVisible(kindIntentLabelModel)));
add(kindIntent);
ListView<String> descriptionLabels = new ListView<String>(ID_DESCRIPTION_LABELS, getDescriptionLabelsModel()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<String> item) {
item.add(new Label(ID_DESCRIPTION, item.getModel()));
}
};
add(descriptionLabels);
}
use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.
the class FocusProjectionsPanel method initLayout.
protected void initLayout() {
IModel<Integer> deadShadows = new ReadOnlyModel<>(this::countDeadShadows);
Label label = new Label(ID_DEAD_SHADOWS, deadShadows);
label.add(new VisibleBehaviour(() -> deadShadows.getObject() > 0));
add(label);
MultivalueContainerListPanelWithDetailsPanel<ShadowType> multivalueContainerListPanel = new MultivalueContainerListPanelWithDetailsPanel<ShadowType>(ID_SHADOW_TABLE, ShadowType.class, getPanelConfiguration()) {
private static final long serialVersionUID = 1L;
@Override
protected ISelectableDataProvider<ShadowType, PrismContainerValueWrapper<ShadowType>> createProvider() {
return new ProjectionsListProvider(FocusProjectionsPanel.this, getSearchModel(), loadShadowModel()) {
@Override
protected PageStorage getPageStorage() {
PageStorage storage = getSession().getSessionStorage().getPageStorageMap().get(SessionStorage.KEY_FOCUS_PROJECTION_TABLE);
if (storage == null) {
storage = getSession().getSessionStorage().initPageStorage(SessionStorage.KEY_FOCUS_PROJECTION_TABLE);
}
return storage;
}
};
}
@Override
protected void newItemPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation) {
List<QName> supportedTypes = Arrays.asList(ResourceType.COMPLEX_TYPE);
PageBase pageBase = FocusProjectionsPanel.this.getPageBase();
ObjectBrowserPanel<ResourceType> resourceSelectionPanel = new ObjectBrowserPanel<>(pageBase.getMainPopupBodyId(), ResourceType.class, supportedTypes, true, pageBase) {
private static final long serialVersionUID = 1L;
@Override
protected void addPerformed(AjaxRequestTarget target, QName type, List<ResourceType> selected) {
FocusProjectionsPanel.this.addSelectedAccountPerformed(target, selected);
target.add(getPageBase().getFeedbackPanel());
}
};
resourceSelectionPanel.setOutputMarkupId(true);
pageBase.showMainPopup(resourceSelectionPanel, target);
}
@Override
protected boolean isCreateNewObjectVisible() {
PrismObjectDefinition<F> def = FocusProjectionsPanel.this.getObjectWrapperModel().getObject().getObject().getDefinition();
PrismReferenceDefinition ref = def.findReferenceDefinition(UserType.F_LINK_REF);
return (ref.canRead() && ref.canAdd());
}
@Override
protected IModel<PrismContainerWrapper<ShadowType>> getContainerModel() {
return null;
}
@Override
protected TableId getTableId() {
return TableId.FOCUS_PROJECTION_TABLE;
}
@Override
protected List<IColumn<PrismContainerValueWrapper<ShadowType>, String>> createDefaultColumns() {
return initBasicColumns();
}
@Override
protected List<InlineMenuItem> createInlineMenu() {
return createShadowMenu();
}
@Override
public void editItemPerformed(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<ShadowType>> rowModel, List<PrismContainerValueWrapper<ShadowType>> listItems) {
loadShadowIfNeeded(rowModel, target);
if (listItems != null) {
listItems.forEach(value -> {
if (((ShadowWrapper) value.getParent()).isLoadWithNoFetch()) {
loadFullShadow((PrismObjectValueWrapper) value, target);
}
});
}
super.editItemPerformed(target, rowModel, listItems);
}
@Override
protected Search createSearch(Class<ShadowType> type) {
Search search = super.createSearch(type);
PropertySearchItem<Boolean> defaultDeadItem = search.findPropertySearchItem(ShadowType.F_DEAD);
if (defaultDeadItem != null) {
defaultDeadItem.setVisible(false);
}
addDeadSearchItem(search);
return search;
}
@Override
protected List<SearchItemDefinition> initSearchableItems(PrismContainerDefinition<ShadowType> containerDef) {
List<SearchItemDefinition> defs = new ArrayList<>();
SearchFactory.addSearchRefDef(containerDef, ShadowType.F_RESOURCE_REF, defs, AreaCategoryType.ADMINISTRATION, getPageBase());
SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_NAME, defs);
SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_INTENT, defs);
SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_KIND, defs);
return defs;
}
@Override
protected MultivalueContainerDetailsPanel<ShadowType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<ShadowType>> item) {
return FocusProjectionsPanel.this.getMultivalueContainerDetailsPanel(item);
}
};
add(multivalueContainerListPanel);
setOutputMarkupId(true);
}
use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.
the class NotificationConfigTabPanel method initLayout.
protected void initLayout() {
PrismPropertyWrapperModel<NotificationConfigurationType, MailConfigurationType> mailConfig = PrismPropertyWrapperModel.fromContainerWrapper(getModel(), NotificationConfigurationType.F_MAIL);
add(createHeader(ID_MAIL_CONFIG_HEADER, mailConfig));
PropertyModel<MailConfigurationType> mailConfigType = new ItemRealValueModel<>(new PropertyModel<>(mailConfig, "values[0]"));
if (mailConfigType.getObject() == null) {
// TODO: This fails for deprecated "mail" element if it's missing, so it's not deprecated yet.
// Reason: mailConfig.getObject() == null
// Root cause: ItemWrapperFactoryImpl.skipCreateWrapper() has a code to skip empty & deprecated stuff.
// The object for mailConfig can't be created with createItemWrapper either as it would be skipped again and return null.
// Let's create new GUI for the new transport configuration first without to-be deprecated components.
mailConfigType.setObject(new MailConfigurationType());
}
add(new TextFormGroup(ID_DEFAULT_FROM, new PropertyModel<>(mailConfigType, "defaultFrom"), createStringResource(mailConfig.getObject().getTypeName().getLocalPart() + ".defaultFrom"), "", getInputCssClass(), false, true));
add(new TextFormGroup(ID_REDIRECT_TO_FILE, new PropertyModel<>(mailConfigType, "redirectToFile"), createStringResource(mailConfig.getObject().getTypeName().getLocalPart() + ".redirectToFile"), "", getInputCssClass(), false, true));
add(new TextFormGroup(ID_LOG_TO_FILE, new PropertyModel<>(mailConfigType, "logToFile"), createStringResource(mailConfig.getObject().getTypeName().getLocalPart() + ".logToFile"), "", getInputCssClass(), false, true));
add(new TriStateFormGroup(ID_DEBUG, new PropertyModel<>(mailConfigType, "debug"), createStringResource(mailConfig.getObject().getTypeName().getLocalPart() + ".debug"), "", getInputCssClass(), false, true));
add(createHeader(ID_MAIL_SERVER_CONFIG_HEADER, MailServerConfigurationType.COMPLEX_TYPE.getLocalPart() + ".details"));
add(initServersTable(mailConfigType));
add(createHeader(ID_FILE_CONFIG_HEADER, FileConfigurationType.COMPLEX_TYPE.getLocalPart() + ".details"));
IModel<PrismPropertyWrapper<FileConfigurationType>> fileConfig = PrismPropertyWrapperModel.fromContainerWrapper(getModel(), NotificationConfigurationType.F_FILE);
WebMarkupContainer files = new WebMarkupContainer(ID_FILE_CONFIG);
files.setOutputMarkupId(true);
add(files);
ListView<PrismPropertyValueWrapper<FileConfigurationType>> values = new ListView<>("values", new PropertyModel<>(fileConfig, "values")) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<PrismPropertyValueWrapper<FileConfigurationType>> item) {
FileConfigurationType fileConfigType = item.getModelObject().getRealValue();
item.add(createHeader(ID_VALUE_HEADER, fileConfigType == null || fileConfigType.getName() == null || fileConfigType.getName().isEmpty() ? (FileConfigurationType.COMPLEX_TYPE.getLocalPart() + ".details") : fileConfigType.getName()));
AjaxLink<Void> removeButton = new AjaxLink<>(ID_REMOVE_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
((PrismPropertyValue<FileConfigurationType>) item.getModelObject()).setValue(null);
item.getParent().remove(item.getId());
target.add(files);
}
};
item.add(removeButton);
TextFormGroup name = new TextFormGroup(ID_FILE_NAME, fileConfigType != null ? new PropertyModel<>(fileConfigType, "name") : Model.of(""), createStringResource(fileConfigType == null ? "" : (fileConfigType.COMPLEX_TYPE.getLocalPart() + ".name")), "", getInputCssClass(), false, true);
name.getField().add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
item.getModelObject().getRealValue().setName(name.getModelObject());
}
});
item.add(name);
TextFormGroup file = new TextFormGroup(ID_FILE_PATH, fileConfigType != null ? new PropertyModel<>(fileConfigType, "file") : Model.of(""), createStringResource(fileConfigType == null ? "" : (fileConfigType.COMPLEX_TYPE.getLocalPart() + ".file")), "", getInputCssClass(), false, true);
file.getField().add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
item.getModelObject().getRealValue().setFile(file.getModelObject());
}
});
item.add(file);
item.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return fileConfigType != null;
}
});
}
};
values.add(new AttributeModifier("class", "col-md-6"));
values.setReuseItems(true);
files.add(values);
AjaxLink<Void> addButton = new AjaxLink<>(ID_ADD_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
PrismPropertyWrapper<FileConfigurationType> propertyWrapper = fileConfig.getObject();
PrismPropertyValue<FileConfigurationType> newValue = getPrismContext().itemFactory().createPropertyValue();
PrismPropertyValueWrapper<FileConfigurationType> newValueWrapper = WebPrismUtil.createNewValueWrapper(propertyWrapper, newValue, getPageBase(), target);
// TODO: do we really need to set real value?? why??
newValueWrapper.setRealValue(new FileConfigurationType());
target.add(files);
}
};
add(addButton);
}
Aggregations