[Bug #937] Add event ON_OK in bandboxSearch in the correponding controllers.
FEA : ItEr73S04BugFixing
This commit is contained in:
parent
f41df2482d
commit
363a56126b
6 changed files with 121 additions and 22 deletions
|
|
@ -137,14 +137,15 @@ public class BandboxSearch extends HtmlMacroComponent {
|
|||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
bandbox.close();
|
||||
close();
|
||||
}
|
||||
});
|
||||
listbox.addEventListener(Events.ON_OK, new EventListener() {
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
bandbox.close();
|
||||
pickElementFromList();
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -212,8 +213,9 @@ public class BandboxSearch extends HtmlMacroComponent {
|
|||
}
|
||||
}
|
||||
|
||||
private Listitem getSelectedItem() {
|
||||
return (Listitem) listbox.getSelectedItems().iterator().next();
|
||||
public Listitem getSelectedItem() {
|
||||
return listbox == null ? null : (Listitem) listbox.getSelectedItems()
|
||||
.iterator().next();
|
||||
}
|
||||
|
||||
public String getFinder() {
|
||||
|
|
@ -325,4 +327,9 @@ public class BandboxSearch extends HtmlMacroComponent {
|
|||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (bandbox != null) {
|
||||
bandbox.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -981,6 +981,17 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
orderModel.setExternalCompany((ExternalCompany) object);
|
||||
}
|
||||
});
|
||||
bdExternalCompanies.setListboxEventListener(Events.ON_OK,
|
||||
new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
final Object object = bdExternalCompanies
|
||||
.getSelectedElement();
|
||||
orderModel.setExternalCompany((ExternalCompany) object);
|
||||
bdExternalCompanies.close();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void setupOrderDetails() {
|
||||
|
|
|
|||
|
|
@ -32,12 +32,16 @@ import org.navalplanner.business.externalcompanies.entities.ExternalCompany;
|
|||
import org.navalplanner.business.orders.entities.Order;
|
||||
import org.navalplanner.web.common.ConstraintChecker;
|
||||
import org.navalplanner.web.common.Util;
|
||||
import org.navalplanner.web.common.components.bandboxsearch.BandboxSearch;
|
||||
import org.navalplanner.web.planner.consolidations.AdvanceConsolidationController;
|
||||
import org.navalplanner.web.planner.tabs.MultipleTabsPlannerController;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.SuspendNotAllowedException;
|
||||
import org.zkoss.zk.ui.WrongValueException;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.ComboitemRenderer;
|
||||
import org.zkoss.zul.Constraint;
|
||||
|
|
@ -72,6 +76,8 @@ public class ProjectDetailsController extends GenericForwardComposer {
|
|||
|
||||
private Datebox initDate;
|
||||
|
||||
private BandboxSearch bdExternalCompanies;
|
||||
|
||||
private Datebox deadline;
|
||||
|
||||
public ProjectDetailsController() {
|
||||
|
|
@ -99,7 +105,7 @@ public class ProjectDetailsController extends GenericForwardComposer {
|
|||
this.defaultCalendar = orderController.getOrder().getCalendar();
|
||||
this.isCodeAutogeneratedInit = orderController.getOrder()
|
||||
.isCodeAutogenerated();
|
||||
|
||||
loadComponents();
|
||||
try {
|
||||
Util.reloadBindings(window);
|
||||
Util.createBindingsFor(gridProjectDetails);
|
||||
|
|
@ -224,4 +230,27 @@ public class ProjectDetailsController extends GenericForwardComposer {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void loadComponents() {
|
||||
bdExternalCompanies.setListboxEventListener(Events.ON_SELECT,
|
||||
new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
final Object object = bdExternalCompanies
|
||||
.getSelectedElement();
|
||||
getOrder().setCustomer((ExternalCompany) object);
|
||||
}
|
||||
});
|
||||
bdExternalCompanies.setListboxEventListener(Events.ON_OK,
|
||||
new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
final Object object = bdExternalCompanies
|
||||
.getSelectedElement();
|
||||
getOrder().setCustomer((ExternalCompany) object);
|
||||
bdExternalCompanies.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -78,23 +78,49 @@ public class TransferOrdersController extends GenericForwardComposer {
|
|||
new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
Scenario sourceScenario = (Scenario) sourceScenarioBandboxSearch
|
||||
.getSelectedElement();
|
||||
transferOrdersModel.setSourceScenario(sourceScenario);
|
||||
Util.reloadBindings(sourceScenarioOrders);
|
||||
setSourceScenario();
|
||||
}
|
||||
});
|
||||
|
||||
sourceScenarioBandboxSearch.setListboxEventListener(Events.ON_OK,
|
||||
new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
setSourceScenario();
|
||||
}
|
||||
});
|
||||
|
||||
destinationScenarioBandboxSearch.setListboxEventListener(
|
||||
Events.ON_CLICK, new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
Scenario destinationScenario = (Scenario) destinationScenarioBandboxSearch
|
||||
.getSelectedElement();
|
||||
transferOrdersModel
|
||||
.setDestinationScenario(destinationScenario);
|
||||
Util.reloadBindings(destinationScenarioOrders);
|
||||
setDestinationScenario();
|
||||
}
|
||||
});
|
||||
|
||||
destinationScenarioBandboxSearch.setListboxEventListener(Events.ON_OK,
|
||||
new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
setDestinationScenario();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setSourceScenario() {
|
||||
Scenario sourceScenario = (Scenario) sourceScenarioBandboxSearch
|
||||
.getSelectedElement();
|
||||
transferOrdersModel.setSourceScenario(sourceScenario);
|
||||
Util.reloadBindings(sourceScenarioOrders);
|
||||
sourceScenarioBandboxSearch.close();
|
||||
}
|
||||
|
||||
private void setDestinationScenario() {
|
||||
Scenario destinationScenario = (Scenario) destinationScenarioBandboxSearch
|
||||
.getSelectedElement();
|
||||
transferOrdersModel.setDestinationScenario(destinationScenario);
|
||||
Util.reloadBindings(destinationScenarioOrders);
|
||||
destinationScenarioBandboxSearch.close();
|
||||
}
|
||||
|
||||
public List<Scenario> getScenarios() {
|
||||
|
|
|
|||
|
|
@ -651,6 +651,21 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
|
|||
getWorkReport().setOrderElement(orderElement);
|
||||
}
|
||||
});
|
||||
|
||||
bandboxSelectOrderElementInHead.setListboxEventListener(Events.ON_OK,
|
||||
new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
Listitem selectedItem = bandboxSelectOrderElementInHead
|
||||
.getSelectedItem();
|
||||
if ((selectedItem != null) && (getWorkReport() != null)) {
|
||||
getWorkReport().setOrderElement(
|
||||
(OrderElement) selectedItem.getValue());
|
||||
}
|
||||
bandboxSelectOrderElementInHead.close();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void loadComponentslist(Component window) {
|
||||
|
|
@ -914,7 +929,7 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
|
|||
private void appendOrderElementInLines(Row row) {
|
||||
final WorkReportLine workReportLine = (WorkReportLine) row.getValue();
|
||||
|
||||
BandboxSearch bandboxSearch = BandboxSearch.create(
|
||||
final BandboxSearch bandboxSearch = BandboxSearch.create(
|
||||
"OrderElementBandboxFinder", getOrderElements());
|
||||
|
||||
bandboxSearch.setSelectedElement(workReportLine.getOrderElement());
|
||||
|
|
@ -924,17 +939,29 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
|
|||
new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
Listitem selectedItem = (Listitem) ((SelectEvent) event)
|
||||
.getSelectedItems().iterator().next();
|
||||
OrderElement orderElement = (OrderElement) selectedItem
|
||||
.getValue();
|
||||
workReportLine.setOrderElement(orderElement);
|
||||
Listitem selectedItem = bandboxSearch.getSelectedItem();
|
||||
setOrderElementInWRL(selectedItem, workReportLine);
|
||||
}
|
||||
});
|
||||
|
||||
bandboxSearch.setListboxEventListener(Events.ON_OK,
|
||||
new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
Listitem selectedItem = bandboxSearch.getSelectedItem();
|
||||
setOrderElementInWRL(selectedItem, workReportLine);
|
||||
bandboxSearch.close();
|
||||
}
|
||||
});
|
||||
|
||||
row.appendChild(bandboxSearch);
|
||||
}
|
||||
|
||||
private void setOrderElementInWRL(Listitem selectedItem, WorkReportLine line) {
|
||||
OrderElement orderElement = (OrderElement) selectedItem.getValue();
|
||||
line.setOrderElement(orderElement);
|
||||
}
|
||||
|
||||
private void appendFieldsAndLabelsInLines(final Row row){
|
||||
final WorkReportLine line = (WorkReportLine)row.getValue();
|
||||
for(Object fieldOrLabel : getFieldsAndLabelsLine(line)){
|
||||
|
|
|
|||
|
|
@ -170,8 +170,7 @@
|
|||
<bandboxSearch id="bandboxSelectOrderElementInHead"
|
||||
finder="OrderElementBandboxFinder"
|
||||
model="@{controller.orderElements}"
|
||||
selectedElement="@{controller.workReport.orderElement}"
|
||||
onSelect="controller.setOrderElementInComponent(event)" />
|
||||
selectedElement="@{controller.workReport.orderElement}"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue