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 277662 | 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 EntityDataModelProvider_entityNotInProjectClasspath;
57
	public static String EntityDataModelProvider_typeNotInProjectClasspath;
58
	public static String EntityDataModelProvider_invalidPKType;
58
	public static String EntityDataModelProvider_invalidArgument;
59
	public static String EntityDataModelProvider_invalidArgument;
59
	public static String REMOVE_BUTTON_LABEL;
60
	public static String REMOVE_BUTTON_LABEL;
60
    public static String DUPLICATED_ENTITY_NAMES_MESSAGE;
61
    public static String DUPLICATED_ENTITY_NAMES_MESSAGE;
(-)src/org/eclipse/jpt/ui/internal/wizards/entity/EntityFieldsWizardPage.java (-1 / +2 lines)
Lines 56-62 Link Here
56
	 */
56
	 */
57
	@Override
57
	@Override
58
	protected String[] getValidationPropertyNames() {
58
	protected String[] getValidationPropertyNames() {
59
		return new String[]{IEntityDataModelProperties.ENTITY_FIELDS};
59
		return new String[]{IEntityDataModelProperties.ENTITY_FIELDS, 
60
							IEntityDataModelProperties.PK_FIELDS};
60
	}
61
	}
61
	
62
	
62
	/* Create the main composite and add to it the entity properties
63
	/* Create the main composite and add to it the entity properties
(-)src/org/eclipse/jpt/ui/internal/wizards/entity/EntityRowTableWizardSection.java (-48 / +110 lines)
Lines 24-31 Link Here
24
import org.eclipse.jdt.core.JavaModelException;
24
import org.eclipse.jdt.core.JavaModelException;
25
import org.eclipse.jdt.core.search.IJavaSearchScope;
25
import org.eclipse.jdt.core.search.IJavaSearchScope;
26
import org.eclipse.jdt.core.JavaCore;
26
import org.eclipse.jdt.core.JavaCore;
27
import org.eclipse.jface.bindings.keys.KeyStroke;
28
import org.eclipse.jface.bindings.keys.ParseException;
27
import org.eclipse.jface.dialogs.Dialog;
29
import org.eclipse.jface.dialogs.Dialog;
28
import org.eclipse.jface.dialogs.IDialogConstants;
30
import org.eclipse.jface.dialogs.IDialogConstants;
31
import org.eclipse.jface.fieldassist.ContentProposalAdapter;
32
import org.eclipse.jface.fieldassist.IContentProposalProvider;
33
import org.eclipse.jface.fieldassist.SimpleContentProposalProvider;
34
import org.eclipse.jface.fieldassist.TextContentAdapter;
29
import org.eclipse.jface.viewers.CheckStateChangedEvent;
35
import org.eclipse.jface.viewers.CheckStateChangedEvent;
30
import org.eclipse.jface.viewers.CheckboxTableViewer;
36
import org.eclipse.jface.viewers.CheckboxTableViewer;
31
import org.eclipse.jface.viewers.DoubleClickEvent;
37
import org.eclipse.jface.viewers.DoubleClickEvent;
Lines 59-71 Link Here
59
import org.eclipse.swt.layout.GridData;
65
import org.eclipse.swt.layout.GridData;
60
import org.eclipse.swt.layout.GridLayout;
66
import org.eclipse.swt.layout.GridLayout;
61
import org.eclipse.swt.widgets.Button;
67
import org.eclipse.swt.widgets.Button;
62
import org.eclipse.swt.widgets.Combo;
63
import org.eclipse.swt.widgets.Composite;
68
import org.eclipse.swt.widgets.Composite;
64
import org.eclipse.swt.widgets.Control;
69
import org.eclipse.swt.widgets.Control;
65
import org.eclipse.swt.widgets.Label;
70
import org.eclipse.swt.widgets.Label;
66
import org.eclipse.swt.widgets.Shell;
71
import org.eclipse.swt.widgets.Shell;
67
import org.eclipse.swt.widgets.Table;
72
import org.eclipse.swt.widgets.Table;
68
import org.eclipse.swt.widgets.TableColumn;
73
import org.eclipse.swt.widgets.TableColumn;
74
import org.eclipse.swt.widgets.TableItem;
69
import org.eclipse.swt.widgets.Text;
75
import org.eclipse.swt.widgets.Text;
70
import org.eclipse.ui.dialogs.SelectionDialog;
76
import org.eclipse.ui.dialogs.SelectionDialog;
71
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
77
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
Lines 81-93 Link Here
81
	/**
87
	/**
82
	 * The possible entity types, mentioned in the specification (Chapter 2.1.1 Persistent Fields and Properties p.20)
88
	 * The possible entity types, mentioned in the specification (Chapter 2.1.1 Persistent Fields and Properties p.20)
83
	 */
