ItEr57S04ValidacionEProbasFuncionaisItEr56S04: [Bug #493] Show to the user that an error has happened.
This commit is contained in:
parent
43ee242e8c
commit
2ed9f663a0
5 changed files with 61 additions and 2 deletions
|
|
@ -37,6 +37,8 @@ public interface ITemplateModel {
|
|||
|
||||
public interface IOnFinished {
|
||||
public void onWithoutErrorFinish();
|
||||
|
||||
public void errorHappened(Exception exceptionHappened);
|
||||
}
|
||||
|
||||
void setScenario(String loginName, Scenario scenario,
|
||||
|
|
|
|||
|
|
@ -20,9 +20,13 @@
|
|||
|
||||
package org.navalplanner.web.common;
|
||||
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.navalplanner.business.scenarios.IScenarioManager;
|
||||
import org.navalplanner.business.scenarios.entities.Scenario;
|
||||
import org.navalplanner.web.common.ITemplateModel.IOnFinished;
|
||||
|
|
@ -46,6 +50,8 @@ import org.zkoss.zul.Window;
|
|||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
public class TemplateController extends GenericForwardComposer {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(TemplateController.class);
|
||||
|
||||
@Autowired
|
||||
private ITemplateModel templateModel;
|
||||
|
||||
|
|
@ -54,10 +60,14 @@ public class TemplateController extends GenericForwardComposer {
|
|||
|
||||
private Window window;
|
||||
|
||||
private IMessagesForUser windowMessages;
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
window = (Window) comp.getFellow("changeScenarioWindow");
|
||||
windowMessages = new MessagesForUser(window
|
||||
.getFellow("messagesContainer"));
|
||||
}
|
||||
|
||||
public Scenario getScenario() {
|
||||
|
|
@ -89,6 +99,15 @@ public class TemplateController extends GenericForwardComposer {
|
|||
window.setVisible(false);
|
||||
Executions.sendRedirect("/");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void errorHappened(Exception exceptionHappened) {
|
||||
LOG.error("error doing reassignation",
|
||||
exceptionHappened);
|
||||
windowMessages.showMessage(Level.ERROR, _(
|
||||
"error doing reassignation: {0}",
|
||||
exceptionHappened));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -423,6 +423,7 @@ public class TemplateModel implements ITemplateModel {
|
|||
@Override
|
||||
public void doOperation(
|
||||
final IDesktopUpdatesEmitter<IDesktopUpdate> desktopUpdateEmitter) {
|
||||
Exception exceptionHappened = null;
|
||||
try {
|
||||
transactionService
|
||||
.runOnTransaction(new IOnTransaction<Void>() {
|
||||
|
|
@ -433,17 +434,25 @@ public class TemplateModel implements ITemplateModel {
|
|||
return null;
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
exceptionHappened = e;
|
||||
} finally {
|
||||
desktopUpdateEmitter.doUpdate(showEnd());
|
||||
}
|
||||
desktopUpdateEmitter.doUpdate(executeFinish(onFinish));
|
||||
if (exceptionHappened == null) {
|
||||
desktopUpdateEmitter.doUpdate(notifySuccess(onFinish));
|
||||
} else {
|
||||
desktopUpdateEmitter.doUpdate(notifyException(onFinish,
|
||||
exceptionHappened));
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
LongOperationFeedback.progressive(desktop, LongOperationFeedback
|
||||
.withAsyncUpates(reassignations));
|
||||
}
|
||||
|
||||
private IDesktopUpdate executeFinish(
|
||||
private IDesktopUpdate notifySuccess(
|
||||
final IOnFinished onFinish) {
|
||||
return new IDesktopUpdate() {
|
||||
|
||||
|
|
@ -454,6 +463,16 @@ public class TemplateModel implements ITemplateModel {
|
|||
};
|
||||
}
|
||||
|
||||
private IDesktopUpdate notifyException(final IOnFinished onFinish,
|
||||
final Exception exceptionHappened) {
|
||||
return new IDesktopUpdate() {
|
||||
|
||||
@Override
|
||||
public void doUpdate() {
|
||||
onFinish.errorHappened(exceptionHappened);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void doReassignations(Scenario scenario,
|
||||
IDesktopUpdatesEmitter<IDesktopUpdate> emitter) {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.orders.entities.Order;
|
||||
import org.navalplanner.business.scenarios.IScenarioManager;
|
||||
|
|
@ -62,6 +64,9 @@ import org.zkoss.zul.api.Window;
|
|||
*/
|
||||
public class ScenarioCRUDController extends GenericForwardComposer {
|
||||
|
||||
private static final Log LOG = LogFactory
|
||||
.getLog(ScenarioCRUDController.class);
|
||||
|
||||
@Autowired
|
||||
private IScenarioModel scenarioModel;
|
||||
|
||||
|
|
@ -234,8 +239,15 @@ public class ScenarioCRUDController extends GenericForwardComposer {
|
|||
Executions
|
||||
.sendRedirect("/scenarios/scenarios.zul");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void errorHappened(
|
||||
Exception exceptionHappened) {
|
||||
errorHappenedDoingReassignation(exceptionHappened);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
if (isCurrentScenario) {
|
||||
connectButton.setDisabled(true);
|
||||
|
|
@ -252,6 +264,12 @@ public class ScenarioCRUDController extends GenericForwardComposer {
|
|||
|
||||
}
|
||||
|
||||
private void errorHappenedDoingReassignation(Exception exceptionHappened) {
|
||||
LOG.error("error happened doing reassignation", exceptionHappened);
|
||||
messagesForUser.showMessage(Level.ERROR, _(
|
||||
"error doing reassignation: {0}", exceptionHappened));
|
||||
}
|
||||
|
||||
public Set<Order> getOrders() {
|
||||
Scenario scenario = scenarioModel.getScenario();
|
||||
if (scenario == null) {
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@
|
|||
label="${templateCtrl.scenario.name}" />
|
||||
<window id="changeScenarioWindow" visible="false"
|
||||
title="${i18n:_('Change scenario')}">
|
||||
<div id="messagesContainer" />
|
||||
<grid>
|
||||
<rows>
|
||||
<row>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue