Source Code Cross Referenced for TemplateSelectionPage.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » wizards » templates » 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 » Eclipse plug in development » org.eclipse.pde.internal.ui.wizards.templates 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2007 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.pde.internal.ui.wizards.templates;
011:
012:        import java.util.ArrayList;
013:
014:        import org.eclipse.jface.dialogs.Dialog;
015:        import org.eclipse.jface.viewers.CheckboxTableViewer;
016:        import org.eclipse.jface.viewers.ColumnWeightData;
017:        import org.eclipse.jface.viewers.ISelectionChangedListener;
018:        import org.eclipse.jface.viewers.IStructuredContentProvider;
019:        import org.eclipse.jface.viewers.IStructuredSelection;
020:        import org.eclipse.jface.viewers.ITableLabelProvider;
021:        import org.eclipse.jface.viewers.LabelProvider;
022:        import org.eclipse.jface.viewers.SelectionChangedEvent;
023:        import org.eclipse.jface.viewers.StructuredViewer;
024:        import org.eclipse.jface.viewers.TableLayout;
025:        import org.eclipse.jface.wizard.IWizardPage;
026:        import org.eclipse.jface.wizard.Wizard;
027:        import org.eclipse.jface.wizard.WizardPage;
028:        import org.eclipse.pde.internal.ui.IHelpContextIds;
029:        import org.eclipse.pde.internal.ui.PDEPlugin;
030:        import org.eclipse.pde.internal.ui.PDEPluginImages;
031:        import org.eclipse.pde.internal.ui.PDEUIMessages;
032:        import org.eclipse.pde.internal.ui.elements.DefaultContentProvider;
033:        import org.eclipse.pde.internal.ui.parts.FormBrowser;
034:        import org.eclipse.pde.internal.ui.parts.WizardCheckboxTablePart;
035:        import org.eclipse.pde.ui.templates.ITemplateSection;
036:        import org.eclipse.swt.SWT;
037:        import org.eclipse.swt.graphics.Image;
038:        import org.eclipse.swt.layout.GridData;
039:        import org.eclipse.swt.layout.GridLayout;
040:        import org.eclipse.swt.widgets.Composite;
041:        import org.eclipse.swt.widgets.Control;
042:        import org.eclipse.swt.widgets.Table;
043:        import org.eclipse.swt.widgets.TableColumn;
044:        import org.eclipse.ui.PlatformUI;
045:        import org.eclipse.ui.forms.widgets.FormToolkit;
046:
047:        public class TemplateSelectionPage extends WizardPage {
048:            private ITemplateSection[] fCandidates;
049:            private ArrayList fVisiblePages;
050:            private WizardCheckboxTablePart fTablePart;
051:            private FormBrowser fDescriptionBrowser;
052:
053:            class TablePart extends WizardCheckboxTablePart {
054:                public TablePart(String mainLabel) {
055:                    super (mainLabel);
056:                }
057:
058:                protected StructuredViewer createStructuredViewer(
059:                        Composite parent, int style, FormToolkit toolkit) {
060:                    return super .createStructuredViewer(parent, style
061:                            | SWT.FULL_SELECTION, toolkit);
062:                }
063:
064:                protected void updateCounter(int amount) {
065:                    super .updateCounter(amount);
066:                    if (getContainer() != null)
067:                        getContainer().updateButtons();
068:                }
069:            }
070:
071:            class ListContentProvider extends DefaultContentProvider implements 
072:                    IStructuredContentProvider {
073:                public Object[] getElements(Object parent) {
074:                    return fCandidates;
075:                }
076:            }
077:
078:            class ListLabelProvider extends LabelProvider implements 
079:                    ITableLabelProvider {
080:                public String getColumnText(Object obj, int index) {
081:                    ITemplateSection section = (ITemplateSection) obj;
082:                    if (index == 0)
083:                        return section.getLabel();
084:                    return section.getUsedExtensionPoint();
085:                }
086:
087:                public Image getColumnImage(Object obj, int index) {
088:                    if (index == 0)
089:                        return PDEPlugin.getDefault().getLabelProvider().get(
090:                                PDEPluginImages.DESC_EXTENSION_OBJ);
091:                    return PDEPlugin.getDefault().getLabelProvider().get(
092:                            PDEPluginImages.DESC_EXT_POINT_OBJ);
093:                }
094:            }
095:
096:            /**
097:             * Constructor for TemplateSelectionPage.
098:             * @param pageName
099:             */
100:            public TemplateSelectionPage(ITemplateSection[] candidates) {
101:                super ("templateSelection"); //$NON-NLS-1$
102:                fCandidates = candidates;
103:                setTitle(PDEUIMessages.TemplateSelectionPage_title);
104:                setDescription(PDEUIMessages.TemplateSelectionPage_desc);
105:                initializeTemplates();
106:            }
107:
108:            private void initializeTemplates() {
109:                fTablePart = new TablePart(
110:                        PDEUIMessages.TemplateSelectionPage_table);
111:                fDescriptionBrowser = new FormBrowser(SWT.BORDER | SWT.V_SCROLL);
112:                fDescriptionBrowser.setText(""); //$NON-NLS-1$
113:                PDEPlugin.getDefault().getLabelProvider().connect(this );
114:                fVisiblePages = new ArrayList();
115:            }
116:
117:            public void dispose() {
118:                super .dispose();
119:                PDEPlugin.getDefault().getLabelProvider().disconnect(this );
120:            }
121:
122:            /**
123:             * @see IDialogPage#createControl(Composite)
124:             */
125:            public void createControl(Composite parent) {
126:                Composite container = new Composite(parent, SWT.NULL);
127:                GridLayout layout = new GridLayout();
128:                container.setLayout(layout);
129:                layout.numColumns = 2;
130:                fTablePart.createControl(container);
131:                CheckboxTableViewer viewer = fTablePart.getTableViewer();
132:                viewer.setContentProvider(new ListContentProvider());
133:                viewer.setLabelProvider(new ListLabelProvider());
134:                initializeTable(viewer.getTable());
135:
136:                viewer
137:                        .addSelectionChangedListener(new ISelectionChangedListener() {
138:                            public void selectionChanged(
139:                                    SelectionChangedEvent event) {
140:                                IStructuredSelection sel = (IStructuredSelection) event
141:                                        .getSelection();
142:                                handleSelectionChanged((ITemplateSection) sel
143:                                        .getFirstElement());
144:                            }
145:                        });
146:                fDescriptionBrowser.createControl(container);
147:                Control c = fDescriptionBrowser.getControl();
148:                GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL
149:                        | GridData.FILL_VERTICAL);
150:                gd.heightHint = 100;
151:                //gd.horizontalSpan = 2;
152:                c.setLayoutData(gd);
153:                viewer.setInput(PDEPlugin.getDefault());
154:                // add all wizard pages to wizard.  Just don't iniatilize them right away (bug 174457)
155:                initializeWizardPages();
156:                fTablePart.selectAll(true);
157:                setControl(container);
158:                Dialog.applyDialogFont(container);
159:                PlatformUI.getWorkbench().getHelpSystem().setHelp(container,
160:                        IHelpContextIds.TEMPLATE_SELECTION);
161:            }
162:
163:            private void initializeWizardPages() {
164:                for (int i = 0; i < fCandidates.length; i++) {
165:                    ITemplateSection section = fCandidates[i];
166:                    if (section.getPagesAdded() == false)
167:                        section.addPages((Wizard) getWizard());
168:                }
169:            }
170:
171:            public ITemplateSection[] getSelectedTemplates() {
172:                Object[] elements = fTablePart.getTableViewer()
173:                        .getCheckedElements();
174:                ITemplateSection[] result = new ITemplateSection[elements.length];
175:                System.arraycopy(elements, 0, result, 0, elements.length);
176:                return result;
177:            }
178:
179:            private void initializeTable(Table table) {
180:                table.setHeaderVisible(true);
181:                TableColumn column = new TableColumn(table, SWT.NULL);
182:                column.setText(PDEUIMessages.TemplateSelectionPage_column_name);
183:                column.setResizable(true);
184:                column = new TableColumn(table, SWT.NULL);
185:                column
186:                        .setText(PDEUIMessages.TemplateSelectionPage_column_point);
187:                column.setResizable(true);
188:
189:                TableLayout layout = new TableLayout();
190:                layout.addColumnData(new ColumnWeightData(50));
191:                layout.addColumnData(new ColumnWeightData(50));
192:                table.setLayout(layout);
193:            }
194:
195:            private void handleSelectionChanged(ITemplateSection section) {
196:                String text = section != null ? section.getDescription() : ""; //$NON-NLS-1$
197:                if (text.length() > 0)
198:                    text = "<p>" + text + "</p>"; //$NON-NLS-1$ //$NON-NLS-2$
199:                fDescriptionBrowser.setText(text);
200:            }
201:
202:            public boolean canFlipToNextPage() {
203:                if (fTablePart.getSelectionCount() == 0)
204:                    return false;
205:                return super .canFlipToNextPage();
206:            }
207:
208:            public IWizardPage getNextPage() {
209:                ITemplateSection[] sections = getSelectedTemplates();
210:                fVisiblePages.clear();
211:
212:                for (int i = 0; i < sections.length; i++) {
213:                    ITemplateSection section = sections[i];
214:
215:                    for (int j = 0; j < section.getPageCount(); j++) {
216:                        fVisiblePages.add(section.getPage(j));
217:                    }
218:                }
219:                if (fVisiblePages.size() > 0)
220:                    return (IWizardPage) fVisiblePages.get(0);
221:
222:                return null;
223:            }
224:
225:            public IWizardPage getNextVisiblePage(IWizardPage page) {
226:                if (page == this )
227:                    return page.getNextPage();
228:                int index = fVisiblePages.indexOf(page);
229:                if (index >= 0 && index < fVisiblePages.size() - 1)
230:                    return (IWizardPage) fVisiblePages.get(index + 1);
231:                return null;
232:            }
233:
234:        }
w_ww__.___java_2___s___._co__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.