Applyable applyable = (Applyable) objectSelectionList
.getElementAt(table
.convertRowIndexToModel(objectSelectionList
.getSelectionIndex()));
Order order = managerRepository.getOrderManager().findByOrderNr(
applyable.getOrderNr());
if (order != null) {
OrderComment orderComment = new OrderComment();
orderComment.setUserName(login.getApplicationUser()
.getUserName());
orderComment.setCommentDate(Util.getCurrentDate());
orderComment.addCommentType(CommentTypeUtil
.getCommentType("Ordre"));
CommentViewHandler orderCommentViewHandler = new CommentViewHandler(
login, managerRepository.getOrderManager());
EditCommentView editDeviationCommentView = new EditCommentView(
new OrderCommentModel(orderComment),
orderCommentViewHandler);
JDialog dialog = Util.getDialog(window, "Legg til kommentar",
true);
dialog.setName("EditDeviationCommentView");
WindowInterface dialogWindow = new JDialogAdapter(dialog);
dialogWindow.add(editDeviationCommentView
.buildPanel(dialogWindow));
dialog.pack();
Util.locateOnScreenCenter(dialog);
dialogWindow.setVisible(true);
if (!orderCommentViewHandler.isCanceled()) {
orderComment.setOrder(order);
managerRepository
.getOrderManager()
.lazyLoadOrder(
order,
new LazyLoadOrderEnum[] { LazyLoadOrderEnum.COMMENTS });
order.addOrderComment(orderComment);
try {
managerRepository.getOrderManager().saveOrder(order);
} catch (ProTransException e) {
Util.showErrorDialog(window, "Feil", e.getMessage());
e.printStackTrace();