01: package com.calipso.reportgenerator.userinterface;
02:
03: import javax.swing.*;
04: import java.awt.*;
05: import java.util.Vector;
06: import java.util.HashMap;
07: import java.util.Iterator;
08:
09: /**
10: * Representa el panel central del dialogo de parametros de usuario.
11: * Cada subpanel de este panel principal representa los filtros
12: * para una dimension.
13: */
14:
15: public class UPsPanel extends JPanel {
16:
17: private UPCollection upCollection;
18:
19: public UPsPanel(LayoutManager layout, boolean isDoubleBuffered,
20: UPCollection upCollection) {
21: super (layout, isDoubleBuffered);
22: this .upCollection = upCollection;
23: initialize();
24: }
25:
26: public UPsPanel(LayoutManager layout, UPCollection upCollection) {
27: super (layout);
28: this .upCollection = upCollection;
29: initialize();
30: }
31:
32: public UPsPanel(boolean isDoubleBuffered, UPCollection upCollection) {
33: super (isDoubleBuffered);
34: this .upCollection = upCollection;
35: initialize();
36: }
37:
38: public UPsPanel(UPCollection upCollection) {
39: this .upCollection = upCollection;
40: initialize();
41: }
42:
43: private void initialize() {
44: Vector upElements = upCollection.getUpCollection();
45: setLayout(new GridBagLayout());
46: GridBagConstraints cons = new GridBagConstraints();
47: int pos = 0;
48: for (int i = 0; i < upElements.size(); i++) {
49: UPCollectionElement upElement = (UPCollectionElement) upElements
50: .elementAt(i);
51: pos += addVisualComponent(upElement.getVisualComponent(),
52: cons, pos);
53: }
54: }
55:
56: private int addVisualComponent(UPPanel visualComponent,
57: GridBagConstraints cons, int pos) {
58: cons.fill = GridBagConstraints.HORIZONTAL;
59: cons.gridwidth = 1;
60: cons.gridx = 0;
61: cons.gridy = pos;
62: if (visualComponent instanceof UPValuePanel) {
63: cons.gridheight = 1;
64: pos++;
65: } else {
66: cons.gridheight = 2;
67: pos += 2;
68: }
69: ((GridBagLayout) getLayout()).setConstraints(visualComponent,
70: cons);
71: add(visualComponent);
72: return pos;
73: }
74:
75: /* private void initialize() {
76: Vector upElements = upCollection.getUpCollection();
77: setLayout(new GridLayout(upElements.size(), 1));
78: for(int i = 0 ; i < upElements.size() ; i++) {
79: UPCollectionElement upElement = (UPCollectionElement) upElements.elementAt(i);
80: add(upElement.getVisualComponent());
81: }
82: }*/
83:
84: public boolean fillParamsMap(HashMap params) {
85: for (int i = 0; i < getComponentCount(); i++) {
86: UPPanel currentPanel = (UPPanel) this .getComponent(i);
87: boolean succeded = currentPanel.fillParamsMap(params);
88: if (!succeded) {
89: return false;
90: }
91: }
92: return true;
93: }
94: }
|