Skip to content

Commit

Permalink
MID-2005 - ExtensionType editor for Role/Org. unit editors implementa…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
Erik Suta committed Aug 13, 2014
1 parent c902e2d commit 1926965
Show file tree
Hide file tree
Showing 11 changed files with 382 additions and 36 deletions.
Expand Up @@ -290,23 +290,31 @@ public boolean isVisible() {
add(body);

ListView<ContainerWrapper> containers = new ListView<ContainerWrapper>("containers",
new PropertyModel<List<ContainerWrapper>>(model, "containers")) {
createContainerModel(model)) {

@Override
protected void populateItem(ListItem<ContainerWrapper> item) {
item.add(new PrismContainerPanel("container", item.getModel(), form));
createContainerPanel(item, form);
}
};
containers.setReuseItems(true);
body.add(containers);
}

protected IModel<List<ContainerWrapper>> createContainerModel(IModel<ObjectWrapper> model){
return new PropertyModel<>(model, "containers");
}

protected void createContainerPanel(ListItem<ContainerWrapper> item, Form form){
item.add(new PrismContainerPanel("container", item.getModel(), form));
}

protected IModel<String> createDisplayName(IModel<ObjectWrapper> model) {
return new PropertyModel<String>(model, "displayName");
return new PropertyModel<>(model, "displayName");
}

protected IModel<String> createDescription(IModel<ObjectWrapper> model) {
return new PropertyModel<String>(model, "description");
return new PropertyModel<>(model, "description");
}

