01: package com.calipso.reportgenerator.userinterface;
02:
03: import com.calipso.reportgenerator.common.LanguageTraslator;
04:
05: import javax.swing.*;
06: import java.util.Date;
07: import java.util.Map;
08: import java.util.TreeMap;
09: import java.text.DateFormat;
10: import java.text.SimpleDateFormat;
11: import java.text.ParseException;
12: import java.awt.*;
13:
14: /**
15: * Representa un subpanel de la instancia <code>UPsPanel</code>.
16: */
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(
40: DateFormat.SHORT, LanguageTraslator.getLocale());
41: returnVal = second.format(date);
42: } catch (ParseException e) {
43: e.printStackTrace();
44: }
45: return returnVal;
46: }
47:
48: protected JPanel getWestPanel() {
49: JPanel pnlWest = new JPanel(new BorderLayout());
50: String dimensioName = owner.getFilterDefinition()
51: .getDimensionName();
52: JLabel label;
53: if (dimensioName != null && !dimensioName.equalsIgnoreCase("")) {
54: String dimensionCaption = owner.getReportSpec()
55: .getDimensionFromName(dimensioName).getCaption();
56: label = new JLabel(dimensionCaption);
57: } else {
58: label = new JLabel(owner.getFilterDefinition().getName());
59: }
60: pnlWest.add(label, BorderLayout.CENTER);
61: return pnlWest;
62: }
63:
64: public abstract boolean fillParamsMap(Map params);
65: }
|