Module access to Ignition's internal 'json to perspective object' code

What are the methods to look for for hooking into ignition’s internal ‘take in json/object description, convert into perspective object or output list of errors’ code that e.g. lives in the designer?

This question isn't formulated well enough to make sense to me yet.

What's the ultimate thing you're trying to do?
I think you might be asking for the PropertyTree API?

So right now, if i e.g. copy paste in a perspective json, or i import a project zip containing a view json, somehow that gets translated in the designer into a bunch of ‘this is a valid perspective object’ or ‘this object isn’t valid because props x, y, and z are missing and prop A has data type B instead of C-E’ errors. i want to hook into that translation pipeline

What does this mean? Each component declares a schema--the designer is just evaluating that, IIUC.

1 Like

com.inductiveautomation.perspective.designer.workspace.propertyeditor.ComponentPropsDocumentModel

which extends com.inductiveautomation.ignition.client.jsonedit.DocumentModel

which exposes DocumentModel.getValidationResults

Constructing a ComponentPropsDocumentModel is going to be tricky while you're not literally the Perspective module, because some of the constructor arguments are going to be hard to realize.

Here's a use-site example:

                JsonSchema schema = switch (scope) {
                    case props -> selection.getPropsSchema();
                    case meta -> PerspectiveModule.META_SCHEMA;
                    case position -> selection.getPositionSchema(editor.get().getDeepSelection());
                    default -> null;
                };
                setModel(new ComponentPropsDocumentModel(editor.get(), selection, scope, schema));
1 Like

Oh, great, where are those component by component schemas declared? is it just each component has a schema property?

Exactly that:

2 Likes

That component descriptor is what the gateway hook registers with Perspective to make the component available in general. The Perspective example project has a very bare skeleton for this.

1 Like

terrific. any chance the defaults the designer fills in are also there?

That would be part of the component's schema, yes.

2 Likes