Source Code Cross Referenced for RowBandingDefinitionChooser.java in  » Report » pentaho-report » org » pentaho » reportdesigner » crm » report » properties » editors » 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 » pentaho report » org.pentaho.reportdesigner.crm.report.properties.editors 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006-2007 Pentaho Corporation.  All rights reserved.
003:         * This software was developed by Pentaho Corporation and is provided under the terms
004:         * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005:         * this file except in compliance with the license. If you need a copy of the license,
006:         * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
007:         *
008:         * Software distributed under the Mozilla Public License is distributed on an "AS IS"
009:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to
010:         * the license for the specific language governing your rights and limitations.
011:         *
012:         * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
013:         */
014:        package org.pentaho.reportdesigner.crm.report.properties.editors;
015:
016:        import com.jgoodies.forms.layout.CellConstraints;
017:        import com.jgoodies.forms.layout.FormLayout;
018:        import org.jetbrains.annotations.NonNls;
019:        import org.jetbrains.annotations.NotNull;
020:        import org.pentaho.reportdesigner.crm.report.components.PaletteColorChooser;
021:        import org.pentaho.reportdesigner.crm.report.model.RowBandingDefinition;
022:        import org.pentaho.reportdesigner.crm.report.util.GraphicUtils;
023:        import org.pentaho.reportdesigner.lib.client.components.CenterPanelDialog;
024:        import org.pentaho.reportdesigner.lib.client.i18n.TranslationManager;
025:        import org.pentaho.reportdesigner.lib.client.util.GUIUtils;
026:        import org.pentaho.reportdesigner.lib.client.util.WindowUtils;
027:
028:        import javax.swing.*;
029:        import javax.swing.border.TitledBorder;
030:        import javax.swing.event.ChangeEvent;
031:        import javax.swing.event.ChangeListener;
032:        import java.awt.*;
033:        import java.awt.event.ActionEvent;
034:        import java.awt.event.ActionListener;
035:        import java.awt.event.MouseAdapter;
036:        import java.awt.event.MouseEvent;
037:
038:        /**
039:         * User: Martin
040:         * Date: 01.11.2005
041:         * Time: 10:23:10
042:         */
043:        public class RowBandingDefinitionChooser {
044:
045:            private RowBandingDefinitionChooser() {
046:            }
047:
048:            @NotNull
049:            public static RowBandingDefinition showBorderDefinitionChooser(
050:                    @NotNull
051:                    JComponent parent, @NotNull
052:                    String title, @NotNull
053:                    RowBandingDefinition origRowBandingDefinition) {
054:                final CenterPanelDialog centerPanelDialog = CenterPanelDialog
055:                        .createDialog(parent, title,
056:                                CenterPanelDialog.ModalityType.DOCUMENT_MODAL);
057:
058:                final boolean[] action = new boolean[] { false };
059:
060:                JButton okButton = new JButton(TranslationManager.getInstance()
061:                        .getTranslation("R", "Button.ok"));
062:                okButton.addActionListener(new ActionListener() {
063:                    public void actionPerformed(@NotNull
064:                    ActionEvent e) {
065:                        action[0] = true;
066:                        centerPanelDialog.dispose();
067:                    }
068:                });
069:
070:                JButton cancelButton = new JButton(TranslationManager
071:                        .getInstance().getTranslation("R", "Button.cancel"));
072:                cancelButton.addActionListener(new ActionListener() {
073:                    public void actionPerformed(@NotNull
074:                    ActionEvent e) {
075:                        action[0] = false;
076:                        centerPanelDialog.dispose();
077:                    }
078:                });
079:
080:                centerPanelDialog.setButtons(okButton, cancelButton, okButton,
081:                        cancelButton);
082:
083:                RowBandingDefinitionPanel centerPanel = new RowBandingDefinitionPanel(
084:                        origRowBandingDefinition);
085:
086:                centerPanelDialog.setCenterPanel(centerPanel);
087:                centerPanelDialog.pack();
088:                GUIUtils.ensureMinimumDialogSize(centerPanelDialog, 250, 400);
089:                WindowUtils.setLocationRelativeTo(centerPanelDialog, parent);
090:                centerPanelDialog.setVisible(true);
091:
092:                if (action[0]) {
093:                    return centerPanel.getCurrentRowBandingDefinition();
094:                }
095:                //return font;
096:                return origRowBandingDefinition;
097:            }
098:
099:            private static class SamplePanel extends JPanel {
100:                @NotNull
101:                private RowBandingDefinition rowBandingDefinition;
102:
103:                private SamplePanel(@NotNull
104:                RowBandingDefinition rowBandingDefinition) {
105:                    this .rowBandingDefinition = rowBandingDefinition;
106:                }
107:
108:                @NotNull
109:                public RowBandingDefinition getRowBandingDefinition() {
110:                    return rowBandingDefinition;
111:                }
112:
113:                public void setRowBandingDefinition(@NotNull
114:                RowBandingDefinition rowBandingDefinition) {
115:                    this .rowBandingDefinition = rowBandingDefinition;
116:
117:                    repaint();
118:                }
119:
120:                protected void paintComponent(@NotNull
121:                Graphics g) {
122:                    super .paintComponent(g);
123:
124:                    Graphics2D g2d = (Graphics2D) g;
125:                    Stroke origStroke = g2d.getStroke();
126:                    Color origColor = g2d.getColor();
127:                    Shape origClip = g2d.getClip();
128:
129:                    g2d
130:                            .clip(new Rectangle(
131:                                    getInsets().left,
132:                                    getInsets().top,
133:                                    getWidth()
134:                                            - (getInsets().left + getInsets().right),
135:                                    getHeight()
136:                                            - (getInsets().top + getInsets().bottom)));
137:                    g2d.setColor(rowBandingDefinition.getColor());
138:                    int stripeHeight = 10;
139:                    int stripes = (getHeight() - (getInsets().top + getInsets().bottom))
140:                            / stripeHeight - 1;
141:
142:                    for (int i = 0; i < stripes; i++) {
143:                        if ((i / rowBandingDefinition.getSwitchItemCount()) % 2 == (rowBandingDefinition
144:                                .isStartState() ? 0 : 1)
145:                                && rowBandingDefinition.isEnabled()) {
146:                            g2d.setColor(rowBandingDefinition.getColor());
147:                            g2d.fillRect(getInsets().left, i * stripeHeight
148:                                    + getInsets().top, getWidth()
149:                                    - (getInsets().left + getInsets().right),
150:                                    stripeHeight);
151:                        } else {
152:                            g2d.setColor(Color.WHITE);
153:                            g2d.fillRect(getInsets().left, i * stripeHeight
154:                                    + getInsets().top, getWidth()
155:                                    - (getInsets().left + getInsets().right),
156:                                    stripeHeight);
157:                        }
158:                        g2d.setColor(Color.GRAY);
159:                        g2d.drawRect(getInsets().left, i * stripeHeight
160:                                + getInsets().top, getWidth()
161:                                - (getInsets().left + getInsets().right) - 1,
162:                                stripeHeight);
163:                    }
164:
165:                    g2d.setClip(origClip);
166:                    g2d.setStroke(origStroke);
167:                    g2d.setColor(origColor);
168:                }
169:            }
170:
171:            private static class RowBandingDefinitionPanel extends JPanel {
172:                @NotNull
173:                private RowBandingDefinition rowBandingDefinition;
174:
175:                @NotNull
176:                private JLabel enabledLabel;
177:                @NotNull
178:                private JCheckBox enabledCheckBox;
179:                @NotNull
180:                private JLabel colorLabel;
181:                @NotNull
182:                private JLabel colorIconLabel;
183:                @NotNull
184:                private Color color;
185:                @NotNull
186:                private JButton colorButton;
187:                @NotNull
188:                private JLabel initialStateLabel;
189:                @NotNull
190:                private JRadioButton initialStateColoredRadioButton;
191:                @NotNull
192:                private JRadioButton initialStateUncoloredRadioButton;
193:                @NotNull
194:                private JLabel switchItemCountLabel;
195:                @NotNull
196:                private JSpinner switchItemCountSpinner;
197:
198:                private RowBandingDefinitionPanel(@NotNull
199:                RowBandingDefinition origRowBandingDefinition) {
200:                    this .rowBandingDefinition = origRowBandingDefinition;
201:
202:                    @NonNls
203:                    FormLayout formLayout = new FormLayout(
204:                            "0dlu, default:grow, 4dlu, fill:default, 4dlu, default, 0dlu",
205:                            "0dlu, " + "pref, " + //enabled
206:                                    "10dlu, " + "pref, " + //color
207:                                    "4dlu, " + "pref, " + //initialStateradioButton
208:                                    "4dlu, " + "pref, " + //numberOfElementsSpinner
209:                                    "10dlu, " + "fill:20dlu:grow, " + //sample
210:                                    "0dlu");
211:
212:                    setLayout(formLayout);
213:                    @NonNls
214:                    CellConstraints cc = new CellConstraints();
215:
216:                    enabledLabel = new JLabel(TranslationManager.getInstance()
217:                            .getTranslation("R",
218:                                    "RowBandingDefinitionChooser.EnabledLabel"));
219:                    enabledCheckBox = new JCheckBox(
220:                            TranslationManager
221:                                    .getInstance()
222:                                    .getTranslation("R",
223:                                            "RowBandingDefinitionChooser.EnabledCheckBox"));
224:                    enabledCheckBox.setSelected(rowBandingDefinition
225:                            .isEnabled());
226:
227:                    colorLabel = new JLabel(TranslationManager.getInstance()
228:                            .getTranslation("R",
229:                                    "RowBandingDefinitionChooser.ColorLabel"));
230:                    color = rowBandingDefinition.getColor();
231:                    colorIconLabel = new JLabel(GraphicUtils
232:                            .createColorImageIcon(Color.BLACK, color, 130, 20,
233:                                    true));
234:                    colorButton = new JButton("...");
235:                    colorButton.setMargin(new Insets(1, 1, 1, 1));
236:
237:                    initialStateLabel = new JLabel(
238:                            TranslationManager
239:                                    .getInstance()
240:                                    .getTranslation("R",
241:                                            "RowBandingDefinitionChooser.InitialStateLabel"));
242:                    initialStateColoredRadioButton = new JRadioButton(
243:                            TranslationManager
244:                                    .getInstance()
245:                                    .getTranslation("R",
246:                                            "RowBandingDefinitionChooser.InitialStateColoredRadioButton"));
247:                    initialStateUncoloredRadioButton = new JRadioButton(
248:                            TranslationManager
249:                                    .getInstance()
250:                                    .getTranslation("R",
251:                                            "RowBandingDefinitionChooser.InitialStateUncoloredRadioButton"));
252:                    ButtonGroup buttonGroup = new ButtonGroup();
253:                    buttonGroup.add(initialStateColoredRadioButton);
254:                    buttonGroup.add(initialStateUncoloredRadioButton);
255:                    initialStateColoredRadioButton
256:                            .setSelected(rowBandingDefinition.isStartState());
257:                    initialStateUncoloredRadioButton
258:                            .setSelected(!rowBandingDefinition.isStartState());
259:
260:                    switchItemCountLabel = new JLabel(
261:                            TranslationManager
262:                                    .getInstance()
263:                                    .getTranslation("R",
264:                                            "RowBandingDefinitionChooser.SwitchItemCountLabel"));
265:                    switchItemCountSpinner = new JSpinner(
266:                            new SpinnerNumberModel(rowBandingDefinition
267:                                    .getSwitchItemCount(), 1,
268:                                    Integer.MAX_VALUE, 1));
269:
270:                    final SamplePanel samplePanel = new SamplePanel(
271:                            rowBandingDefinition);
272:                    samplePanel.setBorder(new TitledBorder(TranslationManager
273:                            .getInstance().getTranslation("R",
274:                                    "RowBandingDefinitionPanel.Sample.Title")));
275:
276:                    add(enabledLabel, cc.xy(2, 2));
277:                    add(enabledCheckBox, cc.xy(4, 2));
278:
279:                    add(colorLabel, cc.xy(2, 4));
280:                    add(colorIconLabel, cc.xy(4, 4));
281:                    add(colorButton, cc.xy(6, 4));
282:
283:                    add(initialStateLabel, cc.xy(2, 6));
284:                    JPanel helperPanel = new JPanel(new GridLayout(1, 0));
285:                    helperPanel.add(initialStateColoredRadioButton);
286:                    helperPanel.add(initialStateUncoloredRadioButton);
287:                    add(helperPanel, cc.xy(4, 6));
288:
289:                    add(switchItemCountLabel, cc.xy(2, 8));
290:                    add(switchItemCountSpinner, cc.xy(4, 8));
291:
292:                    add(samplePanel, cc.xyw(2, 10, 5));
293:
294:                    updateState();
295:                    enabledCheckBox.addActionListener(new ActionListener() {
296:                        public void actionPerformed(@NotNull
297:                        ActionEvent e) {
298:                            updateState();
299:                            rowBandingDefinition = getCurrentRowBandingDefinition();
300:                            samplePanel
301:                                    .setRowBandingDefinition(rowBandingDefinition);
302:                        }
303:                    });
304:
305:                    colorButton.addActionListener(new ActionListener() {
306:                        public void actionPerformed(@NotNull
307:                        ActionEvent e) {
308:                            Color newColor = PaletteColorChooser
309:                                    .showDialog(
310:                                            RowBandingDefinitionChooser.RowBandingDefinitionPanel.this ,
311:                                            TranslationManager
312:                                                    .getInstance()
313:                                                    .getTranslation("R",
314:                                                            "PropertyEditor.Color.Title"),
315:                                            color);
316:                            if (newColor != null) {
317:                                color = newColor;
318:                                colorIconLabel.setIcon(GraphicUtils
319:                                        .createColorImageIcon(Color.BLACK,
320:                                                color, 130, 20, true));
321:                            }
322:
323:                            rowBandingDefinition = getCurrentRowBandingDefinition();
324:                            samplePanel
325:                                    .setRowBandingDefinition(rowBandingDefinition);
326:                        }
327:                    });
328:
329:                    colorIconLabel.addMouseListener(new MouseAdapter() {
330:                        public void mouseClicked(@NotNull
331:                        MouseEvent e) {
332:                            Color newColor = PaletteColorChooser
333:                                    .showDialog(
334:                                            RowBandingDefinitionChooser.RowBandingDefinitionPanel.this ,
335:                                            TranslationManager
336:                                                    .getInstance()
337:                                                    .getTranslation("R",
338:                                                            "PropertyEditor.Color.Title"),
339:                                            color);
340:                            if (newColor != null) {
341:                                color = newColor;
342:                                colorIconLabel.setIcon(GraphicUtils
343:                                        .createColorImageIcon(Color.BLACK,
344:                                                color, 130, 20, true));
345:                            }
346:
347:                            rowBandingDefinition = getCurrentRowBandingDefinition();
348:                            samplePanel
349:                                    .setRowBandingDefinition(rowBandingDefinition);
350:                        }
351:                    });
352:
353:                    initialStateColoredRadioButton
354:                            .addChangeListener(new ChangeListener() {
355:                                public void stateChanged(@NotNull
356:                                ChangeEvent e) {
357:                                    rowBandingDefinition = getCurrentRowBandingDefinition();
358:                                    samplePanel
359:                                            .setRowBandingDefinition(rowBandingDefinition);
360:                                }
361:                            });
362:
363:                    initialStateUncoloredRadioButton
364:                            .addChangeListener(new ChangeListener() {
365:                                public void stateChanged(@NotNull
366:                                ChangeEvent e) {
367:                                    rowBandingDefinition = getCurrentRowBandingDefinition();
368:                                    samplePanel
369:                                            .setRowBandingDefinition(rowBandingDefinition);
370:                                }
371:                            });
372:
373:                    switchItemCountSpinner
374:                            .addChangeListener(new ChangeListener() {
375:                                public void stateChanged(@NotNull
376:                                ChangeEvent e) {
377:                                    rowBandingDefinition = getCurrentRowBandingDefinition();
378:                                    samplePanel
379:                                            .setRowBandingDefinition(rowBandingDefinition);
380:                                }
381:                            });
382:
383:                }
384:
385:                private void updateState() {
386:                    colorLabel.setEnabled(enabledCheckBox.isSelected());
387:                    colorIconLabel.setEnabled(enabledCheckBox.isSelected());
388:                    colorButton.setEnabled(enabledCheckBox.isSelected());
389:
390:                    initialStateLabel.setEnabled(enabledCheckBox.isSelected());
391:                    initialStateColoredRadioButton.setEnabled(enabledCheckBox
392:                            .isSelected());
393:                    initialStateUncoloredRadioButton.setEnabled(enabledCheckBox
394:                            .isSelected());
395:
396:                    switchItemCountLabel.setEnabled(enabledCheckBox
397:                            .isSelected());
398:                    switchItemCountSpinner.setEnabled(enabledCheckBox
399:                            .isSelected());
400:                }
401:
402:                @NotNull
403:                private RowBandingDefinition getCurrentRowBandingDefinition() {
404:                    int switchItemCount = ((Number) switchItemCountSpinner
405:                            .getValue()).intValue();
406:
407:                    return new RowBandingDefinition(enabledCheckBox
408:                            .isSelected(), color,
409:                            initialStateColoredRadioButton.isSelected(),
410:                            switchItemCount);
411:                }
412:            }
413:        }
ww__w___.j___a__v__a2_s___.__c___o_m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.