Author: yradtsevich
Date: 2010-04-29 10:33:58 -0400 (Thu, 29 Apr 2010)
New Revision: 21794
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-6204
VPE is empty and crashing
- Fixed
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java 2010-04-29
14:30:46 UTC (rev 21793)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java 2010-04-29
14:33:58 UTC (rev 21794)
@@ -82,7 +82,7 @@
}
public IVisualController getController() {
- IEditorPart editor =
ModelUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorPart editor = getEditor();
if(!(editor instanceof JSPMultiPageEditor)) return null;
IVisualEditor v = ((JSPMultiPageEditor)editor).getVisualEditor();
if(v == null) return null;
@@ -91,7 +91,7 @@
boolean init() {
if(isVisualContextInitialized) return true;
- IEditorPart editor =
ModelUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorPart editor = getEditor();
if(!(editor instanceof JSPMultiPageEditor)) return false;
JSPTextEditor jspEditor = ((JSPMultiPageEditor)editor).getJspEditor();
@@ -103,6 +103,11 @@
return getIVisualContext() != null;
}
+ protected IEditorPart getEditor() {
+ return ModelUIPlugin.getDefault().getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ }
+
private IVisualContext getIVisualContext(){
JSPTextEditor jspEditor = getJSPTextEditor();
return (jspEditor == null) ? null : jspEditor.getPageContext();
@@ -120,7 +125,7 @@
}
protected JSPTextEditor getJSPTextEditor() {
- IEditorPart editor =
ModelUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorPart editor = getEditor();
if(!(editor instanceof JSPMultiPageEditor)) return null;
return ((JSPMultiPageEditor)editor).getJspEditor();
}
@@ -189,7 +194,7 @@
}
public IEditorInput getEditorInput() {
- IEditorPart editor =
ModelUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorPart editor = getEditor();
return editor.getEditorInput();
}
@@ -221,7 +226,7 @@
//Support of StructuredTextEditor
boolean init2() {
if(isVisualContextInitialized) return true;
- IEditorPart editor =
ModelUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorPart editor = getEditor();
if(!(editor instanceof StructuredTextEditor)) return false;
StructuredTextEditor jspEditor = ((StructuredTextEditor)editor);
IDocument document = jspEditor.getDocumentProvider().getDocument(getEditorInput());
@@ -266,7 +271,7 @@
public ISourceViewer getSourceViewer() {
JSPTextEditor jspEditor = getJSPTextEditor();
if(jspEditor != null) return jspEditor.getTextViewer();
- IEditorPart editor =
ModelUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorPart editor = getEditor();
if (editor == null) return null;
if(editor instanceof AbstractTextEditor) {
try {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2010-04-29
14:30:46 UTC (rev 21793)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2010-04-29
14:33:58 UTC (rev 21794)
@@ -19,6 +19,7 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.editors.text.ILocationProvider;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
@@ -183,8 +184,16 @@
if (document == null || query == null) {
return tagValue;
}
-
- ValueHelper valueHelper = new ValueHelper();
+ final IEditorPart editor =
pageContext.getEditPart().getSite().getPage().getActiveEditor();
+ ValueHelper valueHelper = new ValueHelper() {
+ // yradtsevich: fix of JBIDE-6204: NPE was thrown in the base method
+ // because getActivePage() may be null before the page is initialized
+ @Override
+ protected IEditorPart getEditor() {
+ return editor;
+ }
+ };
+
JspContentAssistProcessor processor = valueHelper.createContentAssistProcessor();
int offset = 0;
if(sourceNode instanceof IndexedRegion) {