private void initButtons(WebMarkupContainer headerPanel, final IModel<ObjectWrapper> model) {
Expand Down
Expand Up @@ -17,7 +17,7 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div class="col-xs-4">
<div wicket:id="labelContainer" class="col-xs-4">
<span wicket:id="label"/>
<span wicket:id="required" style="color: #f00; font-weight: bold;"
wicket:message="title:prismPropertyPanel.required">*</span>
Expand All @@ -27,8 +27,8 @@
wicket:message="title:prismPropertyPanel.hasPendingModification">*</span>
<i wicket:id="help"/>
</div>
<div class="col-xs-8" wicket:id="values">
<div class="row" wicket:id="value"/>
<div class="col-md-6" wicket:id="values">
<div wicket:id="value"/>
</div>
</wicket:panel>
</html>
Expand Up @@ -53,6 +53,7 @@ public class PrismPropertyPanel extends Panel {
private static final Trace LOGGER = TraceManager.getTrace(PrismPropertyPanel.class);
private static final String ID_HAS_PENDING_MODIFICATION = "hasPendingModification";
private static final String ID_HELP = "help";
private static final String ID_LABEL_CONTAINER = "labelContainer";

public PrismPropertyPanel(String id, final IModel<PropertyWrapper> model, Form form) {
super(id);
Expand All @@ -76,8 +77,12 @@ public boolean isEnabled() {
}

private void initLayout(final IModel<PropertyWrapper> model, final Form form) {
WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER);
labelContainer.setOutputMarkupId(true);
add(labelContainer);

final IModel<String> label = createDisplayName(model);
add(new Label("label", label));
labelContainer.add(new Label("label", label));

final IModel<String> helpText = new LoadableModel<String>(false) {

Expand All @@ -96,7 +101,7 @@ public boolean isVisible() {
return StringUtils.isNotEmpty(helpText.getObject());
}
});
add(help);
labelContainer.add(help);

WebMarkupContainer required = new WebMarkupContainer("required");
required.add(new VisibleEnableBehaviour() {
Expand All @@ -115,7 +120,7 @@ public boolean isVisible() {
return def.isMandatory();
}
});
add(required);
labelContainer.add(required);

WebMarkupContainer hasOutbound = new WebMarkupContainer("hasOutbound");
hasOutbound.add(new VisibleEnableBehaviour() {
Expand All @@ -125,7 +130,7 @@ public boolean isVisible() {
return hasOutbound(model);
}
});
add(hasOutbound);
labelContainer.add(hasOutbound);

WebMarkupContainer hasPendingModification = new WebMarkupContainer(ID_HAS_PENDING_MODIFICATION);
hasPendingModification.add(new VisibleEnableBehaviour() {
Expand All @@ -135,14 +140,16 @@ public boolean isVisible() {
return hasPendingModification(model);
}
});
add(hasPendingModification);
labelContainer.add(hasPendingModification);

ListView<ValueWrapper> values = new ListView<ValueWrapper>("values",
new PropertyModel<List<ValueWrapper>>(model, "values")) {

@Override
protected void populateItem(final ListItem<ValueWrapper> item) {
item.add(new PrismValuePanel("value", item.getModel(), label, form));
PrismValuePanel panel = new PrismValuePanel("value", item.getModel(), label, form, getValueCssClass(), getInputCssClass());
panel.add(new AttributeModifier("class", getValueCssClass()));
item.add(panel);
item.add(AttributeModifier.append("class", createStyleClassModel(item.getModel())));

item.add(new VisibleEnableBehaviour() {
Expand All @@ -154,10 +161,23 @@ public boolean isVisible() {
});
}
};
values.add(new AttributeModifier("class", getValuesClass()));
values.setReuseItems(true);
add(values);
}

protected String getInputCssClass(){
return"col-xs-9";
}

protected String getValuesClass(){
return "col-md-6";
}

protected String getValueCssClass(){
return "row";
}

private String loadHelpText(IModel<PropertyWrapper> model) {
PrismProperty property = model.getObject().getItem();
PrismPropertyDefinition def = property.getDefinition();
Expand Down
Expand Up @@ -17,8 +17,8 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div class="row">
<div class="col-xs-9" wicket:id="input"/>
<div wicket:id="valueContainer">
<div wicket:id="input"/>

<div class="col-xs-3">
<span class="btn-group">
Expand Down
Expand Up @@ -44,6 +44,7 @@
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.extensions.yui.calendar.DateTimeField;
import org.apache.wicket.feedback.ComponentFeedbackMessageFilter;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.markup.html.form.TextField;
Expand All @@ -64,27 +65,36 @@
public class PrismValuePanel extends Panel {

private static final String ID_FEEDBACK = "feedback";
private static final String ID_VALUE_CONTAINER = "valueContainer";

private IModel<ValueWrapper> model;

public PrismValuePanel(String id, IModel<ValueWrapper> model, IModel<String> label, Form form) {
public PrismValuePanel(String id, IModel<ValueWrapper> model, IModel<String> label, Form form,
String valueCssClass, String inputCssClass){
super(id);
Validate.notNull(model, "Property value model must not be null.");
this.model = model;

initLayout(label, form);
initLayout(label, form, valueCssClass, inputCssClass);
}

private void initLayout(IModel<String> label, Form form) {
private void initLayout(IModel<String> label, Form form, String valueCssClass, String inputCssClass) {
//container
WebMarkupContainer valueContainer = new WebMarkupContainer(ID_VALUE_CONTAINER);
valueContainer.setOutputMarkupId(true);
valueContainer.add(new AttributeModifier("class", valueCssClass));
add(valueContainer);

//feedback
FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK);
feedback.setOutputMarkupId(true);
add(feedback);

//input
InputPanel input = createInputComponent("input", label, form);
input.add(new AttributeModifier("class", inputCssClass));
initAccessBehaviour(input);
add(input);
valueContainer.add(input);

feedback.setFilter(new ComponentFeedbackMessageFilter(input.getBaseFormComponent()));

Expand All @@ -103,7 +113,7 @@ public boolean isVisible() {
return isAddButtonVisible();
}
});
add(addButton);
valueContainer.add(addButton);

AjaxLink removeButton = new AjaxLink("removeButton") {

Expand All @@ -119,7 +129,7 @@ public boolean isVisible() {
return isRemoveButtonVisible();
}
});
add(removeButton);
valueContainer.add(removeButton);
}

private IModel<String> createHelpModel() {
Expand Down
Expand Up @@ -33,6 +33,12 @@ <h3 style="margin-left: 20px;"><wicket:message key="PageRoleEditor.subtitle.acti
<div class="form-group" wicket:id="adminStatus" />
<div class="form-group" wicket:id="dateFrom" />
<div class="form-group" wicket:id="dateTo" />

<!--Extension-->
<h3 wicket:id="extensionLabel" style="margin-left: 20px;"></h3>
<div class="form-group" wicket:id="extension">
<div wicket:id="property"/>
</div>
</div>

<div class="col-md-6">
Expand Down

0 comments on commit 1926965

Please sign in to comment.