ItEr17S12CUAltaTipoParteDeTraballo: Using new macro compnent TwoWaySelector for the OrderElement edit window.
This commit is contained in:
parent
cdd8560676
commit
3a6597b610
2 changed files with 27 additions and 71 deletions
|
|
@ -3,6 +3,7 @@ package org.navalplanner.web.orders;
|
|||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -243,6 +244,10 @@ public class OrderElementController extends GenericForwardComposer {
|
|||
"At least one HoursGroup is needed");
|
||||
}
|
||||
|
||||
for (CriterionType criterionType : getCriterionTypes()) {
|
||||
removeCriterionsFromHoursGroup(criterionType);
|
||||
}
|
||||
|
||||
Clients.closeErrorBox(window.getFellow("hoursGroupsListbox"));
|
||||
window.setVisible(false);
|
||||
Util.reloadBindings(window.getParent());
|
||||
|
|
@ -298,18 +303,18 @@ public class OrderElementController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the list of possible {@link CriterionType}.
|
||||
* Gets the set of possible {@link CriterionType}.
|
||||
*
|
||||
* @return A {@link List} of {@link CriterionType}
|
||||
* @return A {@link Set} of {@link CriterionType}
|
||||
*/
|
||||
public List<CriterionType> getCriterionTypes() {
|
||||
public Set<CriterionType> getCriterionTypes() {
|
||||
if (model == null) {
|
||||
return new ArrayList<CriterionType>();
|
||||
return new HashSet<CriterionType>();
|
||||
}
|
||||
|
||||
List<CriterionType> list = model.getCriterionTypes();
|
||||
list.removeAll(getSelectedCriterionTypes());
|
||||
return list;
|
||||
return new HashSet<CriterionType>(list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -318,7 +323,13 @@ public class OrderElementController extends GenericForwardComposer {
|
|||
* @return A {@link List} of {@link CriterionType}
|
||||
*/
|
||||
public Set<CriterionType> getSelectedCriterionTypes() {
|
||||
return selectedCriterionTypes;
|
||||
return new HashSet<CriterionType>(selectedCriterionTypes);
|
||||
}
|
||||
|
||||
public void setSelectedCriterionTypes(
|
||||
Set<CriterionType> selectedCriterionTypes) {
|
||||
this.selectedCriterionTypes = selectedCriterionTypes;
|
||||
Util.reloadBindings(window);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -345,39 +356,6 @@ public class OrderElementController extends GenericForwardComposer {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the selected {@link CriterionType} to the selectedCriterionTypes
|
||||
* attribute.
|
||||
*
|
||||
* @param selectedItems
|
||||
* {@link Set} of {@link Listitem} with the selected
|
||||
* {@link CriterionType}
|
||||
*/
|
||||
public void assignCriterions(Set<Listitem> selectedItems) {
|
||||
for (Listitem listitem : selectedItems) {
|
||||
CriterionType value = (CriterionType) listitem.getValue();
|
||||
selectedCriterionTypes.add(value);
|
||||
}
|
||||
Util.reloadBindings(window);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the selected {@link CriterionType} from the
|
||||
* selectedCriterionTypes attribute.
|
||||
*
|
||||
* @param selectedItems
|
||||
* {@link Set} of {@link Listitem} with the selected
|
||||
* {@link CriterionType}
|
||||
*/
|
||||
public void unassignCriterions(Set<Listitem> selectedItems) {
|
||||
for (Listitem listitem : selectedItems) {
|
||||
CriterionType value = (CriterionType) listitem.getValue();
|
||||
selectedCriterionTypes.remove(value);
|
||||
removeCriterionsFromHoursGroup(value);
|
||||
}
|
||||
Util.reloadBindings(window);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the {@link Criterion} which matches with this type for all the
|
||||
* {@link HoursGroup}
|
||||
|
|
|
|||
|
|
@ -58,40 +58,18 @@
|
|||
onClick="orderElementController.manageCriterions();" />
|
||||
</hbox>
|
||||
|
||||
<vbox id="selectCriterions" visible="false">
|
||||
<vbox id="selectCriterions">
|
||||
|
||||
<label value="Manage criterions" />
|
||||
<label value="Manage criterions" />
|
||||
|
||||
<hbox>
|
||||
|
||||
<listbox id="selectedCriterionTypes" model="@{orderElementController.selectedCriterionTypes}"
|
||||
multiple="true" checkmark="true">
|
||||
<listhead>
|
||||
<listheader label="Selected types"></listheader>
|
||||
</listhead>
|
||||
<listitem self="@{each='criterion'}" value="@{criterion}">
|
||||
<listcell label="@{criterion.name}"></listcell>
|
||||
</listitem>
|
||||
</listbox>
|
||||
|
||||
<vbox>
|
||||
<button id="assignButton" label="<<"
|
||||
onClick="orderElementController.assignCriterions(criterionTypes.selectedItems);" />
|
||||
<button id="unassignButton" label=">>"
|
||||
onClick="orderElementController.unassignCriterions(selectedCriterionTypes.selectedItems);" />
|
||||
</vbox>
|
||||
|
||||
<listbox id="criterionTypes" model="@{orderElementController.criterionTypes}"
|
||||
multiple="true" checkmark="true">
|
||||
<listhead>
|
||||
<listheader label="Criterion types"></listheader>
|
||||
</listhead>
|
||||
<listitem self="@{each='criterion'}" value="@{criterion}">
|
||||
<listcell label="@{criterion.name}"></listcell>
|
||||
</listitem>
|
||||
</listbox>
|
||||
|
||||
</hbox>
|
||||
<twowayselector
|
||||
assignedObjects="@{orderElementController.selectedCriterionTypes,
|
||||
access='both'}"
|
||||
assignedTitle="Selected types"
|
||||
unassignedObjects="@{orderElementController.criterionTypes}"
|
||||
unassignedTitle="Criterion types"
|
||||
columns="name"
|
||||
/>
|
||||
|
||||
</vbox>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue