Skip to content

Commit

Permalink
MID-1730 - CapabilityEditor implementation, hopefully finished.
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Suta committed Jul 10, 2014
1 parent 92d80c3 commit 1bb5520
Show file tree
Hide file tree
Showing 11 changed files with 393 additions and 102 deletions.
Expand Up @@ -27,7 +27,7 @@
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.component.wizard.resource.dto.CapabilityDto;
import com.evolveum.midpoint.web.page.PageBase;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.*;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
Expand Down Expand Up @@ -83,10 +83,15 @@ protected CapabilityStepDto load() {
private CapabilityStepDto loadModel(IModel<CapabilityStepDto> capabilityModel){
CapabilityStepDto dto = new CapabilityStepDto();
List<CapabilityDto> capabilityList = new ArrayList<>();
List<Class<? extends CapabilityType>> capabilityClassList = new ArrayList<>();

for(CapabilityDto cap: CapabilityPanel.capabilities){
if(!capabilityModel.getObject().getCapabilities().contains(cap)){
capabilityList.add(cap);
for(CapabilityDto cap: capabilityModel.getObject().getCapabilities()){
capabilityClassList.add(cap.getCapability().getClass());
}

for(Class<? extends CapabilityType> cap: CapabilityPanel.capabilities){
if(!capabilityClassList.contains(cap)){
capabilityList.add(createCapabilityDto(cap));
}
}

Expand All @@ -95,6 +100,28 @@ private CapabilityStepDto loadModel(IModel<CapabilityStepDto> capabilityModel){
return dto;
}

private CapabilityDto createCapabilityDto(Class<? extends CapabilityType> capabilityClass){
if(capabilityClass.equals(ActivationCapabilityType.class)){
return new CapabilityDto(new ActivationCapabilityType(), "Activation", true);
} else if(capabilityClass.equals(ScriptCapabilityType.class)){
return new CapabilityDto(new ScriptCapabilityType(), "Script", true);
} else if(capabilityClass.equals(CredentialsCapabilityType.class)){
return new CapabilityDto(new CredentialsCapabilityType(), "Credentials", true);
} else if(capabilityClass.equals(DeleteCapabilityType.class)){
return new CapabilityDto(new DeleteCapabilityType(), "Delete", true);
} else if(capabilityClass.equals(ReadCapabilityType.class)){
return new CapabilityDto(new ReadCapabilityType(), "Read", true);
} else if(capabilityClass.equals(DeleteCapabilityType.class)){
return new CapabilityDto(new CreateCapabilityType(), "Create", true);
} else if(capabilityClass.equals(UpdateCapabilityType.class)){
return new CapabilityDto(new UpdateCapabilityType(), "Update", true);
} else if(capabilityClass.equals(TestConnectionCapabilityType.class)){
return new CapabilityDto(new TestConnectionCapabilityType(), "Test Connection", true);
} else { //if(capabilityClass.equals(LiveSyncCapabilityType.class)){
return new CapabilityDto(new LiveSyncCapabilityType(), "Live Sync", true);
}
}

private ListDataProvider<CapabilityDto> createProvider(){
return new ListDataProvider<>(this,
new PropertyModel<List<CapabilityDto>>(model, CapabilityStepDto.F_CAPABILITIES));
Expand Down
Expand Up @@ -18,9 +18,9 @@
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>

<h3 wicket:id="label"></h3>
<h3><wicket:message key="capabilityActivationPanel.label"/></h3>

<h4 wicket:id="enabledDisabledLabel"></h4>
<h4><wicket:message key="capabilityActivationPanel.label.enabledDisabled" /></h4>
<div class="row">
<div class="col-xs-6">
<dl class="dl-horizontal">
Expand Down Expand Up @@ -49,7 +49,8 @@ <h4 wicket:id="enabledDisabledLabel"></h4>
<dt>
<label><wicket:message key="capabilityActivationPanel.label.attributeName" /></label>
</dt>
<dd><select class="form-control input-sm"></select></dd>
<!--<dd><select class="form-control input-sm"></select></dd>-->
<dd><select wicket:id="enableDisableSelect" class="form-control input-sm"></select></dd>
</dl>
<dl class="dl-horizontal">
<dt>
Expand All @@ -64,12 +65,54 @@ <h4 wicket:id="enabledDisabledLabel"></h4>
<div wicket:id="disableList" />
</dl>

<h4 wicket:id="labelStatus"></h4>
<p class="text-danger"><wicket:message key="capabilityActivationPanel.label.status.message" /></p>
<h4><wicket:message key="capabilityActivationPanel.label.status" /></h4>
<div class="row">
<div class="col-xs-6">
<dl class="dl-horizontal">
<dt>
<label><wicket:message key="capabilityActivationPanel.label.enabled" /></label>
</dt>
<dd><input wicket:id="statusEnabled" type="checkbox" value="checked"/></dd>
</dl>
</div>
<div class="col-xs-6">
<dl class="dl-horizontal">
<dt>
<label><wicket:message key="capabilityActivationPanel.label.returnedByDefault" /></label>
</dt>
<dd><input wicket:id="statusReturnedByDefault" type="checkbox" value="checked"/></dd>
</dl>
<dl class="dl-horizontal">
<dt>
<label><wicket:message key="capabilityActivationPanel.label.ignoreAttribute"/></label>
</dt>
<dd><input wicket:id="statusIgnoreAttribute" type="checkbox" value="checked"/></dd>
</dl>
</div>
</div>
<dl class="dl-horizontal">
<dt>
<label><wicket:message key="capabilityActivationPanel.label.attributeName" /></label>
</dt>
<dd><select wicket:id="statusSelect" class="form-control input-sm"></select></dd>
<!--<dd><select class="form-control input-sm"></select></dd>-->
</dl>
<dl class="dl-horizontal">
<dt>
<label><wicket:message key="capabilityActivationPanel.label.enableList" /></label>
</dt>
<div wicket:id="statusEnableList" />
</dl>
<dl class="dl-horizontal">
<dt>
<label><wicket:message key="capabilityActivationPanel.label.disableList" /></label>
</dt>
<div wicket:id="statusDisableList" />
</dl>

<div class="row">
<div class="col-xs-6">
<h4 wicket:id="labelValidFrom"></h4>
<h4><wicket:message key="capabilityActivationPanel.label.validFrom" /></h4>
<dl class="dl-horizontal">
<dt>
<label><wicket:message key="capabilityActivationPanel.label.enabled" /></label>
Expand All @@ -84,7 +127,7 @@ <h4 wicket:id="labelValidFrom"></h4>
</dl>
</div>
<div class="col-xs-6">
<h4 wicket:id="labelValidTo"></h4>
<h4><wicket:message key="capabilityActivationPanel.label.validTo" /></h4>
<dl class="dl-horizontal">
<dt>
<label><wicket:message key="capabilityActivationPanel.label.enabled" /></label>
Expand Down
Expand Up @@ -17,12 +17,14 @@

import com.evolveum.midpoint.web.component.util.SimplePanel;
import com.evolveum.midpoint.web.component.wizard.resource.dto.CapabilityDto;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.model.StringResourceModel;

import javax.xml.namespace.QName;
import java.util.List;

/**
Expand All @@ -44,6 +46,13 @@ public class CapabilityActivationPanel extends SimplePanel{
private static final String ID_CHECK_VALID_FROM_RETURNED = "validFromReturned";
private static final String ID_CHECK_VALID_TO_ENABLED = "validToEnabled";
private static final String ID_CHECK_VALID_TO_RETURNED = "validToReturned";
private static final String ID_CHECK_STATUS_ENABLED = "statusEnabled";
private static final String ID_CHECK_STATUS_RETURNED = "statusReturnedByDefault";
private static final String ID_CHECK_STATUS_IGNORE = "statusIgnoreAttribute";
private static final String ID_STATUS_ENABLE_LIST = "statusEnableList";
private static final String ID_STATUS_DISABLE_LIST = "statusDisableList";
private static final String ID_SELECT_ENABLE_DISABLE = "enableDisableSelect";
private static final String ID_SELECT_STATUS = "statusSelect";


public CapabilityActivationPanel(String componentId, IModel<CapabilityDto> model){
Expand All @@ -52,25 +61,6 @@ public CapabilityActivationPanel(String componentId, IModel<CapabilityDto> model

@Override
protected void initLayout(){
Label label = new Label(ID_LABEL, createStringResource("capabilityActivationPanel.label"));
add(label);

Label enableDisableLabel = new Label(ID_LABEL_ENABLED_DISABLED,
createStringResource("capabilityActivationPanel.label.enabledDisabled"));
add(enableDisableLabel);

Label statusLabel = new Label(ID_LABEL_STATUS,
createStringResource("capabilityActivationPanel.label.status"));
add(statusLabel);

Label validFromLabel = new Label(ID_LABEL_VALID_FROM,
createStringResource("capabilityActivationPanel.label.validFrom"));
add(validFromLabel);

Label validToLabel = new Label(ID_LABEL_VALID_TO,
createStringResource("capabilityActivationPanel.label.validTo"));
add(validToLabel);

CheckBox enabled = new CheckBox(ID_CHECK_ENABLED,
new PropertyModel<Boolean>(getModel(), "capability.enableDisable.enabled."));
add(enabled);
Expand Down Expand Up @@ -99,6 +89,39 @@ protected void initLayout(){
new PropertyModel<Boolean>(getModel(), "capability.validTo.returnedByDefault"));
add(validToReturned);

CheckBox statusEnabled = new CheckBox(ID_CHECK_STATUS_ENABLED,
new PropertyModel<Boolean>(getModel(), "capability.status.enabled"));
add(statusEnabled);

CheckBox statusReturned = new CheckBox(ID_CHECK_STATUS_RETURNED,
new PropertyModel<Boolean>(getModel(), "capability.status.returnedByDefault"));
add(statusReturned);

CheckBox statusIgnore = new CheckBox(ID_CHECK_STATUS_IGNORE,
new PropertyModel<Boolean>(getModel(), "capability.status.ignoreAttribute"));
add(statusIgnore);

CapabilityListRepeater statusEnableList = new CapabilityListRepeater(ID_STATUS_ENABLE_LIST,
new PropertyModel<List<String>>(getModel(), "capability.status.enableValue")){

@Override
protected StringResourceModel createEmptyItemPlaceholder(){
return createStringResource("capabilityActivationPanel.list.placeholder");
}
};
add(statusEnableList);

CapabilityListRepeater statusDisableList = new CapabilityListRepeater(ID_STATUS_DISABLE_LIST,
new PropertyModel<List<String>>(getModel(), "capability.status.enableValue")){

@Override
protected StringResourceModel createEmptyItemPlaceholder(){
return createStringResource("capabilityActivationPanel.list.placeholder");
}
};
add(statusDisableList);


CapabilityListRepeater enableList = new CapabilityListRepeater(ID_ENABLE_LIST,
new PropertyModel<List<String>>(getModel(), "capability.enableDisable.enableValue")){

Expand All @@ -118,6 +141,35 @@ protected StringResourceModel createEmptyItemPlaceholder(){
}
};
add(disableList);

IChoiceRenderer renderer = new IChoiceRenderer<QName>() {

@Override
public Object getDisplayValue(QName object) {
return object.getLocalPart();
}

@Override
public String getIdValue(QName object, int index) {
return Integer.toString(index);
}
};

DropDownChoice enableDisableChoice = new DropDownChoice(ID_SELECT_ENABLE_DISABLE,
new PropertyModel<QName>(getModel(), "capability.enableDisable.attribute"),
createAttributeChoiceModel(), renderer);
add(enableDisableChoice);

DropDownChoice statusChoice = new DropDownChoice(ID_SELECT_STATUS,
new PropertyModel<QName>(getModel(), "capability.status.attribute"),
createAttributeChoiceModel(), renderer);
add(statusChoice);
}

public IModel<List<QName>> createAttributeChoiceModel(){
return null;
}



}
Expand Up @@ -18,7 +18,7 @@
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>

<h3 wicket:id="label"></h3>
<h3><wicket:message key="capabilityCredentialsPanel.label" /></h3>

<dl class="dl-horizontal">
<dt>
Expand Down
Expand Up @@ -40,10 +40,6 @@ public CapabilityCredentialsPanel(String componentId, IModel<CapabilityDto> mode

@Override
protected void initLayout(){

Label label = new Label(ID_LABEL, createStringResource("capabilityCredentialsPanel.label"));
add(label);

Label passLabel = new Label(ID_LABEL_PASSWORD, createStringResource("capabilityCredentialsPanel.label.password"));
add(passLabel);

Expand Down
Expand Up @@ -42,6 +42,7 @@ <h3><wicket:message key="CapabilityPanel.title" /></h3>

<div class="main-button-bar">
<a wicket:id="capabilityAdd" class="btn btn-success"><i class="fa fa-fw fa-plus"/></a>
<a class="btn btn-success" wicket:id="saveButton"><i class="fa fa-floppy-o" /></a>
</div>
</div>

Expand Down

0 comments on commit 1bb5520

Please sign in to comment.