Source Code Cross Referenced for WorkingSetTypePage.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, 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:         * 		  Sebastian Davids <sdavids@gmx.de> - Fix for bug 19346 - Dialog font should be
011:         *        activated and used by other components.
012:         *******************************************************************************/package org.eclipse.ui.internal.dialogs;
013:
014:        import org.eclipse.jface.resource.ImageDescriptor;
015:        import org.eclipse.jface.resource.JFaceResources;
016:        import org.eclipse.jface.resource.LocalResourceManager;
017:        import org.eclipse.jface.resource.ResourceManager;
018:        import org.eclipse.jface.viewers.ArrayContentProvider;
019:        import org.eclipse.jface.viewers.DoubleClickEvent;
020:        import org.eclipse.jface.viewers.IDoubleClickListener;
021:        import org.eclipse.jface.viewers.ISelection;
022:        import org.eclipse.jface.viewers.ISelectionChangedListener;
023:        import org.eclipse.jface.viewers.IStructuredSelection;
024:        import org.eclipse.jface.viewers.LabelProvider;
025:        import org.eclipse.jface.viewers.SelectionChangedEvent;
026:        import org.eclipse.jface.viewers.TableViewer;
027:        import org.eclipse.jface.wizard.WizardPage;
028:        import org.eclipse.swt.SWT;
029:        import org.eclipse.swt.graphics.Font;
030:        import org.eclipse.swt.graphics.Image;
031:        import org.eclipse.swt.layout.GridData;
032:        import org.eclipse.swt.layout.GridLayout;
033:        import org.eclipse.swt.widgets.Composite;
034:        import org.eclipse.swt.widgets.Label;
035:        import org.eclipse.ui.PlatformUI;
036:        import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
037:        import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
038:        import org.eclipse.ui.internal.WorkbenchImages;
039:        import org.eclipse.ui.internal.WorkbenchMessages;
040:        import org.eclipse.ui.internal.WorkbenchPlugin;
041:        import org.eclipse.ui.internal.registry.WorkingSetDescriptor;
042:
043:        /**
044:         * The working set type page is used in the new working set 
045:         * wizard to select from a list of plugin defined working set 
046:         * types.
047:         * 
048:         * @since 2.0
049:         */
050:        public class WorkingSetTypePage extends WizardPage {
051:            private final static int SIZING_SELECTION_WIDGET_WIDTH = 50;
052:
053:            private final static int SIZING_SELECTION_WIDGET_HEIGHT = 200;
054:
055:            private TableViewer typesListViewer;
056:
057:            private WorkingSetDescriptor[] descriptors;
058:
059:            /**
060:             * Creates a new instance of the receiver
061:             */
062:            public WorkingSetTypePage() {
063:                this (WorkbenchPlugin.getDefault().getWorkingSetRegistry()
064:                        .getNewPageWorkingSetDescriptors());
065:            }
066:
067:            /**
068:             * @param descriptors a set of working set descriptors which can be selected on the page
069:             */
070:            public WorkingSetTypePage(WorkingSetDescriptor[] descriptors) {
071:                super (
072:                        "workingSetTypeSelectionPage", WorkbenchMessages.WorkingSetTypePage_description, WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_WIZBAN_WORKINGSET_WIZ)); //$NON-NLS-1$ 
073:                this .descriptors = descriptors;
074:            }
075:
076:            /**
077:             * Overrides method in WizardPage
078:             * 
079:             * @see org.eclipse.jface.wizard.IWizardPage#canFlipToNextPage()
080:             */
081:            public boolean canFlipToNextPage() {
082:                return isPageComplete();
083:            }
084:
085:            /** 
086:             * Implements IDialogPage
087:             * 
088:             * @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite)
089:             */
090:            public void createControl(Composite parent) {
091:                Font font = parent.getFont();
092:                Composite composite = new Composite(parent, SWT.NULL);
093:                composite.setLayout(new GridLayout());
094:                composite.setLayoutData(new GridData(
095:                        GridData.HORIZONTAL_ALIGN_FILL));
096:                setControl(composite);
097:
098:                PlatformUI.getWorkbench().getHelpSystem().setHelp(composite,
099:                        IWorkbenchHelpContextIds.WORKING_SET_TYPE_PAGE);
100:                Label typesLabel = new Label(composite, SWT.NONE);
101:                typesLabel
102:                        .setText(WorkbenchMessages.WorkingSetTypePage_typesLabel);
103:                GridData data = new GridData(GridData.FILL_HORIZONTAL);
104:                typesLabel.setLayoutData(data);
105:                typesLabel.setFont(font);
106:
107:                typesListViewer = new TableViewer(composite, SWT.BORDER
108:                        | SWT.SINGLE);
109:                data = new GridData(GridData.FILL_BOTH);
110:                data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
111:                data.widthHint = SIZING_SELECTION_WIDGET_WIDTH;
112:                typesListViewer.getTable().setLayoutData(data);
113:                typesListViewer.getTable().setFont(font);
114:                typesListViewer
115:                        .addSelectionChangedListener(new ISelectionChangedListener() {
116:                            public void selectionChanged(
117:                                    SelectionChangedEvent event) {
118:                                handleSelectionChanged();
119:                            }
120:                        });
121:                typesListViewer
122:                        .addDoubleClickListener(new IDoubleClickListener() {
123:                            public void doubleClick(DoubleClickEvent event) {
124:                                handleDoubleClick();
125:                            }
126:                        });
127:                typesListViewer.setContentProvider(new ArrayContentProvider());
128:                typesListViewer.setLabelProvider(new LabelProvider() {
129:                    private ResourceManager images = new LocalResourceManager(
130:                            JFaceResources.getResources());
131:
132:                    /*
133:                     * (non-Javadoc)
134:                     * 
135:                     * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
136:                     */
137:                    public String getText(Object element) {
138:                        return ((WorkingSetDescriptor) element).getName();
139:                    }
140:
141:                    /* (non-Javadoc)
142:                     * @see org.eclipse.jface.viewers.BaseLabelProvider#dispose()
143:                     */
144:                    public void dispose() {
145:                        images.dispose();
146:                        super .dispose();
147:                    }
148:
149:                    /*
150:                     * (non-Javadoc)
151:                     * 
152:                     * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
153:                     */
154:                    public Image getImage(Object element) {
155:                        ImageDescriptor imageDescriptor = ((WorkingSetDescriptor) element)
156:                                .getIcon();
157:                        return imageDescriptor == null ? null : (Image) images
158:                                .get(imageDescriptor);
159:                    }
160:                });
161:                typesListViewer.setInput(descriptors);
162:                setPageComplete(false);
163:            }
164:
165:            /** 
166:             * Overrides method in DialogPage
167:             * 
168:             * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
169:             */
170:            public void dispose() {
171:                super .dispose();
172:            }
173:
174:            /**
175:             * Returns the page id of the selected working set type.
176:             * 
177:             * @return the page id of the selected working set type.
178:             */
179:            public String getSelection() {
180:                WorkingSetDescriptor descriptor = getSelectedWorkingSet();
181:                if (descriptor != null)
182:                    return descriptor.getId();
183:
184:                return null;
185:            }
186:
187:            /**
188:             * Return the selected working set.
189:             *
190:             * @return the selected working set or <code>null</code>
191:             * @since 3.4
192:             */
193:            private WorkingSetDescriptor getSelectedWorkingSet() {
194:                ISelection selection = typesListViewer.getSelection();
195:                boolean hasSelection = selection != null
196:                        && selection.isEmpty() == false;
197:
198:                WorkingSetDescriptor descriptor = null;
199:                if (hasSelection && selection instanceof  IStructuredSelection) {
200:                    descriptor = (WorkingSetDescriptor) ((IStructuredSelection) selection)
201:                            .getFirstElement();
202:                }
203:                return descriptor;
204:            }
205:
206:            /**
207:             * Called when a working set type is double clicked.
208:             */
209:            private void handleDoubleClick() {
210:                handleSelectionChanged();
211:                getContainer().showPage(getNextPage());
212:            }
213:
214:            /**
215:             * Called when the selection has changed.
216:             */
217:            private void handleSelectionChanged() {
218:                ISelection selection = typesListViewer.getSelection();
219:                boolean hasSelection = selection != null
220:                        && selection.isEmpty() == false;
221:
222:                WorkingSetDescriptor descriptor = getSelectedWorkingSet();
223:                setDescription(descriptor == null ? "" : descriptor.getDescription()); //$NON-NLS-1$
224:
225:                setPageComplete(hasSelection);
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.