Source Code Cross Referenced for TableOrTreeColumnsMgr.java in  » Project-Management » Activity-Manager » jfb » tools » activitymgr » ui » util » 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 » Project Management » Activity Manager » jfb.tools.activitymgr.ui.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2004-2006, Jean-François Brazeau. All rights reserved.
003:         * 
004:         * Redistribution and use in source and binary forms, with or without 
005:         * modification, are permitted provided that the following conditions are met:
006:         *
007:         *  1. Redistributions of source code must retain the above copyright notice,
008:         *     this list of conditions and the following disclaimer.
009:         * 
010:         *  2. Redistributions in binary form must reproduce the above copyright
011:         *     notice, this list of conditions and the following disclaimer in the
012:         *     documentation and/or other materials provided with the distribution.
013:         * 
014:         *  3. The name of the author may not be used to endorse or promote products
015:         *     derived from this software without specific prior written permission.
016:         *
017:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
018:         * IMPLIEDWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
019:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
020:         * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
021:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
022:         * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
023:         * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
024:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
025:         * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
026:         * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027:         */
028:        package jfb.tools.activitymgr.ui.util;
029:
030:        import java.util.ArrayList;
031:
032:        import org.apache.log4j.Logger;
033:        import org.eclipse.jface.viewers.TableViewer;
034:        import org.eclipse.jface.viewers.TreeViewer;
035:        import org.eclipse.swt.widgets.Table;
036:        import org.eclipse.swt.widgets.TableColumn;
037:        import org.eclipse.swt.widgets.Tree;
038:        import org.eclipse.swt.widgets.TreeColumn;
039:
040:        /**
041:         * Classe de base des gestionnaires de colonnes de tableau ou d'arbres.
042:         */
043:        public class TableOrTreeColumnsMgr {
044:
045:            /** Logger */
046:            private static Logger log = Logger
047:                    .getLogger(TableOrTreeColumnsMgr.class);
048:
049:            /** Liste des colonnes */
050:            private ArrayList columns = new ArrayList();
051:
052:            /**
053:             * Configure les colonnes de l'arbre.
054:             * @param treeViewer le viewer de l'arbre.
055:             */
056:            public void configureTree(TreeViewer treeViewer) {
057:                log.debug("configureTree");
058:                treeViewer.setColumnProperties(getColumnCodes());
059:                Tree tree = treeViewer.getTree();
060:                Column[] columns = getColumns();
061:                for (int i = 0; i < columns.length; i++) {
062:                    Column column = columns[i];
063:                    TreeColumn treeColumn = new TreeColumn(tree,
064:                            column.alignment);
065:                    treeColumn.setText(column.name);
066:                    treeColumn.setWidth(column.width);
067:                }
068:            }
069:
070:            /**
071:             * Configure les colonnes d'un tableau.
072:             * @param tableViewer le viewer du tableau.
073:             */
074:            public void configureTable(TableViewer tableViewer) {
075:                log.debug("configureTable");
076:                tableViewer.setColumnProperties(getColumnCodes());
077:                Table table = tableViewer.getTable();
078:                Column[] columns = getColumns();
079:                for (int i = 0; i < columns.length; i++) {
080:                    Column column = columns[i];
081:                    TableColumn tableColumn = new TableColumn(table,
082:                            column.alignment);
083:                    tableColumn.setText(column.name);
084:                    tableColumn.setWidth(column.width);
085:                }
086:            }
087:
088:            /**
089:             * Ajoute une colonne.
090:             * @param columnCode le code de colonne.
091:             * @param columnName le nom de la colonne.
092:             * @param columnWidth la largeur de la colonne.
093:             * @param columnAlignment l'alignement à appliquer à la colonne.
094:             */
095:            public void addColumn(String columnCode, String columnName,
096:                    int columnWidth, int columnAlignment) {
097:                Column newColumn = new Column();
098:                if (columnName == null)
099:                    throw new NullPointerException("Column name cannot be null");
100:                newColumn.code = columnCode;
101:                newColumn.name = columnName;
102:                newColumn.width = columnWidth;
103:                newColumn.alignment = columnAlignment;
104:                columns.add(newColumn);
105:            }
106:
107:            /**
108:             * @return le code associé à la colonne dont le N° est spécifié.
109:             * @param columnIndex numéro de la colonne.
110:             */
111:            public String getColumnCode(int columnIndex) {
112:                String code = ((Column) columns.get(columnIndex)).code;
113:                log.debug("getColumnCode(" + columnIndex + ")=" + code);
114:                return code;
115:            }
116:
117:            /**
118:             * @return le numéro associé à la colonne dont le code est spécifié.
119:             * @param columnCode code de la colonne.
120:             */
121:            public int getColumnIndex(String columnCode) {
122:                int index = -1;
123:                for (int i = 0; i < columns.size() && index < 0; i++) {
124:                    Column column = (Column) columns.get(i);
125:                    if (column.code.equals(columnCode))
126:                        index = i;
127:                }
128:                log.debug("getColumnIndex(" + columnCode + ")=" + index);
129:                return index;
130:            }
131:
132:            /**
133:             * @return la liste des codes des colonnes.
134:             */
135:            private String[] getColumnCodes() {
136:                int n = columns.size();
137:                String[] columnNames = new String[n];
138:                for (int i = 0; i < n; i++)
139:                    columnNames[i] = getColumnCode(i);
140:                return columnNames;
141:            }
142:
143:            /**
144:             * @return Retourne la liste des colonnes.
145:             */
146:            private Column[] getColumns() {
147:                return (Column[]) columns.toArray(new Column[columns.size()]);
148:            }
149:
150:        }
151:
152:        /**
153:         * Bean contenant les attributs dune colonne.
154:         */
155:        class Column {
156:            String code;
157:            String name;
158:            int width;
159:            int alignment;
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.