Community
Participate
Working Groups
Build Identifier: I20110613-1736 I want to show/hide link ediparts. To do so I set the view's visible attribute to true/false. Then I ask the editpart registry for the editpart of the view. This works as long as the link has been visible on diagram startup. The scenario that breaks is the following 1) Open diagram 2) Set view's visible value to false (view gets hidden) 3) Close diagram 4) Set view's visible value to true (view does not become visible) The editpart registry cannot find an edit part for the view even though it is set to visible and hence should have an editpart. Reproducible: Always
This is kinda expected behavior, there are no editparts to react to the changes of the view. To my understanding, the reason for that is just a performance optimization -- there might be A LOT of hidden links, especially in big models, and most of them will never be changed again. As a workaround, I would suggest to explicitly call diagram update (e.g, with XXXDiagramUpdateCommand) after changing of the link's visibility to true. It should create missed editparts. (I am changing component to tooling as runtime is not responsible to the fact that we don't create and immediately hide editparts for hidden views).
Severity = normal, as there is known workaround and semi-solid :) reasoning behind this implementation decision
(In reply to comment #2) > Severity = normal, as there is known workaround and semi-solid :) reasoning > behind this implementation decision I use if (true == variable) v.setVisible(false); else v.setVisible(true); IHandlerService service = (IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class); IHandlerService service = (IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class); try { service.executeCommand("xxxdiagram.updateDiagram", null); } catch (Exception e) { e.printStackTrace(); } IGraphicalEditPart edgeEP = (IGraphicalEditPart) getViewer().getEditPartRegistry().get(v); edgeEP.performRequest(new Request(RequestConstants.REQ_REFRESH)); //NullPointerException This does not create an editpart for the view.
Hum, need to see in action. Could you please try to call the XXXDiagramUpdateCommand directly, something like: EObject diagramSemantic = myFindDiagramSemanticObject(v); XXXDiagramUpdateCommand.perfromCanonicalUpdate(diagramSemantic); Regards, Michael
Hi, all that is available is an execute method which does not have any effect. I called it this way: XXXDiagramUpdateCommand cmd = new XXXDiagramUpdateCommand(); try { cmd.execute(null); } catch (ExecutionException e) { e.printStackTrace(); } The command I use is generated to the xxx.diagram.part package. Do you speak about the same command. Ralph
Yes, but if you look at the code, you will see attempt to obtain the semantic element from the selection, which is I guess not working in your call. Thats why i have asked to check to call directly the worker method, which is generated this way in my case: /** * @generated */ public static void performCanonicalUpdate(EObject modelElement) { if (modelElement == null) { return; } List editPolicies = CanonicalEditPolicy.getRegisteredEditPolicies(modelElement); for (Iterator it = editPolicies.iterator(); it.hasNext();) { CanonicalEditPolicy nextEditPolicy = (CanonicalEditPolicy) it.next(); nextEditPolicy.refresh(); } } I have realized that I am looking at the UML2Tools diagrams and it is possible that this method had been generated by the U2T specific additions. If it is the case, we may want to add this to the GMF templates, especially if you confirm that it indeed works as a workaround for you. Regards, Michael
Hi, that code is specific to UML2Tools. I added it to my command and called it this way: PLMDiagramUpdateCommand.performCanonicalUpdate(EcoreUtil.getRootContainer(resolveSemanticElement())); However, this does not create the editpart for the link :(
Weird, I will try to debug with U2T diagram.