| /******************************************************************************* |
| * Copyright (c) 2012 SAP AG. |
| * 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: |
| * Georgi Konstantinov - initial API and implementation. |
| *******************************************************************************/ |
| package org.eclipse.wst.sse.sieditor.search.provider.wsdl; |
| |
| import java.util.Collection; |
| |
| import org.eclipse.core.resources.IFile; |
| import org.eclipse.platform.discovery.runtime.api.ISearchParameters; |
| import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot; |
| import org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface; |
| import org.eclipse.wst.sse.sieditor.search.provider.AbstractSearchQueryOperation; |
| import org.eclipse.wst.sse.sieditor.search.provider.WildcardStringMatcher; |
| import org.eclipse.wst.sse.sieditor.search.ui.tree.FileNode; |
| import org.eclipse.wst.sse.sieditor.search.ui.tree.ITreeNodeWithCustomizableChildren; |
| import org.eclipse.wst.sse.sieditor.search.ui.tree.NamespaceNode; |
| import org.eclipse.wst.sse.sieditor.search.ui.tree.RootTreeNode; |
| import org.eclipse.wst.sse.sieditor.ui.v2.wsdl.controller.SIFormPageController; |
| import org.eclipse.wst.sse.sieditor.ui.v2.wsdltree.nodes.ServiceInterfaceNode; |
| |
| public class WsdlSearchQueryOperation extends AbstractSearchQueryOperation { |
| |
| public WsdlSearchQueryOperation(ISearchParameters searchParams) { |
| super(searchParams); |
| } |
| |
| @Override |
| protected boolean isFileThatMayHaveTheSearchedContenet(String fileExtension) { |
| if (isWsdlFileExtension(fileExtension) || isXmlFileExtension(fileExtension)) { |
| return true; |
| } |
| return false; |
| } |
| |
| @Override |
| protected void analyzeFile(RootTreeNode rootTreeNode, IFile file, FileNode fileNode) { |
| IWsdlModelRoot wsdlModelRoot = getWsdlModelRootForFile(file); |
| |
| if (isByNamespaceHierarchy() || isByFilesHierarchy()) { |
| NamespaceNode namespaceNode = new NamespaceNode(wsdlModelRoot.getDescription(), fileNode); |
| addInterfacesToNamespaceNode(wsdlModelRoot, namespaceNode); |
| |
| } else { |
| addInterfacesToNamespaceNode(wsdlModelRoot, rootTreeNode); |
| } |
| } |
| |
| private void addInterfacesToNamespaceNode(IWsdlModelRoot wsdlModelRoot, ITreeNodeWithCustomizableChildren parent) { |
| Collection<IServiceInterface> allInterfaces = wsdlModelRoot.getDescription().getAllInterfaces(); |
| for (IServiceInterface serviceInterface : allInterfaces) { |
| if (!WildcardStringMatcher.matches(searchParams.getKeywordString(), serviceInterface.getName())) { |
| continue; |
| } |
| |
| parent.addChild(new ServiceInterfaceNode(parent, serviceInterface, new SIFormPageController(wsdlModelRoot, false, |
| false))); |
| } |
| } |
| } |