Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 330894 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jst/common/jdt/internal/javalite/JavaLiteUtilities.java (+1 lines)
Lines 148-153 Link Here
148
									containers.add(outputContainer);
148
									containers.add(outputContainer);
149
								}
149
								}
150
								break;
150
								break;
151
							default:
151
							}
152
							}
152
						}
153
						}
153
					}
154
					}
(-)j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java (-23 / +11 lines)
Lines 22-33 Link Here
22
import org.eclipse.core.runtime.Path;
22
import org.eclipse.core.runtime.Path;
23
import org.eclipse.jdt.core.IJavaProject;
23
import org.eclipse.jdt.core.IJavaProject;
24
import org.eclipse.jem.workbench.utility.JemProjectUtilities;
24
import org.eclipse.jem.workbench.utility.JemProjectUtilities;
25
import org.eclipse.jst.common.internal.modulecore.AddClasspathFoldersParticipant;
26
import org.eclipse.jst.common.internal.modulecore.AddClasspathLibReferencesParticipant;
27
import org.eclipse.jst.common.internal.modulecore.AddMappedOutputFoldersParticipant;
28
import org.eclipse.jst.common.internal.modulecore.IgnoreJavaInSourceFolderParticipant;
29
import org.eclipse.jst.common.internal.modulecore.ReplaceManifestExportParticipant;
30
import org.eclipse.jst.common.internal.modulecore.SingleRootExportParticipant;
31
import org.eclipse.jst.common.internal.modulecore.SingleRootUtil;
25
import org.eclipse.jst.common.internal.modulecore.SingleRootUtil;
32
import org.eclipse.jst.common.jdt.internal.javalite.JavaLiteUtilities;
26
import org.eclipse.jst.common.jdt.internal.javalite.JavaLiteUtilities;
33
import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit;
27
import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit;
Lines 35-42 Link Here
35
import org.eclipse.jst.j2ee.internal.EjbModuleExtensionHelper;
29
import org.eclipse.jst.j2ee.internal.EjbModuleExtensionHelper;
36
import org.eclipse.jst.j2ee.internal.IEJBModelExtenderManager;
30
import org.eclipse.jst.j2ee.internal.IEJBModelExtenderManager;
37
import org.eclipse.jst.j2ee.internal.J2EEConstants;
31
import org.eclipse.jst.j2ee.internal.J2EEConstants;
38
import org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyEnablement;
39
import org.eclipse.jst.j2ee.internal.common.exportmodel.JEEHeirarchyExportParticipant;
40
import org.eclipse.jst.j2ee.internal.common.exportmodel.JavaEESingleRootCallback;
32
import org.eclipse.jst.j2ee.internal.common.exportmodel.JavaEESingleRootCallback;
41
import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
33
import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
42
import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
34
import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
Lines 50-56 Link Here
50
import org.eclipse.wst.common.componentcore.ArtifactEdit;
42
import org.eclipse.wst.common.componentcore.ArtifactEdit;
51
import org.eclipse.wst.common.componentcore.ComponentCore;
43
import org.eclipse.wst.common.componentcore.ComponentCore;
52
import org.eclipse.wst.common.componentcore.internal.flat.IChildModuleReference;
44
import org.eclipse.wst.common.componentcore.internal.flat.IChildModuleReference;
53
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
54
import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities;
45
import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities;
55
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
46
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
56
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
47
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
Lines 100-119 Link Here
100
	}
91
	}
101
	
92
	
102
	@Override
93
	@Override
