Fixed two translation issues.

* Fixed typo in "Stacktrace"
* Changed "START_NOT_EARLIER_THAN" for "start not earlier than"

FEA: ItEr74S04BugFixing
This commit is contained in:
Manuel Rego Casasnovas 2011-06-02 17:42:53 +02:00
parent ec3d8ba1c6
commit 04afbf3f06
4 changed files with 44 additions and 128 deletions

View file

@ -20,12 +20,13 @@
*/
package org.navalplanner.business.planner.entities;
/**
* Enum with all possible ways of calculating the start of a task <br />
* @author Óscar González Fernández <ogonzalez@igalia.com>
*/
public enum PositionConstraintType {
AS_SOON_AS_POSSIBLE(false) {
AS_SOON_AS_POSSIBLE(false, _("as soon as possible")) {
@Override
public PositionConstraintType newTypeAfterMoved() {
@ -37,7 +38,7 @@ public enum PositionConstraintType {
return true;
}
},
START_NOT_EARLIER_THAN(true) {
START_NOT_EARLIER_THAN(true, _("start not earlier than")) {
@Override
public PositionConstraintType newTypeAfterMoved() {
@ -49,7 +50,7 @@ public enum PositionConstraintType {
return true;
}
},
START_IN_FIXED_DATE(true) {
START_IN_FIXED_DATE(true, _("start in fixed date")) {
@Override
public PositionConstraintType newTypeAfterMoved() {
@ -61,7 +62,7 @@ public enum PositionConstraintType {
return true;
}
},
AS_LATE_AS_POSSIBLE(false) {
AS_LATE_AS_POSSIBLE(false, _("as late as possible")) {
@Override
public PositionConstraintType newTypeAfterMoved() {
@ -73,7 +74,7 @@ public enum PositionConstraintType {
return false;
}
},
FINISH_NOT_LATER_THAN(true) {
FINISH_NOT_LATER_THAN(true, _("finish not later than")) {
@Override
public PositionConstraintType newTypeAfterMoved() {
@ -86,10 +87,19 @@ public enum PositionConstraintType {
}
};
private boolean dateRequired;
/**
* Forces to mark the string as needing translation
*/
private static String _(String string) {
return string;
}
private PositionConstraintType(boolean dateRequired) {
private boolean dateRequired;
private String name;
private PositionConstraintType(boolean dateRequired, String name) {
this.dateRequired = dateRequired;
this.name = name;
}
public abstract PositionConstraintType newTypeAfterMoved();
@ -98,5 +108,9 @@ public enum PositionConstraintType {
return dateRequired;
}
public String getName() {
return name;
}
public abstract boolean appliesToTheStart();
}

View file

@ -72,117 +72,6 @@ import org.zkoss.zul.api.Tabpanel;
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class TaskPropertiesController extends GenericForwardComposer {
// This is a workaround, because in business we don't have access to
// I18nHelper
private enum WebStartConstraintType {
AS_SOON_AS_POSSIBLE(PositionConstraintType.AS_SOON_AS_POSSIBLE) {
@Override
public String getDescription() {
return _("as soon as possible");
}
@Override
public String getName() {
return _("AS_SOON_AS_POSSIBLE");
}
},
START_NOT_EARLIER_THAN(PositionConstraintType.START_NOT_EARLIER_THAN) {
@Override
public String getDescription() {
return _("start not earlier than");
}
@Override
public String getName() {
return _("START_NOT_EARLIER_THAN");
}
},
START_IN_FIXED_DATE(PositionConstraintType.START_IN_FIXED_DATE) {
@Override
public String getDescription() {
return _("start in fixed date");
}
@Override
public String getName() {
return _("START_IN_FIXED_DATE");
}
},
FINISH_NOT_LATER_THAN(PositionConstraintType.FINISH_NOT_LATER_THAN) {
@Override
public String getDescription() {
return _("finish not later than");
}
@Override
public String getName() {
return _("FINISH_NOT_LATER_THAN");
}
},
AS_LATE_AS_POSSIBLE(PositionConstraintType.AS_LATE_AS_POSSIBLE) {
@Override
public String getDescription() {
return _("as late as possible");
}
@Override
public String getName() {
return _("AS_LATE_AS_POSSIBLE");
}
};
public static void setItems(Combobox combo, Order order) {
combo.getChildren().clear();
for (WebStartConstraintType type : WebStartConstraintType.values()) {
if (type != AS_LATE_AS_POSSIBLE || order.getDeadline() != null) {
combo.appendChild(type.createCombo());
}
}
}
private final PositionConstraintType type;
private WebStartConstraintType(PositionConstraintType type) {
this.type = type;
}
public abstract String getName();
public abstract String getDescription();
private Comboitem createCombo() {
Comboitem result = new Comboitem();
result.setValue(this);
result.setLabel(this.getName());
result.setDescription(this.getDescription());
return result;
}
public static boolean representsType(Comboitem item,
PositionConstraintType type) {
WebStartConstraintType webType = (WebStartConstraintType) item
.getValue();
return webType.equivalentTo(type);
}
private boolean equivalentTo(PositionConstraintType type) {
return this.type == type;
}
public boolean isAssociatedDateRequired() {
return type.isAssociatedDateRequired();
}
public PositionConstraintType getType() {
return type;
}
}
/**
* Controller from the Gantt to manage common fields on edit {@link Task}
* popup.
*/
@Autowired
private IScenarioManager scenarioManager;
@ -230,7 +119,8 @@ public class TaskPropertiesController extends GenericForwardComposer {
order = taskElement.getOrderElement().getOrder();
}
WebStartConstraintType.setItems(startConstraintTypes, order);
// WebStartConstraintType.setItems(startConstraintTypes, order);
setItemsStartConstraintTypesCombo(order);
originalState = getResourceAllocationType(currentTaskElement);
setOldState(originalState);
@ -247,6 +137,18 @@ public class TaskPropertiesController extends GenericForwardComposer {
updateComponentValuesForTask();
}
private void setItemsStartConstraintTypesCombo(Order order) {
startConstraintTypes.getChildren().clear();
for (PositionConstraintType type : PositionConstraintType.values()) {
if (type != PositionConstraintType.AS_LATE_AS_POSSIBLE
|| order.getDeadline() != null) {
Comboitem comboitem = new Comboitem(_(type.getName()));
comboitem.setValue(type);
startConstraintTypes.appendChild(comboitem);
}
}
}
private Order findOrderIn(IContextWithPlannerTask<TaskElement> context) {
TaskElement topTask = context.getMapper().findAssociatedDomainObject(
findTopMostTask(context));
@ -327,7 +229,7 @@ public class TaskPropertiesController extends GenericForwardComposer {
for (Object component : startConstraintTypes.getChildren()) {
if (component instanceof Comboitem) {
Comboitem item = (Comboitem) component;
if (WebStartConstraintType.representsType(item, type)) {
if (((PositionConstraintType) item.getValue()) == type) {
return item;
}
}
@ -335,9 +237,9 @@ public class TaskPropertiesController extends GenericForwardComposer {
return null;
}
private void constraintTypeChoosen(WebStartConstraintType constraint) {
private void constraintTypeChoosen(PositionConstraintType constraint) {
startConstraintDate.setVisible(constraint.isAssociatedDateRequired());
updateStartConstraint(constraint.getType());
updateStartConstraint(constraint);
}
private void updateStartConstraint(PositionConstraintType type) {
@ -353,13 +255,13 @@ public class TaskPropertiesController extends GenericForwardComposer {
private boolean saveConstraintChanges() {
TaskPositionConstraint taskConstraint = currentTaskElementAsTaskLeafConstraint()
.getPositionConstraint();
WebStartConstraintType type = (WebStartConstraintType) startConstraintTypes
PositionConstraintType type = (PositionConstraintType) startConstraintTypes
.getSelectedItemApi().getValue();
IntraDayDate inputDate = type.isAssociatedDateRequired() ? IntraDayDate
.startOfDay(LocalDate.fromDateFields(startConstraintDate
.getValue())) : null;
if (taskConstraint.isValid(type.getType(), inputDate)) {
taskConstraint.update(type.getType(), inputDate);
if (taskConstraint.isValid(type, inputDate)) {
taskConstraint.update(type, inputDate);
if (currentContext != null) {
currentContext.recalculatePosition(currentTaskElement);
}
@ -392,7 +294,7 @@ public class TaskPropertiesController extends GenericForwardComposer {
@Override
public void onEvent(Event event) throws Exception {
WebStartConstraintType constraint = (WebStartConstraintType) startConstraintTypes
PositionConstraintType constraint = (PositionConstraintType) startConstraintTypes
.getSelectedItemApi().getValue();
constraintTypeChoosen(constraint);
}

View file

@ -45,7 +45,7 @@
<label value="${requestScope['javax.servlet.error.status_code']}" />
</row>
<row>
<label value="${i18n:_('Stacktracke:')}" />
<label value="${i18n:_('Stacktrace:')}" />
<textbox id="stacktrace" rows="20" width="600px" readonly="true" />
</row>
</rows>

View file

@ -40,7 +40,7 @@
<label value="${requestScope['javax.servlet.error.status_code']}" />
</row>
<row>
<label value="${i18n:_('Stacktracke:')}" />
<label value="${i18n:_('Stacktrace:')}" />
<textbox id="stacktrace" rows="20" width="600px" readonly="true" />
</row>
</rows>