Skip to content

Commit

Permalink
Fixing wrong invocaiton of getString() (MID-3225)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jun 22, 2016
1 parent 28ad3c8 commit d19f56e
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 66 deletions.
@@ -1,3 +1,18 @@
/*
* Copyright (c) 2010-2016 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.web.page.admin.resources;

import org.apache.wicket.AttributeModifier;
Expand All @@ -6,11 +21,12 @@
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.model.ResourceModel;

import com.evolveum.midpoint.gui.api.component.BasePanel;

public class CapabilitiesPanel extends BasePanel<CapabilitiesDto>{
public class CapabilitiesPanel extends BasePanel<CapabilitiesDto> {

private static final String ID_ACTIVATION = "activation";
private static final String ID_ACTIVATION_LOCKOUT_STATUS = "activationLockoutStatus";
private static final String ID_ACTIVATION_STATUS = "activationStatus";
Expand All @@ -28,55 +44,54 @@ public class CapabilitiesPanel extends BasePanel<CapabilitiesDto>{
private static final String ID_DELETE = "delete";
private static final String ID_READ = "read";
private static final String ID_CONNECTOR_SCRIPT = "script";

private static final long serialVersionUID = 1L;

public CapabilitiesPanel(String id, IModel<CapabilitiesDto> model) {
super(id, model);

initLayout();

}

private void initLayout() {
createCapabilityButton(ID_ACTIVATION);
createCapabilityButton(ID_CREDENTIALS);
createCapabilityButton(ID_LIVE_SYNC);
createCapabilityButton(ID_TEST);
createCapabilityButton(ID_CREATE);
createCapabilityButton(ID_UPDATE);
createCapabilityButton(ID_ADD_ATTRIBUE_VALUES);
createCapabilityButton(ID_DELETE);
createCapabilityButton(ID_READ);
createCapabilityButton(ID_CONNECTOR_SCRIPT);
createCapabilityButton(ID_PASSWORD);
createCapabilityButton(ID_PAGED_SEARCH);
createCapabilityButton(ID_AUXILIARY_OBJECT_CLASSES);
createCapabilityButton(ID_ACTIVATION_VALIDITY);
createCapabilityButton(ID_ACTIVATION_STATUS);
createCapabilityButton(ID_ACTIVATION_LOCKOUT_STATUS);
createCapabilityButton(ID_COUNT_OBJECTS);
}

private void createCapabilityButton(String id){
AjaxLink<Boolean> button = new AjaxLink<Boolean>(id, new PropertyModel<Boolean>(getModel(), id)){
@Override
public void onClick(AjaxRequestTarget target) {
//TODO:
}
};
button.add(new AttributeModifier("class", button.getModelObject() ? "btn btn-app btn-resource-capability bg-light-blue" : "btn btn-app btn-resource-capability bg-gray text-light-blue"));
button.add(new Label("label", getString("CapabilitiesType."+id)));
add(button);
}
private void initLayout() {

createCapabilityButton(ID_ACTIVATION);
createCapabilityButton(ID_CREDENTIALS);
createCapabilityButton(ID_LIVE_SYNC);
createCapabilityButton(ID_TEST);
createCapabilityButton(ID_CREATE);
createCapabilityButton(ID_UPDATE);
createCapabilityButton(ID_ADD_ATTRIBUE_VALUES);
createCapabilityButton(ID_DELETE);
createCapabilityButton(ID_READ);
createCapabilityButton(ID_CONNECTOR_SCRIPT);
createCapabilityButton(ID_PASSWORD);
createCapabilityButton(ID_PAGED_SEARCH);
createCapabilityButton(ID_AUXILIARY_OBJECT_CLASSES);
createCapabilityButton(ID_ACTIVATION_VALIDITY);
createCapabilityButton(ID_ACTIVATION_STATUS);
createCapabilityButton(ID_ACTIVATION_LOCKOUT_STATUS);
createCapabilityButton(ID_COUNT_OBJECTS);

}

private void createCapabilityButton(String id) {
AjaxLink<Boolean> button = new AjaxLink<Boolean>(id, new PropertyModel<Boolean>(getModel(), id)) {

@Override
public void onClick(AjaxRequestTarget target) {
// TODO:
}

};

button.add(new AttributeModifier("class",
button.getModelObject() ? "btn btn-app btn-resource-capability bg-light-blue"
: "btn btn-app btn-resource-capability bg-gray text-light-blue"));

button.add(new Label("label", new ResourceModel("CapabilitiesType." + id)));

add(button);
}

}
Expand Up @@ -230,17 +230,6 @@ private void taskDetailsPerformed(AjaxRequestTarget target, String taskOid) {
setResponsePage(PageTaskEdit.class, parameters);
}

private InfoBoxPanel addCapabilityMappingInfo(String fieldId, SourceTarget sourceTarget,
String messageKey) {
String backgroundColor = "bg-green";

InfoBoxType infoBoxType = new InfoBoxType(backgroundColor, sourceTarget.getCssClass(),
getString(messageKey));
Model<InfoBoxType> boxModel = new Model<InfoBoxType>(infoBoxType);

return new InfoBoxPanel(fieldId, boxModel);
}

private InfoBoxPanel createSourceTargetInfo(ResourceType resource) {

String backgroundColor = "bg-aqua";
Expand All @@ -265,11 +254,11 @@ private InfoBoxPanel createSourceTargetInfo(ResourceType resource) {
}

InfoBoxType infoBoxType = new InfoBoxType(backgroundColor, sourceTarget.getCssClass(),
getString("PageResource.resource.mappings"));
infoBoxType.setNumber(getString(numberKey));
parentPage.getString("PageResource.resource.mappings"));
infoBoxType.setNumber(parentPage.getString(numberKey));

if (isSynchronizationDefined(resource)) {
infoBoxType.setDescription(getString("PageResource.resource.sync"));
infoBoxType.setDescription(parentPage.getString("PageResource.resource.sync"));
}

Model<InfoBoxType> boxModel = new Model<InfoBoxType>(infoBoxType);
Expand Down Expand Up @@ -304,7 +293,7 @@ private InfoBoxPanel createLastAvailabilityStatusInfo(ResourceType resource) {
}
}

InfoBoxType infoBoxType = new InfoBoxType(backgroundColor, icon, getString(messageKey));
InfoBoxType infoBoxType = new InfoBoxType(backgroundColor, icon, parentPage.getString(messageKey));

ConnectorType connectorType = resource.getConnector();
String connectorName = StringUtils.substringAfterLast(
Expand Down Expand Up @@ -345,25 +334,25 @@ private InfoBoxPanel createSchemaStatusInfo(ResourceType resource) {
}
}
int numAllDefinitions = refinedDefinitions.size();
numberMessage = numObjectTypes + " " + getString("PageResource.resource.objectTypes");
numberMessage = numObjectTypes + " " + parentPage.getString("PageResource.resource.objectTypes");
if (numAllDefinitions != 0) {
progress = numObjectTypes * 100 / numAllDefinitions;
if (progress > 100) {
progress = 100;
}
}
description = numAllDefinitions + " " + getString("PageResource.resource.schemaDefinitions");
description = numAllDefinitions + " " + parentPage.getString("PageResource.resource.schemaDefinitions");
} else {
numberMessage = getString("PageResource.resource.noSchema");
numberMessage = parentPage.getString("PageResource.resource.noSchema");
}
} catch (SchemaException e) {
backgroundColor = "bg-danger";
icon = "fa-warning";
numberMessage = getString("PageResource.resource.schemaError");
numberMessage = parentPage.getString("PageResource.resource.schemaError");
}

InfoBoxType infoBoxType = new InfoBoxType(backgroundColor, icon,
getString("PageResource.resource.schema"));
parentPage.getString("PageResource.resource.schema"));
infoBoxType.setNumber(numberMessage);
infoBoxType.setProgress(progress);
infoBoxType.setDescription(description);
Expand Down

0 comments on commit d19f56e

Please sign in to comment.