Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Mar 22, 2016
2 parents e622b3e + 1d3d697 commit 5a730ff
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 14 deletions.
Expand Up @@ -22,6 +22,7 @@

import javax.xml.namespace.QName;

import com.evolveum.midpoint.web.component.input.*;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -61,9 +62,6 @@
import com.evolveum.midpoint.web.component.data.paging.NavigatorPanel;
import com.evolveum.midpoint.web.component.form.multivalue.MultiValueAutoCompleteTextPanel;
import com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel;
import com.evolveum.midpoint.web.component.input.ObjectReferenceChoiceRenderer;
import com.evolveum.midpoint.web.component.input.QNameChoiceRenderer;
import com.evolveum.midpoint.web.component.input.ThreeStateBooleanPanel;
import com.evolveum.midpoint.web.component.util.ListDataProvider;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.component.wizard.WizardStep;
Expand Down Expand Up @@ -437,8 +435,7 @@ public List<ObjectReferenceType> getObject() {
ResourceSynchronizationDto.F_SELECTED + ".reconcile"));
editor.add(editorReconcile);

ThreeStateBooleanPanel opportunistic = new ThreeStateBooleanPanel(ID_EDITOR_OPPORTUNISTIC,
new PropertyModel<Boolean>(model, ResourceSynchronizationDto.F_SELECTED + ".opportunistic"));
TriStateComboPanel opportunistic = new TriStateComboPanel(ID_EDITOR_OPPORTUNISTIC, new PropertyModel<Boolean>(model, ResourceSynchronizationDto.F_SELECTED + ".opportunistic"));
editor.add(opportunistic);

MultiValueTextEditPanel editorCorrelation = new MultiValueTextEditPanel<ConditionalSearchFilterType>(ID_EDITOR_EDITOR_CORRELATION,
Expand Down
Expand Up @@ -18,12 +18,17 @@

import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.web.component.form.CheckFormGroup;
import com.evolveum.midpoint.web.component.form.TextFormGroup;
import com.evolveum.midpoint.web.component.input.DropDownChoicePanel;
import com.evolveum.midpoint.web.component.input.ThreeStateBooleanPanel;
import com.evolveum.midpoint.web.component.input.validator.NotNullValidator;
import com.evolveum.midpoint.web.component.wizard.resource.dto.PropertyLimitationsTypeDto;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour;
import com.evolveum.midpoint.web.util.InfoTooltipBehavior;
import com.evolveum.midpoint.xml.ns._public.common.common_3.LayerType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingLevelType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyAccessType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyLimitationsType;

Expand All @@ -36,6 +41,7 @@
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.AbstractReadOnlyModel;
Expand All @@ -55,6 +61,10 @@ private static enum ChangeState{
SKIP, FIRST, LAST
}

private static enum PropertyAccess{
Allow, Inherit, Deny
}

private static final String ID_REPEATER = "repeater";
private static final String ID_LIMITATIONS_LINK = "limitationsLink";
private static final String ID_LIMITATIONS_LABEL = "limitationsLinkName";
Expand Down Expand Up @@ -233,16 +243,41 @@ private void initLimitationBody(final WebMarkupContainer body, ListItem<Property
presentation.getCheck().add(prepareAjaxOnComponentTagUpdateBehavior());
body.add(presentation);

ThreeStateBooleanPanel add = new ThreeStateBooleanPanel(ID_ACCESS_ADD, new PropertyModel<Boolean>(item.getModelObject(), PropertyLimitationsTypeDto.F_LIMITATION + ".access.add"),
"LimitationsEditorDialog.allow", "LimitationsEditorDialog.inherit", "LimitationsEditorDialog.deny", null);
body.add(add);
DropDownChoicePanel add = new DropDownChoicePanel(ID_ACCESS_ADD,
getAddPropertyAccessModel(item.getModel()),
WebComponentUtil.createReadonlyModelFromEnum(PropertyAccess.class), false);
FormComponent<PropertyAccess> addInput = add.getBaseFormComponent();
addInput.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
addInput.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});

ThreeStateBooleanPanel read = new ThreeStateBooleanPanel(ID_ACCESS_READ, new PropertyModel<Boolean>(item.getModelObject(), PropertyLimitationsTypeDto.F_LIMITATION + ".access.read"),
"LimitationsEditorDialog.allow", "LimitationsEditorDialog.inherit", "LimitationsEditorDialog.deny", null);
body.add(read);
DropDownChoicePanel read = new DropDownChoicePanel(ID_ACCESS_READ,
getReadPropertyAccessModel(item.getModel()),
WebComponentUtil.createReadonlyModelFromEnum(PropertyAccess.class), false);
FormComponent<PropertyAccess> readInput = read.getBaseFormComponent();
readInput.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
readInput.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});

DropDownChoicePanel modify = new DropDownChoicePanel(ID_ACCESS_MODIFY,
getModifyPropertyAccessModel(item.getModel()),
WebComponentUtil.createReadonlyModelFromEnum(PropertyAccess.class), false);
FormComponent<PropertyAccess> modifyInput = modify.getBaseFormComponent();
modifyInput.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
modifyInput.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});

