Skip to main content
summaryrefslogtreecommitdiffstats
blob: 4d9289afd1e0a7b4feedc41d43969381ddd3ac2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*******************************************************************************
 * Copyright (c) 2003, 2004 IBM 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:
 * IBM Corporation - initial API and implementation
 *******************************************************************************/
/*
 * Created on Nov 13, 2003
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package org.eclipse.jst.j2ee.application.operations;

import java.lang.reflect.InvocationTargetException;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jst.j2ee.applicationclient.creation.AppClientModuleCreationDataModel;
import org.eclipse.jst.j2ee.applicationclient.creation.AppClientModuleCreationOperation;
import org.eclipse.jst.j2ee.moduleextension.EarModuleExtension;
import org.eclipse.jst.j2ee.moduleextension.EarModuleManager;
import org.eclipse.jst.j2ee.moduleextension.JcaModuleExtension;
import org.eclipse.wst.common.frameworks.internal.activities.WTPActivityBridge;
import org.eclipse.wst.common.frameworks.operations.WTPOperation;


/**
 * @author DABERG
 * 
 * To change the template for this generated type comment go to Window>Preferences>Java>Code
 * Generation>Code and Comments
 */
public class DefaultModuleProjectCreationOperation extends WTPOperation {

	/**
	 * This activity no longer exists use ENTERPRISE_JAVA instead
	 * 
	 * @deprecated
	 */
	public static final String APP_CLIENT_DEV_ACTIVITY_ID = "org.eclipse.jst.j2ee.application.client.development"; //$NON-NLS-1$
	/**
	 * This activity no longer exists use ENTERPRISE_JAVA instead
	 * 
	 * @deprecated
	 */
	public static final String EJB_DEV_ACTIVITY_ID = "com.ibm.wtp.ejb.development"; //$NON-NLS-1$
	/**
	 * This activity no longer exists use ENTERPRISE_JAVA instead
	 * 
	 * @deprecated
	 */
	public static final String JCA_DEV_ACTIVITY_ID = "com.ibm.wtp.jca.development"; //$NON-NLS-1$
	public static final String WEB_DEV_ACTIVITY_ID = "com.ibm.wtp.web.development"; //$NON-NLS-1$
	public static final String ENTERPRISE_JAVA = "com.ibm.wtp.ejb.development"; //$NON-NLS-1$

	/**
	 * @param operationDataModel
	 */
	public DefaultModuleProjectCreationOperation(DefaultModuleProjectCreationDataModel operationDataModel) {
		super(operationDataModel);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
	 */
	protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
		DefaultModuleProjectCreationDataModel model = (DefaultModuleProjectCreationDataModel) operationDataModel;
		if (model.getEjbModel() != null && model.getBooleanProperty(DefaultModuleProjectCreationDataModel.CREATE_EJB))
			createEJBModuleProject(model.getEjbModel(), monitor);
		if (model.getWebModel() != null && model.getBooleanProperty(DefaultModuleProjectCreationDataModel.CREATE_WEB))
			createWebModuleProject(model.getWebModel(), monitor);
		if (model.getJCAModel() != null && model.getBooleanProperty(DefaultModuleProjectCreationDataModel.CREATE_CONNECTOR))
			createRarModuleProject(model.getJCAModel(), monitor);
		if (model.getClientModel() != null && model.getBooleanProperty(DefaultModuleProjectCreationDataModel.CREATE_APPCLIENT))
			createAppClientModuleProject(model.getClientModel(), monitor);
	}

	/**
	 * @param model
	 */
	private void createEJBModuleProject(J2EEModuleCreationDataModel model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
		EarModuleExtension ext = EarModuleManager.getEJBModuleExtension();
		runModuleExtensionOperation(ext, model, monitor);
		WTPActivityBridge.getInstance().enableActivity(ENTERPRISE_JAVA, true);
	}

	/**
	 * @param model
	 */
	private void createWebModuleProject(J2EEModuleCreationDataModel model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
		EarModuleExtension ext = EarModuleManager.getWebModuleExtension();
		runModuleExtensionOperation(ext, model, monitor);
		WTPActivityBridge.getInstance().enableActivity(WEB_DEV_ACTIVITY_ID, true);
	}

	/**
	 * @param model
	 */
	private void createRarModuleProject(J2EEModuleCreationDataModel model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
		JcaModuleExtension jcaExt = EarModuleManager.getJCAModuleExtension();
		runModuleExtensionOperation(jcaExt, model, monitor);
		WTPActivityBridge.getInstance().enableActivity(ENTERPRISE_JAVA, true);
	}

	private void runModuleExtensionOperation(EarModuleExtension extension, J2EEModuleCreationDataModel model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
		if (extension != null) {
			J2EEModuleCreationOperation op = extension.createProjectCreationOperation(model);
			if (op != null)
				op.doRun(monitor);
		}
	}

	/**
	 * @param model
	 */
	private void createAppClientModuleProject(J2EEModuleCreationDataModel model, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
		AppClientModuleCreationOperation op = new AppClientModuleCreationOperation((AppClientModuleCreationDataModel) model);
		op.doRun(monitor);
		WTPActivityBridge.getInstance().enableActivity(ENTERPRISE_JAVA, true);

	}
}

Back to the top