Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Jun 9, 2016
2 parents ec4a4fe + f402986 commit f5f6d6a
Show file tree
Hide file tree
Showing 92 changed files with 3,337 additions and 636 deletions.
Expand Up @@ -37,8 +37,10 @@
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.api.model.NonEmptyModel;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.match.*;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
Expand All @@ -51,6 +53,7 @@
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
import org.apache.wicket.authroles.authentication.AuthenticatedWebApplication;
import org.apache.wicket.authroles.authorization.strategies.role.Roles;
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.core.request.handler.RenderPageRequestHandler;
import org.apache.wicket.datetime.PatternDateConverter;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
Expand Down Expand Up @@ -141,15 +144,14 @@ public final class WebComponentUtil {
private static final Trace LOGGER = TraceManager.getTrace(WebComponentUtil.class);
private static DatatypeFactory df = null;

public static enum Channel {
public enum Channel {
// TODO: move this to schema component
LIVE_SYNC(
"http://midpoint.evolveum.com/xml/ns/public/provisioning/channels-3#liveSync"), RECONCILIATION(
"http://midpoint.evolveum.com/xml/ns/public/provisioning/channels-3#reconciliation"), DISCOVERY(
"http://midpoint.evolveum.com/xml/ns/public/provisioning/channels-3#discovery"), IMPORT(
"http://midpoint.evolveum.com/xml/ns/public/provisioning/channels-3#import"), USER(
"http://midpoint.evolveum.com/xml/ns/public/provisioning/channels-3#user"), WEB_SERVICE(
"http://midpoint.evolveum.com/xml/ns/public/provisioning/channels-3#webService");
LIVE_SYNC(SchemaConstants.CHANGE_CHANNEL_LIVE_SYNC_URI),
RECONCILIATION(SchemaConstants.CHANGE_CHANNEL_RECON_URI),
DISCOVERY(SchemaConstants.CHANGE_CHANNEL_DISCOVERY_URI),
IMPORT(SchemaConstants.CHANNEL_OBJECT_IMPORT_URI),
USER(SchemaConstants.CHANNEL_GUI_USER_URI),
WEB_SERVICE(SchemaConstants.CHANNEL_WEB_SERVICE_URI);

private String channel;

Expand Down Expand Up @@ -1539,4 +1541,23 @@ public static String exceptionToString(String message, Exception e) {
pw.close();
return sw.toString();
}

public static Behavior visibleIfFalse(final NonEmptyModel<Boolean> model) {
return new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !model.getObject();
}
};
}

public static Behavior enabledIfFalse(final NonEmptyModel<Boolean> model) {
return new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return !model.getObject();
}
};
}

}
Expand Up @@ -64,7 +64,7 @@ public String getObject() {
String name = WebComponentUtil.getName(value);
if (selectableBean.getResult() != null){
StringBuilder complexName = new StringBuilder(name);
complexName.append("(");
complexName.append(" (");
complexName.append(selectableBean.getResult().getStatus());
complexName.append(")");
return complexName.toString();
Expand Down
Expand Up @@ -17,6 +17,8 @@
package com.evolveum.midpoint.web.component.form.multivalue;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.model.NonEmptyModel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;

import org.apache.wicket.AttributeModifier;
Expand Down Expand Up @@ -54,14 +56,14 @@ public class MultiValueAutoCompleteTextPanel<T extends Serializable> extends Bas
private static final String CSS_DISABLED = " disabled";
private static final Integer AUTO_COMPLETE_LIST_SIZE = 10;

public MultiValueAutoCompleteTextPanel(String id, IModel<List<T>> model, boolean inputEnabled){
public MultiValueAutoCompleteTextPanel(String id, IModel<List<T>> model, boolean inputEnabled, NonEmptyModel<Boolean> readOnlyModel) {
super(id, model);
setOutputMarkupId(true);

initLayout(inputEnabled);
initLayout(inputEnabled, readOnlyModel);
}

private void initLayout(final boolean inputEnabled){
private void initLayout(final boolean inputEnabled, final NonEmptyModel<Boolean> readOnlyModel) {
WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER);
placeholderContainer.setOutputMarkupPlaceholderTag(true);
placeholderContainer.setOutputMarkupPlaceholderTag(true);
Expand Down Expand Up @@ -94,6 +96,7 @@ public String getObject() {
}));
placeholderAdd.setOutputMarkupId(true);
placeholderAdd.setOutputMarkupPlaceholderTag(true);
placeholderAdd.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
placeholderContainer.add(placeholderAdd);

ListView repeater = new ListView<T>(ID_REPEATER, getModel()){
Expand Down Expand Up @@ -128,7 +131,7 @@ protected void onUpdate(AjaxRequestTarget target) {}

WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
item.add(buttonGroup);
initButtons(buttonGroup, item);
initButtons(buttonGroup, item, readOnlyModel);
}
};
repeater.setOutputMarkupId(true);
Expand Down Expand Up @@ -176,7 +179,7 @@ private Iterator<String> createAutoCompleteObjectList(String input) {
return choices.iterator();
}

private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item) {
private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item, NonEmptyModel<Boolean> readOnlyModel) {
AjaxLink add = new AjaxLink(ID_ADD) {

@Override
Expand All @@ -185,6 +188,7 @@ public void onClick(AjaxRequestTarget target) {
}
};
add.add(new AttributeAppender("class", getPlusClassModifier(item)));
add.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
buttonGroup.add(add);

AjaxLink remove = new AjaxLink(ID_REMOVE) {
Expand All @@ -195,6 +199,7 @@ public void onClick(AjaxRequestTarget target) {
}
};
remove.add(new AttributeAppender("class", getMinusClassModifier()));
remove.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
buttonGroup.add(remove);
}

