[123168] add generic search results view support
diff --git a/bundles/org.eclipse.wst.xsd.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.wst.xsd.ui/META-INF/MANIFEST.MF
index 0864ac0..1bc811e 100644
--- a/bundles/org.eclipse.wst.xsd.ui/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.wst.xsd.ui/META-INF/MANIFEST.MF
@@ -62,6 +62,7 @@
  org.eclipse.wst.validation,
  org.eclipse.ltk.core.refactoring,
  org.eclipse.ltk.ui.refactoring,
- org.eclipse.wst.xsd.core
+ org.eclipse.wst.xsd.core,
+ org.eclipse.search
 Eclipse-AutoStart: true
 Plugin-Class: org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin
diff --git a/bundles/org.eclipse.wst.xsd.ui/plugin.xml b/bundles/org.eclipse.wst.xsd.ui/plugin.xml
index 3c506ac..98791f3 100644
--- a/bundles/org.eclipse.wst.xsd.ui/plugin.xml
+++ b/bundles/org.eclipse.wst.xsd.ui/plugin.xml
@@ -360,18 +360,32 @@
    <extension point="org.eclipse.ui.popupMenus"> 
       <objectContribution 
          id="org.eclipse.wst.xsd.ui.refactoring.menu.objectContrib" 
-         objectClass="org.eclipse.xsd.XSDComponent"> 
+         objectClass="org.eclipse.xsd.XSDComponent">  
+         <action
+            id="org.eclipse.wst.xsd.ui.search.declarations.action" 
+            enablesFor="1"
+            style="pulldown"
+            menubarPath="search-slot"
+            label="Declarations"
+            class="org.eclipse.wst.xsd.ui.internal.search.actions.XSDSearchDeclarationsGroupActionDelegate"> 
+         </action>          
+         <action
+            id="org.eclipse.wst.xsd.ui.search.references.action" 
+            enablesFor="1"
+            style="pulldown"
+            menubarPath="search-slot"
+            label="References"
+            class="org.eclipse.wst.xsd.ui.internal.search.actions.XSDSearchReferencesGroupActionDelegate"> 
+         </action>
          <action
             id="org.eclipse.wst.xsd.ui.refactoring.menu.refactorGroup.object" 
             enablesFor="1"
             style="pulldown"
-            menubarPath="additions"
+            menubarPath="refactoring-slot"
             label="%refactoring.menu.label" 
             class="org.eclipse.wst.xsd.ui.internal.refactor.actions.XSDRefactorGroupActionDelegate"> 
