EclipseUML定义枚举项时慎用符号
今天用EclipseUML画类图遇到一个很郁闷的问题,为了保险起见我还是边画边保存的,画了一上午,有一次关闭了编辑器,再想打开时提示“Impossible to load the diagram xxx.ecd”。我这汗一下子就下来了,一上午的工作啊!赶紧查看一下Eclipse的errorlog,异常信息如下:
java.lang.NullPointerException
at com.omondo.uml.obf.cba.setInput(SourceFile:1153)
at com.omondo.uml.obf.cba.init(SourceFile:1109)
at com.omondo.uml.emf.ClassDiagramEditor.init(SourceFile:1013)
at org.eclipse.ui.internal.EditorManager.createSite(EditorManager.java:784)
at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:585)
at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:374)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:552)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:285)
at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:140)
at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:264)
at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:394)
at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1140)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1093)
at com.omondo.uml.obf.cba.setInput(SourceFile:1153)
at com.omondo.uml.obf.cba.init(SourceFile:1109)
at com.omondo.uml.emf.ClassDiagramEditor.init(SourceFile:1013)
at org.eclipse.ui.internal.EditorManager.createSite(EditorManager.java:784)
at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:585)
at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:374)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:552)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:285)
at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:140)
at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:264)
at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:394)
at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1140)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1093)
找不到任何与类图有关的信息,试着修改.ecd和.ecore文件,几次均没有效果。想到昨天晚上做过备份(万幸),只好恢复到那时的类图重新画。画完了保存,试着关闭编辑器再打开,竟然又提示“Impossible to load the diagram xxx.ecd”!!
我快不行了,最后的办法,边画边保存边备份,想看看到底是什么操作引起的这个问题。终于找到根源了,原来是我定义了一个名为Operator的Enumeration,里面有“+”、“-”、“*”和“/”四个枚举项,其中的“/”号会引起.ecd文件失效,我猜想是没有转义的缘故,EclipseUML会把它认作分隔符。
最后建议大家一定要像对自己的眼睛一样爱护自己的模型,经常备份是非常必要的,现在免费的图形化编辑器普遍都不是很稳定。