diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/common/components/NewAllocationSelector.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/common/components/NewAllocationSelector.java index 7dcded557..9e6257450 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/common/components/NewAllocationSelector.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/common/components/NewAllocationSelector.java @@ -153,7 +153,7 @@ public class NewAllocationSelector extends AllocationSelector { public NewAllocationSelectorController getController() { return (NewAllocationSelectorController) this - .getVariable("controller", true); + .getVariable("selectorController", true); } public void allowSelectMultipleResources(boolean multiple) { diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationController.java index 2f7b5184f..208fd341f 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationController.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationController.java @@ -152,6 +152,7 @@ public class ResourceAllocationController extends GenericForwardComposer { allResourcesPerDay.setWidth("80px"); newAllocationSelector.setLimitingResourceFilter(false); newAllocationSelectorCombo.setLimitingResourceFilter(false); + newAllocationSelector.allowSelectMultipleResources(true); initAllocationLabels(); makeReadyInputsForCalculationTypes(); } diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/resources/search/NewAllocationSelectorController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/resources/search/NewAllocationSelectorController.java index 4bd2da73d..669732927 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/resources/search/NewAllocationSelectorController.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/resources/search/NewAllocationSelectorController.java @@ -61,8 +61,9 @@ import org.zkoss.zul.TreeitemRenderer; import org.zkoss.zul.Treerow; /** - * Controller for searching for {@link Resource} * @author Diego Pino Garcia + * + * Controller for searching for {@link Resource} */ public class NewAllocationSelectorController extends AllocationSelectorController { @@ -88,16 +89,13 @@ public class NewAllocationSelectorController extends @Override public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); - comp.setVariable("controller", this, true); - initController(); + comp.setVariable("selectorController", this, true); + initializeComponents(); } - /** - * Initializes ZUL components - */ - private void initController() { - doInitialSelection(); - // Add event listener onSelect to criterionsTree widget + private void initializeComponents() { + + // Initialize criteria tree if (criterionsTree != null) { criterionsTree.addEventListener("onSelect", new EventListener() { @@ -106,15 +104,13 @@ public class NewAllocationSelectorController extends @Override public void onEvent(Event event) throws Exception { searchResources("", getSelectedCriterions()); + showSelectedAllocations(); } }); } - - // Initialize components criterionsTree.setTreeitemRenderer(criterionRenderer); - listBoxResources.setItemRenderer(getListitemRenderer()); - refreshListBoxResources(); + // Initialize found resources box listBoxResources.addEventListener(Events.ON_SELECT, new EventListener() { @@ -123,8 +119,12 @@ public class NewAllocationSelectorController extends if (isGenericType()) { returnToSpecificDueToResourceSelection(); } + showSelectedAllocations(); } }); + listBoxResources.setItemRenderer(getListitemRenderer()); + + // Initialize radio group of selector types allocationTypeSelector.addEventListener(Events.ON_CHECK, new EventListener() { @@ -136,6 +136,24 @@ public class NewAllocationSelectorController extends showSelectedAllocations(); } }); + doInitialSelection(); + } + + private void showSelectedAllocations() { + allocationSelectedItems.setValue(buildSelectedAllocationsString()); + } + + private String buildSelectedAllocationsString() { + if (currentAllocationType == AllocationType.SPECIFIC) { + List result = new ArrayList(); + for (Resource each : getSelectedResourcesOnListbox()) { + result.add(each.getShortDescription()); + } + return StringUtils.join(result, ","); + } else { + List criteria = getSelectedCriterions(); + return currentAllocationType.asCaption(criteria); + } } private List getAllResources() { @@ -158,6 +176,14 @@ public class NewAllocationSelectorController extends refreshListBoxResources(); } + private void refreshListBoxResources() { + refreshListBoxResources(getAllResources()); + } + + private void refreshListBoxResources(List resources) { + listBoxResources.setModel(new SimpleListModel(resources)); + } + private void returnToSpecificDueToResourceSelection() { currentAllocationType = AllocationType.SPECIFIC; List criteria = getSelectedCriterions(); @@ -261,10 +287,6 @@ public class NewAllocationSelectorController extends return result; } - private void refreshListBoxResources(List resources) { - listBoxResources.setModel(new SimpleListModel(resources)); - } - public ResourceListRenderer getListitemRenderer() { return resourceListRenderer; } @@ -281,10 +303,6 @@ public class NewAllocationSelectorController extends doInitialSelection(); } - private void refreshListBoxResources() { - refreshListBoxResources(getAllResources()); - } - public List getSelectedWorkers() { if (isGenericType()) { return allResourcesShown(); @@ -475,22 +493,8 @@ public class NewAllocationSelectorController extends listBoxResources.setMultiple(multiple); } - public void showSelectedAllocations() { - allocationSelectedItems.setValue(buildSelectedAllocationsString()); - } - - private String buildSelectedAllocationsString() { - - if (currentAllocationType == AllocationType.SPECIFIC) { - List result = new ArrayList(); - for (Resource each : getSelectedResourcesOnListbox()) { - result.add(each.getShortDescription()); - } - return StringUtils.join(result, ","); - } else { - List criterions = getSelectedCriterions(); - return currentAllocationType.asCaption(criterions); - } + public boolean isAllowSelectMultipleResources() { + return listBoxResources.isMultiple(); } } diff --git a/navalplanner-webapp/src/main/webapp/resources/search/allocation_selector.zul b/navalplanner-webapp/src/main/webapp/resources/search/allocation_selector.zul index 04ef6cd74..2c86bdd1a 100644 --- a/navalplanner-webapp/src/main/webapp/resources/search/allocation_selector.zul +++ b/navalplanner-webapp/src/main/webapp/resources/search/allocation_selector.zul @@ -24,45 +24,46 @@ ]]> - - + - + - - - + - - - - - - - + + - + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + @@ -70,24 +71,30 @@ - - - - - - - - + + + + + + + + + + + - + + +