Source Code Cross Referenced for IndividualBlock.java in  » ERP-CRM-Financial » jmoney » net » sf » jmoney » entrytable » 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 » ERP CRM Financial » jmoney » net.sf.jmoney.entrytable 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *
003:         *  JMoney - A Personal Finance Manager
004:         *  Copyright (c) 2007 Nigel Westbury <westbury@users.sf.net>
005:         *
006:         *
007:         *  This program is free software; you can redistribute it and/or modify
008:         *  it under the terms of the GNU General Public License as published by
009:         *  the Free Software Foundation; either version 2 of the License, or
010:         *  (at your option) any later version.
011:         *
012:         *  This program is distributed in the hope that it will be useful,
013:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         *  GNU General Public License for more details.
016:         *
017:         *  You should have received a copy of the GNU General Public License
018:         *  along with this program; if not, write to the Free Software
019:         *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
020:         *
021:         */
022:
023:        package net.sf.jmoney.entrytable;
024:
025:        import java.util.Comparator;
026:
027:        import org.eclipse.swt.SWT;
028:        import org.eclipse.swt.events.SelectionAdapter;
029:        import org.eclipse.swt.events.SelectionEvent;
030:        import org.eclipse.swt.widgets.Composite;
031:        import org.eclipse.swt.widgets.Display;
032:        import org.eclipse.swt.widgets.Label;
033:        import org.eclipse.swt.widgets.Menu;
034:        import org.eclipse.swt.widgets.MenuItem;
035:        import org.eclipse.swt.widgets.Shell;
036:
037:        /**
038:         * Represents a column of data that can be displayed in the entries table,
039:         * edited by the user, sorted, or used in a filter.
040:         * <P>
041:         * All columns are managed by an object of this class.  Special
042:         * implementations exist for the credit, debit, and balance columns.
043:         * More generic implementations exist for the other properties.
044:         */
045:        public abstract class IndividualBlock<T, R> extends CellBlock<T, R> {
046:
047:            /**
048:             * The localized text to be shown in the header.
049:             */
050:            private String text;
051:
052:            public IndividualBlock(String text, int minimumWidth, int weight) {
053:                super (minimumWidth, weight);
054:                this .text = text;
055:            }
056:
057:            @Override
058:            public void createHeaderControls(Composite parent, T entryData) {
059:                Label label = new Label(parent, SWT.NULL);
060:                label.setText(text);
061:                label.setBackground(Display.getCurrent().getSystemColor(
062:                        SWT.COLOR_GRAY));
063:
064:                label.setMenu(buildPopupMenu(parent.getShell()));
065:            }
066:
067:            @Override
068:            void layout(int width) {
069:                this .width = width;
070:            }
071:
072:            /**
073:             * @return a comparator to be used for sorting rows based on the values in
074:             *         this column, or null if this column is not suitable for sorting
075:             */
076:            public Comparator<T> getComparator() {
077:                return null;
078:            }
079:
080:            private Menu buildPopupMenu(Shell shell) {
081:                // Bring up a pop-up menu.
082:                // It would be a more consistent interface if this menu were
083:                // linked to the column header.  However, TableColumn has
084:                // no setMenu method, nor does the column header respond to
085:                // SWT.MenuDetect nor any other event when right clicked.
086:                // This code works but does not follow the popup-menu conventions
087:                // on even one platform!
088:
089:                Menu popupMenu = new Menu(shell, SWT.POP_UP);
090:
091:                MenuItem removeColItem = new MenuItem(popupMenu, SWT.NONE);
092:
093:                MenuItem shiftColLeftItem = new MenuItem(popupMenu, SWT.NONE);
094:
095:                MenuItem shiftColRightItem = new MenuItem(popupMenu, SWT.NONE);
096:
097:                Object[] messageArgs = new Object[] { text };
098:
099:                removeColItem.setText(new java.text.MessageFormat(
100:                        "Remove {0} column", java.util.Locale.US)
101:                        .format(messageArgs));
102:                shiftColLeftItem.setText(new java.text.MessageFormat(
103:                        "Move {0} column left", java.util.Locale.US)
104:                        .format(messageArgs));
105:                shiftColRightItem.setText(new java.text.MessageFormat(
106:                        "Move {0} column right", java.util.Locale.US)
107:                        .format(messageArgs));
108:
109:                removeColItem.addSelectionListener(new SelectionAdapter() {
110:                    @Override
111:                    public void widgetSelected(SelectionEvent e) {
112:                        // TODO:
113:                    }
114:                });
115:
116:                shiftColLeftItem.addSelectionListener(new SelectionAdapter() {
117:                    @Override
118:                    public void widgetSelected(SelectionEvent e) {
119:                        // TODO: shift left if we can
120:                    }
121:                });
122:
123:                shiftColRightItem.addSelectionListener(new SelectionAdapter() {
124:                    @Override
125:                    public void widgetSelected(SelectionEvent e) {
126:                        // TODO: shift right if we can
127:                    }
128:                });
129:
130:                /* TODO: complete implementation of this.
131:                 * We need to allow the user to add columns?????
132:                
133:                 new MenuItem(popupMenu, SWT.SEPARATOR);
134:                
135:                 for (final IEntriesTableProperty entriesSectionProperty: entriesContent.getAllEntryDataObjects()) {
136:                 boolean found = false;
137:                 for (int index = 0; index < fTable.getColumnCount(); index++) {
138:                 IEntriesTableProperty entryData2 = (IEntriesTableProperty) (fTable
139:                 .getColumn(index).getData());
140:                 if (entryData2 == entriesSectionProperty) {
141:                 found = true;
142:                 break;
143:                 }
144:                 }
145:
146:                 if (!found) {
147:                 Object[] messageArgs2 = new Object[] { entriesSectionProperty
148:                 .getText() };
149:
150:                 MenuItem addColItem = new MenuItem(popupMenu,
151:                 SWT.NONE);
152:                 addColItem.setText(new java.text.MessageFormat(
153:                 "Add {0} column", java.util.Locale.US)
154:                 .format(messageArgs2));
155:
156:                 addColItem
157:                 .addSelectionListener(new SelectionAdapter() {
158:                 public void widgetSelected(
159:                 SelectionEvent e) {
160:                 addColumn(entriesSectionProperty,
161:                 Math.max(1, column));
162:                 }
163:                 });
164:                 }
165:                 }
166:                 */
167:                //		popupMenu.setVisible(true);
168:                return popupMenu;
169:            }
170:
171:            public String getText() {
172:                return text;
173:            }
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.