Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 115824 Details for
Bug 250802
Missing Restrictions when creating an Entity Field
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch
EntityCheck.patch (text/plain), 8.41 KB, created by
Georgi Dimitrov
on 2008-10-22 11:41:08 EDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Georgi Dimitrov
Created:
2008-10-22 11:41:08 EDT
Size:
8.41 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jpt.ui >Index: src/org/eclipse/jpt/ui/internal/wizards/entity/EntityWizardMsg.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/EntityWizardMsg.java,v >retrieving revision 1.2 >diff -u -r1.2 EntityWizardMsg.java >--- src/org/eclipse/jpt/ui/internal/wizards/entity/EntityWizardMsg.java 6 May 2008 15:37:46 -0000 1.2 >+++ src/org/eclipse/jpt/ui/internal/wizards/entity/EntityWizardMsg.java 22 Oct 2008 15:32:38 -0000 >@@ -54,7 +54,8 @@ > public static String BROWSE_BUTTON_LABEL; > public static String ADD_BUTTON_LABEL; > public static String EDIT_BUTTON_LABEL; >- public static String REMOVE_BUTTON_LABEL; >+ public static String EntityDataModelProvider_entityNotInProjectClasspath; >+ public static String REMOVE_BUTTON_LABEL; > public static String DUPLICATED_ENTITY_NAMES_MESSAGE; > public static String ACCESS_TYPE; > public static String FIELD_BASED; >Index: src/org/eclipse/jpt/ui/internal/wizards/entity/EntityRowTableWizardSection.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/EntityRowTableWizardSection.java,v >retrieving revision 1.4 >diff -u -r1.4 EntityRowTableWizardSection.java >--- src/org/eclipse/jpt/ui/internal/wizards/entity/EntityRowTableWizardSection.java 13 May 2008 14:26:38 -0000 1.4 >+++ src/org/eclipse/jpt/ui/internal/wizards/entity/EntityRowTableWizardSection.java 22 Oct 2008 15:32:38 -0000 >@@ -13,12 +13,16 @@ > > import java.util.ArrayList; > import java.util.Collection; >+import java.util.Iterator; > import java.util.List; > >+import org.eclipse.core.runtime.IStatus; > import org.eclipse.jdt.core.IPackageFragmentRoot; > import org.eclipse.jdt.core.IType; >+import org.eclipse.jdt.core.JavaConventions; > import org.eclipse.jdt.core.search.IJavaSearchConstants; > import org.eclipse.jdt.core.search.IJavaSearchScope; >+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > import org.eclipse.jdt.internal.ui.dialogs.FilteredTypesSelectionDialog; > import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.dialogs.IDialogConstants; >@@ -63,6 +67,8 @@ > import org.eclipse.swt.widgets.TableColumn; > import org.eclipse.swt.widgets.Text; > import org.eclipse.wst.common.frameworks.datamodel.IDataModel; >+import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard; >+import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage; > > /** > * The class presents the table with entity fields. In the java file are included also content >@@ -511,10 +517,15 @@ > * The first text field should not be empty. > */ > public boolean validate(Combo combo, Text[] texts) { >- if (texts.length > 0) { >- return texts[0].getText().trim().length() > 0; >+ if (texts.length > 0) { >+ IStatus validateFieldNameStatus = JavaConventions.validateFieldName(texts[0].getText(), CompilerOptions.VERSION_1_5, CompilerOptions.VERSION_1_5); >+ if(!validateFieldNameStatus.isOK()){ >+ return false; >+ } else { >+ return texts[0].getText().trim().length() > 0; >+ } > } >- return true; >+ return true; > } > > /** >Index: property_files/jpt_ui_entity_wizard.properties >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_entity_wizard.properties,v >retrieving revision 1.4 >diff -u -r1.4 jpt_ui_entity_wizard.properties >--- property_files/jpt_ui_entity_wizard.properties 6 May 2008 15:37:46 -0000 1.4 >+++ property_files/jpt_ui_entity_wizard.properties 22 Oct 2008 15:32:38 -0000 >@@ -42,6 +42,7 @@ > BROWSE_BUTTON_LABEL=Browse... > ADD_BUTTON_LABEL=Add... > EDIT_BUTTON_LABEL=Edit... >+EntityDataModelProvider_entityNotInProjectClasspath="{0}" is not in the project's classpath. > REMOVE_BUTTON_LABEL=Remove > DUPLICATED_ENTITY_NAMES_MESSAGE=There are duplicate names on created entity fields. Please resolve the duplication. > ACCESS_TYPE=Access Type >Index: src/org/eclipse/jpt/ui/internal/wizards/entity/data/model/EntityDataModelProvider.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/data/model/EntityDataModelProvider.java,v >retrieving revision 1.4 >diff -u -r1.4 EntityDataModelProvider.java >--- src/org/eclipse/jpt/ui/internal/wizards/entity/data/model/EntityDataModelProvider.java 5 Aug 2008 13:48:45 -0000 1.4 >+++ src/org/eclipse/jpt/ui/internal/wizards/entity/data/model/EntityDataModelProvider.java 22 Oct 2008 15:32:38 -0000 >@@ -11,14 +11,27 @@ > ***********************************************************************/ > package org.eclipse.jpt.ui.internal.wizards.entity.data.model; > >+import java.text.MessageFormat; > import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.List; > import java.util.Set; > >+import org.eclipse.core.resources.IProject; > import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.IType; > import org.eclipse.jdt.core.JavaConventions; >+import org.eclipse.jdt.core.JavaCore; >+import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; >+import org.eclipse.jem.util.emf.workbench.ProjectUtilities; >+import org.eclipse.jpt.ui.JptUiPlugin; > import org.eclipse.jpt.ui.internal.wizards.entity.EntityWizardMsg; > import org.eclipse.jpt.ui.internal.wizards.entity.data.operation.NewEntityClassOperation; > import org.eclipse.jst.j2ee.internal.common.J2EECommonMessages; >+import org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties; > import org.eclipse.jst.j2ee.internal.common.operations.NewJavaClassDataModelProvider; > import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; > import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; >@@ -170,11 +183,60 @@ > String msg = EntityWizardMsg.DUPLICATED_ENTITY_NAMES_MESSAGE; > return WTPCommonPlugin.createErrorStatus(msg); > } >+ // Ensure that the entries in the list are valid >+ String errorMsg = checkInputElementsTypeValidation(entities); >+ if(errorMsg != null) >+ return WTPCommonPlugin.createErrorStatus(errorMsg); >+ String warningMsg = checkInputElementsTypeExistence(entities); >+ if(warningMsg != null) >+ return WTPCommonPlugin.createWarningStatus(warningMsg); >+ > } > // Return OK > return WTPCommonPlugin.OK_STATUS; > } > >+ private String checkInputElementsTypeValidation(List<EntityRow> inputElements){ >+ IStatus validateFieldTypeStatus=Status.OK_STATUS; >+ for(EntityRow entityRow: inputElements) { >+ validateFieldTypeStatus = JavaConventions.validateFieldName(entityRow.getType(), CompilerOptions.VERSION_1_5, CompilerOptions.VERSION_1_5); >+ if(!validateFieldTypeStatus.isOK()) { >+ break; >+ } >+ } >+ if(!validateFieldTypeStatus.isOK()){ >+ return validateFieldTypeStatus.getMessage(); >+ } >+ return null; >+ } >+ >+ private String checkInputElementsTypeExistence(List<EntityRow> inputElements){ >+ IStatus validateFieldTypeStatus=Status.OK_STATUS; >+ for(EntityRow entityRow: inputElements) { >+ IProject project = (IProject) getProperty(INewJavaClassDataModelProperties.PROJECT); >+ IJavaProject javaProject = JavaCore.create(project); >+ IType type=null; >+ try { >+ type = javaProject.findType(entityRow.getFqnTypeName()); >+ } catch (JavaModelException e) { >+ validateFieldTypeStatus = e.getStatus(); >+ break; >+ } >+ if (type == null) { >+ String message = MessageFormat.format( >+ EntityWizardMsg.EntityDataModelProvider_entityNotInProjectClasspath, entityRow.getFqnTypeName()); >+ validateFieldTypeStatus = new Status(IStatus.ERROR, >+ JptUiPlugin.PLUGIN_ID, message); >+ break; >+ } >+ } >+ if(!validateFieldTypeStatus.isOK()){ >+ return validateFieldTypeStatus.getMessage(); >+ } >+ return null; >+ } >+ >+ > /** > * This method is intended for internal use only. It provides a simple algorithm for detecting > * if there are duplicate entries in a list. It will accept a null parameter. It will return
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 250802
:
115824
|
116268
|
116512
|
116628