Search code examples
javaalloy-ui

Add custom node to Alloyui DiagramBuilder in JAVA


I have been using this example to make a diagram with Alloyui, but I don't find the way to make a custom node in JAVA.

I've tried to simply add it in AvaliableFields, but doesn't seem to work:

diagramBuilder.setAvailableFields(
    new NodeType(
         "diagram-node-custom-icon",
         "Custom",
         "custom"
     ));

I have already done this in another example, directly in the javascript and works:

 Y.DiagramNodeCustom = Y.Component.create({
        NAME: 'diagram-node',

        ATTRS: {
            type: {
                value: 'custom'
            },
            myAtt: {
                validator: Y.Lang.isString,
                value: ''
            },
            myAtt2: {
                validator: Y.Lang.isString,
                value: ''
            }
        },

        EXTENDS: Y.DiagramNodeTask,

        prototype: {
            getPropertyModel: function () {
                var instance = this;

                var model = Y.DiagramNodeTask.superclass.getPropertyModel.apply(instance, arguments);

                model.push({
                    attributeName: 'myAtt',
                    name: '123'
                });

                model.push({
                    attributeName: 'myAtt2',
                    name: '456'
                });

                return model;
            }
        }
    });

But I'm trying only to touch the java part. Any ideas?


Solution

  • Seems like this add-on doesn't accept custom nodes, so I am working with Javascript.