我正在编写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);
}
当我首先编辑文件时.q我们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。
每次我在GroovyEditors中编辑某些内容时,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发送'message',其中一个GroovyEditors是“脏”的?
答案 0 :(得分:2)
终于解决了 - 问题不在我的代码中,而是在GroovyEditor中 - 如果项目性质是Java项目性质(可能Groovy项目本质也会起作用)一切都很好,否则GroovyEditor抛出异常。我已经向Groove Editor问题跟踪器报告了错误,它已经解决了,所以在下一个版本中一切都应该没问题。现在唯一的解决方案是将java项目性质添加到项目的性质中。