1 /*******************************************************************************
\r
2 * Copyright (c) 2006 Sybase, Inc. and others.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * Sybase, Inc. - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.eclipse.jst.pagedesigner.properties.internal;
\r
14 import java.util.ArrayList;
\r
15 import java.util.List;
\r
17 import org.eclipse.core.runtime.IConfigurationElement;
\r
18 import org.eclipse.core.runtime.IExtensionPoint;
\r
19 import org.eclipse.core.runtime.Platform;
\r
20 import org.eclipse.jst.pagedesigner.editors.HTMLEditor;
\r
21 import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor;
\r
22 import org.eclipse.ui.views.properties.tabbed.ISectionDescriptorProvider;
\r
25 * Provides sections registered for the Web Page Editor whose contributor ID is,
\r
26 * "org.eclipse.jst.pagedesigner.tabPropertyContributor" using the
\r
27 * org.eclipse.ui.views.properties.tabbed.propertyTabs extension-points.
\r
29 * The sections declared using the org.eclipse.ui.views.properties.tabbed.propertySections extension-point
\r
30 * for the WPE will only be displayed by the Quick Edit tab is the selected tag has metadata to choose
\r
31 * the section. TypeMappers/filters, etc. are ignored by this sectionDescriptorProvider.
\r
33 * See jsf_html.xml in the org.eclipse.jst.jsf.standard.tagsupport plugin for examples on how to use.
\r
35 public class WPETabPropertySectionDescriptorProvider implements
\r
36 ISectionDescriptorProvider {
\r
38 private static final String EXTPT_SECTIONS = "propertySections"; //$NON-NLS-1$
\r
39 private static final String ELEMENT_SECTION = "propertySection"; //$NON-NLS-1$
\r
40 private ISectionDescriptor[] _descriptors = null;
\r
45 public WPETabPropertySectionDescriptorProvider() {
\r
49 public ISectionDescriptor[] getSectionDescriptors() {
\r
50 if (_descriptors == null) {
\r
51 List result = new ArrayList();
\r
52 List contributedSections = readSectionDescriptors();
\r
53 result.addAll(contributedSections);
\r
55 // if (1 == 0){ //disabled for now... do we want to allow other mechanisms to add sections?
\r
56 // List providers = readAdditionalSectionDescriptorProviders();
\r
57 // for (int i = 0, size = providers.size(); i < size; i++) {
\r
59 // ISectionDescriptorProvider provider = (ISectionDescriptorProvider) providers
\r
61 // ISectionDescriptor[] sections = provider
\r
62 // .getSectionDescriptors();
\r
63 // if (sections != null) {
\r
64 // result.addAll(Arrays.asList(sections));
\r
66 // } catch (Exception ex) {
\r
68 // ex.printStackTrace();
\r
72 _descriptors = new ISectionDescriptor[result.size()];
\r
73 result.toArray(_descriptors);
\r
75 return _descriptors;
\r
79 * @return registered section descriptors for the WPE QuickEdit tab
\r
81 protected List<QuickEditTabSectionDescriptor> readSectionDescriptors() {
\r
82 List result = new ArrayList();
\r
84 IConfigurationElement[] extensions = getConfigurationElements(EXTPT_SECTIONS);
\r
85 for (int i = 0; i < extensions.length; i++) {
\r
86 IConfigurationElement extension = extensions[i];
\r
87 if (extension.getAttribute("contributorId").equals(HTMLEditor.TABBED_PROPERTIES_CONTRIBUTOR_ID)){ //$NON-NLS-1$
\r
88 IConfigurationElement[] sections = extension
\r
89 .getChildren(ELEMENT_SECTION);
\r
90 for (int j = 0; j < sections.length; j++) {
\r
91 IConfigurationElement section = sections[j];
\r
92 ISectionDescriptor descriptor = new QuickEditTabSectionDescriptor(
\r
93 section, null);//ITypeMapper set to null
\r
94 result.add(descriptor);
\r
102 * @param extensionPointId
\r
103 * @return IConfigurationElement[]
\r
105 private static IConfigurationElement[] getConfigurationElements(
\r
106 String extensionPointId) {
\r
107 IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
\r
108 .getExtensionPoint("org.eclipse.ui.views.properties.tabbed", extensionPointId); //$NON-NLS-1$
\r
109 if (extensionPoint == null) {
\r
112 return extensionPoint.getConfigurationElements();
\r
116 * @param name of section
\r
117 * @return {@link QuickEditTabSectionDescriptor} or null if not located
\r
119 public QuickEditTabSectionDescriptor getNamedSectionDescriptor(String name) {
\r
120 for (int i=0;i<getSectionDescriptors().length;i++){
\r
121 QuickEditTabSectionDescriptor sd = (QuickEditTabSectionDescriptor)getSectionDescriptors()[i];
\r
122 if (name.equals(sd.getId()))
\r