Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search')
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/IXSDTypesFilter.java25
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDComponentDescriptionProvider.java189
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDElementsSearchListProvider.java49
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDSearchListDialogDelegate.java124
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDSearchListProvider.java234
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDTypesSearchListProvider.java110
6 files changed, 0 insertions, 731 deletions
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/IXSDTypesFilter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/IXSDTypesFilter.java
deleted file mode 100644
index 4e3c62acfb..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/IXSDTypesFilter.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 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.editor.search;
-
-public interface IXSDTypesFilter {
- /**
- * Give me an Object o, if I know it and it should be filtered out, I will
- * return true. Otherwise I'll return false, even if I don't know the object
- * @param o
- * @return
- */
- public boolean shouldFilterOut(Object o);
-
- public void turnOn();
- public void turnOff();
- public boolean isOn();
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDComponentDescriptionProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDComponentDescriptionProvider.java
deleted file mode 100644
index aa9a0342c8..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDComponentDescriptionProvider.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 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.editor.search;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.common.core.search.SearchMatch;
-import org.eclipse.wst.common.core.search.pattern.QualifiedName;
-import org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification;
-import org.eclipse.wst.common.ui.internal.search.dialogs.IComponentDescriptionProvider;
-import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.search.IXSDSearchConstants;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-
-public class XSDComponentDescriptionProvider extends LabelProvider implements IComponentDescriptionProvider
-{
- public boolean isApplicable(Object component)
- {
- // TODO (cs) if this provider is used in a multi language context
- // we'll need to provide some logic here
- return true;
- }
-
- private static final Image SIMPLE_TYPE_IMAGE = XSDEditorPlugin.getXSDImage("icons/XSDSimpleType.gif");
- private static final Image COMPLEX_TYPE_IMAGE = XSDEditorPlugin.getXSDImage("icons/XSDComplexType.gif");
- private static final Image ELEMENT_IMAGE = XSDEditorPlugin.getXSDImage("icons/XSDElement.gif");
- //private final static Image BUILT_IN_TYPE)IMAGE =
-
- public String getQualifier(Object component)
- {
- String result = null;
- if (component instanceof ComponentSpecification)
- {
- result = ((ComponentSpecification)component).getQualifier();
- }
- else if (component instanceof XSDNamedComponent)
- {
- result = ((XSDNamedComponent)component).getTargetNamespace();
- }
- else if (component instanceof SearchMatch)
- {
- QualifiedName qualifiedName = getQualifiedNameForSearchMatch((SearchMatch)component);
- if (qualifiedName != null)
- {
- result = qualifiedName.getNamespace();
- }
- }
- return result;
- }
-
- // TODO... this will be much easier with Hiroshi's proposed SearchMatch changes
- //
- private QualifiedName getQualifiedNameForSearchMatch(SearchMatch match)
- {
- QualifiedName qualifiedName = null;
- Object o = match.map.get("name");
- if (o != null && o instanceof QualifiedName)
- {
- qualifiedName = (QualifiedName)o;
- }
- return qualifiedName;
- }
-
- public String getName(Object component)
- {
- String result = null;
- if (component instanceof ComponentSpecification)
- {
- result = ((ComponentSpecification)component).getName();
- }
- else if (component instanceof XSDNamedComponent)
- {
- result = ((XSDNamedComponent)component).getName();
- }
- else if (component instanceof SearchMatch)
- {
- QualifiedName qualifiedName = getQualifiedNameForSearchMatch((SearchMatch)component);
- if (qualifiedName != null)
- {
- result = qualifiedName.getLocalName();
- }
- }
- return result;
- }
-
- public IFile getFile(Object component)
- {
- IFile result = null;
- if (component instanceof ComponentSpecification)
- {
- result = ((ComponentSpecification)component).getFile();
- }
- else if (component instanceof SearchMatch)
- {
- result = ((SearchMatch)component).getFile();
- }
- else if (component instanceof XSDConcreteComponent)
- {
- XSDConcreteComponent concreteComponent = (XSDConcreteComponent)component;
- XSDSchema schema = concreteComponent.getSchema();
- if (schema != null)
- {
- // TODO (cs) revisit and test more
- //
- String location = schema.getSchemaLocation();
- String platformResource = "platform:/resource";
- if (location != null && location.startsWith(platformResource))
- {
- Path path = new Path(location.substring(platformResource.length()));
- result = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
- }
- }
- }
- return result;
- }
-
- public ILabelProvider getLabelProvider()
- {
- return this;
- }
-
- public String getText(Object element)
- {
- String result = "";
- String name = getName(element);
- if (name != null)
- {
- result += name;
- /*
- String qualifier = getQualifier(element);
- if (qualifier != null)
- {
- result += " - " + qualifier;
- }
- IFile file = getFile(element);
- if (file != null)
- {
- result += " (" + file.getProject().getName() + ")";
- }*/
- }
- return result;
- }
-
- public Image getImage(Object component)
- {
- Image result = null;
- if (component instanceof SearchMatch)
- {
- SearchMatch searchMatch = (SearchMatch)component;
- QualifiedName qualifiedName = (QualifiedName)searchMatch.map.get("metaName");
- if ( qualifiedName != null ){
- if ( qualifiedName.equals(IXSDSearchConstants.SIMPLE_TYPE_META_NAME))
- result = SIMPLE_TYPE_IMAGE;
- else if ( qualifiedName.equals(IXSDSearchConstants.COMPLEX_TYPE_META_NAME))
- result = COMPLEX_TYPE_IMAGE;
- else if ( qualifiedName.equals(IXSDSearchConstants.ELEMENT_META_NAME))
- result = ELEMENT_IMAGE;
- }
- }
- else if (component instanceof XSDComplexTypeDefinition)
- result = COMPLEX_TYPE_IMAGE;
- else if (component instanceof XSDSimpleTypeDefinition)
- result = SIMPLE_TYPE_IMAGE;
- else if (component instanceof XSDElementDeclaration)
- result = ELEMENT_IMAGE;
- return result;
- }
-
- public Image getFileIcon(Object component) {
- return XSDEditorPlugin.getXSDImage("icons/XSDFile.gif");
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDElementsSearchListProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDElementsSearchListProvider.java
deleted file mode 100644
index 337fa15fad..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDElementsSearchListProvider.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.eclipse.wst.xsd.ui.internal.editor.search;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.common.core.search.SearchEngine;
-import org.eclipse.wst.common.core.search.scope.SearchScope;
-import org.eclipse.wst.common.ui.internal.search.dialogs.IComponentList;
-import org.eclipse.wst.xsd.ui.internal.search.IXSDSearchConstants;
-import org.eclipse.xsd.XSDSchema;
-
-public class XSDElementsSearchListProvider extends XSDSearchListProvider
-{
- public XSDElementsSearchListProvider(IFile currentFile, XSDSchema[] schemas)
- {
- super(currentFile, schemas);
- }
-
- public void populateComponentList(IComponentList list, SearchScope scope, IProgressMonitor pm)
- {
- // now we traverse the types already defined within the visible schemas
- // we do this in addition to the component search since this should execute
- // very quickly and there's a good chance the user wants to select a time that's
- // already imported/included
- // TODO (cs) ensure we don't add duplicates when we proceed to use the search list
- //
- List visitedSchemas = new ArrayList();
- for (int i = 0; i < schemas.length; i++)
- {
- XSDSchema schema = schemas[i];
- ComponentCollectingXSDVisitor visitor = new ComponentCollectingXSDVisitor(list, IXSDSearchConstants.ELEMENT_META_NAME);
- visitor.visitSchema(schema, true);
- visitedSchemas.addAll(visitor.getVisitedSchemas());
- }
- // finally we call the search API's to do a potentially slow search
- if (scope != null)
- {
- populateComponentListUsingSearch(list, scope, pm, createFileMap(visitedSchemas));
- }
- }
-
- private void populateComponentListUsingSearch(IComponentList list, SearchScope scope, IProgressMonitor pm, HashMap files)
- {
- SearchEngine searchEngine = new SearchEngine();
- InternalSearchRequestor requestor = new InternalSearchRequestor(list, files);
- findMatches(searchEngine, requestor, scope, IXSDSearchConstants.ELEMENT_META_NAME);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDSearchListDialogDelegate.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDSearchListDialogDelegate.java
deleted file mode 100644
index 8bbc6abee4..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDSearchListDialogDelegate.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 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.editor.search;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.common.core.search.pattern.QualifiedName;
-import org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSearchListDialogConfiguration;
-import org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification;
-import org.eclipse.wst.common.ui.internal.search.dialogs.ScopedComponentSearchListDialog;
-import org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog;
-import org.eclipse.wst.xsd.ui.internal.editor.Messages;
-import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-
-public class XSDSearchListDialogDelegate implements IComponentDialog
-{
- public final static QualifiedName TYPE_META_NAME = new QualifiedName(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "type"); //$NON-NLS-1$
- public final static QualifiedName ELEMENT_META_NAME = new QualifiedName(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "element"); //$NON-NLS-1$
- // protected Object setObject;
- protected ComponentSpecification selection;
- protected IFile currentFile;
- protected XSDSchema[] schemas;
- protected QualifiedName metaName;
- protected boolean showComplexTypes = true;
-
- public XSDSearchListDialogDelegate(QualifiedName metaName, IFile currentFile, XSDSchema[] schemas)
- {
- super();
- this.metaName = metaName;
- this.currentFile = currentFile;
- this.schemas = schemas;
- }
-
- public ComponentSpecification getSelectedComponent()
- {
- return selection;
- }
-
- public void setInitialSelection(ComponentSpecification componentSpecification)
- {
- // TODO Auto-generated method stub
- }
-
- /**
- * Whether to show complex types in the Dialog's List, has no effect if the
- * dialog populates list of elements instead of type
- * @param value
- */
- public void showComplexTypes(boolean value)
- {
- showComplexTypes = value;
- }
-
- public int createAndOpen()
- {
- Shell shell = XSDEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
- int returnValue = Window.CANCEL;
- ScopedComponentSearchListDialog dialog = null;
-
- // TODO (cs) lot's of code is common to both these blocks. Can we re-org it a bit
- // so it's easier to see the difference between how we config for an element vs type?
- if ( metaName == ELEMENT_META_NAME)
- {
- XSDComponentDescriptionProvider descriptionProvider = new XSDComponentDescriptionProvider();
- final XSDElementsSearchListProvider searchListProvider = new XSDElementsSearchListProvider(currentFile, schemas);
- ComponentSearchListDialogConfiguration configuration = new ComponentSearchListDialogConfiguration();
-
- configuration.setDescriptionProvider(descriptionProvider);
- configuration.setSearchListProvider(searchListProvider);
- configuration.setFilterLabelText(Messages._UI_LABEL_NAME_SEARCH_FILTER_TEXT);
- configuration.setListLabelText(Messages._UI_LABEL_ELEMENTS_COLON);
-// configuration.setNewComponentHandler(new NewElementButtonHandler());
- //TODO externalize string
- dialog = new ScopedComponentSearchListDialog(shell, Messages._UI_LABEL_SET_ELEMENT_REFERENCE, configuration);
- }
- else if (metaName == TYPE_META_NAME)
- {
- XSDComponentDescriptionProvider descriptionProvider = new XSDComponentDescriptionProvider();
- final XSDTypesSearchListProvider searchListProvider = new XSDTypesSearchListProvider(currentFile, schemas);
- if (!showComplexTypes)
- searchListProvider.showComplexTypes(false);
-
- ComponentSearchListDialogConfiguration configuration = new ComponentSearchListDialogConfiguration();
- configuration.setDescriptionProvider(descriptionProvider);
- configuration.setSearchListProvider(searchListProvider);
-// configuration.setNewComponentHandler(new NewTypeButtonHandler());
- configuration.setFilterLabelText(Messages._UI_LABEL_NAME_SEARCH_FILTER_TEXT);
- configuration.setListLabelText(Messages._UI_LABEL_TYPES_COLON);
- dialog = new ScopedComponentSearchListDialog(shell, Messages._UI_LABEL_SET_TYPE, configuration); //$NON-NLS-1$
- }
-
- if (dialog != null)
- {
- dialog.setCurrentResource(currentFile);
- dialog.setBlockOnOpen(true);
- dialog.create();
- returnValue = dialog.open();
- if (returnValue == Window.OK)
- {
- selection = dialog.getSelectedComponent();
- }
- }
- return returnValue;
- }
-
-// private IEditorPart getActiveEditor()
-// {
-// IWorkbench workbench = PlatformUI.getWorkbench();
-// IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
-// IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor();
-// return editorPart;
-// }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDSearchListProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDSearchListProvider.java
deleted file mode 100644
index bcb1eb2a94..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDSearchListProvider.java
+++ /dev/null
@@ -1,234 +0,0 @@
-package org.eclipse.wst.xsd.ui.internal.editor.search;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-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.SearchRequestor;
-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.dialogs.IComponentList;
-import org.eclipse.wst.common.ui.internal.search.dialogs.IComponentSearchListProvider;
-import org.eclipse.wst.xml.core.internal.search.XMLComponentDeclarationPattern;
-import org.eclipse.wst.xsd.ui.internal.search.IXSDSearchConstants;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDImport;
-import org.eclipse.xsd.XSDInclude;
-import org.eclipse.xsd.XSDRedefine;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaContent;
-import org.eclipse.xsd.XSDSchemaDirective;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-
-
-public abstract class XSDSearchListProvider implements IComponentSearchListProvider
-{
- protected XSDSchema[] schemas;
- protected IFile currentFile;
- // TODO (cs) remove these and use proper search scopes!
- //
- public static final int ENCLOSING_PROJECT_SCOPE = 0;
- public static final int ENTIRE_WORKSPACE_SCOPE = 1;
-
- public XSDSearchListProvider(IFile currentFile, XSDSchema[] schemas)
- {
- this.schemas = schemas;
- this.currentFile = currentFile;
-
- try
- {
- IProject[] refs = currentFile.getProject().getReferencedProjects();
-
- System.out.println("dependencies:----");
- for (int i=0; i < refs.length; i++)
- {
- System.out.println("dep " + refs[i].getName());
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- }
-
-
- class ComponentCollectingXSDVisitor
- {
- protected List visitedSchemas = new ArrayList();
- IComponentList list;
- QualifiedName searchKind;
-
- ComponentCollectingXSDVisitor(IComponentList list, QualifiedName searchKind)
- {
- this.list = list;
- this.searchKind = searchKind;
- }
-
- public void visitSchema(XSDSchema schema, boolean visitImportedSchema)
- {
- visitedSchemas.add(schema);
- for (Iterator contents = schema.getContents().iterator(); contents.hasNext();)
- {
- XSDSchemaContent content = (XSDSchemaContent) contents.next();
- if (content instanceof XSDSchemaDirective)
- {
- XSDSchemaDirective schemaDirective = (XSDSchemaDirective) content;
- XSDSchema extSchema = schemaDirective.getResolvedSchema();
- if (extSchema != null && !visitedSchemas.contains(extSchema))
- {
- if (schemaDirective instanceof XSDImport && visitImportedSchema)
- {
- visitSchema(extSchema, false);
- }
- else if (schemaDirective instanceof XSDInclude || schemaDirective instanceof XSDRedefine)
- {
- visitSchema(extSchema, false);
- }
- }
- }
- else if (content instanceof XSDElementDeclaration && searchKind == IXSDSearchConstants.ELEMENT_META_NAME)
- {
- list.add(content);
- }
- else if (content instanceof XSDSimpleTypeDefinition && searchKind == IXSDSearchConstants.SIMPLE_TYPE_META_NAME)
- {
- // in this case we only want to show simple types
- list.add(content);
- }
- else if (content instanceof XSDTypeDefinition && searchKind == IXSDSearchConstants.TYPE_META_NAME)
- {
- // in this case we want to show all types
- list.add(content);
- }
- }
- }
-
- public List getVisitedSchemas()
- {
- return visitedSchemas;
- }
- }
-
-
- class InternalSearchRequestor extends SearchRequestor
- {
- IComponentList componentList;
- HashMap files;
-
- InternalSearchRequestor(IComponentList componentList, HashMap files)
- {
- this.componentList = componentList;
- this.files = files;
- }
-
- public void acceptSearchMatch(SearchMatch match) throws CoreException
- {
- // we filter out the matches from the current file since we assume the
- // info derived from our schema models is more update to date
- // (in the event that we haven't saved our latest modifications)
- //
- if (files.get(match.getFile()) == null)
- {
- // TODO... this ugly qualified name stashing will go away soon
- //
- QualifiedName qualifiedName = null;
- Object o = match.map.get("name");
- if (o != null && o instanceof QualifiedName)
- {
- qualifiedName = (QualifiedName)o;
- }
- if (qualifiedName != null && qualifiedName.getLocalName() != null)
- {
- componentList.add(match);
- }
- }
- }
- }
-
- protected void findMatches(SearchEngine searchEngine, SearchRequestor requestor, SearchScope scope, QualifiedName metaName)
- {
- try
- {
- XMLComponentDeclarationPattern pattern = new XMLComponentDeclarationPattern(new QualifiedName("*", "*"), metaName, SearchPattern.R_PATTERN_MATCH);
- // TODO (cs) revist this... we shouldn't be needing to hard-code partipant id's
- // All we're really doing here is trying to avoid finding matches in
- // wsdl's since we don't ever want to import/include a wsdl from a schema!
- // Maybe we should just scope out any file types that aren't xsd's using a
- // custom SearchScope?
- //
- SearchParticipant particpant = SearchPlugin.getDefault().getSearchParticipant("org.eclipse.wst.xsd.search.XSDSearchParticipant");
- Assert.isNotNull(particpant);
- SearchParticipant[] participants = {particpant};
- searchEngine.search(pattern, requestor, participants, scope, null, new NullProgressMonitor());
- }
- catch (CoreException e)
- {
- e.printStackTrace();
- }
- }
-
-
- protected HashMap createFileMap(List visitedSchemas)
- {
- HashMap fileMap = new HashMap();
- for (Iterator i = visitedSchemas.iterator(); i.hasNext(); )
- {
- XSDSchema theSchema = (XSDSchema)i.next();
- String location = theSchema.getSchemaLocation();
- IFile file = computeFile(location);
- if (file != null)
- {
- fileMap.put(file, Boolean.TRUE);
- }
- }
- return fileMap;
- }
-
- private IFile computeFile(String baseLocation)
- {
- IFile file = null;
- if (baseLocation != null)
- {
- String fileScheme = "file:"; //$NON-NLS-1$
- String platformResourceScheme = "platform:/resource";
- if (baseLocation.startsWith(fileScheme))
- {
- baseLocation = baseLocation.substring(fileScheme.length());
- baseLocation = removeLeading(baseLocation, "/");
- IPath path = new Path(baseLocation);
- file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
- }
- else if (baseLocation.startsWith(platformResourceScheme))
- {
- baseLocation = baseLocation.substring(platformResourceScheme.length());
- baseLocation = removeLeading(baseLocation, "/");
- IPath path = new Path(baseLocation);
- file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
- }
- }
- return file;
- }
-
- private String removeLeading(String path, String pattern)
- {
- while (path.startsWith(pattern))
- {
- path = path.substring(pattern.length());
- }
- return path;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDTypesSearchListProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDTypesSearchListProvider.java
deleted file mode 100644
index 9d80faeaab..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDTypesSearchListProvider.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 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.editor.search;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.common.core.search.SearchEngine;
-import org.eclipse.wst.common.core.search.pattern.QualifiedName;
-import org.eclipse.wst.common.core.search.scope.SearchScope;
-import org.eclipse.wst.common.ui.internal.search.dialogs.IComponentList;
-import org.eclipse.wst.xsd.ui.internal.search.IXSDSearchConstants;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.impl.XSDSchemaImpl;
-import org.eclipse.xsd.util.XSDConstants;
-public class XSDTypesSearchListProvider extends XSDSearchListProvider
-{
- protected IXSDTypesFilter builtInFilter;
- /**
- * Determines if we should use the filter This us used to turn the filter on
- * and off
- */
- protected boolean supportFilter = true;
- private boolean showComplexTypes = true;
-
- public XSDTypesSearchListProvider(IFile currentFile, XSDSchema[] schemas)
- {
- super(currentFile, schemas);
- }
-
- public void populateComponentList(IComponentList list, SearchScope scope, IProgressMonitor pm)
- {
- // first we add the 'built in' types
- //
- XSDSchema schemaForSchema = XSDSchemaImpl.getSchemaForSchema(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
- for (Iterator i = schemaForSchema.getSimpleTypeIdMap().values().iterator(); i.hasNext();)
- {
- XSDTypeDefinition td = (XSDTypeDefinition) i.next();
- if (builtInFilter == null || !builtInFilter.shouldFilterOut(td))
- {
- list.add(td);
- }
- }
- // now we traverse the types already defined within the visible schemas
- // we do this in addition to the component search since this should execute
- // very quickly and there's a good chance the user wants to select a time
- // that's
- // already imported/included
- // TODO (cs) ensure we don't add duplicates when we proceed to use the
- // search list
- //
- List visitedSchemas = new ArrayList();
- for (int i = 0; i < schemas.length; i++)
- {
- XSDSchema schema = schemas[i];
- QualifiedName kind = showComplexTypes ? IXSDSearchConstants.TYPE_META_NAME : IXSDSearchConstants.SIMPLE_TYPE_META_NAME;
- ComponentCollectingXSDVisitor visitor = new ComponentCollectingXSDVisitor(list, kind);
- visitor.visitSchema(schema, true);
- visitedSchemas.addAll(visitor.getVisitedSchemas());
- }
- // finally we call the search API's to do a potentially slow search
- //
- if (scope != null)
- {
- populateComponentListUsingSearch(list, scope, pm, createFileMap(visitedSchemas));
- }
- }
-
- private void populateComponentListUsingSearch(IComponentList list, SearchScope scope, IProgressMonitor pm, HashMap files)
- {
- SearchEngine searchEngine = new SearchEngine();
- InternalSearchRequestor requestor = new InternalSearchRequestor(list, files);
- if (showComplexTypes)
- {
- findMatches(searchEngine, requestor, scope, IXSDSearchConstants.COMPLEX_TYPE_META_NAME);
- }
- findMatches(searchEngine, requestor, scope, IXSDSearchConstants.SIMPLE_TYPE_META_NAME);
- }
-
-
- public void _populateComponentListQuick(IComponentList list, IProgressMonitor pm)
- {
- }
-
- public void turnBuiltInFilterOn(boolean option)
- {
- supportFilter = option;
- }
-
- public void setBuiltInFilter(IXSDTypesFilter filter)
- {
- this.builtInFilter = filter;
- }
-
- public void showComplexTypes(boolean show)
- {
- showComplexTypes = show;
- }
-}

Back to the top