KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > userinterface > DimensionColumnValue


1 package com.calipso.reportgenerator.userinterface;
2
3 import com.calipso.reportgenerator.common.InfoException;
4 import com.calipso.reportgenerator.common.ShowExceptionMessageDialog;
5
6 import javax.swing.*;
7 import java.awt.*;
8 import java.awt.event.WindowAdapter JavaDoc;
9 import java.awt.event.WindowEvent JavaDoc;
10 import java.util.Vector JavaDoc;
11
12 public class DimensionColumnValue extends javax.swing.JDialog JavaDoc {
13   public int x;
14   public int y;
15   private javax.swing.JScrollPane JavaDoc centerScrollPanel;
16   private int width;
17   private Point point;
18   public JFrame frame;
19   private Vector JavaDoc jcheckVector;
20   private String JavaDoc name;
21   private String JavaDoc panelName;
22   private JList list;
23   private CheckDataListCellRenderer render;
24   private PivotTable table;
25   private CheckDataListener lst;
26
27   /**
28    * Retorna la JList list
29    * @return
30    */

31   public JList getList() {
32     return list;
33   }
34
35   /**
36    * Crea un Objeto DimensionColumnValue
37    * @param width
38    * @param location
39
40    * @param jcheckVector
41    */

42   public DimensionColumnValue(int width, Point location, PivotTable pivotTable, Vector JavaDoc jcheckVector, String JavaDoc name, String JavaDoc panelName) throws InfoException {
43     this.jcheckVector = jcheckVector;
44     this.name = name;
45     this.panelName = panelName;
46     this.x = 0;
47     this.y = 0;
48     this.width = width;
49     this.point = location;
50     this.point.y += 18;
51     this.frame = pivotTable.getFrame();
52     table = pivotTable;
53     initComponents();
54     setProperties();
55   }
56
57   /**
58    * Setea las propiedades del JDialog
59    */

60   private void setProperties() {
61     setUndecorated(true);
62     setSize(width + 15, Math.min((int) list.getPreferredSize().getHeight(), 180));
63     setLocation(point);
64     setVisible(true);
65     list.revalidate();
66   }
67
68   /**
69    * Inicializa el Dialog , seteando paneles , listeners , etc...
70    */

71   private void initComponents() {
72     getContentPane().add(createCenterScrollPanel(), java.awt.BorderLayout.CENTER);
73     frame.addWindowFocusListener(new java.awt.event.WindowFocusListener JavaDoc() {
74       public void windowGainedFocus(java.awt.event.WindowEvent JavaDoc evt) {
75         formWindowGainedFocus();
76       }
77
78       public void windowLostFocus(java.awt.event.WindowEvent JavaDoc evt) {
79         formWindowLostFocus();
80       }
81     });
82     addWindowFocusListener(new java.awt.event.WindowFocusListener JavaDoc() {
83       public void windowGainedFocus(java.awt.event.WindowEvent JavaDoc evt) {
84         dialogWindowGainedFocus();
85       }
86
87       public void windowLostFocus(java.awt.event.WindowEvent JavaDoc evt) {
88         dialogWindowLostFocus();
89       }
90
91     });
92     addWindowListener(new WindowAdapter JavaDoc() {
93       public void windowClosed(WindowEvent JavaDoc e) {
94         try {
95           lst.run(jcheckVector);
96         }
97         catch (InfoException ex) {
98           ShowExceptionMessageDialog.initExceptionDialogMessage(com.calipso.reportgenerator.common.LanguageTraslator.traslate("214"), ex);
99         }
100       }
101     });
102   }
103
104   /**
105    * Implemntación de la interface WindowFocusListener
106    *
107    */

108   private void dialogWindowGainedFocus() {
109   }
110
111   /**
112    * Implemntación de la interface WindowFocusListener
113    *
114    * */

115   private void dialogWindowLostFocus() {
116     setVisible(false);
117     dispose();
118   }
119
120   /**
121    * Implemntación de la interface WindowFocusListener
122    *
123    */

124   private void formWindowLostFocus() {
125     requestFocus();
126     toFront();
127   }
128
129   /**
130    * Implemntación de la interface WindowFocusListener
131    *
132    */

133   private void formWindowGainedFocus() {
134     requestFocus();
135     toBack();
136   }
137
138   /**
139    * Retorna el JSCrollPane centerScrollPanel ubicado al centro del JDialog con el JScrollBar Verical visible siempre y
140    * el JScrollBar nunca visible
141    * @return
142    */

143   private Component createCenterScrollPanel() {
144     centerScrollPanel = new javax.swing.JScrollPane JavaDoc();
145     centerScrollPanel.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
146     centerScrollPanel.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
147     centerScrollPanel.getViewport().add(createListDataComponents());
148     centerScrollPanel.getViewport().setVisible(true);
149     return centerScrollPanel;
150   }
151
152   /**
153    * Crea la JList con los JButtonChech con sus respectivos estados
154    * @return
155    */

156   private Component createListDataComponents() {
157     ListDataModel[] options = new ListDataModel[jcheckVector.size()];
158     Object JavaDoc[] vec;
159     for (int index = 0; index < jcheckVector.size(); index++) {
160       vec = (Object JavaDoc[]) jcheckVector.get(index);
161       Object JavaDoc nameLabel = vec[0];
162       boolean isSelected = new Boolean JavaDoc(vec[1].toString()).booleanValue();
163       ListDataModel aux = new ListDataModel(nameLabel, (new Boolean JavaDoc(isSelected)).booleanValue());
164       options[index] = aux;
165     }
166     list = new JList(options);
167     render = new CheckDataListCellRenderer();
168     list.setCellRenderer(render);
169     lst = new CheckDataListener(this, table);
170     list.addMouseListener(lst);
171     list.addKeyListener(lst);
172
173     return list;
174   }
175
176  /**
177   * Retorna la ubicacion del panel seleccionado (ROW - COLUMN - PAGE)
178   * @return
179   */

180   public String JavaDoc getName() {
181     return name;
182   }
183
184   /**
185    * Retorna el vector con los estados de los valores
186    * @return
187    */

188   public Vector JavaDoc getJcheckVector() {
189     return jcheckVector;
190   }
191
192   /**
193    * Setea el vector con los estados de los valores actualizados
194    * @param jcheckVector
195    */

196   public void setJcheckVector(Vector JavaDoc jcheckVector) {
197     this.jcheckVector = jcheckVector;
198   }
199
200   /**
201    * Retorna el nombre del panel el cual fue seleccionado
202    * @return
203    */

204   public String JavaDoc getPanelName() {
205     return panelName;
206   }
207
208 }
Popular Tags