Skip to content

Commit

Permalink
MID-1730 - CapabilityEditor small code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Suta committed Jul 10, 2014
1 parent 8c29330 commit e84a263
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 56 deletions.
Expand Up @@ -21,12 +21,10 @@
import com.evolveum.midpoint.web.component.data.BaseSortableDataProvider;
import com.evolveum.midpoint.web.component.data.TablePanel;
import com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn;
import com.evolveum.midpoint.web.component.data.column.LinkColumn;
import com.evolveum.midpoint.web.component.util.ListDataProvider;
import com.evolveum.midpoint.web.component.util.LoadableModel;
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.*;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
Expand All @@ -46,7 +44,6 @@
* */
public class AddCapabilityDialog extends ModalWindow{

private static final Trace LOGGER = TraceManager.getTrace(AddCapabilityDialog.class);
private static final String ID_TABLE = "table";
private static final String ID_CANCEL = "cancelButton";
private static final String ID_ADD = "addButton";
Expand All @@ -62,7 +59,7 @@ public AddCapabilityDialog(String id, final IModel<CapabilityStepDto> capability
model = new LoadableModel<CapabilityStepDto>() {
@Override
protected CapabilityStepDto load() {
return loadModel(capabilityModel); //To change body of implemented methods use File | Settings | File Templates.
return loadModel(capabilityModel);
}
};

Expand Down
Expand Up @@ -49,7 +49,6 @@ <h4><wicket:message key="capabilityActivationPanel.label.enabledDisabled" /></h4
<dt>
<label><wicket:message key="capabilityActivationPanel.label.attributeName" /></label>
</dt>
<!--<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">
Expand Down Expand Up @@ -95,7 +94,6 @@ <h4><wicket:message key="capabilityActivationPanel.label.status" /></h4>
<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>
Expand Down
Expand Up @@ -32,16 +32,11 @@
* */
public class CapabilityActivationPanel extends SimplePanel{

private static final String ID_LABEL = "label";
private static final String ID_LABEL_ENABLED_DISABLED = "enabledDisabledLabel";
private static final String ID_CHECK_ENABLED = "enabled";
private static final String ID_CHECK_RETURNED = "returnedByDefault";
private static final String ID_CHECK_IGNORE = "ignoreAttribute";
private static final String ID_ENABLE_LIST = "enableList";
private static final String ID_DISABLE_LIST = "disableList";
private static final String ID_LABEL_STATUS = "labelStatus";
private static final String ID_LABEL_VALID_FROM = "labelValidFrom";
private static final String ID_LABEL_VALID_TO = "labelValidTo";
private static final String ID_CHECK_VALID_FROM_ENABLED = "validFromEnabled";
private static final String ID_CHECK_VALID_FROM_RETURNED = "validFromReturned";
private static final String ID_CHECK_VALID_TO_ENABLED = "validToEnabled";
Expand Down
Expand Up @@ -28,7 +28,6 @@
* */
public class CapabilityCredentialsPanel extends SimplePanel{

private static final String ID_LABEL = "label";
private static final String ID_ENABLED = "enabled";
private static final String ID_LABEL_PASSWORD = "password";
private static final String ID_PASSWORD_ENABLED = "passEnabled";
Expand Down
Expand Up @@ -16,9 +16,6 @@
package com.evolveum.midpoint.web.component.wizard.resource.component.capability;

import com.evolveum.midpoint.web.component.util.SimplePanel;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import org.apache.commons.lang.StringUtils;
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;
Expand All @@ -27,7 +24,6 @@
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.StringResourceModel;

Expand Down Expand Up @@ -83,8 +79,6 @@ protected void onUpdate(AjaxRequestTarget target) {}
}
};
add(repeater);


}

private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item) {
Expand Down
Expand Up @@ -28,10 +28,9 @@ <h3><wicket:message key="CapabilityPanel.title" /></h3>
<tbody wicket:id="tableRows">
<tr wicket:id="capabilityRow">
<td class="capability-item">
<span wicket:id="capabilityName" />
</td>
<td>
<a wicket:id="capabilityEdit" class="btn btn-primary btn-sm"><i class="fa fa-pencil-square-o" /></a>
<a wicket:id="capabilityLink">
<span wicket:id="capabilityName" />
</a>
</td>
<td>
<a wicket:id="capabilityDelete" class="btn btn-danger btn-sm"><i class="fa fa-fw fa-minus" /></a>
Expand Down
Expand Up @@ -86,8 +86,8 @@ public class CapabilityPanel extends SimplePanel{
private static final String ID_CAPABILITY_TABLE = "tableRows";
private static final String ID_CAPABILITY_ROW = "capabilityRow";
private static final String ID_CAPABILITY_NAME = "capabilityName";
private static final String ID_CAPABILITY_LINK = "capabilityLink";
private static final String ID_CAPABILITY_DELETE = "capabilityDelete";
private static final String ID_CAPABILITY_EDIT = "capabilityEdit";
private static final String ID_CAPABILITY_ADD = "capabilityAdd";
private static final String ID_CAPABILITY_CONFIG = "capabilityConfig";
private static final String ID_BUTTON_SAVE = "saveButton";
Expand Down Expand Up @@ -183,26 +183,26 @@ protected PrismObject<ResourceType> load() {
protected void populateItem(final Item<CapabilityDto> capabilityRow) {
final CapabilityDto dto = capabilityRow.getModelObject();

Label label = new Label(ID_CAPABILITY_NAME, new PropertyModel<>(dto, CapabilityDto.F_VALUE));
capabilityRow.add(label);

AjaxLink deleteLink = new AjaxLink(ID_CAPABILITY_DELETE) {
AjaxLink name = new AjaxLink(ID_CAPABILITY_LINK) {

@Override
public void onClick(AjaxRequestTarget target) {
deleteCapabilityPerformed(target, dto);
editCapabilityPerformed(target, dto);
}
};
capabilityRow.add(deleteLink);
Label label = new Label(ID_CAPABILITY_NAME, new PropertyModel<>(dto, CapabilityDto.F_VALUE));
name.add(label);
capabilityRow.add(name);


AjaxLink editLink = new AjaxLink(ID_CAPABILITY_EDIT) {
AjaxLink deleteLink = new AjaxLink(ID_CAPABILITY_DELETE) {

@Override
public void onClick(AjaxRequestTarget target) {
editCapabilityPerformed(target, dto);
deleteCapabilityPerformed(target, dto);
}
};
capabilityRow.add(editLink);
capabilityRow.add(deleteLink);

capabilityRow.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<Object>() {

Expand Down Expand Up @@ -337,28 +337,6 @@ protected List<QName> load() {
target.add(getTable());
}

private List<String> loadResourceAccountObjectAttributes(){
List<String> choices = new ArrayList<>();

PrismObject<ResourceType> resourcePrism = resourceModel.getObject();

try {
ResourceSchema schema = RefinedResourceSchema.getResourceSchema(resourcePrism, getPageBase().getPrismContext());
ObjectClassComplexTypeDefinition def = schema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);

for(ResourceAttributeDefinition attribute: def.getAttributeDefinitions()){
String qName = attribute.getNativeAttributeName();
choices.add(qName);
}

} catch (Exception e){
LoggingUtils.logException(LOGGER, "Couldn't load resource schema attributes.", e);
error("Couldn't load resource schema attributes" + e);
//TODO - show this to the user
}
return choices;
}

private void savePerformed(AjaxRequestTarget target){
PrismObject<ResourceType> oldResource;
PrismObject<ResourceType> newResource = (PrismObject<ResourceType>)getModel().getObject();
Expand Down
Expand Up @@ -20,7 +20,6 @@
import com.evolveum.midpoint.web.component.wizard.resource.dto.CapabilityDto;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ProvisioningScriptHostType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
Expand All @@ -34,7 +33,6 @@
* */
public class CapabilityScriptPanel extends SimplePanel {

private static final String ID_LABEL = "label";
private static final String ID_ENABLED = "enabled";
private static final String ID_ON_CONNECTOR = "onConnectorValue";
private static final String ID_ON_RESOURCE = "onResourceValue";
Expand Down

0 comments on commit e84a263

Please sign in to comment.