Expand Down
Expand Up @@ -17,6 +17,8 @@
package com.evolveum.midpoint.web.component.form.multivalue;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.model.NonEmptyModel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -49,14 +51,14 @@ public class MultiValueDropDownPanel<T extends Serializable> extends BasePanel<L

private static final String CSS_DISABLED = " disabled";

public MultiValueDropDownPanel(String id, IModel<List<T>> model, boolean nullValid){
public MultiValueDropDownPanel(String id, IModel<List<T>> model, boolean nullValid, NonEmptyModel<Boolean> readOnlyModel) {
super(id, model);
setOutputMarkupId(true);

initLayout(nullValid);
initLayout(nullValid, readOnlyModel);
}

private void initLayout(final boolean nullValid){
private void initLayout(final boolean nullValid, final NonEmptyModel<Boolean> readOnlyModel) {
WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER);
placeholderContainer.setOutputMarkupPlaceholderTag(true);
placeholderContainer.setOutputMarkupPlaceholderTag(true);
Expand Down Expand Up @@ -89,6 +91,7 @@ public String getObject() {
}));
placeholderAdd.setOutputMarkupId(true);
placeholderAdd.setOutputMarkupPlaceholderTag(true);
placeholderAdd.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
placeholderContainer.add(placeholderAdd);

ListView repeater = new ListView<T>(ID_REPEATER, getModel()){
Expand All @@ -99,11 +102,12 @@ protected void populateItem(final ListItem<T> item) {
DropDownChoice choice = new DropDownChoice<>(ID_INPUT, createDropDownItemModel(item.getModel()),
createChoiceList(), createRenderer());
choice.setNullValid(nullValid);
choice.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
item.add(choice);

WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
item.add(buttonGroup);
initButtons(buttonGroup, item);
initButtons(buttonGroup, item, readOnlyModel);
}
};
repeater.setOutputMarkupId(true);
Expand Down Expand Up @@ -137,7 +141,7 @@ public void detach() {
};
}

private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item) {
private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item, NonEmptyModel<Boolean> readOnlyModel) {
AjaxLink add = new AjaxLink(ID_ADD) {

@Override
Expand All @@ -146,6 +150,7 @@ public void onClick(AjaxRequestTarget target) {
}
};
add.add(new AttributeAppender("class", getPlusClassModifier(item)));
add.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
buttonGroup.add(add);

AjaxLink remove = new AjaxLink(ID_REMOVE) {
Expand All @@ -156,6 +161,7 @@ public void onClick(AjaxRequestTarget target) {
}
};
remove.add(new AttributeAppender("class", getMinusClassModifier()));
remove.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
buttonGroup.add(remove);
}

Expand Down
Expand Up @@ -17,12 +17,12 @@
package com.evolveum.midpoint.web.component.form.multivalue;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.model.NonEmptyModel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;

import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
import org.apache.wicket.behavior.AttributeAppender;
Expand Down Expand Up @@ -58,15 +58,15 @@ public class MultiValueTextEditPanel<T extends Serializable> extends BasePanel<L

@Nullable private final IModel<T> selectedModel; // holding the selected item

