use of org.kie.workbench.common.stunner.core.definition.property.PropertyType in project kie-wb-common by kiegroup.
the class ElementParser method initialize.
@Override
@SuppressWarnings("unchecked")
public void initialize(final Context context) {
this.context = context;
Object definition = element.getContent().getDefinition();
// Resource id field.
super.addParser(new StringFieldParser("resourceId", element.getUUID()));
// Properties array.
Object def = element.getContent().getDefinition();
Set<?> properties = context.getDefinitionManager().adapters().forDefinition().getProperties(def);
ObjectParser propertiesParser = new ObjectParser("properties");
super.addParser(propertiesParser);
if (null != properties && !properties.isEmpty()) {
for (Object property : properties) {
PropertyAdapter propertyAdapter = context.getDefinitionManager().adapters().registry().getPropertyAdapter(property.getClass());
PropertyType propertyType = propertyAdapter.getType(property);
String oryxPropId = context.getOryxManager().getMappingsManager().getOryxPropertyId(def.getClass(), property.getClass());
Object value = propertyAdapter.getValue(property);
String valueStr = value != null ? context.getOryxManager().getPropertyManager().serialize(property, propertyType, value) : "";
propertiesParser.addParser(new StringFieldParser(oryxPropId, valueStr));
}
}
// Custom extended prpoerties, if any.
parseExtendedProperties(propertiesParser);
// Stencil id field.
String defId = context.getOryxManager().getMappingsManager().getOryxDefinitionId(definition);
super.addParser(new ObjectParser("stencil").addParser(new StringFieldParser("id", defId)));
// Bounds.
Bounds.Bound ul = element.getContent().getBounds().getUpperLeft();
Bounds.Bound lr = element.getContent().getBounds().getLowerRight();
parseBounds(ul, lr);
}
use of org.kie.workbench.common.stunner.core.definition.property.PropertyType in project kie-wb-common by kiegroup.
the class ClientBindablePropertyAdapterTest method testDefaultTypes.
@Test
public void testDefaultTypes() {
types.put(Foo.class, new StringType());
types.put(Bar.class, new BooleanType());
final PropertyType fooType = clientBindablePropertyAdapter.getType(new Foo());
final PropertyType barType = clientBindablePropertyAdapter.getType(new Bar());
assertEquals(StringType.class, fooType.getClass());
assertEquals(BooleanType.class, barType.getClass());
}
use of org.kie.workbench.common.stunner.core.definition.property.PropertyType in project kie-wb-common by kiegroup.
the class BackendPropertyAdapterTest method testGetPropertyType.
@Test
public void testGetPropertyType() {
final PropertyType type = tested.getType(instance);
assertEquals(StringType.class, type.getClass());
}
use of org.kie.workbench.common.stunner.core.definition.property.PropertyType in project kie-wb-common by kiegroup.
the class StunnerClientLogger method logProperty.
public static void logProperty(final DefinitionManager definitionManager, final Object prop, final Set<Object> propertiesVisited) {
final PropertyAdapter<Object, ?> adapter = definitionManager.adapters().registry().getPropertyAdapter(prop.getClass());
final String id = adapter.getId(prop);
final String caption = adapter.getCaption(prop);
final String description = adapter.getDescription(prop);
final PropertyType type = adapter.getType(prop);
final Object value = adapter.getValue(prop);
GWT.log(" -------------------------------------------------");
GWT.log(" ID = " + id);
GWT.log(" CAPTION = " + caption);
GWT.log(" DESC = " + description);
GWT.log(" TYPE = " + type);
GWT.log(" VALUE = " + value);
GWT.log(" -------------------------------------------------");
propertiesVisited.add(prop);
}
Aggregations