[125668] update find component dialog to utilize search API's
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentFinder.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentFinder.java
index d73adcb..9c1bf72 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentFinder.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentFinder.java
@@ -10,16 +10,7 @@
  *******************************************************************************/
 package org.eclipse.wst.xsd.ui.internal.dialogs.types.xml;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
 
 /**
  * this thing parsers xml artifacts and picks out the specified components attributes
@@ -30,12 +21,8 @@
     public static final int ENTIRE_WORKSPACE_SCOPE = 1;
 
     protected IFile currentIFile;
-	protected List validExtensions;			// List of extensions as String objects
-	protected List excludeFiles;			// List of files (full path) as String objects
 
 	public XMLComponentFinder() {
-		validExtensions = new ArrayList();
-		excludeFiles = new ArrayList();
 	}
     
     /*
@@ -46,69 +33,4 @@
     public void setFile(IFile file) {
         currentIFile = file;
     }
-    
-    public void setValidExtensions(List newExtensions) {
-        validExtensions.clear();
-        validExtensions.addAll(newExtensions);
-    }
-
-    public void addExcludeFiles(List newExclude) {
-        excludeFiles.addAll(newExclude);
-    }
-
-    /*
-     * Returns a List of absolute file locations. For example
-     * "D:\files\....\file.xsd"
-     */
-    protected List getEnclosingProjectFiles() {
-        List files = new ArrayList();
-        
-        if (currentIFile != null) {
-            IProject project = currentIFile.getProject();
-            try {
-                traverseIContainer(project, validExtensions, excludeFiles, files);
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-        
-        return files;
-    }
-
-    protected List getWorkspaceFiles() {
-        List files = new ArrayList();
-        IWorkspaceRoot iwr = ResourcesPlugin.getWorkspace().getRoot();
-        IProject[] projects = iwr.getProjects();
-
-        try {
-            for (int index = 0; index < projects.length; index++) {
-                traverseIContainer(projects[index], validExtensions, excludeFiles, files);
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        return files;
-    }
-
-    /**
-     * Returns a List of absolute file locations. For example
-     * "D:\files\....\file.xsd"
-     */
-    protected void traverseIContainer(IContainer container, List extensions, List excludeFiles, List list) throws Exception {
-        IResource[] children = container.members();
-
-        for (int index = 0; index < children.length; index++) {
-            if (children[index] instanceof IFolder) {
-                traverseIContainer((IFolder) children[index], extensions, excludeFiles, list);
-            } else if (children[index] instanceof IFile) {
-                IFile file = (IFile) children[index];
-                String fileName = file.getLocation().toOSString();
-                String ext = file.getFileExtension();
-                if (extensions.contains(ext) && !excludeFiles.contains(fileName)) {
-                    list.add(file.getLocation());
-                }
-            }
-        }
-    }
 }
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSelectionProvider.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSelectionProvider.java
index aef0a01..5e6bd78 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSelectionProvider.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSelectionProvider.java
@@ -19,6 +19,7 @@
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.wst.common.core.search.pattern.QualifiedName;
 import org.eclipse.wst.xsd.ui.internal.dialogs.types.common.IComponentList;
 import org.eclipse.wst.xsd.ui.internal.dialogs.types.common.IComponentSelectionProvider;
 
@@ -52,8 +53,8 @@
             if (treeObject.getName().equals(dataItem.getAttributeInfo("name"))) {
                 // If the existing data item and the new data item have the same names
                 if (treeObject.getXMLComponentSpecification().size() > 0) {
-                    String existingPath = ((XMLComponentSpecification) treeObject.getXMLComponentSpecification().get(0)).getTagPath();
-                    if (existingPath.equals(dataItem.getTagPath())) {
+                    QualifiedName metaName = ((XMLComponentSpecification) treeObject.getXMLComponentSpecification().get(0)).getMetaName();
+                    if (metaName.equals(dataItem.getMetaName())) {
                         // If they are the same 'type' of items (according to the path value)
                         containingTreeObject = treeObject;
                         foundMatch = true;
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSpecification.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSpecification.java
index 04c2546..321a5a3 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSpecification.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSpecification.java
@@ -11,19 +11,21 @@
 package org.eclipse.wst.xsd.ui.internal.dialogs.types.xml;
 
 import java.util.Hashtable;
+import org.eclipse.wst.common.core.search.pattern.QualifiedName;
 
 /*
  * Simple class which keeps track of attribute information.
  * This class is basically a Hashtable with convenience methods.
  */
 public class XMLComponentSpecification {
-    String tagPath;
+  
+    QualifiedName metaName;    
     Hashtable hashtable;
     String targetNamespace;
     String fileLocation;
     
-    public XMLComponentSpecification(String path) {
-        this.tagPath = path;
+    public XMLComponentSpecification(QualifiedName metaName) {
+        this.metaName = metaName;
         hashtable = new Hashtable();
     }
     
@@ -35,8 +37,8 @@
         return hashtable.get(attribute);
     }
     
-    public String getTagPath() {
-        return tagPath;
+    public QualifiedName getMetaName() {
+        return metaName;
     }
     
     public String getTargetNamespace() {
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLQuickScan.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLQuickScan.java
deleted file mode 100644
index 30409c2..0000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLQuickScan.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.dialogs.types.xml;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- *
- */
-public class XMLQuickScan {
-  
-	/*
-	 * Returns information about matches encountered
-     * based on the criteria provided. 
-	 */
-  public static List getTagInfo(String fullFilePath, List paths, List attributes) {
-    XSDGlobalElementTypeContentHandler handler = new XSDGlobalElementTypeContentHandler();
-    handler.stringTagPaths = paths;
-    handler.searchAttributes = attributes;
-    handler.fileLocation = fullFilePath;
-
-    ClassLoader prevClassLoader = Thread.currentThread().getContextClassLoader();
-    
-    try {
-        IPath path = new Path(fullFilePath);
-    	FileInputStream inputStream = new FileInputStream(new File(path.toOSString()));
-    	
-        
-//      SAXParser  sparser = SAXParserFactory.newInstance().newSAXParser();
-//      XMLReader reader = sparser.getXMLReader();
-        
-        // Line below is a hack to get XMLReader working
-        Thread.currentThread().setContextClassLoader(XMLQuickScan.class.getClassLoader());
-        
-    	XMLReader reader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
-    	reader.setContentHandler(handler);
-    	reader.parse(new InputSource(inputStream));
-    }
-    catch (Exception e) {
-    	e.printStackTrace();
-    }
-    finally {
-      Thread.currentThread().setContextClassLoader(prevClassLoader);
-    }
-    return handler.getSearchAttributeValues();
-  }
-  
-  public static class XSDGlobalElementTypeContentHandler extends DefaultHandler {
-  	protected List stringTagPaths;
-  	protected List searchAttributes;
-  	private List matchingTags = new ArrayList();
-  	private String targetNamespace = "";
-  	private String fileLocation;
-
-  	StringBuffer currentPath = new StringBuffer();
-  	
-    public void startElement(String uri, String localName, String qName, Attributes attributes)  throws SAXException {
-    	currentPath.append("/" + localName);
-    	
-    	// Search for targetNamespace if we haven't encountered it yet.
-    	if (targetNamespace.equals("")) {
-	        int nAttributes = attributes.getLength();
-	        for (int i = 0; i < nAttributes; i++)
-	        {
-	          if (attributes.getLocalName(i).equals("targetNamespace"))
-	          {
-	            targetNamespace = attributes.getValue(i);
-	            break;
-	          }
-	        }
-    	}
-    	
-    	// Search for the path
-    	for (int index = 0; index < stringTagPaths.size(); index++) {
-    		String path = (String) stringTagPaths.get(index);
-    		if (currentPath.length() == path.length() && currentPath.toString().equals(path)) {
-    			// Found a path match
-    			createTagInfo(attributes, (String[]) searchAttributes.get(index));
-    		}
-    	}
-    }
-    
-    public void endElement(String uri, String localName, String qName) throws SAXException {
-    	int slashIndex = currentPath.lastIndexOf("/");
-    	currentPath.delete(slashIndex, currentPath.length());
-    }
-    
-    /*
-     * Information about a tag is stored in a TagInfo class.
-     */
-    private void createTagInfo(Attributes attributes, String[] attributesToSearch) {
-    	XMLComponentSpecification spec = new XMLComponentSpecification(currentPath.toString());
-    	
-//    	tagInfo.addAttributeInfo("name", attributes.getValue("name"));
-    	for (int index = 0; index < attributesToSearch.length; index++) {
-    		String attrString = (String) attributesToSearch[index];
-    		String value = attributes.getValue(attrString);
-    		if (value != null) {
-    			spec.addAttributeInfo(attrString, value);
-    		}
-    	}
-    	spec.setTargetNamespace(targetNamespace);
-    	spec.setFileLocation(fileLocation);
-    	matchingTags.add(spec);
-    }
-        
-    public List getSearchAttributeValues() {
-    	return matchingTags;
-    }
-  }
-}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentFinder.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentFinder.java
index 7f9fc7d..e52e53d 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentFinder.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentFinder.java
@@ -13,58 +13,83 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-
-import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.wst.common.core.search.SearchEngine;
+import org.eclipse.wst.common.core.search.SearchMatch;
+import org.eclipse.wst.common.core.search.SearchParticipant;
+import org.eclipse.wst.common.core.search.SearchPlugin;
+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.ProjectSearchScope;
+import org.eclipse.wst.common.core.search.scope.SearchScope;
+import org.eclipse.wst.common.core.search.scope.WorkspaceSearchScope;
+import org.eclipse.wst.common.core.search.util.CollectingSearchRequestor;
+import org.eclipse.wst.xml.core.internal.search.XMLComponentDeclarationPattern;
 import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentFinder;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLQuickScan;
+import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentSpecification;
+import org.eclipse.wst.xsd.ui.internal.search.IXSDSearchConstants;
 
 public class XSDComponentFinder extends XMLComponentFinder {    
     public XSDComponentFinder() {
-        validExtensions.add("xsd");
+    }
+    
+    protected void findTypes(SearchEngine searchEngine, List list, int scope, QualifiedName metaName)
+    {      
+      SearchScope searchScope = new WorkspaceSearchScope();
+      if (scope == ENCLOSING_PROJECT_SCOPE)
+      {
+        searchScope = new ProjectSearchScope(currentIFile.getProject().getLocation());
+      }       
+      try {
+          CollectingSearchRequestor requestor = new CollectingSearchRequestor();
+          
+          XMLComponentDeclarationPattern pattern = new XMLComponentDeclarationPattern(new QualifiedName("*", "*"), metaName, SearchPattern.R_PATTERN_MATCH);
+          SearchParticipant particpant = SearchPlugin.getDefault().getSearchParticipant("org.eclipse.wst.xsd.search.XSDSearchParticipant");
+          
+          // for now we assume that we only want to include the xsd related participant
+          // that way we don't get SearchMatches for things withing WSDL files
+          // TODO... rethink this... since folks should be capable of changing the 'xsd' search participant impl
+          // without killing this logic
+          SearchParticipant[] participants = { particpant };          
+          searchEngine.search(pattern, requestor, participants, searchScope, new NullProgressMonitor());
+          
+          for (Iterator i = requestor.getResults().iterator(); i.hasNext(); )
+          {
+            SearchMatch match = (SearchMatch)i.next();
+            XMLComponentSpecification spec = new XMLComponentSpecification(metaName);
+            spec.setFileLocation(match.getFile().getLocation().toString());
+            Object o = match.map.get("name");
+            if (o != null && o instanceof QualifiedName)
+            {  
+              QualifiedName qualifiedName = (QualifiedName)o;
+              if (qualifiedName.getLocalName() != null)
+              {  
+                spec.addAttributeInfo("name", qualifiedName.getLocalName());
+                spec.setTargetNamespace(qualifiedName.getNamespace());
+                list.add(spec);
+              }  
+            }  
+          }  
+      } catch (CoreException e) {
+        e.printStackTrace();
+          //status.add(e.getStatus());
+      }      
     }
     
     public List getWorkbenchResourceComponents(int scope) {
-        List components = new ArrayList();
-        List filePaths = new ArrayList();
-        
-        // We don't want to search through the current file we're working on.
-        if (currentIFile != null) {
-            excludeFiles.add(currentIFile.getLocation().toOSString());
-        }
-        
-        // Find files matching the search criteria specified in List extensions and
-        // List excludeFiles.
-        switch (scope) {
-        case ENCLOSING_PROJECT_SCOPE:
-            filePaths = getEnclosingProjectFiles();
-            break;
-            
-        case ENTIRE_WORKSPACE_SCOPE:
-            filePaths = getWorkspaceFiles();
-            break;
-            
-        default:            
-            break;
-        }
-        
-        // Search for the components in each of the files specified in the path.
-        List paths = new ArrayList();
-        paths.add("/schema/complexType");
-        paths.add("/schema/simpleType");
-        
-        List attributes = new ArrayList();
-        String[] nameAttr = new String[1];
-        nameAttr[0] = "name";
-        attributes.add(nameAttr);
-        attributes.add(nameAttr);
-
-        Iterator pathsIterator = filePaths.iterator();
-        while (pathsIterator.hasNext()) {
-//           String stringPath = ((Path) pathsIterator.next()).toOSString();
-           String stringPath = ((Path) pathsIterator.next()).toString();
-           components.addAll(XMLQuickScan.getTagInfo(stringPath, paths, attributes));
-        }
-        
-        return components;
+      // TODO... by making this method return a list... we're cutting off any chance provide asynchronous friendly
+      // behaviour where we populate the list and refresh the dialog after every few updates or seconds
+      // returning a list makes this an all or nothing deal
+      //
+      List list = new ArrayList();
+      SearchEngine searchEngine = new SearchEngine();
+      // TODO... we need a way to combine these into a single search!!
+      // we can make this search 2X faster by doing so
+      // either we should combine COMPLEX_TYPE_META_NAME and SIMPLE_TYPE_META_NAME into a single TYPE_META_NAME
+      // or we'll need to introduce a way to 'OR' SearchPatterns ... which may be tricky!
+      findTypes(searchEngine, list, scope, IXSDSearchConstants.COMPLEX_TYPE_META_NAME);
+      findTypes(searchEngine, list, scope, IXSDSearchConstants.SIMPLE_TYPE_META_NAME);    
+      return list;
     }
 }
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentSelectionProvider.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentSelectionProvider.java
index d1936d4..8aa8178 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentSelectionProvider.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentSelectionProvider.java
@@ -22,6 +22,7 @@
 import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentFinder;
 import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentSelectionProvider;
 import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentSpecification;
+import org.eclipse.wst.xsd.ui.internal.search.IXSDSearchConstants;
 import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
 import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
 import org.eclipse.xsd.XSDComplexTypeDefinition;
@@ -118,10 +119,10 @@
         Iterator itemsIterator = comps.iterator();
         while (itemsIterator.hasNext()) {
             XMLComponentSpecification tagItem = (XMLComponentSpecification) itemsIterator.next();
-            if (tagItem.getTagPath().equals("/schema/complexType")) {
+            if (tagItem.getMetaName() == IXSDSearchConstants.COMPLEX_TYPE_META_NAME) {
                 complex.add(tagItem);
             }               
-            else if (tagItem.getTagPath().equals("/schema/simpleType")) {
+            else if (tagItem.getMetaName() == IXSDSearchConstants.SIMPLE_TYPE_META_NAME) {
                 simple.add(tagItem);
             }
         }
@@ -159,7 +160,7 @@
             Object item = it.next();
             String itemString = item.toString();
             
-            XMLComponentSpecification builtInTypeItem = new XMLComponentSpecification("BUILT_IN_SIMPLE_TYPE");
+            XMLComponentSpecification builtInTypeItem = new XMLComponentSpecification(null);
             builtInTypeItem.addAttributeInfo("name", itemString);
             builtInTypeItem.setTargetNamespace(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
 //            String normalizedFile = getNormalizedLocation(schema.getSchemaLocation());
@@ -291,11 +292,11 @@
             if (proceed) {
                 XMLComponentSpecification typeItem =  null;
                 if (showComplexTypes && item instanceof XSDComplexTypeDefinition) {
-                    typeItem = new XMLComponentSpecification("/schema/complexType");
+                    typeItem = new XMLComponentSpecification(IXSDSearchConstants.COMPLEX_TYPE_META_NAME);
                     typeItem.addAttributeInfo("name", ((XSDComplexTypeDefinition) item).getName());
                 }
                 else if (item instanceof XSDSimpleTypeDefinition) {
-                    typeItem = new XMLComponentSpecification("/schema/simpleType");
+                    typeItem = new XMLComponentSpecification(IXSDSearchConstants.SIMPLE_TYPE_META_NAME);
                     typeItem.addAttributeInfo("name", ((XSDSimpleTypeDefinition) item).getName());
                 }
                 
@@ -320,13 +321,13 @@
         public Image getImage(Object element) {
             XMLComponentTreeObject specification = (XMLComponentTreeObject) element;
             XMLComponentSpecification spec = (XMLComponentSpecification) specification.getXMLComponentSpecification().get(0);
-            if (spec.getTagPath().equals("/schema/complexType")) {
+            if (spec.getMetaName() == IXSDSearchConstants.COMPLEX_TYPE_META_NAME) {
                 return XSDEditorPlugin.getXSDImage("icons/XSDComplexType.gif");
             }
-            else if (spec.getTagPath().equals("/schema/simpleType")) {
+            else if (spec.getMetaName() == IXSDSearchConstants.SIMPLE_TYPE_META_NAME) {
                 return XSDEditorPlugin.getXSDImage("icons/XSDSimpleType.gif");
             }
-            else if (spec.getTagPath().equals("BUILT_IN_SIMPLE_TYPE")) {
+            else if (spec.getMetaName() == null) {
                 return XSDEditorPlugin.getXSDImage("icons/XSDSimpleType.gif");
             }
     
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDSetTypeHelper.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDSetTypeHelper.java
index 29946b2..5c45e43 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDSetTypeHelper.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDSetTypeHelper.java
@@ -18,6 +18,7 @@
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.common.core.search.pattern.QualifiedName;
 import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
 import org.eclipse.wst.xsd.ui.internal.actions.CreateElementAction;
 import org.eclipse.wst.xsd.ui.internal.actions.DOMAttribute;
@@ -58,7 +59,7 @@
         }
 
         if (!XSDDOMHelper.inputEquals(element, XSDConstants.UNION_ELEMENT_TAG, false))
-        {
+        {/*
             if (spec != null && spec.getTagPath().equals("**anonymous**"))
             {
               if (spec.getTagPath().equals("ANONYMOUS_SIMPLE_TYPE"))
@@ -78,7 +79,7 @@
               // element.removeAttribute(XSDConstants.TYPE_ATTRIBUTE);
               element.removeAttribute(property);
             }
-            else
+            else*/
             {
               XSDDOMHelper.updateElementToNotAnonymous(element);
               //element.setAttribute(XSDConstants.TYPE_ATTRIBUTE, typeObject.toString());
@@ -91,9 +92,9 @@
         
         // Get the new type --> typeObject
         if (spec != null) {
-            String itemType = spec.getTagPath();
+            QualifiedName metaName = spec.getMetaName();
            
-            if (!itemType.equals("BUILT_IN_SIMPLE_TYPE")) {
+            if (metaName != null) {
                 // Do an actual import if needed
                 XSDParser parser = new XSDParser();
                 parser.parse(spec.getFileLocation());
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AbstractSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AbstractSection.java
index 9f4bd90..d96ec4b 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AbstractSection.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AbstractSection.java
@@ -46,16 +46,16 @@
 import org.eclipse.xsd.XSDSchema;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
-
+//import org.apache.xerces.util.XMLChar;
 
 public class AbstractSection implements ISection, IPropertyChangeListener, Listener, SelectionListener
 {
-	private TabbedPropertySheetWidgetFactory factory;
-	protected IWorkbenchPart part;
-	protected ISelection selection;
-	protected Object input;
+    private TabbedPropertySheetWidgetFactory factory;
+    protected IWorkbenchPart part;
+    protected ISelection selection;
+    protected Object input;
   protected boolean doRefresh = true;
-	XSDSchema xsdSchema;
+    XSDSchema xsdSchema;
   protected boolean isReadOnly = false;
   private IStatusLineManager statusLine;
   protected Composite composite;
@@ -70,7 +70,7 @@
     super();
   }
   
-  public void createControls(Composite parent,	TabbedPropertySheetPage tabbedPropertySheetPage)
+  public void createControls(Composite parent,  TabbedPropertySheetPage tabbedPropertySheetPage)
   {
     createControls(parent, tabbedPropertySheetPage.getWidgetFactory());
   }
@@ -80,7 +80,7 @@
    */
   public void createControls(Composite parent, TabbedPropertySheetWidgetFactory aFactory)
   {
-		this.factory = aFactory;
+        this.factory = aFactory;
     GC gc = new GC(parent);
     Point extent = gc.textExtent("  ...  ");
     rightMarginSpace = extent.x;
@@ -92,10 +92,10 @@
    */
   public void setInput(IWorkbenchPart part, ISelection selection)
   {
-		Assert.isTrue(selection instanceof IStructuredSelection);
-		this.part = part;
-		this.selection = selection;
-		Object input = ((IStructuredSelection)selection).getFirstElement();
+        Assert.isTrue(selection instanceof IStructuredSelection);
+        this.part = part;
+        this.selection = selection;
+        Object input = ((IStructuredSelection)selection).getFirstElement();
     this.input = input;
     
     if (input instanceof XSDConcreteComponent)
@@ -115,7 +115,7 @@
     statusLine = getStatusLine();
     clearErrorMessage();
 
-//		refresh();
+//      refresh();
   }
 
   /* (non-Javadoc)
@@ -176,20 +176,20 @@
     return xsdSchema;
   }
   
-	/**
-	 * Get the widget factory.
-	 * @return the widget factory.
-	 */
-	public TabbedPropertySheetWidgetFactory getWidgetFactory() {
-		return factory;
-	}
+    /**
+     * Get the widget factory.
+     * @return the widget factory.
+     */
+    public TabbedPropertySheetWidgetFactory getWidgetFactory() {
+        return factory;
+    }
 
-	public void propertyChange(PropertyChangeEvent event)
-	{
+    public void propertyChange(PropertyChangeEvent event)
+    {
     refresh();
-	}
+    }
 
-	
+    
   public void doWidgetDefaultSelected(SelectionEvent e)
   {}
   
@@ -409,10 +409,9 @@
     return true;
   }
 
-  // TODO
   protected boolean validatePrefix(String prefix)
   {
-    return true;
+    return true;//XMLChar.isValidNCName(prefix);
   }
 
   
@@ -492,4 +491,4 @@
     return standardLabelWidth;
   }
 
-}
+}
\ No newline at end of file