[GEF4] Add node to graph generate UnsupportedOperationException [message #1718961] |
Sun, 03 January 2016 21:36 |
Victor Hiairrassary Messages: 7 Registered: December 2015 |
Junior Member |
|
|
Hello,
I am trying to add a node to the current graph as the response on a javafx button click but I get an UnsupportedOperationException. The begin of the exception stack trace is:
java.lang.UnsupportedOperationException: Need to implement doAddContentChild(Object, int) for class org.eclipse.gef4.zest.fx.parts.GraphContentPart
at org.eclipse.gef4.mvc.parts.AbstractContentPart.doAddContentChild(AbstractContentPart.java:154)
at org.eclipse.gef4.mvc.parts.AbstractContentPart.addContentChild(AbstractContentPart.java:68)
at org.eclipse.gef4.mvc.operations.AddContentChildOperation.execute(AddContentChildOperation.java:76)
at org.eclipse.gef4.mvc.operations.AbstractCompositeOperation.execute(AbstractCompositeOperation.java:142)
at org.eclipse.gef4.mvc.policies.AbstractTransactionPolicy.locallyExecuteOperation(AbstractTransactionPolicy.java:140)
at org.eclipse.gef4.mvc.policies.ContentPolicy.addContentChild(ContentPolicy.java:72)
at org.eclipse.gef4.mvc.policies.CreationPolicy.create(CreationPolicy.java:128)
at org.eclipse.gef4.mvc.policies.CreationPolicy.create(CreationPolicy.java:195)
at com.capsyx.nati.ui.editor.common.policy.CreatePaletteOnClickPolicy$$anonfun$1.apply$mcV$sp(CreatePaletteOnClickPolicy.scala:103)
My policy create a palette on right mouse click (inspirated from this):
class CreatePaletteOnClickPolicy extends AbstractFXOnClickPolicy {
def click(event: MouseEvent): Unit = {
openPalette(event, positionInScreen)
}
private def getViewer(): FXViewer = {
getHost().getRoot().getViewer().asInstanceOf[FXViewer]
}
private def openPalette(event: MouseEvent, positionInScreen: Point2D): Unit = {
val popup = new Popup()
popup.autoFixProperty().set(true)
popup.autoHideProperty().set(true)
popup.setX(event.getScreenX())
popup.setY(event.getScreenY())
val hb = new HBox();
hb.setStyle("-fx-border-width: 1px; -fx-border-color: DIMGRAY; -fx-background-color: lightgray" );
val first = new Button()
first.setOnAction { actionEvent: ActionEvent =>
onNewPlaceClicked(actionEvent, popup)
}
first.setText("Place")
hb.getChildren().add(first);
hb.setEffect(new DropShadow(4, 4, 2, Color.GRAY))
hb.setSpacing(4)
hb.setPadding(new Insets( 4, 4, 4, 4))
popup.getContent().addAll(hb)
popup.show(getViewer().getScene().getWindow())
}
private def onNewPlaceClicked(event: ActionEvent, popup: Popup): Unit = {
val root = getHost().getRoot()
val viewer = root.getViewer()
val contentPartModel = root.getContentPartChildren().get(0).asInstanceOf[GraphContentPart]
val graph = contentPartModel.getContent
val node = {
val builder = new Node.Builder()
builder
.attr(ZestProperties.ELEMENT_CSS_ID, "A")
.attr(ZestProperties.ELEMENT_LABEL, "A")
builder.buildNode()
}
node.setGraph(graph)
val creationPolicy = root.getAdapter(classOf[CreationPolicy[javafx.scene.Node]])
creationPolicy.init()
// this throws the error
creationPolicy.create(node, contentPartModel, com.google.common.collect.HashMultimap.create())
val operation = creationPolicy.commit()
viewer.getDomain().execute(operation)
popup.hide()
}
}
Can someone help me with this issue please ? I use the latest GEF4 0.3.0 milestone.
Regards,
Victor
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02946 seconds