89
	 */
84
	protected final static String[] VALID_TYPES = {"int", "long", "short", "char", "boolean", "byte", "double", "float", "java.lang.String",
90
	protected final static String[] VALID_TYPES = {"int", 
85
		"byte[]", "char[]",	"java.lang.Byte[]", "java.lang.Character[]", "java.math.BigDecimal", "java.math.BigInteger", "java.sql.Date", "java.sql.Time", "java.sql.Timestamp",
91
												   "long", 
86
		"java.util.Date", "java.util.Calendar"};
92
												   "short", 
93
												   "char", 
94
												   "boolean", 
95
												   "byte", 
96
												   "double", 
97
												   "float", 
98
												   "java.lang.String", 
99
												   "java.lang.Integer", 
100
												   "java.lang.Long", 
101
												   "java.lang.Short",
102
												   "java.lang.Character", 
103
												   "java.lang.Boolean", 
104
												   "java.lang.Byte", 
105
												   "java.lang.Double", 
106
												   "java.lang.Float", 
107
												   "java.math.BigDecimal", 
108
												   "java.math.BigInteger", 
109
												   "java.util.Date", 
110
												   "java.util.Calendar",
111
												   "java.sql.Date", 
112
												   "java.sql.Time", 
113
												   "java.sql.Timestamp",
114
												   "String", 
115
												   "Integer", 
116
												   "Long", 
117
												   "Short",
118
												   "Character", 
119
												   "Boolean", 
120
												   "Byte", 
121
												   "Double", 
122
												   "Float" };	
87
	
123
	
88
	  private CheckboxTableViewer mTableViewer = null;
124
	  private CheckboxTableViewer mTableViewer = null;
89
	  private Table mTableWidget = null;
125
	  private Table mTableWidget = null;
90
	  private final int PK_COLUMN = 0;
91
	  private final int NAME_COLUMN = 1;
126
	  private final int NAME_COLUMN = 1;
92
	  private final int TYPE_COLUMN = 2;
127
	  private final int TYPE_COLUMN = 2;
93
	
128
	
Lines 98-109 Link Here
98
	private Button editButton;
133
	private Button editButton;
99
	private Button removeButton;
134
	private Button removeButton;
100
	private String title = EntityWizardMsg.ENTITY_FIELDS_DIALOG_TITLE;
135
	private String title = EntityWizardMsg.ENTITY_FIELDS_DIALOG_TITLE;
101
	private String[] labelsForCombo = VALID_TYPES;
136
	private String[] typeProposals = VALID_TYPES;
102
	private String[] labelsForText = new String[]{EntityWizardMsg.TYPE_TEXT_FIELD, EntityWizardMsg.NAME_TEXT_FIELD};
137
	private String[] labelsForText = new String[]{EntityWizardMsg.TYPE_TEXT_FIELD, EntityWizardMsg.NAME_TEXT_FIELD};
103
	private IDataModel model;
138
	private IDataModel model;
104
	private String propertyName;
139
	private String propertyName;
105
	private Image labelProviderImage = null;
140
	private Image labelProviderImage = null;
106
	private DialogCallback callback;	
141
	private DialogCallback callback;	
142
	private static KeyStroke ks = null;
143
	static {
144
		try {
145
			ks = KeyStroke.getInstance("Ctrl+Space");			
146
		} catch (ParseException e1) {
147
			JptUiPlugin.log(e1);
148
		} 
149
	}
107
150
108
151
109
	/**
152
	/**
Lines 261-276 Link Here
261
	 * add new entity field
304
	 * add new entity field
262
	 */
305
	 */
