Source Code Cross Referenced for WorkbenchWizardListSelectionPage.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » internal » 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.internal.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.internal.dialogs;
011:
012:        import org.eclipse.jface.dialogs.IDialogSettings;
013:        import org.eclipse.jface.viewers.DoubleClickEvent;
014:        import org.eclipse.jface.viewers.IDoubleClickListener;
015:        import org.eclipse.jface.viewers.ISelectionChangedListener;
016:        import org.eclipse.jface.viewers.IStructuredSelection;
017:        import org.eclipse.jface.viewers.SelectionChangedEvent;
018:        import org.eclipse.jface.viewers.StructuredSelection;
019:        import org.eclipse.jface.viewers.TableViewer;
020:        import org.eclipse.jface.wizard.IWizardNode;
021:        import org.eclipse.swt.SWT;
022:        import org.eclipse.swt.graphics.Font;
023:        import org.eclipse.swt.layout.GridData;
024:        import org.eclipse.swt.layout.GridLayout;
025:        import org.eclipse.swt.widgets.Composite;
026:        import org.eclipse.swt.widgets.Control;
027:        import org.eclipse.swt.widgets.Label;
028:        import org.eclipse.swt.widgets.Table;
029:        import org.eclipse.ui.IWorkbench;
030:        import org.eclipse.ui.internal.WorkbenchMessages;
031:        import org.eclipse.ui.model.AdaptableList;
032:        import org.eclipse.ui.model.WorkbenchLabelProvider;
033:        import org.eclipse.ui.model.WorkbenchViewerComparator;
034:
035:        /**
036:         * Abstract implementation of a wizard selection page which simply displays a
037:         * list of specified wizard elements and allows the user to select one to be
038:         * launched. Subclasses just need to provide a method which creates an
039:         * appropriate wizard node based upon a user selection.
040:         */
041:        public abstract class WorkbenchWizardListSelectionPage extends
042:                WorkbenchWizardSelectionPage implements 
043:                ISelectionChangedListener, IDoubleClickListener {
044:
045:            // id constants
046:            private static final String DIALOG_SETTING_SECTION_NAME = "WizardListSelectionPage."; //$NON-NLS-1$
047:
048:            private final static int SIZING_LISTS_HEIGHT = 200;
049:
050:            private static final String STORE_SELECTED_WIZARD_ID = DIALOG_SETTING_SECTION_NAME
051:                    + "STORE_SELECTED_WIZARD_ID"; //$NON-NLS-1$
052:
053:            private TableViewer viewer;
054:
055:            private String message;
056:
057:            /**
058:             * Creates a <code>WorkbenchWizardListSelectionPage</code>.
059:             * 
060:             * @param aWorkbench the current workbench
061:             * @param currentSelection the workbench's current resource selection
062:             * @param wizardElements the collection of <code>WorkbenchWizardElements</code>
063:             *            to display for selection
064:             * @param message the message to display above the selection list
065:             * @param triggerPointId the trigger point id
066:             */
067:            protected WorkbenchWizardListSelectionPage(IWorkbench aWorkbench,
068:                    IStructuredSelection currentSelection,
069:                    AdaptableList wizardElements, String message,
070:                    String triggerPointId) {
071:                super (
072:                        "singleWizardSelectionPage", aWorkbench, currentSelection, wizardElements, triggerPointId); //$NON-NLS-1$
073:                setDescription(WorkbenchMessages.WizardList_description);
074:                this .message = message;
075:            }
076:
077:            /*
078:             * (non-Javadoc)
079:             * 
080:             * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
081:             */
082:            public void createControl(Composite parent) {
083:
084:                Font font = parent.getFont();
085:
086:                // create composite for page.
087:                Composite outerContainer = new Composite(parent, SWT.NONE);
088:                outerContainer.setLayout(new GridLayout());
089:                outerContainer.setLayoutData(new GridData(
090:                        GridData.VERTICAL_ALIGN_FILL
091:                                | GridData.HORIZONTAL_ALIGN_FILL));
092:                outerContainer.setFont(font);
093:
094:                Label messageLabel = new Label(outerContainer, SWT.NONE);
095:                messageLabel.setText(message);
096:                messageLabel.setFont(font);
097:
098:                createViewer(outerContainer);
099:                layoutTopControl(viewer.getControl());
100:
101:                restoreWidgetValues();
102:
103:                setControl(outerContainer);
104:            }
105:
106:            /**
107:             * Create a new viewer in the parent.
108:             * 
109:             * @param parent the parent <code>Composite</code>.
110:             */
111:            private void createViewer(Composite parent) {
112:                //Create a table for the list
113:                Table table = new Table(parent, SWT.BORDER);
114:                table.setFont(parent.getFont());
115:
116:                // the list viewer
117:                viewer = new TableViewer(table);
118:                viewer.setContentProvider(new WizardContentProvider());
119:                viewer.setLabelProvider(new WorkbenchLabelProvider());
120:                viewer.setComparator(new WorkbenchViewerComparator());
121:                viewer.addSelectionChangedListener(this );
122:                viewer.addDoubleClickListener(this );
123:                viewer.setInput(wizardElements);
124:            }
125:
126:            /**
127:             * Returns an <code>IWizardNode</code> representing the specified
128:             * workbench wizard which has been selected by the user. <b>Subclasses
129:             * </b> must override this abstract implementation.
130:             * 
131:             * @param element the wizard element that an <code>IWizardNode</code> is
132:             *            needed for
133:             * @return org.eclipse.jface.wizards.IWizardNode
134:             */
135:            protected abstract IWizardNode createWizardNode(
136:                    WorkbenchWizardElement element);
137:
138:            /**
139:             * An item in a viewer has been double-clicked.
140:             */
141:            public void doubleClick(DoubleClickEvent event) {
142:                selectionChanged(new SelectionChangedEvent(event.getViewer(),
143:                        event.getViewer().getSelection()));
144:                getContainer().showPage(getNextPage());
145:            }
146:
147:            /**
148:             * Layout the top control.
149:             * 
150:             * @param control the control.
151:             * @since 3.0
152:             */
153:            private void layoutTopControl(Control control) {
154:                GridData data = new GridData(GridData.FILL_BOTH);
155:
156:                int availableRows = DialogUtil.availableRows(control
157:                        .getParent());
158:
159:                //Only give a height hint if the dialog is going to be too small
160:                if (availableRows > 50) {
161:                    data.heightHint = SIZING_LISTS_HEIGHT;
162:                } else {
163:                    data.heightHint = availableRows * 3;
164:                }
165:
166:                control.setLayoutData(data);
167:
168:            }
169:
170:            /**
171:             * Uses the dialog store to restore widget values to the values that they
172:             * held last time this wizard was used to completion.
173:             */
174:            private void restoreWidgetValues() {
175:
176:                IDialogSettings settings = getDialogSettings();
177:                if (settings == null) {
178:                    return;
179:                }
180:
181:                String wizardId = settings.get(STORE_SELECTED_WIZARD_ID);
182:                WorkbenchWizardElement wizard = findWizard(wizardId);
183:                if (wizard == null) {
184:                    return;
185:                }
186:
187:                StructuredSelection selection = new StructuredSelection(wizard);
188:                viewer.setSelection(selection);
189:            }
190:
191:            /**
192:             * Since Finish was pressed, write widget values to the dialog store so
193:             * that they will persist into the next invocation of this wizard page
194:             */
195:            public void saveWidgetValues() {
196:                IStructuredSelection sel = (IStructuredSelection) viewer
197:                        .getSelection();
198:                if (sel.size() > 0) {
199:                    WorkbenchWizardElement selectedWizard = (WorkbenchWizardElement) sel
200:                            .getFirstElement();
201:                    getDialogSettings().put(STORE_SELECTED_WIZARD_ID,
202:                            selectedWizard.getId());
203:                }
204:            }
205:
206:            /**
207:             * Notes the newly-selected wizard element and updates the page
208:             * accordingly.
209:             * 
210:             * @param event the selection changed event
211:             */
212:            public void selectionChanged(SelectionChangedEvent event) {
213:                setErrorMessage(null);
214:                IStructuredSelection selection = (IStructuredSelection) event
215:                        .getSelection();
216:                WorkbenchWizardElement currentWizardSelection = (WorkbenchWizardElement) selection
217:                        .getFirstElement();
218:                if (currentWizardSelection == null) {
219:                    setMessage(null);
220:                    setSelectedNode(null);
221:                    return;
222:                }
223:
224:                setSelectedNode(createWizardNode(currentWizardSelection));
225:                setMessage(currentWizardSelection.getDescription());
226:            }
227:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.