-         </action> 
-      </objectContribution> 
- 
-   
+         </action>          
+      </objectContribution>         
     <viewerContribution
         id="org.eclipse.wst.xsd.ui.refactoring.menu.source"
         targetID="org.eclipse.wst.xsd.core.xsdsource.source.EditorContext">
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/XSDSearchQuery.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/XSDSearchQuery.java
new file mode 100644
index 0000000..f7737ca
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/XSDSearchQuery.java
@@ -0,0 +1,43 @@
+package org.eclipse.wst.xsd.ui.internal.search;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.wst.common.core.search.pattern.QualifiedName;
+import org.eclipse.wst.common.core.search.pattern.SearchPattern;
+import org.eclipse.wst.common.core.search.scope.SearchScope;
+import org.eclipse.wst.common.ui.internal.search.AbstractSearchQuery;
+import org.eclipse.wst.xml.core.internal.search.XMLComponentDeclarationPattern;
+import org.eclipse.wst.xml.core.internal.search.XMLComponentReferencePattern;
+
+public class XSDSearchQuery extends AbstractSearchQuery
+{   
+  public final static int LIMIT_TO_DECLARATIONS = 1;
+  public final static int LIMIT_TO_REFERENCES   = 2;  
+  
+  int fLimitTo = 0;
+  IFile fContextFile;
+  QualifiedName fElementQName;
+  QualifiedName fTypeName;
+  
+  public XSDSearchQuery(String pattern, IFile file, QualifiedName elementQName, QualifiedName typeName, int limitTo, SearchScope scope, String scopeDescription)
+  {
+    super(pattern, scope, scopeDescription);
+    fLimitTo = limitTo;
+    fContextFile = file;
+    fElementQName = elementQName;
+    fTypeName = typeName;
+  }
+
+  protected SearchPattern createSearchPattern(QualifiedName typeName)
+  {
+    if (fLimitTo == LIMIT_TO_DECLARATIONS)
+    {  
+      return new XMLComponentDeclarationPattern(fContextFile, fElementQName, fTypeName);
+    }  
+    else if (fLimitTo == LIMIT_TO_REFERENCES)
+    {
+      return new XMLComponentReferencePattern(fContextFile, fElementQName, fTypeName);
+    }  
+    return null;
+  }
+}
+
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/BaseGroupActionDelegate.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/BaseGroupActionDelegate.java
new file mode 100644
index 0000000..b5b5195
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/BaseGroupActionDelegate.java
@@ -0,0 +1,134 @@
+package org.eclipse.wst.xsd.ui.internal.search.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.IEditorActionDelegate;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+public abstract class BaseGroupActionDelegate implements IObjectActionDelegate, IEditorActionDelegate, IMenuCreator
+{
+    protected ISelection fSelection;
+    private IAction fDelegateAction;
+    // whether to re-fill the menu (reset on selection change)
+    private boolean fFillMenu = true;
+    protected IWorkbenchPart workbenchPart; 
+    
+
+    public BaseGroupActionDelegate() 
+    {
+      System.out.println("Create ActionDelegate " + this.getClass().getName());
+    }
+    
+    /*
+     * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
+     */
+    public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+        workbenchPart = targetPart;
+    }
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.action.IMenuCreator#dispose()
+     */
+    public void dispose() {
+        // nothing to do
+    }
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control)
+     */
+    public Menu getMenu(Control parent) {
+        // never called
+        return null;
+    }
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu)
+     */
+    public Menu getMenu(Menu parent) {
+        //Create the new menu. The menu will get filled when it is about to be shown. see fillMenu(Menu).
+        Menu menu = new Menu(parent);
+        /**
+         * Add listener to repopulate the menu each time
+         * it is shown because MenuManager.update(boolean, boolean) 
+         * doesn't dispose pulldown ActionContribution items for each popup menu.
+         */
+        menu.addMenuListener(new MenuAdapter() {
+            public void menuShown(MenuEvent e) {
+                if (fFillMenu) {
+                    Menu m = (Menu)e.widget;
+                    MenuItem[] items = m.getItems();
+                    for (int i=0; i < items.length; i++) {
+                        items[i].dispose();
+                    }
+                    fillMenu(m);
+                    fFillMenu = false;
+                }
+            }
+        });
+        return menu;
+    }
+
+    /*
+     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+     */
+    public void run(IAction action) {
+        // Never called because we become a menu.
+    }
+    
+    /*
+     * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+     */
+    public void selectionChanged(IAction action, ISelection selection) {
+        fDelegateAction = action;
+        updateWith(selection);
+        
+    }
+
+  public void setActiveEditor(IAction action, IEditorPart targetEditor) {
+        workbenchPart = targetEditor;
+        fDelegateAction = action;
+        if (targetEditor != null && targetEditor.getEditorSite() != null && targetEditor.getEditorSite().getSelectionProvider() != null) {
+            updateWith(targetEditor.getEditorSite().getSelectionProvider().getSelection());
+        }
+        
+    }
+  
+    public void updateWith(ISelection selection) {
+        fSelection = selection;
+        if (fDelegateAction != null) {
+            boolean enable = false;
+            if (selection != null) {
+                if (selection instanceof ITextSelection) {
+                    //if (((ITextSelection) selection).getLength() > 0) {
+                        enable = true;
+                    //}
+                }
+                else if(selection instanceof IStructuredSelection ){
+                    enable = !selection.isEmpty();
+                }
+            }
+            // enable action
+            fDelegateAction.setEnabled(enable);
+            
+            // fill submenu
+            fFillMenu = true;
+            fDelegateAction.setMenuCreator(this);
+            
+            
+        }
+        
+    }
+    
+    
+  protected abstract void fillMenu(Menu menu);
+    
+   
+  
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/CompositeActionGroup.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/CompositeActionGroup.java
new file mode 100644
index 0000000..0bc530a
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/CompositeActionGroup.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+// TODO... open a bugzilla to get the JDT class moved to non internal platform
+package org.eclipse.wst.xsd.ui.internal.search.actions;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.util.Assert;
+
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.actions.ActionGroup;
+
+public class CompositeActionGroup extends ActionGroup {
+
+    private ActionGroup[] fGroups;
+    
+    public CompositeActionGroup() {
+    }
+    
+    public CompositeActionGroup(ActionGroup[] groups) {
+        setGroups(groups);
+    }
+
+    protected void setGroups(ActionGroup[] groups) {
+        Assert.isTrue(fGroups == null);
+        Assert.isNotNull(groups);
+        fGroups= groups;        
+    }
+        
+    public ActionGroup get(int index) {
+        if (fGroups == null)
+            return null;
+        return fGroups[index];
+    }
+    
+    public void addGroup(ActionGroup group) {
+        if (fGroups == null) {
+            fGroups= new ActionGroup[] { group };
+        } else {
+            ActionGroup[] newGroups= new ActionGroup[fGroups.length + 1];
+            System.arraycopy(fGroups, 0, newGroups, 0, fGroups.length);
+            newGroups[fGroups.length]= group;
+            fGroups= newGroups;
+        }
+    }
+    
+    public void dispose() {
+        super.dispose();
+        if (fGroups == null)
+            return;
+        for (int i= 0; i < fGroups.length; i++) {
+            fGroups[i].dispose();
+        }
+    }
+
+    public void fillActionBars(IActionBars actionBars) {
+        super.fillActionBars(actionBars);
+        if (fGroups == null)
+            return;
+        for (int i= 0; i < fGroups.length; i++) {
+            fGroups[i].fillActionBars(actionBars);
+        }
+    }
+
+    public void fillContextMenu(IMenuManager menu) {
+        super.fillContextMenu(menu);
+        if (fGroups == null)
+            return;
+        for (int i= 0; i < fGroups.length; i++) {
+            fGroups[i].fillContextMenu(menu);
+        }
+    }
+
+    public void setContext(ActionContext context) {
+        super.setContext(context);
+        if (fGroups == null)
+            return;
+        for (int i= 0; i < fGroups.length; i++) {
+            fGroups[i].setContext(context);
+        }
+    }
+
+    public void updateActionBars() {
+        super.updateActionBars();
+        if (fGroups == null)
+            return;
+        for (int i= 0; i < fGroups.length; i++) {
+            fGroups[i].updateActionBars();
+        }
+    }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/DeclarationsSearchGroup.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/DeclarationsSearchGroup.java
new file mode 100644
index 0000000..3bb7470
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/DeclarationsSearchGroup.java
@@ -0,0 +1,5 @@
+package org.eclipse.wst.xsd.ui.internal.search.actions;
+
+public class DeclarationsSearchGroup
+{
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/FindAction.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/FindAction.java
new file mode 100644
index 0000000..b4f5111
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/FindAction.java
@@ -0,0 +1,22 @@
+package org.eclipse.wst.xsd.ui.internal.search.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.IEditorPart;
+
+public class FindAction extends Action implements ISelectionChangedListener
+{
+  IEditorPart editor;
+  
+  protected FindAction(IEditorPart editor)
+  {
+    this.editor = editor;
+  }
+  
+  public void selectionChanged(SelectionChangedEvent event)
+  {
+    // TODO Auto-generated method stub
+    
+  }
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/FindReferencesAction.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/FindReferencesAction.java
new file mode 100644
index 0000000..fcc7691
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/FindReferencesAction.java
@@ -0,0 +1,80 @@
+package org.eclipse.wst.xsd.ui.internal.search.actions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.search.ui.NewSearchUI;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.wst.common.core.search.pattern.QualifiedName;
+import org.eclipse.wst.common.core.search.scope.SearchScope;
+import org.eclipse.wst.common.core.search.scope.WorkspaceSearchScope;
+import org.eclipse.wst.xsd.ui.internal.search.IXSDSearchConstants;
+import org.eclipse.wst.xsd.ui.internal.search.XSDSearchQuery;
+import org.eclipse.xsd.XSDComplexTypeDefinition;
+import org.eclipse.xsd.XSDElementDeclaration;
+import org.eclipse.xsd.XSDNamedComponent;
+import org.eclipse.xsd.XSDSimpleTypeDefinition;
+
+public class FindReferencesAction extends FindAction
+{
+  public FindReferencesAction(IEditorPart editor)
+  {   
+    super(editor);
+  }
+  
+  public void setActionDefinitionId(String string)
+  {
+    
+  }
+
+  public void run()
+  {
+    String pattern = "";
+    if (editor != null)
+    {  
+      IEditorInput input = editor.getEditorInput();
+      if (input instanceof IFileEditorInput)
+      {
+        IFileEditorInput fileEditorInput = (IFileEditorInput)input;               
+        IFile file = fileEditorInput.getFile();        
+        ISelectionProvider provider = (ISelectionProvider)editor.getAdapter(ISelectionProvider.class);
+        if (provider != null)
+        {  
+          ISelection selection = provider.getSelection();
+          if (selection != null && selection instanceof IStructuredSelection)
+          {
+            IStructuredSelection s = (IStructuredSelection)selection;
+            Object o = s.getFirstElement();
+            if (o != null && o instanceof XSDNamedComponent)
+            {  
+              XSDNamedComponent c = (XSDNamedComponent)o;
+              QualifiedName metaName = null;
+              if (c instanceof XSDComplexTypeDefinition)
+              {             
+                metaName = IXSDSearchConstants.COMPLEX_TYPE_META_NAME;
+              }
+              else if (c instanceof XSDSimpleTypeDefinition)
+              {
+                metaName = IXSDSearchConstants.SIMPLE_TYPE_META_NAME;
+              }  
+              else if (c instanceof XSDElementDeclaration)
+              {
+               metaName = IXSDSearchConstants.ELEMENT_META_NAME; 
+              }  
+              QualifiedName elementQName = new QualifiedName(c.getTargetNamespace(), c.getName());
+              System.out.println("name" + c.getTargetNamespace() + ":" + c.getName());
+              SearchScope scope = new WorkspaceSearchScope();
+              String scopeDescription = "Workspace";    
+              XSDSearchQuery searchQuery= new XSDSearchQuery(pattern, file, elementQName, metaName, XSDSearchQuery.LIMIT_TO_REFERENCES, scope, scopeDescription);    
+              NewSearchUI.activateSearchResultView();
+              NewSearchUI.runQueryInBackground(searchQuery);
+            }
+          }
+        }
+      }
+    }
+  }     
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/ImplementorsSearchGroup.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/ImplementorsSearchGroup.java
new file mode 100644
index 0000000..07ad996
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/ImplementorsSearchGroup.java
@@ -0,0 +1,5 @@
+package org.eclipse.wst.xsd.ui.internal.search.actions;
+
+public class ImplementorsSearchGroup
+{
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/OccurrencesSearchGroup.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/OccurrencesSearchGroup.java
new file mode 100644
index 0000000..3103ffd
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/OccurrencesSearchGroup.java
@@ -0,0 +1,5 @@
+package org.eclipse.wst.xsd.ui.internal.search.actions;
+
+public class OccurrencesSearchGroup
+{
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/ReferencesSearchGroup.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/ReferencesSearchGroup.java
new file mode 100644
index 0000000..47a6999b
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/ReferencesSearchGroup.java
@@ -0,0 +1,182 @@
+package org.eclipse.wst.xsd.ui.internal.search.actions;
+
+import java.util.List;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+
+/**
+ * Action group that adds the search for references actions to a
+ * context menu and the global menu bar.
+ * 
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ * 
+ * @since 2.0
+ */
+public class ReferencesSearchGroup extends SearchGroup  {
+
+    private static final String MENU_TEXT= "References...";//SearchMessages.group_references; 
+
+    private IWorkbenchSite fSite;
+    private IEditorPart fEditor;
+    private IActionBars fActionBars;
+    
+    private String fGroupId;
+    
+    private FindReferencesAction fFindReferencesAction;
+    private FindReferencesAction fFindReferencesInProjectAction;
+    private FindReferencesAction fFindReferencesInHierarchyAction;
+    private FindReferencesAction fFindReferencesInWorkingSetAction;
+
+
+    /**
+     * Note: This constructor is for internal use only. Clients should not call this constructor.
+     * @param editor
+     */
+    public ReferencesSearchGroup(IEditorPart editor) {
+        Assert.isNotNull(editor);
+        fEditor= editor;
+        fSite= fEditor.getSite();
+        fGroupId= ITextEditorActionConstants.GROUP_FIND;
+
+        fFindReferencesAction= new FindReferencesAction(editor);
+        fFindReferencesAction.setText("Workspace");
+        fFindReferencesAction.setActionDefinitionId("SEARCH_REFERENCES_IN_WORKSPACE");
+        //fEditor.setAction("SearchReferencesInWorkspace", fFindReferencesAction); //$NON-NLS-1$
+
+        fFindReferencesInProjectAction= new FindReferencesAction(fEditor);
+        fFindReferencesInProjectAction.setText("Project");        
+        fFindReferencesInProjectAction.setActionDefinitionId("SEARCH_REFERENCES_IN_PROJECT");
+        //fEditor.setAction("SearchReferencesInProject", fFindReferencesInProjectAction); //$NON-NLS-1$
+
+        fFindReferencesInHierarchyAction= new FindReferencesAction(fEditor);
+        fFindReferencesInHierarchyAction.setText("Hierarchy");          
+        fFindReferencesInHierarchyAction.setActionDefinitionId("SEARCH_REFERENCES_IN_HIERARCHY");
+        //fEditor.setAction("SearchReferencesInHierarchy", fFindReferencesInHierarchyAction); //$NON-NLS-1$
+        
+        fFindReferencesInWorkingSetAction= new FindReferencesAction(fEditor);
+        fFindReferencesInWorkingSetAction.setText("Working Set...");         
+        fFindReferencesInWorkingSetAction.setActionDefinitionId(".SEARCH_REFERENCES_IN_WORKING_SET");
+        //fEditor.setAction("SearchReferencesInWorkingSet", fFindReferencesInWorkingSetAction); //$NON-NLS-1$
+    }
+
+    /*
+    private void registerAction(SelectionDispatchAction action, ISelectionProvider provider, ISelection selection) {
+        action.update(selection);
+        provider.addSelectionChangedListener(action);
+    }*/
+
+    /**
+     * Note: this method is for internal use only. Clients should not call this method.
+     * 
+     * @return the menu label
+     */
+    protected String getName() {
+        return MENU_TEXT;
+    }
+    
+    public void fillActions(List list)
+    {
+      list.add(fFindReferencesAction);
+      list.add(fFindReferencesInHierarchyAction);
+      list.add(fFindReferencesInProjectAction);
+      list.add(new Separator());
+      list.add(fFindReferencesInWorkingSetAction);
+    }
+    
+    /* (non-Javadoc)
+     * Method declared in ActionGroup
+     */
+    public void fillActionBars(IActionBars actionBars) {
+        Assert.isNotNull(actionBars);
+        super.fillActionBars(actionBars);
+        fActionBars= actionBars;
+        updateGlobalActionHandlers();
+    }
+
+    
+    private void addAction(IAction action, IMenuManager manager) {
+        if (action.isEnabled()) {
+            manager.add(action);
+        }
+    }
+
+    /*
+    private void addWorkingSetAction(IWorkingSet[] workingSets, IMenuManager manager) {
+        FindAction action;
+        if (fEditor != null)
+            action= new WorkingSetFindAction(fEditor, new FindReferencesInWorkingSetAction(fEditor, workingSets), SearchUtil.toString(workingSets));
+        else
+            action= new WorkingSetFindAction(fSite, new FindReferencesInWorkingSetAction(fSite, workingSets), SearchUtil.toString(workingSets));
+        action.update(getContext().getSelection());
+        addAction(action, manager);
+    }
+    */
+    
+    /* (non-Javadoc)
+     * Method declared on ActionGroup.
+     */
+    public void fillContextMenu(IMenuManager manager) {
+      /*
+        MenuManager javaSearchMM= new MenuManager(getName(), IContextMenuConstants.GROUP_SEARCH);
+        addAction(fFindReferencesAction, javaSearchMM);
+        addAction(fFindReferencesInProjectAction, javaSearchMM);
+        addAction(fFindReferencesInHierarchyAction, javaSearchMM);
+        
+        javaSearchMM.add(new Separator());
+        
+        Iterator iter= SearchUtil.getLRUWorkingSets().sortedIterator();
+        while (iter.hasNext()) {
+            addWorkingSetAction((IWorkingSet[]) iter.next(), javaSearchMM);
+        }
+        addAction(fFindReferencesInWorkingSetAction, javaSearchMM);
+
+        if (!javaSearchMM.isEmpty())
+            manager.appendToGroup(fGroupId, javaSearchMM);
+        */    
+    }
+    
+    /* 
+     * Overrides method declared in ActionGroup
+     */
+    public void dispose() {
+        ISelectionProvider provider= fSite.getSelectionProvider();
+        if (provider != null) {
+            disposeAction(fFindReferencesAction, provider);
+            disposeAction(fFindReferencesInProjectAction, provider);
+            disposeAction(fFindReferencesInHierarchyAction, provider);
+            disposeAction(fFindReferencesInWorkingSetAction, provider);
+        }
+        fFindReferencesAction= null;
+        fFindReferencesInProjectAction= null;
+        fFindReferencesInHierarchyAction= null;
+        fFindReferencesInWorkingSetAction= null;
+        updateGlobalActionHandlers();
+        super.dispose();
+    }
+
+    private void updateGlobalActionHandlers() {
+      /*
+        if (fActionBars != null) {
+            fActionBars.setGlobalActionHandler(JdtActionConstants.FIND_REFERENCES_IN_WORKSPACE, fFindReferencesAction);
+            fActionBars.setGlobalActionHandler(JdtActionConstants.FIND_REFERENCES_IN_PROJECT, fFindReferencesInProjectAction);
+            fActionBars.setGlobalActionHandler(JdtActionConstants.FIND_REFERENCES_IN_HIERARCHY, fFindReferencesInHierarchyAction);
+            fActionBars.setGlobalActionHandler(JdtActionConstants.FIND_REFERENCES_IN_WORKING_SET, fFindReferencesInWorkingSetAction);
+        }
+        */
+    }
+
+    private void disposeAction(ISelectionChangedListener action, ISelectionProvider provider) {
+        if (action != null)
+            provider.removeSelectionChangedListener(action);
+    }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/SearchGroup.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/SearchGroup.java
new file mode 100644
index 0000000..c7dfaca
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/SearchGroup.java
@@ -0,0 +1,9 @@
+package org.eclipse.wst.xsd.ui.internal.search.actions;
+
+import java.util.List;
+import org.eclipse.ui.actions.ActionGroup;
+
+public abstract class SearchGroup extends ActionGroup
+{
+  public abstract void fillActions(List list);
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/XSDSearchActionGroup.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/XSDSearchActionGroup.java
new file mode 100644
index 0000000..ab8aea6
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/XSDSearchActionGroup.java
@@ -0,0 +1,24 @@
+package org.eclipse.wst.xsd.ui.internal.search.actions;
+
+import org.eclipse.jface.util.Assert;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.actions.ActionGroup;
+
+public class XSDSearchActionGroup extends ActionGroup
+{
+  private ReferencesSearchGroup fReferencesGroup;
+  private DeclarationsSearchGroup fDeclarationsGroup;
+  private ImplementorsSearchGroup fImplementorsGroup;
+  private OccurrencesSearchGroup fOccurrencesGroup;
+  private IEditorPart fEditor;
+
+  public XSDSearchActionGroup(IEditorPart editor)
+  {
+    Assert.isNotNull(editor);
+    fEditor = editor;
+    fReferencesGroup = new ReferencesSearchGroup(editor);
+    fDeclarationsGroup = new DeclarationsSearchGroup();
+    fImplementorsGroup = new ImplementorsSearchGroup();
+    fOccurrencesGroup = new OccurrencesSearchGroup();
+  }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/XSDSearchDeclarationsGroupActionDelegate.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/XSDSearchDeclarationsGroupActionDelegate.java
new file mode 100644
index 0000000..ca83ebf
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/XSDSearchDeclarationsGroupActionDelegate.java
@@ -0,0 +1,18 @@
+package org.eclipse.wst.xsd.ui.internal.search.actions;
+
+import org.eclipse.swt.widgets.Menu;
+
+//org.eclipse.wst.xsd.ui.internal.search.actions.XSDSearchGroupActionDelegate
+public class XSDSearchDeclarationsGroupActionDelegate extends BaseGroupActionDelegate
+{
+    protected void fillMenu(Menu menu) {
+      /*
+        if (fSelection == null) {
+            return;
+        }          
+        XSDSearchActionGroup refactorMenuGroup = new XSDSearchActionGroup(null);
+        XSDSearchGroupSubMenu subMenu = new XSDSearchGroupSubMenu(refactorMenuGroup);
+        subMenu.fill(menu, -1);
+      */          
+    }  
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/XSDSearchGroupSubMenu.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/XSDSearchGroupSubMenu.java
new file mode 100644
index 0000000..e354c79
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/XSDSearchGroupSubMenu.java
@@ -0,0 +1,60 @@
+package org.eclipse.wst.xsd.ui.internal.search.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.ui.actions.CompoundContributionItem;
+
+public class XSDSearchGroupSubMenu extends CompoundContributionItem
+{
+  SearchGroup searchActionGroup;
+
+  public XSDSearchGroupSubMenu(SearchGroup refactorMenuGroup)
+  {
+    super();
+    searchActionGroup = refactorMenuGroup;
+  }
+
+  public XSDSearchGroupSubMenu(String id)
+  {
+    super(id);
+  }
+
+  protected IContributionItem[] getContributionItems()
+  {
+    ArrayList actionsList = new ArrayList();
+    ArrayList contribList = new ArrayList();
+    searchActionGroup.fillActions(actionsList);
+    if (actionsList != null && !actionsList.isEmpty())
+    {
+      for (Iterator iter = actionsList.iterator(); iter.hasNext();)
+      {
+        Object o = iter.next();
+        if (o instanceof IAction)
+        {  
+          IAction action = (IAction)o;
+          contribList.add(new ActionContributionItem(action));
+        }
+        else if (o instanceof Separator)
+        {
+          Separator separator = (Separator)o;
+          contribList.add(separator);
+        }  
+      }
+    }
+    else
+    {
+      Action dummyAction = new Action("XSDSeachActionGroup_no_refactoring_available")
+      {
+        // dummy inner class; no methods
+      };
+      dummyAction.setEnabled(false);
+      contribList.add(new ActionContributionItem(dummyAction));
+    }
+    return (IContributionItem[]) contribList.toArray(new IContributionItem[contribList.size()]);        
+  }
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/XSDSearchReferencesGroupActionDelegate.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/XSDSearchReferencesGroupActionDelegate.java
new file mode 100644
index 0000000..69097c6
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/actions/XSDSearchReferencesGroupActionDelegate.java
@@ -0,0 +1,27 @@
+package org.eclipse.wst.xsd.ui.internal.search.actions;
+
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IEditorPart;
+
+//org.eclipse.wst.xsd.ui.internal.search.actions.XSDSearchGroupActionDelegate
+public class XSDSearchReferencesGroupActionDelegate extends BaseGroupActionDelegate
+{
+    protected void fillMenu(Menu menu) {
+      try
+      {
+        if (fSelection == null) {
+            return;
+        }  
+        if (workbenchPart instanceof IEditorPart)
+        {            
+          ReferencesSearchGroup referencesGroup = new ReferencesSearchGroup((IEditorPart)workbenchPart);
+          XSDSearchGroupSubMenu subMenu = new XSDSearchGroupSubMenu(referencesGroup);
+          subMenu.fill(menu, -1);
+        }  
+      }
+      catch (Exception e)
+      {
+        e.printStackTrace();
+      }
+    }  
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDMenuListener.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDMenuListener.java
index d003bfa..090992a 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDMenuListener.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDMenuListener.java
@@ -150,7 +150,7 @@
     updateXSDSchema();
     if (xsdSchema == null)
     {
-      manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+      manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));    
       return;
     }
     
@@ -324,9 +324,15 @@
     {
       manager.add(deleteAction);
     }
+
+    manager.add(new Separator());       
+    manager.add(new Separator("refactoring_slot")); 
+    manager.add(new Separator());       
+    manager.add(new Separator("search_slot"));       
+    manager.add(new Separator());
     
     // insertion point for popupMenus extension
-    manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));    
+    manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); 
   }
 
   protected String getBuiltInStringQName()