103
	protected IFlattenParticipant[] getParticipants() {
94
	protected String[] getDefaultFlattenParticipantIDs() {
104
		List<IFlattenParticipant> participants = new ArrayList<IFlattenParticipant>();
95
		String[] defaultParticipants = new String[]{
105
		
96
				JEEFlattenParticipantProvider.JEESingleRootParticipant,
106
		participants.add(new SingleRootExportParticipant(new JavaEESingleRootCallback()));
97
				JEEFlattenParticipantProvider.JEEHeirarchyExportParticipant,
107
		participants.add(new JEEHeirarchyExportParticipant());
98
				JEEFlattenParticipantProvider.AddClasspathLibReferencesParticipant,
108
		participants.add(new AddClasspathLibReferencesParticipant());
99
				JEEFlattenParticipantProvider.AddClasspathFoldersParticipant,
109
		participants.add(new AddClasspathFoldersParticipant());
100
				JEEFlattenParticipantProvider.AddMappedOutputFoldersParticipant,
110
		participants.add(new AddMappedOutputFoldersParticipant());
101
				JEEFlattenParticipantProvider.IgnoreJavaInSourceFolderParticipant,
111
		participants.add(new IgnoreJavaInSourceFolderParticipant());
102
				JEEFlattenParticipantProvider.JEEReplaceManifestExportParticipant
112
		if (ClasspathDependencyEnablement.isAllowClasspathComponentDependency()) {
103
		};
113
			participants.add(new ReplaceManifestExportParticipant(new Path(J2EEConstants.MANIFEST_URI)));
104
		return defaultParticipants;
114
		}
115
		
116
		return participants.toArray(new IFlattenParticipant[participants.size()]);
117
	}
105
	}
118
    
106
    
119
    @Override
107
    @Override
