001    package edu.uchsc.ccp.knowtator.ui;
002    
003    import java.util.Collections;
004    import java.util.HashSet;
005    import java.util.Iterator;
006    import java.util.Set;
007    
008    import javax.swing.Icon;
009    import javax.swing.JTree;
010    
011    import edu.stanford.smi.protege.model.Cls;
012    import edu.stanford.smi.protege.model.KnowledgeBase;
013    import edu.stanford.smi.protege.model.Slot;
014    import edu.stanford.smi.protege.resource.ResourceKey;
015    import edu.stanford.smi.protege.ui.ClsTreeFinder;
016    import edu.stanford.smi.protege.util.SimpleStringMatcher;
017    
018    public class AnnotationSchemaFinder extends ClsTreeFinder {
019    
020            public AnnotationSchemaFinder(KnowledgeBase kb, JTree tree) {
021                    super(kb, tree);
022            }
023    
024            public AnnotationSchemaFinder(KnowledgeBase kb, JTree tree, ResourceKey key) {
025                    super(kb, tree, key);
026            }
027    
028            public AnnotationSchemaFinder(KnowledgeBase kb, JTree tree, String description) {
029                    super(kb, tree, description);
030            }
031    
032            public AnnotationSchemaFinder(KnowledgeBase kb, JTree tree, String description, Icon icon) {
033                    super(kb, tree, description, icon);
034            }
035    
036        protected Set getMatchingFrames(String text, int maxMatches) {
037            if (!text.endsWith("*")) {
038                text += '*';
039            }
040            
041            System.out.println("search text = "+text);
042            Set returnValues = new HashSet(getKnowledgeBase().getClsesWithMatchingBrowserText(text, Collections.EMPTY_LIST, maxMatches));
043            
044            Slot searchSlot = getKnowledgeBase().getSlot(":DOCUMENTATION");
045            
046            Iterator clses = getKnowledgeBase().getClses().iterator();
047            while(clses.hasNext()) {
048                    Cls cls = (Cls)clses.next();
049                    Iterator values = cls.getOwnSlotValues(searchSlot).iterator();
050                    while(values.hasNext()) {
051                            String value = values.next().toString();
052                    SimpleStringMatcher matcher = new SimpleStringMatcher(value);
053                    if(matcher.isMatch(value)) {
054                            returnValues.add(cls);
055                            break;
056                    }
057                    }
058            }
059            return returnValues;
060        }
061    
062    
063    
064    
065    }