#1365431 (toshihiro) - PHP Editor crashes Windows with JavaScript 'windows.close()'
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / JavaOutlinePage.java
index c552344..f3a1eae 100644 (file)
@@ -10,7 +10,6 @@
  *******************************************************************************/
 package net.sourceforge.phpeclipse.phpeditor;
 
-
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.List;
@@ -109,754 +108,806 @@ import org.eclipse.ui.texteditor.TextEditorAction;
 import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
 import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
 
-
 /**
- * The content outline page of the Java editor. The viewer implements a proprietary
- * update mechanism based on Java model deltas. It does not react on domain changes.
- * It is specified to show the content of ICompilationUnits and IClassFiles.
- * Publishes its context menu under <code>PHPeclipsePlugin.getDefault().getPluginId() + ".outline"</code>.
+ * The content outline page of the Java editor. The viewer implements a
+ * proprietary update mechanism based on Java model deltas. It does not react on
+ * domain changes. It is specified to show the content of ICompilationUnits and
+ * IClassFiles. Publishes its context menu under
+ * <code>PHPeclipsePlugin.getDefault().getPluginId() + ".outline"</code>.
  */
-public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdaptable , IPostSelectionProvider {
-
-                       static Object[] NO_CHILDREN= new Object[0];
-
-                       /**
-                        * The element change listener of the java outline viewer.
-                        * @see IElementChangedListener
-                        */
-                       class ElementChangedListener implements IElementChangedListener {
+public class JavaOutlinePage extends Page implements IContentOutlinePage,
+               IAdaptable, IPostSelectionProvider {
 
-                               public void elementChanged(final ElementChangedEvent e) {
+       static Object[] NO_CHILDREN = new Object[0];
 
-                                       if (getControl() == null)
+       /**
+        * The element change listener of the java outline viewer.
+        * 
+        * @see IElementChangedListener
+        */
+       class ElementChangedListener implements IElementChangedListener {
+
+               public void elementChanged(final ElementChangedEvent e) {
+
+                       if (getControl() == null)
+                               return;
+
+                       Display d = getControl().getDisplay();
+                       if (d != null) {
+                               d.asyncExec(new Runnable() {
+                                       public void run() {
+                                               ICompilationUnit cu = (ICompilationUnit) fInput;
+                                               IJavaElement base = cu;
+                                               // if (fTopLevelTypeOnly) {
+                                               // base= getMainType(cu);
+                                               // if (base == null) {
+                                               if (fOutlineViewer != null)
+                                                       fOutlineViewer.refresh(true);
                                                return;
-
-                                       Display d= getControl().getDisplay();
-                                       if (d != null) {
-                                               d.asyncExec(new Runnable() {
-                                                       public void run() {
-                                                               ICompilationUnit cu= (ICompilationUnit) fInput;
-                                                               IJavaElement base= cu;
-//                                                             if (fTopLevelTypeOnly) {
-//                                                                     base= getMainType(cu);
-//                                                                     if (base == null) {
-                                                                               if (fOutlineViewer != null)
-                                                                                       fOutlineViewer.refresh(true);
-                                                                               return;
-//                                                                     }
-//                                                             }
-//                                                             IJavaElementDelta delta= findElement(base, e.getDelta());
-//                                                             if (delta != null && fOutlineViewer != null) {
-//                                                                     fOutlineViewer.reconcile(delta);
-//                                                             }
-                                                       }
-                                               });
-                                       }
-                               }
-
-                               private boolean isPossibleStructuralChange(IJavaElementDelta cuDelta) {
-                                       if (cuDelta.getKind() != IJavaElementDelta.CHANGED) {
-                                               return true; // add or remove
-                                       }
-                                       int flags= cuDelta.getFlags();
-                                       if ((flags & IJavaElementDelta.F_CHILDREN) != 0) {
-                                               return true;
-                                       }
-                                       return (flags & (IJavaElementDelta.F_CONTENT | IJavaElementDelta.F_FINE_GRAINED)) == IJavaElementDelta.F_CONTENT;
-                               }
-
-                               protected IJavaElementDelta findElement(IJavaElement unit, IJavaElementDelta delta) {
-
-                                       if (delta == null || unit == null)
-                                               return null;
-
-                                       IJavaElement element= delta.getElement();
-
-                                       if (unit.equals(element)) {
-                                               if (isPossibleStructuralChange(delta)) {
-                                                       return delta;
-                                               }
-                                               return null;
+                                               // }
+                                               // }
+                                               // IJavaElementDelta delta= findElement(base,
+                                               // e.getDelta());
+                                               // if (delta != null && fOutlineViewer != null) {
+                                               // fOutlineViewer.reconcile(delta);
+                                               // }
                                        }
+                               });
+                       }
+               }
 
+               private boolean isPossibleStructuralChange(IJavaElementDelta cuDelta) {
+                       if (cuDelta.getKind() != IJavaElementDelta.CHANGED) {
+                               return true; // add or remove
+                       }
+                       int flags = cuDelta.getFlags();
+                       if ((flags & IJavaElementDelta.F_CHILDREN) != 0) {
+                               return true;
+                       }
+                       return (flags & (IJavaElementDelta.F_CONTENT | IJavaElementDelta.F_FINE_GRAINED)) == IJavaElementDelta.F_CONTENT;
+               }
 
-                                       if (element.getElementType() > IJavaElement.CLASS_FILE)
-                                               return null;
+               protected IJavaElementDelta findElement(IJavaElement unit,
+                               IJavaElementDelta delta) {
 
-                                       IJavaElementDelta[] children= delta.getAffectedChildren();
-                                       if (children == null || children.length == 0)
-                                               return null;
+                       if (delta == null || unit == null)
+                               return null;
 
-                                       for (int i= 0; i < children.length; i++) {
-                                               IJavaElementDelta d= findElement(unit, children[i]);
-                                               if (d != null)
-                                                       return d;
-                                       }
+                       IJavaElement element = delta.getElement();
 
-                                       return null;
+                       if (unit.equals(element)) {
+                               if (isPossibleStructuralChange(delta)) {
+                                       return delta;
                                }
+                               return null;
                        }
 
-                       static class NoClassElement extends WorkbenchAdapter implements IAdaptable {
-                               /*
-                                * @see java.lang.Object#toString()
-                                */
-                               public String toString() {
-                                       return PHPEditorMessages.getString("JavaOutlinePage.error.NoTopLevelType"); //$NON-NLS-1$
-                               }
+                       if (element.getElementType() > IJavaElement.CLASS_FILE)
+                               return null;
 
-                               /*
-                                * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
-                                */
-                               public Object getAdapter(Class clas) {
-                                       if (clas == IWorkbenchAdapter.class)
-                                               return this;
-                                       return null;
-                               }
+                       IJavaElementDelta[] children = delta.getAffectedChildren();
+                       if (children == null || children.length == 0)
+                               return null;
+
+                       for (int i = 0; i < children.length; i++) {
+                               IJavaElementDelta d = findElement(unit, children[i]);
+                               if (d != null)
+                                       return d;
                        }
 
-                       /**
-                        * Content provider for the children of an ICompilationUnit or
-                        * an IClassFile
-                        * @see ITreeContentProvider
-                        */
-                       class ChildrenProvider implements ITreeContentProvider {
+                       return null;
+               }
+       }
 
-                               private Object[] NO_CLASS= new Object[] {new NoClassElement()};
-                               private ElementChangedListener fListener;
+       static class NoClassElement extends WorkbenchAdapter implements IAdaptable {
+               /*
+                * @see java.lang.Object#toString()
+                */
+               public String toString() {
+                       return PHPEditorMessages
+                                       .getString("JavaOutlinePage.error.NoTopLevelType"); //$NON-NLS-1$
+               }
 
-                               protected boolean matches(IJavaElement element) {
-                                       if (element.getElementType() == IJavaElement.METHOD) {
-                                               String name= element.getElementName();
-                                               return (name != null && name.indexOf('<') >= 0);
-                                       }
-                                       return false;
-                               }
+               /*
+                * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
+                */
+               public Object getAdapter(Class clas) {
+                       if (clas == IWorkbenchAdapter.class)
+                               return this;
+                       return null;
+               }
+       }
 
-                               protected IJavaElement[] filter(IJavaElement[] children) {
-                                       boolean initializers= false;
-                                       for (int i= 0; i < children.length; i++) {
-                                               if (matches(children[i])) {
-                                                       initializers= true;
-                                                       break;
-                                               }
-                                       }
+       /**
+        * Content provider for the children of an ICompilationUnit or an IClassFile
+        * 
+        * @see ITreeContentProvider
+        */
+       class ChildrenProvider implements ITreeContentProvider {
 
-                                       if (!initializers)
-                                               return children;
+               private Object[] NO_CLASS = new Object[] { new NoClassElement() };
 
-                                       Vector v= new Vector();
-                                       for (int i= 0; i < children.length; i++) {
-                                               if (matches(children[i]))
-                                                       continue;
-                                               v.addElement(children[i]);
-                                       }
+               private ElementChangedListener fListener;
 
-                                       IJavaElement[] result= new IJavaElement[v.size()];
-                                       v.copyInto(result);
-                                       return result;
-                               }
+               protected boolean matches(IJavaElement element) {
+                       if (element.getElementType() == IJavaElement.METHOD) {
+                               String name = element.getElementName();
+                               return (name != null && name.indexOf('<') >= 0);
+                       }
+                       return false;
+               }
 
-                               public Object[] getChildren(Object parent) {
-                                       if (parent instanceof IParent) {
-                                               IParent c= (IParent) parent;
-                                               try {
-                                                       return filter(c.getChildren());
-                                               } catch (JavaModelException x) {
-                                                       // https://bugs.eclipse.org/bugs/show_bug.cgi?id=38341
-                                                       // don't log NotExist exceptions as this is a valid case
-                                                       // since we might have been posted and the element
-                                                       // removed in the meantime.
-                                                       if (PHPeclipsePlugin.isDebug() || !x.isDoesNotExist())
-                                                               PHPeclipsePlugin.log(x);
-                                               }
-                                       }
-                                       return NO_CHILDREN;
+               protected IJavaElement[] filter(IJavaElement[] children) {
+                       boolean initializers = false;
+                       for (int i = 0; i < children.length; i++) {
+                               if (matches(children[i])) {
+                                       initializers = true;
+                                       break;
                                }
+                       }
 
-                               public Object[] getElements(Object parent) {
-                                       if (fTopLevelTypeOnly) {
-                                               if (parent instanceof ICompilationUnit) {
-                                                       try {
-                                                               IType type= getMainType((ICompilationUnit) parent);
-                                                               return type != null ? type.getChildren() : NO_CLASS;
-                                                       } catch (JavaModelException e) {
-                                                               PHPeclipsePlugin.log(e);
-                                                       }
-                                               }
-//                                             else if (parent instanceof IClassFile) {
-//                                                     try {
-//                                                             IType type= getMainType((IClassFile) parent);
-//                                                             return type != null ? type.getChildren() : NO_CLASS;
-//                                                     } catch (JavaModelException e) {
-//                                                             PHPeclipsePlugin.log(e);
-//                                                     }
-//                                             }
-                                       }
-                                       return getChildren(parent);
-                               }
+                       if (!initializers)
+                               return children;
 
-                               public Object getParent(Object child) {
-                                       if (child instanceof IJavaElement) {
-                                               IJavaElement e= (IJavaElement) child;
-                                               return e.getParent();
-                                       }
-                                       return null;
-                               }
+                       Vector v = new Vector();
+                       for (int i = 0; i < children.length; i++) {
+                               if (matches(children[i]))
+                                       continue;
+                               v.addElement(children[i]);
+                       }
 
-                               public boolean hasChildren(Object parent) {
-                                       if (parent instanceof IParent) {
-                                               IParent c= (IParent) parent;
-                                               try {
-                                                       IJavaElement[] children= filter(c.getChildren());
-                                                       return (children != null && children.length > 0);
-                                               } catch (JavaModelException x) {
-                                                       // https://bugs.eclipse.org/bugs/show_bug.cgi?id=38341
-                                                       // don't log NotExist exceptions as this is a valid case
-                                                       // since we might have been posted and the element
-                                                       // removed in the meantime.
-                                                       if (PHPeclipsePlugin.isDebug() || !x.isDoesNotExist())
-                                                               PHPeclipsePlugin.log(x);
-                                               }
-                                       }
-                                       return false;
-                               }
+                       IJavaElement[] result = new IJavaElement[v.size()];
+                       v.copyInto(result);
+                       return result;
+               }
 
-                               public boolean isDeleted(Object o) {
-                                       return false;
+               public Object[] getChildren(Object parent) {
+                       if (parent instanceof IParent) {
+                               IParent c = (IParent) parent;
+                               try {
+                                       return filter(c.getChildren());
+                               } catch (JavaModelException x) {
+                                       // https://bugs.eclipse.org/bugs/show_bug.cgi?id=38341
+                                       // don't log NotExist exceptions as this is a valid case
+                                       // since we might have been posted and the element
+                                       // removed in the meantime.
+                                       if (PHPeclipsePlugin.isDebug() || !x.isDoesNotExist())
+                                               PHPeclipsePlugin.log(x);
                                }
+                       }
+                       return NO_CHILDREN;
+               }
 
-                               public void dispose() {
-                                       if (fListener != null) {
-                                               JavaCore.removeElementChangedListener(fListener);
-                                               fListener= null;
+               public Object[] getElements(Object parent) {
+                       if (fTopLevelTypeOnly) {
+                               if (parent instanceof ICompilationUnit) {
+                                       try {
+                                               IType type = getMainType((ICompilationUnit) parent);
+                                               return type != null ? type.getChildren() : NO_CLASS;
+                                       } catch (JavaModelException e) {
+                                               PHPeclipsePlugin.log(e);
                                        }
                                }
+                               // else if (parent instanceof IClassFile) {
+                               // try {
+                               // IType type= getMainType((IClassFile) parent);
+                               // return type != null ? type.getChildren() : NO_CLASS;
+                               // } catch (JavaModelException e) {
+                               // PHPeclipsePlugin.log(e);
+                               // }
+                               // }
+                       }
+                       return getChildren(parent);
+               }
 
-                               /*
-                                * @see IContentProvider#inputChanged(Viewer, Object, Object)
-                                */
-                               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-                                       boolean isCU= (newInput instanceof ICompilationUnit);
-
-                                       if (isCU && fListener == null) {
-                                               fListener= new ElementChangedListener();
-                                               JavaCore.addElementChangedListener(fListener);
-                                       } else if (!isCU && fListener != null) {
-                                               JavaCore.removeElementChangedListener(fListener);
-                                               fListener= null;
-                                       }
+               public Object getParent(Object child) {
+                       if (child instanceof IJavaElement) {
+                               IJavaElement e = (IJavaElement) child;
+                               return e.getParent();
+                       }
+                       return null;
+               }
+
+               public boolean hasChildren(Object parent) {
+                       if (parent instanceof IParent) {
+                               IParent c = (IParent) parent;
+                               try {
+                                       IJavaElement[] children = filter(c.getChildren());
+                                       return (children != null && children.length > 0);
+                               } catch (JavaModelException x) {
+                                       // https://bugs.eclipse.org/bugs/show_bug.cgi?id=38341
+                                       // don't log NotExist exceptions as this is a valid case
+                                       // since we might have been posted and the element
+                                       // removed in the meantime.
+                                       if (PHPeclipsePlugin.isDebug() || !x.isDoesNotExist())
+                                               PHPeclipsePlugin.log(x);
                                }
                        }
+                       return false;
+               }
 
+               public boolean isDeleted(Object o) {
+                       return false;
+               }
 
-                       class JavaOutlineViewer extends TreeViewer {
+               public void dispose() {
+                       if (fListener != null) {
+                               JavaCore.removeElementChangedListener(fListener);
+                               fListener = null;
+                       }
+               }
 
-                               /**
-                                * Indicates an item which has been reused. At the point of
-                                * its reuse it has been expanded. This field is used to
-                                * communicate between <code>internalExpandToLevel</code> and
-                                * <code>reuseTreeItem</code>.
-                                */
-                               private Item fReusedExpandedItem;
-                               private boolean fReorderedMembers;
-                               private boolean fForceFireSelectionChanged;
+               /*
+                * @see IContentProvider#inputChanged(Viewer, Object, Object)
+                */
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       boolean isCU = (newInput instanceof ICompilationUnit);
+
+                       if (isCU && fListener == null) {
+                               fListener = new ElementChangedListener();
+                               JavaCore.addElementChangedListener(fListener);
+                       } else if (!isCU && fListener != null) {
+                               JavaCore.removeElementChangedListener(fListener);
+                               fListener = null;
+                       }
+               }
+       }
 
-                               public JavaOutlineViewer(Tree tree) {
-                                       super(tree);
-                                       setAutoExpandLevel(ALL_LEVELS);
-                                       setUseHashlookup(true);
-                               }
+       class JavaOutlineViewer extends TreeViewer {
 
-                               /**
-                                * Investigates the given element change event and if affected
-                                * incrementally updates the Java outline.
-                                *
-                                * @param delta the Java element delta used to reconcile the Java outline
-                                */
-                               public void reconcile(IJavaElementDelta delta) {
-                                       fReorderedMembers= false;
-                                       fForceFireSelectionChanged= false;
-                                       if (getSorter() == null) {
-                                               if (fTopLevelTypeOnly
-                                                       && delta.getElement() instanceof IType
-                                                       && (delta.getKind() & IJavaElementDelta.ADDED) != 0)
-                                               {
-                                                       refresh(true);
-
-                                               } else {
-                                                       Widget w= findItem(fInput);
-                                                       if (w != null && !w.isDisposed())
-                                                               update(w, delta);
-                                                       if (fForceFireSelectionChanged)
-                                                               fireSelectionChanged(new SelectionChangedEvent(getSite().getSelectionProvider(), this.getSelection()));
-                                                       if (fReorderedMembers) {
-                                                               refresh(false);
-                                                               fReorderedMembers= false;
-                                               }
-                                               }
-                                       } else {
-                                               // just for now
-                                               refresh(true);
-                                       }
-                               }
-
-                               /*
-                                * @see TreeViewer#internalExpandToLevel
-                                */
-                               protected void internalExpandToLevel(Widget node, int level) {
-                                       if (node instanceof Item) {
-                                               Item i= (Item) node;
-                                               if (i.getData() instanceof IJavaElement) {
-                                                       IJavaElement je= (IJavaElement) i.getData();
-                                                       if (je.getElementType() == IJavaElement.IMPORT_CONTAINER || isInnerType(je)) {
-                                                               if (i != fReusedExpandedItem) {
-                                                                       setExpanded(i, false);
-                                                                       return;
-                                                               }
-                                                       }
-                                               }
-                                       }
-                                       super.internalExpandToLevel(node, level);
-                               }
+               /**
+                * Indicates an item which has been reused. At the point of its reuse it
+                * has been expanded. This field is used to communicate between
+                * <code>internalExpandToLevel</code> and <code>reuseTreeItem</code>.
+                */
+               private Item fReusedExpandedItem;
 
-                               protected void reuseTreeItem(Item item, Object element) {
+               private boolean fReorderedMembers;
 
-                                       // remove children
-                                       Item[] c= getChildren(item);
-                                       if (c != null && c.length > 0) {
+               private boolean fForceFireSelectionChanged;
 
-                                               if (getExpanded(item))
-                                                       fReusedExpandedItem= item;
+               public JavaOutlineViewer(Tree tree) {
+                       super(tree);
+                       setAutoExpandLevel(ALL_LEVELS);
+                       setUseHashlookup(true);
+               }
 
-                                               for (int k= 0; k < c.length; k++) {
-                                                       if (c[k].getData() != null)
-                                                               disassociate(c[k]);
-                                                       c[k].dispose();
-                                               }
+               /**
+                * Investigates the given element change event and if affected
+                * incrementally updates the Java outline.
+                * 
+                * @param delta
+                *            the Java element delta used to reconcile the Java outline
+                */
+               public void reconcile(IJavaElementDelta delta) {
+                       fReorderedMembers = false;
+                       fForceFireSelectionChanged = false;
+                       if (getSorter() == null) {
+                               if (fTopLevelTypeOnly && delta.getElement() instanceof IType
+                                               && (delta.getKind() & IJavaElementDelta.ADDED) != 0) {
+                                       refresh(true);
+
+                               } else {
+                                       Widget w = findItem(fInput);
+                                       if (w != null && !w.isDisposed())
+                                               update(w, delta);
+                                       if (fForceFireSelectionChanged)
+                                               fireSelectionChanged(new SelectionChangedEvent(
+                                                               getSite().getSelectionProvider(), this
+                                                                               .getSelection()));
+                                       if (fReorderedMembers) {
+                                               refresh(false);
+                                               fReorderedMembers = false;
                                        }
-
-                                       updateItem(item, element);
-                                       updatePlus(item, element);
-                                       internalExpandToLevel(item, ALL_LEVELS);
-
-                                       fReusedExpandedItem= null;
-                                       fForceFireSelectionChanged= true;
                                }
+                       } else {
+                               // just for now
+                               refresh(true);
+                       }
+               }
 
-                               protected boolean mustUpdateParent(IJavaElementDelta delta, IJavaElement element) {
-                                       if (element instanceof IMethod) {
-                                               if ((delta.getKind() & IJavaElementDelta.ADDED) != 0) {
-                                                       try {
-                                                               return ((IMethod)element).isMainMethod();
-                                                       } catch (JavaModelException e) {
-                                                               PHPeclipsePlugin.log(e.getStatus());
-                                                       }
+               /*
+                * @see TreeViewer#internalExpandToLevel
+                */
+               protected void internalExpandToLevel(Widget node, int level) {
+                       if (node instanceof Item) {
+                               Item i = (Item) node;
+                               if (i.getData() instanceof IJavaElement) {
+                                       IJavaElement je = (IJavaElement) i.getData();
+                                       if (je.getElementType() == IJavaElement.IMPORT_CONTAINER
+                                                       || isInnerType(je)) {
+                                               if (i != fReusedExpandedItem) {
+                                                       setExpanded(i, false);
+                                                       return;
                                                }
-                                               return "main".equals(element.getElementName()); //$NON-NLS-1$
                                        }
-                                       return false;
                                }
+                       }
+                       super.internalExpandToLevel(node, level);
+               }
 
-                               /*
-                                * @see org.eclipse.jface.viewers.AbstractTreeViewer#isExpandable(java.lang.Object)
-                                */
-                               public boolean isExpandable(Object element) {
-                                       if (hasFilters()) {
-                                               return getFilteredChildren(element).length > 0;
-                                       }
-                                       return super.isExpandable(element);
-                               }
+               protected void reuseTreeItem(Item item, Object element) {
 
-                               protected ISourceRange getSourceRange(IJavaElement element) throws JavaModelException {
-                                       if (element instanceof ISourceReference)
-                                               return ((ISourceReference) element).getSourceRange();
-                                       if (element instanceof IMember)// && !(element instanceof IInitializer))
-                                               return ((IMember) element).getNameRange();
-                                       return null;
-                               }
+                       // remove children
+                       Item[] c = getChildren(item);
+                       if (c != null && c.length > 0) {
+
+                               if (getExpanded(item))
+                                       fReusedExpandedItem = item;
 
-                               protected boolean overlaps(ISourceRange range, int start, int end) {
-                                       return start <= (range.getOffset() + range.getLength() - 1) && range.getOffset() <= end;
+                               for (int k = 0; k < c.length; k++) {
+                                       if (c[k].getData() != null)
+                                               disassociate(c[k]);
+                                       c[k].dispose();
                                }
+                       }
 
-                               protected boolean filtered(IJavaElement parent, IJavaElement child) {
+                       updateItem(item, element);
+                       updatePlus(item, element);
+                       internalExpandToLevel(item, ALL_LEVELS);
 
-                                       Object[] result= new Object[] { child };
-                                       ViewerFilter[] filters= getFilters();
-                                       for (int i= 0; i < filters.length; i++) {
-                                               result= filters[i].filter(this, parent, result);
-                                               if (result.length == 0)
-                                                       return true;
-                                       }
+                       fReusedExpandedItem = null;
+                       fForceFireSelectionChanged = true;
+               }
 
-                                       return false;
+               protected boolean mustUpdateParent(IJavaElementDelta delta,
+                               IJavaElement element) {
+                       if (element instanceof IMethod) {
+                               if ((delta.getKind() & IJavaElementDelta.ADDED) != 0) {
+                                       try {
+                                               return ((IMethod) element).isMainMethod();
+                                       } catch (JavaModelException e) {
+                                               PHPeclipsePlugin.log(e.getStatus());
+                                       }
                                }
+                               return "main".equals(element.getElementName()); //$NON-NLS-1$
+                       }
+                       return false;
+               }
 
-                               protected void update(Widget w, IJavaElementDelta delta) {
+               /*
+                * @see org.eclipse.jface.viewers.AbstractTreeViewer#isExpandable(java.lang.Object)
+                */
+               public boolean isExpandable(Object element) {
+                       if (hasFilters()) {
+                               return getFilteredChildren(element).length > 0;
+                       }
+                       return super.isExpandable(element);
+               }
 
-                                       Item item;
+               protected ISourceRange getSourceRange(IJavaElement element)
+                               throws JavaModelException {
+                       if (element instanceof ISourceReference)
+                               return ((ISourceReference) element).getSourceRange();
+                       if (element instanceof IMember)// && !(element instanceof
+                                                                                       // IInitializer))
+                               return ((IMember) element).getNameRange();
+                       return null;
+               }
 
-                                       IJavaElement parent= delta.getElement();
-                                       IJavaElementDelta[] affected= delta.getAffectedChildren();
-                                       Item[] children= getChildren(w);
+               protected boolean overlaps(ISourceRange range, int start, int end) {
+                       return start <= (range.getOffset() + range.getLength() - 1)
+                                       && range.getOffset() <= end;
+               }
 
-                                       boolean doUpdateParent= false;
-                                       boolean doUpdateParentsPlus= false;
+               protected boolean filtered(IJavaElement parent, IJavaElement child) {
 
-                                       Vector deletions= new Vector();
-                                       Vector additions= new Vector();
+                       Object[] result = new Object[] { child };
+                       ViewerFilter[] filters = getFilters();
+                       for (int i = 0; i < filters.length; i++) {
+                               result = filters[i].filter(this, parent, result);
+                               if (result.length == 0)
+                                       return true;
+                       }
 
-                                       for (int i= 0; i < affected.length; i++) {
-                                           IJavaElementDelta affectedDelta= affected[i];
-                                               IJavaElement affectedElement= affectedDelta.getElement();
-                                               int status= affected[i].getKind();
+                       return false;
+               }
 
-                                               // find tree item with affected element
-                                               int j;
-                                               for (j= 0; j < children.length; j++)
-                                                   if (affectedElement.equals(children[j].getData()))
-                                                       break;
+               protected void update(Widget w, IJavaElementDelta delta) {
 
-                                               if (j == children.length) {
-                                                       // remove from collapsed parent
-                                                       if ((status & IJavaElementDelta.REMOVED) != 0) {
-                                                               doUpdateParentsPlus= true;
-                                                               continue;
-                                                       }
-                                                       // addition
-                                                       if ((status & IJavaElementDelta.CHANGED) != 0 &&
-                                                               (affectedDelta.getFlags() & IJavaElementDelta.F_MODIFIERS) != 0 &&
-                                                               !filtered(parent, affectedElement))
-                                                       {
-                                                               additions.addElement(affectedDelta);
-                                                       }
-                                                       continue;
-                                               }
+                       Item item;
 
-                                               item= children[j];
+                       IJavaElement parent = delta.getElement();
+                       IJavaElementDelta[] affected = delta.getAffectedChildren();
+                       Item[] children = getChildren(w);
 
-                                               // removed
-                                               if ((status & IJavaElementDelta.REMOVED) != 0) {
-                                                       deletions.addElement(item);
-                                                       doUpdateParent= doUpdateParent || mustUpdateParent(affectedDelta, affectedElement);
-
-                                               // changed
-                                               } else if ((status & IJavaElementDelta.CHANGED) != 0) {
-                                                       int change= affectedDelta.getFlags();
-                                                       doUpdateParent= doUpdateParent || mustUpdateParent(affectedDelta, affectedElement);
-
-                                                       if ((change & IJavaElementDelta.F_MODIFIERS) != 0) {
-                                                               if (filtered(parent, affectedElement))
-                                                                       deletions.addElement(item);
-                                                               else
-                                                                       updateItem(item, affectedElement);
-                                                       }
+                       boolean doUpdateParent = false;
+                       boolean doUpdateParentsPlus = false;
 
-                                                       if ((change & IJavaElementDelta.F_CONTENT) != 0)
-                                                               updateItem(item, affectedElement);
+                       Vector deletions = new Vector();
+                       Vector additions = new Vector();
 
-                                                       if ((change & IJavaElementDelta.F_CHILDREN) != 0)
-                                                               update(item, affectedDelta);
+                       for (int i = 0; i < affected.length; i++) {
+                               IJavaElementDelta affectedDelta = affected[i];
+                               IJavaElement affectedElement = affectedDelta.getElement();
+                               int status = affected[i].getKind();
 
-                                                       if ((change & IJavaElementDelta.F_REORDER) != 0)
-                                                               fReorderedMembers= true;
-                                               }
-                                       }
+                               // find tree item with affected element
+                               int j;
+                               for (j = 0; j < children.length; j++)
+                                       if (affectedElement.equals(children[j].getData()))
+                                               break;
 
-                                       // find all elements to add
-                                       IJavaElementDelta[] add= delta.getAddedChildren();
-                                       if (additions.size() > 0) {
-                                               IJavaElementDelta[] tmp= new IJavaElementDelta[add.length + additions.size()];
-                                               System.arraycopy(add, 0, tmp, 0, add.length);
-                                               for (int i= 0; i < additions.size(); i++)
-                                                       tmp[i + add.length]= (IJavaElementDelta) additions.elementAt(i);
-                                               add= tmp;
+                               if (j == children.length) {
+                                       // remove from collapsed parent
+                                       if ((status & IJavaElementDelta.REMOVED) != 0) {
+                                               doUpdateParentsPlus = true;
+                                               continue;
+                                       }
+                                       // addition
+                                       if ((status & IJavaElementDelta.CHANGED) != 0
+                                                       && (affectedDelta.getFlags() & IJavaElementDelta.F_MODIFIERS) != 0
+                                                       && !filtered(parent, affectedElement)) {
+                                               additions.addElement(affectedDelta);
                                        }
+                                       continue;
+                               }
 
-                                       // add at the right position
-                                       go2: for (int i= 0; i < add.length; i++) {
+                               item = children[j];
 
-                                               try {
+                               // removed
+                               if ((status & IJavaElementDelta.REMOVED) != 0) {
+                                       deletions.addElement(item);
+                                       doUpdateParent = doUpdateParent
+                                                       || mustUpdateParent(affectedDelta, affectedElement);
 
-                                                       IJavaElement e= add[i].getElement();
-                                                       if (filtered(parent, e))
-                                                               continue go2;
+                                       // changed
+                               } else if ((status & IJavaElementDelta.CHANGED) != 0) {
+                                       int change = affectedDelta.getFlags();
+                                       doUpdateParent = doUpdateParent
+                                                       || mustUpdateParent(affectedDelta, affectedElement);
 
-                                                       doUpdateParent= doUpdateParent || mustUpdateParent(add[i], e);
-                                                       ISourceRange rng= getSourceRange(e);
-                                                       int start= rng.getOffset();
-                                                       int end= start + rng.getLength() - 1;
-                                                       int nameOffset= Integer.MAX_VALUE;
-                                                       if (e instanceof IField) {
-                                                               ISourceRange nameRange= ((IField) e).getNameRange();
-                                                               if (nameRange != null)
-                                                                       nameOffset= nameRange.getOffset();
-                                                       }
+                                       if ((change & IJavaElementDelta.F_MODIFIERS) != 0) {
+                                               if (filtered(parent, affectedElement))
+                                                       deletions.addElement(item);
+                                               else
+                                                       updateItem(item, affectedElement);
+                                       }
 
-                                                       Item last= null;
-                                                       item= null;
-                                                       children= getChildren(w);
+                                       if ((change & IJavaElementDelta.F_CONTENT) != 0)
+                                               updateItem(item, affectedElement);
 
-                                                       for (int j= 0; j < children.length; j++) {
-                                                               item= children[j];
-                                                               IJavaElement r= (IJavaElement) item.getData();
+                                       if ((change & IJavaElementDelta.F_CHILDREN) != 0)
+                                               update(item, affectedDelta);
 
-                                                               if (r == null) {
-                                                                       // parent node collapsed and not be opened before -> do nothing
-                                                                       continue go2;
-                                                               }
+                                       if ((change & IJavaElementDelta.F_REORDER) != 0)
+                                               fReorderedMembers = true;
+                               }
+                       }
 
+                       // find all elements to add
+                       IJavaElementDelta[] add = delta.getAddedChildren();
+                       if (additions.size() > 0) {
+                               IJavaElementDelta[] tmp = new IJavaElementDelta[add.length
+                                               + additions.size()];
+                               System.arraycopy(add, 0, tmp, 0, add.length);
+                               for (int i = 0; i < additions.size(); i++)
+                                       tmp[i + add.length] = (IJavaElementDelta) additions
+                                                       .elementAt(i);
+                               add = tmp;
+                       }
 
-                                                               try {
-                                                                       rng= getSourceRange(r);
-
-                                                                       // multi-field declarations always start at
-                                                                       // the same offset. They also have the same
-                                                                       // end offset if the field sequence is terminated
-                                                                       // with a semicolon. If not, the source range
-                                                                       // ends behind the identifier / initializer
-                                                                       // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=51851
-                                                                       boolean multiFieldDeclaration=
-                                                                               r.getElementType() == IJavaElement.FIELD
-                                                                                       && e.getElementType() == IJavaElement.FIELD
-                                                                                       && rng.getOffset() == start;
-
-                                                                       // elements are inserted by occurrence
-                                                                       // however, multi-field declarations have
-                                                                       // equal source ranges offsets, therefore we
-                                                                       // compare name-range offsets.
-                                                                       boolean multiFieldOrderBefore= false;
-                                                                       if (multiFieldDeclaration) {
-                                                                               if (r instanceof IField) {
-                                                                                       ISourceRange nameRange= ((IField) r).getNameRange();
-                                                                                       if (nameRange != null) {
-                                                                                               if (nameRange.getOffset() > nameOffset)
-                                                                                                       multiFieldOrderBefore= true;
-                                                                                       }
-                                                                               }
-                                                                       }
+                       // add at the right position
+                       go2: for (int i = 0; i < add.length; i++) {
+
+                               try {
+
+                                       IJavaElement e = add[i].getElement();
+                                       if (filtered(parent, e))
+                                               continue go2;
+
+                                       doUpdateParent = doUpdateParent
+                                                       || mustUpdateParent(add[i], e);
+                                       ISourceRange rng = getSourceRange(e);
+                                       int start = rng.getOffset();
+                                       int end = start + rng.getLength() - 1;
+                                       int nameOffset = Integer.MAX_VALUE;
+                                       if (e instanceof IField) {
+                                               ISourceRange nameRange = ((IField) e).getNameRange();
+                                               if (nameRange != null)
+                                                       nameOffset = nameRange.getOffset();
+                                       }
 
-                                                                       if (!multiFieldDeclaration && overlaps(rng, start, end)) {
+                                       Item last = null;
+                                       item = null;
+                                       children = getChildren(w);
 
-                                                                               // be tolerant if the delta is not correct, or if
-                                                                               // the tree has been updated other than by a delta
-                                                                               reuseTreeItem(item, e);
-                                                                               continue go2;
+                                       for (int j = 0; j < children.length; j++) {
+                                               item = children[j];
+                                               IJavaElement r = (IJavaElement) item.getData();
 
-                                                                       } else if (multiFieldOrderBefore || rng.getOffset() > start) {
+                                               if (r == null) {
+                                                       // parent node collapsed and not be opened before ->
+                                                       // do nothing
+                                                       continue go2;
+                                               }
 
-                                                                               if (last != null && deletions.contains(last)) {
-                                                                                       // reuse item
-                                                                                       deletions.removeElement(last);
-                                                                                       reuseTreeItem(last, e);
-                                                                               } else {
-                                                                                       // nothing to reuse
-                                                                                       createTreeItem(w, e, j);
-                                                                               }
-                                                                               continue go2;
+                                               try {
+                                                       rng = getSourceRange(r);
+
+                                                       // multi-field declarations always start at
+                                                       // the same offset. They also have the same
+                                                       // end offset if the field sequence is terminated
+                                                       // with a semicolon. If not, the source range
+                                                       // ends behind the identifier / initializer
+                                                       // see
+                                                       // https://bugs.eclipse.org/bugs/show_bug.cgi?id=51851
+                                                       boolean multiFieldDeclaration = r.getElementType() == IJavaElement.FIELD
+                                                                       && e.getElementType() == IJavaElement.FIELD
+                                                                       && rng.getOffset() == start;
+
+                                                       // elements are inserted by occurrence
+                                                       // however, multi-field declarations have
+                                                       // equal source ranges offsets, therefore we
+                                                       // compare name-range offsets.
+                                                       boolean multiFieldOrderBefore = false;
+                                                       if (multiFieldDeclaration) {
+                                                               if (r instanceof IField) {
+                                                                       ISourceRange nameRange = ((IField) r)
+                                                                                       .getNameRange();
+                                                                       if (nameRange != null) {
+                                                                               if (nameRange.getOffset() > nameOffset)
+                                                                                       multiFieldOrderBefore = true;
                                                                        }
-
-                                                               } catch (JavaModelException x) {
-                                                                       // stumbled over deleted element
                                                                }
-
-                                                               last= item;
                                                        }
 
-                                                       // add at the end of the list
-                                                       if (last != null && deletions.contains(last)) {
-                                                               // reuse item
-                                                               deletions.removeElement(last);
-                                                               reuseTreeItem(last, e);
-                                                       } else {
-                                                               // nothing to reuse
-                                                               createTreeItem(w, e, -1);
+                                                       if (!multiFieldDeclaration
+                                                                       && overlaps(rng, start, end)) {
+
+                                                               // be tolerant if the delta is not correct, or
+                                                               // if
+                                                               // the tree has been updated other than by a
+                                                               // delta
+                                                               reuseTreeItem(item, e);
+                                                               continue go2;
+
+                                                       } else if (multiFieldOrderBefore
+                                                                       || rng.getOffset() > start) {
+
+                                                               if (last != null && deletions.contains(last)) {
+                                                                       // reuse item
+                                                                       deletions.removeElement(last);
+                                                                       reuseTreeItem(last, e);
+                                                               } else {
+                                                                       // nothing to reuse
+                                                                       createTreeItem(w, e, j);
+                                                               }
+                                                               continue go2;
                                                        }
 
                                                } catch (JavaModelException x) {
-                                                       // the element to be added is not present -> don't add it
+                                                       // stumbled over deleted element
                                                }
-                                       }
 
+                                               last = item;
+                                       }
 
-                                       // remove items which haven't been reused
-                                       Enumeration e= deletions.elements();
-                                       while (e.hasMoreElements()) {
-                                               item= (Item) e.nextElement();
-                                               disassociate(item);
-                                               item.dispose();
+                                       // add at the end of the list
+                                       if (last != null && deletions.contains(last)) {
+                                               // reuse item
+                                               deletions.removeElement(last);
+                                               reuseTreeItem(last, e);
+                                       } else {
+                                               // nothing to reuse
+                                               createTreeItem(w, e, -1);
                                        }
 
-                                       if (doUpdateParent)
-                                               updateItem(w, delta.getElement());
-                                       if (!doUpdateParent && doUpdateParentsPlus && w instanceof Item)
-                                               updatePlus((Item)w, delta.getElement());
+                               } catch (JavaModelException x) {
+                                       // the element to be added is not present -> don't add it
                                }
+                       }
 
+                       // remove items which haven't been reused
+                       Enumeration e = deletions.elements();
+                       while (e.hasMoreElements()) {
+                               item = (Item) e.nextElement();
+                               disassociate(item);
+                               item.dispose();
+                       }
 
+                       if (doUpdateParent)
+                               updateItem(w, delta.getElement());
+                       if (!doUpdateParent && doUpdateParentsPlus && w instanceof Item)
+                               updatePlus((Item) w, delta.getElement());
+               }
 
-                               /*
-                                * @see ContentViewer#handleLabelProviderChanged(LabelProviderChangedEvent)
-                                */
-                               protected void handleLabelProviderChanged(LabelProviderChangedEvent event) {
-                                       Object input= getInput();
-                                       if (event instanceof ProblemsLabelChangedEvent) {
-                                               ProblemsLabelChangedEvent e= (ProblemsLabelChangedEvent) event;
-                                               if (e.isMarkerChange() && input instanceof ICompilationUnit) {
-                                                       return; // marker changes can be ignored
-                                               }
-                                       }
-                                       // look if the underlying resource changed
-                                       Object[] changed= event.getElements();
-                                       if (changed != null) {
-                                               IResource resource= getUnderlyingResource();
-                                               if (resource != null) {
-                                                       for (int i= 0; i < changed.length; i++) {
-                                                               if (changed[i] != null && changed[i].equals(resource)) {
-                                                                       // change event to a full refresh
-                                                                       event= new LabelProviderChangedEvent((IBaseLabelProvider) event.getSource());
-                                                                       break;
-                                                               }
-                                                       }
-                                               }
-                                       }
-                                       super.handleLabelProviderChanged(event);
+               /*
+                * @see ContentViewer#handleLabelProviderChanged(LabelProviderChangedEvent)
+                */
+               protected void handleLabelProviderChanged(
+                               LabelProviderChangedEvent event) {
+                       Object input = getInput();
+                       if (event instanceof ProblemsLabelChangedEvent) {
+                               ProblemsLabelChangedEvent e = (ProblemsLabelChangedEvent) event;
+                               if (e.isMarkerChange() && input instanceof ICompilationUnit) {
+                                       return; // marker changes can be ignored
                                }
-
-                               private IResource getUnderlyingResource() {
-                                       Object input= getInput();
-                                       if (input instanceof ICompilationUnit) {
-                                               ICompilationUnit cu= (ICompilationUnit) input;
-                                               cu= JavaModelUtil.toOriginal(cu);
-                                               return cu.getResource();
+                       }
+                       // look if the underlying resource changed
+                       Object[] changed = event.getElements();
+                       if (changed != null) {
+                               IResource resource = getUnderlyingResource();
+                               if (resource != null) {
+                                       for (int i = 0; i < changed.length; i++) {
+                                               if (changed[i] != null && changed[i].equals(resource)) {
+                                                       // change event to a full refresh
+                                                       event = new LabelProviderChangedEvent(
+                                                                       (IBaseLabelProvider) event.getSource());
+                                                       break;
+                                               }
                                        }
-//                                     else if (input instanceof IClassFile) {
-//                                             return ((IClassFile) input).getResource();
-//                                     }
-                                       return null;
                                }
-
-
                        }
+                       super.handleLabelProviderChanged(event);
+               }
 
-                       class LexicalSortingAction extends Action {
-
-                               private JavaElementSorter fSorter= new JavaElementSorter();
+               private IResource getUnderlyingResource() {
+                       Object input = getInput();
+                       if (input instanceof ICompilationUnit) {
+                               ICompilationUnit cu = (ICompilationUnit) input;
+                               cu = JavaModelUtil.toOriginal(cu);
+                               return cu.getResource();
+                       }
+                       // else if (input instanceof IClassFile) {
+                       // return ((IClassFile) input).getResource();
+                       // }
+                       return null;
+               }
 
-                               public LexicalSortingAction() {
-                                       super();
-                                       PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LEXICAL_SORTING_OUTLINE_ACTION);
-                                       setText(PHPEditorMessages.getString("JavaOutlinePage.Sort.label")); //$NON-NLS-1$
-                                       PHPUiImages.setLocalImageDescriptors(this, "alphab_sort_co.gif"); //$NON-NLS-1$
-                                       setToolTipText(PHPEditorMessages.getString("JavaOutlinePage.Sort.tooltip")); //$NON-NLS-1$
-                                       setDescription(PHPEditorMessages.getString("JavaOutlinePage.Sort.description")); //$NON-NLS-1$
+       }
 
-                                       boolean checked= PHPeclipsePlugin.getDefault().getPreferenceStore().getBoolean("LexicalSortingAction.isChecked"); //$NON-NLS-1$
-                                       valueChanged(checked, false);
-                               }
+       class LexicalSortingAction extends Action {
+
+               private JavaElementSorter fSorter = new JavaElementSorter();
+
+               public LexicalSortingAction() {
+                       super();
+                       PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
+                                       IJavaHelpContextIds.LEXICAL_SORTING_OUTLINE_ACTION);
+                       setText(PHPEditorMessages.getString("JavaOutlinePage.Sort.label")); //$NON-NLS-1$
+                       PHPUiImages.setLocalImageDescriptors(this, "alphab_sort_co.gif"); //$NON-NLS-1$
+                       setToolTipText(PHPEditorMessages
+                                       .getString("JavaOutlinePage.Sort.tooltip")); //$NON-NLS-1$
+                       setDescription(PHPEditorMessages
+                                       .getString("JavaOutlinePage.Sort.description")); //$NON-NLS-1$
+
+                       boolean checked = PHPeclipsePlugin.getDefault()
+                                       .getPreferenceStore().getBoolean(
+                                                       "LexicalSortingAction.isChecked"); //$NON-NLS-1$
+                       valueChanged(checked, false);
+               }
 
-                               public void run() {
-                                       valueChanged(isChecked(), true);
-                               }
+               public void run() {
+                       valueChanged(isChecked(), true);
+               }
 
-                               private void valueChanged(final boolean on, boolean store) {
-                                       setChecked(on);
-                                       BusyIndicator.showWhile(fOutlineViewer.getControl().getDisplay(), new Runnable() {
+               private void valueChanged(final boolean on, boolean store) {
+                       setChecked(on);
+                       BusyIndicator.showWhile(fOutlineViewer.getControl().getDisplay(),
+                                       new Runnable() {
                                                public void run() {
-                                                       fOutlineViewer.setSorter(on ? fSorter : null);                                          }
+                                                       fOutlineViewer.setSorter(on ? fSorter : null);
+                                               }
                                        });
 
-                                       if (store)
-                                               PHPeclipsePlugin.getDefault().getPreferenceStore().setValue("LexicalSortingAction.isChecked", on); //$NON-NLS-1$
-                               }
-                       }
+                       if (store)
+                               PHPeclipsePlugin.getDefault().getPreferenceStore().setValue(
+                                               "LexicalSortingAction.isChecked", on); //$NON-NLS-1$
+               }
+       }
 
-               class ClassOnlyAction extends Action {
+       class ClassOnlyAction extends Action {
+
+               public ClassOnlyAction() {
+                       super();
+                       PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
+                                       IJavaHelpContextIds.GO_INTO_TOP_LEVEL_TYPE_ACTION);
+                       setText(PHPEditorMessages
+                                       .getString("JavaOutlinePage.GoIntoTopLevelType.label")); //$NON-NLS-1$
+                       setToolTipText(PHPEditorMessages
+                                       .getString("JavaOutlinePage.GoIntoTopLevelType.tooltip")); //$NON-NLS-1$
+                       setDescription(PHPEditorMessages
+                                       .getString("JavaOutlinePage.GoIntoTopLevelType.description")); //$NON-NLS-1$
+                       PHPUiImages.setLocalImageDescriptors(this,
+                                       "gointo_toplevel_type.gif"); //$NON-NLS-1$
+
+                       IPreferenceStore preferenceStore = PHPeclipsePlugin.getDefault()
+                                       .getPreferenceStore();
+                       boolean showclass = preferenceStore
+                                       .getBoolean("GoIntoTopLevelTypeAction.isChecked"); //$NON-NLS-1$
+                       setTopLevelTypeOnly(showclass);
+               }
 
-                       public ClassOnlyAction() {
-                               super();
-                               PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GO_INTO_TOP_LEVEL_TYPE_ACTION);
-                               setText(PHPEditorMessages.getString("JavaOutlinePage.GoIntoTopLevelType.label")); //$NON-NLS-1$
-                               setToolTipText(PHPEditorMessages.getString("JavaOutlinePage.GoIntoTopLevelType.tooltip")); //$NON-NLS-1$
-                               setDescription(PHPEditorMessages.getString("JavaOutlinePage.GoIntoTopLevelType.description")); //$NON-NLS-1$
-                               PHPUiImages.setLocalImageDescriptors(this, "gointo_toplevel_type.gif"); //$NON-NLS-1$
+               /*
+                * @see org.eclipse.jface.action.Action#run()
+                */
+               public void run() {
+                       setTopLevelTypeOnly(!fTopLevelTypeOnly);
+               }
 
-                               IPreferenceStore preferenceStore= PHPeclipsePlugin.getDefault().getPreferenceStore();
-                               boolean showclass= preferenceStore.getBoolean("GoIntoTopLevelTypeAction.isChecked"); //$NON-NLS-1$
-                               setTopLevelTypeOnly(showclass);
-                       }
+               private void setTopLevelTypeOnly(boolean show) {
+                       fTopLevelTypeOnly = show;
+                       setChecked(show);
+                       fOutlineViewer.refresh(false);
 
-                       /*
-                        * @see org.eclipse.jface.action.Action#run()
-                        */
-                       public void run() {
-                               setTopLevelTypeOnly(!fTopLevelTypeOnly);
-                       }
+                       IPreferenceStore preferenceStore = PHPeclipsePlugin.getDefault()
+                                       .getPreferenceStore();
+                       preferenceStore
+                                       .setValue("GoIntoTopLevelTypeAction.isChecked", show); //$NON-NLS-1$
+               }
+       }
 
-                       private void setTopLevelTypeOnly(boolean show) {
-                               fTopLevelTypeOnly= show;
-                               setChecked(show);
-                               fOutlineViewer.refresh(false);
+       /**
+        * This action toggles whether this Java Outline page links its selection to
+        * the active editor.
+        * 
+        * @since 3.0
+        */
+       public class ToggleLinkingAction extends AbstractToggleLinkingAction {
 
-                               IPreferenceStore preferenceStore= PHPeclipsePlugin.getDefault().getPreferenceStore();
-                               preferenceStore.setValue("GoIntoTopLevelTypeAction.isChecked", show); //$NON-NLS-1$
-                       }
-               }
+               JavaOutlinePage fJavaOutlinePage;
 
                /**
-                * This action toggles whether this Java Outline page links
-                * its selection to the active editor.
-                *
-                * @since 3.0
+                * Constructs a new action.
+                * 
+                * @param outlinePage
+                *            the Java outline page
                 */
-               public class ToggleLinkingAction extends AbstractToggleLinkingAction {
-
-                       JavaOutlinePage fJavaOutlinePage;
-
-                       /**
-                        * Constructs a new action.
-                        *
-                        * @param outlinePage the Java outline page
-                        */
-                       public ToggleLinkingAction(JavaOutlinePage outlinePage) {
-                               boolean isLinkingEnabled= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);
-                               setChecked(isLinkingEnabled);
-                               fJavaOutlinePage= outlinePage;
-                       }
-
-                       /**
-                        * Runs the action.
-                        */
-                       public void run() {
-                               PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE, isChecked());
-                               if (isChecked() && fEditor != null)
-                                       fEditor.synchronizeOutlinePage(fEditor.computeHighlightRangeSourceReference(), false);
-                       }
+               public ToggleLinkingAction(JavaOutlinePage outlinePage) {
+                       boolean isLinkingEnabled = PreferenceConstants
+                                       .getPreferenceStore()
+                                       .getBoolean(
+                                                       PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);
+                       setChecked(isLinkingEnabled);
+                       fJavaOutlinePage = outlinePage;
+               }
 
+               /**
+                * Runs the action.
+                */
+               public void run() {
+                       PreferenceConstants.getPreferenceStore().setValue(
+                                       PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE,
+                                       isChecked());
+                       if (isChecked() && fEditor != null)
+                               fEditor.synchronizeOutlinePage(fEditor
+                                               .computeHighlightRangeSourceReference(), false);
                }
 
+       }
 
        /** A flag to show contents of top level type only */
        private boolean fTopLevelTypeOnly;
 
        private IJavaElement fInput;
+
        private String fContextMenuID;
+
        private Menu fMenu;
+
        private JavaOutlineViewer fOutlineViewer;
+
        private PHPEditor fEditor;
 
        private MemberFilterActionGroup fMemberFilterActionGroup;
 
-       private ListenerList fSelectionChangedListeners= new ListenerList();
-       private ListenerList fPostSelectionChangedListeners= new ListenerList();
-       private Hashtable fActions= new Hashtable();
+       private ListenerList fSelectionChangedListeners = new ListenerList();
+
+       private ListenerList fPostSelectionChangedListeners = new ListenerList();
+
+       private Hashtable fActions = new Hashtable();
 
        private TogglePresentationAction fTogglePresentation;
+
        private GotoAnnotationAction fPreviousAnnotation;
+
        private GotoAnnotationAction fNextAnnotation;
+
        private TextEditorAction fShowJavadoc;
+
        private IAction fUndo;
+
        private IAction fRedo;
 
        private ToggleLinkingAction fToggleLinkingAction;
@@ -864,8 +915,10 @@ public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdapt
        private CompositeActionGroup fActionGroups;
 
        private IPropertyChangeListener fPropertyChangeListener;
+
        /**
         * Custom filter action group.
+        * 
         * @since 3.0
         */
        private CustomFiltersActionGroup fCustomFiltersActionGroup;
@@ -875,66 +928,69 @@ public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdapt
 
                Assert.isNotNull(editor);
 
-               fContextMenuID= contextMenuID;
-               fEditor= editor;
-               fTogglePresentation= new TogglePresentationAction();
-               fPreviousAnnotation= new GotoAnnotationAction("PreviousAnnotation.", false); //$NON-NLS-1$
-               fNextAnnotation= new GotoAnnotationAction("NextAnnotation.", true); //$NON-NLS-1$
-               fShowJavadoc= (TextEditorAction) fEditor.getAction("ShowJavaDoc"); //$NON-NLS-1$
-               fUndo= fEditor.getAction(ITextEditorActionConstants.UNDO);
-               fRedo= fEditor.getAction(ITextEditorActionConstants.REDO);
+               fContextMenuID = contextMenuID;
+               fEditor = editor;
+               fTogglePresentation = new TogglePresentationAction();
+               fPreviousAnnotation = new GotoAnnotationAction(
+                               "PreviousAnnotation.", false); //$NON-NLS-1$
+               fNextAnnotation = new GotoAnnotationAction("NextAnnotation.", true); //$NON-NLS-1$
+               fShowJavadoc = (TextEditorAction) fEditor.getAction("ShowJavaDoc"); //$NON-NLS-1$
+               fUndo = fEditor.getAction(ITextEditorActionConstants.UNDO);
+               fRedo = fEditor.getAction(ITextEditorActionConstants.REDO);
 
                fTogglePresentation.setEditor(editor);
                fPreviousAnnotation.setEditor(editor);
                fNextAnnotation.setEditor(editor);
 
-               fPropertyChangeListener= new IPropertyChangeListener() {
+               fPropertyChangeListener = new IPropertyChangeListener() {
                        public void propertyChange(PropertyChangeEvent event) {
                                doPropertyChange(event);
                        }
                };
-               PHPeclipsePlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
+               PHPeclipsePlugin.getDefault().getPreferenceStore()
+                               .addPropertyChangeListener(fPropertyChangeListener);
        }
 
        /**
-        * Returns the primary type of a compilation unit (has the same
-        * name as the compilation unit).
-        *
-        * @param compilationUnit the compilation unit
+        * Returns the primary type of a compilation unit (has the same name as the
+        * compilation unit).
+        * 
+        * @param compilationUnit
+        *            the compilation unit
         * @return returns the primary type of the compilation unit, or
-        * <code>null</code> if is does not have one
+        *         <code>null</code> if is does not have one
         */
        protected IType getMainType(ICompilationUnit compilationUnit) {
 
                if (compilationUnit == null)
                        return null;
 
-               String name= compilationUnit.getElementName();
-               int index= name.indexOf('.');
+               String name = compilationUnit.getElementName();
+               int index = name.indexOf('.');
                if (index != -1)
-                       name= name.substring(0, index);
-               IType type= compilationUnit.getType(name);
+                       name = name.substring(0, index);
+               IType type = compilationUnit.getType(name);
                return type.exists() ? type : null;
        }
 
        /**
         * Returns the primary type of a class file.
-        *
-        * @param classFile the class file
+        * 
+        * @param classFile
+        *            the class file
         * @return returns the primary type of the class file, or <code>null</code>
-        * if is does not have one
+        *         if is does not have one
         */
-//     protected IType getMainType(IClassFile classFile) {
-//             try {
-//                     IType type= classFile.getType();
-//                     return type != null && type.exists() ? type : null;
-//             } catch (JavaModelException e) {
-//                     return null;
-//             }
-//     }
-
-       /* (non-Javadoc)
-        * Method declared on Page
+       // protected IType getMainType(IClassFile classFile) {
+       // try {
+       // IType type= classFile.getType();
+       // return type != null && type.exists() ? type : null;
+       // } catch (JavaModelException e) {
+       // return null;
+       // }
+       // }
+       /*
+        * (non-Javadoc) Method declared on Page
         */
        public void init(IPageSite pageSite) {
                super.init(pageSite);
@@ -942,7 +998,8 @@ public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdapt
 
        private void doPropertyChange(PropertyChangeEvent event) {
                if (fOutlineViewer != null) {
-                       if (MembersOrderPreferenceCache.isMemberOrderProperty(event.getProperty())) {
+                       if (MembersOrderPreferenceCache.isMemberOrderProperty(event
+                                       .getProperty())) {
                                fOutlineViewer.refresh(false);
                        }
                }
@@ -961,7 +1018,8 @@ public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdapt
        /*
         * @see ISelectionProvider#removeSelectionChangedListener(ISelectionChangedListener)
         */
-       public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+       public void removeSelectionChangedListener(
+                       ISelectionChangedListener listener) {
                if (fOutlineViewer != null)
                        fOutlineViewer.removeSelectionChangedListener(listener);
                else
@@ -988,7 +1046,8 @@ public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdapt
        /*
         * @see org.eclipse.jface.text.IPostSelectionProvider#addPostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
         */
-       public void addPostSelectionChangedListener(ISelectionChangedListener listener) {
+       public void addPostSelectionChangedListener(
+                       ISelectionChangedListener listener) {
                if (fOutlineViewer != null)
                        fOutlineViewer.addPostSelectionChangedListener(listener);
                else
@@ -998,7 +1057,8 @@ public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdapt
        /*
         * @see org.eclipse.jface.text.IPostSelectionProvider#removePostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
         */
-       public void removePostSelectionChangedListener(ISelectionChangedListener listener) {
+       public void removePostSelectionChangedListener(
+                       ISelectionChangedListener listener) {
                if (fOutlineViewer != null)
                        fOutlineViewer.removePostSelectionChangedListener(listener);
                else
@@ -1007,19 +1067,21 @@ public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdapt
 
        private void registerToolbarActions(IActionBars actionBars) {
 
-               IToolBarManager toolBarManager= actionBars.getToolBarManager();
+               IToolBarManager toolBarManager = actionBars.getToolBarManager();
                if (toolBarManager != null) {
                        toolBarManager.add(new LexicalSortingAction());
 
-                       fMemberFilterActionGroup= new MemberFilterActionGroup(fOutlineViewer, "net.sourceforge.phpeclipse.JavaOutlinePage"); //$NON-NLS-1$
+                       fMemberFilterActionGroup = new MemberFilterActionGroup(
+                                       fOutlineViewer,
+                                       "net.sourceforge.phpeclipse.JavaOutlinePage"); //$NON-NLS-1$
                        fMemberFilterActionGroup.contributeToToolBar(toolBarManager);
 
                        fCustomFiltersActionGroup.fillActionBars(actionBars);
 
-                       IMenuManager menu= actionBars.getMenuManager();
+                       IMenuManager menu = actionBars.getMenuManager();
                        menu.add(new Separator("EndFilterGroup")); //$NON-NLS-1$
 
-                       fToggleLinkingAction= new ToggleLinkingAction(this);
+                       fToggleLinkingAction = new ToggleLinkingAction(this);
                        menu.add(new ClassOnlyAction());
                        menu.add(fToggleLinkingAction);
                }
@@ -1030,74 +1092,91 @@ public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdapt
         */
        public void createControl(Composite parent) {
 
-               Tree tree= new Tree(parent, SWT.MULTI);
+               Tree tree = new Tree(parent, SWT.MULTI);
 
-               AppearanceAwareLabelProvider lprovider= new AppearanceAwareLabelProvider(
-                       AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS |  JavaElementLabels.F_APP_TYPE_SIGNATURE,
-                       AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS
-               );
+               AppearanceAwareLabelProvider lprovider = new AppearanceAwareLabelProvider(
+                               AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS
+                                               | JavaElementLabels.F_APP_TYPE_SIGNATURE,
+                               AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS);
 
-               fOutlineViewer= new JavaOutlineViewer(tree);
+               fOutlineViewer = new JavaOutlineViewer(tree);
                initDragAndDrop();
                fOutlineViewer.setContentProvider(new ChildrenProvider());
-               fOutlineViewer.setLabelProvider(new DecoratingJavaLabelProvider(lprovider));
+               fOutlineViewer.setLabelProvider(new DecoratingJavaLabelProvider(
+                               lprovider));
 
-               Object[] listeners= fSelectionChangedListeners.getListeners();
-               for (int i= 0; i < listeners.length; i++) {
+               Object[] listeners = fSelectionChangedListeners.getListeners();
+               for (int i = 0; i < listeners.length; i++) {
                        fSelectionChangedListeners.remove(listeners[i]);
-                       fOutlineViewer.addSelectionChangedListener((ISelectionChangedListener) listeners[i]);
+                       fOutlineViewer
+                                       .addSelectionChangedListener((ISelectionChangedListener) listeners[i]);
                }
 
-               listeners= fPostSelectionChangedListeners.getListeners();
-               for (int i= 0; i < listeners.length; i++) {
+               listeners = fPostSelectionChangedListeners.getListeners();
+               for (int i = 0; i < listeners.length; i++) {
                        fPostSelectionChangedListeners.remove(listeners[i]);
-                       fOutlineViewer.addPostSelectionChangedListener((ISelectionChangedListener) listeners[i]);
+                       fOutlineViewer
+                                       .addPostSelectionChangedListener((ISelectionChangedListener) listeners[i]);
                }
 
-               MenuManager manager= new MenuManager(fContextMenuID, fContextMenuID);
+               MenuManager manager = new MenuManager(fContextMenuID, fContextMenuID);
                manager.setRemoveAllWhenShown(true);
                manager.addMenuListener(new IMenuListener() {
                        public void menuAboutToShow(IMenuManager m) {
                                contextMenuAboutToShow(m);
                        }
                });
-               fMenu= manager.createContextMenu(tree);
+               fMenu = manager.createContextMenu(tree);
                tree.setMenu(fMenu);
 
-               IPageSite site= getSite();
-               site.registerContextMenu(PHPeclipsePlugin.getPluginId() + ".outline", manager, fOutlineViewer); //$NON-NLS-1$
+               IPageSite site = getSite();
+               site
+                               .registerContextMenu(PHPeclipsePlugin.getPluginId()
+                                               + ".outline", manager, fOutlineViewer); //$NON-NLS-1$
                site.setSelectionProvider(fOutlineViewer);
 
-               // we must create the groups after we have set the selection provider to the site
-               fActionGroups= new CompositeActionGroup(new ActionGroup[] {
-//                             new OpenViewActionGroup(this),
-//                             new CCPActionGroup(this),
-                               new GenerateActionGroup(this)});
-//                             new RefactorActionGroup(this),
-//                             new JavaSearchActionGroup(this)});
+               // we must create the groups after we have set the selection provider to
+               // the site
+               fActionGroups = new CompositeActionGroup(new ActionGroup[] {
+               // new OpenViewActionGroup(this),
+                               // new CCPActionGroup(this),
+                               new GenerateActionGroup(this) });
+               // new RefactorActionGroup(this),
+               // new JavaSearchActionGroup(this)});
 
                // register global actions
-               IActionBars bars= site.getActionBars();
+               IActionBars bars = site.getActionBars();
 
                bars.setGlobalActionHandler(ITextEditorActionConstants.UNDO, fUndo);
                bars.setGlobalActionHandler(ITextEditorActionConstants.REDO, fRedo);
-               bars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPreviousAnnotation);
-               bars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fNextAnnotation);
-               bars.setGlobalActionHandler(PHPdtActionConstants.SHOW_JAVA_DOC, fShowJavadoc);
-               bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation);
-               bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, fNextAnnotation);
-               bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, fPreviousAnnotation);
-
+               bars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(),
+                               fPreviousAnnotation);
+               bars
+                               .setGlobalActionHandler(ActionFactory.NEXT.getId(),
+                                               fNextAnnotation);
+               bars.setGlobalActionHandler(PHPdtActionConstants.SHOW_JAVA_DOC,
+                               fShowJavadoc);
+               bars
+                               .setGlobalActionHandler(
+                                               ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY,
+                                               fTogglePresentation);
+               bars.setGlobalActionHandler(
+                               ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION,
+                               fNextAnnotation);
+               bars.setGlobalActionHandler(
+                               ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION,
+                               fPreviousAnnotation);
 
                fActionGroups.fillActionBars(bars);
 
-               IStatusLineManager statusLineManager= bars.getStatusLineManager();
+               IStatusLineManager statusLineManager = bars.getStatusLineManager();
                if (statusLineManager != null) {
-                       StatusBarUpdater updater= new StatusBarUpdater(statusLineManager);
+                       StatusBarUpdater updater = new StatusBarUpdater(statusLineManager);
                        fOutlineViewer.addPostSelectionChangedListener(updater);
                }
                // Custom filter group
-               fCustomFiltersActionGroup= new CustomFiltersActionGroup("net.sourceforge.phpdt.ui.JavaOutlinePage", fOutlineViewer); //$NON-NLS-1$
+               fCustomFiltersActionGroup = new CustomFiltersActionGroup(
+                               "net.sourceforge.phpdt.ui.JavaOutlinePage", fOutlineViewer); //$NON-NLS-1$
 
                registerToolbarActions(bars);
 
@@ -1111,32 +1190,32 @@ public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdapt
 
                if (fMemberFilterActionGroup != null) {
                        fMemberFilterActionGroup.dispose();
-                       fMemberFilterActionGroup= null;
+                       fMemberFilterActionGroup = null;
                }
 
                if (fCustomFiltersActionGroup != null) {
                        fCustomFiltersActionGroup.dispose();
-                       fCustomFiltersActionGroup= null;
+                       fCustomFiltersActionGroup = null;
                }
 
-
                fEditor.outlinePageClosed();
-               fEditor= null;
+               fEditor = null;
 
                fSelectionChangedListeners.clear();
-               fSelectionChangedListeners= null;
+               fSelectionChangedListeners = null;
 
                fPostSelectionChangedListeners.clear();
-               fPostSelectionChangedListeners= null;
+               fPostSelectionChangedListeners = null;
 
                if (fPropertyChangeListener != null) {
-                       PHPeclipsePlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
-                       fPropertyChangeListener= null;
+                       PHPeclipsePlugin.getDefault().getPreferenceStore()
+                                       .removePropertyChangeListener(fPropertyChangeListener);
+                       fPropertyChangeListener = null;
                }
 
                if (fMenu != null && !fMenu.isDisposed()) {
                        fMenu.dispose();
-                       fMenu= null;
+                       fMenu = null;
                }
 
                if (fActionGroups != null)
@@ -1146,7 +1225,7 @@ public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdapt
                fPreviousAnnotation.setEditor(null);
                fNextAnnotation.setEditor(null);
 
-               fOutlineViewer= null;
+               fOutlineViewer = null;
 
                super.dispose();
        }
@@ -1158,7 +1237,7 @@ public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdapt
        }
 
        public void setInput(IJavaElement inputElement) {
-               fInput= inputElement;
+               fInput = inputElement;
                if (fOutlineViewer != null)
                        fOutlineViewer.setInput(fInput);
        }
@@ -1166,12 +1245,13 @@ public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdapt
        public void select(ISourceReference reference) {
                if (fOutlineViewer != null) {
 
-                       ISelection s= fOutlineViewer.getSelection();
+                       ISelection s = fOutlineViewer.getSelection();
                        if (s instanceof IStructuredSelection) {
-                               IStructuredSelection ss= (IStructuredSelection) s;
-                               List elements= ss.toList();
+                               IStructuredSelection ss = (IStructuredSelection) s;
+                               List elements = ss.toList();
                                if (!elements.contains(reference)) {
-                                       s= (reference == null ? StructuredSelection.EMPTY : new StructuredSelection(reference));
+                                       s = (reference == null ? StructuredSelection.EMPTY
+                                                       : new StructuredSelection(reference));
                                        fOutlineViewer.setSelection(s, true);
                                }
                        }
@@ -1214,25 +1294,28 @@ public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdapt
        }
 
        /**
-        * Convenience method to add the action installed under the given actionID to the
-        * specified group of the menu.
-        *
-        * @param menu          the menu manager
-        * @param group         the group to which to add the action
-        * @param actionID      the ID of the new action
+        * Convenience method to add the action installed under the given actionID
+        * to the specified group of the menu.
+        * 
+        * @param menu
+        *            the menu manager
+        * @param group
+        *            the group to which to add the action
+        * @param actionID
+        *            the ID of the new action
         */
        protected void addAction(IMenuManager menu, String group, String actionID) {
-               IAction action= getAction(actionID);
+               IAction action = getAction(actionID);
                if (action != null) {
                        if (action instanceof IUpdate)
                                ((IUpdate) action).update();
 
                        if (action.isEnabled()) {
-                               IMenuManager subMenu= menu.findMenuUsingPath(group);
-                               if (subMenu != null)
-                                       subMenu.add(action);
-                               else
-                                       menu.appendToGroup(group, action);
+                               IMenuManager subMenu = menu.findMenuUsingPath(group);
+                               if (subMenu != null)
+                                       subMenu.add(action);
+                               else
+                                       menu.appendToGroup(group, action);
                        }
                }
        }
@@ -1241,7 +1324,7 @@ public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdapt
 
                PHPeclipsePlugin.createStandardGroups(menu);
 
-               IStructuredSelection selection= (IStructuredSelection)getSelection();
+               IStructuredSelection selection = (IStructuredSelection) getSelection();
                fActionGroups.setContext(new ActionContext(selection));
                fActionGroups.fillContextMenu(menu);
        }
@@ -1256,20 +1339,21 @@ public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdapt
 
        /**
         * Checks whether a given Java element is an inner type.
-        *
-        * @param element the java element
+        * 
+        * @param element
+        *            the java element
         * @return <code>true</code> iff the given element is an inner type
         */
        private boolean isInnerType(IJavaElement element) {
 
                if (element != null && element.getElementType() == IJavaElement.TYPE) {
-                       IType type= (IType)element;
+                       IType type = (IType) element;
                        try {
                                return type.isMember();
                        } catch (JavaModelException e) {
-                               IJavaElement parent= type.getParent();
+                               IJavaElement parent = type.getParent();
                                if (parent != null) {
-                                       int parentElementType= parent.getElementType();
+                                       int parentElementType = parent.getElementType();
                                        return (parentElementType != IJavaElement.COMPILATION_UNIT && parentElementType != IJavaElement.CLASS_FILE);
                                }
                        }
@@ -1280,32 +1364,31 @@ public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdapt
 
        /**
         * Returns the <code>IShowInSource</code> for this view.
-        *
+        * 
         * @return the {@link IShowInSource}
         */
        protected IShowInSource getShowInSource() {
                return new IShowInSource() {
                        public ShowInContext getShowInContext() {
-                               return new ShowInContext(
-                                       null,
-                                       getSite().getSelectionProvider().getSelection());
+                               return new ShowInContext(null, getSite().getSelectionProvider()
+                                               .getSelection());
                        }
                };
        }
 
        /**
         * Returns the <code>IShowInTarget</code> for this view.
-        *
+        * 
         * @return the {@link IShowInTarget}
         */
        protected IShowInTarget getShowInTarget() {
                return new IShowInTarget() {
                        public boolean show(ShowInContext context) {
-                               ISelection sel= context.getSelection();
+                               ISelection sel = context.getSelection();
                                if (sel instanceof ITextSelection) {
-                                       ITextSelection tsel= (ITextSelection) sel;
-                                       int offset= tsel.getOffset();
-                                       IJavaElement element= fEditor.getElementAt(offset);
+                                       ITextSelection tsel = (ITextSelection) sel;
+                                       int offset = tsel.getOffset();
+                                       IJavaElement element = fEditor.getElementAt(offset);
                                        if (element != null) {
                                                setSelection(new StructuredSelection(element));
                                                return true;
@@ -1317,21 +1400,24 @@ public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdapt
        }
 
        private void initDragAndDrop() {
-               int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
-               Transfer[] transfers= new Transfer[] {
-                       LocalSelectionTransfer.getInstance()
-                       };
+               int ops = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
+               Transfer[] transfers = new Transfer[] { LocalSelectionTransfer
+                               .getInstance() };
 
                // Drop Adapter
-//             TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
-//                     new SelectionTransferDropAdapter(fOutlineViewer)
-//             };
-//             fOutlineViewer.addDropSupport(ops | DND.DROP_DEFAULT, transfers, new DelegatingDropAdapter(dropListeners));
+               // TransferDropTargetListener[] dropListeners= new
+               // TransferDropTargetListener[] {
+               // new SelectionTransferDropAdapter(fOutlineViewer)
+               // };
+               // fOutlineViewer.addDropSupport(ops | DND.DROP_DEFAULT, transfers, new
+               // DelegatingDropAdapter(dropListeners));
 
                // Drag Adapter
-//             TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
-//                     new SelectionTransferDragAdapter(fOutlineViewer)
-//             };
-//             fOutlineViewer.addDragSupport(ops, transfers, new JdtViewerDragAdapter(fOutlineViewer, dragListeners));
+               // TransferDragSourceListener[] dragListeners= new
+               // TransferDragSourceListener[] {
+               // new SelectionTransferDragAdapter(fOutlineViewer)
+               // };
+               // fOutlineViewer.addDragSupport(ops, transfers, new
+               // JdtViewerDragAdapter(fOutlineViewer, dragListeners));
        }
 }