263
	private void handleAddButtonSelected() {
306
	private void handleAddButtonSelected() {
264
		AddFieldDialog dialog = new AddFieldDialog(getShell(), title, labelsForCombo, labelsForText);
307
		AddFieldDialog dialog = new AddFieldDialog(getShell(), title, typeProposals, labelsForText);
265
		int result = dialog.open();
308
		int result = dialog.open();
266
		if (result == Window.CANCEL) {
309
		if (result == Window.CANCEL) {
267
			return;
310
			return;
268
		}
311
		}
269
		EntityRow entityRow = dialog.getEntityRow();
312
		EntityRow entityRow = dialog.getEntityRow();
270
		addEntityRow(entityRow);
313
		addEntityRow(entityRow);
314
		/*
271
		if (!entityRow.couldBeKey()) {
315
		if (!entityRow.couldBeKey()) {
272
			mTableViewer.setGrayed(entityRow, true);
316
			mTableViewer.setGrayed(entityRow, true);
273
		}		
317
		}
318
		*/		
274
	}
319
	}
275
	
320
	
276
	/**
321
	/**
Lines 305-322 Link Here
305
		int index = mTableWidget.getSelectionIndex();
350
		int index = mTableWidget.getSelectionIndex();
306
		boolean isChecked = mTableViewer.getChecked(entityForEdit);
351
		boolean isChecked = mTableViewer.getChecked(entityForEdit);
307
		
352
		
308
		EditFieldDialog dialog = new EditFieldDialog(getShell(), title, labelsForCombo, labelsForText, entityForEdit);
353
		EditFieldDialog dialog = new EditFieldDialog(getShell(), title, typeProposals, labelsForText, entityForEdit);
309
		dialog.open();
354
		dialog.open();
310
		EntityRow entityRow = dialog.getEntityRow();
355
		EntityRow entityRow = dialog.getEntityRow();
311
		if (entityRow != null) {			
356
		if (entityRow != null) {			
312
			editEntityRow(index, entityRow);
357
			editEntityRow(index, entityRow);
313
			mTableViewer.setChecked(entityRow, isChecked);
358
			mTableViewer.setChecked(entityRow, isChecked);
314
			if (!entityRow.couldBeKey()) {
359
//			if (!entityRow.couldBeKey()) {
315
				mTableViewer.setChecked(entityRow, false);
360
//				mTableViewer.setChecked(entityRow, false);
316
				mTableViewer.setGrayed(entityRow, true);
361
//				mTableViewer.setGrayed(entityRow, true);
317
			} else {				
362
//			} else {				
318
				mTableViewer.setGrayed(entityRow, false);
363
				mTableViewer.setGrayed(entityRow, false);
319
			}
364
//			}
320
		}
365
		}
321
	}
366
	}
322
	
367
	
Lines 425-433 Link Here
425
			if (columnIndex == TYPE_COLUMN) {
470
			if (columnIndex == TYPE_COLUMN) {
426
				return entity.getFqnTypeName();
471
				return entity.getFqnTypeName();
427
			}		
472
			}		
428
			if (entity.couldBeKey()) {
473
//			if (entity.couldBeKey()) {
429
				mTableViewer.setChecked(entity, entity.isKey());
474
				mTableViewer.setChecked(entity, entity.isKey());
430
			} 
475
//			} 
431
			return "";
476
			return "";
432
		}
477
		}
433
478
Lines 454-470 Link Here
454
	private class PKFieldCheckStateListener implements ICheckStateListener {
499
	private class PKFieldCheckStateListener implements ICheckStateListener {
455
500
456
		public void checkStateChanged(CheckStateChangedEvent event) {
501
		public void checkStateChanged(CheckStateChangedEvent event) {
457
			Object[] checkedElements = mTableViewer.getCheckedElements();
458
			List<String> pkFields = new ArrayList<String>();
502
			List<String> pkFields = new ArrayList<String>();
459
			for (Object object : checkedElements) {
503
	        TableItem[] children = mTableViewer.getTable().getItems();
460
				EntityRow entity = (EntityRow)object;
504
	        for (int i = 0; i < children.length; i++) {
461
				if (entity.couldBeKey()) {					
505
	            TableItem item = children[i];
462
					pkFields.add(entity.getName());
506
	            EntityRow entityRow = (EntityRow)item.getData(); 
463
				} else {
507
	            entityRow.setKey(item.getChecked());
464
					mTableViewer.setChecked(entity, false);
508
				if (item.getChecked())
465
				}
509
					pkFields.add(entityRow.getName());
466
			}			
510
	        }
467
			model.setProperty(IEntityDataModelProperties.PK_FIELDS, pkFields);			
511
	        model.setProperty(IEntityDataModelProperties.PK_FIELDS, pkFields);
468
		}
512
		}
469
		
513
		
470
	}
514
	}
Lines 485-491 Link Here
485
		 * @return <code>true</code> if the values in the text fields are 
529
		 * @return <code>true</code> if the values in the text fields are 
486
		 *         valid, <code>false</code> otherwise.	 
530
		 *         valid, <code>false</code> otherwise.	 
487
		 */
