Source Code Cross Referenced for ComboViewer.java in  » IDE-Eclipse » jface » org » eclipse » jface » viewers » 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 » IDE Eclipse » jface » org.eclipse.jface.viewers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2004-2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *     Sebastian Davids - bug 69254
011:         *******************************************************************************/package org.eclipse.jface.viewers;
012:
013:        import org.eclipse.core.runtime.Assert;
014:        import org.eclipse.swt.SWT;
015:        import org.eclipse.swt.custom.CCombo;
016:        import org.eclipse.swt.widgets.Combo;
017:        import org.eclipse.swt.widgets.Composite;
018:        import org.eclipse.swt.widgets.Control;
019:
020:        /**
021:         * A concrete viewer based either on an SWT <code>Combo</code> control or <code>CCombo</code>
022:         * control. This class is intended as an alternative to the JFace <code>ListViewer</code>, which displays
023:         * its content in a combo box rather than a list. Wherever possible, this class attempts to behave
024:         * like ListViewer. <p>
025:         * 
026:         * This class is designed to be instantiated with a pre-existing SWT combo control 
027:         * and configured with a domain-specific content provider, label provider, element
028:         * filter (optional), and element sorter (optional).
029:         * </p>
030:         * 
031:         * @see org.eclipse.jface.viewers.ListViewer
032:         * @since 3.0
033:         */
034:        public final class ComboViewer extends AbstractListViewer {
035:
036:            /**
037:             * This viewer's list control if this viewer is instantiated with a combo control; otherwise
038:             * <code>null</code>.
039:             * 
040:             * @see #ComboViewer(Combo)
041:             */
042:            private Combo combo;
043:
044:            /**
045:             * This viewer's list control if this viewer is instantiated with a CCombo control; otherwise
046:             * <code>null</code>.
047:             * 
048:             * @see #ComboViewer(CCombo)
049:             * @since 3.3
050:             */
051:            private CCombo ccombo;
052:
053:            /**
054:             * Creates a combo viewer on a newly-created combo control under the given parent.
055:             * The viewer has no input, no content provider, a default label provider, 
056:             * no sorter, and no filters.
057:             *
058:             * @param parent the parent control
059:             */
060:            public ComboViewer(Composite parent) {
061:                this (parent, SWT.READ_ONLY | SWT.BORDER);
062:            }
063:
064:            /**
065:             * Creates a combo viewer on a newly-created combo control under the given parent.
066:             * The combo control is created using the given SWT style bits.
067:             * The viewer has no input, no content provider, a default label provider, 
068:             * no sorter, and no filters.
069:             *
070:             * @param parent the parent control
071:             * @param style the SWT style bits
072:             */
073:            public ComboViewer(Composite parent, int style) {
074:                this (new Combo(parent, style));
075:            }
076:
077:            /**
078:             * Creates a combo viewer on the given combo control.
079:             * The viewer has no input, no content provider, a default label provider, 
080:             * no sorter, and no filters.
081:             *
082:             * @param list the combo control
083:             */
084:            public ComboViewer(Combo list) {
085:                this .combo = list;
086:                hookControl(list);
087:            }
088:
089:            /**
090:             * Creates a combo viewer on the given CCombo control.
091:             * The viewer has no input, no content provider, a default label provider, 
092:             * no sorter, and no filters.
093:             *
094:             * @param list the CCombo control
095:             * @since 3.3
096:             */
097:            public ComboViewer(CCombo list) {
098:                this .ccombo = list;
099:                hookControl(list);
100:            }
101:
102:            protected void listAdd(String string, int index) {
103:                if (combo == null) {
104:                    ccombo.add(string, index);
105:                } else {
106:                    combo.add(string, index);
107:                }
108:            }
109:
110:            protected void listSetItem(int index, String string) {
111:                if (combo == null) {
112:                    ccombo.setItem(index, string);
113:                } else {
114:                    combo.setItem(index, string);
115:                }
116:            }
117:
118:            protected int[] listGetSelectionIndices() {
119:                if (combo == null) {
120:                    return new int[] { ccombo.getSelectionIndex() };
121:                } else {
122:                    return new int[] { combo.getSelectionIndex() };
123:                }
124:            }
125:
126:            protected int listGetItemCount() {
127:                if (combo == null) {
128:                    return ccombo.getItemCount();
129:                } else {
130:                    return combo.getItemCount();
131:                }
132:            }
133:
134:            protected void listSetItems(String[] labels) {
135:                if (combo == null) {
136:                    ccombo.setItems(labels);
137:                } else {
138:                    combo.setItems(labels);
139:                }
140:            }
141:
142:            protected void listRemoveAll() {
143:                if (combo == null) {
144:                    ccombo.removeAll();
145:                } else {
146:                    combo.removeAll();
147:                }
148:            }
149:
150:            protected void listRemove(int index) {
151:                if (combo == null) {
152:                    ccombo.remove(index);
153:                } else {
154:                    combo.remove(index);
155:                }
156:            }
157:
158:            /* (non-Javadoc)
159:             * Method declared on Viewer.
160:             */
161:            public Control getControl() {
162:                if (combo == null) {
163:                    return ccombo;
164:                } else {
165:                    return combo;
166:                }
167:            }
168:
169:            /**
170:             * Returns this list viewer's list control. If the viewer was not created on
171:             * a CCombo control, some kind of unchecked exception is thrown.
172:             * 
173:             * @return the list control
174:             * @since 3.3
175:             */
176:            public CCombo getCCombo() {
177:                Assert.isNotNull(ccombo);
178:                return ccombo;
179:            }
180:
181:            /**
182:             * Returns this list viewer's list control. If the viewer was not created on
183:             * a Combo control, some kind of unchecked exception is thrown.
184:             *
185:             * @return the list control
186:             */
187:            public Combo getCombo() {
188:                Assert.isNotNull(combo);
189:                return combo;
190:            }
191:
192:            /*
193:             * Do nothing -- combos only display the selected element, so there is no way
194:             * we can ensure that the given element is visible without changing the selection.
195:             * Method defined on StructuredViewer.
196:             */
197:            public void reveal(Object element) {
198:            }
199:
200:            /* (non-Javadoc)
201:             * @see org.eclipse.jface.viewers.AbstractListViewer#listSetSelection(int[])
202:             */
203:            protected void listSetSelection(int[] ixs) {
204:                if (combo == null) {
205:                    for (int idx = 0; idx < ixs.length; idx++) {
206:                        ccombo.select(ixs[idx]);
207:                    }
208:                } else {
209:                    for (int idx = 0; idx < ixs.length; idx++) {
210:                        combo.select(ixs[idx]);
211:                    }
212:                }
213:            }
214:
215:            /* (non-Javadoc)
216:             * @see org.eclipse.jface.viewers.AbstractListViewer#listDeselectAll()
217:             */
218:            protected void listDeselectAll() {
219:                if (combo == null) {
220:                    ccombo.deselectAll();
221:                    ccombo.clearSelection();
222:                } else {
223:                    combo.deselectAll();
224:                    combo.clearSelection();
225:                }
226:            }
227:
228:            /* (non-Javadoc)
229:             * @see org.eclipse.jface.viewers.AbstractListViewer#listShowSelection()
230:             */
231:            protected void listShowSelection() {
232:            }
233:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.