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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 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:         *******************************************************************************/package org.eclipse.ui.dialogs;
011:
012:        import java.util.List;
013:
014:        import org.eclipse.jface.dialogs.IDialogConstants;
015:        import org.eclipse.jface.viewers.DoubleClickEvent;
016:        import org.eclipse.jface.viewers.IDoubleClickListener;
017:        import org.eclipse.jface.viewers.ILabelProvider;
018:        import org.eclipse.jface.viewers.IStructuredContentProvider;
019:        import org.eclipse.jface.viewers.IStructuredSelection;
020:        import org.eclipse.jface.viewers.StructuredSelection;
021:        import org.eclipse.jface.viewers.TableViewer;
022:        import org.eclipse.swt.SWT;
023:        import org.eclipse.swt.layout.GridData;
024:        import org.eclipse.swt.widgets.Composite;
025:        import org.eclipse.swt.widgets.Control;
026:        import org.eclipse.swt.widgets.Shell;
027:        import org.eclipse.swt.widgets.Table;
028:
029:        /**
030:         * A dialog that prompts for one element out of a list of elements. Uses
031:         * <code>IStructuredContentProvider</code> to provide the elements and
032:         * <code>ILabelProvider</code> to provide their labels.
033:         * 
034:         * @since 2.1
035:         */
036:        public class ListDialog extends SelectionDialog {
037:            private IStructuredContentProvider fContentProvider;
038:
039:            private ILabelProvider fLabelProvider;
040:
041:            private Object fInput;
042:
043:            private TableViewer fTableViewer;
044:
045:            private boolean fAddCancelButton = true;
046:
047:            private int widthInChars = 55;
048:
049:            private int heightInChars = 15;
050:
051:            /**
052:             * Create a new instance of the receiver with parent shell of parent.
053:             * @param parent
054:             */
055:            public ListDialog(Shell parent) {
056:                super (parent);
057:            }
058:
059:            /**
060:             * @param input The input for the list.
061:             */
062:            public void setInput(Object input) {
063:                fInput = input;
064:            }
065:
066:            /**
067:             * @param sp The content provider for the list.
068:             */
069:            public void setContentProvider(IStructuredContentProvider sp) {
070:                fContentProvider = sp;
071:            }
072:
073:            /**
074:             * @param lp The labelProvider for the list.
075:             */
076:            public void setLabelProvider(ILabelProvider lp) {
077:                fLabelProvider = lp;
078:            }
079:
080:            /**
081:             *@param addCancelButton if <code>true</code> there will be a cancel
082:             * button.
083:             */
084:            public void setAddCancelButton(boolean addCancelButton) {
085:                fAddCancelButton = addCancelButton;
086:            }
087:
088:            /**
089:             * @return the TableViewer for the receiver.
090:             */
091:            public TableViewer getTableViewer() {
092:                return fTableViewer;
093:            }
094:
095:            protected void createButtonsForButtonBar(Composite parent) {
096:                if (!fAddCancelButton) {
097:                    createButton(parent, IDialogConstants.OK_ID,
098:                            IDialogConstants.OK_LABEL, true);
099:                } else {
100:                    super .createButtonsForButtonBar(parent);
101:                }
102:            }
103:
104:            protected Control createDialogArea(Composite container) {
105:                Composite parent = (Composite) super 
106:                        .createDialogArea(container);
107:                createMessageArea(parent);
108:                fTableViewer = new TableViewer(parent, getTableStyle());
109:                fTableViewer.setContentProvider(fContentProvider);
110:                fTableViewer.setLabelProvider(fLabelProvider);
111:                fTableViewer.setInput(fInput);
112:                fTableViewer.addDoubleClickListener(new IDoubleClickListener() {
113:                    public void doubleClick(DoubleClickEvent event) {
114:                        if (fAddCancelButton) {
115:                            okPressed();
116:                        }
117:                    }
118:                });
119:                List initialSelection = getInitialElementSelections();
120:                if (initialSelection != null) {
121:                    fTableViewer.setSelection(new StructuredSelection(
122:                            initialSelection));
123:                }
124:                GridData gd = new GridData(GridData.FILL_BOTH);
125:                gd.heightHint = convertHeightInCharsToPixels(heightInChars);
126:                gd.widthHint = convertWidthInCharsToPixels(widthInChars);
127:                Table table = fTableViewer.getTable();
128:                table.setLayoutData(gd);
129:                table.setFont(container.getFont());
130:                return parent;
131:            }
132:
133:            /**
134:             * Return the style flags for the table viewer.
135:             * @return int
136:             */
137:            protected int getTableStyle() {
138:                return SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
139:            }
140:
141:            /*
142:             * Overrides method from Dialog
143:             */
144:            protected void okPressed() {
145:                // Build a list of selected children.
146:                IStructuredSelection selection = (IStructuredSelection) fTableViewer
147:                        .getSelection();
148:                setResult(selection.toList());
149:                super .okPressed();
150:            }
151:
152:            /**
153:             * Returns the initial height of the dialog in number of characters.
154:             * 
155:             * @return the initial height of the dialog in number of characters
156:             */
157:            public int getHeightInChars() {
158:                return heightInChars;
159:            }
160:
161:            /**
162:             * Returns the initial width of the dialog in number of characters.
163:             * 
164:             * @return the initial width of the dialog in number of characters
165:             */
166:            public int getWidthInChars() {
167:                return widthInChars;
168:            }
169:
170:            /**
171:             * Sets the initial height of the dialog in number of characters.
172:             * 
173:             * @param heightInChars
174:             *            the initialheight of the dialog in number of characters
175:             */
176:            public void setHeightInChars(int heightInChars) {
177:                this .heightInChars = heightInChars;
178:            }
179:
180:            /**
181:             * Sets the initial width of the dialog in number of characters.
182:             * 
183:             * @param widthInChars
184:             *            the initial width of the dialog in number of characters
185:             */
186:            public void setWidthInChars(int widthInChars) {
187:                this.widthInChars = widthInChars;
188:            }
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.