531
		 */
488
		public boolean validate(Combo combo, Text[] texts);
532
		public boolean validate(Text type, Text[] texts);
489
		
533
		
490
		/**
534
		/**
491
		 * Retrieves the entity presentation object from the fields of the dialog. 
535
		 * Retrieves the entity presentation object from the fields of the dialog. 
Lines 497-503 Link Here
497
		 * @param texts	the name of the entity field	
541
		 * @param texts	the name of the entity field	
498
		 * @return the entity presentation object retrieved from the dialog
542
		 * @return the entity presentation object retrieved from the dialog
499
		 */
543
		 */
500
		public EntityRow retrieveResultStrings(Combo combo, Text[] texts);
544
		public EntityRow retrieveResultStrings(Text type, Text[] texts);
501
		
545
		
502
	}
546
	}
503
	
547
	
Lines 510-516 Link Here
510
		/**
554
		/**
511
		 * The first text field should not be empty. 
555
		 * The first text field should not be empty. 
512
		 */
556
		 */
513
		public boolean validate(Combo combo, Text[] texts) {
557
		public boolean validate(Text type, Text[] texts) {
514
			if (texts.length > 0) {
558
			if (texts.length > 0) {
515
				IStatus validateFieldNameStatus = JavaConventions
559
				IStatus validateFieldNameStatus = JavaConventions
516
						.validateFieldName(texts[0].getText(),
560
						.validateFieldName(texts[0].getText(),
Lines 520-526 Link Here
520
					return false;
564
					return false;
521
				}
565
				}
522
			}
566
			}
523
			if (combo.getText().equals("")) {
567
			if (type.getText().equals("")) {
524
				return false;
568
				return false;
525
			}
569
			}
526
			return true;
570
			return true;
Lines 531-539 Link Here
531
		 * entity field presentation
575
		 * entity field presentation
532
		 * @see org.eclipse.jpt.ui.internal.wizards.entity.data.model.EntityRow
576
		 * @see org.eclipse.jpt.ui.internal.wizards.entity.data.model.EntityRow
533
		 */
577
		 */
534
		public EntityRow retrieveResultStrings(Combo combo, Text[] texts) {
578
		public EntityRow retrieveResultStrings(Text type, Text[] texts) {
535
			EntityRow entity = new EntityRow();			
579
			EntityRow entity = new EntityRow();			
536
			entity.setFqnTypeName(combo.getText());
580
			entity.setFqnTypeName(type.getText());
537
			entity.setName(texts[0].getText());
581
			entity.setName(texts[0].getText());
538
			return entity;
582
			return entity;
539
		}
583
		}
Lines 546-568 Link Here
546
	 */
590
	 */
547
	private class AddFieldDialog extends Dialog implements ModifyListener, SelectionListener {
591
	private class AddFieldDialog extends Dialog implements ModifyListener, SelectionListener {
548
		protected String windowTitle;
592
		protected String windowTitle;
549
		protected String[] labelsForCombo;
593
		protected String[] typeProposals;
550
		protected String[] labelsForText;
594
		protected String[] labelsForText;
551
		protected Text[] texts;		
595
		protected Text[] texts;		
552
		protected EntityRow entityRow;
596
		protected EntityRow entityRow;
553
		protected Combo combo;
597
		protected Text attributeType;
598
		protected ContentProposalAdapter contentProposalAdapter; 		
554
		
599
		
555
		/**
600
		/**
556
		 * Constructs AddFieldDialog
601
		 * Constructs AddFieldDialog
557
		 * @param shell
602
		 * @param shell
558
		 * @param windowTitle dialog label
603
		 * @param windowTitle dialog label
559
		 * @param labelsForCombo the elements for the combo
604
		 * @param typeProposals the elements for the combo
560
		 * @param labelsForText name text
605
		 * @param labelsForText name text
561
		 */
606
		 */
562
		public AddFieldDialog(Shell shell, String windowTitle, String[] labelsForCombo, String[] labelsForText) {
607
		public AddFieldDialog(Shell shell, String windowTitle, String[] typeProposals, String[] labelsForText) {
563
			super(shell);
608
			super(shell);
564
			this.windowTitle = windowTitle;
609
			this.windowTitle = windowTitle;
565
			this.labelsForCombo = labelsForCombo;
610
			this.typeProposals = typeProposals;
566
			this.labelsForText  = labelsForText;
611
			this.labelsForText  = labelsForText;
567
		}
612
		}
568
		
613
		
Lines 589-599 Link Here
589
			label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
634
			label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
590
			
635
			
591
			
636
			
592
			combo = new Combo(composite, SWT.SINGLE | SWT.BORDER);// | SWT.READ_ONLY);		
637
			attributeType = new Text(composite, SWT.SINGLE | SWT.BORDER);// | SWT.READ_ONLY);		
593
			combo.setItems(labelsForCombo);
638
			//combo.setItems(labelsForCombo);
594
			data = new GridData(GridData.FILL_HORIZONTAL);
639
			data = new GridData(GridData.FILL_HORIZONTAL);
595
			data.horizontalSpan = 2;			
640
			data.horizontalSpan = 2;			
596
			combo.setLayoutData(data);
641
			attributeType.setLayoutData(data);
597
			
642
			
598
			Button browseButton = new Button(composite, SWT.PUSH);
643
			Button browseButton = new Button(composite, SWT.PUSH);
599
			browseButton.setText(EntityWizardMsg.BROWSE_BUTTON_LABEL);
644
			browseButton.setText(EntityWizardMsg.BROWSE_BUTTON_LABEL);
Lines 618-631 Link Here
618
				labelI.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
663
				labelI.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
619
				texts[i-1] = new Text(composite, SWT.SINGLE | SWT.BORDER);
664
				texts[i-1] = new Text(composite, SWT.SINGLE | SWT.BORDER);
620
				data = new GridData(GridData.FILL_HORIZONTAL);
665
				data = new GridData(GridData.FILL_HORIZONTAL);
621
				data.widthHint = 100;
666
				data.horizontalSpan = 2;		
622
				texts[i-1].setLayoutData(data);
667
				texts[i-1].setLayoutData(data);
623
			}
668
			}
624
669
625
			combo.setFocus();
670
			attributeType.setFocus();
626
			Dialog.applyDialogFont(parent);
671
			Dialog.applyDialogFont(parent);
672
			createContentProposalProvider();			
627
			return composite;
673
			return composite;
628
		}
674
		}
