eclipse-uml2 / uml2

An EMF-based implementation of the UML 2.x metamodel for the Eclipse platform.
Eclipse Public License 2.0
5 stars 4 forks source link

Eclipse UML2 migration issue #120

Open eclipse-uml2-bot opened 5 hours ago

eclipse-uml2-bot commented 5 hours ago

| --- | --- | | Bugzilla Link | 583572 | | Status | UNCONFIRMED | | Importance | P3 blocker | | Reported | Sep 24, 2024 03:43 EDT | | Modified | Sep 24, 2024 03:57 EDT | | Version | 5.5.2 | | Reporter | Vishal Sharnagat |

Description

The Eclipse platform for RCP application is migrated from 4.6.3 to 4.23 (it's too old version but got the support till next year). With this change, the Eclipse UML2 is also migrated from 3.x to 5.x. Luckily, there are not many code changes introduced as part of this migration. Only createNode() has to be replaced with createOwnedNode() as below:\ \ umlNode = (InitialNode)getActivity().createOwnedNode(name = (name != null)? name : GRAPH_NODE_INITIAL, UMLPackage.eINSTANCE.getInitialNode());

However, with this change/migration, the nodes are not getting created in Activity Diagram Editor with below exception:

!ENTRY org.eclipse.ui 4 0 2024-09-23 09:10:49.257\
!MESSAGE Unhandled event loop exception\
!STACK 0\
java.lang.NullPointerException\
    at org.eclipse.epf.diagram.core.actions.CreateElementAction.run(CreateElementAction.java:51)\
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:474)\
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:580)\
    at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:414)\
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)\
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4243)\
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1063)\
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1087)\
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1072)\
    at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:775)\
    at org.eclipse.jface.action.ActionContributionItem.lambda$8(ActionContributionItem.java:1207)\
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)\
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4243)\
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1063)\
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4060)\
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3632)\
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)\
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)\
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)\
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)\
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)\
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)\
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551)\
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156)

Upon debugging, it is learnt that the below line returns null command:

    Command cmd = getDiagramEditPart().getCommand(req);

I compared the returned command with older UML2 3.x libraries and found that it was returning command of type ICommandProxy which has executable property. The command object created by new UML2 5.x is not executable and returns null from below class and method:

    class org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy extends AbstractEditPolicy

    /**
 * Method getCreateElementAndViewCommand.\
 * 
 * @param request
 * @return Command Which creates the sematnic and the view command for the
 *         given CreateViewAndElementRequest\
 */\
protected Command getCreateElementAndViewCommand(CreateViewAndElementRequest request) {\
    // get the element descriptor\
    CreateElementRequestAdapter requestAdapter =\
        request.getViewAndElementDescriptor().getCreateElementRequestAdapter();

    // get the semantic request\
    CreateElementRequest createElementRequest =\
        (CreateElementRequest) requestAdapter.getAdapter(\
            CreateElementRequest.class);

    if (createElementRequest.getContainer() == null) {\
        // complete the semantic request by filling in the host's semantic\
        // element as the context\
        View view = (View)getHost().getModel();\
        EObject hostElement = ViewUtil.resolveSemanticElement(view);\
        \
        if (hostElement == null && view.getElement() == null) {\
            hostElement = view;\
        }           

        // Returns null if host is unresolvable so that trying to create a\
        // new element in an unresolved shape will not be allowed.\
        if (hostElement == null) {\
            return null;\
        }\
        createElementRequest.setContainer(hostElement);\
    }

    // get the create element command based on the elementdescriptor's\
    // request\
    Command createElementCommand =\
        getHost().getCommand(\
            new EditCommandRequestWrapper(\
                (CreateElementRequest)requestAdapter.getAdapter(\
                    CreateElementRequest.class), request.getExtendedData()));

    if (createElementCommand == null) { \
        return UnexecutableCommand.INSTANCE;\
    }       \
    if(!createElementCommand.canExecute()){\
        return createElementCommand;\
    }\
    // create the semantic create wrapper command\
    SemanticCreateCommand semanticCommand =\
        new SemanticCreateCommand(requestAdapter, createElementCommand);\
    Command viewCommand = getCreateCommand(request);

    Command refreshConnectionCommand =\
        getHost().getCommand(\
            new RefreshConnectionsRequest(((List)request.getNewObject())));

    // form the compound command and return\
    CompositeCommand cc = new CompositeCommand(semanticCommand.getLabel());\
    cc.compose(semanticCommand);\
    cc.compose(new CommandProxy(viewCommand));\
    if ( refreshConnectionCommand != null ) {\
        cc.compose(new CommandProxy(refreshConnectionCommand));\
    }

    return new ICommandProxy(cc);\
}

The code returns non executable object from below lines of code and nodes are not getting created in activity diagram:

    if(!createElementCommand.canExecute()){\
       return createElementCommand;\
    }

May I know if:

  1. Am I missing something in the migration from UML2 3.x to UML2 5.x?
  2. Is there any migration document which talk about replacing createNode() with createOwnedNode()?
  3. Any pointers on how to get nodes created would be helpful.

Thanks in advance.

eclipse-uml2-bot commented 5 hours ago

By Vishal Sharnagat on Sep 24, 2024 03:52

Created attachment 289494 Disabled menu

Looks like the menu/toolbar (horizontal bar with nodes to select) is disabled. However, the same shown on Pallete are enabled. But, nothing happens when I click it. On debug, it calls the same code to return null command.

Screenshot 2024-09-24 at 1.14.46 PM.png

Screenshot 2024-09-24 at 1.14.46 PM.png

eclipse-uml2-bot commented 5 hours ago

By Vishal Sharnagat on Sep 24, 2024 03:55

Created attachment 289497 Context Menu

The context menu is enabled. However, only for the nodes it is returning null command. For other menu items like note, text, geometric shapes (circle, oval, triangle, etc.) it is working fine.

Screenshot 2024-09-24 at 1.17.50 PM.png

Screenshot 2024-09-24 at 1.17.50 PM.png