我在写eclipse插件。我有MultiPageEditor,其中有5页。在第一页上,有一个扩展了GraphicalEditor(geEx)的编辑器,在第二页上,是2(logicInputEditor,logicOutputEditor),它们是GroovyEditor的org.codehaus.groovy.eclipse.editor.GroovyEditor)。 geEx正在处理一个文件(例如first.qwe),并且
logicEditors正在使用其他2个文件(in.groovy,out.groovy)。在
geEx有一个代码:
@Override
public void commandStackChanged(EventObject event) {
firePropertyChange(IEditorPart.PROP_DIRTY);
super.commandStackChanged(event);
}
当我首先编辑文件时,qwe MultiPageEditor知道某些东西
被修改并标记它并允许保存文件-一切都在
精细。
我将侦听器添加到GrooveEditors:
logicInputEditor.addPropertyListener(new IPropertyListener() {
@Override
public void propertyChanged(Object source, int propId) {
if (propId == IEditorPart.PROP_DIRTY){
firePropertyChange(IEditorPart.PROP_DIRTY);
}
}
});
我无法覆盖commandStackChanged函数,因为GrooveEditor没有实现CommandStackListener。
每次我在GroovyEditor之一中编辑某些内容时,MultiPageEditor都会将其状态更改为脏-这是我想要的,但控制台上也会打印异常。所以-它按我的意愿工作,但是每次用户在编辑器中键入内容时都抛出并捕获异常是缓慢的,并且通常很糟糕。
消息是:
Problem trying to determine classpath of project Test:
Java Model Exception: Java Model Status [Test does not exist]
at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException(JavaElement.java:495)
at org.eclipse.jdt.internal.core.JavaModelManager.getPerProjectInfoCheckExistence(JavaModelManager.java:2287)
at org.eclipse.jdt.internal.core.JavaProject.getPerProjectInfo(JavaProject.java:1914)
at org.eclipse.jdt.internal.core.JavaProject.getOutputLocation(JavaProject.java:1741)
at org.eclipse.jdt.core.util.CompilerUtils.calculateClasspath(CompilerUtils.java:209)
at org.eclipse.jdt.core.util.CompilerUtils.setGroovyClasspath(CompilerUtils.java:152)
at org.eclipse.jdt.core.util.CompilerUtils.setGroovyClasspath(CompilerUtils.java:117)
at org.codehaus.jdt.groovy.model.GroovyCompilationUnit.buildStructure(GroovyCompilationUnit.java:260)
at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:258)
at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:526)
at org.eclipse.jdt.internal.core.CompilationUnit.makeConsistent(CompilationUnit.java:1100)
at org.codehaus.jdt.groovy.model.GroovyReconcileWorkingCopyOperation.makeConsistent(GroovyReconcileWorkingCopyOperation.java:60)
at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:89)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:788)
at org.codehaus.jdt.groovy.model.GroovyCompilationUnit.reconcile(GroovyCompilationUnit.java:423)
at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1231)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:133)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.access$0(JavaReconcilingStrategy.java:108)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:89)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:87)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:151)
at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86)
at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:104)
at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77)
at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)
要么:
!ENTRY org.eclipse.jdt.core 4 4 2012-08-13 20:33:29.402
!MESSAGE Problem with build structure for in.groovy
!STACK 1
Java Model Exception: Java Model Status [Test does not exist]
at org.eclipse.jdt.internal.core.JavaElement.newJavaModelException(JavaElement.java:505)
at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:246)
at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:526)
at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:255)
at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:241)
at org.eclipse.jdt.internal.core.JavaProject.getJavaProjectElementInfo(JavaProject.java:1646)
at org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.java:2334)
at org.eclipse.jdt.internal.core.SearchableEnvironment.<init>(SearchableEnvironment.java:59)
at org.eclipse.jdt.internal.core.SearchableEnvironment.<init>(SearchableEnvironment.java:66)
at org.eclipse.jdt.internal.core.CancelableNameEnvironment.<init>(CancelableNameEnvironment.java:26)
at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:178)
at org.codehaus.jdt.groovy.model.GroovyCompilationUnit.buildStructure(GroovyCompilationUnit.java:338)
at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:258)
at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:526)
at org.eclipse.jdt.internal.core.CompilationUnit.makeConsistent(CompilationUnit.java:1100)
at org.codehaus.jdt.groovy.model.GroovyReconcileWorkingCopyOperation.makeConsistent(GroovyReconcileWorkingCopyOperation.java:60)
at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:89)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:788)
at org.codehaus.jdt.groovy.model.GroovyCompilationUnit.reconcile(GroovyCompilationUnit.java:423)
at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1231)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:133)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.access$0(JavaReconcilingStrategy.java:108)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:89)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:87)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:151)
at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86)
at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:104)
at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77)
at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)
!SUBENTRY 1 org.eclipse.jdt.core 4 969 2012-08-13 20:33:29.402
!MESSAGE Test does not exist
问题是-我该如何解决?我应该如何向MultiPageEditor发送“消息”,而GroovyEditors之一是“脏”?
最佳答案
最终解决了-问题不在我的代码中,而是在GroovyEditor中-如果项目性质是Java项目性质(可能Groovy项目性质也可以工作),一切都很好,否则GroovyEditor抛出异常。我已经向Groove Editor问题跟踪器报告了错误,并且已经解决了该错误,因此在下一版本中,一切应该没问题。现在唯一的解决方案是将Java项目性质添加到项目的性质中。