675
		
676
		private IContentProposalProvider createContentProposalProvider() {
677
			SimpleContentProposalProvider contProvider = new SimpleContentProposalProvider(typeProposals);
678
			contProvider.setFiltering(true);
679
			
680
			contentProposalAdapter = new ContentProposalAdapter(
681
					attributeType,
682
					new TextContentAdapter(), 
683
					contProvider,
684
					ks,
685
					new char[] {'b', 'c', 'd', 'i', 'f', 'l', 's', 'j', 'B', 'C', 'D', 'F', 'S', 'L', 'I'});
686
			contentProposalAdapter.setEnabled(true);
687
			contentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
688
			return contProvider;
689
		}
690
		
629
691
630
		/**
692
		/**
631
		 * Process browsing when the Browse... button have been pressed. Allow adding of entity field
693
		 * Process browsing when the Browse... button have been pressed. Allow adding of entity field
Lines 670-676 Link Here
670
				if (type != null) {
732
				if (type != null) {
671
					superclassFullPath = type.getFullyQualifiedName();
733
					superclassFullPath = type.getFullyQualifiedName();
672
				}
734
				}
673
				combo.setText(superclassFullPath);
735
				attributeType.setText(superclassFullPath);
674
				//getControl().setCursor(null);
736
				//getControl().setCursor(null);
675
				return;
737
				return;
676
			}
738
			}
Lines 685-692 Link Here
685
		protected Control createContents(Composite parent) {
747
		protected Control createContents(Composite parent) {
686
			Composite composite = (Composite) super.createContents(parent);
748
			Composite composite = (Composite) super.createContents(parent);
687
			
749
			
688
			combo.addSelectionListener(this);
750
			attributeType.addSelectionListener(this);
689
			combo.addModifyListener(this);
751
			attributeType.addModifyListener(this);
690
			for (int i = 0; i < texts.length; i++) {
752
			for (int i = 0; i < texts.length; i++) {
691
				texts[i].addModifyListener(this);
753
				texts[i].addModifyListener(this);
692
			}
754
			}
Lines 701-707 Link Here
701
		 */
