use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.
the class MultiValueAutoCompleteTextPanel method initLayout.
private void initLayout(final boolean inputEnabled, final NonEmptyModel<Boolean> readOnlyModel) {
WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER);
placeholderContainer.setOutputMarkupPlaceholderTag(true);
placeholderContainer.setOutputMarkupPlaceholderTag(true);
placeholderContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModel().getObject().isEmpty();
}
});
add(placeholderContainer);
AjaxLink placeholderAdd = new AjaxLink(ID_PLACEHOLDER_ADD) {
@Override
public void onClick(AjaxRequestTarget target) {
addValuePerformed(target);
}
};
placeholderAdd.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (buttonsDisabled()) {
return " " + CSS_DISABLED;
}
return "";
}
}));
placeholderAdd.setOutputMarkupId(true);
placeholderAdd.setOutputMarkupPlaceholderTag(true);
placeholderAdd.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
placeholderContainer.add(placeholderAdd);
ListView repeater = new ListView<T>(ID_REPEATER, getModel()) {
@Override
protected void populateItem(final ListItem<T> item) {
AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
autoCompleteSettings.setShowListOnEmptyInput(true);
autoCompleteSettings.setMaxHeightInPx(200);
AutoCompleteTextField<String> autoCompleteEditor = new AutoCompleteTextField<String>(ID_TEXT, createTextModel(item.getModel()), autoCompleteSettings) {
@Override
protected Iterator<String> getChoices(String input) {
return createAutoCompleteObjectList(input);
}
};
autoCompleteEditor.add(createAutoCompleteValidator());
autoCompleteEditor.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
item.add(autoCompleteEditor);
autoCompleteEditor.add(AttributeAppender.replace("placeholder", createEmptyItemPlaceholder()));
if (!inputEnabled) {
autoCompleteEditor.add(new AttributeModifier("disabled", "disabled"));
}
item.add(autoCompleteEditor);
WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
item.add(buttonGroup);
initButtons(buttonGroup, item, readOnlyModel);
}
};
repeater.setOutputMarkupId(true);
repeater.setOutputMarkupPlaceholderTag(true);
repeater.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !getModel().getObject().isEmpty();
}
});
add(repeater);
}
use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.
the class NavigatorPanel method initLast.
private void initLast() {
WebMarkupContainer last = new WebMarkupContainer(ID_LAST);
last.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return isLastEnabled() ? "" : "disabled";
}
}));
add(last);
AjaxLink lastLink = new AjaxLink(ID_LAST_LINK) {
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
}
@Override
public void onClick(AjaxRequestTarget target) {
lastPerformed(target);
}
};
lastLink.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return BooleanUtils.isTrue(showPageListingModel.getObject()) && isLastEnabled();
}
});
last.add(lastLink);
}
use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.
the class AbstractSummaryPanel method initLayoutCommon.
protected void initLayoutCommon() {
box = new WebMarkupContainer(ID_BOX);
add(box);
box.add(new AttributeModifier("class", BOX_CSS_CLASS + " " + getBoxAdditionalCssClass()));
box.add(new Label(ID_DISPLAY_NAME, new PrismPropertyRealValueFromContainerableModel<>(getModel(), getDisplayNamePropertyName())));
WebMarkupContainer identifierPanel = new WebMarkupContainer(ID_IDENTIFIER_PANEL);
identifierPanel.add(new Label(ID_IDENTIFIER, new PrismPropertyRealValueFromContainerableModel<>(getModel(), getIdentifierPropertyName())));
identifierPanel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return isIdentifierVisible();
}
});
box.add(identifierPanel);
if (getTitlePropertyName() != null) {
box.add(new Label(ID_TITLE, new PrismPropertyRealValueFromContainerableModel<>(getModel(), getTitlePropertyName())));
} else if (getTitleModel() != null) {
box.add(new Label(ID_TITLE, getTitleModel()));
} else {
box.add(new Label(ID_TITLE, " "));
}
if (getTitle2PropertyName() != null) {
box.add(new Label(ID_TITLE2, new PrismPropertyRealValueFromContainerableModel<>(getModel(), getTitle2PropertyName())));
} else if (getTitle2Model() != null) {
box.add(new Label(ID_TITLE2, getTitle2Model()));
} else {
Label label = new Label(ID_TITLE2, " ");
label.setVisible(false);
box.add(label);
}
if (getTitle3PropertyName() != null) {
box.add(new Label(ID_TITLE3, new PrismPropertyRealValueFromContainerableModel<>(getModel(), getTitle3PropertyName())));
} else if (getTitle3Model() != null) {
box.add(new Label(ID_TITLE3, getTitle3Model()));
} else {
Label label = new Label(ID_TITLE3, " ");
label.setVisible(false);
box.add(label);
}
Label parentOrgLabel = new Label(ID_ORGANIZATION, getParentOrgModel());
parentOrgLabel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getParentOrgModel().getObject() != null;
}
});
box.add(parentOrgLabel);
iconBox = new WebMarkupContainer(ID_ICON_BOX);
box.add(iconBox);
if (getIconBoxAdditionalCssClass() != null) {
iconBox.add(new AttributeModifier("class", ICON_BOX_CSS_CLASS + " " + getIconBoxAdditionalCssClass()));
}
Label icon = new Label(ID_ICON, "");
icon.add(new AttributeModifier("class", getIconCssClass()));
icon.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getPhotoModel().getObject() == null;
}
});
iconBox.add(icon);
NonCachingImage img = new NonCachingImage(ID_PHOTO, getPhotoModel());
img.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getPhotoModel().getObject() != null;
}
});
iconBox.add(img);
tagBox = new WebMarkupContainer(ID_TAG_BOX);
if (getTagBoxCssClass() != null) {
tagBox.add(new AttributeModifier("class", getTagBoxCssClass()));
}
box.add(tagBox);
}
use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.
the class PrismValuePanel method createInputComponent.
private Panel createInputComponent(String id, IModel<String> labelModel, Form form) {
ValueWrapper valueWrapper = valueWrapperModel.getObject();
ObjectWrapper objectWrapper = null;
if (valueWrapper.getItem().getContainer() != null) {
objectWrapper = valueWrapper.getItem().getContainer().getObject();
}
Item property = valueWrapper.getItem().getItem();
boolean required = property.getDefinition().getMinOccurs() > 0;
Panel component = createTypedInputComponent(id);
if (component instanceof InputPanel) {
InputPanel inputPanel = (InputPanel) component;
//adding valid from/to date range validator, if necessary
ItemPath activation = new ItemPath(UserType.F_ACTIVATION);
if (ActivationType.F_VALID_FROM.equals(property.getElementName())) {
DateValidator validator = WebComponentUtil.getRangeValidator(form, activation);
validator.setDateFrom((DateTimeField) inputPanel.getBaseFormComponent());
} else if (ActivationType.F_VALID_TO.equals(property.getElementName())) {
DateValidator validator = WebComponentUtil.getRangeValidator(form, activation);
validator.setDateTo((DateTimeField) inputPanel.getBaseFormComponent());
}
final List<FormComponent> formComponents = inputPanel.getFormComponents();
for (FormComponent formComponent : formComponents) {
formComponent.setLabel(labelModel);
formComponent.setRequired(required);
if (formComponent instanceof TextField) {
formComponent.add(new AttributeModifier("size", "42"));
}
formComponent.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
// Validation occurs when submitting the form
// if (form != null) {
// AjaxFormValidatingBehavior validator = new AjaxFormValidatingBehavior(form, "Blur");
//
// formComponent.add(validator);
// }
}
}
if (component == null) {
throw new RuntimeException("Cannot create input component for item " + property + " (" + valueWrapper + ") in " + objectWrapper);
}
return component;
}
use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.
the class AutoRefreshPanel method initLayout.
private void initLayout(final Refreshable refreshable, boolean inSummaryPanel) {
final LinkIconPanel refreshNow = new LinkIconPanel(ID_REFRESH_NOW, new Model("fa fa-refresh"), createStringResource("autoRefreshPanel.refreshNow")) {
@Override
protected void onClickPerformed(AjaxRequestTarget target) {
refreshable.refresh(target);
}
};
refreshNow.setRenderBodyOnly(true);
add(refreshNow);
final LinkIconPanel resumeRefreshing = new LinkIconPanel(ID_START, new Model("fa fa-play"), createStringResource("autoRefreshPanel.resumeRefreshing")) {
@Override
protected void onClickPerformed(AjaxRequestTarget target) {
getModelObject().setEnabled(true);
refreshable.refresh(target);
startRefreshing(refreshable, target);
}
};
resumeRefreshing.setRenderBodyOnly(true);
resumeRefreshing.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !getModelObject().isEnabled();
}
});
add(resumeRefreshing);
final LinkIconPanel pauseRefreshing = new LinkIconPanel(ID_PAUSE, new Model("fa fa-pause"), createStringResource("autoRefreshPanel.pauseRefreshing")) {
@Override
protected void onClickPerformed(AjaxRequestTarget target) {
getModelObject().setEnabled(false);
refreshable.refresh(target);
stopRefreshing(refreshable, target);
}
};
pauseRefreshing.setRenderBodyOnly(true);
pauseRefreshing.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModelObject().isEnabled();
}
});
add(pauseRefreshing);
final Label status = new Label(ID_STATUS, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
AutoRefreshDto dto = getModelObject();
if (dto.isEnabled()) {
return createStringResource("autoRefreshPanel.refreshingEach", dto.getInterval() / 1000).getString();
} else {
return createStringResource("autoRefreshPanel.noRefreshing").getString();
}
}
});
status.setRenderBodyOnly(true);
add(status);
if (inSummaryPanel) {
add(new AttributeModifier("class", "summary-tag"));
}
}
Aggregations