.getActuator()).removeListener(actuatorListener);
}
if (this.config instanceof IConfig1D) {
IConfig1D config1D = (IConfig1D) this.config;
IDimension dimension = config1D.getDimensionX();
if (dimension != null) {
((IEventSource<EntityPropertyChangedEvent<? extends IDimension>>) dimensionListener
.getDimension()).removeListener(dimensionListener);
}
}
else if (this.config instanceof IConfig2D) {
IConfig2D config2D = (IConfig2D) this.config;
IDimension dimension;
if (this.yActuator) {
dimension = config2D.getDimensionY();
}
else {
dimension = config2D.getDimensionX();
}
if (dimension != null) {
((IEventSource<EntityPropertyChangedEvent<? extends IDimension>>) dimensionListener
.getDimension()).removeListener(dimensionListener);
}
}
else if (this.config instanceof IConfigEnergy) {
IConfigEnergy configEnergy = (IConfigEnergy) this.config;
IDimension dimension = configEnergy.getDimensionEnergy();
if (dimension != null) {
((IEventSource<EntityPropertyChangedEvent<? extends IDimension>>) dimensionListener
.getDimension()).removeListener(dimensionListener);
}
}
}
this.config = config;
actuatorListenersList.clear();
if (config != null) {
((IEventSource<EntityPropertyChangedEvent<IConfig>>) this.config)
.addListener(configListener);
if (config instanceof IConfig1D) {
IConfig1D config1D = (IConfig1D) config;
this.setViewVisible(true);
listActuator = config1D.getDimensionX().getActuatorsList();
IDimension dimension = config1D.getDimensionX();
if (dimension != null) {
dimensionListener = new DimensionListener(dimension);
((IEventSource<EntityPropertyChangedEvent<? extends IDimension>>) dimension)
.addListener(dimensionListener);
}
}
else if (config instanceof IConfig2D) {
IConfig2D config2D = (IConfig2D) config;
if (this.yActuator) { // Case of Y Actuator.
this.setViewVisible(true);
listActuator = config2D.getDimensionY().getActuatorsList();
IDimension dimension = config2D.getDimensionY();
if (dimension != null) {
dimensionListener = new DimensionListener(dimension);
((IEventSource<EntityPropertyChangedEvent<? extends IDimension>>) dimension)
.addListener(dimensionListener);
}
}
else { // Case of X Actuator.
this.setViewVisible(true);
listActuator = config2D.getDimensionX().getActuatorsList();
IDimension dimension = config2D.getDimensionX();
if (dimension != null) {
dimensionListener = new DimensionListener(dimension);
((IEventSource<EntityPropertyChangedEvent<? extends IDimension>>) dimension)
.addListener(dimensionListener);
}
}
}
else if (config instanceof IConfigEnergy) {
IConfigEnergy configEnergy = (IConfigEnergy) config;
this.setViewVisible(true);
listActuator = configEnergy.getDimensionEnergy().getActuatorsList();
IDimension dimension = configEnergy.getDimensionEnergy();
if (dimension != null) {
dimensionListener = new DimensionListener(dimension);
((IEventSource<EntityPropertyChangedEvent<? extends IDimension>>) dimension)
.addListener(dimensionListener);
}
}
// Actuator used for ScanHCS
else if (config instanceof IConfigHCS) {
IConfigHCS configHCS = (IConfigHCS) config;
this.setViewVisible(true);
listActuator = configHCS.getDimensionX().getActuatorsList();
IDimension dimension = configHCS.getDimensionX();
if (dimension != null) {
dimensionListener = new DimensionListener(dimension);
((IEventSource<EntityPropertyChangedEvent<? extends IDimension>>) dimension)
.addListener(dimensionListener);
}
}
else {
if (config instanceof IConfigK) {
IConfigK configK = (IConfigK) config;
this.setViewVisible(true);
listActuator = configK.getDimensionX().getActuatorsList();
IDimension dimension = configK.getDimensionX();
if (dimension != null) {
dimensionListener = new DimensionListener(dimension);
((IEventSource<EntityPropertyChangedEvent<? extends IDimension>>) dimension)
.addListener(dimensionListener);
}