ItEr35S09CUConfiguracionMaquinasItEr34S09: Configuration Unit Criterion requirements are added with explicit button press
This commit is contained in:
parent
adf0fdeb65
commit
647f043ac3
2 changed files with 21 additions and 17 deletions
|
|
@ -28,8 +28,6 @@ import java.util.List;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.resources.daos.ICriterionDAO;
|
||||
import org.navalplanner.business.resources.daos.IWorkerDAO;
|
||||
import org.navalplanner.business.resources.entities.Criterion;
|
||||
import org.navalplanner.business.resources.entities.CriterionWithItsType;
|
||||
import org.navalplanner.business.resources.entities.MachineWorkerAssignment;
|
||||
|
|
@ -40,13 +38,14 @@ import org.navalplanner.web.common.Level;
|
|||
import org.navalplanner.web.common.MessagesForUser;
|
||||
import org.navalplanner.web.common.Util;
|
||||
import org.navalplanner.web.common.components.Autocomplete;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.WrongValueException;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.Button;
|
||||
import org.zkoss.zul.Constraint;
|
||||
import org.zkoss.zul.Datebox;
|
||||
import org.zkoss.zul.Grid;
|
||||
import org.zkoss.zul.Listbox;
|
||||
import org.zkoss.zul.Listitem;
|
||||
import org.zkoss.zul.Row;
|
||||
import org.zkoss.zul.Rows;
|
||||
|
|
@ -60,12 +59,6 @@ import org.zkoss.zul.api.Bandbox;
|
|||
*/
|
||||
public class MachineConfigurationController extends GenericForwardComposer {
|
||||
|
||||
@Autowired
|
||||
private IWorkerDAO workerDAO;
|
||||
|
||||
@Autowired
|
||||
private ICriterionDAO criterionDAO;
|
||||
|
||||
private IMachineModel machineModel;
|
||||
|
||||
private IMessagesForUser messages;
|
||||
|
|
@ -118,14 +111,12 @@ public class MachineConfigurationController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
public List<MachineWorkerAssignment> getWorkerAssignments() {
|
||||
// Need to specify concrete unit
|
||||
MachineWorkersConfigurationUnit unit = (MachineWorkersConfigurationUnit) this.machineModel
|
||||
.getConfigurationUnitsOfMachine().iterator().next();
|
||||
return (List<MachineWorkerAssignment>) unit.getWorkerAssignments();
|
||||
}
|
||||
|
||||
public List<Criterion> getRequiredCriterions() {
|
||||
// Need to specify concrete unit
|
||||
MachineWorkersConfigurationUnit unit = (MachineWorkersConfigurationUnit) this.machineModel
|
||||
.getConfigurationUnitsOfMachine().iterator().next();
|
||||
return (List<Criterion>) unit.getRequiredCriterions();
|
||||
|
|
@ -154,7 +145,10 @@ public class MachineConfigurationController extends GenericForwardComposer {
|
|||
return repeated;
|
||||
}
|
||||
|
||||
public void addCriterionRequirement(Listitem item, Bandbox bandbox) {
|
||||
public void addCriterionRequirement(Button button) {
|
||||
Bandbox bandbox = (Bandbox) button.getPreviousSibling();
|
||||
Listitem item = ((Listbox) bandbox.getFirstChild().getFirstChild())
|
||||
.getSelectedItem();
|
||||
MachineWorkersConfigurationUnit unit = null;
|
||||
String unitString = ((Textbox) bandbox.getPreviousSibling()).getValue();
|
||||
try {
|
||||
|
|
@ -167,14 +161,23 @@ public class MachineConfigurationController extends GenericForwardComposer {
|
|||
CriterionWithItsType criterionAndType = (CriterionWithItsType) item
|
||||
.getValue();
|
||||
bandbox.setValue(criterionAndType.getNameAndType());
|
||||
|
||||
if (checkExistingCriterion(unit, criterionAndType.getCriterion())) {
|
||||
messages.showMessage(Level.ERROR,
|
||||
_("Criterion previously selected"));
|
||||
} else {
|
||||
machineModel.addCriterionRequirementToConfigurationUnit(unit,
|
||||
criterionAndType.getCriterion());
|
||||
bandbox.setValue("");
|
||||
}
|
||||
}
|
||||
Util.reloadBindings(bandbox.getNextSibling().getNextSibling());
|
||||
}
|
||||
|
||||
public void selectCriterionRequirement(Listitem item, Bandbox bandbox) {
|
||||
if (item != null) {
|
||||
CriterionWithItsType criterionAndType = (CriterionWithItsType) item
|
||||
.getValue();
|
||||
bandbox.setValue(criterionAndType.getNameAndType());
|
||||
} else {
|
||||
bandbox.setValue("");
|
||||
}
|
||||
|
|
@ -182,6 +185,7 @@ public class MachineConfigurationController extends GenericForwardComposer {
|
|||
Util.reloadBindings(bandbox.getNextSibling().getNextSibling());
|
||||
}
|
||||
|
||||
|
||||
public void deleteConfigurationUnit(MachineWorkersConfigurationUnit unit) {
|
||||
machineModel.removeConfigurationUnit(unit);
|
||||
Util.reloadBindings(configurationUnitsGrid);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
<grid fixedLayout="true"
|
||||
model="@{configurationUnit.workerAssignments}">
|
||||
<columns sizable="true">
|
||||
<column label="${i18n:_('Name')}" sort="auto" />
|
||||
<column label="${i18n:_('Name')}" />
|
||||
<column label="${i18n:_('Start date')}" />
|
||||
<column label="${i18n:_('End date')}" />
|
||||
<column label="${i18n:_('Operations')}" />
|
||||
|
|
@ -82,7 +82,7 @@
|
|||
<bandpopup>
|
||||
<listbox width="500px" height="150px" fixedLayout="true"
|
||||
model="@{assignedCriterionsController.criterionWithItsTypes}"
|
||||
onSelect="configurationController.addCriterionRequirement(self.selectedItem,self.parent.parent)">
|
||||
onSelect="configurationController.selectCriterionRequirement(self.selectedItem,self.parent.parent)">
|
||||
<listhead>
|
||||
<listheader label="Type" />
|
||||
<listheader label="Criterion" />
|
||||
|
|
@ -96,7 +96,7 @@
|
|||
</bandbox>
|
||||
|
||||
<button label="${i18n:_('Add new criterion requirement')}"
|
||||
onClick="configurationController.addCriterionRequirement(self.parent.parent.value,self)" disabled="true" />
|
||||
onClick="configurationController.addCriterionRequirement(self)" />
|
||||
|
||||
<panel title="${i18n:_('Criterion requirements')}" border="normal">
|
||||
<panelchildren>
|
||||
|
|
@ -104,7 +104,7 @@
|
|||
<grid fixedLayout="true"
|
||||
model="@{configurationUnit.requiredCriterions}">
|
||||
<columns sizable="true">
|
||||
<column label="${i18n:_('Name')}" sort="auto" />
|
||||
<column label="${i18n:_('Name')}" />
|
||||
<column label="${i18n:_('Operations')}" />
|
||||
</columns>
|
||||
<rows>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue