001 /**
002 * Copyright 2010 The Kuali Foundation Licensed under the
003 * Educational Community License, Version 2.0 (the "License"); you may
004 * not use this file except in compliance with the License. You may
005 * obtain a copy of the License at
006 *
007 * http://www.osedu.org/licenses/ECL-2.0
008 *
009 * Unless required by applicable law or agreed to in writing,
010 * software distributed under the License is distributed on an "AS IS"
011 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
012 * or implied. See the License for the specific language governing
013 * permissions and limitations under the License.
014 */
015
016 package org.kuali.student.common.ui.client.widgets.suggestbox;
017
018 import java.util.HashMap;
019 import java.util.Map;
020
021 import com.google.gwt.user.client.ui.SuggestOracle;
022
023 public abstract class IdableSuggestOracle extends SuggestOracle{
024 public static class IdableSuggestion implements Suggestion{
025 private String id;
026 private String displayString;
027 private String replacementString;
028 private Map<String, String> attrMap = new HashMap<String, String>();
029 //private List<String> attrKeys = new ArrayList<String>();
030
031 public IdableSuggestion(){}
032
033 public IdableSuggestion(String id, String displayString, String replacementString) {
034 this.displayString = displayString;
035 this.id = id;
036 this.replacementString = replacementString;
037 }
038
039 public String getId() {
040 return id;
041 }
042
043 @Override
044 public String getDisplayString() {
045 return displayString;
046 }
047
048 @Override
049 public String getReplacementString() {
050 return replacementString;
051 }
052
053 public void setId(String id) {
054 this.id = id;
055 }
056
057 public void setDisplayString(String displayString) {
058 this.displayString = displayString;
059 }
060
061 public void setReplacementString(String replacementString) {
062 this.replacementString = replacementString;
063 }
064
065 protected void addAttr(String key, String value){
066 attrMap.put(key, value);
067 }
068
069 /* protected void addAttrKey(String key){
070 attrKeys.add(key);
071 }*/
072
073 public Map<String, String> getAttrMap(){
074 return attrMap;
075 }
076
077 public void setAttrMap(Map<String, String> attrMap){
078 this.attrMap = attrMap;
079 }
080
081 /* public List<String> getAttrKeys(){
082 return attrKeys;
083 }*/
084
085
086 }
087 //public abstract IdableSuggestion getSuggestionById(String id);
088 public abstract IdableSuggestion getSuggestionByText(String text);
089 public abstract void getSuggestionByIdSearch(String id, org.kuali.student.common.ui.client.mvc.Callback<IdableSuggestion> callback);
090 public abstract void addSearchCompletedCallback(org.kuali.student.common.ui.client.mvc.Callback<IdableSuggestion> callback);
091 }