[Bug #1045] Fix bug
Avoid to execute some constraint violations when they are not in a ZK context. FEA: ItEr74S04BugFixing
This commit is contained in:
parent
e9f35966db
commit
28d642376a
3 changed files with 28 additions and 4 deletions
|
|
@ -64,7 +64,8 @@ public class DependencyComponent extends XulElement implements AfterCompose {
|
|||
this.source = source;
|
||||
this.destination = destination;
|
||||
this.dependency = dependency;
|
||||
violationListener = new IConstraintViolationListener<GanttDate>() {
|
||||
violationListener = Constraint
|
||||
.onlyOnZKExecution(new IConstraintViolationListener<GanttDate>() {
|
||||
|
||||
@Override
|
||||
public void constraintViolated(Constraint<GanttDate> constraint,
|
||||
|
|
@ -80,7 +81,7 @@ public class DependencyComponent extends XulElement implements AfterCompose {
|
|||
response("constraintViolated", new AuInvoke(
|
||||
DependencyComponent.this, "setCSSClass", "dependency"));
|
||||
}
|
||||
};
|
||||
});
|
||||
this.dependency.addConstraintViolationListener(violationListener);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -197,7 +197,8 @@ public class TaskComponent extends Div implements AfterCompose {
|
|||
|
||||
setId(UUID.randomUUID().toString());
|
||||
this.disabilityConfiguration = disabilityConfiguration;
|
||||
taskViolationListener = new IConstraintViolationListener<GanttDate>() {
|
||||
taskViolationListener = Constraint
|
||||
.onlyOnZKExecution(new IConstraintViolationListener<GanttDate>() {
|
||||
|
||||
@Override
|
||||
public void constraintViolated(Constraint<GanttDate> constraint,
|
||||
|
|
@ -210,7 +211,7 @@ public class TaskComponent extends Div implements AfterCompose {
|
|||
GanttDate value) {
|
||||
// TODO mark graphically dependency as not violated
|
||||
}
|
||||
};
|
||||
});
|
||||
this.task.addConstraintViolationListener(taskViolationListener);
|
||||
reloadResourcesTextRequested = new IReloadResourcesTextRequested() {
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import java.util.List;
|
|||
|
||||
import org.zkoss.ganttz.util.WeakReferencedListeners;
|
||||
import org.zkoss.ganttz.util.WeakReferencedListeners.IListenerNotification;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
|
||||
/**
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
|
|
@ -91,6 +92,27 @@ public abstract class Constraint<T> {
|
|||
public void constraintSatisfied(Constraint<T> constraint, T value);
|
||||
}
|
||||
|
||||
public static <T> IConstraintViolationListener<T> onlyOnZKExecution(
|
||||
final IConstraintViolationListener<T> original) {
|
||||
return new IConstraintViolationListener<T>() {
|
||||
|
||||
@Override
|
||||
public void constraintViolated(Constraint<T> constraint, T value) {
|
||||
if (Executions.getCurrent() != null) {
|
||||
original.constraintViolated(constraint, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void constraintSatisfied(Constraint<T> constraint, T value) {
|
||||
if (Executions.getCurrent() != null) {
|
||||
original.constraintSatisfied(constraint, value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public static class ConstraintBuilder<T> {
|
||||
|
||||
private final T value;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue