Eclipse rcp 修改Eclipse RCP Graphiti中的象形图元素
我尝试了这里提供的解决方案: 我试图在实现AbstractUpdateFeature的类的UpdateNeeded函数中调用Upadate功能:Eclipse rcp 修改Eclipse RCP Graphiti中的象形图元素,eclipse-rcp,eclipse-emf,Eclipse Rcp,Eclipse Emf,我尝试了这里提供的解决方案: 我试图在实现AbstractUpdateFeature的类的UpdateNeeded函数中调用Upadate功能: TransactionalEditingDomain域=TransactionUtils.getEditingDomain(图); domain.getCommandStack().execute(新记录命令(域){ 公共void doExecute(){ UpdateContext UpdateContext=new UpdateContext(g
TransactionalEditingDomain域=TransactionUtils.getEditingDomain(图);
domain.getCommandStack().execute(新记录命令(域){
公共void doExecute(){
UpdateContext UpdateContext=new
UpdateContext(getDiagram().getChildren().get(0.getGraphicsAlgorithm().getPictogramElement());
IUpdateFeature updateFeature=getFeatureProvider().getUpdateFeature(updateContext);
updateFeature.update(updateContext);
}});
在更新功能中,我试图更改象形图元素文本字段的值:
//在象形图模型中设置名称
if(集装箱船的象形图元素实例){
集装箱船外形cs=(集装箱船外形)象形图元素;
对于(形状:cs.getChildren()){
if(shape.getGraphicsAlgorithm()文本实例){
Text Text=(Text)shape.getGraphicsAlgorithm();
text.setValue(“aaa”);
返回true;
}
}
}
但我得到了一个例外:
java.lang.IllegalStateException: Cannot modify resource set without a write transaction
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.assertWriting(TransactionChangeRecorder.java:348)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.appendNotification(TransactionChangeRecorder.java:302)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.processObjectNotification(TransactionChangeRecorder.java:284)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.notifyChanged(TransactionChangeRecorder.java:240)
尝试使用DiagramBehavior执行功能
getDiagramBehavior().executeFeature(feature, context);
什么例外?显示您的代码和错误。我们不是千里眼。@Jandogen我已经用所需的信息修改了我的问题。