Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » [GEF4] Add node to graph generate UnsupportedOperationException
[GEF4] Add node to graph generate UnsupportedOperationException [message #1718961] Sun, 03 January 2016 21:36 Go to next message
Victor Hiairrassary is currently offline Victor HiairrassaryFriend
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
Re: [GEF4] Add node to graph generate UnsupportedOperationException [message #1719132 is a reply to message #1718961] Tue, 05 January 2016 14:43 Go to previous messageGo to next message
Alexander Nyssen is currently offline Alexander NyssenFriend
Messages: 244
Registered: July 2009
Location: Lünen
Senior Member
As you can see this functionality is not yet supported by GraphContentPart. Please open a bugzilla, we can add the required functionality.
Re: [GEF4] Add node to graph generate UnsupportedOperationException [message #1719624 is a reply to message #1719132] Sun, 10 January 2016 09:30 Go to previous message
Victor Hiairrassary is currently offline Victor HiairrassaryFriend
Messages: 7
Registered: December 2015
Junior Member
Thank you for the answer, here is the link to the bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=485488
Previous Topic:[GEF4] https for all update-sites
Next Topic:NPE when a new non empty graph is set in a ZestFxUiView
Goto Forum:
  


Current Time: Fri Apr 26 16:33:30 GMT 2024

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

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

Back to the top