ItEr29S06CUAsignacionGrupoRecursosAPlanificacionItEr28S06: [Refactoring] Clear all settings in WorkerSearch when canceling selection
This commit is contained in:
parent
bd599b4b91
commit
98c2e260c8
4 changed files with 14 additions and 45 deletions
|
|
@ -20,13 +20,11 @@
|
|||
|
||||
package org.navalplanner.web.common.components;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.resources.entities.Worker;
|
||||
import org.navalplanner.web.resources.search.WorkerSearchController;
|
||||
import org.zkoss.zk.ui.HtmlMacroComponent;
|
||||
import org.zkoss.zul.Window;
|
||||
|
||||
/**
|
||||
* ZK macro component for searching {@link Worker} entities
|
||||
|
|
@ -36,21 +34,16 @@ import org.zkoss.zul.Window;
|
|||
@SuppressWarnings("serial")
|
||||
public class WorkerSearch extends HtmlMacroComponent {
|
||||
|
||||
List<Worker> workers = new ArrayList<Worker>();
|
||||
|
||||
public Window getWindow() {
|
||||
return (Window) getFellow("workerSearch");
|
||||
}
|
||||
|
||||
public List<Worker> getWorkers() {
|
||||
WorkerSearchController controller = (WorkerSearchController) this
|
||||
.getVariable("controller", true);
|
||||
final List<Worker> workers = controller.getSelectedWorkers();
|
||||
return workers;
|
||||
return controller.getSelectedWorkers();
|
||||
}
|
||||
|
||||
public void setWorkers(List<Worker> workers) {
|
||||
this.workers = workers;
|
||||
public void clearAll() {
|
||||
WorkerSearchController controller = (WorkerSearchController) this
|
||||
.getVariable("controller", true);
|
||||
controller.clearAll();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,6 @@ import org.zkoss.zul.Radio;
|
|||
import org.zkoss.zul.Radiogroup;
|
||||
import org.zkoss.zul.SimpleConstraint;
|
||||
import org.zkoss.zul.Tab;
|
||||
import org.zkoss.zul.Tabpanel;
|
||||
import org.zkoss.zul.api.Window;
|
||||
|
||||
/**
|
||||
|
|
@ -109,8 +108,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
|
||||
private WorkerSearch workerSearch;
|
||||
|
||||
private Tabpanel tbpWorkerSearch;
|
||||
|
||||
private Tab tbResourceAllocation;
|
||||
|
||||
private IChildrenSnapshot previousSnapshot;
|
||||
|
|
@ -155,31 +152,12 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Shows WorkerSearch window, add picked workers as
|
||||
* {@link SpecificResourceAllocation} to {@link ResourceAllocation} list
|
||||
* @return
|
||||
* Pick resources selected from {@link WorkerSearch} and add them to
|
||||
* resource allocation list
|
||||
*
|
||||
* @param e
|
||||
*/
|
||||
public void showSearchResources() {
|
||||
WorkerSearch workerSearch = new WorkerSearch();
|
||||
workerSearch.setParent(self.getParent());
|
||||
workerSearch.afterCompose();
|
||||
|
||||
Window window = workerSearch.getWindow();
|
||||
try {
|
||||
window.doModal();
|
||||
} catch (SuspendNotAllowedException e1) {
|
||||
throw new RuntimeException(e1);
|
||||
} catch (InterruptedException e1) {
|
||||
throw new RuntimeException(e1);
|
||||
}
|
||||
|
||||
addSpecificResourceAllocations(workerSearch.getWorkers());
|
||||
|
||||
Util.reloadBindings(allocationsList);
|
||||
}
|
||||
|
||||
public void onSelectWorkers(Event e) {
|
||||
final List<Worker> workers = workerSearch.getWorkers();
|
||||
addSpecificResourceAllocations(workerSearch.getWorkers());
|
||||
tbResourceAllocation.setSelected(true);
|
||||
Util.reloadBindings(allocationsList);
|
||||
|
|
@ -316,6 +294,7 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
private void clear() {
|
||||
workerSearch.clearAll();
|
||||
allocationsList.getItems().clear();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ import org.zkoss.zul.ListitemRenderer;
|
|||
import org.zkoss.zul.SimpleListModel;
|
||||
import org.zkoss.zul.SimpleTreeModel;
|
||||
import org.zkoss.zul.SimpleTreeNode;
|
||||
import org.zkoss.zul.Tabpanel;
|
||||
import org.zkoss.zul.Textbox;
|
||||
import org.zkoss.zul.Tree;
|
||||
import org.zkoss.zul.TreeModel;
|
||||
|
|
@ -71,8 +70,6 @@ public class WorkerSearchController extends GenericForwardComposer {
|
|||
|
||||
private Listbox listBoxWorkers;
|
||||
|
||||
private Tabpanel tbpWorkerSearch;
|
||||
|
||||
CriterionRenderer criterionRenderer = new CriterionRenderer();
|
||||
|
||||
public WorkerSearchController() {
|
||||
|
|
@ -183,9 +180,9 @@ public class WorkerSearchController extends GenericForwardComposer {
|
|||
clearAll();
|
||||
}
|
||||
|
||||
private void clearAll() {
|
||||
public void clearAll() {
|
||||
txtName.setValue("");
|
||||
listBoxWorkers.setModel(new SimpleListModel(new ArrayList<Worker>()));
|
||||
refreshListBoxWorkers(workerSearchModel.getAllWorkers());
|
||||
criterionsTree.setModel(getCriterions());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@
|
|||
<tab label="${i18n:_('Worker search')}" />
|
||||
</tabs>
|
||||
<tabpanels>
|
||||
<tabpanel id="tbpResourceAllocation">
|
||||
<tabpanel>
|
||||
<panel title="${i18n:_('Calculation type')}">
|
||||
<panelchildren>
|
||||
<radiogroup id="calculationTypeSelector"
|
||||
|
|
@ -158,7 +158,7 @@
|
|||
</listbox>
|
||||
</tabpanel>
|
||||
|
||||
<tabpanel id="tbpWorkerSearch">
|
||||
<tabpanel>
|
||||
<workerSearch id="workerSearch"/>
|
||||
|
||||
<!-- Select worker -->
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue