1 package com.calipso.reportgenerator.userinterface; 2 3 import com.calipso.reportgenerator.common.LanguageTraslator; 4 import com.calipso.reportgenerator.common.ShowExceptionMessageDialog; 5 6 import javax.swing.*; 7 import java.net.URL ; 8 import java.awt.event.ActionEvent ; 9 import java.awt.event.ActionListener ; 10 import java.awt.*; 11 12 19 20 public class ReportViewerToolBar extends JToolBar implements ActionListener { 21 22 private PivotTableFrame pivotTableFrame; 23 private boolean btTotalsState; 24 private boolean btSizesState; 25 private JToggleButton btTotals; 26 private JToggleButton btSizes; 27 private JToggleButton printButton; 28 private JToggleButton exportMicroReportButton; 29 private JToggleButton graphicButton; 30 private JToggleButton colorIndicator; 31 private JToggleButton searcher; 32 private JToggleButton excel; 33 private JToggleButton viewBtn; 34 private JToggleButton editDimensionValueBtn; 35 private JToggleButton ordenBtn; 36 private JToggleButton btRefresh; 37 private JToggleButton btReportInfo; 38 39 public ReportViewerToolBar() { 40 addToolBarButtons(); 41 } 42 43 public ReportViewerToolBar(int orientation) { 44 super(orientation); 45 addToolBarButtons(); 46 } 47 48 public ReportViewerToolBar(String name) { 49 super(name); 50 addToolBarButtons(); 51 } 52 53 public ReportViewerToolBar(String name, int orientation) { 54 super(name, orientation); 55 addToolBarButtons(); 56 } 57 58 private void addToolBarButtons() { 59 btTotals = (JToggleButton) makeNavigationButton("sum", 60 "TOTALS", 61 LanguageTraslator.traslate("352"), 62 "", true); 63 64 65 add(btTotals); 66 67 btSizes = (JToggleButton) makeNavigationButton("ruler", 68 "SIZES", 69 LanguageTraslator.traslate("351"), 70 "", true); 71 add(btSizes); 72 73 printButton = (JToggleButton) makeNavigationButton("print", "PRINT", 74 LanguageTraslator.traslate("343"), 75 "", true); 76 77 add(printButton); 78 79 exportMicroReportButton = (JToggleButton) makeNavigationButton("save", "EXPORT", 80 LanguageTraslator.traslate("344"), 81 "", true); 82 83 add(exportMicroReportButton); 84 85 graphicButton = (JToggleButton) makeNavigationButton("chart", "CHART", 86 LanguageTraslator.traslate("345"), 87 "", true); 88 89 add(graphicButton); 90 91 searcher = (JToggleButton) makeNavigationButton("search", "SEARCH", 92 LanguageTraslator.traslate("346"), 93 "", true); 94 95 add(searcher); 96 97 excel = (JToggleButton) makeNavigationButton("excel", "EXCEL", 98 LanguageTraslator.traslate("347"), 99 "", true); 100 101 add(excel); 102 103 colorIndicator = (JToggleButton) makeNavigationButton("semaphore", "SEMAPHORE", 104 LanguageTraslator.traslate("348"), 105 "", true); 106 107 add(colorIndicator); 108 109 viewBtn = (JToggleButton) makeNavigationButton("profiles", "PROFILES", 110 LanguageTraslator.traslate("349"), 111 "", true); 112 113 add(viewBtn); 114 115 editDimensionValueBtn = (JToggleButton) makeNavigationButton("ranking", "RANKING", 116 LanguageTraslator.traslate("350"), 117 "", true); 118 119 add(editDimensionValueBtn); 120 121 ordenBtn = (JToggleButton) makeNavigationButton("order", "ORDER", 122 LanguageTraslator.traslate("388"), 123 "", true); 124 125 126 add(ordenBtn); 127 128 btRefresh = (JToggleButton) makeNavigationButton("refresh", 129 "REFRESH", 130 LanguageTraslator.traslate("387"), 131 "", true); 132 133 134 add(btRefresh); 135 btReportInfo = (JToggleButton) makeNavigationButton("infoicon", 136 "INFOICON", 137 LanguageTraslator.traslate("530"), 138 "", true); 139 140 141 add(btReportInfo); 142 143 } 144 145 public void microReportLoaded() { 146 btTotalsState = true; 147 btTotals.setEnabled(true); 148 btTotals.setSelected(true); 149 btSizes.setEnabled(true); 150 printButton.setEnabled(true); 151 exportMicroReportButton.setEnabled(true); 152 graphicButton.setEnabled(true); 153 searcher.setEnabled(true); 154 excel.setEnabled(true); 155 colorIndicator.setEnabled(true); 156 viewBtn.setEnabled(true); 157 editDimensionValueBtn.setEnabled(true); 158 ordenBtn.setEnabled(true); 159 btRefresh.setEnabled(true); 160 btReportInfo.setEnabled(true); 161 } 162 163 public void definitionExecuted() { 164 btTotals.setEnabled(false); 165 btSizes.setEnabled(false); 166 printButton.setEnabled(false); 167 exportMicroReportButton.setEnabled(false); 168 graphicButton.setEnabled(false); 169 searcher.setEnabled(false); 170 excel.setEnabled(false); 171 colorIndicator.setEnabled(false); 172 viewBtn.setEnabled(false); 173 editDimensionValueBtn.setEnabled(false); 174 ordenBtn.setEnabled(false); 175 btRefresh.setEnabled(false); 176 btReportInfo.setEnabled(false); 177 } 178 179 public void drillDownExecuted() { 180 btTotals.setSelected(true); 181 btSizes.setSelected(false); 182 btTotalsState = true; 183 btSizesState = false; 184 } 185 186 private Object makeNavigationButton(String imageName, 187 String actionCommand, 188 String toolTipText, 189 String altText, 190 boolean isToggle) { 191 192 193 ClassLoader loader = this.getClass().getClassLoader(); 194 URL url; 195 url = loader.getResource("com/calipso/reportgenerator/userinterface/images/" + imageName + ".gif"); 196 197 198 202 203 205 Object button = null; 206 if(isToggle) { 207 button = new JToggleButton(); 208 ((JToggleButton)button).setActionCommand(actionCommand); 209 ((JToggleButton)button).setToolTipText(toolTipText); 210 ((JToggleButton)button).addActionListener(this); 211 if (url!= null) { 212 ((JToggleButton)button).setIcon(new ImageIcon(url, altText)); 213 if (imageName.equalsIgnoreCase("REFRESH")){ 215 ((JToggleButton)button).setSelectedIcon(new ImageIcon(loader.getResource("com/calipso/reportgenerator/userinterface/images/no" + imageName + ".gif"), altText)); 216 } 217 } else { 218 ((JToggleButton)button).setText(altText); 219 } 220 } else { 221 button = new JButton(); 222 ((JButton)button).setActionCommand(actionCommand); 223 ((JButton)button).setToolTipText(toolTipText); 224 ((JButton)button).addActionListener(this); 225 if (url != null) { 226 ((JButton)button).setIcon(new ImageIcon(url, altText)); 227 } else { 228 ((JButton)button).setText(altText); 229 } 230 } 231 232 return button; 233 } 234 235 public void actionPerformed(ActionEvent e) { 236 try { 237 if(e.getActionCommand().equals("TOTALS")) { 238 if(btTotalsState == true) { 239 btTotals.setSelected(false); 240 btTotalsState = false; 241 } else { 242 btTotals.setSelected(true); 243 btTotalsState = true; 244 } 245 pivotTableFrame.getPivotTable().setPivoteTableSinTotales(); 246 } else if(e.getActionCommand().equals("SIZES")) { 247 if(btSizesState == false) { 248 btSizes.setSelected(true); 249 btSizesState = true; 250 } else { 251 btSizes.setSelected(false); 252 btSizesState = false; 253 } 254 pivotTableFrame.maximizarActionPerformed(); 255 pivotTableFrame.getPivotTable().maximizarActionPerformed(); 256 } else if(e.getActionCommand().equals("PRINT")) { 257 printButton.setSelected(false); 258 pivotTableFrame.printPivotTable(this.getRootPane().getSize()); 259 } else if(e.getActionCommand().equals("CHART")) { 260 graphicButton.setSelected(false); 261 pivotTableFrame.doGraphics(); 262 } else if(e.getActionCommand().equals("SEARCH")) { 263 searcher.setSelected(false); 264 pivotTableFrame.getPivotTable().executeSearcher(); 265 } else if(e.getActionCommand().equals("EXPORT")) { 266 exportMicroReportButton.setSelected(false); 267 pivotTableFrame.exportMicroReport(); 268 } else if(e.getActionCommand().equals("EXCEL")) { 269 excel.setSelected(false); 270 pivotTableFrame.getPivotTable().executeExcelFormatSerializer(); 271 } else if(e.getActionCommand().equals("SEMAPHORE")) { 272 colorIndicator.setSelected(false); 273 pivotTableFrame.getPivotTable().executeSemafore(); 274 } else if(e.getActionCommand().equals("PROFILES")) { 275 viewBtn.setSelected(false); 276 pivotTableFrame.getPivotTable().executeViewBtn(); 277 } else if(e.getActionCommand().equals("RANKING")) { 278 editDimensionValueBtn.setSelected(false); 279 pivotTableFrame.getPivotTable().executeEditDimensionValues(); 280 } else if(e.getActionCommand().equals("ORDER")) { 281 ordenBtn.setSelected(false); 282 pivotTableFrame.getPivotTable().executeEditOrdenValues(); 283 } else if(e.getActionCommand().equals("REFRESH")) { 284 pivotTableFrame.setAutoRefresh(!btRefresh.isSelected()); 285 } else if(e.getActionCommand().equals("INFOICON")) { 286 btReportInfo.setSelected(false); 287 pivotTableFrame.launchInfoPage(); 288 } 289 290 } catch(Exception e1) { 291 ShowExceptionMessageDialog.initExceptionDialogMessage(LanguageTraslator.traslate("263"), e1); 292 } finally { 293 setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); 294 } 295 } 296 297 public PivotTableFrame getPivotTableFrame() { 298 return pivotTableFrame; 299 } 300 301 public void setPivotTableFrame(PivotTableFrame pivotTableFrame) { 302 this.pivotTableFrame = pivotTableFrame; 303 } 304 305 public boolean isBtTotalsState() { 306 return btTotalsState; 307 } 308 309 public void setBtTotalsState(boolean btTotalsState) { 310 this.btTotalsState = btTotalsState; 311 } 312 313 public boolean isBtSizesState() { 314 return btSizesState; 315 } 316 317 public void setBtSizesState(boolean btSizesState) { 318 this.btSizesState = btSizesState; 319 } 320 321 public JToggleButton getBtTotals() { 322 return btTotals; 323 } 324 325 public void setBtTotals(JToggleButton btTotals) { 326 this.btTotals = btTotals; 327 } 328 329 public JToggleButton getBtSizes() { 330 return btSizes; 331 } 332 333 public void setBtSizes(JToggleButton btSizes) { 334 this.btSizes = btSizes; 335 } 336 337 public JToggleButton getPrintButton() { 338 return printButton; 339 } 340 341 public void setPrintButton(JToggleButton printButton) { 342 this.printButton = printButton; 343 } 344 345 public JToggleButton getExportMicroReportButton() { 346 return exportMicroReportButton; 347 } 348 349 public void setExportMicroReportButton(JToggleButton exportMicroReportButton) { 350 this.exportMicroReportButton = exportMicroReportButton; 351 } 352 353 public JToggleButton getGraphicButton() { 354 return graphicButton; 355 } 356 357 public void setGraphicButton(JToggleButton graphicButton) { 358 this.graphicButton = graphicButton; 359 } 360 361 public JToggleButton getColorIndicator() { 362 return colorIndicator; 363 } 364 365 public void setColorIndicator(JToggleButton colorIndicator) { 366 this.colorIndicator = colorIndicator; 367 } 368 369 public JToggleButton getSearcher() { 370 return searcher; 371 } 372 373 public void setSearcher(JToggleButton searcher) { 374 this.searcher = searcher; 375 } 376 377 public JToggleButton getExcel() { 378 return excel; 379 } 380 381 public void setExcel(JToggleButton excel) { 382 this.excel = excel; 383 } 384 385 public JToggleButton getViewBtn() { 386 return viewBtn; 387 } 388 389 public void setViewBtn(JToggleButton viewBtn) { 390 this.viewBtn = viewBtn; 391 } 392 393 public JToggleButton getEditDimensionValueBtn() { 394 return editDimensionValueBtn; 395 } 396 397 public void setEditDimensionValueBtn(JToggleButton editDimensionValueBtn) { 398 this.editDimensionValueBtn = editDimensionValueBtn; 399 } 400 401 public JToggleButton getOrdenBtn() { 402 return ordenBtn; 403 } 404 405 public void setOrdenBtn(JToggleButton ordenBtn) { 406 this.ordenBtn = ordenBtn; 407 } 408 409 public void cubeExecuted(){ 410 setBtTotalsState(true); 411 setBtSizesState(false); 412 getBtTotals().setEnabled(true); 413 getBtTotals().setSelected(true); 414 getBtSizes().setEnabled(true); 415 getPrintButton().setEnabled(true); 416 getExportMicroReportButton().setEnabled(true); 417 getGraphicButton().setEnabled(true); 418 getColorIndicator().setEnabled(true); 419 getSearcher().setEnabled(true); 420 getExcel().setEnabled(true); 421 getViewBtn().setEnabled(true); 422 getEditDimensionValueBtn().setEnabled(true); 423 getOrdenBtn().setEnabled(true); 424 getBtRefresh().setEnabled(true); 425 getBtReportInfo().setEnabled(true); 426 } 427 428 public void chartcubeExecuted(){ 429 getBtTotals().setEnabled(false); 430 getBtTotals().setSelected(false); 431 getBtSizes().setEnabled(false); 432 getPrintButton().setEnabled(false); 433 getExportMicroReportButton().setEnabled(false); 434 getGraphicButton().setEnabled(false); 435 getColorIndicator().setEnabled(false); 436 getSearcher().setEnabled(false); 437 getExcel().setEnabled(false); 438 getViewBtn().setEnabled(false); 439 getEditDimensionValueBtn().setEnabled(false); 440 getOrdenBtn().setEnabled(false); 441 getBtRefresh().setEnabled(false); 442 getBtReportInfo().setEnabled(false); 443 } 444 445 public JToggleButton getBtRefresh() { 446 return btRefresh; 447 } 448 449 public void setBtRefresh(JToggleButton btRefresh) { 450 this.btRefresh = btRefresh; 451 } 452 453 public JToggleButton getBtReportInfo() { 454 return btReportInfo; 455 } 456 457 public void setBtReportInfo(JToggleButton btReportInfo) { 458 this.btReportInfo = btReportInfo; 459 } 460 } | Popular Tags |