[Bug #825] Fix bug
The previous listeners associated to the recommended allocation were not removed, so pressing the recommended allocation button caused it to be executed several times. FEA: ItEr69S04BugFixing
This commit is contained in:
parent
3a1b50c2c2
commit
0563524f4a
2 changed files with 23 additions and 2 deletions
|
|
@ -26,6 +26,7 @@ import static org.navalplanner.web.I18nHelper._;
|
|||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.zkoss.ganttz.util.ComponentsFinder;
|
||||
|
|
@ -578,4 +579,23 @@ public class Util {
|
|||
return ifNotFound.createAt(container);
|
||||
}
|
||||
|
||||
/**
|
||||
* It removes all listeners registered for eventName and adds the new
|
||||
* listener. It's ensured that the only listener left in the component for
|
||||
* events of name eventName is uniqueListener
|
||||
*
|
||||
* @param component
|
||||
* @param eventName
|
||||
* @param uniqueListener
|
||||
*/
|
||||
public static void ensureUniqueListener(Component component, String eventName,
|
||||
EventListener uniqueListener) {
|
||||
Iterator<?> listenerIterator = component.getListenerIterator(eventName);
|
||||
while (listenerIterator.hasNext()) {
|
||||
listenerIterator.next();
|
||||
listenerIterator.remove();
|
||||
}
|
||||
component.addEventListener(eventName, uniqueListener);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,8 +75,9 @@ public class TaskInformation extends HtmlMacroComponent {
|
|||
gridTaskRows.setRowRenderer(newTaskRowsRenderer());
|
||||
}
|
||||
|
||||
public void onRecomendAllocation(EventListener event) {
|
||||
btnRecommendedAllocation.addEventListener(Events.ON_CLICK, event);
|
||||
public void onRecomendAllocation(EventListener eventListener) {
|
||||
Util.ensureUniqueListener(btnRecommendedAllocation, Events.ON_CLICK,
|
||||
eventListener);
|
||||
}
|
||||
|
||||
public void showRecomendedAllocationButton() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue