package tool.model;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.text.IDocument;
import tool.ToolModelActivator;
import tool.ToolProjectSupport;
public class ToolModel {
protected static Map<String, ToolType> forteTypeCache;
static {
forteTypeCache = new HashMap<String, ToolType>();
}
/**
* Returns the global list of Forte Types
* @return
*/
public static Map<String, ToolType> getForteTypeCache() {
return forteTypeCache;
}
/**
* returns the IProject specific list of types
* @param project
* @return
*/
public static Map<String, ToolType> getTypeCache(IProject project){
Map<String, ToolType> cache = null;
try {
cache = (Map<String, ToolType>)project.getSessionProperty(new QualifiedName(ToolProjectSupport.PROJECT_QUALIFIED_NAME, ToolProjectSupport.TYPE_CACHE));
if (cache == null){
cache = new HashMap<String, ToolType>();
project.setSessionProperty(new QualifiedName(ToolProjectSupport.PROJECT_QUALIFIED_NAME, ToolProjectSupport.TYPE_CACHE), cache);
}
} catch (CoreException e) {
ToolModelActivator.showError("Error getting class cache", e);
}
return cache;
}
IDocument doc;
Object obj;
public static ToolModel getModel(IDocument doc, Object obj){
//TODO invent a cache for the model
return new ToolModel(doc, obj);
}
private ToolModel(IDocument doc, Object obj){
this.doc = doc;
this.obj = obj;
}
public ToolComponent getElementAt(int offset){
//TODO get an element;
return null;
}
public void getContentProposals(String prefix, String indent, int offset,
ArrayList result) {
if (prefix.equalsIgnoreCase("for"))
result.add("(int i : tits) {\n\n}");
}
}