(-)j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/JEEFlattenParticipantProvider.java (+61 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jst.j2ee.internal.deployables;
12
13
import org.eclipse.core.runtime.Path;
14
import org.eclipse.jst.common.internal.modulecore.AddClasspathFoldersParticipant;
15
import org.eclipse.jst.common.internal.modulecore.AddClasspathLibReferencesParticipant;
16
import org.eclipse.jst.common.internal.modulecore.AddMappedOutputFoldersParticipant;
17
import org.eclipse.jst.common.internal.modulecore.IgnoreJavaInSourceFolderParticipant;
18
import org.eclipse.jst.common.internal.modulecore.ReplaceManifestExportParticipant;
19
import org.eclipse.jst.common.internal.modulecore.SingleRootExportParticipant;
20
import org.eclipse.jst.j2ee.internal.J2EEConstants;
21
import org.eclipse.jst.j2ee.internal.common.exportmodel.JEEHeirarchyExportParticipant;
22
import org.eclipse.jst.j2ee.internal.common.exportmodel.JavaEESingleRootCallback;
23
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
24
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipantProvider;
25
26
public class JEEFlattenParticipantProvider implements
27
		IFlattenParticipantProvider {
28
29
	/*
30
	 * The following are all internal to jeetools and are not API,
31
	 * though may at some point be saved in a settings file in a list 
32
	 * format. if the user decides to customize their list of participants,
33
	 * they may add or remove items to the list in the .settings file
34
	 */
35
	protected static final String JEESingleRootParticipant = "JEESingleRootParticipant"; //$NON-NLS-1$
36
	protected static final String JEEHeirarchyExportParticipant = "JEEHeirarchyExportParticipant"; //$NON-NLS-1$
37
	protected static final String AddClasspathLibReferencesParticipant = "AddClasspathLibReferencesParticipant"; //$NON-NLS-1$
38
	protected static final String AddClasspathFoldersParticipant = "AddClasspathFoldersParticipant"; //$NON-NLS-1$
39
	protected static final String AddMappedOutputFoldersParticipant = "AddMappedOutputFoldersParticipant"; //$NON-NLS-1$
40
	protected static final String IgnoreJavaInSourceFolderParticipant = "IgnoreJavaInSourceFolderParticipant"; //$NON-NLS-1$
41
	protected static final String JEEReplaceManifestExportParticipant = "JEEReplaceManifestExportParticipant"; //$NON-NLS-1$
42
	
43
	public IFlattenParticipant findParticipant(String id) {
44
		if( JEESingleRootParticipant.equals(id))
45
			return new SingleRootExportParticipant(new JavaEESingleRootCallback());
46
		if( JEEHeirarchyExportParticipant.equals(id))
47
			return new JEEHeirarchyExportParticipant();
48
		if( AddClasspathLibReferencesParticipant.equals(id))
49
			return new AddClasspathLibReferencesParticipant();
50
		if( AddClasspathFoldersParticipant.equals(id))
51
			return new AddClasspathFoldersParticipant();
52
		if( AddMappedOutputFoldersParticipant.equals(id))
53
			return new AddMappedOutputFoldersParticipant();
54
		if( IgnoreJavaInSourceFolderParticipant.equals(id))
55
			return new IgnoreJavaInSourceFolderParticipant();
56
		if( JEEReplaceManifestExportParticipant.equals(id))
57
			return new ReplaceManifestExportParticipant(new Path(J2EEConstants.MANIFEST_URI));
58
		return null;
59
	}
60
61
}
(-)plugin.xml (+7 lines)
Lines 859-862 Link Here
859
          class="org.eclipse.jst.j2ee.internal.modulecore.util.JEEManifestDiscerner">
859
          class="org.eclipse.jst.j2ee.internal.modulecore.util.JEEManifestDiscerner">
860
    </discerner>
860
    </discerner>
861
 </extension>
861
 </extension>
862
 <extension
863
       point="org.eclipse.wst.common.modulecore.flattenParticipantProvider">
864
    <flattenParticipantProvider
865
          class="org.eclipse.jst.j2ee.internal.deployables.JEEFlattenParticipantProvider"
866
          weight="10">
867
    </flattenParticipantProvider>
868
 </extension>
862
</plugin>
869
</plugin>
(-)modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/FlattenParticipantModel.java (+123 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 Red Hat and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Red Hat - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.common.componentcore.internal.flat;
12
13
import java.util.ArrayList;
14
import java.util.Collections;
15
import java.util.Comparator;
16
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.IConfigurationElement;
19
import org.eclipse.core.runtime.IExtensionRegistry;
20
import org.eclipse.core.runtime.Platform;
21
import org.eclipse.wst.common.componentcore.internal.ModulecorePlugin;
22
23
/**
24
 * A class to load and keep track of all IFlattenParticipantProviders, 
25
 * and also to assist in locating IFlattenParticipants of a specific ID. 
26
 */
27
public class FlattenParticipantModel {
28
	
29
	private static FlattenParticipantModel model;
30
	public static FlattenParticipantModel getDefault() {
31
		if( model == null )
32
			model = new FlattenParticipantModel();
33
		return model;
34
	}
35
	
36
	private ArrayList<FlattenParticipantProviderWrapper> providers;
37
	public FlattenParticipantModel() {
38
		
39
	}
40
	
41
	public IFlattenParticipant getParticipant(String id) {
42
		IFlattenParticipantProvider[] providers = getProviders();
43
		IFlattenParticipant result = null;
44
		for( int i = 0; i < providers.length; i++ ) {
45
			result = providers[i].findParticipant(id);
46
			if( result != null )
47
				return result;
48
		}
49
		return null;
50
	}
51
	
52
	protected IFlattenParticipantProvider[] getProviders() {
53
		if( providers == null )
54
			loadProviders();
55
		return providers.toArray(new IFlattenParticipantProvider[providers.size()]);
56
	}
57
	
58
	protected void loadProviders() {
59
		ArrayList<FlattenParticipantProviderWrapper> tmp = new ArrayList<FlattenParticipantProviderWrapper>();
60
		IExtensionRegistry registry = Platform.getExtensionRegistry();
61
		IConfigurationElement[] cf = registry.getConfigurationElementsFor(ModulecorePlugin.PLUGIN_ID, "flattenParticipantProvider"); //$NON-NLS-1$
62
		String id = null;
63
		for( int j = 0; j < cf.length; j++ ) {
64
			tmp.add(getWrapper(cf[j]));
65
		}
66
		
67
		// Sort
68
		Collections.sort(tmp, new Comparator<FlattenParticipantProviderWrapper>() {
69
			public int compare(FlattenParticipantProviderWrapper o1,
70
					FlattenParticipantProviderWrapper o2) {
71
				if( o1 == null && o2 == null )
72
					return 0;
73
				if( o1 == null )
74
					return 1;
75
				if( o2 == null )
76
					return -1;
77
				return o2.getWeight() - o1.getWeight();
78
			}
79
		});
80
		
81
		providers = tmp;
82
	}
83
	
84
	private FlattenParticipantProviderWrapper getWrapper(IConfigurationElement element) {
85
		return new FlattenParticipantProviderWrapper(element);
86
	}
87
	
88
	private static class FlattenParticipantProviderWrapper implements IFlattenParticipantProvider {
89
		private IConfigurationElement cf;
90
		private int weight;
91
		private IFlattenParticipantProvider delegate;
92
		public FlattenParticipantProviderWrapper(IConfigurationElement element) {
93
			this.cf = element;
94
			System.out.println(element.getAttribute("class"));
95
			String s = element.getAttribute("weight");
96
			try {
97
				weight = Integer.parseInt(s);
98
			} catch(NumberFormatException nfe ) {
99
				// TODO trace / log? Maybe not necessary. Use default weight
100
				weight = 0; // default weight
101
			}
102
		}
103
		
104
		public int getWeight() {
105
			return weight;
106
		}
107
		
108
		public IFlattenParticipant findParticipant(String id) {
109
			if( delegate == null )
110
				loadDelegate();
111
			return delegate == null ? null : delegate.findParticipant(id);
112
		}
113
		
114
		private void loadDelegate() {
115
			try {
116
				delegate = (IFlattenParticipantProvider) cf.createExecutableExtension("class");
117
			} catch(CoreException ce ) {
118
				// TODO where to do the logging?
119
			}
120
		}
121
	}
122
	
123
}
(-)modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/IFlattenParticipantProvider.java (+23 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 Red Hat and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Red Hat - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.common.componentcore.internal.flat;
12
13
public interface IFlattenParticipantProvider {
14
	
15
	/**
16
	 * If this provider can find a participant for this specific
17
	 * id, it should do so now. Otherwise, return null. 
18
	 * 
19
	 * @param id A flatten participant id
20
	 * @return
21
	 */
22
	public IFlattenParticipant findParticipant(String id);
23
}
(-)plugin.xml (+1 lines)
Lines 56-61 Link Here
56
    <extension-point id="componentimpl" name="componentimpl" schema="schema/componentimpl.exsd"/>
56
    <extension-point id="componentimpl" name="componentimpl" schema="schema/componentimpl.exsd"/>
57
	<extension-point id="resourceFactories" name="Resource Factory Association (Internal)" schema="schema/resourceFactories.exsd"/>
57
	<extension-point id="resourceFactories" name="Resource Factory Association (Internal)" schema="schema/resourceFactories.exsd"/>
58
 <extension-point id="referenceResolver" name="referenceResolver" schema="schema/referenceResolver.exsd"/>
58
 <extension-point id="referenceResolver" name="referenceResolver" schema="schema/referenceResolver.exsd"/>
59
 <extension-point id="flattenParticipantProvider" name="flattenParticipantProvider" schema="schema/flattenParticipantProvider.exsd"/>
59
	
60
	
60
	<!-- Contribute a URIResolverExtension for flexible projects -->
61
	<!-- Contribute a URIResolverExtension for flexible projects -->
61
	<extension point="org.eclipse.wst.common.uriresolver.resolverExtensions">
62
	<extension point="org.eclipse.wst.common.uriresolver.resolverExtensions">
(-)schema/flattenParticipantProvider.exsd (+109 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.wst.common.modulecore" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.wst.common.modulecore" id="flattenParticipant" name="flattenParticipant"/>
7
      </appInfo>
8
      <documentation>
9
         [Enter description of this extension point.]
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <annotation>
15
         <appInfo>
16
            <meta.element />
17
         </appInfo>
18
      </annotation>
19
      <complexType>
20
         <sequence>
21
            <element ref="flattenParticipantProvider" minOccurs="1" maxOccurs="unbounded"/>
22
         </sequence>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  
41
               </documentation>
42
               <appInfo>
43
                  <meta.attribute translatable="true"/>
44
               </appInfo>
45
            </annotation>
46
         </attribute>
47
      </complexType>
48
   </element>
49
50
   <element name="flattenParticipantProvider">
51
      <complexType>
52
         <attribute name="class" type="string" use="required">
53
            <annotation>
54
               <documentation>
55
                  The implementation class for this participant provider. The class must have a 0-argument constructor.
56
               </documentation>
57
               <appInfo>
58
                  <meta.attribute kind="java" basedOn=":org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipantProvider"/>
59
               </appInfo>
60
            </annotation>
61
         </attribute>
62
         <attribute name="weight" type="string">
63
            <annotation>
64
               <documentation>
65
                  A weight for this provider. Providers will be sorted by their weight and polled individually  in order for a specific key. If the provider can find or create that flatten participant, it should return it.
66
               </documentation>
67
            </annotation>
68
         </attribute>
69
      </complexType>
70
   </element>
71
72
   <annotation>
73
      <appInfo>
74
         <meta.section type="since"/>
75
      </appInfo>
76
      <documentation>
77
         [Enter the first release in which this extension point appears.]
78
      </documentation>
79
   </annotation>
80
81
   <annotation>
82
      <appInfo>
83
         <meta.section type="examples"/>
84
      </appInfo>
85
      <documentation>
86
         [Enter extension point usage example here.]
87
      </documentation>
88
   </annotation>
89
90
   <annotation>
91
      <appInfo>
92
         <meta.section type="apiinfo"/>
93
      </appInfo>
94
      <documentation>
95
         [Enter API information here.]
96
      </documentation>
97
   </annotation>
98
99
   <annotation>
100
      <appInfo>
101
         <meta.section type="implementation"/>
102
      </appInfo>
103
      <documentation>
104
         [Enter information about supplied implementation of this extension point.]
105
      </documentation>
106
   </annotation>
107
108
109
</schema>
(-)commontests/org/eclipse/wst/common/tests/flatten/ExampleFlattenParticipantProvider.java (+22 lines)
Added Link Here
1
package org.eclipse.wst.common.tests.flatten;
2
3
import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant;
4
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
5
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipantProvider;
6
7
public class ExampleFlattenParticipantProvider implements
8
		IFlattenParticipantProvider {
9
10
	public static final String DUMMY_PARTICIPANT = "example1";
11
	public IFlattenParticipant findParticipant(String id) {
12
		if( DUMMY_PARTICIPANT.equals(id)) {
13
			return new DummyFlattenParticipant();
14
		}
15
		return null;
16
	}
17
	
18
	public static class DummyFlattenParticipant extends AbstractFlattenParticipant {
19
		
20
	}
21
22
}
(-)commontests/org/eclipse/wst/common/tests/flatten/ExampleFlattenParticipantProvider2.java (+27 lines)
Added Link Here
1
package org.eclipse.wst.common.tests.flatten;
2
3
import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant;
4
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
5
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipantProvider;
6
7
public class ExampleFlattenParticipantProvider2 implements
8
		IFlattenParticipantProvider {
9
10
	public static final String DUMMY_PARTICIPANT = "example2";
11
	
12
	public static final String COMMON_KEY = "common";
13
	public IFlattenParticipant findParticipant(String id) {
14
		if( DUMMY_PARTICIPANT.equals(id)) {
15
			return new Dummy2FlattenParticipant();
16
		}
17
		if( COMMON_KEY.equals(id))
18
			return new Dummy2FlattenParticipant();
19
		
20
		return null;
21
	}
22
	
23
	public static class Dummy2FlattenParticipant extends AbstractFlattenParticipant {
24
		
25
	}
26
27
}
(-)commontests/org/eclipse/wst/common/tests/flatten/ExampleFlattenParticipantProvider3.java (+24 lines)
Added Link Here
1
package org.eclipse.wst.common.tests.flatten;
2
3
import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant;
4
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
5
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipantProvider;
6
7
public class ExampleFlattenParticipantProvider3 implements
8
		IFlattenParticipantProvider {
9
10
	public static final String DUMMY_PARTICIPANT = "example3";
11
	public static final String COMMON_KEY = ExampleFlattenParticipantProvider2.COMMON_KEY;
12
	public IFlattenParticipant findParticipant(String id) {
13
		if( DUMMY_PARTICIPANT.equals(id))
14
			return new Dummy3FlattenParticipant();
15
		if( COMMON_KEY.equals(id))
16
			return new Dummy3FlattenParticipant();
17
		return null;
18
	}
19
	
20
	public static class Dummy3FlattenParticipant extends AbstractFlattenParticipant {
21
		
22
	}
23
24
}
(-)commontests/org/eclipse/wst/common/tests/flatten/FlattenParticipantProviderTest.java (+61 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.common.tests.flatten;
12
13
import junit.framework.TestCase;
14
15
import org.eclipse.wst.common.componentcore.internal.flat.FlattenParticipantModel;
16
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
17
18
19
public class FlattenParticipantProviderTest extends TestCase {
20
21
    public FlattenParticipantProviderTest(String name) {
22
        super(name);
23
    }
24
25
    public void testNotFoundParticipantFound() {
26
    	assertNull(searchModel("NOT FOUND"));
27
    }
28
29
    public void testExample1ParticipantFound() {
30
    	IFlattenParticipant fp = searchModel(ExampleFlattenParticipantProvider.DUMMY_PARTICIPANT);
31
    	assertNotNull(fp);
32
    	assertTrue(fp.getClass().getName().endsWith("DummyFlattenParticipant"));
33
    }
34
35
    public void testExample2ParticipantFound() {
36
    	IFlattenParticipant fp = searchModel(ExampleFlattenParticipantProvider2.DUMMY_PARTICIPANT);
37
    	assertNotNull(fp);
38
    	assertTrue(fp.getClass().getName().endsWith("Dummy2FlattenParticipant"));
39
    }
40
41
    public void testExample3ParticipantFound() {
42
    	IFlattenParticipant fp = searchModel(ExampleFlattenParticipantProvider3.DUMMY_PARTICIPANT);
43
    	assertNotNull(fp);
44
    	assertTrue(fp.getClass().getName().endsWith("Dummy3FlattenParticipant"));
45
    }
46
47
    /**
48
     * This test ensures that the weighting is done properly.
49
     * providers with a higher weight should be consulted first.
50
     * Weight 10 should be asked before weight 0
51
     */
52
    public void testCommonParticipantFound() {
53
    	IFlattenParticipant fp = searchModel(ExampleFlattenParticipantProvider2.COMMON_KEY);
54
    	assertNotNull(fp);
55
    	assertTrue(fp.getClass().getName().endsWith("Dummy3FlattenParticipant"));
56
    }
57
58
    private IFlattenParticipant searchModel(String id) {
59
    	return FlattenParticipantModel.getDefault().getParticipant(id);
60
    }
61
}
(-)plugin.xml (+14 lines)
Lines 105-110 Link Here
105
      <operationExtension
105
      <operationExtension
106
            id="org.eclipse.wst.common.frameworks.datamodel.tests.extended.H"/>
106
            id="org.eclipse.wst.common.frameworks.datamodel.tests.extended.H"/>
107
   </extension>
107
   </extension>
108
  <extension
109
        point="org.eclipse.wst.common.modulecore.flattenParticipantProvider">
110
     <flattenParticipantProvider
111
           class="org.eclipse.wst.common.tests.flatten.ExampleFlattenParticipantProvider"
112
           weight="5">
113
     </flattenParticipantProvider>
114
     <flattenParticipantProvider
115
           class="org.eclipse.wst.common.tests.flatten.ExampleFlattenParticipantProvider2">
116
     </flattenParticipantProvider>
117
     <flattenParticipantProvider
118
           class="org.eclipse.wst.common.tests.flatten.ExampleFlattenParticipantProvider3"
119
           weight="10">
120
     </flattenParticipantProvider>
121
  </extension>
108
   
122
   
109
   
123
   
110
   <!-- Uncomment the below hook to test specific operation extension ids when needed -->
124
   <!-- Uncomment the below hook to test specific operation extension ids when needed -->
(-)static_web_project/org/eclipse/wst/web/internal/deployables/FlatComponentDeployable.java (-2 / +39 lines)
Lines 26-31 Link Here
26
import org.eclipse.wst.common.componentcore.ComponentCore;
26
import org.eclipse.wst.common.componentcore.ComponentCore;
27
import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent;
27
import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent;
28
import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.FlatComponentTaskModel;
28
import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.FlatComponentTaskModel;
29
import org.eclipse.wst.common.componentcore.internal.flat.FlattenParticipantModel;
29
import org.eclipse.wst.common.componentcore.internal.flat.IChildModuleReference;
30
import org.eclipse.wst.common.componentcore.internal.flat.IChildModuleReference;
30
import org.eclipse.wst.common.componentcore.internal.flat.IFlatFile;
31
import org.eclipse.wst.common.componentcore.internal.flat.IFlatFile;
31
import org.eclipse.wst.common.componentcore.internal.flat.IFlatFolder;
32
import org.eclipse.wst.common.componentcore.internal.flat.IFlatFolder;
Lines 130-137 Link Here
130
	 * @return
131
	 * @return
131
	 */
132
	 */
132
	protected IFlattenParticipant[] getParticipants() {
133
	protected IFlattenParticipant[] getParticipants() {
133
		return new IFlattenParticipant[]{
134
		// If file exists, load from file
134
		};
135
		
136
		
137
		// else, get default participants
138
		return getDefaultFlattenParticipants();
139
	}
140
	
141
	/*
142
	 * Load the default participants
143
	 */
144
	protected IFlattenParticipant[] getDefaultFlattenParticipants() {
145
		ArrayList<IFlattenParticipant> participants = new ArrayList<IFlattenParticipant>();
146
		
147
		String[] defaultParticipants = getDefaultFlattenParticipantIDs();
148
		
149
		// Null protection
150
		defaultParticipants = defaultParticipants == null ? new String[0] : defaultParticipants;
151
		
152
		IFlattenParticipant tmp;
153
		for( int i = 0; i < defaultParticipants.length; i++ ) {
154
			tmp = FlattenParticipantModel.getDefault().getParticipant(defaultParticipants[i]);
155
			if( tmp != null )
156
				participants.add(tmp);
157
			else {
158
				// Log? This is an error somehow
159
			}
160
		}
161
		
162
		return participants.toArray(new IFlattenParticipant[participants.size()]);
163
	}
164
	
165
	
166
	/**
167
	 * Get a list of participant keys that are default for this project type
168
	 * @return
169
	 */
170
	protected String[] getDefaultFlattenParticipantIDs() {
171
		return new String[0];
135
	}
172
	}
136
	
173
	
137
	public boolean isBinary() {
174
	public boolean isBinary() {

Return to bug 330894