Source Code Cross Referenced for BooleanTableCellRenderer.java in  » Report » pentaho-report » org » pentaho » reportdesigner » crm » report » properties » renderers » 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.renderers 
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.renderers;
015:
016:        import org.jetbrains.annotations.NotNull;
017:        import org.jetbrains.annotations.Nullable;
018:        import org.pentaho.reportdesigner.crm.report.PropertyKeys;
019:        import org.pentaho.reportdesigner.lib.client.i18n.TranslationManager;
020:        import org.pentaho.reportdesigner.lib.client.util.UIConstants;
021:
022:        import javax.swing.*;
023:        import javax.swing.border.Border;
024:        import javax.swing.border.EmptyBorder;
025:        import javax.swing.table.TableCellRenderer;
026:        import java.awt.*;
027:        import java.util.HashSet;
028:
029:        /**
030:         * User: Martin
031:         * Date: 21.10.2005
032:         * Time: 09:15:46
033:         */
034:        public class BooleanTableCellRenderer extends JCheckBox implements 
035:                TableCellRenderer {
036:
037:            @NotNull
038:            protected static final Border noFocusBorder = new EmptyBorder(1, 1,
039:                    1, 1);
040:
041:            // We need a place to store the color the JLabel should be returned
042:            // to after its foreground and background colors have been set
043:            // to the selection background color.
044:            // These ivars will be made protected when their names are finalized.
045:            @Nullable
046:            private Color unselectedForeground;
047:            @Nullable
048:            private Color unselectedBackground;
049:
050:            /**
051:             * Creates a default table cell renderer.
052:             */
053:            public BooleanTableCellRenderer() {
054:                super ();
055:                setOpaque(true);
056:                setBorder(noFocusBorder);
057:            }
058:
059:            /**
060:             * Overrides <code>JComponent.setForeground</code> to assign
061:             * the unselected-foreground color to the specified color.
062:             *
063:             * @param c set the foreground color to this value
064:             */
065:            public void setForeground(@Nullable
066:            Color c) {
067:                super .setForeground(c);
068:                unselectedForeground = c;
069:            }
070:
071:            /**
072:             * Overrides <code>JComponent.setBackground</code> to assign
073:             * the unselected-background color to the specified color.
074:             *
075:             * @param c set the background color to this value
076:             */
077:            public void setBackground(@Nullable
078:            Color c) {
079:                super .setBackground(c);
080:                unselectedBackground = c;
081:            }
082:
083:            /**
084:             * Notification from the <code>UIManager</code> that the look and feel
085:             * [L&F] has changed.
086:             * Replaces the current UI object with the latest version from the
087:             * <code>UIManager</code>.
088:             *
089:             * @see JComponent#updateUI
090:             */
091:            public void updateUI() {
092:                super .updateUI();
093:                setForeground(null);
094:                setBackground(null);
095:            }
096:
097:            // implements javax.swing.table.TableCellRenderer
098:
099:            /**
100:             * Returns the default table cell renderer.
101:             *
102:             * @param table      the <code>JTable</code>
103:             * @param value      the value to assign to the cell at
104:             *                   <code>[row, column]</code>
105:             * @param isSelected true if cell is selected
106:             * @param hasFocus   true if cell has focus
107:             * @param row        the row of the cell to render
108:             * @param column     the column of the cell to render
109:             * @return the default table cell renderer
110:             */
111:            @NotNull
112:            public Component getTableCellRendererComponent(@NotNull
113:            JTable table, @Nullable
114:            Object value, boolean isSelected, boolean hasFocus, int row,
115:                    int column) {
116:
117:                if (isSelected) {
118:                    super .setForeground(table.getSelectionForeground());
119:                    super .setBackground(table.getSelectionBackground());
120:                } else {
121:                    super 
122:                            .setForeground((unselectedForeground != null) ? unselectedForeground
123:                                    : table.getForeground());
124:                    super 
125:                            .setBackground((unselectedBackground != null) ? unselectedBackground
126:                                    : table.getBackground());
127:                }
128:
129:                setFont(table.getFont());
130:
131:                if (hasFocus) {
132:                    Border border = null;
133:                    if (isSelected) {
134:                        border = UIManager
135:                                .getBorder(UIConstants.TABLE_FOCUS_SELECTED_CELL_HIGHLIGHT_BORDER);
136:                    }
137:                    if (border == null) {
138:                        border = UIManager
139:                                .getBorder(UIConstants.TABLE_FOCUS_CELL_HIGHLIGHT_BORDER);
140:                    }
141:                    setBorder(border);
142:
143:                    if (!isSelected && table.isCellEditable(row, column)) {
144:                        Color col;
145:                        col = UIManager
146:                                .getColor(UIConstants.TABLE_FOCUS_CELL_FOREGROUND);
147:                        if (col != null) {
148:                            super .setForeground(col);
149:                        }
150:                        col = UIManager
151:                                .getColor(UIConstants.TABLE_FOCUS_CELL_BACKGROUND);
152:                        if (col != null) {
153:                            super .setBackground(col);
154:                        }
155:                    }
156:                } else {
157:                    setBorder(noFocusBorder);
158:                }
159:
160:                setValue(value);
161:
162:                return this ;
163:            }
164:
165:            /*
166:             * The following methods are overridden as a performance measure to
167:             * to prune code-paths are often called in the case of renders
168:             * but which we know are unnecessary.  Great care should be taken
169:             * when writing your own renderer to weigh the benefits and
170:             * drawbacks of overriding methods like these.
171:             */
172:
173:            /**
174:             * Overridden for performance reasons.
175:             * See the <a href="#override">Implementation Note</a>
176:             * for more information.
177:             */
178:            public boolean isOpaque() {
179:                Color back = getBackground();
180:                Component p = getParent();
181:                if (p != null) {
182:                    p = p.getParent();
183:                }
184:                // p should now be the JTable.
185:                boolean colorMatch = (back != null) && (p != null)
186:                        && back.equals(p.getBackground()) && p.isOpaque();
187:                return !colorMatch && super .isOpaque();
188:            }
189:
190:            /**
191:             * Overridden for performance reasons.
192:             * See the <a href="#override">Implementation Note</a>
193:             * for more information.
194:             *
195:             * @since 1.5
196:             */
197:            public void invalidate() {
198:            }
199:
200:            /**
201:             * Overridden for performance reasons.
202:             * See the <a href="#override">Implementation Note</a>
203:             * for more information.
204:             */
205:            public void validate() {
206:            }
207:
208:            /**
209:             * Overridden for performance reasons.
210:             * See the <a href="#override">Implementation Note</a>
211:             * for more information.
212:             */
213:            public void revalidate() {
214:            }
215:
216:            /**
217:             * Overridden for performance reasons.
218:             * See the <a href="#override">Implementation Note</a>
219:             * for more information.
220:             */
221:            public void repaint(long tm, int x, int y, int width, int height) {
222:            }
223:
224:            /**
225:             * Overridden for performance reasons.
226:             * See the <a href="#override">Implementation Note</a>
227:             * for more information.
228:             */
229:            public void repaint(@NotNull
230:            Rectangle r) {
231:            }
232:
233:            /**
234:             * Overridden for performance reasons.
235:             * See the <a href="#override">Implementation Note</a>
236:             * for more information.
237:             *
238:             * @since 1.5
239:             */
240:            public void repaint() {
241:            }
242:
243:            /**
244:             * Overridden for performance reasons.
245:             * See the <a href="#override">Implementation Note</a>
246:             * for more information.
247:             */
248:            protected void firePropertyChange(@NotNull
249:            String propertyName, @Nullable
250:            Object oldValue, @Nullable
251:            Object newValue) {
252:                // Strings get interned...
253:                if (PropertyKeys.TEXT.equals(propertyName)) {
254:                    super .firePropertyChange(propertyName, oldValue, newValue);
255:                }
256:            }
257:
258:            /**
259:             * Overridden for performance reasons.
260:             * See the <a href="#override">Implementation Note</a>
261:             * for more information.
262:             */
263:            public void firePropertyChange(@NotNull
264:            String propertyName, boolean oldValue, boolean newValue) {
265:            }
266:
267:            /**
268:             * Sets the <code>String</code> object for the cell being rendered to
269:             * <code>value</code>.
270:             *
271:             * @param value the string value for this cell; if value is
272:             *              <code>null</code> it sets the text value to an empty string
273:             * @see JLabel#setText
274:             */
275:            protected void setValue(@Nullable
276:            Object value) {
277:                if (value instanceof  HashSet) {
278:                    HashSet<?> hashSet = (HashSet<?>) value;
279:                    if (hashSet.size() > 1) {
280:                        setText(TranslationManager.getInstance()
281:                                .getTranslation("R", "Property.MultipleValues"));
282:                        setEnabled(false);
283:                    }
284:
285:                    if (hashSet.size() == 1) {
286:                        Boolean selected = (Boolean) hashSet.iterator().next();
287:                        if (selected == null) {
288:                            selected = Boolean.FALSE;
289:                        }
290:                        setSelected(selected.booleanValue());
291:                        setEnabled(true);
292:                        if (selected.booleanValue()) {
293:                            setText(TranslationManager.getInstance()
294:                                    .getTranslation("R",
295:                                            "Property.Boolean.True"));
296:                        } else {
297:                            setText(TranslationManager.getInstance()
298:                                    .getTranslation("R",
299:                                            "Property.Boolean.False"));
300:                        }
301:                    }
302:                }
303:            }
304:
305:            public static class UIResource extends BooleanTableCellRenderer
306:                    implements  javax.swing.plaf.UIResource {
307:            }
308:
309:        }
w__w__w.__ja___v_a___2__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.