1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.text.folding;
13 import net.sourceforge.phpdt.ui.text.folding.IJavaFoldingPreferenceBlock;
14 import net.sourceforge.phpdt.ui.text.folding.IJavaFoldingStructureProvider;
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.IConfigurationElement;
19 //import org.eclipse.jface.text.Assert;
20 import org.eclipse.core.runtime.Assert;
22 * Describes a contribution to the folding provider extension point.
26 public final class JavaFoldingStructureProviderDescriptor {
28 /* extension point attribute names */
30 private static final String PREFERENCES_CLASS = "preferencesClass"; //$NON-NLS-1$
32 private static final String CLASS = "class"; //$NON-NLS-1$
34 private static final String NAME = "name"; //$NON-NLS-1$
36 private static final String ID = "id"; //$NON-NLS-1$
38 /** The identifier of the extension. */
41 /** The name of the extension. */
44 /** The class name of the provided <code>IJavaFoldingStructureProvider</code>. */
45 private String fClass;
48 * <code>true</code> if the extension specifies a custom
49 * <code>IJavaFoldingPreferenceBlock</code>.
51 private boolean fHasPreferences;
53 /** The configuration element of this extension. */
54 private IConfigurationElement fElement;
57 * Creates a new descriptor.
60 * the configuration element to read
62 JavaFoldingStructureProviderDescriptor(IConfigurationElement element) {
64 fId = element.getAttributeAsIs(ID);
65 Assert.isLegal(fId != null);
67 fName = element.getAttribute(NAME);
71 fClass = element.getAttributeAsIs(CLASS);
72 Assert.isLegal(fClass != null);
74 if (element.getAttributeAsIs(PREFERENCES_CLASS) == null)
75 fHasPreferences = false;
77 fHasPreferences = true;
81 * Creates a folding provider as described in the extension's xml.
83 * @return a new instance of the folding provider described by this
85 * @throws CoreException
88 public IJavaFoldingStructureProvider createProvider() throws CoreException {
89 IJavaFoldingStructureProvider prov = (IJavaFoldingStructureProvider) fElement
90 .createExecutableExtension(CLASS);
95 * Creates a preferences object as described in the extension's xml.
97 * @return a new instance of the reference provider described by this
99 * @throws CoreException
102 public IJavaFoldingPreferenceBlock createPreferences() throws CoreException {
103 if (fHasPreferences) {
104 IJavaFoldingPreferenceBlock prefs = (IJavaFoldingPreferenceBlock) fElement
105 .createExecutableExtension(PREFERENCES_CLASS);
108 return new EmptyJavaFoldingPreferenceBlock();
113 * Returns the identifier of the described extension.
115 * @return Returns the id
117 public String getId() {
122 * Returns the name of the described extension.
124 * @return Returns the name
126 public String getName() {