001: package com.calipso.reportgenerator.userinterface;
002:
003: import com.calipso.reportgenerator.common.LanguageTraslator;
004: import com.calipso.reportgenerator.common.ShowExceptionMessageDialog;
005:
006: import javax.swing.*;
007: import java.net.URL;
008: import java.awt.event.ActionEvent;
009: import java.awt.event.ActionListener;
010: import java.awt.*;
011:
012: /**
013: *
014: * User: soliveri
015: * Date: Dec 10, 2003
016: * Time: 5:04:56 PM
017: *
018: */
019:
020: public class ReportViewerToolBar extends JToolBar implements
021: ActionListener {
022:
023: private PivotTableFrame pivotTableFrame;
024: private boolean btTotalsState;
025: private boolean btSizesState;
026: private JToggleButton btTotals;
027: private JToggleButton btSizes;
028: private JToggleButton printButton;
029: private JToggleButton exportMicroReportButton;
030: private JToggleButton graphicButton;
031: private JToggleButton colorIndicator;
032: private JToggleButton searcher;
033: private JToggleButton excel;
034: private JToggleButton viewBtn;
035: private JToggleButton editDimensionValueBtn;
036: private JToggleButton ordenBtn;
037: private JToggleButton btRefresh;
038: private JToggleButton btReportInfo;
039:
040: public ReportViewerToolBar() {
041: addToolBarButtons();
042: }
043:
044: public ReportViewerToolBar(int orientation) {
045: super (orientation);
046: addToolBarButtons();
047: }
048:
049: public ReportViewerToolBar(String name) {
050: super (name);
051: addToolBarButtons();
052: }
053:
054: public ReportViewerToolBar(String name, int orientation) {
055: super (name, orientation);
056: addToolBarButtons();
057: }
058:
059: private void addToolBarButtons() {
060: btTotals = (JToggleButton) makeNavigationButton("sum",
061: "TOTALS", LanguageTraslator.traslate("352"), "", true);
062:
063: add(btTotals);
064:
065: btSizes = (JToggleButton) makeNavigationButton("ruler",
066: "SIZES", LanguageTraslator.traslate("351"), "", true);
067: add(btSizes);
068:
069: printButton = (JToggleButton) makeNavigationButton("print",
070: "PRINT", LanguageTraslator.traslate("343"), "", true);
071:
072: add(printButton);
073:
074: exportMicroReportButton = (JToggleButton) makeNavigationButton(
075: "save", "EXPORT", LanguageTraslator.traslate("344"),
076: "", true);
077:
078: add(exportMicroReportButton);
079:
080: graphicButton = (JToggleButton) makeNavigationButton("chart",
081: "CHART", LanguageTraslator.traslate("345"), "", true);
082:
083: add(graphicButton);
084:
085: searcher = (JToggleButton) makeNavigationButton("search",
086: "SEARCH", LanguageTraslator.traslate("346"), "", true);
087:
088: add(searcher);
089:
090: excel = (JToggleButton) makeNavigationButton("excel", "EXCEL",
091: LanguageTraslator.traslate("347"), "", true);
092:
093: add(excel);
094:
095: colorIndicator = (JToggleButton) makeNavigationButton(
096: "semaphore", "SEMAPHORE", LanguageTraslator
097: .traslate("348"), "", true);
098:
099: add(colorIndicator);
100:
101: viewBtn = (JToggleButton) makeNavigationButton("profiles",
102: "PROFILES", LanguageTraslator.traslate("349"), "", true);
103:
104: add(viewBtn);
105:
106: editDimensionValueBtn = (JToggleButton) makeNavigationButton(
107: "ranking", "RANKING",
108: LanguageTraslator.traslate("350"), "", true);
109:
110: add(editDimensionValueBtn);
111:
112: ordenBtn = (JToggleButton) makeNavigationButton("order",
113: "ORDER", LanguageTraslator.traslate("388"), "", true);
114:
115: add(ordenBtn);
116:
117: btRefresh = (JToggleButton) makeNavigationButton("refresh",
118: "REFRESH", LanguageTraslator.traslate("387"), "", true);
119:
120: add(btRefresh);
121: btReportInfo = (JToggleButton) makeNavigationButton("infoicon",
122: "INFOICON", LanguageTraslator.traslate("530"), "", true);
123:
124: add(btReportInfo);
125:
126: }
127:
128: public void microReportLoaded() {
129: btTotalsState = true;
130: btTotals.setEnabled(true);
131: btTotals.setSelected(true);
132: btSizes.setEnabled(true);
133: printButton.setEnabled(true);
134: exportMicroReportButton.setEnabled(true);
135: graphicButton.setEnabled(true);
136: searcher.setEnabled(true);
137: excel.setEnabled(true);
138: colorIndicator.setEnabled(true);
139: viewBtn.setEnabled(true);
140: editDimensionValueBtn.setEnabled(true);
141: ordenBtn.setEnabled(true);
142: btRefresh.setEnabled(true);
143: btReportInfo.setEnabled(true);
144: }
145:
146: public void definitionExecuted() {
147: btTotals.setEnabled(false);
148: btSizes.setEnabled(false);
149: printButton.setEnabled(false);
150: exportMicroReportButton.setEnabled(false);
151: graphicButton.setEnabled(false);
152: searcher.setEnabled(false);
153: excel.setEnabled(false);
154: colorIndicator.setEnabled(false);
155: viewBtn.setEnabled(false);
156: editDimensionValueBtn.setEnabled(false);
157: ordenBtn.setEnabled(false);
158: btRefresh.setEnabled(false);
159: btReportInfo.setEnabled(false);
160: }
161:
162: public void drillDownExecuted() {
163: btTotals.setSelected(true);
164: btSizes.setSelected(false);
165: btTotalsState = true;
166: btSizesState = false;
167: }
168:
169: private Object makeNavigationButton(String imageName,
170: String actionCommand, String toolTipText, String altText,
171: boolean isToggle) {
172:
173: ClassLoader loader = this .getClass().getClassLoader();
174: URL url;
175: url = loader
176: .getResource("com/calipso/reportgenerator/userinterface/images/"
177: + imageName + ".gif");
178:
179: /*String imgLocation = com.calipso.reportgenerator.userinterface.images
180: reportGeneratorConfiguration.getImagesPath()
181: + "\\" + imageName
182: + ".gif"; */
183:
184: //Create and initialize the button.
185: Object button = null;
186: if (isToggle) {
187: button = new JToggleButton();
188: ((JToggleButton) button).setActionCommand(actionCommand);
189: ((JToggleButton) button).setToolTipText(toolTipText);
190: ((JToggleButton) button).addActionListener(this );
191: if (url != null) {
192: ((JToggleButton) button).setIcon(new ImageIcon(url,
193: altText));
194: //((JToggleButton)button).setMaximumSize(new Dimension(10,10));
195: if (imageName.equalsIgnoreCase("REFRESH")) {
196: ((JToggleButton) button)
197: .setSelectedIcon(new ImageIcon(
198: loader
199: .getResource("com/calipso/reportgenerator/userinterface/images/no"
200: + imageName
201: + ".gif"), altText));
202: }
203: } else {
204: ((JToggleButton) button).setText(altText);
205: }
206: } else {
207: button = new JButton();
208: ((JButton) button).setActionCommand(actionCommand);
209: ((JButton) button).setToolTipText(toolTipText);
210: ((JButton) button).addActionListener(this );
211: if (url != null) {
212: ((JButton) button).setIcon(new ImageIcon(url, altText));
213: } else {
214: ((JButton) button).setText(altText);
215: }
216: }
217:
218: return button;
219: }
220:
221: public void actionPerformed(ActionEvent e) {
222: try {
223: if (e.getActionCommand().equals("TOTALS")) {
224: if (btTotalsState == true) {
225: btTotals.setSelected(false);
226: btTotalsState = false;
227: } else {
228: btTotals.setSelected(true);
229: btTotalsState = true;
230: }
231: pivotTableFrame.getPivotTable()
232: .setPivoteTableSinTotales();
233: } else if (e.getActionCommand().equals("SIZES")) {
234: if (btSizesState == false) {
235: btSizes.setSelected(true);
236: btSizesState = true;
237: } else {
238: btSizes.setSelected(false);
239: btSizesState = false;
240: }
241: pivotTableFrame.maximizarActionPerformed();
242: pivotTableFrame.getPivotTable()
243: .maximizarActionPerformed();
244: } else if (e.getActionCommand().equals("PRINT")) {
245: printButton.setSelected(false);
246: pivotTableFrame.printPivotTable(this .getRootPane()
247: .getSize());
248: } else if (e.getActionCommand().equals("CHART")) {
249: graphicButton.setSelected(false);
250: pivotTableFrame.doGraphics();
251: } else if (e.getActionCommand().equals("SEARCH")) {
252: searcher.setSelected(false);
253: pivotTableFrame.getPivotTable().executeSearcher();
254: } else if (e.getActionCommand().equals("EXPORT")) {
255: exportMicroReportButton.setSelected(false);
256: pivotTableFrame.exportMicroReport();
257: } else if (e.getActionCommand().equals("EXCEL")) {
258: excel.setSelected(false);
259: pivotTableFrame.getPivotTable()
260: .executeExcelFormatSerializer();
261: } else if (e.getActionCommand().equals("SEMAPHORE")) {
262: colorIndicator.setSelected(false);
263: pivotTableFrame.getPivotTable().executeSemafore();
264: } else if (e.getActionCommand().equals("PROFILES")) {
265: viewBtn.setSelected(false);
266: pivotTableFrame.getPivotTable().executeViewBtn();
267: } else if (e.getActionCommand().equals("RANKING")) {
268: editDimensionValueBtn.setSelected(false);
269: pivotTableFrame.getPivotTable()
270: .executeEditDimensionValues();
271: } else if (e.getActionCommand().equals("ORDER")) {
272: ordenBtn.setSelected(false);
273: pivotTableFrame.getPivotTable()
274: .executeEditOrdenValues();
275: } else if (e.getActionCommand().equals("REFRESH")) {
276: pivotTableFrame.setAutoRefresh(!btRefresh.isSelected());
277: } else if (e.getActionCommand().equals("INFOICON")) {
278: btReportInfo.setSelected(false);
279: pivotTableFrame.launchInfoPage();
280: }
281:
282: } catch (Exception e1) {
283: ShowExceptionMessageDialog.initExceptionDialogMessage(
284: LanguageTraslator.traslate("263"), e1);
285: } finally {
286: setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
287: }
288: }
289:
290: public PivotTableFrame getPivotTableFrame() {
291: return pivotTableFrame;
292: }
293:
294: public void setPivotTableFrame(PivotTableFrame pivotTableFrame) {
295: this .pivotTableFrame = pivotTableFrame;
296: }
297:
298: public boolean isBtTotalsState() {
299: return btTotalsState;
300: }
301:
302: public void setBtTotalsState(boolean btTotalsState) {
303: this .btTotalsState = btTotalsState;
304: }
305:
306: public boolean isBtSizesState() {
307: return btSizesState;
308: }
309:
310: public void setBtSizesState(boolean btSizesState) {
311: this .btSizesState = btSizesState;
312: }
313:
314: public JToggleButton getBtTotals() {
315: return btTotals;
316: }
317:
318: public void setBtTotals(JToggleButton btTotals) {
319: this .btTotals = btTotals;
320: }
321:
322: public JToggleButton getBtSizes() {
323: return btSizes;
324: }
325:
326: public void setBtSizes(JToggleButton btSizes) {
327: this .btSizes = btSizes;
328: }
329:
330: public JToggleButton getPrintButton() {
331: return printButton;
332: }
333:
334: public void setPrintButton(JToggleButton printButton) {
335: this .printButton = printButton;
336: }
337:
338: public JToggleButton getExportMicroReportButton() {
339: return exportMicroReportButton;
340: }
341:
342: public void setExportMicroReportButton(
343: JToggleButton exportMicroReportButton) {
344: this .exportMicroReportButton = exportMicroReportButton;
345: }
346:
347: public JToggleButton getGraphicButton() {
348: return graphicButton;
349: }
350:
351: public void setGraphicButton(JToggleButton graphicButton) {
352: this .graphicButton = graphicButton;
353: }
354:
355: public JToggleButton getColorIndicator() {
356: return colorIndicator;
357: }
358:
359: public void setColorIndicator(JToggleButton colorIndicator) {
360: this .colorIndicator = colorIndicator;
361: }
362:
363: public JToggleButton getSearcher() {
364: return searcher;
365: }
366:
367: public void setSearcher(JToggleButton searcher) {
368: this .searcher = searcher;
369: }
370:
371: public JToggleButton getExcel() {
372: return excel;
373: }
374:
375: public void setExcel(JToggleButton excel) {
376: this .excel = excel;
377: }
378:
379: public JToggleButton getViewBtn() {
380: return viewBtn;
381: }
382:
383: public void setViewBtn(JToggleButton viewBtn) {
384: this .viewBtn = viewBtn;
385: }
386:
387: public JToggleButton getEditDimensionValueBtn() {
388: return editDimensionValueBtn;
389: }
390:
391: public void setEditDimensionValueBtn(
392: JToggleButton editDimensionValueBtn) {
393: this .editDimensionValueBtn = editDimensionValueBtn;
394: }
395:
396: public JToggleButton getOrdenBtn() {
397: return ordenBtn;
398: }
399:
400: public void setOrdenBtn(JToggleButton ordenBtn) {
401: this .ordenBtn = ordenBtn;
402: }
403:
404: public void cubeExecuted() {
405: setBtTotalsState(true);
406: setBtSizesState(false);
407: getBtTotals().setEnabled(true);
408: getBtTotals().setSelected(true);
409: getBtSizes().setEnabled(true);
410: getPrintButton().setEnabled(true);
411: getExportMicroReportButton().setEnabled(true);
412: getGraphicButton().setEnabled(true);
413: getColorIndicator().setEnabled(true);
414: getSearcher().setEnabled(true);
415: getExcel().setEnabled(true);
416: getViewBtn().setEnabled(true);
417: getEditDimensionValueBtn().setEnabled(true);
418: getOrdenBtn().setEnabled(true);
419: getBtRefresh().setEnabled(true);
420: getBtReportInfo().setEnabled(true);
421: }
422:
423: public void chartcubeExecuted() {
424: getBtTotals().setEnabled(false);
425: getBtTotals().setSelected(false);
426: getBtSizes().setEnabled(false);
427: getPrintButton().setEnabled(false);
428: getExportMicroReportButton().setEnabled(false);
429: getGraphicButton().setEnabled(false);
430: getColorIndicator().setEnabled(false);
431: getSearcher().setEnabled(false);
432: getExcel().setEnabled(false);
433: getViewBtn().setEnabled(false);
434: getEditDimensionValueBtn().setEnabled(false);
435: getOrdenBtn().setEnabled(false);
436: getBtRefresh().setEnabled(false);
437: getBtReportInfo().setEnabled(false);
438: }
439:
440: public JToggleButton getBtRefresh() {
441: return btRefresh;
442: }
443:
444: public void setBtRefresh(JToggleButton btRefresh) {
445: this .btRefresh = btRefresh;
446: }
447:
448: public JToggleButton getBtReportInfo() {
449: return btReportInfo;
450: }
451:
452: public void setBtReportInfo(JToggleButton btReportInfo) {
453: this.btReportInfo = btReportInfo;
454: }
455: }
|