mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
fixed dynamic loading
This commit is contained in:
@@ -21,12 +21,16 @@
|
||||
*/
|
||||
package org.diylc.core;
|
||||
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IDynamicPropertySource {
|
||||
|
||||
void setComponent(IDIYComponent<?> component);
|
||||
void setProperties(List<PropertyWrapper> properties);
|
||||
|
||||
void setComponent(IDIYComponent<?> ownerObject);
|
||||
|
||||
List<Object> getAvailableValues();
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package org.diylc.core;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SwitchPositionPropertyValueSource implements IDynamicPropertySource {
|
||||
|
||||
private IDIYComponent<?> component;
|
||||
|
||||
@Override
|
||||
public void setComponent(IDIYComponent<?> component) {
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> getAvailableValues() {
|
||||
if (component == null) {
|
||||
throw new RuntimeException("Component not set");
|
||||
}
|
||||
if (!(component instanceof ISwitch sw)) {
|
||||
return List.of();
|
||||
}
|
||||
int positionCount = sw.getPositionCount();
|
||||
List<Object> res = new ArrayList<>();
|
||||
res.add(null);
|
||||
for (int i = 0; i < positionCount; i++) {
|
||||
res.add(i);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayValue(Object value) {
|
||||
if (value == null) {
|
||||
return "";
|
||||
}
|
||||
return "#" + (((Integer)value) + 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user