Source Code Cross Referenced for AplicationView.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) 


001:        package com.calipso.reportgenerator.userinterface;
002:
003:        import com.calipso.reportgenerator.common.*;
004:        import com.calipso.reportgenerator.reportdefinitions.ReportView;
005:        import javax.swing.tree.DefaultMutableTreeNode;
006:        import javax.swing.tree.DefaultTreeModel;
007:        import javax.swing.*;
008:        import javax.swing.event.TreeSelectionListener;
009:        import javax.swing.event.TreeSelectionEvent;
010:        import java.awt.*;
011:        import java.awt.event.ActionListener;
012:        import java.awt.event.ActionEvent;
013:        import java.awt.event.WindowAdapter;
014:        import java.awt.event.WindowEvent;
015:        import java.util.Map;
016:        import java.io.*;
017:        import com.calipso.reportgenerator.common.InfoException;
018:        import org.exolab.castor.xml.Unmarshaller;
019:        import org.exolab.castor.xml.Marshaller;
020:
021:        public class AplicationView extends JDialog {
022:            private PivotTable pivotTable;
023:            private File file;
024:            private JLabel usrLabel;
025:            private MicroReport microReport;
026:
027:            public AplicationView(Frame parent, boolean modal,
028:                    PivotTable pivotTable, MicroReport microReport)
029:                    throws InfoException {
030:                super (parent, modal);
031:                Image icon = pivotTable.getPivotTableFrame()
032:                        .getReportGeneratorConfiguration().getImage("icon");
033:                if (icon != null) {
034:                    parent.setIconImage(icon);
035:                }
036:                this .microReport = microReport;
037:                this .pivotTable = pivotTable;
038:                try {
039:                    initComponents();
040:                } catch (Exception e) {
041:                    ShowExceptionMessageDialog.initExceptionDialogMessage(
042:                            LanguageTraslator.traslate("106"), e);
043:                }
044:
045:            }
046:
047:            private boolean getIsReadOnly() {
048:                return (microReport != null);
049:            }
050:
051:            private void initComponents() throws InfoException {
052:                centerPanel = new JPanel();
053:                centerScrollPanel = new JScrollPane();
054:                northPanel = new JPanel();
055:                southPanel = new JPanel();
056:                closeConteinerBtnPanel = new JPanel();
057:                closeBtn = new JButton();
058:                conteinerSouthPanel = new JPanel();
059:                viewTextFieldName = new JTextField();
060:                northSeparatorPanel = new JPanel();
061:                usrLabel = new JLabel();
062:                boxBtnPanel = new JPanel();
063:                addBtn = new JButton();
064:                removeBtn = new JButton();
065:                applyBtn = new JButton();
066:                defaultBtn = new JButton();
067:                export = new JButton();
068:                importar = new JButton();
069:                setTitle(LanguageTraslator.traslate("175"));
070:                setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
071:                setName("viewDaialog");
072:                setResizable(false);
073:                addWindowListener(new WindowAdapter() {
074:                    public void windowClosing(WindowEvent evt) {
075:                        closeDialog();
076:                    }
077:                });
078:
079:                centerPanel.setLayout(new BorderLayout());
080:
081:                centerScrollPanel.setViewportView(createTreeView());
082:
083:                centerPanel.add(centerScrollPanel, BorderLayout.CENTER);
084:
085:                getContentPane().add(centerPanel, BorderLayout.CENTER);
086:
087:                getContentPane().add(northPanel, BorderLayout.NORTH);
088:
089:                southPanel.setLayout(new BorderLayout());
090:
091:                closeConteinerBtnPanel.setLayout(new BorderLayout());
092:
093:                usrLabel.setText(LanguageTraslator.traslate("232"));
094:                usrLabel.setPreferredSize(new Dimension(50, 15));
095:
096:                closeBtn.setText(LanguageTraslator.traslate("132"));
097:                closeBtn.setPreferredSize(new Dimension(85, 15));
098:
099:                closeConteinerBtnPanel.add(closeBtn, BorderLayout.CENTER);
100:
101:                southPanel.add(closeConteinerBtnPanel, BorderLayout.EAST);
102:                southPanel.add(usrLabel, BorderLayout.WEST);
103:
104:                conteinerSouthPanel.setLayout(new BorderLayout());
105:
106:                conteinerSouthPanel.add(viewTextFieldName, BorderLayout.CENTER);
107:
108:                northSeparatorPanel.setPreferredSize(new Dimension(0, 1));
109:                conteinerSouthPanel
110:                        .add(northSeparatorPanel, BorderLayout.NORTH);
111:
112:                southPanel.add(conteinerSouthPanel, BorderLayout.CENTER);
113:
114:                getContentPane().add(southPanel, BorderLayout.SOUTH);
115:
116:                boxBtnPanel.setLayout(new BoxLayout(boxBtnPanel,
117:                        BoxLayout.Y_AXIS));
118:
119:                addBtn.setText(LanguageTraslator.traslate("179"));
120:                addBtn.setToolTipText(LanguageTraslator.traslate("179"));
121:                addBtn.setMaximumSize(new Dimension(85, 26));
122:                addBtn.setMinimumSize(new Dimension(85, 26));
123:                addBtn.setPreferredSize(new Dimension(85, 26));
124:                boxBtnPanel.add(addBtn);
125:
126:                applyBtn.setText(LanguageTraslator.traslate("181"));
127:                applyBtn.setToolTipText(LanguageTraslator.traslate("181"));
128:                applyBtn.setMaximumSize(new Dimension(85, 26));
129:                applyBtn.setMinimumSize(new Dimension(85, 26));
130:                applyBtn.setPreferredSize(new Dimension(85, 26));
131:                boxBtnPanel.add(applyBtn);
132:
133:                defaultBtn.setText(LanguageTraslator.traslate("184"));
134:                defaultBtn.setMaximumSize(new Dimension(85, 26));
135:                defaultBtn.setMinimumSize(new Dimension(85, 26));
136:                defaultBtn.setPreferredSize(new Dimension(85, 26));
137:                boxBtnPanel.add(defaultBtn);
138:
139:                export.setText(LanguageTraslator.traslate("182"));
140:                export.setMaximumSize(new Dimension(85, 26));
141:                export.setMinimumSize(new Dimension(85, 26));
142:                export.setPreferredSize(new Dimension(85, 26));
143:                boxBtnPanel.add(export);
144:
145:                importar.setText(LanguageTraslator.traslate("183"));
146:                importar.setMaximumSize(new Dimension(85, 26));
147:                importar.setMinimumSize(new Dimension(85, 26));
148:                importar.setPreferredSize(new Dimension(85, 26));
149:                boxBtnPanel.add(importar);
150:
151:                removeBtn.setText(LanguageTraslator.traslate("180"));
152:                removeBtn.setMaximumSize(new Dimension(85, 26));
153:                removeBtn.setMinimumSize(new Dimension(85, 26));
154:                removeBtn.setPreferredSize(new Dimension(85, 26));
155:                boxBtnPanel.add(removeBtn);
156:
157:                getContentPane().add(boxBtnPanel, BorderLayout.EAST);
158:
159:                closeBtn.addActionListener(new ActionListener() {
160:                    public void actionPerformed(ActionEvent evt) {
161:                        closeBtnActionPerformed();
162:                    }
163:                });
164:
165:                addBtn.addActionListener(new ActionListener() {
166:                    public void actionPerformed(ActionEvent e) {
167:                        try {
168:                            if (AcctionsValid()) {
169:                                addView();
170:                            }
171:                        } catch (Exception ex) {
172:                            ShowExceptionMessageDialog
173:                                    .initExceptionDialogMessage(
174:                                            LanguageTraslator.traslate("215"),
175:                                            ex);
176:                        }
177:                    }
178:                });
179:
180:                treeViews.addTreeSelectionListener(new TreeSelectionListener() {
181:                    public void valueChanged(TreeSelectionEvent e) {
182:                        setCurrent(e);
183:                    }
184:                });
185:
186:                removeBtn.addActionListener(new ActionListener() {
187:                    public void actionPerformed(ActionEvent e) {
188:                        try {
189:                            if (AcctionsValid()) {
190:                                removeView();
191:                            }
192:                        } catch (Exception ex) {
193:                            ShowExceptionMessageDialog
194:                                    .initExceptionDialogMessage(
195:                                            LanguageTraslator.traslate("258"),
196:                                            ex);
197:                        }
198:
199:                    }
200:                });
201:                defaultBtn.addActionListener(new ActionListener() {
202:                    public void actionPerformed(ActionEvent e) {
203:                        try {
204:                            if (AcctionsValid()) {
205:                                defaultView();
206:                            }
207:                        } catch (Exception ex) {
208:                            ShowExceptionMessageDialog
209:                                    .initExceptionDialogMessage(
210:                                            LanguageTraslator.traslate("259"),
211:                                            ex);
212:                        }
213:
214:                    }
215:                });
216:
217:                applyBtn.addActionListener(new ActionListener() {
218:                    public void actionPerformed(ActionEvent e) {
219:                        try {
220:                            applyView();
221:                        } catch (Exception ex) {
222:                            ShowExceptionMessageDialog
223:                                    .initExceptionDialogMessage(
224:                                            LanguageTraslator.traslate("216"),
225:                                            ex);
226:                        }
227:
228:                    }
229:                });
230:
231:                export.addActionListener(new ActionListener() {
232:                    public void actionPerformed(ActionEvent e) {
233:                        exportXML();
234:                    }
235:                });
236:
237:                importar.addActionListener(new ActionListener() {
238:                    public void actionPerformed(ActionEvent e) {
239:                        if (AcctionsValid()) {
240:                            importXML();
241:                        }
242:                    }
243:                });
244:                pack();
245:                Dimension screenSize = Toolkit.getDefaultToolkit()
246:                        .getScreenSize();
247:                setSize(new java.awt.Dimension(398, 300));
248:                setLocation((screenSize.width - 398) / 2,
249:                        (screenSize.height - 300) / 2);
250:            }
251:
252:            private boolean AcctionsValid() {
253:                if (getIsReadOnly()) {
254:                    ShowExceptionMessageDialog
255:                            .initExceptionDialogMessage(LanguageTraslator
256:                                    .traslate("216"), new InfoException(
257:                                    LanguageTraslator.traslate("272")));
258:                    return false;
259:                }
260:                return true;
261:            }
262:
263:            private void importXML() {
264:                JFileChooser fileChooser = new JFileChooser();
265:                fileChooser.setMultiSelectionEnabled(true);
266:                ExtensionFilter filter = new ExtensionFilter(".xml", "*.xml");
267:                fileChooser.addChoosableFileFilter(filter);
268:                fileChooser.setFileFilter(filter);
269:                int mode = fileChooser.showDialog(this , LanguageTraslator
270:                        .traslate("185"));
271:                if (mode == JFileChooser.APPROVE_OPTION) {
272:                    file = fileChooser.getSelectedFile();
273:                    try {
274:                        ReportView reportView = (ReportView) Unmarshaller
275:                                .unmarshal(ReportView.class, new FileReader(
276:                                        file));
277:                        getReportManager().saveReportView(reportView);
278:                    } catch (Exception e) {
279:                        ShowExceptionMessageDialog.initExceptionDialogMessage(
280:                                LanguageTraslator.traslate("218"), e);
281:                    }
282:                }
283:            }
284:
285:            private void exportXML() {
286:                if (!treeViews.isSelectionEmpty() || current.getLevel() > 0) {
287:                    if (viewTextFieldName.getText().compareToIgnoreCase("") != 0) {
288:                        JFileChooser fileChooser = new JFileChooser();
289:                        fileChooser.setMultiSelectionEnabled(true);
290:                        ExtensionFilter filter = new ExtensionFilter(".xml",
291:                                "*.xml");
292:                        fileChooser.addChoosableFileFilter(filter);
293:                        fileChooser.setFileFilter(filter);
294:                        int mode = fileChooser.showSaveDialog(this );
295:                        if (mode == JFileChooser.APPROVE_OPTION) {
296:                            file = fileChooser.getSelectedFile();
297:                            try {
298:                                FileWriter writer = new FileWriter(file);
299:                                ReportView reportView = pivotTable
300:                                        .getTableProperties().getReportView(
301:                                                file.getName(),
302:                                                pivotTable.getPivotTableFrame()
303:                                                        .getUserID(),
304:                                                viewTextFieldName.getText());
305:                                reportView.setDescription(viewTextFieldName
306:                                        .getText());
307:                                Marshaller.marshal(reportView, writer);
308:                                writer.flush();
309:                                writer.close();
310:                            } catch (Exception e) {
311:                                ShowExceptionMessageDialog
312:                                        .initExceptionDialogMessage(
313:                                                LanguageTraslator
314:                                                        .traslate("217"), e);
315:                            }
316:                        }
317:                    }
318:                } else {
319:                    JOptionPane.showMessageDialog(this , LanguageTraslator
320:                            .traslate("334"),
321:                            LanguageTraslator.traslate("335"),
322:                            JOptionPane.ERROR_MESSAGE);
323:                }
324:            }
325:
326:            private void applyView() throws InfoException {
327:                if (current.getLevel() > 0) {
328:                    ReportView reportView = null;
329:                    PivotTableProperties pivoteTableProperties = pivotTable
330:                            .getTableProperties();
331:                    pivoteTableProperties.setConditionManager(pivotTable
332:                            .getColorConditionManager());
333:                    if (getIsReadOnly()) {
334:                        reportView = (ReportView) microReport.getViews().get(
335:                                ((DefinitionInfo) current.getUserObject())
336:                                        .getId());
337:                    } else {
338:                        reportView = getReportManager().getReportViewFromID(
339:                                ((DefinitionInfo) current.getUserObject())
340:                                        .getId(),
341:                                getReportResult().getReportSpec()
342:                                        .getDefinitionId(),
343:                                pivotTable.getPivotTableFrame().getUserID());
344:                    }
345:                    pivoteTableProperties.assignFromView(reportView);
346:                    pivotTable.getPivotTableFrame().buildNewQuery(
347:                            pivoteTableProperties);
348:                }
349:            }
350:
351:            private void defaultView() throws InfoException {
352:                if (current != null) {
353:                    if (current.getLevel() != 0) {
354:                        Map views = getReportManager().getReportViews(
355:                                getReportResult().getReportSpec()
356:                                        .getDefinitionId(),
357:                                pivotTable.getPivotTableFrame().getUserID());
358:                        DefinitionInfo definitionInfo = (DefinitionInfo) views
359:                                .get(current.getUserObject().toString()
360:                                        .toUpperCase());
361:                        getReportManager().assingDefaultView(
362:                                definitionInfo.getId(),
363:                                getReportResult().getReportSpec()
364:                                        .getDefinitionId(),
365:                                pivotTable.getPivotTableFrame().getUserID());
366:                    } else {
367:                        JOptionPane.showMessageDialog(this , LanguageTraslator
368:                                .traslate("334"), LanguageTraslator
369:                                .traslate("335"), JOptionPane.ERROR_MESSAGE);
370:                    }
371:                } else {
372:                    JOptionPane.showMessageDialog(this , LanguageTraslator
373:                            .traslate("334"),
374:                            LanguageTraslator.traslate("335"),
375:                            JOptionPane.ERROR_MESSAGE);
376:                }
377:            }
378:
379:            private void removeView() throws InfoException {
380:                if (current != null) {
381:                    if (current.getLevel() != 0) {
382:                        getReportManager().deleteReportView(
383:                                ((DefinitionInfo) (current.getUserObject()))
384:                                        .getId(),
385:                                getReportResult().getReportSpec()
386:                                        .getDefinitionId(),
387:                                pivotTable.getPivotTableFrame().getUserID());
388:                        DefaultMutableTreeNode node = getCurrent();
389:                        if (node != null && node.isLeaf() && !node.isRoot()
390:                                && node.getLevel() > 0) {
391:                            treeModel.removeNodeFromParent(node);
392:                            treeModel.reload();
393:                        }
394:                    } else {
395:                        JOptionPane.showMessageDialog(this , LanguageTraslator
396:                                .traslate("334"), LanguageTraslator
397:                                .traslate("335"), JOptionPane.ERROR_MESSAGE);
398:                    }
399:                } else {
400:                    JOptionPane.showMessageDialog(this , LanguageTraslator
401:                            .traslate("334"),
402:                            LanguageTraslator.traslate("335"),
403:                            JOptionPane.ERROR_MESSAGE);
404:                }
405:            }
406:
407:            private void addView() throws InfoException {
408:                if (viewTextFieldName.getText().compareToIgnoreCase("") != 0) {
409:                    String nameView = viewTextFieldName.getText().trim();
410:                    DefaultMutableTreeNode node = new DefaultMutableTreeNode(
411:                            nameView);
412:                    createReportView(nameView);
413:                    root.add(node);
414:                    viewTextFieldName.setText("");
415:                    treeModel.reload();
416:                }
417:            }
418:
419:            private void createReportView(String nameView) throws InfoException {
420:                getReportManager().saveReportView(
421:                        pivotTable.getTableProperties().getReportView(nameView,
422:                                pivotTable.getPivotTableFrame().getUserID(),
423:                                nameView));
424:            }
425:
426:            private Component createTreeView() throws InfoException {
427:                root = new DefaultMutableTreeNode(LanguageTraslator
428:                        .traslate("109"));
429:                treeModel = new DefaultTreeModel(root);
430:                Map map = getMapViews();
431:                for (int i = 0; i < map.size(); i++) {
432:                    DefaultMutableTreeNode node = new DefaultMutableTreeNode(
433:                            map.values().toArray()[i]);
434:                    root.add(node);
435:                }
436:                treeViews = new JTree(treeModel);
437:                return treeViews;
438:            }
439:
440:            /**Devuelve la lista de vistas para el reporte, si es un Micro report trae de la lista que viene en el Microreport
441:             *
442:             * @return
443:             */
444:            public Map getMapViews() throws InfoException {
445:                if (getIsReadOnly()) {
446:                    return microReport.getDefinitionsInfo();
447:                } else {
448:                    return getReportManager()
449:                            .getReportViews(
450:                                    getReportResult().getReportSpec()
451:                                            .getDefinitionId(),
452:                                    pivotTable.getPivotTableFrame().getUserID());
453:                }
454:            }
455:
456:            private void closeBtnActionPerformed() {
457:                setVisible(false);
458:                dispose();
459:            }
460:
461:            /** Closes the dialog */
462:            private void closeDialog() {
463:                setVisible(false);
464:                dispose();
465:            }
466:
467:            public void setCurrent(TreeSelectionEvent e) {
468:                DefaultMutableTreeNode node = (DefaultMutableTreeNode) (e
469:                        .getPath().getLastPathComponent());
470:                this .current = node;
471:            }
472:
473:            public DefaultMutableTreeNode getCurrent() {
474:                return current;
475:            }
476:
477:            private IReportManager getReportManager() {
478:                return pivotTable.getPivotTableFrame().getReportManager();
479:            }
480:
481:            private ReportResult getReportResult() {
482:                return pivotTable.getPivotTableFrame().getReportResult();
483:            }
484:
485:            private JTextField viewTextFieldName;
486:            private JPanel northSeparatorPanel;
487:            private JButton defaultBtn;
488:            private JPanel southPanel;
489:            private JPanel centerPanel;
490:            private JButton removeBtn;
491:            private JButton applyBtn;
492:            private JButton addBtn;
493:            private JButton export;
494:            private JButton importar;
495:            private JButton closeBtn;
496:            private JPanel closeConteinerBtnPanel;
497:            private JPanel boxBtnPanel;
498:            private JPanel conteinerSouthPanel;
499:            private JScrollPane centerScrollPanel;
500:            private JPanel northPanel;
501:            private JTree treeViews;
502:            private DefaultTreeModel treeModel;
503:            private DefaultMutableTreeNode root;
504:            private DefaultMutableTreeNode current;
505:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.