summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordhubner2009-03-16 09:24:50 (EDT)
committer dhubner2009-03-16 09:24:50 (EDT)
commite7bbbb24981d16a20b9b47ab998c7fe8e2f3195d (patch)
tree907ad1aa6f358d63e210d9593529b6e6228fdd91
parentd1fdfe821b7c801c7744d65de091540fa1e488ea (diff)
downloadorg.eclipse.mwe-e7bbbb24981d16a20b9b47ab998c7fe8e2f3195d.zip
org.eclipse.mwe-e7bbbb24981d16a20b9b47ab998c7fe8e2f3195d.tar.gz
org.eclipse.mwe-e7bbbb24981d16a20b9b47ab998c7fe8e2f3195d.tar.bz2
[268730] NPE during initialization of the editor - patch applied
-rw-r--r--plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/WorkflowEditorPlugin.java7
-rw-r--r--plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/editor/WorkflowEditor.java45
-rw-r--r--plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/editor/WorkflowReconcilingStrategy.java5
-rw-r--r--plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/utils/TypeUtils.java12
4 files changed, 44 insertions, 25 deletions
diff --git a/plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/WorkflowEditorPlugin.java b/plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/WorkflowEditorPlugin.java
index bb70c90..a6ea826 100644
--- a/plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/WorkflowEditorPlugin.java
+++ b/plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/WorkflowEditorPlugin.java
@@ -15,7 +15,9 @@ import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -27,11 +29,11 @@ import org.osgi.framework.BundleContext;
/**
* @author Patrick Schoenbach - Initial API and implementation
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
/**
* @author Patrick Schoenbach - Initial API and implementation
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public class WorkflowEditorPlugin extends AbstractUIPlugin {
@@ -200,6 +202,7 @@ public class WorkflowEditorPlugin extends AbstractUIPlugin {
@Override
public void start(final BundleContext context) throws Exception {
super.start(context);
+ JavaCore.initializeAfterLoad(new NullProgressMonitor());
}
/*
diff --git a/plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/editor/WorkflowEditor.java b/plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/editor/WorkflowEditor.java
index df6527d..d5161d5 100644
--- a/plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/editor/WorkflowEditor.java
+++ b/plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/editor/WorkflowEditor.java
@@ -11,12 +11,15 @@
package org.eclipse.emf.mwe.ui.internal.editor.editor;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.ResourceBundle;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -41,6 +44,7 @@ import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextListener;
+import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRuler;
@@ -49,6 +53,7 @@ import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel;
import org.eclipse.jface.text.source.projection.ProjectionSupport;
import org.eclipse.jface.text.source.projection.ProjectionViewer;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
@@ -57,21 +62,29 @@ import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
/**
* @author Patrick Schoenbach - Initial API and implementation
- * @version $Revision: 1.44 $
+ * @version $Revision: 1.45 $
*/
public class WorkflowEditor extends TextEditor {
private class InitializerJob extends Job {
- public InitializerJob(String name) {
+ public InitializerJob(String name, IResource resource) {
super(name);
setPriority(Job.LONG);
+ if (resource != null)
+ setRule(resource);
+ else
+ setRule(ResourcesPlugin.getWorkspace().getRoot());
}
@Override
protected IStatus run(IProgressMonitor monitor) {
+ if (monitor.isCanceled())
+ return Status.CANCEL_STATUS;
try {
preloadClassNameCache(monitor);
+ if (monitor.isCanceled())
+ return Status.CANCEL_STATUS;
}
catch (CoreException e) {
IDocument document = getInputDocument();
@@ -94,8 +107,8 @@ public class WorkflowEditor extends TextEditor {
private Job validationJob;
- private Job initializerJob = new InitializerJob("Initializing editor...");
-
+ private Job initializerJob;
+
private IWorkflowElement rootElement;
private Collection<IWorkflowElement> elements;
@@ -138,18 +151,19 @@ public class WorkflowEditor extends TextEditor {
if (outlinePage != null) {
outlinePage.setInput(null);
}
-
- initializerJob.cancel();
+ if (initializerJob != null)
+ initializerJob.cancel();
TypeUtils.clearCache();
super.dispose();
}
/**
* This method overrides the implementation of <code>getAdapter</code>
- * inherited from the superclass.
+ * inherited from the superclass to provide an adapter for IContentOutlinePage.
*
* @see org.eclipse.ui.editors.text.TextEditor#getAdapter(java.lang.Class)
*/
+ @SuppressWarnings("unchecked")
@Override
public Object getAdapter(final Class adapter) {
if (IContentOutlinePage.class.equals(adapter)) {
@@ -185,6 +199,16 @@ public class WorkflowEditor extends TextEditor {
final IFile file = ife.getFile();
return file;
}
+
+ @Override
+ protected void doSetInput(IEditorInput input) throws CoreException {
+ super.doSetInput(input);
+ if (input instanceof IFileEditorInput) {
+ IFile file = getInputFile();
+ initializerJob = new InitializerJob("Initializing editor...", file);
+ initializerJob.schedule();
+ }
+ }
/**
* Returns the value of field <code>propertyNames</code>.
@@ -241,9 +265,9 @@ public class WorkflowEditor extends TextEditor {
this.rootElement = newRootElement;
}
- public void updateFoldingStructure(final ArrayList positions) {
+ public void updateFoldingStructure(final List<Position> positions) {
final Annotation[] annotations = new Annotation[positions.size()];
- final HashMap newAnnotations = new HashMap();
+ final Map<ProjectionAnnotation, Position> newAnnotations = new HashMap<ProjectionAnnotation, Position>();
for (int i = 0; i < positions.size(); i++) {
final ProjectionAnnotation annotation = new ProjectionAnnotation();
@@ -321,7 +345,6 @@ public class WorkflowEditor extends TextEditor {
});
validateAndMark();
- initializerJob.schedule();
return viewer;
}
diff --git a/plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/editor/WorkflowReconcilingStrategy.java b/plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/editor/WorkflowReconcilingStrategy.java
index d713f08..cd88b36 100644
--- a/plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/editor/WorkflowReconcilingStrategy.java
+++ b/plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/editor/WorkflowReconcilingStrategy.java
@@ -12,6 +12,7 @@
package org.eclipse.emf.mwe.ui.internal.editor.editor;
import java.util.ArrayList;
+import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.text.BadLocationException;
@@ -25,7 +26,7 @@ import org.eclipse.swt.widgets.Display;
/**
* @author Patrick Schoenbach - Initial API and implementation
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
*/
public class WorkflowReconcilingStrategy implements IReconcilingStrategy,
IReconcilingStrategyExtension {
@@ -42,7 +43,7 @@ public class WorkflowReconcilingStrategy implements IReconcilingStrategy,
protected static final int PI_TAG = 6;
- protected final ArrayList positions = new ArrayList();
+ protected final List<Position> positions = new ArrayList<Position>();
protected int offset;
diff --git a/plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/utils/TypeUtils.java b/plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/utils/TypeUtils.java
index 484c988..d9ab559 100644
--- a/plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/utils/TypeUtils.java
+++ b/plugins/org.eclipse.emf.mwe.ui.editor/src/org/eclipse/emf/mwe/ui/internal/editor/utils/TypeUtils.java
@@ -40,8 +40,6 @@ import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IRegion;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.core.JavaCore;
@@ -55,7 +53,7 @@ import org.eclipse.jdt.core.search.TypeNameMatchRequestor;
/**
* @author Patrick Schoenbach - Initial API and implementation
- * @version $Revision: 1.13 $
+ * @version $Revision: 1.14 $
*/
public final class TypeUtils {
@@ -529,13 +527,7 @@ public final class TypeUtils {
private static ITypeHierarchy createTypeHierarchy(final IProject project, final IType type, IProgressMonitor monitor) {
try {
final IJavaProject jp = JavaCore.create(project);
- final IRegion region = JavaCore.newRegion();
- final IPackageFragmentRoot[] root = jp.getAllPackageFragmentRoots();
- for (final IPackageFragmentRoot r : root) {
- region.add(r);
- }
- final ITypeHierarchy hierarchy = jp.newTypeHierarchy(type, region, monitor);
- return hierarchy;
+ return type.newTypeHierarchy(jp, monitor);
}
catch (final JavaModelException e) {
Log.logError("Java Model Exception", e);