public MultiValueTextEditPanel(String id, IModel<List<T>> model, IModel<T> selectedModel, boolean inputEnabled, boolean showPlaceholder) {
public MultiValueTextEditPanel(String id, IModel<List<T>> model, IModel<T> selectedModel, boolean inputEnabled, boolean showPlaceholder, NonEmptyModel<Boolean> readOnlyModel) {
super(id, model);
setOutputMarkupId(true);
this.selectedModel = selectedModel;

initLayout(inputEnabled, showPlaceholder);
initLayout(inputEnabled, showPlaceholder, readOnlyModel);
}

private void initLayout(final boolean inputEnabled, final boolean showPlaceholder) {
private void initLayout(final boolean inputEnabled, final boolean showPlaceholder, final NonEmptyModel<Boolean> readOnlyModel) {
WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER);
placeholderContainer.setOutputMarkupPlaceholderTag(true);
placeholderContainer.setOutputMarkupPlaceholderTag(true);
Expand Down Expand Up @@ -97,6 +97,7 @@ public String getObject() {
return "";
}
}));
placeholderAdd.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
placeholderAdd.setOutputMarkupId(true);
placeholderAdd.setOutputMarkupPlaceholderTag(true);
placeholderContainer.add(placeholderAdd);
Expand All @@ -119,7 +120,7 @@ protected void populateItem(final ListItem<T> item) {

WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
item.add(buttonGroup);
initButtons(buttonGroup, item);
initButtons(buttonGroup, item, readOnlyModel);
}
};
repeater.setOutputMarkupId(true);
Expand All @@ -134,7 +135,7 @@ public boolean isVisible() {
add(repeater);
}

private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item) {
private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item, NonEmptyModel<Boolean> readOnlyModel) {
AjaxSubmitLink edit = new AjaxSubmitLink(ID_EDIT) {

@Override
Expand Down Expand Up @@ -168,6 +169,7 @@ public void onClick(AjaxRequestTarget target) {
}
};
add.add(new AttributeAppender("class", getPlusClassModifier(item)));
add.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
buttonGroup.add(add);

AjaxLink remove = new AjaxLink(ID_REMOVE) {
Expand All @@ -178,7 +180,8 @@ public void onClick(AjaxRequestTarget target) {
}
};
remove.add(new AttributeAppender("class", getMinusClassModifier()));
buttonGroup.add(remove);
remove.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
buttonGroup.add(remove);
}

protected String getPlusClassModifier(ListItem<T> item){
Expand Down
Expand Up @@ -16,6 +16,8 @@
package com.evolveum.midpoint.web.component.form.multivalue;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.model.NonEmptyModel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;

import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -50,11 +52,11 @@ public class MultiValueTextPanel<T extends Serializable> extends BasePanel<List<

private static final String CSS_DISABLED = " disabled";

public MultiValueTextPanel(String id, IModel<List<T>> value){
public MultiValueTextPanel(String id, IModel<List<T>> value, NonEmptyModel<Boolean> readOnlyModel){
super(id, value);
setOutputMarkupId(true);

initLayout();
initLayout(readOnlyModel);
}

@Override
Expand All @@ -66,7 +68,7 @@ public IModel<List<T>> getModel(){
return super.getModel();
}

private void initLayout(){
private void initLayout(final NonEmptyModel<Boolean> readOnlyModel) {
WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER);
placeholderContainer.setOutputMarkupPlaceholderTag(true);
placeholderContainer.setOutputMarkupPlaceholderTag(true);
Expand All @@ -86,6 +88,7 @@ public void onClick(AjaxRequestTarget target) {
addValuePerformed(target);
}
};
placeholderAdd.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
placeholderAdd.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

@Override
Expand All @@ -111,11 +114,12 @@ protected void populateItem(final ListItem<T> item) {
protected void onUpdate(AjaxRequestTarget target) {}
});
text.add(AttributeAppender.replace("placeholder", createEmptyItemPlaceholder()));
text.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
item.add(text);

WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
item.add(buttonGroup);
initButtons(buttonGroup, item);
initButtons(buttonGroup, item, readOnlyModel);
}
};
repeater.setOutputMarkupId(true);
Expand All @@ -130,7 +134,7 @@ public boolean isVisible() {
add(repeater);
}

private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item) {
private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item, NonEmptyModel<Boolean> readOnlyModel) {
AjaxLink plus = new AjaxLink(ID_PLUS) {

@Override
Expand All @@ -139,6 +143,7 @@ public void onClick(AjaxRequestTarget target) {
}
};
plus.add(new AttributeAppender("class", getPlusClassModifier(item)));
plus.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
buttonGroup.add(plus);

AjaxLink minus = new AjaxLink(ID_MINUS) {
Expand All @@ -149,6 +154,7 @@ public void onClick(AjaxRequestTarget target) {
}
};
minus.add(new AttributeAppender("class", getMinusClassModifier()));
minus.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
buttonGroup.add(minus);
}

Expand Down

0 comments on commit f5f6d6a

Please sign in to comment.