-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MID-7815 mail/sms transport missing fields panels, wip
- Loading branch information
Showing
6 changed files
with
286 additions
and
136 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
...point/gui/impl/page/admin/systemconfiguration/component/ComplexPropertyEmbeddedModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (c) 2022 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.gui.impl.page.admin.systemconfiguration.component; | ||
|
||
import java.io.Serializable; | ||
|
||
import org.apache.wicket.model.IModel; | ||
|
||
import com.evolveum.midpoint.web.component.util.SerializableBiConsumer; | ||
import com.evolveum.midpoint.web.component.util.SerializableFunction; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Created by Viliam Repan (lazyman). | ||
*/ | ||
public class ComplexPropertyEmbeddedModel<O extends Serializable, T extends Serializable> implements IModel<T> { | ||
|
||
private IModel<O> model; | ||
|
||
private SerializableFunction<O, T> get; | ||
|
||
private SerializableBiConsumer<O, T> set; | ||
|
||
public ComplexPropertyEmbeddedModel(@NotNull IModel<O> model, @NotNull SerializableFunction<O, T> get, @NotNull SerializableBiConsumer<O, T> set) { | ||
this.model = model; | ||
this.get = get; | ||
this.set = set; | ||
} | ||
|
||
@Override | ||
public T getObject() { | ||
O object = model.getObject(); | ||
if (object == null) { | ||
return null; | ||
} | ||
|
||
return get.apply(object); | ||
} | ||
|
||
@Override | ||
public void setObject(T object) { | ||
O parent = model.getObject(); | ||
|
||
if (object == null && parent == null) { | ||
return; | ||
} | ||
|
||
if (parent == null) { | ||
parent = createEmptyParentObject(); | ||
model.setObject(parent); | ||
} | ||
|
||
if (parent == null) { | ||
return; | ||
} | ||
|
||
set.accept(parent, object); | ||
|
||
if (isParentModelObjectEmpty(parent)) { | ||
model.setObject(null); | ||
} | ||
} | ||
|
||
protected O createEmptyParentObject() { | ||
return null; | ||
} | ||
|
||
protected boolean isParentModelObjectEmpty(O object) { | ||
return false; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...midpoint/gui/impl/page/admin/systemconfiguration/component/ComplexPropertyInputPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2022 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.gui.impl.page.admin.systemconfiguration.component; | ||
|
||
import java.io.Serializable; | ||
|
||
import org.apache.wicket.Component; | ||
import org.apache.wicket.MarkupContainer; | ||
import org.apache.wicket.markup.html.form.FormComponent; | ||
import org.apache.wicket.model.IModel; | ||
|
||
import com.evolveum.midpoint.web.component.prism.InputPanel; | ||
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour; | ||
|
||
/** | ||
* Created by Viliam Repan (lazyman). | ||
*/ | ||
public abstract class ComplexPropertyInputPanel<T extends Serializable> extends InputPanel { | ||
|
||
private static final long serialVersionUID = 1L; | ||
private IModel<T> model; | ||
|
||
public ComplexPropertyInputPanel(String id, IModel<T> model) { | ||
super(id); | ||
|
||
this.model = model; | ||
} | ||
|
||
public IModel<T> getModel() { | ||
return model; | ||
} | ||
|
||
protected MarkupContainer add(Component child, boolean addUpdatingBehaviour) { | ||
if (addUpdatingBehaviour) { | ||
FormComponent fc = null; | ||
if (child instanceof FormComponent) { | ||
fc = (FormComponent) child; | ||
} else if (child instanceof InputPanel) { | ||
fc = ((InputPanel) child).getBaseFormComponent(); | ||
} | ||
|
||
if (fc != null) { | ||
fc.add(new EmptyOnBlurAjaxFormUpdatingBehaviour()); | ||
} | ||
} | ||
|
||
return super.add(child); | ||
} | ||
|
||
protected MarkupContainer add(Component child) { | ||
return add(child, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.