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 325911
Collapse All | Expand All

(-)j2ee_ui/org/eclipse/jst/j2ee/internal/ui/J2EEModuleDependenciesPropertyPage.java (+11 lines)
Lines 21-26 Link Here
21
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IPath;
22
import org.eclipse.core.runtime.IPath;
23
import org.eclipse.core.runtime.IProgressMonitor;
23
import org.eclipse.core.runtime.IProgressMonitor;
24
import org.eclipse.core.runtime.IStatus;
24
import org.eclipse.core.runtime.Path;
25
import org.eclipse.core.runtime.Path;
25
import org.eclipse.jdt.core.IClasspathAttribute;
26
import org.eclipse.jdt.core.IClasspathAttribute;
26
import org.eclipse.jdt.core.IClasspathEntry;
27
import org.eclipse.jdt.core.IClasspathEntry;
Lines 296-301 Link Here
296
			super.handleAddDirective(wizard);
297
			super.handleAddDirective(wizard);
297
		}
298
		}
298
	}
299
	}
300
	
301
	@Override
302
	protected void verify() {
303
		ArrayList<ComponentResourceProxy> allMappings = new ArrayList<ComponentResourceProxy>();
304
		allMappings.addAll(resourceMappings);
305
		allMappings.addAll(hiddenMappings);
306
		
307
		IStatus status = J2EEModuleDeploymentAssemblyVerifierHelper.verify(rootComponent, runtime, currentReferences, allMappings,resourceMappingsChanged, currentClasspathEntries);
308
		setErrorMessage(status);
309
	}
