diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/PositionConstraintType.java b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/PositionConstraintType.java
index 3b5ae9490..7d7e0538a 100644
--- a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/PositionConstraintType.java
+++ b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/PositionConstraintType.java
@@ -20,12 +20,13 @@
*/
package org.navalplanner.business.planner.entities;
+
/**
* Enum with all possible ways of calculating the start of a task
* @author Óscar González Fernández
*/
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();
}
diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/taskedition/TaskPropertiesController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/taskedition/TaskPropertiesController.java
index 11bc41933..232a613ef 100644
--- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/taskedition/TaskPropertiesController.java
+++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/taskedition/TaskPropertiesController.java
@@ -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 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);
}
diff --git a/navalplanner-webapp/src/main/webapp/common/error.zul b/navalplanner-webapp/src/main/webapp/common/error.zul
index b8c9354a0..ec76463e7 100644
--- a/navalplanner-webapp/src/main/webapp/common/error.zul
+++ b/navalplanner-webapp/src/main/webapp/common/error.zul
@@ -45,7 +45,7 @@
-
+
diff --git a/navalplanner-webapp/src/main/webapp/common/event_error.zul b/navalplanner-webapp/src/main/webapp/common/event_error.zul
index 71ce1ff18..a783f5eb3 100644
--- a/navalplanner-webapp/src/main/webapp/common/event_error.zul
+++ b/navalplanner-webapp/src/main/webapp/common/event_error.zul
@@ -40,7 +40,7 @@
-
+