Source Code Cross Referenced for DynamicTestsView.java in  » IDE-Eclipse » ui » org » eclipse » ui » tests » views » properties » tabbed » dynamic » views » 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 » org.eclipse.ui.tests.views.properties.tabbed.dynamic.views 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 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.ui.tests.views.properties.tabbed.dynamic.views;
011:
012:        import org.eclipse.jface.action.Action;
013:        import org.eclipse.jface.action.IAction;
014:        import org.eclipse.jface.action.IToolBarManager;
015:        import org.eclipse.jface.resource.ImageDescriptor;
016:        import org.eclipse.jface.viewers.LabelProvider;
017:        import org.eclipse.jface.viewers.StructuredSelection;
018:        import org.eclipse.jface.viewers.TreeViewer;
019:        import org.eclipse.swt.SWT;
020:        import org.eclipse.swt.graphics.Image;
021:        import org.eclipse.swt.widgets.Composite;
022:        import org.eclipse.ui.ISharedImages;
023:        import org.eclipse.ui.PlatformUI;
024:        import org.eclipse.ui.part.ViewPart;
025:        import org.eclipse.ui.tests.views.properties.tabbed.Activator;
026:        import org.eclipse.ui.tests.views.properties.tabbed.dynamic.model.DynamicTestsElement;
027:        import org.eclipse.ui.views.properties.IPropertySheetPage;
028:        import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
029:        import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
030:
031:        /**
032:         * A view to test dynamic contributions to the tabbed properties view. The view
033:         * has three modes of providing tabs and sections to the tabbed properties view:
034:         * use static contributions from plugin.xml, use dynamic section contributions
035:         * from code, or use dynamic tab (and section) contributions from code.
036:         * 
037:         * @author Anthony Hunter
038:         */
039:        public class DynamicTestsView extends ViewPart implements 
040:                ITabbedPropertySheetPageContributor {
041:
042:            class DynamicTestsViewLabelProvider extends LabelProvider {
043:
044:                public Image getImage(Object obj) {
045:                    DynamicTestsElement element = ((DynamicTestsTreeNode) obj)
046:                            .getDynamicTestsElement();
047:                    return element.getImage();
048:                }
049:
050:                public String getText(Object obj) {
051:                    DynamicTestsElement element = ((DynamicTestsTreeNode) obj)
052:                            .getDynamicTestsElement();
053:                    return element.getName();
054:                }
055:            }
056:
057:            public static final String DYNAMIC_TESTS_VIEW_ID = "org.eclipse.ui.tests.views.properties.tabbed.dynamic.views.DynamicTestsView"; //$NON-NLS-1$
058:
059:            public static final String DYNAMIC_TESTS_VIEW_STATIC = "org.eclipse.ui.tests.views.properties.tabbed.static"; //$NON-NLS-1$
060:
061:            public static final String DYNAMIC_TESTS_VIEW_DYNAMIC_TABS = "org.eclipse.ui.tests.views.properties.tabbed.dynamic.tab"; //$NON-NLS-1$
062:
063:            public static final String DYNAMIC_TESTS_VIEW_DYNAMIC_SECTIONS = "org.eclipse.ui.tests.views.properties.tabbed.dynamic.section"; //$NON-NLS-1$
064:            private Action dynamicSectionsAction;
065:
066:            private Action dynamicTabsAction;
067:
068:            private Action staticAction;
069:
070:            private TabbedPropertySheetPage tabbedPropertySheetPage;
071:
072:            private TreeViewer viewer;
073:
074:            public void createPartControl(Composite parent) {
075:                viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL
076:                        | SWT.V_SCROLL);
077:                viewer.setContentProvider(new DynamicTestsViewContentProvider(
078:                        this ));
079:                viewer.setLabelProvider(new DynamicTestsViewLabelProvider());
080:                viewer.setInput(getViewSite());
081:                initToolBar();
082:                getSite().setSelectionProvider(viewer);
083:            }
084:
085:            public Object getAdapter(Class adapter) {
086:                if (adapter == IPropertySheetPage.class) {
087:                    if (tabbedPropertySheetPage == null) {
088:                        tabbedPropertySheetPage = new TabbedPropertySheetPage(
089:                                this );
090:                    }
091:                    return tabbedPropertySheetPage;
092:                }
093:                return super .getAdapter(adapter);
094:            }
095:
096:            public String getContributorId() {
097:                if (staticAction.isChecked()) {
098:                    return DYNAMIC_TESTS_VIEW_STATIC;
099:                } else if (dynamicSectionsAction.isChecked()) {
100:                    return DYNAMIC_TESTS_VIEW_DYNAMIC_SECTIONS;
101:                } else if (dynamicTabsAction.isChecked()) {
102:                    return DYNAMIC_TESTS_VIEW_DYNAMIC_TABS;
103:                } else {
104:                    return null;
105:                }
106:            }
107:
108:            public void setContributorId(String contributorId) {
109:                if (DYNAMIC_TESTS_VIEW_STATIC.equals(contributorId)) {
110:                    staticAction.setChecked(true);
111:                    dynamicSectionsAction.setChecked(false);
112:                    dynamicTabsAction.setChecked(false);
113:                } else if (DYNAMIC_TESTS_VIEW_DYNAMIC_SECTIONS
114:                        .equals(contributorId)) {
115:                    staticAction.setChecked(false);
116:                    dynamicSectionsAction.setChecked(true);
117:                    dynamicTabsAction.setChecked(false);
118:                } else if (DYNAMIC_TESTS_VIEW_DYNAMIC_TABS
119:                        .equals(contributorId)) {
120:                    staticAction.setChecked(false);
121:                    dynamicSectionsAction.setChecked(false);
122:                    dynamicTabsAction.setChecked(true);
123:                }
124:            }
125:
126:            public TabbedPropertySheetPage getTabbedPropertySheetPage() {
127:                return tabbedPropertySheetPage;
128:            }
129:
130:            public TreeViewer getViewer() {
131:                return viewer;
132:            }
133:
134:            /**
135:             * Create the tool bar for the view. The tool bar has three toggle buttons
136:             * which enable one of the three property contributors.
137:             */
138:            private void initToolBar() {
139:                final String staticText = "Use static contributions from plugin.xml"; //$NON-NLS-1$
140:                final String dynamicSectionsText = "Use dynamic section contributions from code"; //$NON-NLS-1$
141:                final String dynamicTabsText = "Use dynamic tab (and section) contributions from code"; //$NON-NLS-1$
142:                ImageDescriptor imageDescriptor = Activator
143:                        .getImageDescriptor("icons/sample.gif");//$NON-NLS-1$
144:                if (imageDescriptor == null) {
145:                    imageDescriptor = PlatformUI.getWorkbench()
146:                            .getSharedImages().getImageDescriptor(
147:                                    ISharedImages.IMG_OBJS_ERROR_TSK);
148:                }
149:
150:                staticAction = new Action(staticText, IAction.AS_CHECK_BOX) {
151:                    public void run() {
152:                        if (isChecked()) {
153:                            getViewSite().getActionBars()
154:                                    .getStatusLineManager().setMessage(
155:                                            staticText);
156:                            dynamicSectionsAction.setChecked(false);
157:                            dynamicTabsAction.setChecked(false);
158:                            viewer.setSelection(StructuredSelection.EMPTY);
159:                        }
160:                    }
161:                };
162:                staticAction.setToolTipText(staticText);
163:                staticAction.setImageDescriptor(imageDescriptor);
164:                staticAction.setDisabledImageDescriptor(imageDescriptor);
165:
166:                dynamicSectionsAction = new Action(dynamicSectionsText,
167:                        IAction.AS_CHECK_BOX) {
168:                    public void run() {
169:                        if (isChecked()) {
170:                            getViewSite().getActionBars()
171:                                    .getStatusLineManager().setMessage(
172:                                            dynamicSectionsText);
173:                            staticAction.setChecked(false);
174:                            dynamicTabsAction.setChecked(false);
175:                            viewer.setSelection(StructuredSelection.EMPTY);
176:                        }
177:                    }
178:                };
179:                dynamicSectionsAction.setToolTipText(dynamicSectionsText);
180:                dynamicSectionsAction.setImageDescriptor(imageDescriptor);
181:                dynamicSectionsAction
182:                        .setDisabledImageDescriptor(imageDescriptor);
183:
184:                dynamicTabsAction = new Action(dynamicTabsText,
185:                        IAction.AS_CHECK_BOX) {
186:                    public void run() {
187:                        if (isChecked()) {
188:                            getViewSite().getActionBars()
189:                                    .getStatusLineManager().setMessage(
190:                                            dynamicTabsText);
191:                            staticAction.setChecked(false);
192:                            dynamicSectionsAction.setChecked(false);
193:                            viewer.setSelection(StructuredSelection.EMPTY);
194:                        }
195:                    }
196:                };
197:                dynamicTabsAction.setToolTipText(dynamicTabsText);
198:                dynamicTabsAction.setImageDescriptor(imageDescriptor);
199:                dynamicTabsAction.setDisabledImageDescriptor(imageDescriptor);
200:                staticAction.setChecked(true);
201:
202:                IToolBarManager toolBarManager = getViewSite().getActionBars()
203:                        .getToolBarManager();
204:                toolBarManager.add(staticAction);
205:                toolBarManager.add(dynamicSectionsAction);
206:                toolBarManager.add(dynamicTabsAction);
207:
208:                getViewSite().getActionBars().getStatusLineManager()
209:                        .setMessage(staticText);
210:            }
211:
212:            public void setFocus() {
213:                viewer.getControl().setFocus();
214:            }
215:        }
w_w_w.__j___a__v_a__2__s__.c___o_m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.