763
		 */
702
		@Override
764
		@Override
703
		protected void okPressed() {
765
		protected void okPressed() {
704
			entityRow = callback.retrieveResultStrings(combo, texts);
766
			entityRow = callback.retrieveResultStrings(attributeType, texts);
705
			super.okPressed();
767
			super.okPressed();
706
		}
768
		}
707
769
Lines 724-730 Link Here
724
		 * @see DialogCallback
786
		 * @see DialogCallback
725
		 */
787
		 */
726
		private void updateOKButton() {
788
		private void updateOKButton() {
727
			getButton(IDialogConstants.OK_ID).setEnabled(callback.validate(combo, texts));
789
			getButton(IDialogConstants.OK_ID).setEnabled(callback.validate(attributeType, texts));
728
		}
790
		}
729
		/* (non-Javadoc)
791
		/* (non-Javadoc)
730
		 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
792
		 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
Lines 762-768 Link Here
762
824
763
			Composite composite = (Composite) super.createDialogArea(parent);
825
			Composite composite = (Composite) super.createDialogArea(parent);
764
826
765
			combo.setText(entityRow.getFqnTypeName());
827
			attributeType.setText(entityRow.getFqnTypeName());
766
			texts[0].setText(entityRow.getName());
828
			texts[0].setText(entityRow.getName());
767
			
829
			
768
			return composite;
830
			return composite;
(-)src/org/eclipse/jpt/ui/internal/wizards/entity/data/model/EntityRow.java (-52 / +28 lines)
Lines 17-64 Link Here
17
public class EntityRow {
17
public class EntityRow {
18
18
19
	private static final String DOT = ".";
19
	private static final String DOT = ".";
20
	private static final String PACKAGE_JAVA_LANG = "java.lang.";
20
	private boolean key = false;
21
	private boolean key = false;
21
	private String name = "";
22
	private String name = "";
22
	private String type = "";
23
	private String type = "";
23
	private String fqnTypeName = "";
24
	private String fqnTypeName = "";
24
	private boolean isSimpleType = false;
25
25
26
	private final static String[] PK_TYPES = {"int", "long", "short", "char", "boolean", "byte", "double", "float", 
26
	private final static String[] PK_TYPES = {"int", "long", "short", "char", "boolean", "byte", "double", "float", 
27
		"java.lang.String", "java.sql.Date", "java.util.Date", "java.lang.Integer", "java.lang.Long", "java.lang.Short",
27
		"java.lang.String", "java.sql.Date", "java.util.Date", "java.lang.Integer", "java.lang.Long", "java.lang.Short",
28
		"java.lang.Character", "java.lang.Boolean", "java.lang.Byte", "java.lang.Double", "java.lang.Float"};
28
		"java.lang.Character", "java.lang.Boolean", "java.lang.Byte", "java.lang.Double", "java.lang.Float"};
29
	
29
	
30
	private final static List<String> VALID_PK_TYPES = Arrays.asList(PK_TYPES);
30
	private final static String[] PK_TYPES_SHORT = { "String", "Integer", "Long", "Short", "Character", "Boolean", 
31
	
31
		 "Byte", "Double", "Float" };
32
	
33
	/**
34
	 * Constructs <code>EntityColumn</code>.
35
	 */
36
	public EntityRow() {
37
		super();
38
	}
39
32
40
	
33
	private final static List<String> VALID_PK_TYPES = Arrays.asList(PK_TYPES);
41
	/**
34
	private final static List<String> VALID_PK_TYPES_SHORT = Arrays.asList(PK_TYPES_SHORT);
42
	 * 
43
	 * Constructs <code>EntityColumn</code> with the following parameters
44
	 * 
45
	 * @param fqnTypeName - fully qualified name of the entity field type
46
	 * @param name - name of the entity field
47
	 * @param isKey - flag which indicates whether the entity field is primary key or part of composite primary key
48
	 */
