Source Code Cross Referenced for ChoosSemaphoreSelection.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.reportcalculator.expression.*;
004:        import com.calipso.reportgenerator.common.InfoException;
005:        import com.calipso.reportgenerator.common.ShowExceptionMessageDialog;
006:
007:        import javax.swing.*;
008:        import java.awt.*;
009:        import java.awt.event.ActionListener;
010:        import java.awt.event.ActionEvent;
011:        import java.text.MessageFormat;
012:        import java.util.Vector;
013:
014:        /**
015:         * Crea un Dialog de selleccion de Colores
016:         */
017:
018:        public class ChoosSemaphoreSelection extends javax.swing.JDialog {
019:            private Color bgColor;
020:            private ColorCondition resultColorCondition;
021:            private JPanel jPanel4;
022:            private JLabel colorjLabel;
023:            private JLabel valuejLabel;
024:            private JButton okjButton;
025:            private JTextField fromjTextField;
026:            private JRadioButton greaterOrEqualTojRadioButton;
027:            private JRadioButton greaterThanjRadioButton;
028:            private JPanel jPanel3;
029:            private Color storedColor;
030:            private JButton canceljButton;
031:            private JTextField colorjTextField;
032:            private JRadioButton lessThanjRadioButton;
033:            private JPanel jPanel2;
034:            private JPanel jPanel5;
035:            private ButtonGroup operatorbuttonGroup;
036:            private JTextField tojTextField;
037:            private JButton colorjButton;
038:            private JPanel jPanel7;
039:            private JLabel tojLabel;
040:            private JPanel jPanel1;
041:            private JPanel jPanel6;
042:            private JRadioButton lessOrEqualTojRadioButton;
043:            private JLabel fromjLabel;
044:            private JTextField valuejTextField;
045:            private JRadioButton equalTojRadioButton;
046:            private JTabbedPane tabPanel;
047:            private int seleccionRadioButton;
048:            private MetricState metricState;
049:
050:            /**
051:             * Obtiene un ColorCondition
052:             * @param owner
053:             * @param metricState
054:             * @return
055:             */
056:            public static ColorCondition newColorCondition(Frame owner,
057:                    MetricState metricState, ColorCondition condition) {
058:                ChoosSemaphoreSelection dialog = new ChoosSemaphoreSelection(
059:                        owner, metricState, condition);
060:                ColorCondition colorCondition = dialog.execute();
061:                dialog.dispose();
062:                return colorCondition;
063:            }
064:
065:            /**
066:             *  Muestra el Dialog y retorna un colorCondition nuevo
067:             * @return
068:             */
069:            public ColorCondition execute() {
070:                this .setVisible(true);
071:                return this .resultColorCondition;
072:            }
073:
074:            /**
075:             * Crea un un Dialog modal  ChoosSemaphoreSelection
076:             * @param owner
077:             * @param metricState
078:             */
079:            public ChoosSemaphoreSelection(Frame owner,
080:                    MetricState metricState, ColorCondition condition) {
081:                super (owner, true);
082:                this .metricState = metricState;
083:                resultColorCondition = null;
084:                initComponents();
085:                setValuesComponents(condition);
086:            }
087:
088:            /**
089:             * Setea los valores de los componentes para un <code>ColorCondition</code> determinado
090:             * @param condition
091:             */
092:            private void setValuesComponents(ColorCondition condition) {
093:                if (condition != null) {
094:                    storedColor = condition.getColor();
095:                    bgColor = storedColor;
096:                    Expression expression = condition.getExpression();
097:                    colorjTextField.setBackground(storedColor);
098:                    if (expression instanceof  GreaterThan) {
099:                        greaterThanjRadioButton.setSelected(true);
100:                        greaterThanjRadioButtonMousePressed();
101:                        Float aFloat = Float
102:                                .valueOf(expression.getArguments()[1]
103:                                        .toString());
104:                        valuejTextField.setText(String.valueOf(aFloat
105:                                .intValue()));
106:                    } else if (expression instanceof  GreaterOrEqualTo) {
107:                        greaterOrEqualTojRadioButton.setSelected(true);
108:                        greaterOrEqualTojRadioButtonMousePressed();
109:                        Float aFloat = Float
110:                                .valueOf(expression.getArguments()[1]
111:                                        .toString());
112:                        valuejTextField.setText(String.valueOf(aFloat
113:                                .intValue()));
114:                    } else if (expression instanceof  LessThan) {
115:                        lessThanjRadioButton.setSelected(true);
116:                        lessThanjRadioButtonMousePressed();
117:                        Float aFloat = Float
118:                                .valueOf(expression.getArguments()[1]
119:                                        .toString());
120:                        valuejTextField.setText(String.valueOf(aFloat
121:                                .intValue()));
122:                    } else if (expression instanceof  LessOrEqualTo) {
123:                        lessOrEqualTojRadioButton.setSelected(true);
124:                        lessOrEqualTojRadioButtonMousePressed();
125:                        Float aFloat = Float
126:                                .valueOf(expression.getArguments()[1]
127:                                        .toString());
128:                        valuejTextField.setText(String.valueOf(aFloat
129:                                .intValue()));
130:                    } else if (expression instanceof  EqualTo) {
131:                        equalTojRadioButton.setSelected(true);
132:                        equalTojRadioButtonMousePressed();
133:                        Float aFloat = Float
134:                                .valueOf(expression.getArguments()[1]
135:                                        .toString());
136:                        valuejTextField.setText(String.valueOf(aFloat
137:                                .intValue()));
138:                    } else if (expression instanceof  AndExp) {
139:                        tabPanel.setSelectedIndex(1);
140:                        Expression[] expressions = expression.getArguments();
141:                        Expression greaterOrEqualTo = expressions[0];
142:                        Expression lessOrEqualTo = expressions[1];
143:                        Float aFloat = Float.valueOf(greaterOrEqualTo
144:                                .getArguments()[1].toString());
145:                        fromjTextField.setText(String
146:                                .valueOf(aFloat.intValue()));
147:                        aFloat = Float.valueOf(lessOrEqualTo.getArguments()[1]
148:                                .toString());
149:                        tojTextField.setText(String.valueOf(aFloat.intValue()));
150:                    }
151:                }
152:            }
153:
154:            /**
155:             * Inicializa los componentes del Dialog
156:             */
157:            private void initComponents() {
158:                operatorbuttonGroup = new javax.swing.ButtonGroup();
159:                jPanel3 = new javax.swing.JPanel();
160:                jPanel4 = new javax.swing.JPanel();
161:                okjButton = new javax.swing.JButton();
162:                canceljButton = new javax.swing.JButton();
163:                jPanel6 = new javax.swing.JPanel();
164:                tabPanel = new javax.swing.JTabbedPane();
165:                jPanel2 = new javax.swing.JPanel();
166:                greaterThanjRadioButton = new javax.swing.JRadioButton();
167:                lessThanjRadioButton = new javax.swing.JRadioButton();
168:                greaterOrEqualTojRadioButton = new javax.swing.JRadioButton();
169:                lessOrEqualTojRadioButton = new javax.swing.JRadioButton();
170:                equalTojRadioButton = new javax.swing.JRadioButton();
171:                jPanel5 = new javax.swing.JPanel();
172:                valuejLabel = new javax.swing.JLabel();
173:                valuejTextField = new javax.swing.JTextField();
174:                jPanel1 = new javax.swing.JPanel();
175:                fromjLabel = new javax.swing.JLabel();
176:                tojLabel = new javax.swing.JLabel();
177:                fromjTextField = new javax.swing.JTextField();
178:                tojTextField = new javax.swing.JTextField();
179:                jPanel7 = new javax.swing.JPanel();
180:                colorjLabel = new javax.swing.JLabel();
181:                colorjTextField = new javax.swing.JTextField();
182:                colorjButton = new javax.swing.JButton();
183:
184:                setResizable(false);
185:                addWindowListener(new java.awt.event.WindowAdapter() {
186:                    public void windowClosing(java.awt.event.WindowEvent evt) {
187:                        setVisible(false);
188:                    }
189:                });
190:
191:                getContentPane().add(jPanel3, java.awt.BorderLayout.NORTH);
192:
193:                jPanel4.setLayout(new java.awt.FlowLayout(
194:                        java.awt.FlowLayout.RIGHT));
195:
196:                okjButton
197:                        .setText(com.calipso.reportgenerator.common.LanguageTraslator
198:                                .traslate("112"));
199:                okjButton
200:                        .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
201:                okjButton
202:                        .setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
203:                jPanel4.add(okjButton);
204:
205:                canceljButton
206:                        .setText(com.calipso.reportgenerator.common.LanguageTraslator
207:                                .traslate("113"));
208:                canceljButton
209:                        .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
210:                canceljButton
211:                        .setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
212:                jPanel4.add(canceljButton);
213:
214:                getContentPane().add(jPanel4, java.awt.BorderLayout.SOUTH);
215:                jPanel6.setLayout(new java.awt.BorderLayout());
216:                jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2,
217:                        javax.swing.BoxLayout.Y_AXIS));
218:
219:                greaterThanjRadioButton
220:                        .setText(com.calipso.reportgenerator.common.LanguageTraslator
221:                                .traslate("117")
222:                                + "(>)");
223:                operatorbuttonGroup.add(greaterThanjRadioButton);
224:                jPanel2.add(greaterThanjRadioButton);
225:                seleccionRadioButton = 0;
226:                greaterThanjRadioButton.setSelected(true);
227:
228:                lessThanjRadioButton
229:                        .setText(com.calipso.reportgenerator.common.LanguageTraslator
230:                                .traslate("118")
231:                                + "(<)");
232:                operatorbuttonGroup.add(lessThanjRadioButton);
233:                jPanel2.add(lessThanjRadioButton);
234:
235:                greaterOrEqualTojRadioButton
236:                        .setText(com.calipso.reportgenerator.common.LanguageTraslator
237:                                .traslate("119")
238:                                + "(>=)");
239:                operatorbuttonGroup.add(greaterOrEqualTojRadioButton);
240:                jPanel2.add(greaterOrEqualTojRadioButton);
241:
242:                lessOrEqualTojRadioButton
243:                        .setText(com.calipso.reportgenerator.common.LanguageTraslator
244:                                .traslate("120")
245:                                + "(<=)");
246:                lessOrEqualTojRadioButton.setToolTipText("null");
247:                operatorbuttonGroup.add(lessOrEqualTojRadioButton);
248:                jPanel2.add(lessOrEqualTojRadioButton);
249:
250:                equalTojRadioButton
251:                        .setText(com.calipso.reportgenerator.common.LanguageTraslator
252:                                .traslate("121")
253:                                + "(=)");
254:                operatorbuttonGroup.add(equalTojRadioButton);
255:                jPanel2.add(equalTojRadioButton);
256:
257:                jPanel5.setLayout(null);
258:
259:                valuejLabel
260:                        .setText(com.calipso.reportgenerator.common.LanguageTraslator
261:                                .traslate("122")
262:                                + ":");
263:                jPanel5.add(valuejLabel);
264:                valuejLabel.setBounds(10, 8, 31, 16);
265:
266:                jPanel5.add(valuejTextField);
267:                valuejTextField.setBounds(76, 4, 150, 20);
268:
269:                jPanel2.add(jPanel5);
270:
271:                tabPanel.addTab(
272:                        com.calipso.reportgenerator.common.LanguageTraslator
273:                                .traslate("123"), jPanel2);
274:
275:                jPanel1.setLayout(null);
276:
277:                fromjLabel
278:                        .setText(com.calipso.reportgenerator.common.LanguageTraslator
279:                                .traslate("124")
280:                                + ":");
281:                jPanel1.add(fromjLabel);
282:                fromjLabel.setBounds(10, 20, 39, 16);
283:
284:                tojLabel
285:                        .setText(com.calipso.reportgenerator.common.LanguageTraslator
286:                                .traslate("125")
287:                                + ":");
288:                jPanel1.add(tojLabel);
289:                tojLabel.setBounds(10, 50, 36, 16);
290:
291:                jPanel1.add(fromjTextField);
292:                fromjTextField.setBounds(80, 20, 160, 20);
293:
294:                jPanel1.add(tojTextField);
295:                tojTextField.setBounds(80, 50, 160, 20);
296:
297:                tabPanel.addTab(
298:                        com.calipso.reportgenerator.common.LanguageTraslator
299:                                .traslate("126"), jPanel1);
300:
301:                jPanel6.add(tabPanel, java.awt.BorderLayout.CENTER);
302:
303:                jPanel7.setLayout(null);
304:
305:                jPanel7.setBorder(new javax.swing.border.CompoundBorder(
306:                        new javax.swing.border.SoftBevelBorder(
307:                                javax.swing.border.BevelBorder.RAISED), null));
308:                jPanel7.setPreferredSize(new java.awt.Dimension(10, 30));
309:                colorjLabel
310:                        .setText(com.calipso.reportgenerator.common.LanguageTraslator
311:                                .traslate("127")
312:                                + ":");
313:                jPanel7.add(colorjLabel);
314:                colorjLabel.setBounds(10, 6, 33, 16);
315:
316:                colorjTextField.setBackground(java.awt.Color.RED);
317:                if (storedColor == null) {
318:                    bgColor = java.awt.Color.RED;
319:                } else {
320:                    bgColor = storedColor;
321:                }
322:                colorjTextField.setEditable(false);
323:                jPanel7.add(colorjTextField);
324:                colorjTextField.setBounds(80, 6, 140, 20);
325:
326:                colorjButton.setText("...");
327:                colorjButton
328:                        .addActionListener(new java.awt.event.ActionListener() {
329:                            public void actionPerformed(
330:                                    java.awt.event.ActionEvent evt) {
331:                                colorjButtonActionPerformed();
332:                            }
333:                        });
334:                okjButton
335:                        .addActionListener(new java.awt.event.ActionListener() {
336:                            public void actionPerformed(
337:                                    java.awt.event.ActionEvent evt) {
338:                                try {
339:                                    doPaint();
340:                                } catch (Exception e) {
341:                                    ShowExceptionMessageDialog
342:                                            .initExceptionDialogMessage(
343:                                                    com.calipso.reportgenerator.common.LanguageTraslator
344:                                                            .traslate("226"), e);
345:                                }
346:                            }
347:                        });
348:
349:                greaterThanjRadioButton
350:                        .addMouseListener(new java.awt.event.MouseAdapter() {
351:                            public void mousePressed(
352:                                    java.awt.event.MouseEvent evt) {
353:                                greaterThanjRadioButtonMousePressed();
354:                            }
355:                        });
356:
357:                lessThanjRadioButton
358:                        .addMouseListener(new java.awt.event.MouseAdapter() {
359:                            public void mousePressed(
360:                                    java.awt.event.MouseEvent evt) {
361:                                lessThanjRadioButtonMousePressed();
362:                            }
363:                        });
364:
365:                greaterOrEqualTojRadioButton
366:                        .addMouseListener(new java.awt.event.MouseAdapter() {
367:                            public void mousePressed(
368:                                    java.awt.event.MouseEvent evt) {
369:                                greaterOrEqualTojRadioButtonMousePressed();
370:                            }
371:                        });
372:                lessOrEqualTojRadioButton
373:                        .addMouseListener(new java.awt.event.MouseAdapter() {
374:                            public void mousePressed(
375:                                    java.awt.event.MouseEvent evt) {
376:                                lessOrEqualTojRadioButtonMousePressed();
377:                            }
378:                        });
379:                equalTojRadioButton
380:                        .addMouseListener(new java.awt.event.MouseAdapter() {
381:                            public void mousePressed(
382:                                    java.awt.event.MouseEvent evt) {
383:                                equalTojRadioButtonMousePressed();
384:                            }
385:                        });
386:
387:                canceljButton.addActionListener(new ActionListener() {
388:                    public void actionPerformed(ActionEvent e) {
389:                        closeChoosSemaphoreSelection();
390:
391:                    }
392:                });
393:
394:                jPanel7.add(colorjButton);
395:                colorjButton.setBounds(220, 6, 20, 20);
396:
397:                jPanel6.add(jPanel7, java.awt.BorderLayout.SOUTH);
398:
399:                getContentPane().add(jPanel6, java.awt.BorderLayout.CENTER);
400:
401:                pack();
402:                java.awt.Dimension screenSize = java.awt.Toolkit
403:                        .getDefaultToolkit().getScreenSize();
404:                setSize(new java.awt.Dimension(400, 300));
405:                setLocation((screenSize.width - 400) / 2,
406:                        (screenSize.height - 300) / 2);
407:            }
408:
409:            /**
410:             * Cierra el Dialog
411:             */
412:            private void closeChoosSemaphoreSelection() {
413:                this .setVisible(false);
414:            }
415:
416:            /**
417:             * Retorna el indicador de para el JRadioButton equalTo
418:             */
419:            private void equalTojRadioButtonMousePressed() {
420:                seleccionRadioButton = 4;
421:            }
422:
423:            /**
424:             * Retorna el indicador de para el JRadioButton lessOrEqualTo
425:             */
426:            private void lessOrEqualTojRadioButtonMousePressed() {
427:                seleccionRadioButton = 3;
428:            }
429:
430:            /**
431:             * Retorna el indicador de para el JRadioButton greaterOrEqualTo
432:             */
433:            private void greaterOrEqualTojRadioButtonMousePressed() {
434:                seleccionRadioButton = 2;
435:            }
436:
437:            /**
438:             * Retorna el indicador de para el JRadioButton lessThan
439:             */
440:            private void lessThanjRadioButtonMousePressed() {
441:                seleccionRadioButton = 1;
442:            }
443:
444:            /**
445:             * Retorna el indicador de para el JRadioButton greaterThan
446:             */
447:            private void greaterThanjRadioButtonMousePressed() {
448:                seleccionRadioButton = 0;
449:            }
450:
451:            /**
452:             * Actualiza el colorcondition y cierra el Dialog
453:             */
454:            private void doPaint() throws InfoException {
455:                switch (tabPanel.getSelectedIndex()) {
456:                case 0: {
457:                    resultColorCondition = doPaintSimpleSelectionMode();
458:                    break;
459:                }
460:                case 1: {
461:                    resultColorCondition = doPaintRangoSeleccionMode();
462:                    break;
463:                }
464:                }
465:                if (resultColorCondition != null) {
466:                    setVisible(false);
467:                }
468:            }
469:
470:            /**
471:             * retorna un color condition , seteando la expresion segun corresponda
472:             * @return
473:             */
474:            private ColorCondition doPaintSimpleSelectionMode()
475:                    throws InfoException {
476:                switch (seleccionRadioButton) {
477:                case 0: {
478:                    return greaterThan();
479:                }
480:                case 1: {
481:                    return lessThan();
482:                }
483:                case 2: {
484:                    return greaterOrEqualTo();
485:                }
486:                case 3: {
487:                    return lessOrEqualTo();
488:                }
489:                case 4: {
490:                    return equalTo();
491:                }
492:                }
493:                return null;
494:            }
495:
496:            /**
497:             * Retorna el colorCondition cuando la expresion es igual a un numero determinaddo
498:             * @return
499:             */
500:            private ColorCondition equalTo() throws InfoException {
501:                Vector errors = new Vector();
502:                float value = 0;
503:                try {
504:                    value = Float.parseFloat(this .valuejTextField.getText());
505:                } catch (NumberFormatException e) {
506:                    errors.add(valuejTextField.getText());
507:                    toString();
508:                }
509:                if (errors.size() == 0) {
510:                    value = Float.parseFloat(this .valuejTextField.getText());
511:                    Expression expression = (new VariableExp("VALUE"))
512:                            .newEqualTo(new ConstantExp(new Float(value)));
513:                    return newColorCondition(expression);
514:                } else {
515:                    if (errors.size() == 1) {
516:                        String message = MessageFormat
517:                                .format(
518:                                        com.calipso.reportgenerator.common.LanguageTraslator
519:                                                .traslate("128"),
520:                                        new Object[] { this .valuejTextField
521:                                                .getText() });
522:                        throw new InfoException(message);
523:                    }
524:                    return null;
525:                }
526:            }
527:
528:            /**
529:             * Retorna el colorCondition y actualiza su color
530:             * @return
531:             */
532:            private ColorCondition newColorCondition(Expression expression) {
533:                if (bgColor == null) {
534:                    //bgColor = Color.RED;
535:
536:                    bgColor = colorjTextField.getBackground();
537:                }
538:                return new ColorCondition(expression, bgColor, metricState);
539:            }
540:
541:            /**
542:             * Retorna el colorCondition cuando la expresion sea menor o igual  a un numero determinaddo
543:             * @return
544:             */
545:            private ColorCondition lessOrEqualTo() throws InfoException {
546:                Vector errors = new Vector();
547:                float value = 0;
548:                try {
549:                    value = Float.parseFloat(this .valuejTextField.getText());
550:                } catch (NumberFormatException e) {
551:                    errors.add(valuejTextField.getText());
552:                }
553:                if (errors.size() == 0) {
554:                    value = Float.parseFloat(this .valuejTextField.getText());
555:                    Expression expression = (new VariableExp("VALUE"))
556:                            .newLessOrEquealTo(new ConstantExp(new Float(value)));
557:                    return newColorCondition(expression);
558:                } else {
559:                    if (errors.size() == 1) {
560:                        String message = MessageFormat
561:                                .format(
562:                                        com.calipso.reportgenerator.common.LanguageTraslator
563:                                                .traslate("128"),
564:                                        new Object[] { this .valuejTextField
565:                                                .getText() });
566:                        throw new InfoException(message);
567:                    }
568:                    return null;
569:                }
570:            }
571:
572:            /**
573:             * Retorna el colorCondition cuando la expresion sea mayor o igual a un numero determinaddo
574:             * @return
575:             */
576:            private ColorCondition greaterOrEqualTo() throws InfoException {
577:                Vector errors = new Vector();
578:                float value = 0;
579:                try {
580:                    value = Float.parseFloat(this .valuejTextField.getText());
581:                } catch (NumberFormatException e) {
582:                    errors.add(valuejTextField.getText());
583:                }
584:                if (errors.size() == 0) {
585:                    value = Float.parseFloat(this .valuejTextField.getText());
586:                    Expression expression = (new VariableExp("VALUE"))
587:                            .newGreaterOrEqualTo(new ConstantExp(new Float(
588:                                    value)));
589:                    return newColorCondition(expression);
590:                } else {
591:                    if (errors.size() == 1) {
592:                        String message = MessageFormat
593:                                .format(
594:                                        com.calipso.reportgenerator.common.LanguageTraslator
595:                                                .traslate("128"),
596:                                        new Object[] { this .valuejTextField
597:                                                .getText() });
598:                        throw new InfoException(message);
599:                    }
600:                    return null;
601:                }
602:            }
603:
604:            /**
605:             * Retorna el colorCondition cuando la expresion sea menor a  un numero determinaddo
606:             * @return
607:             */
608:            private ColorCondition lessThan() throws InfoException {
609:                Vector errors = new Vector();
610:                float value = 0;
611:                try {
612:                    value = Float.parseFloat(this .valuejTextField.getText());
613:                } catch (NumberFormatException e) {
614:                    errors.add(valuejTextField.getText());
615:                }
616:                if (errors.size() == 0) {
617:                    value = Float.parseFloat(this .valuejTextField.getText());
618:                    Expression expression = (new VariableExp("VALUE"))
619:                            .newLessThan(new ConstantExp(new Float(value)));
620:                    return newColorCondition(expression);
621:                } else {
622:                    if (errors.size() == 1) {
623:                        String message = MessageFormat
624:                                .format(
625:                                        com.calipso.reportgenerator.common.LanguageTraslator
626:                                                .traslate("128"),
627:                                        new Object[] { this .valuejTextField
628:                                                .getText() });
629:                        throw new InfoException(message);
630:                    }
631:                    return null;
632:                }
633:            }
634:
635:            /**
636:             * Retorna el colorCondition cuando la expresion sea mayor a un numero determinaddo
637:             * @return
638:             */
639:
640:            private ColorCondition greaterThan() throws InfoException {
641:                Vector errors = new Vector();
642:                float value = 0;
643:                try {
644:                    value = Float.parseFloat(this .valuejTextField.getText());
645:                } catch (NumberFormatException e) {
646:                    errors.add(valuejTextField.getText());
647:                }
648:                if (errors.size() == 0) {
649:                    value = Float.parseFloat(this .valuejTextField.getText());
650:                    Expression expression = (new VariableExp("VALUE"))
651:                            .newGreaterThan(new ConstantExp(new Float(value)));
652:                    return newColorCondition(expression);
653:                } else {
654:                    if (errors.size() == 1) {
655:                        String message = MessageFormat
656:                                .format(
657:                                        com.calipso.reportgenerator.common.LanguageTraslator
658:                                                .traslate("128"),
659:                                        new Object[] { this .valuejTextField
660:                                                .getText() });
661:                        throw new InfoException(message);
662:                    }
663:                    return null;
664:                }
665:            }
666:
667:            /**
668:             * Evento del boton de seleccion  de colores
669:             */
670:            private void colorjButtonActionPerformed() {
671:                this .executeJColorChooser();
672:            }
673:
674:            /**
675:             * Retona un colorCondition comprendido en un determinado rango de valores
676:             * @return
677:             */
678:            private ColorCondition doPaintRangoSeleccionMode()
679:                    throws InfoException {
680:                float desdeValue = 0;
681:                float hastaValue = 0;
682:                Vector errors = new Vector();
683:                Expression exp = null;
684:                try {
685:                    desdeValue = Float
686:                            .parseFloat(this .fromjTextField.getText());
687:                } catch (NumberFormatException e) {
688:                    errors.add(fromjTextField.getText());
689:                }
690:                try {
691:                    hastaValue = Float.parseFloat(this .tojTextField.getText());
692:                } catch (NumberFormatException e) {
693:                    errors.add(tojTextField.getText());
694:                }
695:                if (errors.size() == 0) {
696:                    Expression subexp1 = (new VariableExp("VALUE"))
697:                            .newGreaterOrEqualTo(new ConstantExp(new Float(
698:                                    desdeValue)));
699:                    Expression subexp2 = (new VariableExp("VALUE"))
700:                            .newLessOrEquealTo((new ConstantExp(new Float(
701:                                    hastaValue))));
702:                    exp = subexp1.newAnd(subexp2);
703:                    return newColorCondition(exp);
704:                } else {
705:                    if (errors.size() == 1) {
706:                        String message = MessageFormat
707:                                .format(
708:                                        com.calipso.reportgenerator.common.LanguageTraslator
709:                                                .traslate("128"),
710:                                        new Object[] { errors.get(0) });
711:                        throw new InfoException(message);
712:                    } else {
713:                        String message = MessageFormat
714:                                .format(
715:                                        com.calipso.reportgenerator.common.LanguageTraslator
716:                                                .traslate("129"), new Object[] {
717:                                                errors.get(0), errors.get(1) });
718:                        throw new InfoException(message);
719:                    }
720:                }
721:            }
722:
723:            /**
724:             * Pone no visible el JColorChooser y  setea el color que se quiere utilizar
725:             */
726:            private void executeJColorChooser() {
727:                if (storedColor != null) {
728:                    bgColor = JColorChooser.showDialog(this , "", storedColor);
729:                } else {
730:                    bgColor = JColorChooser.showDialog(this , "",
731:                            getBackground());
732:                }
733:                if (bgColor != null) {
734:                    colorjTextField.setBackground(bgColor);
735:                }
736:            }
737:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.