package org.injac.indexing.util;

import java.io.File;
import java.io.FileReader;
import java.util.ResourceBundle;

import org.apache.log4j.Logger;

public class WidgetManager {
	static Logger logger = Logger.getLogger(WidgetManager.class);
	static public String getTitleBar(ResourceBundle resBundle){
		String titleFile = resBundle.getString("widget.titlebar");
		return getStringFromFile(titleFile);
	}
	
	static public String getContent(ResourceBundle resBundle){
		String titleFile = resBundle.getString("widget.content");
		return getStringFromFile(titleFile);
	}
	
	
	
	static public String getStringFromFile(String titleFile){
		String result = "";
		
		File file = new File(titleFile);
		if(file.exists()){
			try{
				FileReader fr = new FileReader(file);
				int read=-1;
				while((read = fr.read())!=-1){
					result+= (char)read;
				}
			}catch(Exception fne){
				logger.error(fne +" : "+fne.getLocalizedMessage());
			}
		}
		return result;
		
	}
}