49
	public EntityRow(String fqnTypeName, String name, boolean isKey) {
50
		super();
51
		this.fqnTypeName = type;
52
		this.name = name;
53
		this.key = isKey;
54
		if (fqnTypeName.indexOf(DOT) == -1) {
55
			type = fqnTypeName;
56
			isSimpleType = true;
57
		} else {
58
			type = getSimpleName(fqnTypeName);
59
		}
60
	}
61
	
62
	
35
	
63
	/**
36
	/**
64
	 * @return whether the presented entity field is primary key or part of composite primary key
37
	 * @return whether the presented entity field is primary key or part of composite primary key
Lines 131-140 Link Here
131
	 * @param fqnTypeName
104
	 * @param fqnTypeName
132
	 */
105
	 */
133
	public void setFqnTypeName(String fqnTypeName) {
106
	public void setFqnTypeName(String fqnTypeName) {
134
		this.fqnTypeName = fqnTypeName;
107
		fqnTypeName = fqnTypeName.trim();
135
		if (fqnTypeName.indexOf(DOT) == -1) {
108
		StringBuffer fqn = new StringBuffer();
136
			setType(fqnTypeName);
109
		StringBuffer fqnBasic = new StringBuffer();
137
			setSimpleType(true);
110
		boolean basicOver = false;
111
		for (int i = 0; i < fqnTypeName.length(); i++) {
112
			char c = fqnTypeName.charAt(i);
113
			if (!Character.isWhitespace(c)) {
114
				fqn.append(c);
115
				if ((c == '[') || (c == '<')) 
116
					basicOver = true;
117
				if (!basicOver)
118
					fqnBasic.append(c);
119
			} 
120
		}
121
		fqnTypeName = fqn.toString();
122
		String fqnBasicTypeName = fqnBasic.toString();
123
		if (fqnBasicTypeName.indexOf(DOT) == -1) {
124
			if (VALID_PK_TYPES_SHORT.contains(fqnBasicTypeName)) {
125
				this.fqnTypeName = PACKAGE_JAVA_LANG + fqnTypeName;
126
				setType(fqnTypeName);
127
			} else {
128
				setType(fqnTypeName);
129
			}			
138
		} else {
130
		} else {
139
			setType(getSimpleName(fqnTypeName));
131
			setType(getSimpleName(fqnTypeName));
140
		}
132
		}
Lines 142-163 Link Here
142
	}
134
	}
143
135
144
	/**
136
	/**
145
	 * @return is the type of the entity field is primitive type
146
	 */
147
	public boolean isSimpleType() {
148
		return isSimpleType;
149
	}
150
151
	/**
152
	 * Sets the flag which indicate the type of the entity field as primitive type
153
	 * 
154
	 * @param isSimpleType
155
	 */
156
	public void setSimpleType(boolean isSimpleType) {
157
		this.isSimpleType = isSimpleType;
158
	}
159
160
	/**
161
	 * @return whether the type of the entity field is boolean. The information could be used 
137
	 * @return whether the type of the entity field is boolean. The information could be used 
162
	 * when the name of getter should be constructed
138
	 * when the name of getter should be constructed
163
	 */
139
	 */
(-)src/org/eclipse/jpt/ui/internal/wizards/entity/data/model/EntityDataModelProvider.java (-5 / +11 lines)
Lines 140-146 Link Here
140
		if (propertyName.equals(XML_NAME)) {
140
		if (propertyName.equals(XML_NAME)) {
141
			return validateXmlName(getStringProperty(propertyName));
141
			return validateXmlName(getStringProperty(propertyName));
142
		}
142
		}
143
		if (propertyName.equals(ENTITY_FIELDS)) {
143
		if (propertyName.equals(ENTITY_FIELDS) || propertyName.equals(ENTITY_FIELDS)) {
144
			return validateFieldsList((ArrayList<EntityRow>) getProperty(propertyName));
144
			return validateFieldsList((ArrayList<EntityRow>) getProperty(propertyName));
145
		}
145
		}
146
		return result;		
146
		return result;		
