ItEr44S10CUGravacionModelosUnidadesTraballoItEr43S12: Moving createSchedulingState from OrderElement to SchedulingState in order to be reused.
This commit is contained in:
parent
688edb98ac
commit
0d23c14da4
2 changed files with 21 additions and 15 deletions
|
|
@ -107,25 +107,18 @@ public abstract class OrderElement extends BaseEntity implements
|
|||
|
||||
public SchedulingState getSchedulingState() {
|
||||
if (schedulingState == null) {
|
||||
schedulingState = createSchedulingState();
|
||||
schedulingState = SchedulingState.createSchedulingState(
|
||||
getSchedulingStateType(), getChildrenStates(),
|
||||
new ITypeChangedListener() {
|
||||
@Override
|
||||
public void typeChanged(Type newType) {
|
||||
schedulingStateType = newType;
|
||||
}
|
||||
});
|
||||
}
|
||||
return schedulingState;
|
||||
}
|
||||
|
||||
private SchedulingState createSchedulingState() {
|
||||
List<SchedulingState> childrenStates = getChildrenStates();
|
||||
SchedulingState result = new SchedulingState(getSchedulingStateType(),
|
||||
childrenStates);
|
||||
schedulingStateType = result.getType();
|
||||
result.addTypeChangeListener(new ITypeChangedListener() {
|
||||
@Override
|
||||
public void typeChanged(Type newType) {
|
||||
schedulingStateType = newType;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<SchedulingState> getChildrenStates() {
|
||||
List<SchedulingState> result = new ArrayList<SchedulingState>();
|
||||
for (OrderElement each : getChildren()) {
|
||||
|
|
|
|||
|
|
@ -131,6 +131,19 @@ public class SchedulingState {
|
|||
public void typeChanged(Type newType);
|
||||
}
|
||||
|
||||
public static SchedulingState createSchedulingState(Type initialType,
|
||||
List<SchedulingState> childrenStates,
|
||||
ITypeChangedListener typeListener) {
|
||||
SchedulingState result = new SchedulingState(initialType,
|
||||
childrenStates);
|
||||
Type newType = result.getType();
|
||||
if (newType != initialType) {
|
||||
typeListener.typeChanged(newType);
|
||||
}
|
||||
result.addTypeChangeListener(typeListener);
|
||||
return result;
|
||||
}
|
||||
|
||||
private Type type = Type.NO_SCHEDULED;
|
||||
private SchedulingState parent;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue