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 250802 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jpt/ui/internal/wizards/entity/EntityWizardMsg.java (-1 / +2 lines)
Lines 54-60 Link Here
54
    public static String BROWSE_BUTTON_LABEL;
54
    public static String BROWSE_BUTTON_LABEL;
55
    public static String ADD_BUTTON_LABEL;
55
    public static String ADD_BUTTON_LABEL;
56
    public static String EDIT_BUTTON_LABEL;
56
    public static String EDIT_BUTTON_LABEL;
57
    public static String REMOVE_BUTTON_LABEL;
57
	public static String EntityDataModelProvider_entityNotInProjectClasspath;
58
	public static String REMOVE_BUTTON_LABEL;
58
    public static String DUPLICATED_ENTITY_NAMES_MESSAGE;
59
    public static String DUPLICATED_ENTITY_NAMES_MESSAGE;
59
    public static String ACCESS_TYPE;
60
    public static String ACCESS_TYPE;
60
    public static String FIELD_BASED;
61
    public static String FIELD_BASED;
(-)src/org/eclipse/jpt/ui/internal/wizards/entity/EntityRowTableWizardSection.java (-3 / +14 lines)
Lines 13-24 Link Here
13
13
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.Collection;
15
import java.util.Collection;
16
import java.util.Iterator;
16
import java.util.List;
17
import java.util.List;
17
18
19
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.jdt.core.IPackageFragmentRoot;
20
import org.eclipse.jdt.core.IPackageFragmentRoot;
19
import org.eclipse.jdt.core.IType;
21
import org.eclipse.jdt.core.IType;
22
import org.eclipse.jdt.core.JavaConventions;
20
import org.eclipse.jdt.core.search.IJavaSearchConstants;
23
import org.eclipse.jdt.core.search.IJavaSearchConstants;
21
import org.eclipse.jdt.core.search.IJavaSearchScope;
24
import org.eclipse.jdt.core.search.IJavaSearchScope;
25
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
22
import org.eclipse.jdt.internal.ui.dialogs.FilteredTypesSelectionDialog;
26
import org.eclipse.jdt.internal.ui.dialogs.FilteredTypesSelectionDialog;
23
import org.eclipse.jface.dialogs.Dialog;
27
import org.eclipse.jface.dialogs.Dialog;
24
import org.eclipse.jface.dialogs.IDialogConstants;
28
import org.eclipse.jface.dialogs.IDialogConstants;
Lines 63-68 Link Here
63
import org.eclipse.swt.widgets.TableColumn;
67
import org.eclipse.swt.widgets.TableColumn;
64
import org.eclipse.swt.widgets.Text;
68
import org.eclipse.swt.widgets.Text;
65
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
69
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
70
import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard;
71
import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage;
66
72
67
/**
73
/**
68
 * The class presents the table with entity fields. In the java file are included also content
74
 * The class presents the table with entity fields. In the java file are included also content
Lines 511-520 Link Here
511
		 * The first text field should not be empty. 
517
		 * The first text field should not be empty. 
512
		 */
518
		 */
513
		public boolean validate(Combo combo, Text[] texts) {
519
		public boolean validate(Combo combo, Text[] texts) {
514
			if (texts.length > 0) {
520
			 if (texts.length > 0) {
515
				return texts[0].getText().trim().length() > 0;
521
				IStatus validateFieldNameStatus = JavaConventions.validateFieldName(texts[0].getText(), CompilerOptions.VERSION_1_5, CompilerOptions.VERSION_1_5);
522
				if(!validateFieldNameStatus.isOK()){
523
					return false;
524
				} else {
525
				 return texts[0].getText().trim().length() > 0;
526
				}
516
			}
527
			}
517
			return true;
528
 			return true;
518
		}
529
		}
519
		
530
		
520
		/**
531
		/**
(-)property_files/jpt_ui_entity_wizard.properties (+1 lines)
Lines 42-47 Link Here
42
BROWSE_BUTTON_LABEL=Browse...
42
BROWSE_BUTTON_LABEL=Browse...
43
ADD_BUTTON_LABEL=Add...
43
ADD_BUTTON_LABEL=Add...
44
EDIT_BUTTON_LABEL=Edit...
44
EDIT_BUTTON_LABEL=Edit...
45
EntityDataModelProvider_entityNotInProjectClasspath="{0}" is not in the project's classpath.
45
REMOVE_BUTTON_LABEL=Remove
46
REMOVE_BUTTON_LABEL=Remove
46
DUPLICATED_ENTITY_NAMES_MESSAGE=There are duplicate names on created entity fields. Please resolve the duplication.
47
DUPLICATED_ENTITY_NAMES_MESSAGE=There are duplicate names on created entity fields. Please resolve the duplication.
47
ACCESS_TYPE=Access Type
48
ACCESS_TYPE=Access Type
(-)src/org/eclipse/jpt/ui/internal/wizards/entity/data/model/EntityDataModelProvider.java (+62 lines)
Lines 11-24 Link Here
11
 ***********************************************************************/
11
 ***********************************************************************/
