Source Code Cross Referenced for SummaryControl.java in  » GIS » udig-1.1 » net » refractions » udig » project » ui » summary » 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 » GIS » udig 1.1 » net.refractions.udig.project.ui.summary 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* uDig - User Friendly Desktop Internet GIS client
002:         * http://udig.refractions.net
003:         * (C) 2004, Refractions Research Inc.
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation;
008:         * version 2.1 of the License.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         */
015:        package net.refractions.udig.project.ui.summary;
016:
017:        import java.util.Collection;
018:
019:        import org.eclipse.jface.viewers.CellEditor;
020:        import org.eclipse.jface.viewers.ColumnWeightData;
021:        import org.eclipse.jface.viewers.ITableColorProvider;
022:        import org.eclipse.jface.viewers.ITableLabelProvider;
023:        import org.eclipse.jface.viewers.ITreeContentProvider;
024:        import org.eclipse.jface.viewers.LabelProvider;
025:        import org.eclipse.jface.viewers.TableLayout;
026:        import org.eclipse.jface.viewers.TextCellEditor;
027:        import org.eclipse.jface.viewers.TreeViewer;
028:        import org.eclipse.jface.viewers.Viewer;
029:        import org.eclipse.swt.SWT;
030:        import org.eclipse.swt.graphics.Color;
031:        import org.eclipse.swt.graphics.Image;
032:        import org.eclipse.swt.layout.GridData;
033:        import org.eclipse.swt.widgets.Composite;
034:        import org.eclipse.swt.widgets.Control;
035:        import org.eclipse.swt.widgets.Display;
036:        import org.eclipse.swt.widgets.Tree;
037:        import org.eclipse.swt.widgets.TreeColumn;
038:
039:        /**
040:         * A control that shows a TableTree summary of the provided {@link SummaryData}
041:         * @author Jesse
042:         * @since 1.1.0
043:         */
044:        public class SummaryControl {
045:
046:            private static final String VALUE = "VALUE"; //$NON-NLS-1$
047:            private Collection<SummaryData> data;
048:            private TreeViewer viewer;
049:
050:            public SummaryControl(Collection<SummaryData> data) {
051:                this .data = data;
052:            }
053:
054:            public Control createControl(Composite parent) {
055:                Tree tree = new Tree(parent, SWT.V_SCROLL | SWT.H_SCROLL);
056:                tree.setLinesVisible(true);
057:                tree.setHeaderVisible(true);
058:                tree
059:                        .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
060:                                true));
061:                TableLayout tableLayout = new TableLayout();
062:                tableLayout.addColumnData(new ColumnWeightData(1, 200));
063:                tableLayout.addColumnData(new ColumnWeightData(3, 200));
064:                TreeColumn nameColumn = new TreeColumn(tree, SWT.LEFT);
065:                nameColumn.setWidth(200);
066:                TreeColumn infoColumn = new TreeColumn(tree, SWT.LEFT
067:                        | SWT.H_SCROLL);
068:                viewer = new TreeViewer(tree);
069:                viewer.setContentProvider(new SummaryDataProvider());
070:                viewer.setLabelProvider(new SummaryLabelProvider());
071:                viewer.setInput(data);
072:                viewer.setColumnProperties(new String[] { "TITLE", VALUE }); //$NON-NLS-1$
073:
074:                infoColumn.pack();
075:                setCellEditor(viewer);
076:
077:                return tree;
078:            }
079:
080:            private void setCellEditor(TreeViewer viewer) {
081:                TextCellEditor textCellEditor = new TextCellEditor(viewer
082:                        .getTree());
083:                textCellEditor.setValidator(new SummaryCellEditorValidator(
084:                        data, viewer.getTree()));
085:                viewer
086:                        .setCellEditors(new CellEditor[] { null, textCellEditor });
087:                viewer.setCellModifier(new SummaryCellModifier(data));
088:            }
089:
090:            /**
091:             * Refresh an element
092:             *
093:             * @param element
094:             */
095:            public void refresh(Object element) {
096:                viewer.refresh(element);
097:            }
098:
099:            /**
100:             * Applies edits if an editor is active
101:             */
102:            public void applyEdit() {
103:                viewer.getCellEditors()[1].deactivate();
104:            }
105:
106:            /**
107:             * Cancel edits if an editor is active
108:             */
109:            public void cancelEdit() {
110:                viewer.cancelEditing();
111:            }
112:
113:            private class SummaryDataProvider implements  ITreeContentProvider {
114:
115:                public Object[] getChildren(Object parentElement) {
116:                    if (parentElement == data) {
117:                        return data.toArray();
118:                    }
119:                    if (parentElement instanceof  SummaryData) {
120:                        return ((SummaryData) parentElement).getChildren();
121:                    }
122:                    return null;
123:                }
124:
125:                public Object getParent(Object element) {
126:                    if (element instanceof  SummaryData) {
127:                        SummaryData parent = ((SummaryData) element)
128:                                .getParent();
129:                        if (parent == null)
130:                            return data;
131:                        else
132:                            return parent;
133:                    }
134:                    return null;
135:                }
136:
137:                public boolean hasChildren(Object element) {
138:                    if (element == data)
139:                        return true;
140:                    if (element instanceof  SummaryData) {
141:                        SummaryData[] children = ((SummaryData) element)
142:                                .getChildren();
143:                        if (children != null && children.length > 0)
144:                            return true;
145:                    }
146:                    return false;
147:                }
148:
149:                public Object[] getElements(Object inputElement) {
150:                    return getChildren(inputElement);
151:                }
152:
153:                public void dispose() {
154:                }
155:
156:                public void inputChanged(Viewer viewer, Object oldInput,
157:                        Object newInput) {
158:                }
159:
160:            }
161:
162:            private static class SummaryLabelProvider extends LabelProvider
163:                    implements  ITableLabelProvider, ITableColorProvider {
164:
165:                public Image getColumnImage(Object element, int columnIndex) {
166:                    return null;
167:                }
168:
169:                public String getColumnText(Object element, int columnIndex) {
170:                    if (!(element instanceof  SummaryData))
171:                        return null;
172:                    SummaryData data = (SummaryData) element;
173:                    if (columnIndex == 0)
174:                        return data.getTitle();
175:                    return data.getInfo();
176:                }
177:
178:                public Color getBackground(Object element, int columnIndex) {
179:                    return null;
180:                }
181:
182:                public Color getForeground(Object element, int columnIndex) {
183:
184:                    if (columnIndex == 0)
185:                        return null;
186:                    SummaryData data = (SummaryData) element;
187:                    if (data.getModifier().canModify(element, VALUE))
188:                        return null;
189:                    return Display.getCurrent().getSystemColor(
190:                            SWT.COLOR_DARK_GRAY);
191:                }
192:
193:            }
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.