refactor(renderer): simplify G2DDrawControl constructor and initialize customControlConfigurations lazily
This commit is contained in:
@@ -86,11 +86,10 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
|
|||||||
|
|
||||||
private final Area2 tempArea = new Area2(MutableCoordI2.create(), MutableCoordI2.create());
|
private final Area2 tempArea = new Area2(MutableCoordI2.create(), MutableCoordI2.create());
|
||||||
|
|
||||||
private final List<CustomControlConfiguration<? extends G2DBaseControlImpl>> customControlConfigurations;
|
private List<CustomControlConfiguration<? extends G2DBaseControlImpl>> customControlConfigurations;
|
||||||
|
|
||||||
public G2DDrawControl(final List<CustomControlConfiguration<? extends G2DBaseControlImpl>> customControlConfigurations) {
|
public G2DDrawControl() {
|
||||||
super(RenderingBoLayer.UI0);
|
super(RenderingBoLayer.UI0);
|
||||||
this.customControlConfigurations = customControlConfigurations;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -204,6 +203,10 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.customControlConfigurations == null) {
|
||||||
|
this.customControlConfigurations = List.copyOf( this.rendererData.getApplicationContext().getBeansOfType(CustomControlConfiguration.class).values());
|
||||||
|
}
|
||||||
|
|
||||||
var control = (G2DBaseControlImpl) CACHED_CONTROLS.get(this.id);
|
var control = (G2DBaseControlImpl) CACHED_CONTROLS.get(this.id);
|
||||||
if (control == null) {
|
if (control == null) {
|
||||||
if (this.clazz == null) {
|
if (this.clazz == null) {
|
||||||
@@ -244,14 +247,12 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
|
|||||||
control = new G2DTooltipControl();
|
control = new G2DTooltipControl();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (this.customControlConfigurations != null) {
|
|
||||||
for (final var customControlConfiguration : this.customControlConfigurations) {
|
for (final var customControlConfiguration : this.customControlConfigurations) {
|
||||||
if (customControlConfiguration.getControlClass().equals(this.clazz)) {
|
if (customControlConfiguration.getControlClass().equals(this.clazz)) {
|
||||||
control = customControlConfiguration.createControl();
|
control = customControlConfiguration.createControl();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (control == null) {
|
if (control == null) {
|
||||||
throw new IllegalArgumentException("Control type not registered: " + this.clazz.getName());
|
throw new IllegalArgumentException("Control type not registered: " + this.clazz.getName());
|
||||||
@@ -339,7 +340,6 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
|
|||||||
((TextfieldControl) control).setCustomData(this.textfieldData);
|
((TextfieldControl) control).setCustomData(this.textfieldData);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (this.customControlConfigurations != null) {
|
|
||||||
for (final var customControlConfiguration : this.customControlConfigurations) {
|
for (final var customControlConfiguration : this.customControlConfigurations) {
|
||||||
if (customControlConfiguration.getControlClass().equals(this.clazz)) {
|
if (customControlConfiguration.getControlClass().equals(this.clazz)) {
|
||||||
((CustomControlConfiguration) customControlConfiguration).setCustomData(control, this.customData);
|
((CustomControlConfiguration) customControlConfiguration).setCustomData(control, this.customData);
|
||||||
@@ -348,7 +348,6 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(final RenderingBo other) {
|
public void apply(final RenderingBo other) {
|
||||||
@@ -376,6 +375,7 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
|
|||||||
this.tooltip = o.tooltip;
|
this.tooltip = o.tooltip;
|
||||||
this.visibleArea = o.visibleArea;
|
this.visibleArea = o.visibleArea;
|
||||||
this.controlArea = o.controlArea;
|
this.controlArea = o.controlArea;
|
||||||
|
this.customControlConfigurations = o.customControlConfigurations;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,6 +404,7 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
|
|||||||
this.tooltip = null;
|
this.tooltip = null;
|
||||||
this.visibleArea = null;
|
this.visibleArea = null;
|
||||||
this.controlArea = null;
|
this.controlArea = null;
|
||||||
|
this.customControlConfigurations = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user