Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » NPE with invisible shapes and connections
NPE with invisible shapes and connections [message #487165] Tue, 22 September 2009 08:50
Bruno Ziswiler is currently offline Bruno ZiswilerFriend
Messages: 7
Registered: July 2009
Junior Member
Hello

I've a ShapeCompartment with ShapeNodes as children. c and n both have
border items which serve as source and target for connections. Some of
the ShapeCompartment's children (ShapeNodes) and their associated
connections need to be invisible while other ShapeNodes and their
associated connections are visible. Whenever I toggle the visibility of
the nodes I get an NPE like this:

Caused by: java.lang.NullPointerException
at
org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmen tEditPart$ConnectionRefreshMgr.refreshConnections(ShapeCompa rtmentEditPart.java:144)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmen tEditPart.forceRefreshConnections(ShapeCompartmentEditPart.j ava:611)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmen tEditPart$2.run(ShapeCompartmentEditPart.java:594)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:134)
... 23 more

The visibility is toggled using this code in an EditPolicy which is
derived from AbstractEditPolicy:


@Override
public Command getCommand (Request request) {

Command result;
final SetRequest req= unwrap(request);

if (req != null &&
XyzPackage.eINSTANCE.getToolStatefulContainer_ActiveState(). equals(req.getFeature()))
{

final CompositeCommand cc= new CompositeCommand("Toggle States
Visibility"); //$NON-NLS-1$
final IGraphicalEditPart hostEP= (IGraphicalEditPart) getHost();
final String hint=
SemanticHintsConstants.HINT_BORDERED_STATEFUL_CONTAINER;
final IGraphicalEditPart borderEP= hostEP.getChildBySemanticHint(hint);
final View view= borderEP.getNotationView();
final EAttribute viewVisible= NotationPackage.eINSTANCE.getView_Visible();

for (Object obj: view.getChildren()) {
View childView= (View) obj;
EObject eObject= ViewUtil.resolveSemanticElement(childView);

if (eObject instanceof ToolState) {
active= eObject == req.getValue();
SetRequest stateVisibilityRequest= new SetRequest(childView,
viewVisible, active);
final SetValueCommand setValueCommand= new
SetValueCommand(stateVisibilityRequest);
cc.compose(setValueCommand);
}
}

cc.compose(make)

result= new ICommandProxy(cc);

} else {
result= super.getCommand(request);
}
return result;
}


Does someone know what I'm missing? I tried to handle the visibility as
well but w/o success.

I use the GMF runtime w/o the generation features, i.e. I don't have the
..gmfgen models.


Thank you so much
Bruno
Previous Topic:Capturing event of a compartment
Next Topic:Progressmonitor on EMF operation
Goto Forum:
  


Current Time: Wed Apr 24 14:50:24 GMT 2024

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

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

Back to the top