12
package org.eclipse.jpt.ui.internal.wizards.entity.data.model;
12
package org.eclipse.jpt.ui.internal.wizards.entity.data.model;
13
13
14
import java.text.MessageFormat;
14
import java.util.ArrayList;
15
import java.util.ArrayList;
16
import java.util.Iterator;
17
import java.util.List;
15
import java.util.Set;
18
import java.util.Set;
16
19
20
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.Status;
23
import org.eclipse.jdt.core.IJavaProject;
24
import org.eclipse.jdt.core.IType;
18
import org.eclipse.jdt.core.JavaConventions;
25
import org.eclipse.jdt.core.JavaConventions;
26
import org.eclipse.jdt.core.JavaCore;
27
import org.eclipse.jdt.core.JavaModelException;
28
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
29
import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
30
import org.eclipse.jpt.ui.JptUiPlugin;
19
import org.eclipse.jpt.ui.internal.wizards.entity.EntityWizardMsg;
31
import org.eclipse.jpt.ui.internal.wizards.entity.EntityWizardMsg;
20
import org.eclipse.jpt.ui.internal.wizards.entity.data.operation.NewEntityClassOperation;
32
import org.eclipse.jpt.ui.internal.wizards.entity.data.operation.NewEntityClassOperation;
21
import org.eclipse.jst.j2ee.internal.common.J2EECommonMessages;
33
import org.eclipse.jst.j2ee.internal.common.J2EECommonMessages;
34
import org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties;
22
import org.eclipse.jst.j2ee.internal.common.operations.NewJavaClassDataModelProvider;
35
import org.eclipse.jst.j2ee.internal.common.operations.NewJavaClassDataModelProvider;
23
import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
36
import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
24
import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
37
import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
Lines 170-180 Link Here
170
				String msg = EntityWizardMsg.DUPLICATED_ENTITY_NAMES_MESSAGE;				
183
				String msg = EntityWizardMsg.DUPLICATED_ENTITY_NAMES_MESSAGE;				
171
				return WTPCommonPlugin.createErrorStatus(msg);
184
				return WTPCommonPlugin.createErrorStatus(msg);
172
			}
185
			}
186
			// Ensure that the entries in the list are valid
187
			String errorMsg = checkInputElementsTypeValidation(entities);
188
			if(errorMsg != null) 
189
				return WTPCommonPlugin.createErrorStatus(errorMsg);
190
			String warningMsg = checkInputElementsTypeExistence(entities);
191
			if(warningMsg != null) 
192
				return WTPCommonPlugin.createWarningStatus(warningMsg);
193
			
173
		}
194
		}
174
		// Return OK
195
		// Return OK
175
		return WTPCommonPlugin.OK_STATUS;
196
		return WTPCommonPlugin.OK_STATUS;
176
	}
197
	}
177
	
198
	
199
	private String checkInputElementsTypeValidation(List<EntityRow> inputElements){
200
		IStatus validateFieldTypeStatus=Status.OK_STATUS;
201
		for(EntityRow entityRow: inputElements) {
202
			validateFieldTypeStatus = JavaConventions.validateFieldName(entityRow.getType(), CompilerOptions.VERSION_1_5, CompilerOptions.VERSION_1_5);
203
			if(!validateFieldTypeStatus.isOK()) {
204
				break;
205
			}
206
		}
207
		if(!validateFieldTypeStatus.isOK()){
208
			return validateFieldTypeStatus.getMessage();
209
		}
210
		return null;
211
	}
212
	
213
	private String checkInputElementsTypeExistence(List<EntityRow> inputElements){
214
		IStatus validateFieldTypeStatus=Status.OK_STATUS;
215
		for(EntityRow entityRow: inputElements) {
216
			IProject project = (IProject) getProperty(INewJavaClassDataModelProperties.PROJECT);
217
			IJavaProject javaProject = JavaCore.create(project);
218
			IType type=null;
219
			try {
220
				type = javaProject.findType(entityRow.getFqnTypeName());
221
			} catch (JavaModelException e) {
222
				validateFieldTypeStatus = e.getStatus();
223
				break;
224
			}
225
			if (type == null) {
226
				String message = MessageFormat.format(
227
						EntityWizardMsg.EntityDataModelProvider_entityNotInProjectClasspath, entityRow.getFqnTypeName());
228
				validateFieldTypeStatus = new Status(IStatus.ERROR,
229
						JptUiPlugin.PLUGIN_ID, message);
230
				break;
231
			}
232
		}
233
		if(!validateFieldTypeStatus.isOK()){
234
			return validateFieldTypeStatus.getMessage();
235
		}
236
		return null;
237
	}
238
	
239
	
178
	/**
240
	/**
179
	 * This method is intended for internal use only. It provides a simple algorithm for detecting
241
	 * This method is intended for internal use only. It provides a simple algorithm for detecting
180
	 * if there are duplicate entries in a list. It will accept a null parameter. It will return
242
	 * if there are duplicate entries in a list. It will accept a null parameter. It will return

Return to bug 250802