1 package com.calipso.reportgenerator.userinterface; 2 3 import com.calipso.reportgenerator.reportdefinitions.types.ReportDataType; 4 import com.calipso.reportgenerator.reportcalculator.SharedDate; 5 import com.calipso.reportgenerator.reportcalculator.FilterOperation; 6 import com.calipso.reportgenerator.common.LanguageTraslator; 7 import com.calipso.common.DateEx; 8 9 import javax.swing.*; 10 import java.util.Map ; 11 import java.util.Iterator ; 12 import java.awt.*; 13 14 21 public class UPExcludePanel extends UPPanel { 22 23 private ParameterPanelConstructor subPanel = null; 24 private UPValuePanel obligatory = null; 25 26 public UPExcludePanel(UPExcludeElement owner) { 27 this.owner = owner; 28 initialize(); 29 } 30 31 private void initialize() { 32 setLayout(new GridLayout(1, 1)); 33 add(getWestPanel()); 34 add(getCenterPanel()); 35 } 36 37 private JPanel getCenterPanel() { 38 String dimensioName = owner.getFilterDefinition().getDimensionName(); 39 int type; 40 if(dimensioName!=null && !dimensioName.equalsIgnoreCase("")){ 41 type = owner.getReportSpec().getDimensionFromName(dimensioName).getDataType().getType(); 42 }else{ 43 type = owner.getFilterDefinition().getDataType().getType(); 44 } 45 JPanel pnlCenter; 46 boolean isRangeOperation = ((UPExcludeElement)owner).isRangeOperation(); 47 if(isRangeOperation){ 48 pnlCenter = new JPanel(new GridLayout(3, 2)); 49 subPanel = createUPRangePanel(); 50 }else{ 51 pnlCenter = new JPanel(new GridLayout(2, 2)); 52 subPanel = createUPValuePanel(); 53 } 54 fillCenterPanel(pnlCenter, type); 55 return pnlCenter; 56 } 57 58 private UPRangePanel createUPRangePanel() { 59 String baseParameterName = FilterOperation.getOperationName(owner.getReportSpec(), owner.getFilterDefinition()); 60 UPRangeElement element = new UPRangeElement(owner.getFilterDefinition(), owner.getReportSpec(),"FROM","TO", 61 baseParameterName + " " + LanguageTraslator.traslate("146"), baseParameterName + " " + LanguageTraslator.traslate("147")); 62 return new UPRangePanel(element); 63 } 64 65 private UPValuePanel createUPValuePanel() { 66 UPValueElement element = new UPValueElement(owner.getFilterDefinition(), owner.getReportSpec(),"VALUE", 67 FilterOperation.getOperationName(owner.getReportSpec(), owner.getFilterDefinition())); 68 return new UPValuePanel(element); 69 } 70 71 private void fillCenterPanel(JPanel pnlCenter, int type) { 72 obligatory = createObligatoryPanel(); 73 switch(type) { 74 case ReportDataType.DATETIME_TYPE: 75 case ReportDataType.DATE_TYPE: 76 subPanel.addWithDateTextField(pnlCenter); 77 obligatory.addWithDateTextField(pnlCenter); 78 break; 79 case ReportDataType.STRING_TYPE: 80 subPanel.addWithStringTextField(pnlCenter); 81 obligatory.addWithStringTextField(pnlCenter); 82 break; 83 case ReportDataType.INTEGER_TYPE: 84 subPanel.addWithIntegerTextField(pnlCenter); 85 obligatory.addWithIntegerTextField(pnlCenter); 86 break; 87 case ReportDataType.FLOAT_TYPE: 88 subPanel.addWithFloatTextField(pnlCenter); 89 obligatory.addWithFloatTextField(pnlCenter); 90 break; 91 } 92 } 93 94 private UPValuePanel createObligatoryPanel() { 95 UPValueElement element = new UPValueElement(owner.getFilterDefinition(), owner.getReportSpec(), "OBLIGATORYVALUE", 96 LanguageTraslator.traslate("406")); 97 return new UPValuePanel(element); 98 } 99 100 public boolean fillParamsMap(Map params) { 101 boolean result = true; 102 result = result && ((UPPanel)subPanel).fillParamsMap(params); 103 result = result && obligatory.fillParamsMap(params); 104 return result; 105 } 106 107 } 108 | Popular Tags |