*/
@SuppressWarnings("unchecked")
private void registerDeviation(ArrayListModel orderLines,
TransportListable transportlistable) {
PostShipment postShipment = new PostShipment();
PostShipmentManager postShipmentManager = (PostShipmentManager) ModelUtil
.getBean("postShipmentManager");
DeviationViewHandler deviationViewHandler = deviationViewHandlerFactory.create(transportlistable.getOrder(), false,
false, false, null, true);
Deviation deviation = new Deviation();
DeviationModel deviationModel = new DeviationModel(deviation, true);
deviationModel.setOrderLines(orderLines);
deviationModel.setPostShipment(postShipment);
deviationModel.setOrder(transportlistable.getOrder());
EditDeviationView editDeviationView = new EditDeviationView(false,
deviationModel, deviationViewHandler, true, true);
JDialog dialog = new JDialog(ProTransMain.PRO_TRANS_MAIN, "Avvik", true);
dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
WindowInterface window = new JDialogAdapter(dialog);
window.add(editDeviationView.buildPanel(window), BorderLayout.CENTER);
window.pack();
Util.locateOnScreenCenter(window);
window.setVisible(true);
postShipment = deviation.getPostShipment();
// postShipment.setDeviation(deviation);
postShipment.setOrder(transportlistable.getOrder());
postShipment.cacheComments();
if (transportlistable instanceof PostShipment) {
postShipment.setPostShipmentRef((PostShipment) transportlistable);
}
postShipmentManager.savePostShipment(postShipment);
Colli colli;
Iterator<OrderLine> it = orderLines.iterator();
while (it.hasNext()) {
OrderLine orderLine = it.next();
orderLine.setPostShipment(postShipment);