Source Code Cross Referenced for ReportViewer.java in  » Report » jmagallanes-1.0 » com » calipso » reportgenerator » userinterface » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » jmagallanes 1.0 » com.calipso.reportgenerator.userinterface 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        package com.calipso.reportgenerator.userinterface;
0002:
0003:        import com.calipso.reportgenerator.reportdefinitions.types.ReportDefinitionReportTypeType;
0004:        import com.calipso.reportgenerator.reportdefinitions.ReportView;
0005:        import com.calipso.reportgenerator.reportdefinitions.ReportDefinition;
0006:        import com.calipso.reportgenerator.reportdefinitions.Roles;
0007:        import com.calipso.reportgenerator.userinterface.dinamicchart.ChartPivotTable;
0008:        import com.calipso.reportgenerator.common.*;
0009:        import com.calipso.reportgenerator.client.ReportManagerService;
0010:
0011:        import javax.swing.*;
0012:        import java.awt.*;
0013:        import java.awt.event.ActionListener;
0014:        import java.awt.event.ActionEvent;
0015:        import java.util.*;
0016:        import java.io.*;
0017:        import java.net.URL;
0018:        import java.net.InetAddress;
0019:        import java.net.UnknownHostException;
0020:
0021:        import com.calipso.reportgenerator.common.InfoException;
0022:        import com.calipso.reportgenerator.usermanager.UserManagerFrame;
0023:        import com.calipso.xmleditor.XmlEditorConnectionPane;
0024:
0025:        /**
0026:         * Visualizador de reportes
0027:         */
0028:        public class ReportViewer extends JFrame implements  IReportFrame {
0029:
0030:            public static final String defaultRol = "ANY";
0031:            private ReportViewerToolBar reportViewerToolBar;
0032:            private JPanel mainPanel;
0033:            private JPanel toolBarPanel;
0034:            private JPanel reportPanel;
0035:            private JMenu menu;
0036:            private JMenuBar menuBar;
0037:            private JComboBox comboReports;
0038:            private JComboBox comboProfiles;
0039:            private JButton executeNewReportBtn;
0040:            private PivotTableFrame pivotTableFrame;
0041:            private JLabel reportsLabel;
0042:            private int btnWIDTH = 90;
0043:            private int btnHEIGTH = 45;
0044:            private IReportManager reportManager;
0045:            private String userID;
0046:            private String userData;
0047:            private String reportDefinitionID;
0048:            private String reportViewID;
0049:            private ReportGeneratorConfiguration reportGeneratorConfiguration;
0050:            private String propertiesPath = "";
0051:            private boolean visibleActions;
0052:            private Map params;
0053:            private JToolBar jToolBar;
0054:            private JToggleButton btSizes;
0055:            private JMenuItem miXmlExporter;
0056:            private JToggleButton btTotals;
0057:            private boolean btTotalsState;
0058:            private boolean btSizesState;
0059:            private JToggleButton printButton;
0060:            private JToggleButton exportMicroReportButton;
0061:            private JToggleButton graphicButton;
0062:            private JToggleButton semaforo;
0063:            private JToggleButton searcher;
0064:            private JToggleButton excel;
0065:            private JToggleButton viewBtn;
0066:            private JToggleButton editDimensionValueBtn;
0067:            private JToggleButton ordenBtn;
0068:            private JPanel actionsToolBarPanel;
0069:            private JPanel comboReportPanel;
0070:            private JMenu mnuReportTools;
0071:            private JMenuItem mnuItemGenerateReportFromSQL;
0072:            private JMenuItem mnuItemGenerateReportView;
0073:            private JMenuItem mnuItemGenerateReportLayout;
0074:            private JMenuItem mnuEditReportDefinition;
0075:            private JMenuItem mnuEditReportSourceDefinition;
0076:            private JMenuItem mnuUsersMannager;
0077:            private XmlEditorConnectionPane connectionPane;
0078:
0079:            /**
0080:             * Inicializa el visualizador con un usuario
0081:             * @param userID
0082:             * @param visibleActions Indica si se muesttran las acciones
0083:             * @throws InfoException
0084:             */
0085:            public ReportViewer(String userID, boolean visibleActions)
0086:                    throws InfoException {
0087:                this .userID = userID;
0088:                this .visibleActions = visibleActions;
0089:                initViewer();
0090:            }
0091:
0092:            public ReportViewer(String userID, String reportDefinitionID,
0093:                    boolean visibleActions, Map params) throws InfoException {
0094:                this .userID = userID;
0095:                this .reportDefinitionID = reportDefinitionID;
0096:                this .visibleActions = visibleActions;
0097:                this .params = params;
0098:                initViewer();
0099:                executeInitialReport();
0100:            }
0101:
0102:            public ReportViewer(String userID, String microReportFileName,
0103:                    boolean inServer, String propertiesPath,
0104:                    IReportManager reportManager, boolean visibleActions,
0105:                    Map params) throws InfoException {
0106:                this .userID = userID;
0107:                this .propertiesPath = propertiesPath;
0108:                this .reportManager = reportManager;
0109:                this .visibleActions = visibleActions;
0110:                this .params = params;
0111:                this .reportDefinitionID = "";
0112:                this .reportViewID = "";
0113:                initViewer();
0114:                //if(!inServer){
0115:                executeMicroReport(microReportFileName, inServer);
0116:                //}else{
0117:                // executeMicroReport(microReportFileName);
0118:                //}
0119:            }
0120:
0121:            public ReportViewer(String userID, String reportDefinitionID,
0122:                    String reportViewID, boolean visibleActions, Map params)
0123:                    throws InfoException {
0124:                this .userID = userID;
0125:                this .reportDefinitionID = reportDefinitionID;
0126:                this .reportViewID = reportViewID;
0127:                this .visibleActions = visibleActions;
0128:                this .params = params;
0129:                initViewer();
0130:                executeInitialReport();
0131:            }
0132:
0133:            public ReportViewer(String userID, String reportDefinitionID,
0134:                    String reportViewID, String propertiesPath,
0135:                    boolean visibleActions, Map params) throws InfoException {
0136:                this .userID = userID;
0137:                this .reportDefinitionID = reportDefinitionID;
0138:                this .reportViewID = reportViewID;
0139:                this .propertiesPath = propertiesPath;
0140:                this .visibleActions = visibleActions;
0141:                this .params = params;
0142:                initViewer();
0143:                executeInitialReport();
0144:            }
0145:
0146:            public ReportViewer(String userID, String reportDefinitionID,
0147:                    String reportViewID, String propertiesPath,
0148:                    IReportManager reportManager, boolean visibleActions,
0149:                    Map params) throws InfoException {
0150:                this .userID = userID;
0151:                this .reportDefinitionID = reportDefinitionID;
0152:                this .reportViewID = reportViewID;
0153:                this .propertiesPath = propertiesPath;
0154:                this .reportManager = reportManager;
0155:                this .visibleActions = visibleActions;
0156:                this .params = params;
0157:                initViewer();
0158:                executeInitialReport();
0159:            }
0160:
0161:            public ReportViewer(String userID, String reportDefinitionID,
0162:                    String reportViewID, String propertiesPath,
0163:                    IReportManager reportManager,
0164:                    ReportGeneratorConfiguration configuration,
0165:                    boolean visibleActions, Map params) throws InfoException {
0166:                this .userID = userID;
0167:                this .reportDefinitionID = reportDefinitionID;
0168:                this .reportViewID = reportViewID;
0169:                this .propertiesPath = propertiesPath;
0170:                this .reportManager = reportManager;
0171:                this .reportGeneratorConfiguration = configuration;
0172:                this .visibleActions = visibleActions;
0173:                this .params = params;
0174:                initViewer();
0175:                executeInitialReport();
0176:            }
0177:
0178:            /**
0179:             * Inicializa el Visualizador
0180:             * @throws InfoException
0181:             */
0182:            protected void initViewer() throws InfoException {
0183:                Image icon = null;
0184:                try {
0185:                    icon = getReportGeneratorConfiguration().getImage("icon");
0186:                    /*if(icon == null){
0187:                      URL url = this.getClass().getClassLoader().getResource("com/calipso/reportgenerator/userinterface/images/" + getReportGeneratorConfiguration().getFrameworkPlatform() + "/icon.jpg");
0188:                      icon = Toolkit.getDefaultToolkit().getImage(url);
0189:                    }*/
0190:                } catch (Exception e) {
0191:                    e.printStackTrace();
0192:                }
0193:                if (icon != null) {
0194:                    setIconImage(icon);
0195:                }
0196:                setTitle(LanguageTraslator.traslate("313") + " - "
0197:                        + LanguageTraslator.traslate("141") + ": "
0198:                        + getUserData(userID));
0199:                launchSplash();
0200:                loadComboReports();
0201:                initComponents();
0202:                logClientData("Loggin");
0203:            }
0204:
0205:            private void logClientData(String log) throws InfoException {
0206:                InetAddress addr = null;
0207:                try {
0208:                    addr = InetAddress.getLocalHost();
0209:                } catch (UnknownHostException e) {
0210:                    e.printStackTrace();
0211:                }
0212:                getReportManager().logClientData(
0213:                        System.getProperty("user.name") + " - "
0214:                                + addr.getHostName() + " - "
0215:                                + addr.getHostAddress() + " - User: " + userID
0216:                                + " - " + log);
0217:            }
0218:
0219:            private void launchSplash() throws InfoException {
0220:                String splashPath = getApplicationSplashPath();
0221:                //if(splashPath != null) {
0222:                ApplicationSplash splash = new ApplicationSplash(this ,
0223:                        splashPath, getReportGeneratorConfiguration()
0224:                                .getFrameworkPlatform());
0225:                splash.showSplashScreen();
0226:                //}
0227:            }
0228:
0229:            private String getApplicationSplashPath() throws InfoException {
0230:                String splashPath = null;
0231:                splashPath = getReportGeneratorConfiguration().getImagePath(
0232:                        "SPLASH");
0233:                return splashPath;
0234:            }
0235:
0236:            /**
0237:             * Si está indicado el reporte lo ejecuta
0238:             */
0239:            private void executeInitialReport() throws InfoException {
0240:                if (!getUserID().equals("")
0241:                        && ((!reportViewID.equals("")) || (!reportDefinitionID
0242:                                .equals("")))) {
0243:                    try {
0244:                        executeReport(reportDefinitionID, reportViewID, params);//executeReport(reportDefinitionID,"");
0245:                    } finally {
0246:                        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
0247:                    }
0248:                }
0249:            }
0250:
0251:            /**
0252:             * Carga el combo de reportes disponibles
0253:             * @throws InfoException
0254:             */
0255:            private void loadComboReports() throws InfoException {
0256:                if (visibleActions) {
0257:                    DefaultComboBoxModel model = new DefaultComboBoxModel(
0258:                            getComboModelVector());
0259:                    getComboReports().setModel(model);
0260:                    updateComboProfiles();
0261:                }
0262:            }
0263:
0264:            private void updateComboProfiles() {
0265:                DefaultComboBoxModel model = null;
0266:                try {
0267:                    model = new DefaultComboBoxModel(
0268:                            getComboProfilesModelVector());
0269:                    getComboProfiles().setModel(model);
0270:                } catch (InfoException e) {
0271:                    ShowExceptionMessageDialog.initExceptionDialogMessage(
0272:                            LanguageTraslator.traslate("369"), e);
0273:                }
0274:
0275:            }
0276:
0277:            private Vector getComboProfilesModelVector() throws InfoException {
0278:                Vector result = new Vector();
0279:                Map definitionsMap;
0280:                DefinitionInfo definitionInfo;
0281:                Map.Entry entry;
0282:                Object selectedItem = getComboReports().getSelectedItem();
0283:                if (selectedItem != null) {
0284:                    String id = ((DefinitionInfo) getComboReports()
0285:                            .getSelectedItem()).getId();
0286:                    definitionsMap = getReportManager().getReportViews(id,
0287:                            userID);
0288:                    definitionInfo = new DefinitionInfo("", LanguageTraslator
0289:                            .traslate("184"));
0290:                    result.add(definitionInfo);
0291:                    if (definitionsMap != null) {
0292:                        Iterator iterator = definitionsMap.entrySet()
0293:                                .iterator();
0294:                        while (iterator.hasNext()) {
0295:                            entry = (Map.Entry) iterator.next();
0296:                            definitionInfo = (DefinitionInfo) entry.getValue();
0297:                            result.add(definitionInfo);
0298:                        }
0299:                    }
0300:                }
0301:                return result;
0302:            }
0303:
0304:            /**
0305:             * Inicializa los componentes
0306:             */
0307:            private void initComponents() throws InfoException {
0308:                getContentPane().setLayout(new BorderLayout());
0309:                this .setJMenuBar(createMenu());
0310:                getContentPane().add(createMainPanel());//,BorderLayout.CENTER);
0311:
0312:                pack();
0313:                java.awt.Dimension screenSize = java.awt.Toolkit
0314:                        .getDefaultToolkit().getScreenSize();
0315:                setSize(new java.awt.Dimension(800, 550));
0316:                setLocation((screenSize.width - 800) / 2,
0317:                        (screenSize.height - 550) / 2);
0318:            }
0319:
0320:            private ReportViewerToolBar createReportViewerToolBar() {
0321:                if (reportViewerToolBar == null) {
0322:                    reportViewerToolBar = new ReportViewerToolBar();
0323:                }
0324:                return reportViewerToolBar;
0325:            }
0326:
0327:            private Object makeNavigationButton(String imageName,
0328:                    String actionCommand, String toolTipText, String altText,
0329:                    boolean isToggle) {
0330:
0331:                ClassLoader loader = this .getClass().getClassLoader();
0332:                URL url = loader
0333:                        .getResource("com/calipso/reportgenerator/userinterface/images/"
0334:                                + imageName + ".gif");
0335:
0336:                /*String imgLocation =  com.calipso.reportgenerator.userinterface.images
0337:                                      reportGeneratorConfiguration.getImagesPath()
0338:                                     + "\\" + imageName
0339:                                     + ".gif";         */
0340:
0341:                //Create and initialize the button.
0342:                Object button = null;
0343:                if (isToggle) {
0344:                    button = new JToggleButton();
0345:                    ((JToggleButton) button).setActionCommand(actionCommand);
0346:                    ((JToggleButton) button).setToolTipText(toolTipText);
0347:                    if (url != null) {
0348:                        ((JToggleButton) button).setIcon(new ImageIcon(url,
0349:                                altText));
0350:                    } else {
0351:                        ((JToggleButton) button).setText(altText);
0352:                    }
0353:                } else {
0354:                    button = new JButton();
0355:                    ((JButton) button).setActionCommand(actionCommand);
0356:                    ((JButton) button).setToolTipText(toolTipText);
0357:                    if (url != null) {
0358:                        ((JButton) button).setIcon(new ImageIcon(url, altText));
0359:                    } else {
0360:                        ((JButton) button).setText(altText);
0361:                    }
0362:                }
0363:
0364:                return button;
0365:            }
0366:
0367:            /**
0368:             * Crea el menu
0369:             * @return
0370:             */
0371:            private JMenuBar createMenu() {
0372:                menuBar = new JMenuBar();
0373:                if (visibleActions) {
0374:                    menu = new JMenu(LanguageTraslator.traslate("294"));
0375:                    JMenuItem menuItem;
0376:                    menuItem = new JMenuItem(LanguageTraslator.traslate("249"));
0377:                    menuItem.addActionListener(new ActionListener() {
0378:                        public void actionPerformed(ActionEvent e) {
0379:                            try {
0380:                                registerDefinitions();
0381:                            } catch (Exception e1) {
0382:                                ShowExceptionMessageDialog
0383:                                        .initExceptionDialogMessage(
0384:                                                LanguageTraslator
0385:                                                        .traslate("257"), e1);
0386:                            }
0387:
0388:                        }
0389:                    });
0390:                    menu.add(menuItem);
0391:
0392:                    menuItem = new JMenuItem(LanguageTraslator.traslate("248"));
0393:                    menuItem.addActionListener(new ActionListener() {
0394:                        public void actionPerformed(ActionEvent e) {
0395:                            try {
0396:                                clearRepository();
0397:                            } catch (Exception e1) {
0398:                                ShowExceptionMessageDialog
0399:                                        .initExceptionDialogMessage(
0400:                                                LanguageTraslator
0401:                                                        .traslate("257"), e1);
0402:                            }
0403:
0404:                        }
0405:                    });
0406:                    menu.add(menuItem);
0407:
0408:                    miXmlExporter = new JMenuItem(LanguageTraslator
0409:                            .traslate("354"));
0410:                    miXmlExporter.addActionListener(new ActionListener() {
0411:                        public void actionPerformed(ActionEvent e) {
0412:                            try {
0413:                                exportToXml();
0414:                            } catch (Exception e1) {
0415:                                ShowExceptionMessageDialog
0416:                                        .initExceptionDialogMessage(
0417:                                                LanguageTraslator
0418:                                                        .traslate("263"), e1);
0419:                            }
0420:                        }
0421:                    });
0422:                    menu.add(miXmlExporter);
0423:
0424:                    menuItem = new JMenuItem(LanguageTraslator.traslate("264"));
0425:                    menuItem.addActionListener(new ActionListener() {
0426:                        public void actionPerformed(ActionEvent e) {
0427:                            try {
0428:                                loadMicroReport();
0429:                            } catch (Exception e1) {
0430:                                ShowExceptionMessageDialog
0431:                                        .initExceptionDialogMessage(
0432:                                                LanguageTraslator
0433:                                                        .traslate("263"), e1);
0434:                            }
0435:                        }
0436:                    });
0437:                    menu.add(menuItem);
0438:
0439:                    menu.add(new JSeparator());
0440:
0441:                    menuItem = new JMenuItem(LanguageTraslator.traslate("144"));
0442:                    menuItem.addActionListener(new ActionListener() {
0443:                        public void actionPerformed(ActionEvent e) {
0444:                            try {
0445:                                saveLastView();
0446:                                dispose();
0447:                                System.exit(0);
0448:                            } catch (Exception e1) {
0449:                                ShowExceptionMessageDialog
0450:                                        .initExceptionDialogMessage(
0451:                                                LanguageTraslator
0452:                                                        .traslate("263"), e1);
0453:                            }
0454:                        }
0455:                    });
0456:                    menu.add(menuItem);
0457:                    menuBar.add(menu);
0458:                    if (!reportGeneratorConfiguration.getIsDistributed()) {
0459:                        menuBar.add(CreateReportToolMenu());
0460:                    }
0461:                    menuBar.add(CreateHelpMenu());
0462:                }
0463:                return menuBar;
0464:            }
0465:
0466:            private JMenu CreateReportToolMenu() {
0467:                mnuReportTools = new JMenu(LanguageTraslator.traslate("535"));
0468:
0469:                mnuItemGenerateReportFromSQL = new JMenuItem(LanguageTraslator
0470:                        .traslate("560"));
0471:                mnuItemGenerateReportFromSQL
0472:                        .addActionListener(new ActionListener() {
0473:                            public void actionPerformed(ActionEvent e) {
0474:                                try {
0475:                                    reportFromSQL();
0476:                                } catch (Exception e1) {
0477:                                    ShowExceptionMessageDialog
0478:                                            .initExceptionDialogMessage(
0479:                                                    LanguageTraslator
0480:                                                            .traslate("536"),
0481:                                                    e1);
0482:                                }
0483:                            }
0484:
0485:                        });
0486:
0487:                mnuReportTools.add(mnuItemGenerateReportFromSQL);
0488:
0489:                mnuItemGenerateReportView = new JMenuItem(LanguageTraslator
0490:                        .traslate("561"));
0491:                mnuItemGenerateReportView
0492:                        .addActionListener(new ActionListener() {
0493:                            public void actionPerformed(ActionEvent e) {
0494:                                try {
0495:                                    createReportFrame();
0496:                                } catch (Exception e1) {
0497:                                    ShowExceptionMessageDialog
0498:                                            .initExceptionDialogMessage(
0499:                                                    LanguageTraslator
0500:                                                            .traslate("536"),
0501:                                                    e1);
0502:                                }
0503:                            }
0504:
0505:                        });
0506:                //mnuReportTools.add(mnuItemGenerateReportView);
0507:
0508:                mnuItemGenerateReportLayout = new JMenuItem(LanguageTraslator
0509:                        .traslate("562"));
0510:                mnuItemGenerateReportLayout
0511:                        .addActionListener(new ActionListener() {
0512:                            public void actionPerformed(ActionEvent e) {
0513:                                try {
0514:                                    createReportLayout();
0515:                                } catch (Exception e1) {
0516:                                    ShowExceptionMessageDialog
0517:                                            .initExceptionDialogMessage(
0518:                                                    LanguageTraslator
0519:                                                            .traslate("536"),
0520:                                                    e1);
0521:                                }
0522:                            }
0523:                        });
0524:
0525:                mnuReportTools.add(mnuItemGenerateReportLayout);
0526:                mnuReportTools.setMnemonic("g".charAt(0));
0527:
0528:                mnuEditReportDefinition = new JMenuItem(LanguageTraslator
0529:                        .traslate("537"));
0530:                mnuEditReportDefinition.addActionListener(new ActionListener() {
0531:                    public void actionPerformed(ActionEvent e) {
0532:                        try {
0533:                            if (!reportDefinitionID.equalsIgnoreCase("")) {
0534:                                editReportDefinition();
0535:                            } else {
0536:                                throw new InfoException(LanguageTraslator
0537:                                        .traslate("557"));
0538:                            }
0539:                        } catch (Exception e1) {
0540:                            ShowExceptionMessageDialog
0541:                                    .initExceptionDialogMessage(
0542:                                            LanguageTraslator.traslate("539"),
0543:                                            e1);
0544:                        }
0545:                    }
0546:
0547:                });
0548:                mnuReportTools.add(mnuEditReportDefinition);
0549:
0550:                mnuEditReportSourceDefinition = new JMenuItem(LanguageTraslator
0551:                        .traslate("538"));
0552:                mnuEditReportSourceDefinition
0553:                        .addActionListener(new ActionListener() {
0554:                            public void actionPerformed(ActionEvent e) {
0555:                                try {
0556:                                    if (!reportDefinitionID
0557:                                            .equalsIgnoreCase("")) {
0558:                                        editReportSourceDefinition();
0559:                                    } else {
0560:                                        throw new InfoException(
0561:                                                LanguageTraslator
0562:                                                        .traslate("557"));
0563:                                    }
0564:
0565:                                } catch (Exception e1) {
0566:                                    ShowExceptionMessageDialog
0567:                                            .initExceptionDialogMessage(
0568:                                                    LanguageTraslator
0569:                                                            .traslate("540"),
0570:                                                    e1);
0571:                                }
0572:                            }
0573:                        });
0574:                mnuReportTools.add(mnuEditReportSourceDefinition);
0575:
0576:                mnuUsersMannager = new JMenuItem(LanguageTraslator
0577:                        .traslate("587"));
0578:                mnuUsersMannager.addActionListener(new ActionListener() {
0579:                    public void actionPerformed(ActionEvent e) {
0580:                        try {
0581:                            if (userID.equalsIgnoreCase("root")
0582:                                    && (!reportGeneratorConfiguration
0583:                                            .getIsDistributed())) {
0584:                                editUserManager();
0585:                            } else {
0586:                                throw new InfoException(LanguageTraslator
0587:                                        .traslate("589"));
0588:                            }
0589:                        } catch (Exception e1) {
0590:                            ShowExceptionMessageDialog
0591:                                    .initExceptionDialogMessage(
0592:                                            LanguageTraslator.traslate("588"),
0593:                                            e1);
0594:                        }
0595:                    }
0596:                });
0597:                mnuReportTools.add(mnuUsersMannager);
0598:
0599:                return mnuReportTools;
0600:            }
0601:
0602:            private void editUserManager() throws InfoException {
0603:                UserManagerFrame userManagerFrame = new UserManagerFrame(true,
0604:                        getReportGeneratorConfiguration());
0605:                userManagerFrame.setVisible(true);
0606:            }
0607:
0608:            private void reportFromSQL() throws InfoException {
0609:                ReportFromSQL reportFromSQL = new ReportFromSQL(this ,
0610:                        reportGeneratorConfiguration);
0611:                reportFromSQL.createReportFrame();
0612:            }
0613:
0614:            private void editReportDefinition() throws InfoException {
0615:                DefinitionEditor.reportDefinitionEditor(reportDefinitionID,
0616:                        getReportGeneratorConfiguration());
0617:            }
0618:
0619:            private void editReportSourceDefinition() throws InfoException {
0620:                DefinitionEditor.reportSourceDefinitionEditor(
0621:                        reportDefinitionID, getReportGeneratorConfiguration());
0622:            }
0623:
0624:            private JMenu CreateHelpMenu() {
0625:                JMenu menuHelp;
0626:                menuHelp = new JMenu();
0627:                menuHelp = new JMenu(LanguageTraslator.traslate("383"));
0628:                JMenuItem menuItem;
0629:                menuItem = new JMenuItem(LanguageTraslator.traslate("384"));
0630:                menuItem.addActionListener(new ActionListener() {
0631:                    public void actionPerformed(ActionEvent e) {
0632:                        JOptionPane.showMessageDialog(null, LanguageTraslator
0633:                                .traslate("313")
0634:                                + " - "
0635:                                + LanguageTraslator.traslate("385")
0636:                                + " " + VersionProperties.versionNumber);
0637:                        //showExceptionMessageDialog. initExceptionDialogMessage()
0638:                    }
0639:                });
0640:                menuHelp.add(menuItem);
0641:                return menuHelp;
0642:            }
0643:
0644:            /**
0645:             * Permite grabar la última vista del reporte para tenerla posteriormente disponible
0646:             */
0647:            private void saveLastView() {
0648:                if ((pivotTableFrame != null)
0649:                        && (pivotTableFrame.getPivotTable() != null)
0650:                        && (pivotTableFrame.getReportResult().getReportSpec()
0651:                                .getDefinitionId().equals(reportDefinitionID))) {
0652:                    int result = JOptionPane.showConfirmDialog(this ,
0653:                            LanguageTraslator.traslate("370"),
0654:                            LanguageTraslator.traslate("109"),
0655:                            JOptionPane.YES_NO_OPTION,
0656:                            JOptionPane.QUESTION_MESSAGE);
0657:                    if (result == JOptionPane.YES_OPTION) {
0658:                        try {
0659:                            pivotTableFrame.getPivotTable()
0660:                                    .executeAplicationView();
0661:                        } catch (InfoException e) {
0662:                            ShowExceptionMessageDialog
0663:                                    .initExceptionDialogMessage(
0664:                                            LanguageTraslator.traslate("371"),
0665:                                            e);
0666:                        }
0667:                    }
0668:                }
0669:            }
0670:
0671:            private void exportToXml() {
0672:                try {
0673:                    JFileChooser fileChooser = new JFileChooser();
0674:                    int result = fileChooser.showSaveDialog(this );
0675:                    if (result == JFileChooser.APPROVE_OPTION) {
0676:                        File file = fileChooser.getSelectedFile();
0677:                        FileWriter fileWriter = new FileWriter(file);
0678:                        String xml = getReportManager().getXML(
0679:                                pivotTableFrame.getReportHandle());
0680:                        BufferedWriter bufferedWriter = new BufferedWriter(
0681:                                fileWriter);
0682:                        char[] cbuff = new char[xml.length()];
0683:                        for (int i = 0; i < cbuff.length; i++) {
0684:                            cbuff[i] = xml.charAt(i);
0685:                        }
0686:                        bufferedWriter.write(cbuff);
0687:                        bufferedWriter.close();
0688:                        fileWriter.close();
0689:                    }
0690:                } catch (Exception e) {
0691:                    ShowExceptionMessageDialog.initExceptionDialogMessage(
0692:                            LanguageTraslator.traslate("195"), e);
0693:                }
0694:            }
0695:
0696:            /**
0697:             * Borra los repositorios
0698:             * @throws InfoException
0699:             */
0700:            private void clearRepository() throws InfoException {
0701:                getReportManager().deleteAllDefinitions();
0702:                updateReportComboBox();
0703:            }
0704:
0705:            /**
0706:             * Registra las definiciones
0707:             *
0708:             */
0709:            private void registerDefinitions() throws InfoException {
0710:                try {
0711:                    Vector vector = getReportManager()
0712:                            .registerReportDefinitions(new Vector());
0713:                    showExceptionsFrom(vector);
0714:                } catch (Exception e1) {
0715:                    ShowExceptionMessageDialog.initExceptionDialogMessage(
0716:                            LanguageTraslator.traslate("257"), e1);
0717:                }
0718:                try {
0719:                    Vector vector = getReportManager()
0720:                            .registerReportSourceDefinitions(new Vector());
0721:                    showExceptionsFrom(vector);
0722:                } catch (Exception e1) {
0723:                    ShowExceptionMessageDialog.initExceptionDialogMessage(
0724:                            LanguageTraslator.traslate("257"), e1);
0725:                }
0726:                try {
0727:                    Vector vector = getReportManager().registerReportViews(
0728:                            new Vector());
0729:                    showExceptionsFrom(vector);
0730:                } catch (Exception e1) {
0731:                    ShowExceptionMessageDialog.initExceptionDialogMessage(
0732:                            LanguageTraslator.traslate("257"), e1);
0733:                }
0734:                updateReportComboBox();
0735:            }
0736:
0737:            private void showExceptionsFrom(Vector vector) {
0738:                if (vector.size() > 0) {
0739:                    for (int i = 0; i < vector.size(); i++) {
0740:                        ShowExceptionMessageDialog.initExceptionDialogMessage(
0741:                                LanguageTraslator.traslate("257"),
0742:                                (Exception) vector.elementAt(i));
0743:                    }
0744:                }
0745:            }
0746:
0747:            /**
0748:             * Carga un MicroReport
0749:             */
0750:            private void loadMicroReport() {
0751:                JFileChooser fileChooser = new JFileChooser();
0752:                fileChooser.setMultiSelectionEnabled(true);
0753:                int mode = fileChooser.showDialog(this , LanguageTraslator
0754:                        .traslate("270"));
0755:                if (mode == JFileChooser.APPROVE_OPTION) {
0756:                    File file = fileChooser.getSelectedFile();
0757:                    executeMicroReport(file.getAbsolutePath(), false);
0758:                }
0759:            }
0760:
0761:            private void executeMicroReport(String fileName,
0762:                    boolean serverLocated) {
0763:                try {
0764:                    reportViewerToolBar = createReportViewerToolBar();
0765:                    reportViewerToolBar.microReportLoaded();
0766:                    MicroReport micro;
0767:                    if (!serverLocated) {
0768:                        micro = new MicroReport(fileName,
0769:                                getReportGeneratorConfiguration());
0770:                    } else {
0771:                        micro = getReportManager().getMicroReport(fileName);
0772:                    }
0773:                    String[] roles = getRoles(micro.getReportDefinition()); //TODO pasar esto urgente al ReportManager
0774:                    if (!getReportManager().validateRol(
0775:                            roles,
0776:                            getUserID(),
0777:                            getReportGeneratorConfiguration()
0778:                                    .getRolsRepositoryPath())) {
0779:                        throw new InfoException(LanguageTraslator
0780:                                .traslate("396"));
0781:                    }
0782:                    pivotTableFrame = new PivotTableFrame(this , micro,
0783:                            getReportManager(), getUserID(),
0784:                            getReportGeneratorConfiguration());
0785:                    reportViewerToolBar.setPivotTableFrame(pivotTableFrame);
0786:                    reportPanel.setLayout(new GridLayout(1, 1));
0787:                    reportPanel.removeAll();
0788:                    reportPanel.add(pivotTableFrame.getCenterPanel());
0789:                    validate();
0790:                    reportPanel.repaint();
0791:                } catch (Exception e) {
0792:                    ShowExceptionMessageDialog.initExceptionDialogMessage(
0793:                            LanguageTraslator.traslate("269"), e);
0794:                }
0795:
0796:            }
0797:
0798:            private String[] getRoles(ReportDefinition reportDefinition) {
0799:                Roles roles = reportDefinition.getRoles();
0800:                if (roles == null) {
0801:                    return new String[] { defaultRol };
0802:                }
0803:                int rolCount = roles.getRolCount();
0804:                ArrayList rolesNames = new ArrayList();
0805:                for (int i = 0; i < rolCount; i++) {
0806:                    if (roles.getRol(i) != null
0807:                            && roles.getRol(i).getName() != null
0808:                            && !roles.getRol(i).getName().equalsIgnoreCase("")) {
0809:                        rolesNames.add(roles.getRol(i).getName());
0810:                    }
0811:                }
0812:                if (rolesNames.size() == 0) {
0813:                    rolesNames.add(defaultRol);
0814:                }
0815:                String[] rolesArray = fillArray(rolesNames);
0816:                return rolesArray;
0817:            }
0818:
0819:            private String[] fillArray(ArrayList rolesNames) {
0820:                Iterator iterator = rolesNames.iterator();
0821:                String[] result = new String[rolesNames.size()];
0822:                for (int i = 0; iterator.hasNext(); i++) {
0823:                    result[i] = iterator.next().toString().toUpperCase();
0824:                }
0825:                return result;
0826:            }
0827:
0828:            /**
0829:             * Acualiza en como de reportes disponibles
0830:             * @throws InfoException
0831:             */
0832:            private void updateReportComboBox() throws InfoException {
0833:                comboReports.removeAllItems();
0834:                loadComboReports();
0835:                comboReports.repaint();
0836:            }
0837:
0838:            /**
0839:             * Crea el panel central
0840:             * @return
0841:             */
0842:            private JPanel createMainPanel() throws InfoException {
0843:                mainPanel = new JPanel();
0844:                mainPanel.setLayout(new BorderLayout());
0845:                mainPanel.add(createToolbarPanel(), BorderLayout.NORTH);
0846:                mainPanel.add(createPivotTablePanel(), BorderLayout.CENTER);
0847:                return mainPanel;
0848:            }
0849:
0850:            private JPanel createActionsToolbarPanel() {
0851:                actionsToolBarPanel = new JPanel();
0852:                //if (visibleActions){
0853:                FlowLayout layout = new FlowLayout(FlowLayout.LEFT);
0854:                layout.setHgap(1);
0855:                actionsToolBarPanel.setPreferredSize(new Dimension(300, 40));
0856:                actionsToolBarPanel.setLayout(layout);
0857:                actionsToolBarPanel.add(createReportViewerToolBar());
0858:                reportViewerToolBar.definitionExecuted();
0859:                //}
0860:                return actionsToolBarPanel;
0861:            }
0862:
0863:            private JPanel createPivotTablePanel() throws InfoException {
0864:                Toolkit tk;
0865:                Image image = null;
0866:                tk = Toolkit.getDefaultToolkit();
0867:                try {
0868:                    image = getReportGeneratorConfiguration().getImage(
0869:                            "backgroundreportviewer");
0870:                    /*String imagePath = getReportGeneratorConfiguration().getImagePath("BACKGROUNDREPORTVIEWER");
0871:                    if(imagePath!=null){
0872:                      image = tk.getImage(imagePath);
0873:                    }
0874:                    if(image == null){
0875:                      //Viene de jar
0876:                      URL url = this.getClass().getClassLoader().getResource("com/calipso/reportgenerator/userinterface/images/" + getReportGeneratorConfiguration().getFrameworkPlatform() + "/" + "BACKGROUNDREPORTVIEWER.jpg");
0877:                      image = tk.getImage(url);
0878:                    }*/
0879:                } catch (Exception e) {
0880:                    ReportManagerLogger.debug(
0881:                            LanguageTraslator.traslate("318"), e);
0882:                }
0883:                reportPanel = new ImagePanel(image);
0884:                //    reportPanel = new JPanel();
0885:                return reportPanel;
0886:            }
0887:
0888:            /**
0889:             * Crea el panel de barra de herramientas
0890:             * @return
0891:             */
0892:            private JPanel createToolbarPanel() {
0893:                toolBarPanel = new JPanel(new BorderLayout());
0894:                toolBarPanel.add(createActionsToolbarPanel(),
0895:                        BorderLayout.NORTH);
0896:                toolBarPanel.add(createComboReportPanel(), BorderLayout.SOUTH);
0897:                return toolBarPanel;
0898:            }
0899:
0900:            private JPanel createComboReportPanel() {
0901:                comboReportPanel = new JPanel();
0902:                if (visibleActions) {
0903:                    comboReportPanel.setPreferredSize(new Dimension(300, 30));
0904:                    comboReportPanel.setLayout(new javax.swing.BoxLayout(
0905:                            comboReportPanel, javax.swing.BoxLayout.X_AXIS));
0906:                    comboReportPanel
0907:                            .setBorder(new javax.swing.border.TitledBorder(""));
0908:                    comboReportPanel.add(createNewReportLabel());
0909:                    comboReportPanel.add(createNewReportComboBox());
0910:                    comboReportPanel.add(createProfilesComboBox());
0911:                    comboReportPanel.add(createNewReportBtn());
0912:                }
0913:                return comboReportPanel;
0914:            }
0915:
0916:            private Component createProfilesComboBox() {
0917:                getComboProfiles().setBounds(240, 22, 20, 10);
0918:                return getComboProfiles();
0919:            }
0920:
0921:            /**
0922:             * Crea el combo de reportes
0923:             * @return
0924:             */
0925:            private Component createNewReportComboBox() {
0926:                getComboReports().setBounds(100, 22, 140, 10);
0927:                return getComboReports();
0928:            }
0929:
0930:            /**
0931:             * Crea el boton de ejecución de un nuevo reporte
0932:             * @return
0933:             */
0934:            private Component createNewReportBtn() {
0935:                executeNewReportBtn = (JButton) makeNavigationButton("play",
0936:                        "EJECUTAR", LanguageTraslator.traslate("353"), "",
0937:                        false);
0938:                executeNewReportBtn.setMaximumSize(new java.awt.Dimension(
0939:                        btnWIDTH, btnHEIGTH));
0940:                executeNewReportBtn.setMinimumSize(new java.awt.Dimension(
0941:                        btnWIDTH, btnHEIGTH));
0942:                executeNewReportBtn.setPreferredSize(new java.awt.Dimension(
0943:                        btnWIDTH, btnHEIGTH));
0944:                executeNewReportBtn.addActionListener(new ActionListener() {
0945:                    public void actionPerformed(ActionEvent e) {
0946:                        try {
0947:                            saveLastView();
0948:                            executeReport(((DefinitionInfo) comboReports
0949:                                    .getSelectedItem()).getId(),
0950:                                    ((DefinitionInfo) comboProfiles
0951:                                            .getSelectedItem()).getId(),
0952:                                    new HashMap());
0953:                            updateComboProfiles();
0954:                            reportDefinitionID = ((DefinitionInfo) comboReports
0955:                                    .getSelectedItem()).getId();
0956:                        } catch (Exception ex) {
0957:                            ShowExceptionMessageDialog
0958:                                    .initExceptionDialogMessage(
0959:                                            LanguageTraslator.traslate("293"),
0960:                                            ex);
0961:                        } finally {
0962:                            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
0963:                        }
0964:                    }
0965:                });
0966:                return executeNewReportBtn;
0967:            }
0968:
0969:            /**
0970:             * Crea la etiqueta de nuevo reporte
0971:             * @return
0972:             */
0973:            private Component createNewReportLabel() {
0974:                reportsLabel = new JLabel();
0975:                reportsLabel.setText(LanguageTraslator.traslate("290"));
0976:                reportsLabel.setMaximumSize(new java.awt.Dimension(btnWIDTH,
0977:                        btnHEIGTH));
0978:                reportsLabel.setMinimumSize(new java.awt.Dimension(btnWIDTH,
0979:                        btnHEIGTH));
0980:                reportsLabel.setPreferredSize(new java.awt.Dimension(btnWIDTH,
0981:                        btnHEIGTH));
0982:                return reportsLabel;
0983:            }
0984:
0985:            /**
0986:             * Devuelve el combo de reportes
0987:             * @return
0988:             */
0989:            public JComboBox getComboReports() {
0990:                if (comboReports == null) {
0991:                    comboReports = new JComboBox();
0992:                    comboReports.addActionListener(new ActionListener() {
0993:                        public void actionPerformed(ActionEvent e) {
0994:                            updateComboProfiles();
0995:                        }
0996:                    });
0997:                }
0998:                return comboReports;
0999:            }
1000:
1001:            public JComboBox getComboProfiles() {
1002:                if (comboProfiles == null) {
1003:                    comboProfiles = new JComboBox();
1004:                }
1005:                return comboProfiles;
1006:            }
1007:
1008:            /**
1009:             * Ejecute el reporte indicado
1010:             */
1011:            private void executeReport(String reportDefinitionId,
1012:                    String viewId, Map existingParams) throws InfoException {
1013:                ReportSpec reportSpec = getReportManager().getReportSpec(
1014:                        reportDefinitionId);
1015:                String[] roles = getRoles(getReportManager()
1016:                        .getReportDefinitionFromID(reportDefinitionId));
1017:                if (!getReportManager().validateRol(
1018:                        roles,
1019:                        getUserID(),
1020:                        getReportGeneratorConfiguration()
1021:                                .getRolsRepositoryPath())) {
1022:                    throw new InfoException(LanguageTraslator.traslate("396"));
1023:                }
1024:                logClientData(reportDefinitionId);
1025:                params = UPDialog.getParams(this , reportSpec,
1026:                        reportGeneratorConfiguration, existingParams);
1027:                reportSpec.setPosParamValues(params);
1028:                if (params != null) {
1029:                    if (reportSpec.getReportType().getType() == ReportDefinitionReportTypeType.CUBE_TYPE) {
1030:                        setCursor(new Cursor(Cursor.WAIT_CURSOR));
1031:                        if ((!reportDefinitionId.equals(""))
1032:                                && (!getUserID().equals(""))) {
1033:                            pivotTableFrame = null;
1034:                            if (!viewId.equals("")) {
1035:                                pivotTableFrame = new PivotTableFrame(this ,
1036:                                        reportDefinitionId, getReportManager(),
1037:                                        getParams(), getUserID(), viewId,
1038:                                        getReportGeneratorConfiguration());
1039:                            } else if (!reportViewID.equals("")) {
1040:                                pivotTableFrame = new PivotTableFrame(this ,
1041:                                        reportDefinitionId, getReportManager(),
1042:                                        getParams(), getUserID(), reportViewID,
1043:                                        getReportGeneratorConfiguration());
1044:                            } else if (!reportDefinitionId.equals("")) {
1045:                                String defaultReportView = getReportManager()
1046:                                        .getDefaultReportViewId(
1047:                                                reportDefinitionId, getUserID());
1048:                                if (defaultReportView == null
1049:                                        || defaultReportView.equals("")) {
1050:                                    pivotTableFrame = new PivotTableFrame(this ,
1051:                                            reportDefinitionId,
1052:                                            getReportManager(), getParams(),
1053:                                            getUserID(),
1054:                                            getReportGeneratorConfiguration());
1055:                                } else {
1056:                                    pivotTableFrame = new PivotTableFrame(this ,
1057:                                            reportDefinitionId,
1058:                                            getReportManager(), getParams(),
1059:                                            getUserID(), defaultReportView,
1060:                                            getReportGeneratorConfiguration());
1061:                                }
1062:                            }
1063:                            String tittle = pivotTableFrame.getReportResult()
1064:                                    .getReportSpec().getTitle();
1065:                            setTitle(LanguageTraslator.traslate("313") + " - "
1066:                                    + LanguageTraslator.traslate("141") + ": "
1067:                                    + getUserData(userID) + " - " + tittle);
1068:
1069:                            reportViewerToolBar
1070:                                    .setPivotTableFrame(pivotTableFrame);
1071:                            if (pivotTableFrame != null) {
1072:                                JPanel pnlCenter = pivotTableFrame
1073:                                        .getCenterPanel();
1074:                                reportPanel.setLayout(new GridLayout(1, 1));
1075:                                reportPanel.removeAll();
1076:                                reportPanel.add(pnlCenter);
1077:                                validate();
1078:                                reportPanel.repaint();
1079:                            }
1080:                        }
1081:                        reportViewerToolBar.cubeExecuted();
1082:                        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
1083:                    } else if (reportSpec.getReportType().getType() == ReportDefinitionReportTypeType.CHARTCUBE_TYPE) {
1084:                        setCursor(new Cursor(Cursor.WAIT_CURSOR));
1085:                        ChartPivotTable chartPivotTable = new ChartPivotTable(
1086:                                reportSpec, getReportManager(), getParams(),
1087:                                userID, reportDefinitionId, this );
1088:                        chartPivotTable.paintComponents(true);
1089:                        reportPanel.setLayout(new GridLayout(1, 1));
1090:                        reportPanel.removeAll();
1091:                        reportPanel.add(chartPivotTable, BorderLayout.CENTER);
1092:                        validate();
1093:                        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
1094:                        reportViewerToolBar.chartcubeExecuted();
1095:                    } else if (reportSpec.getReportType().getType() == ReportDefinitionReportTypeType.STATICSQL_TYPE) {
1096:                        try {
1097:                            ReportUI reportUI = null;
1098:                            String reportView = !viewId.equalsIgnoreCase("") ? viewId
1099:                                    : reportViewID;
1100:                            ReportView view = null;
1101:                            try {
1102:                                view = getReportManager().getReportViewFromID(
1103:                                        reportView,
1104:                                        reportSpec.getDefinitionId(),
1105:                                        getUserID());
1106:                            } catch (Exception e) {
1107:                                //No obtiene ninguna view
1108:                            }
1109:                            reportUI = new ReportUI(null, reportSpec,
1110:                                    getReportManager(),
1111:                                    getReportGeneratorConfiguration(), view,
1112:                                    this .getSize());
1113:                            reportUI.show();
1114:                        } catch (Exception e) {
1115:                            throw new InfoException(LanguageTraslator
1116:                                    .traslate("222"), e);
1117:                        }
1118:                    } else {
1119:                        try {
1120:                            ReportResult reportResult = getReportManager()
1121:                                    .ExecReportQuery(
1122:                                            reportSpec.getDefinitionId(),
1123:                                            getParams());
1124:                            ReportUI reportUI = null;
1125:                            String reportView = !viewId.equalsIgnoreCase("") ? viewId
1126:                                    : reportViewID;
1127:                            ReportView view = null;
1128:                            if (reportView != null
1129:                                    && !reportView.equalsIgnoreCase("")) {
1130:                                view = getReportManager().getReportViewFromID(
1131:                                        reportView,
1132:                                        reportSpec.getDefinitionId(),
1133:                                        getUserID());
1134:                            }
1135:                            reportUI = new ReportUI(reportResult, reportResult
1136:                                    .getReportSpec(), getReportManager(),
1137:                                    getReportGeneratorConfiguration(), view,
1138:                                    this .getSize());
1139:                            if (reportUI != null) {
1140:                                reportUI.show();
1141:                            }
1142:                        } catch (Exception e) {
1143:                            throw new InfoException(LanguageTraslator
1144:                                    .traslate("222"), e);
1145:                        }
1146:                    }
1147:                }
1148:            }
1149:
1150:            /**
1151:             * Devuelve el usuario
1152:             * @return
1153:             */
1154:            private String getUserID() {
1155:                if (userID.equals("")) {
1156:                    LoginFrame loginFrame = new LoginFrame("user",
1157:                            new ReportLoginValidator());
1158:                    loginFrame.login();
1159:                    if (loginFrame.getLoginResult() == 0) {
1160:                        userID = loginFrame.getUserNameText().getText();
1161:                    }
1162:                }
1163:                return userID;
1164:            }
1165:
1166:            public String getUserData(String userID) throws InfoException {
1167:                if (userData == null) {
1168:                    userData = "";
1169:                    Collection dataCollection = getReportManager().getUserData(
1170:                            userID,
1171:                            getReportGeneratorConfiguration()
1172:                                    .getUserDataRepositoryPath());
1173:                    if (dataCollection != null) {
1174:                        Iterator data = dataCollection.iterator();
1175:                        while (data.hasNext()) {
1176:                            if (!userData.equalsIgnoreCase("")) {
1177:                                userData += ", ";
1178:                            }
1179:                            userData += data.next().toString();
1180:                        }
1181:                    }
1182:                }
1183:                return userData;
1184:            }
1185:
1186:            /**
1187:             * Devuelve un vector con los reportes
1188:             * @return
1189:             * @throws InfoException
1190:             */
1191:            private Vector getComboModelVector() throws InfoException {
1192:                Vector result = new Vector();
1193:                Map definitionsMap;
1194:                DefinitionInfo definitionInfo;
1195:                Map.Entry entry;
1196:                definitionsMap = getReportManager().getReportDefinitions();
1197:                if (definitionsMap != null) {
1198:                    Iterator iterator = definitionsMap.entrySet().iterator();
1199:                    while (iterator.hasNext()) {
1200:                        entry = (Map.Entry) iterator.next();
1201:                        definitionInfo = (DefinitionInfo) entry.getValue();
1202:                        result.add(definitionInfo);
1203:                    }
1204:                }
1205:                return result;
1206:            }
1207:
1208:            /**
1209:             * Instancia un reportmanager service y lo devuelve
1210:             * @return
1211:             */
1212:            public IReportManager getReportManager() {
1213:                if (reportManager == null) {
1214:                    try {
1215:                        String distributedHost = (String) getParams().get(
1216:                                "DistributedHost");
1217:                        reportManager = ReportManagerService
1218:                                .getReportManagerService("", null,
1219:                                        distributedHost);
1220:                    } catch (Exception e) {
1221:                        ShowExceptionMessageDialog.initExceptionDialogMessage(
1222:                                LanguageTraslator.traslate("223"), e);
1223:                        System.exit(3);
1224:                    }
1225:                }
1226:                return reportManager;
1227:            }
1228:
1229:            /**
1230:             * Devuelve un reportGeneratorConfigurator
1231:             * @return
1232:             * @throws InfoException
1233:             */
1234:            public ReportGeneratorConfiguration getReportGeneratorConfiguration()
1235:                    throws InfoException {
1236:                if (reportGeneratorConfiguration == null) {
1237:                    reportGeneratorConfiguration = new ReportGeneratorConfiguration(
1238:                            ReportGeneratorConfiguration
1239:                                    .getConfiguration(propertiesPath));
1240:                }
1241:                return reportGeneratorConfiguration;
1242:            }
1243:
1244:            public JPanel getMainPanel() {
1245:                return mainPanel;
1246:            }
1247:
1248:            private Map getParams() {
1249:                if (params == null) {
1250:                    params = new HashMap();
1251:                }
1252:                return params;
1253:            }
1254:
1255:            public JToggleButton getSizesButton() {
1256:                return btSizes;
1257:            }
1258:
1259:            public void setBtSizesState(boolean state) {
1260:                btSizesState = state;
1261:            }
1262:
1263:            public ReportViewerToolBar getToolBar() {
1264:                return reportViewerToolBar;
1265:            }
1266:
1267:            public Frame owner() {
1268:                return this ;
1269:            }
1270:
1271:            public JPanel getToolBarPanel() {
1272:                if (toolBarPanel == null) {
1273:                    createToolbarPanel();
1274:                }
1275:                return toolBarPanel;
1276:            }
1277:
1278:            public JPanel getActionsBarPanel() {
1279:                if (actionsToolBarPanel == null) {
1280:                    createActionsToolbarPanel();
1281:                }
1282:                return actionsToolBarPanel;
1283:            }
1284:
1285:            public void applyView(String reportViewId) {
1286:                this .reportViewID = reportViewId;
1287:                try {
1288:                    pivotTableFrame.getPivotTable().applyView(reportViewID);
1289:                } catch (Exception ex) {
1290:                    ShowExceptionMessageDialog.initExceptionDialogMessage(
1291:                            LanguageTraslator.traslate("293"), ex);
1292:                } finally {
1293:                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
1294:                }
1295:            }
1296:
1297:            private void createReportFrame() {
1298:            }
1299:
1300:            private void createReportLayout() throws InfoException {
1301:                if (!reportDefinitionID.equalsIgnoreCase("")) {
1302:                    ReportLayoutGenerator reportLayoutGenerator = new ReportLayoutGenerator(
1303:                            getReportManager().getReportDefinitionFromID(
1304:                                    reportDefinitionID),
1305:                            getReportGeneratorConfiguration(),
1306:                            getReportManager(), this );
1307:                    reportLayoutGenerator.generateReportLayout();
1308:                } else {
1309:                    throw new InfoException(LanguageTraslator.traslate("557"));
1310:                }
1311:            }
1312:
1313:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.