Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Bug in org.eclipse.gmf.runtime.diagram.ui.render.clipboard.DiagramGenerator class ?
Bug in org.eclipse.gmf.runtime.diagram.ui.render.clipboard.DiagramGenerator class ? [message #167822] Fri, 11 January 2008 14:07 Go to next message
Mariot Chauvin is currently offline Mariot ChauvinFriend
Messages: 174
Registered: July 2009
Senior Member
Hi all,

Please find below a snippet of DiagramGenerator#findConnectionsToPaint(List editParts, List connectionsToPaint) :

private void findConnectionsToPaint(List editParts, List connectionsToPaint) {

EditPartViewer viewer = getDiagramEditPart().getRoot().getViewer();

// For each edit part
for (Iterator iter = editParts.iterator(); iter.hasNext();) {
IGraphicalEditPart element = (IGraphicalEditPart) iter.next();

// Get its view
View view = (View) element.getModel();

// If the view is a shape view...
if (element instanceof ShapeEditPart) {
// Get its connections source
List sourceConnections = view.getSourceEdges();

// For each source connection...
for (int i = 0; i < sourceConnections.size(); i++) {
Edge edge = (Edge) sourceConnections.get(i);

// Get the connections target
View toView = (edge).getTarget();

AbstractEditPart toEditPart = (AbstractEditPart) viewer
.getEditPartRegistry().get(toView);

if (editParts.contains(toEditPart)) {

ConnectionNodeEditPart connectionEditPart = (ConnectionNodeEditPart) viewer
.getEditPartRegistry().get(edge);

connectionsToPaint.add(connectionEditPart);
}
}
}
}
}

The way this method get the view connections source ( view.getSourceEdges() ) seems to me unsafe. I think that it would be preferable to get the
source connections from the edit part :

AbstractGraphicalEditPart agep = (AbstractGraphicalEditPart) viewer.getEditPartRegistry().get(view);
List sourceConnections = agep.getModelSourceConnections();

For instance, if the edge has it "Visible" property set to false, the method getSourceEdges() will return the edge in the List.
It will result a null pointer when the code will try to get the connectionEditPart from the edit part :

ConnectionNodeEditPart connectionEditPart = (ConnectionNodeEditPart) viewer.getEditPartRegistry().get(edge);

Furthermore the image export will fail due to this null pointer in DiagramGenerator#mapFiguresToEditParts(Collection editParts) on the getFigure() call :

....
result.put(next.getFigure(), next);
....

Thanks for your help,
Regards,

Mariot
Re: Bug in org.eclipse.gmf.runtime.diagram.ui.render.clipboard.DiagramGenerator class ? [message #167940 is a reply to message #167822] Fri, 11 January 2008 18:53 Go to previous messageGo to next message
Cherie Revells is currently offline Cherie RevellsFriend
Messages: 299
Registered: July 2009
Senior Member
Mariot,

Sounds like a bug. Please raise a bugzilla against the Diagram Runtime
component.

Regards,
Cherie

Mariot Chauvin wrote:
> Hi all,
>
> Please find below a snippet of DiagramGenerator#findConnectionsToPaint(List editParts, List connectionsToPaint) :
>
> private void findConnectionsToPaint(List editParts, List connectionsToPaint) {
>
> EditPartViewer viewer = getDiagramEditPart().getRoot().getViewer();
>
> // For each edit part
> for (Iterator iter = editParts.iterator(); iter.hasNext();) {
> IGraphicalEditPart element = (IGraphicalEditPart) iter.next();
>
> // Get its view
> View view = (View) element.getModel();
>
> // If the view is a shape view...
> if (element instanceof ShapeEditPart) {
> // Get its connections source
> List sourceConnections = view.getSourceEdges();
>
> // For each source connection...
> for (int i = 0; i < sourceConnections.size(); i++) {
> Edge edge = (Edge) sourceConnections.get(i);
>
> // Get the connections target
> View toView = (edge).getTarget();
>
> AbstractEditPart toEditPart = (AbstractEditPart) viewer
> .getEditPartRegistry().get(toView);
>
> if (editParts.contains(toEditPart)) {
>
> ConnectionNodeEditPart connectionEditPart = (ConnectionNodeEditPart) viewer
> .getEditPartRegistry().get(edge);
>
> connectionsToPaint.add(connectionEditPart);
> }
> }
> }
> }
> }
>
> The way this method get the view connections source ( view.getSourceEdges() ) seems to me unsafe. I think that it would be preferable to get the
> source connections from the edit part :
>
> AbstractGraphicalEditPart agep = (AbstractGraphicalEditPart) viewer.getEditPartRegistry().get(view);
> List sourceConnections = agep.getModelSourceConnections();
>
> For instance, if the edge has it "Visible" property set to false, the method getSourceEdges() will return the edge in the List.
> It will result a null pointer when the code will try to get the connectionEditPart from the edit part :
>
> ConnectionNodeEditPart connectionEditPart = (ConnectionNodeEditPart) viewer.getEditPartRegistry().get(edge);
>
> Furthermore the image export will fail due to this null pointer in DiagramGenerator#mapFiguresToEditParts(Collection editParts) on the getFigure() call :
>
> ...
> result.put(next.getFigure(), next);
> ...
>
> Thanks for your help,
> Regards,
>
> Mariot
Re: Bug in org.eclipse.gmf.runtime.diagram.ui.render.clipboard.DiagramGenerator class ? [message #167982 is a reply to message #167940] Mon, 14 January 2008 09:00 Go to previous message
Mariot Chauvin is currently offline Mariot ChauvinFriend
Messages: 174
Registered: July 2009
Senior Member
Cherie,

Thanks for your response.
Bugzilla entry is https://bugs.eclipse.org/bugs/show_bug.cgi?id=215179

Regards,
Mariot

Cherie Revells wrote :
> Mariot,
>
> Sounds like a bug. Please raise a bugzilla against the Diagram Runtime
> component.
>
> Regards,
> Cherie
>
> Mariot Chauvin wrote:
>> Hi all,
>>
>> Please find below a snippet of
>> DiagramGenerator#findConnectionsToPaint(List editParts, List
>> connectionsToPaint) :
>>
>> private void findConnectionsToPaint(List editParts, List
>> connectionsToPaint) {
>>
>> EditPartViewer viewer = getDiagramEditPart().getRoot().getViewer();
>>
>> // For each edit part
>> for (Iterator iter = editParts.iterator(); iter.hasNext();) {
>> IGraphicalEditPart element = (IGraphicalEditPart) iter.next();
>>
>> // Get its view
>> View view = (View) element.getModel();
>>
>> // If the view is a shape view...
>> if (element instanceof ShapeEditPart) {
>> // Get its connections source
>> List sourceConnections = view.getSourceEdges();
>>
>> // For each source connection...
>> for (int i = 0; i < sourceConnections.size(); i++) {
>> Edge edge = (Edge) sourceConnections.get(i);
>>
>> // Get the connections target
>> View toView = (edge).getTarget();
>>
>> AbstractEditPart toEditPart = (AbstractEditPart) viewer
>> .getEditPartRegistry().get(toView);
>>
>> if (editParts.contains(toEditPart)) {
>>
>> ConnectionNodeEditPart connectionEditPart =
>> (ConnectionNodeEditPart) viewer
>> .getEditPartRegistry().get(edge);
>>
>> connectionsToPaint.add(connectionEditPart);
>> }
>> }
>> }
>> }
>> }
>>
>> The way this method get the view connections source (
>> view.getSourceEdges() ) seems to me unsafe. I think that it would be
>> preferable to get the
>> source connections from the edit part :
>>
>> AbstractGraphicalEditPart agep = (AbstractGraphicalEditPart)
>> viewer.getEditPartRegistry().get(view);
>> List sourceConnections = agep.getModelSourceConnections();
>>
>> For instance, if the edge has it "Visible" property set to false, the
>> method getSourceEdges() will return the edge in the List.
>> It will result a null pointer when the code will try to get the
>> connectionEditPart from the edit part :
>>
>> ConnectionNodeEditPart connectionEditPart = (ConnectionNodeEditPart)
>> viewer.getEditPartRegistry().get(edge);
>>
>> Furthermore the image export will fail due to this null pointer in
>> DiagramGenerator#mapFiguresToEditParts(Collection editParts) on the
>> getFigure() call :
>>
>> ...
>> result.put(next.getFigure(), next);
>> ...
>>
>> Thanks for your help,
>> Regards,
>>
>> Mariot
Previous Topic:Specialization Type
Next Topic:Button in Properties and own
Goto Forum:
  


Current Time: Mon Sep 23 16:48:02 GMT 2024

Powered by FUDForum. Page generated in 0.03790 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top