299
310
300
//	
311
//	
301
//	@Override
312
//	@Override
(-)j2ee_ui/org/eclipse/jst/j2ee/internal/ui/J2EEModuleDeploymentAssemblyVerifierData.java (+38 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 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.ui;
12
13
import java.util.ArrayList;
14
import java.util.List;
15
16
import org.eclipse.jst.j2ee.internal.ui.J2EEModuleDependenciesPropertyPage.ClasspathEntryProxy;
17
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
18
import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
19
import org.eclipse.wst.common.componentcore.ui.internal.propertypage.verifier.DeploymentAssemblyVerifierData;
20
import org.eclipse.wst.common.componentcore.ui.propertypage.AddModuleDependenciesPropertiesPage.ComponentResourceProxy;
21
import org.eclipse.wst.server.core.IRuntime;
22
23
public class J2EEModuleDeploymentAssemblyVerifierData extends DeploymentAssemblyVerifierData{
24
	
25
	public J2EEModuleDeploymentAssemblyVerifierData(IVirtualComponent component, IRuntime runtime, ArrayList<IVirtualReference> currentReferences,
26
			ArrayList<ComponentResourceProxy> resourceMappings, boolean resourceMappingsChanged, List<ClasspathEntryProxy> currentClasspathEntries2) {
27
		super(component, runtime, currentReferences,resourceMappings, resourceMappingsChanged);
28
		this.currentClasspathEntries = currentClasspathEntries2;
29
	}
30
	private List<ClasspathEntryProxy> currentClasspathEntries;
31
32
	public List<ClasspathEntryProxy> getCurrentClasspathEntries() {
33
		return currentClasspathEntries;
34
	}
35
	public void setCurrentClasspathEntries(List<ClasspathEntryProxy> currentClasspathEntries) {
36
		this.currentClasspathEntries = currentClasspathEntries;
37
	}
38
}
(-)j2ee_ui/org/eclipse/jst/j2ee/internal/ui/J2EEModuleDeploymentAssemblyVerifierHelper.java (+70 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 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.ui;
12
13
import java.util.ArrayList;
14
import java.util.List;
15
16
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.runtime.IConfigurationElement;
18
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.MultiStatus;
20
import org.eclipse.core.runtime.Status;
21
import org.eclipse.jst.j2ee.internal.ui.J2EEModuleDependenciesPropertyPage.ClasspathEntryProxy;
22
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
23
import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
24
import org.eclipse.wst.common.componentcore.ui.Messages;
25
import org.eclipse.wst.common.componentcore.ui.ModuleCoreUIPlugin;
26
import org.eclipse.wst.common.componentcore.ui.internal.propertypage.verifier.DeploymentAssemblyVerifierHelper;
27
import org.eclipse.wst.common.componentcore.ui.internal.propertypage.verifier.IDeploymentAssemblyVerifier;
28
import org.eclipse.wst.common.componentcore.ui.internal.propertypage.verifier.VerifierRegistryReader;
29
import org.eclipse.wst.common.componentcore.ui.propertypage.AddModuleDependenciesPropertiesPage.ComponentResourceProxy;
30
import org.eclipse.wst.server.core.IRuntime;
31
32
public class J2EEModuleDeploymentAssemblyVerifierHelper {
33
	
34
	
35
	/**
36
	 * This method will use the facet framework to find all registered verifiers based on installed facets and runtimes.
37
	 * All the verifiers will have an opportunity to verify and return status on the proposed component mappings
38
	 * @param component
39
	 * @param runtime
40
	 * @param resourceMappingsChanged 
41
	 * @param resourceMappings 
42
	 * @param currentReferences 
43
	 * @param currentClasspathEntries
44
	 * @return IStatus
45
	 */
46
	public static IStatus verify(IVirtualComponent component,IRuntime runtime, ArrayList<IVirtualReference> currentReferences, ArrayList<ComponentResourceProxy> resourceMappings, boolean resourceMappingsChanged, List<ClasspathEntryProxy> currentClasspathEntries) {
47
		IProject project = component.getProject();
48
		
49
		List verifiers = DeploymentAssemblyVerifierHelper.collectAllVerifiers(project,runtime);
50
		if (verifiers.isEmpty()) return Status.OK_STATUS;
51
		MultiStatus masterStatus = new MultiStatus(ModuleCoreUIPlugin.PLUGIN_ID, IStatus.OK, Messages.DeploymentAssemblyVerifierHelper_0,null); 
52
		
53
		for (int i = 0; i < verifiers.size(); i++) {
54
			if (!(verifiers.get(i) instanceof IConfigurationElement))
55
				continue;
56
			IDeploymentAssemblyVerifier verifier = null;
57
			try {
58
				verifier = (IDeploymentAssemblyVerifier) ((IConfigurationElement) verifiers.get(i)).createExecutableExtension(VerifierRegistryReader.VERIFIER_CLASS);
59
				J2EEModuleDeploymentAssemblyVerifierData data = new J2EEModuleDeploymentAssemblyVerifierData(component, runtime,currentReferences,resourceMappings,resourceMappingsChanged,currentClasspathEntries );
60
				IStatus verifyStatus = verifier.verify(data);
61
				masterStatus.add(verifyStatus);
62
			} catch (Exception e) {
63
				ModuleCoreUIPlugin.log(e);
64
				continue;
65
			}
66
			
67
		}
68
		return masterStatus;
69
	}	
70
}
(-)src/org/eclipse/wst/common/componentcore/ui/internal/propertypage/verifier/DeploymentAssemblyVerifierHelper.java (-1 / +1 lines)
Lines 75-81 Link Here
75
	 * @param runtime
75
	 * @param runtime
76
	 * @return all verifiers by iterating through projects installed facets, and querying the registry
76
	 * @return all verifiers by iterating through projects installed facets, and querying the registry
77
	 */
77
	 */
78
	private static List collectAllVerifiers(IProject project, IRuntime runtime) {
78
	public static List collectAllVerifiers(IProject project, IRuntime runtime) {
79
		IFacetedProject fProj = null;
79
		IFacetedProject fProj = null;
80
		try {
80
		try {
81
			fProj = ProjectFacetsManager.create(project);
81
			fProj = ProjectFacetsManager.create(project);
(-)src/org/eclipse/wst/common/componentcore/ui/propertypage/AddModuleDependenciesPropertiesPage.java (-13 / +19 lines)
Lines 703-724 Link Here
703
		allMappings.addAll(hiddenMappings);
703
		allMappings.addAll(hiddenMappings);
704
		
704
		
705
		IStatus status = DeploymentAssemblyVerifierHelper.verify(rootComponent, runtime, currentReferences, allMappings,resourceMappingsChanged);
705
		IStatus status = DeploymentAssemblyVerifierHelper.verify(rootComponent, runtime, currentReferences, allMappings,resourceMappingsChanged);
706
		setErrorMessage(status);
707
	}
708
	
709
	protected void setErrorMessage(IStatus status) {
706
		// Clear the messages
710
		// Clear the messages
707
		propPage.setErrorMessage(null);
711
		propPage.setErrorMessage(null);
708
		propPage.setMessage(null);
712
		propPage.setMessage(null);
709
		if (status.isMultiStatus()) {
713
		if(status != null) {
710
			MultiStatus multi = (MultiStatus)status;
714
			if (status.isMultiStatus()) {
711
			if (!multi.isOK()) {
715
				MultiStatus multi = (MultiStatus)status;
712
				propPage.setMessage(getMessage(multi), multi.getSeverity());
716
				if (!multi.isOK()) {
713
				if (multi.getSeverity() == IStatus.ERROR) {
717
					propPage.setMessage(getMessage(multi), multi.getSeverity());
714
					propPage.setErrorMessage(getMessage(multi));
718
					if (multi.getSeverity() == IStatus.ERROR) {
715
					propPage.setValid(false);
719
						propPage.setErrorMessage(getMessage(multi));
716
				}
720
						propPage.setValid(false);
717
				else 
721
					}
718
					propPage.setValid(true);
722
					else 
719
			} else propPage.setValid(true);
723
						propPage.setValid(true);
720
		} else if (status.isOK()) propPage.setValid(true);
724
				} else propPage.setValid(true);
721
		propPage.getContainer().updateMessage();
725
			} else if (status.isOK()) propPage.setValid(true);
726
			propPage.getContainer().updateMessage();
727
		}
722
	}
728
	}
723
729
724
	private String getMessage(MultiStatus multi) {
730
	private String getMessage(MultiStatus multi) {

Return to bug 325911