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


001:        /*******************************************************************************
002:         * Copyright (c) 2001, 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.internal.views.properties.tabbed.view;
011:
012:        import java.util.ArrayList;
013:        import java.util.List;
014:
015:        import org.eclipse.core.runtime.CoreException;
016:        import org.eclipse.core.runtime.IConfigurationElement;
017:        import org.eclipse.core.runtime.IStatus;
018:        import org.eclipse.core.runtime.Status;
019:        import org.eclipse.jface.viewers.IFilter;
020:        import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewPlugin;
021:        import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewStatusCodes;
022:        import org.eclipse.ui.internal.views.properties.tabbed.l10n.TabbedPropertyMessages;
023:        import org.eclipse.ui.views.properties.tabbed.AbstractSectionDescriptor;
024:        import org.eclipse.ui.views.properties.tabbed.ISection;
025:        import org.eclipse.ui.views.properties.tabbed.ITypeMapper;
026:
027:        import com.ibm.icu.text.MessageFormat;
028:
029:        /**
030:         * Represents the default implementation of a section descriptor on the tabbed
031:         * property sections extensions. This implementation assumes that we are
032:         * interested in selected objects in an IStructuredSelection.
033:         * 
034:         * @author Anthony Hunter
035:         */
036:        public class SectionDescriptor extends AbstractSectionDescriptor {
037:
038:            private static final String ATT_ID = "id"; //$NON-NLS-1$
039:
040:            private static final String ATT_TARGET_TAB = "tab"; //$NON-NLS-1$
041:
042:            private static final String ATT_AFTER_SECTION = "afterSection"; //$NON-NLS-1$
043:
044:            private static final String ATT_CLASS = "class"; //$NON-NLS-1$
045:
046:            private static final String ATT_SECTION_FILTER = "filter"; //$NON-NLS-1$	
047:
048:            private static final String ATT_SECTION_ENABLES_FOR = "enablesFor"; //$NON-NLS-1$	
049:
050:            private static final String ATT_INPUT_TYPE = "type"; //$NON-NLS-1$
051:
052:            private static final String ELEMENT_INPUT = "input"; //$NON-NLS-1$
053:
054:            private String id;
055:
056:            private String targetTab;
057:
058:            private String afterSection;
059:
060:            private ArrayList inputTypes;
061:
062:            private IFilter filter;
063:
064:            private int enablesFor = ENABLES_FOR_ANY;
065:
066:            private IConfigurationElement configurationElement;
067:
068:            /**
069:             * Constructor for the section descriptor.
070:             * 
071:             * @param configurationElement
072:             *            the configuration element for the section descriptor.
073:             * @param typeMapper
074:             *            The type mapper.
075:             */
076:            protected SectionDescriptor(
077:                    IConfigurationElement configurationElement,
078:                    ITypeMapper typeMapper) {
079:                super (typeMapper);
080:                this .configurationElement = configurationElement;
081:
082:                id = getConfigurationElement().getAttribute(ATT_ID);
083:                targetTab = getConfigurationElement().getAttribute(
084:                        ATT_TARGET_TAB);
085:                afterSection = getConfigurationElement().getAttribute(
086:                        ATT_AFTER_SECTION);
087:                if (getConfigurationElement().getAttribute(
088:                        ATT_SECTION_ENABLES_FOR) != null) {
089:                    String enablesForStr = getConfigurationElement()
090:                            .getAttribute(ATT_SECTION_ENABLES_FOR);
091:                    int enablesForTest = Integer.parseInt(enablesForStr);
092:                    if (enablesForTest > 0) {
093:                        enablesFor = enablesForTest;
094:                    }
095:                }
096:
097:                if (id == null || targetTab == null) {
098:                    // the section id and tab are mandatory - log error
099:                    handleSectionError(null);
100:                }
101:            }
102:
103:            /**
104:             * Handle the section error when an issue is found loading from the
105:             * configuration element.
106:             * 
107:             * @param configurationElement
108:             *            the configuration element
109:             * @param exception
110:             *            an optional CoreException
111:             */
112:            private void handleSectionError(CoreException exception) {
113:                String pluginId = getConfigurationElement()
114:                        .getDeclaringExtension().getNamespaceIdentifier();
115:                String message = TabbedPropertyMessages.SectionDescriptor_Section_error;
116:                if (exception == null) {
117:                    message = MessageFormat
118:                            .format(
119:                                    TabbedPropertyMessages.SectionDescriptor_Section_error,
120:                                    new Object[] { pluginId });
121:                } else {
122:                    message = MessageFormat
123:                            .format(
124:                                    TabbedPropertyMessages.SectionDescriptor_class_not_found_error,
125:                                    new Object[] { pluginId });
126:                }
127:                IStatus status = new Status(IStatus.ERROR, pluginId,
128:                        TabbedPropertyViewStatusCodes.SECTION_ERROR, message,
129:                        exception);
130:                TabbedPropertyViewPlugin.getPlugin().getLog().log(status);
131:            }
132:
133:            /**
134:             * @see org.eclipse.ui.views.properties.tabbed.ISectionDescriptor#getId()
135:             */
136:            public String getId() {
137:                return id;
138:            }
139:
140:            /**
141:             * @see org.eclipse.ui.views.properties.tabbed.ISectionDescriptor#getFilter()
142:             */
143:            public IFilter getFilter() {
144:                if (filter == null) {
145:                    try {
146:                        if (getConfigurationElement().getAttribute(
147:                                ATT_SECTION_FILTER) != null) {
148:                            filter = (IFilter) configurationElement
149:                                    .createExecutableExtension(ATT_SECTION_FILTER);
150:                        }
151:                    } catch (CoreException exception) {
152:                        handleSectionError(exception);
153:                    }
154:                }
155:                return filter;
156:            }
157:
158:            /**
159:             * Retrieves the value for section enablement which is a precise number of
160:             * items selected. For example: enablesFor=" 4" enables the action only when
161:             * 4 items are selected. If not specified, enable for all selections.
162:             * 
163:             * @return the value for section enablement.
164:             */
165:            public int getEnablesFor() {
166:                return enablesFor;
167:            }
168:
169:            /**
170:             * @see org.eclipse.ui.views.properties.tabbed.ISectionDescriptor#getTargetTab()
171:             */
172:            public String getTargetTab() {
173:                return targetTab;
174:            }
175:
176:            /**
177:             * @see org.eclipse.ui.views.properties.tabbed.ISectionDescriptor#getAfterSection()
178:             */
179:            public String getAfterSection() {
180:                if (afterSection == null) {
181:                    return super .getAfterSection();
182:                }
183:                return afterSection;
184:            }
185:
186:            /**
187:             * Creates an instance of a section described by this descriptor
188:             * 
189:             * @see org.eclipse.ui.views.properties.tabbed.ISectionDescriptor#getSectionClass()
190:             */
191:            public ISection getSectionClass() {
192:                ISection section = null;
193:                try {
194:                    section = (ISection) getConfigurationElement()
195:                            .createExecutableExtension(ATT_CLASS);
196:                } catch (CoreException exception) {
197:                    handleSectionError(exception);
198:                }
199:
200:                return section;
201:            }
202:
203:            /**
204:             * Gets the input types that are valid for this section.
205:             * 
206:             * @see org.eclipse.ui.views.properties.tabbed.ISectionDescriptor#getInputTypes()
207:             */
208:            public List getInputTypes() {
209:                if (inputTypes == null) {
210:                    inputTypes = new ArrayList();
211:                    IConfigurationElement[] elements = getConfigurationElement()
212:                            .getChildren(ELEMENT_INPUT);
213:                    for (int i = 0; i < elements.length; i++) {
214:                        IConfigurationElement element = elements[i];
215:                        inputTypes.add(element.getAttribute(ATT_INPUT_TYPE));
216:                    }
217:                }
218:
219:                return inputTypes;
220:            }
221:
222:            /**
223:             * @see java.lang.Object#toString()
224:             */
225:            public String toString() {
226:                return getId();
227:            }
228:
229:            /**
230:             * @return Returns the configurationElement.
231:             */
232:            private IConfigurationElement getConfigurationElement() {
233:                return configurationElement;
234:            }
235:        }
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.