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 ; 9 import java.awt.event.WindowEvent ; 10 import java.util.Vector ; 11 12 public class DimensionColumnValue extends javax.swing.JDialog { 13 public int x; 14 public int y; 15 private javax.swing.JScrollPane centerScrollPanel; 16 private int width; 17 private Point point; 18 public JFrame frame; 19 private Vector jcheckVector; 20 private String name; 21 private String panelName; 22 private JList list; 23 private CheckDataListCellRenderer render; 24 private PivotTable table; 25 private CheckDataListener lst; 26 27 31 public JList getList() { 32 return list; 33 } 34 35 42 public DimensionColumnValue(int width, Point location, PivotTable pivotTable, Vector jcheckVector, String name, String 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 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 71 private void initComponents() { 72 getContentPane().add(createCenterScrollPanel(), java.awt.BorderLayout.CENTER); 73 frame.addWindowFocusListener(new java.awt.event.WindowFocusListener () { 74 public void windowGainedFocus(java.awt.event.WindowEvent evt) { 75 formWindowGainedFocus(); 76 } 77 78 public void windowLostFocus(java.awt.event.WindowEvent evt) { 79 formWindowLostFocus(); 80 } 81 }); 82 addWindowFocusListener(new java.awt.event.WindowFocusListener () { 83 public void windowGainedFocus(java.awt.event.WindowEvent evt) { 84 dialogWindowGainedFocus(); 85 } 86 87 public void windowLostFocus(java.awt.event.WindowEvent evt) { 88 dialogWindowLostFocus(); 89 } 90 91 }); 92 addWindowListener(new WindowAdapter () { 93 public void windowClosed(WindowEvent 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 108 private void dialogWindowGainedFocus() { 109 } 110 111 115 private void dialogWindowLostFocus() { 116 setVisible(false); 117 dispose(); 118 } 119 120 124 private void formWindowLostFocus() { 125 requestFocus(); 126 toFront(); 127 } 128 129 133 private void formWindowGainedFocus() { 134 requestFocus(); 135 toBack(); 136 } 137 138 143 private Component createCenterScrollPanel() { 144 centerScrollPanel = new javax.swing.JScrollPane (); 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 156 private Component createListDataComponents() { 157 ListDataModel[] options = new ListDataModel[jcheckVector.size()]; 158 Object [] vec; 159 for (int index = 0; index < jcheckVector.size(); index++) { 160 vec = (Object []) jcheckVector.get(index); 161 Object nameLabel = vec[0]; 162 boolean isSelected = new Boolean (vec[1].toString()).booleanValue(); 163 ListDataModel aux = new ListDataModel(nameLabel, (new Boolean (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 180 public String getName() { 181 return name; 182 } 183 184 188 public Vector getJcheckVector() { 189 return jcheckVector; 190 } 191 192 196 public void setJcheckVector(Vector jcheckVector) { 197 this.jcheckVector = jcheckVector; 198 } 199 200 204 public String getPanelName() { 205 return panelName; 206 } 207 208 } | Popular Tags |