1 package com.calipso.reportgenerator.userinterface; 2 3 import com.calipso.reportgenerator.common.LanguageTraslator; 4 5 import javax.swing.*; 6 import java.util.Date ; 7 import java.util.Map ; 8 import java.util.TreeMap ; 9 import java.text.DateFormat ; 10 import java.text.SimpleDateFormat ; 11 import java.text.ParseException ; 12 import java.awt.*; 13 14 17 18 public abstract class UPPanel extends JPanel { 19 20 private TreeMap upTextFieldCollection; 21 protected UPCollectionElement owner; 22 23 protected void addUPTextField(Object key, UPComponent upTextField) { 24 getUpTextFieldCollection().put(key, upTextField); 25 } 26 27 public TreeMap getUpTextFieldCollection() { 28 if(upTextFieldCollection == null) { 29 upTextFieldCollection = new TreeMap (); 30 } 31 return upTextFieldCollection; 32 } 33 34 protected String getDateFormatFrom(String dateString) { 35 String returnVal = null; 36 try { 37 DateFormat dateFormat = new SimpleDateFormat ("yyyyMMdd"); 38 Date date = dateFormat.parse(dateString); 39 DateFormat second = SimpleDateFormat.getDateInstance(DateFormat.SHORT, LanguageTraslator.getLocale()); 40 returnVal = second.format(date); 41 } catch (ParseException e) { 42 e.printStackTrace(); 43 } 44 return returnVal; 45 } 46 47 protected JPanel getWestPanel() { 48 JPanel pnlWest = new JPanel(new BorderLayout()); 49 String dimensioName = owner.getFilterDefinition().getDimensionName(); 50 JLabel label; 51 if(dimensioName!=null && !dimensioName.equalsIgnoreCase("")){ 52 String dimensionCaption = owner.getReportSpec().getDimensionFromName(dimensioName).getCaption(); 53 label = new JLabel(dimensionCaption); 54 }else{ 55 label = new JLabel(owner.getFilterDefinition().getName()); 56 } 57 pnlWest.add(label, BorderLayout.CENTER); 58 return pnlWest; 59 } 60 61 62 public abstract boolean fillParamsMap(Map params); 63 } 64 | Popular Tags |