use of org.apache.wicket.Component in project midpoint by Evolveum.
the class AutoRefreshPanel method startRefreshing.
public void startRefreshing(final Refreshable refreshable, AjaxRequestTarget target) {
stopRefreshing(refreshable, target);
int refreshInterval = refreshable.getRefreshInterval();
getModel().getObject().setInterval(refreshInterval);
Component parent = refreshable.getRefreshingBehaviorParent();
RemovableAjaxTimerBehavior refreshingBehavior = new RemovableAjaxTimerBehavior(parent, refreshInterval) {
@Override
protected void handleOnTimer(AjaxRequestTarget target1) {
refreshable.refresh(target1);
}
};
parent.add(refreshingBehavior);
}
use of org.apache.wicket.Component in project midpoint by Evolveum.
the class TextPopupPanel method initLayout.
private void initLayout() {
final TextField input = initTextField();
input.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
//nothing to do, just update model data
}
});
input.add(new Behavior() {
@Override
public void bind(Component component) {
super.bind(component);
component.add(AttributeModifier.replace("onkeydown", Model.of("if(event.keyCode == 13) {event.preventDefault();}")));
}
});
input.setOutputMarkupId(true);
add(input);
}
use of org.apache.wicket.Component in project midpoint by Evolveum.
the class AssignmentEditorPanel method initBodyLayout.
protected void initBodyLayout(WebMarkupContainer body) {
WebMarkupContainer propertyContainer = new WebMarkupContainer(ID_PROPERTY_CONTAINER);
propertyContainer.setOutputMarkupId(true);
body.add(propertyContainer);
WebMarkupContainer descriptionContainer = new WebMarkupContainer(ID_DESCRIPTION_CONTAINER);
descriptionContainer.setOutputMarkupId(true);
descriptionContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_DESCRIPTION));
}
});
body.add(descriptionContainer);
TextArea<String> description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(getModel(), AssignmentEditorDto.F_DESCRIPTION));
description.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return getModel().getObject().isEditable();
}
});
descriptionContainer.add(description);
WebMarkupContainer relationContainer = new WebMarkupContainer(ID_RELATION_CONTAINER);
relationContainer.setOutputMarkupId(true);
relationContainer.setOutputMarkupPlaceholderTag(true);
relationContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
if (!isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF, ObjectReferenceType.F_RELATION))) {
return false;
}
AssignmentEditorDto dto = getModel().getObject();
if (dto != null) {
if (AssignmentEditorDtoType.ORG_UNIT.equals(dto.getType()) || AssignmentEditorDtoType.SERVICE.equals(dto.getType()) || AssignmentEditorDtoType.ROLE.equals(dto.getType())) {
return true;
}
}
return false;
}
});
body.add(relationContainer);
addRelationDropDown(relationContainer);
WebMarkupContainer focusTypeContainer = new WebMarkupContainer(ID_FOCUS_TYPE_CONTAINER);
focusTypeContainer.setOutputMarkupId(true);
focusTypeContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_FOCUS_TYPE));
}
});
body.add(focusTypeContainer);
ObjectTypeSelectPanel<FocusType> focusType = new ObjectTypeSelectPanel<>(ID_FOCUS_TYPE, new PropertyModel<>(getModel(), AssignmentEditorDto.F_FOCUS_TYPE), FocusType.class);
focusTypeContainer.add(focusType);
Label relationLabel = new Label(ID_RELATION_LABEL, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (getModel() == null || getModel().getObject() == null) {
return getString("AssignmentEditorPanel.relation.notSpecified");
}
AssignmentEditorDto object = getModel().getObject();
String propertyKey = RelationTypes.class.getSimpleName() + "." + (object.getTargetRef() == null || object.getTargetRef().getRelation() == null ? RelationTypes.MEMBER : RelationTypes.getRelationType(object.getTargetRef().getRelation()));
return createStringResource(propertyKey).getString();
}
});
relationLabel.setOutputMarkupId(true);
relationLabel.setOutputMarkupPlaceholderTag(true);
relationLabel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !isCreatingNewAssignment();
}
});
relationContainer.add(relationLabel);
WebMarkupContainer tenantRefContainer = createTenantContainer();
tenantRefContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_TENANT_REF));
}
});
body.add(tenantRefContainer);
WebMarkupContainer orgRefContainer = createOrgContainer();
orgRefContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_ORG_REF));
}
});
body.add(orgRefContainer);
propertyContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_DESCRIPTION)) || isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF, ObjectReferenceType.F_RELATION)) || isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_FOCUS_TYPE)) || isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_TENANT_REF)) || isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_ORG_REF));
}
});
WebMarkupContainer activationBlock = new WebMarkupContainer(ID_ACTIVATION_BLOCK);
body.add(activationBlock);
WebMarkupContainer adminStatusContainer = new WebMarkupContainer(ID_ADMIN_STATUS_CONTAINER);
adminStatusContainer.setOutputMarkupId(true);
adminStatusContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS));
}
});
activationBlock.add(adminStatusContainer);
DropDownChoicePanel administrativeStatus = WebComponentUtil.createEnumPanel(ActivationStatusType.class, ID_ADMINISTRATIVE_STATUS, new PropertyModel<ActivationStatusType>(getModel(), AssignmentEditorDto.F_ACTIVATION + "." + ActivationType.F_ADMINISTRATIVE_STATUS.getLocalPart()), this);
administrativeStatus.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return getModel().getObject().isEditable();
}
});
adminStatusContainer.add(administrativeStatus);
WebMarkupContainer validFromContainer = new WebMarkupContainer(ID_VALID_FROM_CONTAINER);
validFromContainer.setOutputMarkupId(true);
validFromContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_ACTIVATION, ActivationType.F_VALID_FROM));
}
});
activationBlock.add(validFromContainer);
DateInput validFrom = new DateInput(ID_VALID_FROM, createDateModel(new PropertyModel<>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validFrom")));
validFrom.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return getModel().getObject().isEditable();
}
});
validFromContainer.add(validFrom);
WebMarkupContainer validToContainer = new WebMarkupContainer(ID_VALID_TO_CONTAINER);
validToContainer.setOutputMarkupId(true);
validToContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_ACTIVATION, ActivationType.F_VALID_TO));
}
});
activationBlock.add(validToContainer);
DateInput validTo = new DateInput(ID_VALID_TO, createDateModel(new PropertyModel<>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validTo")));
validTo.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return getModel().getObject().isEditable();
}
});
validToContainer.add(validTo);
activationBlock.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
// enabled activation in assignments for now.
return true;
}
});
WebMarkupContainer targetContainer = new WebMarkupContainer(ID_TARGET_CONTAINER);
targetContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
if (!isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET))) {
return false;
}
AssignmentEditorDto dto = getModel().getObject();
return !AssignmentEditorDtoType.CONSTRUCTION.equals(dto.getType());
}
});
body.add(targetContainer);
Label target = new Label(ID_TARGET, createTargetModel());
targetContainer.add(target);
WebMarkupContainer constructionContainer = new WebMarkupContainer(ID_CONSTRUCTION_CONTAINER);
constructionContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
AssignmentEditorDto dto = getModel().getObject();
return AssignmentEditorDtoType.CONSTRUCTION.equals(dto.getType());
}
});
body.add(constructionContainer);
AjaxLink showEmpty = new AjaxLink(ID_SHOW_EMPTY) {
@Override
public void onClick(AjaxRequestTarget target) {
showEmptyPerformed(target);
}
};
constructionContainer.add(showEmpty);
Label showEmptyLabel = new Label(ID_SHOW_EMPTY_LABEL, createShowEmptyLabel());
showEmptyLabel.setOutputMarkupId(true);
showEmpty.add(showEmptyLabel);
initAttributesLayout(constructionContainer);
Component metadataPanel;
if (UserDtoStatus.ADD.equals(getModel().getObject().getStatus()) || getModelObject().getOldValue().asContainerable() == null) {
metadataPanel = new WebMarkupContainer(ID_METADATA_CONTAINER);
} else {
metadataPanel = new MetadataPanel(ID_METADATA_CONTAINER, new AbstractReadOnlyModel<MetadataType>() {
@Override
public MetadataType getObject() {
return getModelObject().getOldValue().getValue().getMetadata();
}
}, "", "row");
}
metadataPanel.setOutputMarkupId(true);
metadataPanel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !UserDtoStatus.ADD.equals(getModel().getObject().getStatus());
}
});
body.add(metadataPanel);
addAjaxOnUpdateBehavior(body);
}
use of org.apache.wicket.Component in project midpoint by Evolveum.
the class TabbedPanel method setCurrentTab.
private void setCurrentTab(int index) {
if (this.currentTab == index) {
// already current
return;
}
this.currentTab = index;
final Component component;
if (currentTab == -1 || (tabs.getObject().size() == 0) || !getVisiblityCache().isVisible(currentTab)) {
// no tabs or the current tab is not visible
component = newPanel();
} else {
// show panel from selected tab
T tab = tabs.getObject().get(currentTab);
component = tab.getPanel(TAB_PANEL_ID);
if (component == null) {
throw new WicketRuntimeException("ITab.getPanel() returned null. TabbedPanel [" + getPath() + "] ITab index [" + currentTab + "]");
}
}
if (!component.getId().equals(TAB_PANEL_ID)) {
throw new WicketRuntimeException("ITab.getPanel() returned a panel with invalid id [" + component.getId() + "]. You must always return a panel with id equal to the provided panelId parameter. TabbedPanel [" + getPath() + "] ITab index [" + currentTab + "]");
}
addOrReplace(component);
}
use of org.apache.wicket.Component in project midpoint by Evolveum.
the class CatalogItemsPanel method initLayout.
private void initLayout() {
setOutputMarkupId(true);
Component assignmentsTable;
if (isCatalogOidEmpty()) {
assignmentsTable = new Label(ID_MULTI_BUTTON_TABLE, createStringResource("PageAssignmentShoppingKart.roleCatalogIsNotConfigured"));
} else {
assignmentsTable = new MultiButtonTable(ID_MULTI_BUTTON_TABLE, itemsPerRow, itemsListModel, pageBase);
}
assignmentsTable.setOutputMarkupId(true);
add(assignmentsTable);
add(createFooter(ID_FOOTER));
}
Aggregations