diff options
author | cbateman | 2009-02-05 00:12:56 +0000 |
---|---|---|
committer | cbateman | 2009-02-05 00:12:56 +0000 |
commit | c4cad2acdd1a5a22d9a421dd29b63f26ce816533 (patch) | |
tree | 85db40dcc941c6224f184bf332d1184ca5309016 | |
parent | 0f45341cf714998e2178a8603086caf360ad4629 (diff) | |
download | webtools.jsf-c4cad2acdd1a5a22d9a421dd29b63f26ce816533.tar.gz webtools.jsf-c4cad2acdd1a5a22d9a421dd29b63f26ce816533.tar.xz webtools.jsf-c4cad2acdd1a5a22d9a421dd29b63f26ce816533.zip |
Fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=263718.
Adds a non-breaking factory extension that allows an adopter to replace the IPropertySheetPage being used.
5 files changed, 193 insertions, 40 deletions
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/schema/pageDesignerExtension.exsd b/jsf/plugins/org.eclipse.jst.pagedesigner/schema/pageDesignerExtension.exsd index 25ef001a7..b733b6efc 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/schema/pageDesignerExtension.exsd +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/schema/pageDesignerExtension.exsd @@ -1,16 +1,21 @@ <?xml version='1.0' encoding='UTF-8'?> <!-- Schema file written by PDE --> -<schema targetNamespace="org.eclipse.jst.pagedesigner"> +<schema targetNamespace="org.eclipse.jst.pagedesigner" xmlns="http://www.w3.org/2001/XMLSchema"> <annotation> - <appInfo> + <appinfo> <meta.schema plugin="org.eclipse.jst.pagedesigner" id="pageDesignerExtension" name="Web Page Editor Extension"/> - </appInfo> + </appinfo> <documentation> <p><b>This extension point is provisional and subject to change</b></p> </documentation> </annotation> <element name="extension"> + <annotation> + <appinfo> + <meta.element /> + </appinfo> + </annotation> <complexType> <sequence> <element ref="localDropHandler" minOccurs="0" maxOccurs="unbounded"/> @@ -20,6 +25,7 @@ <element ref="linkCreator" minOccurs="0" maxOccurs="unbounded"/> <element ref="tagAttributeCellEditorFactory" minOccurs="0" maxOccurs="unbounded"/> <element ref="tagTransformOperation" minOccurs="0" maxOccurs="unbounded"/> + <element ref="propertyPageFactory" minOccurs="0" maxOccurs="unbounded"/> </sequence> <attribute name="point" type="string" use="required"> <annotation> @@ -52,9 +58,9 @@ <documentation> </documentation> - <appInfo> + <appinfo> <meta.attribute kind="java"/> - </appInfo> + </appinfo> </annotation> </attribute> </complexType> @@ -72,9 +78,9 @@ <documentation> </documentation> - <appInfo> + <appinfo> <meta.attribute kind="java" deprecated="true"/> - </appInfo> + </appinfo> </annotation> </attribute> </complexType> @@ -92,9 +98,9 @@ <documentation> </documentation> - <appInfo> + <appinfo> <meta.attribute kind="java" basedOn=":org.eclipse.jst.pagedesigner.meta.ITagAttributeCellEditorFactory"/> - </appInfo> + </appinfo> </annotation> </attribute> </complexType> @@ -107,9 +113,9 @@ <documentation> </documentation> - <appInfo> + <appinfo> <meta.attribute kind="java"/> - </appInfo> + </appinfo> </annotation> </attribute> </complexType> @@ -122,9 +128,9 @@ <documentation> </documentation> - <appInfo> + <appinfo> <meta.attribute kind="java"/> - </appInfo> + </appinfo> </annotation> </attribute> </complexType> @@ -137,9 +143,9 @@ <documentation> </documentation> - <appInfo> + <appinfo> <meta.attribute kind="java" basedOn="org.eclipse.jst.pagedesigner.actions.link.ILinkCreator"/> - </appInfo> + </appinfo> </annotation> </attribute> <attribute name="linkIdentifier" type="string" use="required"> @@ -163,10 +169,10 @@ <annotation> <documentation> The transform operation id. Referencers will use plugin-qualified references. i.e if the plugin extending this was <code>org.foo.bar</code>, then the meta data instance that referenced this operation would specify: - <pre> - <operation id="org.foo.bar.MyTransformId"/> - </pre> - + <pre> + <operation id="org.foo.bar.MyTransformId"/> + </pre> + The exception to this rule is that if the reference is not plugin-qualified, then the reference is assumed to be a <i>core</i> transformation and uses the <code>org.eclipse.jst.pagedesigner</code> prefix. </documentation> </annotation> @@ -176,18 +182,33 @@ The exception to this rule is that if the reference is not plugin-qualified, the <documentation> class extending the <code>org.eclipse.jst.pagedesigner.dtmanager.converter.operations.AbstractTransformOperation</code> </documentation> - <appInfo> + <appinfo> <meta.attribute kind="java" basedOn="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.AbstractTransformOperation:"/> - </appInfo> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="propertyPageFactory"> + <complexType> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + Provisional API. If an extension point is found in the system, the Web Page Editor will use the factory implementation to provide its property page. + </documentation> + <appinfo> + <meta.attribute kind="java" basedOn="org.eclipse.jst.pagedesigner.editors.AbstractPropertySheetPageFactory:"/> + </appinfo> </annotation> </attribute> </complexType> </element> <annotation> - <appInfo> + <appinfo> <meta.section type="since"/> - </appInfo> + </appinfo> <documentation> 2.0 </documentation> @@ -197,9 +218,9 @@ The exception to this rule is that if the reference is not plugin-qualified, the <annotation> - <appInfo> + <appinfo> <meta.section type="copyright"/> - </appInfo> + </appinfo> <documentation> Copyright 2006 Sybase and others All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/IJMTConstants.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/IJMTConstants.java index ef1d7589a..c6ee37ec8 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/IJMTConstants.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/IJMTConstants.java @@ -95,4 +95,8 @@ public interface IJMTConstants { */ public static final String LINK_CREATOR = "linkCreator"; //$NON-NLS-1$ + /** + * extension for property page factory + */ + public static final String PROPERTY_PAGE_FACTORY = "propertyPageFactory"; //$NON-NLS-1$ } diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/AbstractPropertySheetPageFactory.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/AbstractPropertySheetPageFactory.java new file mode 100644 index 000000000..849acb55c --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/AbstractPropertySheetPageFactory.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2001, 2009 Oracle Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Oracle Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.jst.pagedesigner.editors; + +import org.eclipse.core.resources.IFile; +import org.eclipse.ui.views.properties.IPropertySheetPage; + +/** + * Abstract class that should be extended to provide a property sheet page + * factory. + * + * @author cbateman + * + */ +public abstract class AbstractPropertySheetPageFactory implements + IPropertySheetPageFactory +{ + + /* (non-Javadoc) + * @see org.eclipse.jst.pagedesigner.editors.IPropertySheetPageFactory#createPage(org.eclipse.core.resources.IFile) + */ + public abstract IPropertySheetPage createPage(IFile file); +} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/HTMLEditor.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/HTMLEditor.java index 603c271f9..12bcb47d2 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/HTMLEditor.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/HTMLEditor.java @@ -21,8 +21,12 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Platform; import org.eclipse.gef.DefaultEditDomain; import org.eclipse.gef.palette.PaletteRoot; import org.eclipse.gef.ui.palette.PaletteViewerProvider; @@ -36,6 +40,7 @@ import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jst.jsf.common.ui.internal.logging.Logger; import org.eclipse.jst.jsf.common.ui.internal.utils.ResourceUtils; +import org.eclipse.jst.pagedesigner.IJMTConstants; import org.eclipse.jst.pagedesigner.PDPlugin; import org.eclipse.jst.pagedesigner.dnd.internal.DesignerSourceMouseTrackAdapter; import org.eclipse.jst.pagedesigner.editors.pagedesigner.PageDesignerResources; @@ -144,7 +149,7 @@ public final class HTMLEditor extends PostSelectionMultiPageEditorPart implement private List PREVIEW_FILES_LIST = new ArrayList(); - private WPETabbedPropertySheetPage _tabbedPropSheet; + private IPropertySheetPage _tabbedPropSheet; private ISelectionChangedListener _selChangedListener; @@ -891,20 +896,76 @@ public final class HTMLEditor extends PostSelectionMultiPageEditorPart implement return getTextEditor().isDirty(); } - private IPropertySheetPage getPropertySheetPage() { - if (_tabbedPropSheet == null){ - _tabbedPropSheet = new org.eclipse.jst.pagedesigner.properties.WPETabbedPropertySheetPage( - this, this); - } - return _tabbedPropSheet; - } - - private PaletteViewerPage getPaletteViewerPage() { - if (null == _paletteViewerPage) { - DefaultEditDomain editDomain = getEditDomain(); - PaletteItemManager manager = PaletteItemManager - .getInstance(getCurrentProject(getEditorInput())); - manager.reset(); + private IPropertySheetPage getPropertySheetPage() + { + if (_tabbedPropSheet == null) + { + IPropertySheetPageFactory factory = getPageFactory(); + if (factory != null) + { + final IFile file = ((IFileEditorInput)getEditorInput()).getFile(); + _tabbedPropSheet = factory.createPage(file); + } + else + { + _tabbedPropSheet = new WPETabbedPropertySheetPage(this,this); + } + } + return _tabbedPropSheet; + } + + private IPropertySheetPageFactory getPageFactory() + { + //List<IElementEditFactory> result = new ArrayList<IElementEditFactory>(); + IExtensionPoint extensionPoint = Platform.getExtensionRegistry() + .getExtensionPoint(PDPlugin.getPluginId(), + IJMTConstants.EXTENSION_POINT_PAGEDESIGNER); + IExtension[] extensions = extensionPoint.getExtensions(); + + for (int i = 0; i < extensions.length; i++) + { + IExtension ext = extensions[i]; + IConfigurationElement[] elementEditElement = ext + .getConfigurationElements(); + + for (int j = 0; j < elementEditElement.length; j++) + { + final IConfigurationElement element = elementEditElement[j]; + if (element.getName().equals( + IJMTConstants.PROPERTY_PAGE_FACTORY)) + { + elementEditElement[j].getAttribute("factory"); //$NON-NLS-1$ + Object obj; + try + { + obj = elementEditElement[j] + .createExecutableExtension("factory"); //$NON-NLS-1$ + + // TODO: we need a policy based solution here, + // but this will do for now + if (obj instanceof IPropertySheetPageFactory) + { + return (IPropertySheetPageFactory) obj; + } + } + catch (CoreException e) + { + PDPlugin.log("Problem loading element edit extension for "+element.toString(), e); //$NON-NLS-1$ + } + } + } + } + return null; + } + + private PaletteViewerPage getPaletteViewerPage() + { + if (null == _paletteViewerPage) + { + DefaultEditDomain editDomain = getEditDomain(); + PaletteItemManager manager = PaletteItemManager + .getInstance(getCurrentProject(getEditorInput())); + manager.reset(); PaletteRoot paletteRoot = _designViewer.getPaletteRoot(); editDomain.setPaletteRoot(paletteRoot); diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/IPropertySheetPageFactory.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/IPropertySheetPageFactory.java new file mode 100644 index 000000000..3e37903d9 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/IPropertySheetPageFactory.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2001, 2009 Oracle Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Oracle Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.jst.pagedesigner.editors; + +import org.eclipse.core.resources.IFile; +import org.eclipse.ui.views.properties.IPropertySheetPage; + +/** + * A factory that can be used with the pageDesignerExtension to override + * the default property sheet page provided by the WPE when tag elements are + * selected by the user. + * + * This interface should not be implemented or extended by clients. Use + * AbstractPropertySheetPageFactory instead. + * + * @author cbateman + * + */ +public interface IPropertySheetPageFactory +{ + /** + * @param file + * @return the property sheet page for the file. + */ + IPropertySheetPage createPage(final IFile file); +} |