Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 165836 Details for
Bug 308125
[API] Support more flexible facet group enlistment
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch
patch308125.txt (text/plain), 40.20 KB, created by
Konstantin Komissarchik
on 2010-04-22 15:36:21 EDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Konstantin Komissarchik
Created:
2010-04-22 15:36:21 EDT
Size:
40.20 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.common.project.facet.core >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/plugin.properties,v >retrieving revision 1.10 >diff -u -r1.10 plugin.properties >--- plugin.properties 13 Jan 2010 17:04:45 -0000 1.10 >+++ plugin.properties 22 Apr 2010 19:33:12 -0000 >@@ -6,3 +6,4 @@ > extPointPresets = Faceted Project Presets Extension Point > extPointDetectors = Project Facet Detectors Extension Point > extPointAliases = Project Facet Aliases Extension Point >+extPointAliases = Project Facet Groups Extension Point >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/plugin.xml,v >retrieving revision 1.22 >diff -u -r1.22 plugin.xml >--- plugin.xml 13 Jan 2010 17:04:45 -0000 1.22 >+++ plugin.xml 22 Apr 2010 19:33:12 -0000 >@@ -47,6 +47,11 @@ > id="aliases" > name="%extPointAliases" > schema="schemas/aliases.exsd"/> >+ >+ <extension-point >+ id="groups" >+ name="%extPointGroups" >+ schema="schemas/groups.exsd"/> > > <extension > id="nature" >Index: schemas/facets.exsd >=================================================================== >RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/schemas/facets.exsd,v >retrieving revision 1.27 >diff -u -r1.27 facets.exsd >--- schemas/facets.exsd 22 Dec 2009 08:15:16 -0000 1.27 >+++ schemas/facets.exsd 22 Apr 2010 19:33:12 -0000 >@@ -652,8 +652,13 @@ > > <element name="group"> > <annotation> >+ <appInfo> >+ <meta.element deprecated="true"/> >+ </appInfo> > <documentation> > Describes a project facet group. A group is a named collection of project facet versions. It is used primarily as a parameter to the "requires" and "conflicts" constraints and allows a level of indirection where a facet does not need to know about all the members of the group. A given project facet version can belong to several groups. Groups are created automatically when used in the "group-member" element, so an explicit group declaration is optional. However, it does allow a label and a description to be associated with the group. >+ >+<p><b>DEPRECATED:</b> Use groups extension point instead.</p> > </documentation> > </annotation> > <complexType> >Index: schemas/groups.exsd >=================================================================== >RCS file: schemas/groups.exsd >diff -N schemas/groups.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schemas/groups.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,204 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.wst.common.project.facet.core" xmlns="http://www.w3.org/2001/XMLSchema"> >+<annotation> >+ <appInfo> >+ <meta.schema plugin="org.eclipse.wst.common.project.facet.core" id="groups" name="Project Facet Groups Extension Point"/> >+ </appInfo> >+ <documentation> >+ A group is a collection of project facets that's used to provide a level of indirection between facets. For instance, instead of specifying a dependency on a specific facet or a list of facets, a facet can specify a dependency on a group. Facets can join or leave the group as requirements change without directly impacting the facet that is specifying the dependency. >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <annotation> >+ <appInfo> >+ <meta.element /> >+ </appInfo> >+ </annotation> >+ <complexType> >+ <choice minOccurs="0" maxOccurs="unbounded"> >+ <element ref="group"/> >+ <element ref="members"/> >+ </choice> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ A fully qualified identifier of the target extension point. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ An optional identifier of the extension instance. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ An optional name of the extension instance. >+ </documentation> >+ <appInfo> >+ <meta.attribute translatable="true"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="group"> >+ <annotation> >+ <documentation> >+ Defines a project facet group. >+ </documentation> >+ </annotation> >+ <complexType> >+ <sequence> >+ <element ref="label"/> >+ <element ref="description" minOccurs="0" maxOccurs="1"/> >+ <element ref="include" minOccurs="0" maxOccurs="unbounded"/> >+ </sequence> >+ <attribute name="id" type="string" use="required"> >+ <annotation> >+ <documentation> >+ Group identifier. >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="label" type="string"> >+ <annotation> >+ <documentation> >+ The localizable name that is presented to the user. If not specified, the id will be used for a label. >+ </documentation> >+ </annotation> >+ </element> >+ >+ <element name="description" type="string"> >+ <annotation> >+ <documentation> >+ The description text. >+ </documentation> >+ </annotation> >+ </element> >+ >+ <element name="include"> >+ <annotation> >+ <documentation> >+ Specifies that one or more version of the facet should be included in the group. >+ </documentation> >+ </annotation> >+ <complexType> >+ <attribute name="facet" type="string" use="required"> >+ <annotation> >+ <documentation> >+ The facet id. >+ </documentation> >+ <appInfo> >+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.common.project.facet.core.facets/project-facet/@id"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ <attribute name="versions" type="string"> >+ <annotation> >+ <documentation> >+ Specifies the match expression for the facet version. The expression should be of the form "2.2,2.5,[3.0-5.3],(7.3", where the comas function as an OR. Brackets and parenthesis are used as part of the range notation. A bracket means inclusive while a parenthesis means exclusive. >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="members"> >+ <annotation> >+ <documentation> >+ Used by third-partys to enlist facets into a group. >+ </documentation> >+ </annotation> >+ <complexType> >+ <sequence> >+ <element ref="include" minOccurs="0" maxOccurs="unbounded"/> >+ </sequence> >+ <attribute name="group" type="string" use="required"> >+ <annotation> >+ <documentation> >+ The group id. >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="examples"/> >+ </appInfo> >+ <documentation> >+ <p>The following example illustrates creation of a group and various ways that facets can join the group.</p> >+ >+<pre><extension point="org.eclipse.wst.common.project.facet.core.groups"> >+ >+ <!-- >+ Groups do not have to be explicitly defined. They come into existence when the >+ first member is added, however explicit definition is recommended as that's the >+ only way to specify a label and a description for the group. You can also >+ enlist facets into the group as part of that group's definition. >+ --> >+ >+ <group id="gr"> >+ <label>Test Group</label> >+ <description>Test group of facets.</description> >+ <include facet="a"/> >+ <include facet="b" versions="1.2"/> >+ <include facet="c" versions="[1.3-2.0)"/> >+ </group> >+ >+ <!-- >+ This is the most flexible way of enlisting facets into the group. This >+ declaration can be made by a third party that is neither the facet author >+ nor the group creator. >+ --> >+ >+ <members group="gr"> >+ <include facet="d" versions="2.3,2.4,2.7"/> >+ <include facet="e"/> >+ </members> >+ >+</extension> >+ >+<!-- Facet can be enlisted into one or more group as part of facet definition. --> >+ >+<extension point="org.eclipse.wst.common.project.facet.core.facets"> >+ <project-facet id="f"> >+ ... >+ </project-facet> >+ <project-facet-version facet="f" version="1.0"> >+ ... >+ <group-member id="gr"/> >+ ... >+ </project-facet-version> >+</extension></pre> >+ </documentation> >+ </annotation> >+ >+ >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="copyright"/> >+ </appInfo> >+ <documentation> >+ Copyright (c) 2010 Oracle and others.<br> >+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 >+<a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. >+ </documentation> >+ </annotation> >+ >+</schema> >Index: src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectFrameworkImpl.java >=================================================================== >RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectFrameworkImpl.java,v >retrieving revision 1.22 >diff -u -r1.22 FacetedProjectFrameworkImpl.java >--- src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectFrameworkImpl.java 13 Jan 2010 17:04:45 -0000 1.22 >+++ src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectFrameworkImpl.java 22 Apr 2010 19:33:14 -0000 >@@ -59,6 +59,7 @@ > import org.eclipse.wst.common.project.facet.core.IConstraint; > import org.eclipse.wst.common.project.facet.core.IDefaultVersionProvider; > import org.eclipse.wst.common.project.facet.core.IFacetedProject; >+import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action; > import org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate; > import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy; > import org.eclipse.wst.common.project.facet.core.IGroup; >@@ -67,7 +68,6 @@ > import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; > import org.eclipse.wst.common.project.facet.core.IVersionExpr; > import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; >-import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action; > import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent; > import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectFrameworkEvent; > import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectFrameworkListener; >@@ -78,8 +78,8 @@ > import org.eclipse.wst.common.project.facet.core.events.internal.LegacyEventHandlerAdapter; > import org.eclipse.wst.common.project.facet.core.events.internal.ProjectListenerRegistry; > import org.eclipse.wst.common.project.facet.core.util.internal.IndexedSet; >-import org.eclipse.wst.common.project.facet.core.util.internal.VersionExpr; > import org.eclipse.wst.common.project.facet.core.util.internal.PluginUtil.InvalidExtensionException; >+import org.eclipse.wst.common.project.facet.core.util.internal.VersionExpr; > import org.osgi.service.prefs.BackingStoreException; > import org.osgi.service.prefs.Preferences; > >@@ -112,8 +112,6 @@ > private static final String EL_DELEGATE = "delegate"; //$NON-NLS-1$ > private static final String EL_DESCRIPTION = "description"; //$NON-NLS-1$ > private static final String EL_EVENT_HANDLER = "event-handler"; //$NON-NLS-1$ >- private static final String EL_GROUP = "group"; //$NON-NLS-1$ >- private static final String EL_GROUP_MEMBER = "group-member"; //$NON-NLS-1$ > private static final String EL_LABEL = "label"; //$NON-NLS-1$ > private static final String EL_MEMBER = "member"; //$NON-NLS-1$ > private static final String EL_PROJECT_FACET = "project-facet"; //$NON-NLS-1$ >@@ -597,6 +595,11 @@ > return group; > } > >+ void addGroup( final IGroup group ) >+ { >+ this.groups.addItemWithKey( group.getId(), group ); >+ } >+ > public Set<IFacetedProject> getFacetedProjects() > > throws CoreException >@@ -1382,6 +1385,8 @@ > > calculateVersionComparisonTables( fvToConstraint, fvToActions ); > >+ ProjectFacetGroupsExtensionPoint.processExtensions( this ); >+ > for( Map.Entry<ProjectFacetVersion,IConfigurationElement> x : fvToConstraint.entrySet() ) > { > readConstraint( x.getValue(), x.getKey() ); >@@ -1417,21 +1422,6 @@ > readDefaultVersionInfo( config ); > } > } >- >- for( IConfigurationElement config : cfgels ) >- { >- if( config.getName().equals( EL_GROUP ) ) >- { >- try >- { >- readGroup( config ); >- } >- catch( InvalidExtensionException e ) >- { >- // Continue. The problem has been reported in the log. >- } >- } >- } > } > > private void readCategory( final IConfigurationElement config ) >@@ -1607,28 +1597,6 @@ > { > fvToConstraint.put( fv, child ); > } >- else if( childName.equals( EL_GROUP_MEMBER ) ) >- { >- final String id = child.getAttribute( ATTR_ID ); >- >- if( id == null ) >- { >- reportMissingAttribute( child, ATTR_ID ); >- return; >- } >- >- Group group = (Group) this.groups.getItemByKey( id ); >- >- if( group == null ) >- { >- group = new Group(); >- group.setId( id ); >- >- this.groups.addItemWithKey( id, group ); >- } >- >- group.addMember( fv ); >- } > else if( childName.equals( EL_ACTION ) ) > { > actions.add( child ); >@@ -2312,27 +2280,6 @@ > return new Constraint( fv, type, operands ); > } > >- private void readGroup( final IConfigurationElement config ) >- >- throws InvalidExtensionException >- >- { >- final String id = findRequiredAttribute( config, ATTR_ID ); >- >- if( ! isGroupDefined( id ) ) >- { >- return; >- } >- >- final Group group = (Group) getGroup( id ); >- >- final IConfigurationElement elLabel = findOptionalElement( config, EL_LABEL ); >- group.setLabel( getElementValue( elLabel, group.getId() ) ); >- >- final IConfigurationElement elDesc = findOptionalElement( config, EL_DESCRIPTION ); >- group.setDescription( getElementValue( elDesc, DEFAULT_DESCRIPTION ) ); >- } >- > private static String toString( final Collection<? extends Object> collection ) > { > final StringBuffer buf = new StringBuffer(); >Index: src/org/eclipse/wst/common/project/facet/core/internal/Group.java >=================================================================== >RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/internal/Group.java,v >retrieving revision 1.8 >diff -u -r1.8 Group.java >--- src/org/eclipse/wst/common/project/facet/core/internal/Group.java 22 Dec 2009 08:15:12 -0000 1.8 >+++ src/org/eclipse/wst/common/project/facet/core/internal/Group.java 22 Apr 2010 19:33:14 -0000 >@@ -11,6 +11,7 @@ > > package org.eclipse.wst.common.project.facet.core.internal; > >+import java.util.Collection; > import java.util.Collections; > import java.util.HashSet; > import java.util.Set; >@@ -87,6 +88,11 @@ > this.members.add( fv ); > } > >+ void addMembers( final Collection<IProjectFacetVersion> facets ) >+ { >+ this.members.addAll( facets ); >+ } >+ > public String toString() > { > return getLabel(); >Index: src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacetGroupsExtensionPoint.java >=================================================================== >RCS file: src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacetGroupsExtensionPoint.java >diff -N src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacetGroupsExtensionPoint.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacetGroupsExtensionPoint.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,226 @@ >+/****************************************************************************** >+ * Copyright (c) 2010 Oracle >+ * 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: >+ * Konstantin Komissarchik - initial implementation and ongoing maintenance >+ ******************************************************************************/ >+ >+package org.eclipse.wst.common.project.facet.core.internal; >+ >+import static org.eclipse.wst.common.project.facet.core.internal.FacetCorePlugin.PLUGIN_ID; >+import static org.eclipse.wst.common.project.facet.core.util.internal.PluginUtil.findExtensions; >+import static org.eclipse.wst.common.project.facet.core.util.internal.PluginUtil.findOptionalElement; >+import static org.eclipse.wst.common.project.facet.core.util.internal.PluginUtil.findRequiredAttribute; >+import static org.eclipse.wst.common.project.facet.core.util.internal.PluginUtil.findRequiredElement; >+import static org.eclipse.wst.common.project.facet.core.util.internal.PluginUtil.getElementValue; >+import static org.eclipse.wst.common.project.facet.core.util.internal.PluginUtil.getTopLevelElements; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.wst.common.project.facet.core.IProjectFacet; >+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; >+import org.eclipse.wst.common.project.facet.core.util.internal.PluginUtil.InvalidExtensionException; >+ >+/** >+ * Contains the logic for processing the <code>groups</code> extension point, along with the >+ * <code>group</code> and <code>group-member</code> elements of the <code>facets</code> extension >+ * point. >+ * >+ * @author <a href="mailto:konstantin.komissarchik@oracle.com">Konstantin Komissarchik</a> >+ */ >+ >+public final class ProjectFacetGroupsExtensionPoint >+{ >+ private static final String GROUPS_EXTENSION_POINT_ID = "groups"; //$NON-NLS-1$ >+ private static final String FACETS_EXTENSION_POINT_ID = "facets"; //$NON-NLS-1$ >+ >+ private static final String EL_GROUP = "group"; //$NON-NLS-1$ >+ private static final String EL_LABEL = "label"; //$NON-NLS-1$ >+ private static final String EL_DESCRIPTION = "description"; //$NON-NLS-1$ >+ private static final String EL_INCLUDE = "include"; //$NON-NLS-1$ >+ private static final String EL_MEMBERS = "members"; //$NON-NLS-1$ >+ private static final String EL_PROJECT_FACET_VERSION = "project-facet-version"; //$NON-NLS-1$ >+ private static final String EL_GROUP_MEMBER = "group-member"; //$NON-NLS-1$ >+ >+ private static final String ATTR_ID = "id"; //$NON-NLS-1$ >+ private static final String ATTR_GROUP = "group"; //$NON-NLS-1$ >+ private static final String ATTR_FACET = "facet"; //$NON-NLS-1$ >+ private static final String ATTR_VERSION = "version"; //$NON-NLS-1$ >+ private static final String ATTR_VERSIONS = "versions"; //$NON-NLS-1$ >+ >+ public static void processExtensions( final FacetedProjectFrameworkImpl framework ) >+ { >+ // Process group definitions and stand-alone group enlistments. >+ >+ for( IConfigurationElement element >+ : getTopLevelElements( findExtensions( PLUGIN_ID, GROUPS_EXTENSION_POINT_ID ) ) ) >+ { >+ try >+ { >+ final String elname = element.getName(); >+ >+ if( elname.equals( EL_GROUP ) ) >+ { >+ final String id = findRequiredAttribute( element, ATTR_ID ); >+ final String label = getElementValue( findRequiredElement( element, EL_LABEL ), null ); >+ final String description = getElementValue( findOptionalElement( element, EL_DESCRIPTION ), "" ); //$NON-NLS-1$ >+ >+ final Group group = findOrCreateGroup( framework, id ); >+ >+ group.setLabel( label ); >+ group.setDescription( description ); >+ >+ processIncludeDirectives( framework, group, element ); >+ } >+ else if( elname.equals( EL_MEMBERS ) ) >+ { >+ final String gid = findRequiredAttribute( element, ATTR_GROUP ); >+ final Group group = findOrCreateGroup( framework, gid ); >+ >+ processIncludeDirectives( framework, group, element ); >+ } >+ } >+ catch( InvalidExtensionException e ) >+ { >+ // Continue. The problem has been reported to the user via the log. >+ } >+ } >+ >+ // Process group enlistments as part of facet declaration. >+ >+ for( IConfigurationElement element >+ : getTopLevelElements( findExtensions( PLUGIN_ID, FACETS_EXTENSION_POINT_ID ) ) ) >+ { >+ if( element.getName().equals( EL_PROJECT_FACET_VERSION ) ) >+ { >+ final IConfigurationElement[] groupMemberElements = element.getChildren( EL_GROUP_MEMBER ); >+ >+ if( groupMemberElements.length > 0 ) >+ { >+ final String fid = element.getAttribute( ATTR_FACET ); >+ >+ if( fid != null && framework.isProjectFacetDefined( fid ) ) >+ { >+ final IProjectFacet f = framework.getProjectFacet( fid ); >+ final String version = element.getAttribute( ATTR_VERSION ); >+ >+ if( version != null && f.hasVersion( version ) ) >+ { >+ final IProjectFacetVersion fv = f.getVersion( version ); >+ >+ for( IConfigurationElement groupMemberElement : groupMemberElements ) >+ { >+ try >+ { >+ final String gid = findRequiredAttribute( groupMemberElement, ATTR_ID ); >+ findOrCreateGroup( framework, gid ).addMember( fv ); >+ } >+ catch( InvalidExtensionException e ) >+ { >+ // Continue. The problem has been reported to the user via the log. >+ } >+ } >+ } >+ } >+ } >+ } >+ } >+ >+ // Process the deprecated declaration of groups within facets extension point. >+ >+ for( IConfigurationElement element >+ : getTopLevelElements( findExtensions( PLUGIN_ID, FACETS_EXTENSION_POINT_ID ) ) ) >+ { >+ if( element.getName().equals( EL_GROUP ) ) >+ { >+ try >+ { >+ final String id = findRequiredAttribute( element, ATTR_ID ); >+ final String label = getElementValue( findRequiredElement( element, EL_LABEL ), null ); >+ final String description = getElementValue( findOptionalElement( element, EL_DESCRIPTION ), "" ); //$NON-NLS-1$ >+ >+ final Group group = findOrCreateGroup( framework, id ); >+ >+ group.setLabel( label ); >+ group.setDescription( description ); >+ } >+ catch( InvalidExtensionException e ) >+ { >+ // Continue. The problem has been reported to the user via the log. >+ } >+ } >+ } >+ } >+ >+ private static void processIncludeDirectives( final FacetedProjectFrameworkImpl framework, >+ final Group group, >+ final IConfigurationElement context ) >+ { >+ final String bundleId = context.getContributor().getName(); >+ >+ for( IConfigurationElement element : context.getChildren( EL_INCLUDE ) ) >+ { >+ try >+ { >+ final String fid = findRequiredAttribute( element, ATTR_FACET ); >+ final String versions = element.getAttribute( ATTR_VERSIONS ); >+ >+ if( framework.isProjectFacetDefined( fid ) ) >+ { >+ final IProjectFacet f = framework.getProjectFacet( fid ); >+ group.addMembers( versions == null ? f.getVersions() : f.getVersions( versions ) ); >+ } >+ else >+ { >+ ProblemLog.reportMissingFacet( fid, bundleId ); >+ } >+ } >+ catch( InvalidExtensionException e ) >+ { >+ // Continue. The problem has been reported to the user via the log. >+ } >+ catch( CoreException e ) >+ { >+ FacetCorePlugin.log( e ); >+ } >+ } >+ } >+ >+ private static Group findOrCreateGroup( final FacetedProjectFrameworkImpl framework, >+ final String id ) >+ { >+ final Group group; >+ >+ if( framework.isGroupDefined( id ) ) >+ { >+ group = (Group) framework.getGroup( id ); >+ } >+ else >+ { >+ group = new Group(); >+ group.setId( id ); >+ framework.addGroup( group ); >+ } >+ >+ return group; >+ } >+ >+ public static final class Resources >+ >+ extends NLS >+ >+ { >+ public static String invalidEventType; >+ >+ static >+ { >+ initializeMessages( ProjectFacetGroupsExtensionPoint.class.getName(), Resources.class ); >+ } >+ } >+ >+} >#P org.eclipse.wst.common.project.facet.core.tests >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/webtools/common/tests/org.eclipse.wst.common.project.facet.core.tests/plugin.xml,v >retrieving revision 1.14 >diff -u -r1.14 plugin.xml >--- plugin.xml 14 Jan 2010 18:43:25 -0000 1.14 >+++ plugin.xml 22 Apr 2010 19:33:16 -0000 >@@ -592,4 +592,129 @@ > > </extension> > >+ <!-- ProjectFacetGroupsTests --> >+ >+ <extension point="org.eclipse.wst.common.project.facet.core.facets"> >+ >+ <project-facet id="grp-f1"/> >+ <project-facet-version facet="grp-f1" version="1.0"> >+ <group-member id="grp-g3"/> >+ </project-facet-version> >+ <project-facet-version facet="grp-f1" version="1.2"> >+ <group-member id="grp-g3"/> >+ </project-facet-version> >+ <project-facet-version facet="grp-f1" version="2.0"> >+ <group-member id="grp-g3"/> >+ </project-facet-version> >+ <action facet="grp-f1" type="INSTALL"> >+ <delegate class="org.eclipse.wst.common.project.facet.core.tests.support.NoOpDelegate"/> >+ </action> >+ >+ <project-facet id="grp-f2"/> >+ <project-facet-version facet="grp-f2" version="1.0"/> >+ <project-facet-version facet="grp-f2" version="1.2"> >+ <group-member id="grp-g3"/> >+ </project-facet-version> >+ <project-facet-version facet="grp-f2" version="2.0"/> >+ <action facet="grp-f2" type="INSTALL"> >+ <delegate class="org.eclipse.wst.common.project.facet.core.tests.support.NoOpDelegate"/> >+ </action> >+ >+ <project-facet id="grp-f3"/> >+ <project-facet-version facet="grp-f3" version="1.0"/> >+ <project-facet-version facet="grp-f3" version="1.2"> >+ <group-member id="grp-g3"/> >+ </project-facet-version> >+ <project-facet-version facet="grp-f3" version="2.0"> >+ <group-member id="grp-g3"/> >+ </project-facet-version> >+ <action facet="grp-f3" type="INSTALL"> >+ <delegate class="org.eclipse.wst.common.project.facet.core.tests.support.NoOpDelegate"/> >+ </action> >+ >+ <project-facet id="grp-f4"/> >+ <project-facet-version facet="grp-f4" version="1.0"> >+ <group-member id="grp-g3"/> >+ </project-facet-version> >+ <project-facet-version facet="grp-f4" version="1.2"> >+ <group-member id="grp-g3"/> >+ </project-facet-version> >+ <project-facet-version facet="grp-f4" version="2.0"> >+ <group-member id="grp-g3"/> >+ </project-facet-version> >+ <action facet="grp-f4" type="INSTALL"> >+ <delegate class="org.eclipse.wst.common.project.facet.core.tests.support.NoOpDelegate"/> >+ </action> >+ >+ <project-facet id="grp-f5"/> >+ <project-facet-version facet="grp-f5" version="1.0"> >+ <group-member id="grp-g3"/> >+ </project-facet-version> >+ <project-facet-version facet="grp-f5" version="1.2"> >+ <group-member id="grp-g3"/> >+ </project-facet-version> >+ <project-facet-version facet="grp-f5" version="2.0"/> >+ <action facet="grp-f5" type="INSTALL"> >+ <delegate class="org.eclipse.wst.common.project.facet.core.tests.support.NoOpDelegate"/> >+ </action> >+ >+ <project-facet id="grp-f6"/> >+ <project-facet-version facet="grp-f6" version="1.0"/> >+ <project-facet-version facet="grp-f6" version="1.2"> >+ <group-member id="grp-g1"/> >+ <group-member id="grp-g2"/> >+ <group-member id="grp-g3"/> >+ </project-facet-version> >+ <project-facet-version facet="grp-f6" version="2.0"> >+ <group-member id="grp-g1"/> >+ <group-member id="grp-g2"/> >+ <group-member id="grp-g3"/> >+ </project-facet-version> >+ <action facet="grp-f6" type="INSTALL"> >+ <delegate class="org.eclipse.wst.common.project.facet.core.tests.support.NoOpDelegate"/> >+ </action> >+ >+ </extension> >+ >+ <extension point="org.eclipse.wst.common.project.facet.core.groups"> >+ >+ <group id="grp-g1"> >+ <label>Group 1</label> >+ <description>Description for Group 1.</description> >+ <include facet="grp-f1"/> >+ <include facet="grp-f2" versions="1.2"/> >+ <include facet="grp-f3" versions="[1.2-3.0)"/> >+ </group> >+ >+ <members group="grp-g1"> >+ <include facet="grp-f4"/> >+ <include facet="grp-f5" versions="1.0,1.2"/> >+ </members> >+ >+ </extension> >+ >+ <extension point="org.eclipse.wst.common.project.facet.core.facets"> >+ >+ <group id="grp-g2"> >+ <label>Group 2</label> >+ <description>Description for Group 2.</description> >+ </group> >+ >+ </extension> >+ >+ <extension point="org.eclipse.wst.common.project.facet.core.groups"> >+ >+ <members group="grp-g2"> >+ <include facet="grp-f1"/> >+ <include facet="grp-f2" versions="1.2"/> >+ <include facet="grp-f3" versions="[1.2-3.0)"/> >+ </members> >+ >+ <members group="grp-g2"> >+ <include facet="grp-f4"/> >+ <include facet="grp-f5" versions="1.0,1.2"/> >+ </members> >+ >+ </extension> >+ > </plugin> >Index: src/org/eclipse/wst/common/project/facet/core/tests/AllTests.java >=================================================================== >RCS file: /cvsroot/webtools/common/tests/org.eclipse.wst.common.project.facet.core.tests/src/org/eclipse/wst/common/project/facet/core/tests/AllTests.java,v >retrieving revision 1.9 >diff -u -r1.9 AllTests.java >--- src/org/eclipse/wst/common/project/facet/core/tests/AllTests.java 14 Jan 2010 18:43:25 -0000 1.9 >+++ src/org/eclipse/wst/common/project/facet/core/tests/AllTests.java 22 Apr 2010 19:33:16 -0000 >@@ -41,6 +41,7 @@ > suite.addTest( DefaultVersionTests.suite() ); > suite.addTest( EventDeliveryTests.suite() ); > suite.addTest( AliasingSystemTests.suite() ); >+ suite.addTest( ProjectFacetGroupsTests.suite() ); > > return suite; > } >Index: src/org/eclipse/wst/common/project/facet/core/tests/ProjectFacetGroupsTests.java >=================================================================== >RCS file: src/org/eclipse/wst/common/project/facet/core/tests/ProjectFacetGroupsTests.java >diff -N src/org/eclipse/wst/common/project/facet/core/tests/ProjectFacetGroupsTests.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/common/project/facet/core/tests/ProjectFacetGroupsTests.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,164 @@ >+/****************************************************************************** >+ * Copyright (c) 2010 Oracle >+ * 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: >+ * Konstantin Komissarchik - initial implementation and ongoing maintenance >+ ******************************************************************************/ >+ >+package org.eclipse.wst.common.project.facet.core.tests; >+ >+import java.io.IOException; >+import java.util.HashSet; >+import java.util.Set; >+ >+import junit.framework.Test; >+import junit.framework.TestSuite; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.wst.common.project.facet.core.IGroup; >+import org.eclipse.wst.common.project.facet.core.IProjectFacet; >+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; >+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; >+ >+/** >+ * @author <a href="mailto:konstantin.komissarchik@oracle.com">Konstantin Komissarchik</a> >+ */ >+ >+@SuppressWarnings( "unused" ) >+ >+public final class ProjectFacetGroupsTests >+ >+ extends AbstractTests >+ >+{ >+ private static IProjectFacet f1; >+ private static IProjectFacetVersion f1v10; >+ private static IProjectFacetVersion f1v12; >+ private static IProjectFacetVersion f1v20; >+ >+ private static IProjectFacet f2; >+ private static IProjectFacetVersion f2v10; >+ private static IProjectFacetVersion f2v12; >+ private static IProjectFacetVersion f2v20; >+ >+ private static IProjectFacet f3; >+ private static IProjectFacetVersion f3v10; >+ private static IProjectFacetVersion f3v12; >+ private static IProjectFacetVersion f3v20; >+ >+ private static IProjectFacet f4; >+ private static IProjectFacetVersion f4v10; >+ private static IProjectFacetVersion f4v12; >+ private static IProjectFacetVersion f4v20; >+ >+ private static IProjectFacet f5; >+ private static IProjectFacetVersion f5v10; >+ private static IProjectFacetVersion f5v12; >+ private static IProjectFacetVersion f5v20; >+ >+ private static IProjectFacet f6; >+ private static IProjectFacetVersion f6v10; >+ private static IProjectFacetVersion f6v12; >+ private static IProjectFacetVersion f6v20; >+ >+ static >+ { >+ f1 = ProjectFacetsManager.getProjectFacet( "grp-f1" ); >+ f1v10 = f1.getVersion( "1.0" ); >+ f1v12 = f1.getVersion( "1.2" ); >+ f1v20 = f1.getVersion( "2.0" ); >+ >+ f2 = ProjectFacetsManager.getProjectFacet( "grp-f2" ); >+ f2v10 = f2.getVersion( "1.0" ); >+ f2v12 = f2.getVersion( "1.2" ); >+ f2v20 = f2.getVersion( "2.0" ); >+ >+ f3 = ProjectFacetsManager.getProjectFacet( "grp-f3" ); >+ f3v10 = f3.getVersion( "1.0" ); >+ f3v12 = f3.getVersion( "1.2" ); >+ f3v20 = f3.getVersion( "2.0" ); >+ >+ f4 = ProjectFacetsManager.getProjectFacet( "grp-f4" ); >+ f4v10 = f4.getVersion( "1.0" ); >+ f4v12 = f4.getVersion( "1.2" ); >+ f4v20 = f4.getVersion( "2.0" ); >+ >+ f5 = ProjectFacetsManager.getProjectFacet( "grp-f5" ); >+ f5v10 = f5.getVersion( "1.0" ); >+ f5v12 = f5.getVersion( "1.2" ); >+ f5v20 = f5.getVersion( "2.0" ); >+ >+ f6 = ProjectFacetsManager.getProjectFacet( "grp-f6" ); >+ f6v10 = f6.getVersion( "1.0" ); >+ f6v12 = f6.getVersion( "1.2" ); >+ f6v20 = f6.getVersion( "2.0" ); >+ } >+ >+ private ProjectFacetGroupsTests( final String name ) >+ { >+ super( name ); >+ } >+ >+ public static Test suite() >+ { >+ final TestSuite suite = new TestSuite(); >+ >+ suite.setName( "Project Facet Groups Tests" ); >+ >+ suite.addTest( new ProjectFacetGroupsTests( "testCreationAndEnlistment" ) ); >+ >+ return suite; >+ } >+ >+ /** >+ * Tests creation of groups and enlistment of facets. >+ * >+ * @throws CoreException >+ * @throws IOException >+ */ >+ >+ public void testCreationAndEnlistment() >+ >+ throws CoreException, IOException >+ >+ { >+ final Set<IProjectFacetVersion> expected = new HashSet<IProjectFacetVersion>(); >+ >+ expected.add( f1v10 ); >+ expected.add( f1v12 ); >+ expected.add( f1v20 ); >+ expected.add( f2v12 ); >+ expected.add( f3v12 ); >+ expected.add( f3v20 ); >+ expected.add( f4v10 ); >+ expected.add( f4v12 ); >+ expected.add( f4v20 ); >+ expected.add( f5v10 ); >+ expected.add( f5v12 ); >+ expected.add( f6v12 ); >+ expected.add( f6v20 ); >+ >+ assertTrue( ProjectFacetsManager.isGroupDefined( "grp-g1" ) ); >+ final IGroup g1 = ProjectFacetsManager.getGroup( "grp-g1" ); >+ assertEquals( expected, g1.getMembers() ); >+ assertEquals( "Group 1", g1.getLabel() ); >+ assertEquals( "Description for Group 1.", g1.getDescription() ); >+ >+ assertTrue( ProjectFacetsManager.isGroupDefined( "grp-g2" ) ); >+ final IGroup g2 = ProjectFacetsManager.getGroup( "grp-g2" ); >+ assertEquals( expected, g2.getMembers() ); >+ assertEquals( "Group 2", g2.getLabel() ); >+ assertEquals( "Description for Group 2.", g2.getDescription() ); >+ >+ assertTrue( ProjectFacetsManager.isGroupDefined( "grp-g3" ) ); >+ final IGroup g3 = ProjectFacetsManager.getGroup( "grp-g3" ); >+ assertEquals( expected, g3.getMembers() ); >+ assertEquals( "grp-g3", g3.getLabel() ); >+ assertEquals( "", g3.getDescription() ); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 308125
: 165836