001: package com.calipso.reportgenerator.userinterface;
002:
003: import com.calipso.reportgenerator.reportdefinitions.types.ReportDataType;
004: import com.calipso.reportgenerator.reportcalculator.SharedDate;
005: import com.calipso.reportgenerator.reportcalculator.FilterOperation;
006: import com.calipso.reportgenerator.common.LanguageTraslator;
007: import com.calipso.common.DateEx;
008:
009: import javax.swing.*;
010: import java.util.Map;
011: import java.util.Iterator;
012: import java.awt.*;
013:
014: /**
015: *
016: * User: jbassino
017: * Date: 31-may-2005
018: * Time: 15:45:36
019: * Calipso Software
020: */
021: public class UPExcludePanel extends UPPanel {
022:
023: private ParameterPanelConstructor subPanel = null;
024: private UPValuePanel obligatory = null;
025:
026: public UPExcludePanel(UPExcludeElement owner) {
027: this .owner = owner;
028: initialize();
029: }
030:
031: private void initialize() {
032: setLayout(new GridLayout(1, 1));
033: add(getWestPanel());
034: add(getCenterPanel());
035: }
036:
037: private JPanel getCenterPanel() {
038: String dimensioName = owner.getFilterDefinition()
039: .getDimensionName();
040: int type;
041: if (dimensioName != null && !dimensioName.equalsIgnoreCase("")) {
042: type = owner.getReportSpec().getDimensionFromName(
043: dimensioName).getDataType().getType();
044: } else {
045: type = owner.getFilterDefinition().getDataType().getType();
046: }
047: JPanel pnlCenter;
048: boolean isRangeOperation = ((UPExcludeElement) owner)
049: .isRangeOperation();
050: if (isRangeOperation) {
051: pnlCenter = new JPanel(new GridLayout(3, 2));
052: subPanel = createUPRangePanel();
053: } else {
054: pnlCenter = new JPanel(new GridLayout(2, 2));
055: subPanel = createUPValuePanel();
056: }
057: fillCenterPanel(pnlCenter, type);
058: return pnlCenter;
059: }
060:
061: private UPRangePanel createUPRangePanel() {
062: String baseParameterName = FilterOperation.getOperationName(
063: owner.getReportSpec(), owner.getFilterDefinition());
064: UPRangeElement element = new UPRangeElement(owner
065: .getFilterDefinition(), owner.getReportSpec(), "FROM",
066: "TO", baseParameterName + " "
067: + LanguageTraslator.traslate("146"),
068: baseParameterName + " "
069: + LanguageTraslator.traslate("147"));
070: return new UPRangePanel(element);
071: }
072:
073: private UPValuePanel createUPValuePanel() {
074: UPValueElement element = new UPValueElement(owner
075: .getFilterDefinition(), owner.getReportSpec(), "VALUE",
076: FilterOperation.getOperationName(owner.getReportSpec(),
077: owner.getFilterDefinition()));
078: return new UPValuePanel(element);
079: }
080:
081: private void fillCenterPanel(JPanel pnlCenter, int type) {
082: obligatory = createObligatoryPanel();
083: switch (type) {
084: case ReportDataType.DATETIME_TYPE:
085: case ReportDataType.DATE_TYPE:
086: subPanel.addWithDateTextField(pnlCenter);
087: obligatory.addWithDateTextField(pnlCenter);
088: break;
089: case ReportDataType.STRING_TYPE:
090: subPanel.addWithStringTextField(pnlCenter);
091: obligatory.addWithStringTextField(pnlCenter);
092: break;
093: case ReportDataType.INTEGER_TYPE:
094: subPanel.addWithIntegerTextField(pnlCenter);
095: obligatory.addWithIntegerTextField(pnlCenter);
096: break;
097: case ReportDataType.FLOAT_TYPE:
098: subPanel.addWithFloatTextField(pnlCenter);
099: obligatory.addWithFloatTextField(pnlCenter);
100: break;
101: }
102: }
103:
104: private UPValuePanel createObligatoryPanel() {
105: UPValueElement element = new UPValueElement(owner
106: .getFilterDefinition(), owner.getReportSpec(),
107: "OBLIGATORYVALUE", LanguageTraslator.traslate("406"));
108: return new UPValuePanel(element);
109: }
110:
111: public boolean fillParamsMap(Map params) {
112: boolean result = true;
113: result = result && ((UPPanel) subPanel).fillParamsMap(params);
114: result = result && obligatory.fillParamsMap(params);
115: return result;
116: }
117:
118: }
|