This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 262216

Summary: Add more extension points to VMDGraphScene
Product: platform Reporter: crosati <crosati>
Component: GraphAssignee: issues@platform <issues>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.1   
Hardware: PC   
OS: Mac OS X   
Issue Type: ENHANCEMENT Exception Reporter:

Description crosati 2016-05-25 09:12:45 UTC
VMDGraphScene is a great class but it is difficult to extend or add functionalities to it.

To change the move action from the default one to AlignWithMoveAction, this is what I have to do:


private class MyVMDGraphScene extends VMDGraphScene {

    private final WidgetAction alignWithMoveAction;

    public MyVMDGraphScene() {

        super(new InspectorColorScheme());

        alignWithMoveAction = ActionFactory.createAlignWithMoveAction(
            (LayerWidget) getChildren().get(1),
            (LayerWidget) getChildren().get(3),
            null,
            true
        );

    }

    @Override
    protected Widget attachNodeWidget( String node ) {

        Widget widget = super.attachNodeWidget(node);

        widget.getActions().removeAction(ActionFactory.createMoveAction());
        widget.getActions().addAction(alignWithMoveAction);

        return widget;

    }

}


This is not a clean way to do it because of lack of proper extension points in the base class.

I suggest/request the following:

1. Add getters for the 4 layers [getBackgroundLayer(), getMainLayer(), getConnectionLayer(), getUpperLayer() - or getInteractionLayer()];

2. Add lazy creation of the moveAction, using a factory method:

    private WidgetAction moveAction = null;
    ...
    private WidgetAction getMoveAction() {
        if ( moveAction == null } {
            moveAction = createMoveAction();
        }
        return moveAction;
    }
    ...
    protected WidgetAction createMoveAction() {
        return ActionFactory.createMoveAction();
    }
    ...
    protected Widget attachNodeWidget (String node) {
        ...
        widget.getActions ().addAction (getMoveAction());
        ...
    }

3. Similarly for moveControlPointAction, router and sceneLayout.


Thank you,
Claudio Rosati



Product Version = NetBeans IDE 8.1 (Build 201510222201)
Operating System = Mac OS X version 10.11.5 running on x86_64
Java; VM; Vendor = 1.8.0_92
Runtime = Java HotSpot(TM) 64-Bit Server VM 25.92-b14