ThreeStateBooleanPanel modify = new ThreeStateBooleanPanel(ID_ACCESS_MODIFY, new PropertyModel<Boolean>(item.getModelObject(), PropertyLimitationsTypeDto.F_LIMITATION + ".access.modify"),
"LimitationsEditorDialog.allow", "LimitationsEditorDialog.inherit", "LimitationsEditorDialog.deny", null);
body.add(add);
body.add(read);
body.add(modify);

TextFormGroup minOccurs = new TextFormGroup(ID_MIN_OCCURS, new PropertyModel<String>(item.getModelObject(), PropertyLimitationsTypeDto.F_LIMITATION + ".minOccurs"),
Expand Down Expand Up @@ -378,4 +413,95 @@ protected void savePerformed(AjaxRequestTarget target){
inputModel.setObject(outputList);
close(target);
}

private IModel<PropertyAccess> getAddPropertyAccessModel(final IModel<PropertyLimitationsTypeDto> model){
return new IModel<PropertyAccess>() {
@Override
public PropertyAccess getObject() {
Boolean add = model.getObject().getLimitationObject().getAccess().isAdd();
if (add == null){
return PropertyAccess.Inherit;
} else if (add){
return PropertyAccess.Allow;
} else {
return PropertyAccess.Deny;
}
}

@Override
public void setObject(PropertyAccess propertyAccess) {
if (propertyAccess.equals(PropertyAccess.Allow)){
model.getObject().getLimitationObject().getAccess().setAdd(true);
} else if (propertyAccess.equals(PropertyAccess.Deny)){
model.getObject().getLimitationObject().getAccess().setAdd(false);
} else {
model.getObject().getLimitationObject().getAccess().setAdd(null);
}
}

@Override
public void detach() {
}
};
}
private IModel<PropertyAccess> getReadPropertyAccessModel(final IModel<PropertyLimitationsTypeDto> model){
return new IModel<PropertyAccess>() {
@Override
public PropertyAccess getObject() {
Boolean read = model.getObject().getLimitationObject().getAccess().isRead();
if (read == null){
return PropertyAccess.Inherit;
} else if (read){
return PropertyAccess.Allow;
} else {
return PropertyAccess.Deny;
}
}

@Override
public void setObject(PropertyAccess propertyAccess) {
if (propertyAccess.equals(PropertyAccess.Allow)){
model.getObject().getLimitationObject().getAccess().setRead(true);
} else if (propertyAccess.equals(PropertyAccess.Deny)){
model.getObject().getLimitationObject().getAccess().setRead(false);
} else {
model.getObject().getLimitationObject().getAccess().setRead(null);
}
}

@Override
public void detach() {
}
};
}
private IModel<PropertyAccess> getModifyPropertyAccessModel(final IModel<PropertyLimitationsTypeDto> model){
return new IModel<PropertyAccess>() {
@Override
public PropertyAccess getObject() {
Boolean modify = model.getObject().getLimitationObject().getAccess().isModify();
if (modify == null){
return PropertyAccess.Inherit;
} else if (modify){
return PropertyAccess.Allow;
} else {
return PropertyAccess.Deny;
}
}

@Override
public void setObject(PropertyAccess propertyAccess) {
if (propertyAccess.equals(PropertyAccess.Allow)){
model.getObject().getLimitationObject().getAccess().setModify(true);
} else if (propertyAccess.equals(PropertyAccess.Deny)){
model.getObject().getLimitationObject().getAccess().setModify(false);
} else {
model.getObject().getLimitationObject().getAccess().setModify(null);
}
}

@Override
public void detach() {
}
};
}
}
Expand Up @@ -30,6 +30,7 @@
import com.evolveum.midpoint.web.component.input.ObjectReferenceChoiceRenderer;
import com.evolveum.midpoint.web.component.input.StringChoiceRenderer;
import com.evolveum.midpoint.web.component.input.ThreeStateBooleanPanel;
import com.evolveum.midpoint.web.component.input.TriStateComboPanel;
import com.evolveum.midpoint.web.component.util.SimplePanel;
import com.evolveum.midpoint.web.util.InfoTooltipBehavior;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
Expand Down Expand Up @@ -137,8 +138,8 @@ protected IChoiceRenderer<String> createRenderer() {
}
};
add(channel);
TriStateComboPanel synchronize = new TriStateComboPanel(ID_SYNCHRONIZE, new PropertyModel<Boolean>(getModel(), "synchronize"));

ThreeStateBooleanPanel synchronize = new ThreeStateBooleanPanel(ID_SYNCHRONIZE, new PropertyModel<Boolean>(getModel(), "synchronize"));
add(synchronize);

CheckBox reconcile = new CheckBox(ID_RECONCILE, new PropertyModel<Boolean>(getModel(), "reconcile"));
Expand Down

0 comments on commit 5a730ff

Please sign in to comment.