|
From: Carlos <ma...@us...> - 2007-10-10 21:28:15
|
Update of /cvsroot/tail/TailS/src/java/net/sf/tails/swing/helper In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv11367/src/java/net/sf/tails/swing/helper Modified Files: FrameHelper.java Log Message: Refatoração de tela para conseguir criar critérios como o versus buy and hold que necessita de outro critério em seu construtor. Index: FrameHelper.java =================================================================== RCS file: /cvsroot/tail/TailS/src/java/net/sf/tails/swing/helper/FrameHelper.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** FrameHelper.java 8 Oct 2007 20:01:47 -0000 1.15 --- FrameHelper.java 10 Oct 2007 21:28:10 -0000 1.16 *************** *** 13,16 **** --- 13,18 ---- import java.io.File; import java.io.FileReader; + import java.lang.reflect.Constructor; + import java.lang.reflect.InvocationTargetException; import java.util.ResourceBundle; *************** *** 35,39 **** private static final ResourceBundle classBundle = ResourceBundle.getBundle("net.sf.tails.i18n.Classes"); ! public static String[] getCriteriaFiles() { String analysisCriteria = classBundle.getString("ANALYSIS_CRITERIA"); String[] criteria = analysisCriteria.split(";"); --- 37,41 ---- private static final ResourceBundle classBundle = ResourceBundle.getBundle("net.sf.tails.i18n.Classes"); ! public String[] getCommunCriteria() { String analysisCriteria = classBundle.getString("ANALYSIS_CRITERIA"); String[] criteria = analysisCriteria.split(";"); *************** *** 41,46 **** return criteria; } ! public static String[] getLoaderFiles() { String loaders = classBundle.getString("LOADERS"); String[] loaderArray = loaders.split(";"); --- 43,55 ---- return criteria; } + + public String[] getGenericCriteria() { + String analysisCriteria = classBundle.getString("GENERIC_CRITERIA"); + String[] criteria = analysisCriteria.split(";"); + + return criteria; + } ! public String[] getLoaders() { String loaders = classBundle.getString("LOADERS"); String[] loaderArray = loaders.split(";"); *************** *** 49,55 **** } ! public static AnalysisCriterion getSelectedCriterion(String criterionName) ! throws InstantiationException, IllegalAccessException, ! ClassNotFoundException { Class<?> cls = Class.forName(packageBundle.getString("CRITERIA_PACKAGE") + criterionName); Object object = cls.newInstance(); --- 58,64 ---- } ! public AnalysisCriterion getSelectedCommunCriterion(String criterionName) ! throws InstantiationException, IllegalAccessException, ClassNotFoundException { ! Class<?> cls = Class.forName(packageBundle.getString("CRITERIA_PACKAGE") + criterionName); Object object = cls.newInstance(); *************** *** 60,65 **** return null; } ! public static TimeSeriesLoader getSelectedLoader(String loaderName) throws InstantiationException, IllegalAccessException, ClassNotFoundException { --- 69,90 ---- return null; } + + public AnalysisCriterion getSelectedGenericCriterion(String genericCriterionName, String secondCriterionName) + throws InstantiationException, IllegalAccessException, ClassNotFoundException, IllegalArgumentException, InvocationTargetException, SecurityException, NoSuchMethodException { + + Class<?> cls = Class.forName(packageBundle.getString("CRITERIA_PACKAGE") + secondCriterionName); + Object object = cls.newInstance(); + + Class<?> cls2 = Class.forName(packageBundle.getString("CRITERIA_PACKAGE") + genericCriterionName); + Constructor<?> constructor = cls2.getConstructor(new Class[]{AnalysisCriterion.class}); + Object object2 = constructor.newInstance(object); ! if (object2 instanceof AnalysisCriterion) { ! return (AnalysisCriterion) object2; ! } else ! return null; ! } ! ! public TimeSeriesLoader getSelectedLoader(String loaderName) throws InstantiationException, IllegalAccessException, ClassNotFoundException { *************** *** 73,77 **** } ! public static DateTime getDate(String dateString) throws Exception { String[] split = dateString.split("/"); int day = Integer.parseInt(split[0]); --- 98,102 ---- } ! public DateTime getDate(String dateString) throws Exception { String[] split = dateString.split("/"); int day = Integer.parseInt(split[0]); *************** *** 88,92 **** } ! public static String readFile(String name) throws Exception { BufferedReader in = new BufferedReader(new FileReader(name)); String text = ""; --- 113,117 ---- } ! public String readFile(String name) throws Exception { BufferedReader in = new BufferedReader(new FileReader(name)); String text = ""; *************** *** 98,102 **** } ! private static Object[][] getReportMatrix(StockAnalysis stockAnalysis) { Object[][] reportMatrix = new Object[stockAnalysis.getReports().size()][2+stockAnalysis.getAdditionalCriteria().size()]; --- 123,127 ---- } ! private Object[][] getReportMatrix(StockAnalysis stockAnalysis) { Object[][] reportMatrix = new Object[stockAnalysis.getReports().size()][2+stockAnalysis.getAdditionalCriteria().size()]; *************** *** 116,120 **** } ! private static String[] getColumnNames(StockAnalysis stockAnalysis) { String[] columnNames = new String[2+stockAnalysis.getAdditionalCriteria().size()]; --- 141,145 ---- } ! private String[] getColumnNames(StockAnalysis stockAnalysis) { String[] columnNames = new String[2+stockAnalysis.getAdditionalCriteria().size()]; *************** *** 128,137 **** } ! public static TableModel getTableModel(StockAnalysis stockAnalysis) { return new DefaultTableModel(getReportMatrix(stockAnalysis), getColumnNames(stockAnalysis)); } ! public static String generateStockAnalysisName() { generateFolders(folderBundle.getString("STOCKANALYSIS_DIR")); File[] files = new File(folderBundle.getString("STOCKANALYSIS_DIR")).listFiles(); --- 153,162 ---- } ! public TableModel getTableModel(StockAnalysis stockAnalysis) { return new DefaultTableModel(getReportMatrix(stockAnalysis), getColumnNames(stockAnalysis)); } ! public String generateStockAnalysisName() { generateFolders(folderBundle.getString("STOCKANALYSIS_DIR")); File[] files = new File(folderBundle.getString("STOCKANALYSIS_DIR")).listFiles(); *************** *** 147,151 **** } ! public static String getStockAnalysisPath(){ generateFolders(folderBundle.getString("STOCKANALYSIS_DIR")); File path = new File(folderBundle.getString("STOCKANALYSIS_DIR")); --- 172,176 ---- } ! public String getStockAnalysisPath(){ generateFolders(folderBundle.getString("STOCKANALYSIS_DIR")); File path = new File(folderBundle.getString("STOCKANALYSIS_DIR")); *************** *** 153,160 **** } ! public static void generateFolders(String path) { new File(path).mkdirs(); } } --- 178,196 ---- } ! public void generateFolders(String path) { new File(path).mkdirs(); } + public boolean isGenericCriteria(String criteriaName) + { + for (String generic : getGenericCriteria()) { + if(criteriaName.equals(generic)) + { + return true; + } + } + return false; + } + } |