Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: 004401d905a8c21b73aa1c93840c0f5d16e7e19f (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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*******************************************************************************
 * 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
 *******************************************************************************/
package org.eclipse.jst.j2ee.internal.wizard;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
import org.eclipse.ui.IImportWizard;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;

/**
 * <p>
 * Serves as a base class for Wizards which import J2EE module structures into Eclipse projects.
 * </p>
 * <p>
 * Import wizards must define the following methods:
 * <ul>
 * <li>{@link #getImportOperation()}
 * <li>{@link #getModuleValidatorStrings()}
 * </ul>
 * </p>
 * <p>
 * And optionally, they may override the following methods from
 * {@see org.eclipse.jst.j2ee.internal.wizard.J2EEArtifactImportWizard}:
 * <ul>
 * <li>{@link #getFinalPerspectiveID()}
 * <li>{@link #doInit()()}
 * <li>{@link #doDispose()()}
 * </ul>
 */
public abstract class J2EEComponentImportWizard extends J2EEArtifactImportWizard implements IImportWizard, IExecutableExtension {

	private static final String[] VALIDATOR_STRINGS = new String[]{"org.eclipse.jst.j2ee.internal.validation.UIEarValidator"}; //$NON-NLS-1$

	private static final Class IPROJECT_CLASS = IProject.class;

	/**
	 * <p>
	 * The default constructor. Creates a wizard with no selection, no model instance, and no
	 * operation instance. The model and operation will be created as needed.
	 * </p>
	 */
	public J2EEComponentImportWizard() {
		super();
		setWindowTitle(J2EEUIMessages.getResourceString("38")); //$NON-NLS-1$
	}

	/**
	 * <p>
	 * The model is used to prepopulate the wizard controls and interface with the operation.
	 * </p>
	 * 
	 * @param model
	 *            The model parameter is used to pre-populate wizard controls and interface with the
	 *            operation
	 */
	public J2EEComponentImportWizard(IDataModel model) {
		super(model);
		setWindowTitle(J2EEUIMessages.getResourceString("38"));//$NON-NLS-1$ 
	}

	// /**
	// * <p>
	// * Creates an Import Operation using {@link #getImportOperation()}and wraps it to run
	// * validation once the module has been imported.
	// * </p>
	// *
	// * @return Returns a wrapper operation around the result of getImportOperation() that also
	// runs
	// * validation as defined in getModuleValidatorStrings()
	// * @see #getImportOperation()
	// * @see #getModuleValidatorStrings()
	// */
	// protected final WTPOperation createBaseOperation() {
	// return new WTPOperation() {
	// protected void execute(IProgressMonitor monitor) throws CoreException,
	// InvocationTargetException, InterruptedException {
	// WTPOperation importOp = getImportOperation();
	// if (importOp == null)
	// return;
	// importOp.run(monitor);
	//
	// J2EEModuleImportDataModel importModel = (J2EEModuleImportDataModel)
	// getImportOperation().getOperationDataModel();
	// IProject moduleProject = importModel.getProject();
	// ValidatorSubsetOperation moduleValidator = new ValidatorSubsetOperation(moduleProject, true,
	// false);
	// moduleValidator.setValidators(getModuleValidatorStrings());
	// moduleValidator.run(monitor);
	//
	// if (importModel.getBooleanProperty(J2EEModuleImportDataModel.ADD_TO_EAR)) {
	// IProject earProject =
	// importModel.getJ2EEModuleCreationDataModel().getEarComponentCreationDataModel().getTargetProject();
	// ValidatorSubsetOperation earValidator = new ValidatorSubsetOperation(earProject, true,
	// false);
	// earValidator.setValidators(getEarValidatorStrings());
	// earValidator.run(monitor);
	// }
	// }
	// };
	// }

	// /**
	// *
	// * @return The appropriate import operation for the specific J2EE model type
	// */
	// protected abstract WTPOperation getImportOperation();

	/**
	 * <p>
	 * The Import Wizards can run arbitrary validators once the module has been created. These
	 * validators ensure that the structure created by the Import operation and the contents of that
	 * structure are valid. Any errors will be announced to the Problems view in Eclipse.
	 * </p>
	 * 
	 * @return An array of validator IDs that should be used for this module type
	 */
	protected abstract String[] getModuleValidatorStrings();

	// /**
	// * <p>
	// * Uses the selection supplied from the {@link #init(IWorkbench, IStructuredSelection)}method
	// * to set the associated EAR Module if an EAR artifact was selected.
	// * </p>
	// *
	// * @param importModel
	// * The Module Import data model to have its J2EEModuleImportDataModel.EAR_PROJECT
	// * field set.
	// */
	// protected final void updateEARToModelFromSelection(J2EEModuleImportDataModel importModel) {
	// /* Set the default ear selected if a ear is selected */
	// try {
	// if (getSelection() != null && !getSelection().isEmpty()) {
	// IProject targetEARProject = (IProject)
	// AdaptabilityUtility.getAdapter(getSelection().getFirstElement(), IPROJECT_CLASS);
	// if (targetEARProject != null && targetEARProject.hasNature(IEARNatureConstants.NATURE_ID))
	// importModel.setProperty(J2EEModuleImportDataModel.EAR_NAME, targetEARProject.getName());
	// }
	// } catch (Exception e) {
	// //Ignore
	// }
	// }

	// private String[] getEarValidatorStrings() {
	// return VALIDATOR_STRINGS;
	// }

}

Back to the top