Lines 266-276 Link Here
266
	private String checkInputElementsTypeExistence(List<EntityRow> inputElements) {
266
	private String checkInputElementsTypeExistence(List<EntityRow> inputElements) {
267
		IStatus validateFieldTypeStatus=Status.OK_STATUS;
267
		IStatus validateFieldTypeStatus=Status.OK_STATUS;
268
		for (EntityRow entityRow: inputElements) {
268
		for (EntityRow entityRow: inputElements) {
269
			
269
			if (entityRow.isKey() && !entityRow.couldBeKey()) {
270
				String message = MessageFormat.format(
271
						EntityWizardMsg.EntityDataModelProvider_invalidPKType, new Object[]{entityRow.getFqnTypeName()});
272
				validateFieldTypeStatus = new Status(IStatus.ERROR,
273
						JptUiPlugin.PLUGIN_ID, message);
274
				break;				
275
			}
270
			String sig = Signature.createTypeSignature(entityRow.getFqnTypeName() ,true);
276
			String sig = Signature.createTypeSignature(entityRow.getFqnTypeName() ,true);
271
			if (sig == null) {
277
			if (sig == null) {
272
				String message = MessageFormat.format(
278
				String message = MessageFormat.format(
273
						EntityWizardMsg.EntityDataModelProvider_entityNotInProjectClasspath, new Object[]{entityRow.getFqnTypeName()});
279
						EntityWizardMsg.EntityDataModelProvider_typeNotInProjectClasspath, new Object[]{entityRow.getFqnTypeName()});
274
				validateFieldTypeStatus = new Status(IStatus.ERROR,
280
				validateFieldTypeStatus = new Status(IStatus.ERROR,
275
						JptUiPlugin.PLUGIN_ID, message);
281
						JptUiPlugin.PLUGIN_ID, message);
276
				break;
282
				break;
Lines 296-302 Link Here
296
				}
302
				}
297
				if (type == null) {
303
				if (type == null) {
298
					String message = MessageFormat.format(
304
					String message = MessageFormat.format(
299
							EntityWizardMsg.EntityDataModelProvider_entityNotInProjectClasspath, new Object[]{entityRow.getFqnTypeName()});
305
							EntityWizardMsg.EntityDataModelProvider_typeNotInProjectClasspath, new Object[]{entityRow.getFqnTypeName()});
300
					validateFieldTypeStatus = new Status(IStatus.ERROR,
306
					validateFieldTypeStatus = new Status(IStatus.ERROR,
301
							JptUiPlugin.PLUGIN_ID, message);
307
							JptUiPlugin.PLUGIN_ID, message);
302
					break;
308
					break;
Lines 314-320 Link Here
314
				}
320
				}
315
				if (type == null) {
321
				if (type == null) {
316
					String message = MessageFormat.format(
322
					String message = MessageFormat.format(
317
							EntityWizardMsg.EntityDataModelProvider_entityNotInProjectClasspath, new Object[]{entityRow.getFqnTypeName()});
323
							EntityWizardMsg.EntityDataModelProvider_typeNotInProjectClasspath, new Object[]{entityRow.getFqnTypeName()});
318
					validateFieldTypeStatus = new Status(IStatus.ERROR,
324
					validateFieldTypeStatus = new Status(IStatus.ERROR,
319
							JptUiPlugin.PLUGIN_ID, message);
325
							JptUiPlugin.PLUGIN_ID, message);
320
					break;
326
					break;
(-)property_files/jpt_ui_entity_wizard.properties (-1 / +2 lines)
Lines 52-56 Link Here
52
APPLY_CHANGES_TO_PERSISTENCE_XML=Apply changes to persistence XML
52
APPLY_CHANGES_TO_PERSISTENCE_XML=Apply changes to persistence XML
53
ADD_MAPPED_SUPERCLASS_TO_XML=Add mapped superclass to XML
53
ADD_MAPPED_SUPERCLASS_TO_XML=Add mapped superclass to XML
54
ADD_ENTITY_TO_XML=Add entity to XML
54
ADD_ENTITY_TO_XML=Add entity to XML
55
EntityDataModelProvider_entityNotInProjectClasspath=''{0}'' does not exist on the project classpath
55
EntityDataModelProvider_typeNotInProjectClasspath=''{0}'' does not exist on the project classpath
56
EntityDataModelProvider_invalidPKType=''{0}'' is not a valid primary key type
56
EntityDataModelProvider_invalidArgument=Invalid argument ''{0}''
57
EntityDataModelProvider_invalidArgument=Invalid argument ''{0}''

Return to bug 277662