|
Lines 36-41
Link Here
|
| 36 |
import org.eclipse.jpt.ui.diagrameditor.internal.i18n.JPAEditorMessages; |
36 |
import org.eclipse.jpt.ui.diagrameditor.internal.i18n.JPAEditorMessages; |
| 37 |
import org.eclipse.jpt.ui.diagrameditor.internal.preferences.JPAEditorPreferenceInitializer; |
37 |
import org.eclipse.jpt.ui.diagrameditor.internal.preferences.JPAEditorPreferenceInitializer; |
| 38 |
import org.eclipse.jpt.ui.diagrameditor.internal.preferences.JPAEditorPreferencesPage; |
38 |
import org.eclipse.jpt.ui.diagrameditor.internal.preferences.JPAEditorPreferencesPage; |
|
|
39 |
import org.eclipse.jpt.ui.diagrameditor.internal.util.JPAEditorUtil; |
| 39 |
import org.eclipse.swt.SWT; |
40 |
import org.eclipse.swt.SWT; |
| 40 |
import org.eclipse.swt.events.ModifyEvent; |
41 |
import org.eclipse.swt.events.ModifyEvent; |
| 41 |
import org.eclipse.swt.events.ModifyListener; |
42 |
import org.eclipse.swt.events.ModifyListener; |
|
Lines 55-60
Link Here
|
| 55 |
public class JPADiagramPropertyPage extends PropertyPage { |
56 |
public class JPADiagramPropertyPage extends PropertyPage { |
| 56 |
|
57 |
|
| 57 |
public static final String PROJECT_SETTINGS_PATH = "/.settings/org.eclipse.jpt.ui.diagrameditor"; //$NON-NLS-1$; |
58 |
public static final String PROJECT_SETTINGS_PATH = "/.settings/org.eclipse.jpt.ui.diagrameditor"; //$NON-NLS-1$; |
|
|
59 |
protected IProject project = null; |
| 60 |
protected boolean isJPA10Project = false; //$NON-NLS-1$; |
| 61 |
|
| 58 |
private Properties editorProps; |
62 |
private Properties editorProps; |
| 59 |
|
63 |
|
| 60 |
private Text txtDefaultFolderField; |
64 |
private Text txtDefaultFolderField; |
|
Lines 68-73
Link Here
|
| 68 |
private Button btnCollectionType; |
72 |
private Button btnCollectionType; |
| 69 |
private Button btnListType; |
73 |
private Button btnListType; |
| 70 |
private Button btnSetType; |
74 |
private Button btnSetType; |
|
|
75 |
private Button checkOneToManyOldStyle; |
| 71 |
|
76 |
|
| 72 |
private boolean propsModified = false; |
77 |
private boolean propsModified = false; |
| 73 |
|
78 |
|
|
Lines 77-83
Link Here
|
| 77 |
static public final QualifiedName PROP_DEFAULT_TABLE_NAME_PREFIX = new QualifiedName(QUALIFIER, "defaultTableNamePrefix"); //$NON-NLS-1$; |
82 |
static public final QualifiedName PROP_DEFAULT_TABLE_NAME_PREFIX = new QualifiedName(QUALIFIER, "defaultTableNamePrefix"); //$NON-NLS-1$; |
| 78 |
static public final QualifiedName PROP_DIRECT_EDIT_AFFECTS_CLASS = new QualifiedName(QUALIFIER, "directEditAffectsClass"); //$NON-NLS-1$; |
83 |
static public final QualifiedName PROP_DIRECT_EDIT_AFFECTS_CLASS = new QualifiedName(QUALIFIER, "directEditAffectsClass"); //$NON-NLS-1$; |
| 79 |
static public final QualifiedName PROP_ACCESS_TYPE = new QualifiedName(QUALIFIER, "accessType"); //$NON-NLS-1$; |
84 |
static public final QualifiedName PROP_ACCESS_TYPE = new QualifiedName(QUALIFIER, "accessType"); //$NON-NLS-1$; |
| 80 |
static public final QualifiedName PROP_COLLECTION_TYPE = new QualifiedName(QUALIFIER, "collectionType"); //$NON-NLS-1$; |
85 |
static public final QualifiedName PROP_COLLECTION_TYPE = new QualifiedName(QUALIFIER, "collectionType"); //$NON-NLS-1$; |
|
|
86 |
static public final QualifiedName PROP_ONE_TO_MANY_OLD_STYLE = new QualifiedName(QUALIFIER, "oneToManyOldStyle"); //$NON-NLS-1$; |
| 87 |
|
| 81 |
|
88 |
|
| 82 |
public static final String COLLECTION_TYPE = "java.util.Collection"; //$NON-NLS-1$ |
89 |
public static final String COLLECTION_TYPE = "java.util.Collection"; //$NON-NLS-1$ |
| 83 |
public static final String LIST_TYPE = "java.util.List"; //$NON-NLS-1$ |
90 |
public static final String LIST_TYPE = "java.util.List"; //$NON-NLS-1$ |
|
Lines 89-94
Link Here
|
| 89 |
@Override |
96 |
@Override |
| 90 |
protected Control createContents(Composite parent) { |
97 |
protected Control createContents(Composite parent) { |
| 91 |
final Composite composite = createCompositeContainer(parent); |
98 |
final Composite composite = createCompositeContainer(parent); |
|
|
99 |
project = (IProject)getElement().getAdapter(IProject.class); |
| 100 |
isJPA10Project = JPAEditorUtil.checkJPAFacetVersion(project, "1.0"); //$NON-NLS-1$; |
| 92 |
loadProperties(); |
101 |
loadProperties(); |
| 93 |
createDefaultFolderControl(composite); |
102 |
createDefaultFolderControl(composite); |
| 94 |
createDefaultPackageControl(composite); |
103 |
createDefaultPackageControl(composite); |
|
Lines 96-101
Link Here
|
| 96 |
createDirectEditAffectsClassControl(composite); |
105 |
createDirectEditAffectsClassControl(composite); |
| 97 |
createAccessTypeControl(composite); |
106 |
createAccessTypeControl(composite); |
| 98 |
createDefaultCollectionTypeControl(composite); |
107 |
createDefaultCollectionTypeControl(composite); |
|
|
108 |
if (!isJPA10Project) |
| 109 |
createOneToManyOldStyleControl(composite); |
| 99 |
Dialog.applyDialogFont(composite); |
110 |
Dialog.applyDialogFont(composite); |
| 100 |
validatePage(); |
111 |
validatePage(); |
| 101 |
return composite; |
112 |
return composite; |
|
Lines 196-201
Link Here
|
| 196 |
}); |
207 |
}); |
| 197 |
} |
208 |
} |
| 198 |
|
209 |
|
|
|
210 |
private void createOneToManyOldStyleControl(Composite composite) { |
| 211 |
checkOneToManyOldStyle = new Button(composite, SWT.FLAT | SWT.CHECK); |
| 212 |
checkOneToManyOldStyle.setText(JPAEditorMessages.JPAEditorPropertyPage_oneToManyOldStyle); |
| 213 |
checkOneToManyOldStyle.setToolTipText(JPAEditorMessages.JPAEditorPropertyPage_oneToManyOldStyleTooltip); |
| 214 |
checkOneToManyOldStyle.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 2, 1)); |
| 215 |
|
| 216 |
boolean defaultDirectEditAffectsClass = Boolean.parseBoolean(editorProps.getProperty(PROP_ONE_TO_MANY_OLD_STYLE.getLocalName())); |
| 217 |
checkOneToManyOldStyle.setSelection(defaultDirectEditAffectsClass); |
| 218 |
checkOneToManyOldStyle.addSelectionListener(new SelectionListener() { |
| 219 |
public void widgetSelected(SelectionEvent e) { |
| 220 |
propsModified = true; |
| 221 |
} |
| 222 |
public void widgetDefaultSelected(SelectionEvent e) {} |
| 223 |
}); |
| 224 |
} |
| 225 |
|
| 226 |
|
| 227 |
|
| 199 |
private void createDefaultCollectionTypeControl(Composite composite) { |
228 |
private void createDefaultCollectionTypeControl(Composite composite) { |
| 200 |
groupCollectionType = new Group(composite, 0); |
229 |
groupCollectionType = new Group(composite, 0); |
| 201 |
groupCollectionType.setText(JPAEditorMessages.JPAEditorPreferencesPage_DefaultCollectionTypeSectionTittle); |
230 |
groupCollectionType.setText(JPAEditorMessages.JPAEditorPreferencesPage_DefaultCollectionTypeSectionTittle); |
|
Lines 321-332
Link Here
|
| 321 |
String defaultCollectionType = store.getString(JPAEditorPreferenceInitializer.PROPERTY_DEFAULT_COLLECTION_TYPE); |
350 |
String defaultCollectionType = store.getString(JPAEditorPreferenceInitializer.PROPERTY_DEFAULT_COLLECTION_TYPE); |
| 322 |
btnCollectionType.setSelection(defaultCollectionType.equals(JPAEditorPreferenceInitializer.PROPERTY_VAL_COLLECTION_TYPE)); |
351 |
btnCollectionType.setSelection(defaultCollectionType.equals(JPAEditorPreferenceInitializer.PROPERTY_VAL_COLLECTION_TYPE)); |
| 323 |
btnListType.setSelection(defaultCollectionType.equals(JPAEditorPreferenceInitializer.PROPERTY_VAL_LIST_TYPE)); |
352 |
btnListType.setSelection(defaultCollectionType.equals(JPAEditorPreferenceInitializer.PROPERTY_VAL_LIST_TYPE)); |
| 324 |
btnSetType.setSelection(defaultCollectionType.equals(JPAEditorPreferenceInitializer.PROPERTY_VAL_SET_TYPE)); |
353 |
btnSetType.setSelection(defaultCollectionType.equals(JPAEditorPreferenceInitializer.PROPERTY_VAL_SET_TYPE)); |
|
|
354 |
boolean defaultOneToManyOldStyle = store.getBoolean(JPAEditorPreferenceInitializer.PROPERTY_ONE_TO_MANY_OLD_STYLE); |
| 355 |
if (!isJPA10Project) |
| 356 |
checkOneToManyOldStyle.setSelection(defaultOneToManyOldStyle); |
| 325 |
super.performDefaults(); |
357 |
super.performDefaults(); |
| 326 |
} |
358 |
} |
| 327 |
|
359 |
|
| 328 |
synchronized protected void validatePage() { |
360 |
synchronized protected void validatePage() { |
| 329 |
IProject project = (IProject)getElement().getAdapter(IProject.class); |
|
|
| 330 |
IStatus statFolder = JPAEditorPreferencesPage.validateDefaultFolder(txtDefaultFolderField.getText().trim(), |
361 |
IStatus statFolder = JPAEditorPreferencesPage.validateDefaultFolder(txtDefaultFolderField.getText().trim(), |
| 331 |
project.getName()); |
362 |
project.getName()); |
| 332 |
IStatus statPack = JPAEditorPreferencesPage.validateDefaultPackage(txtDefaultEntityPackageField.getText().trim()); |
363 |
IStatus statPack = JPAEditorPreferencesPage.validateDefaultPackage(txtDefaultEntityPackageField.getText().trim()); |
|
Lines 402-409
Link Here
|
| 402 |
editorProps.put(PROP_DEFAULT_TABLE_NAME_PREFIX.getLocalName(), txtDefaultTableNamePrefix.getText().trim()); |
433 |
editorProps.put(PROP_DEFAULT_TABLE_NAME_PREFIX.getLocalName(), txtDefaultTableNamePrefix.getText().trim()); |
| 403 |
editorProps.put(PROP_DIRECT_EDIT_AFFECTS_CLASS.getLocalName(), "" + checkDirectEditAffectsClass.getSelection()); //$NON-NLS-1$; |
434 |
editorProps.put(PROP_DIRECT_EDIT_AFFECTS_CLASS.getLocalName(), "" + checkDirectEditAffectsClass.getSelection()); //$NON-NLS-1$; |
| 404 |
editorProps.put(PROP_ACCESS_TYPE.getLocalName(), btnFieldBasedAccess.getSelection() ? JPAEditorPreferenceInitializer.PROPERTY_VAL_ACCESS_FIELD_BASED : JPAEditorPreferenceInitializer.PROPERTY_VAL_ACCESS_PROPERTY_BASED); |
435 |
editorProps.put(PROP_ACCESS_TYPE.getLocalName(), btnFieldBasedAccess.getSelection() ? JPAEditorPreferenceInitializer.PROPERTY_VAL_ACCESS_FIELD_BASED : JPAEditorPreferenceInitializer.PROPERTY_VAL_ACCESS_PROPERTY_BASED); |
| 405 |
editorProps.put(PROP_COLLECTION_TYPE.getLocalName(), getCollectionProperty()); |
436 |
editorProps.put(PROP_COLLECTION_TYPE.getLocalName(), getCollectionProperty()); |
| 406 |
|
437 |
if (!isJPA10Project) |
|
|
438 |
editorProps.put(PROP_ONE_TO_MANY_OLD_STYLE.getLocalName(), "" + checkOneToManyOldStyle.getSelection()); //$NON-NLS-1$; |
| 407 |
} |
439 |
} |
| 408 |
|
440 |
|
| 409 |
|
441 |
|
|
Lines 428-434
Link Here
|
| 428 |
editorDefaultProps.setProperty(PROP_DEFAULT_TABLE_NAME_PREFIX.getLocalName(), store.getString(JPAEditorPreferenceInitializer.PROPERTY_TABLE_NAME_PREFIX)); |
460 |
editorDefaultProps.setProperty(PROP_DEFAULT_TABLE_NAME_PREFIX.getLocalName(), store.getString(JPAEditorPreferenceInitializer.PROPERTY_TABLE_NAME_PREFIX)); |
| 429 |
editorDefaultProps.setProperty(PROP_DIRECT_EDIT_AFFECTS_CLASS.getLocalName(), "" + store.getBoolean(JPAEditorPreferenceInitializer.PROPERTY_DIRECT_EDIT_CLASS_NAME)); //$NON-NLS-1$; |
461 |
editorDefaultProps.setProperty(PROP_DIRECT_EDIT_AFFECTS_CLASS.getLocalName(), "" + store.getBoolean(JPAEditorPreferenceInitializer.PROPERTY_DIRECT_EDIT_CLASS_NAME)); //$NON-NLS-1$; |
| 430 |
editorDefaultProps.setProperty(PROP_ACCESS_TYPE.getLocalName(), store.getString(JPAEditorPreferenceInitializer.PROPERTY_ENTITY_ACCESS_TYPE)); |
462 |
editorDefaultProps.setProperty(PROP_ACCESS_TYPE.getLocalName(), store.getString(JPAEditorPreferenceInitializer.PROPERTY_ENTITY_ACCESS_TYPE)); |
| 431 |
editorDefaultProps.setProperty(PROP_COLLECTION_TYPE.getLocalName(), store.getString(JPAEditorPreferenceInitializer.PROPERTY_DEFAULT_COLLECTION_TYPE)); |
463 |
editorDefaultProps.setProperty(PROP_COLLECTION_TYPE.getLocalName(), store.getString(JPAEditorPreferenceInitializer.PROPERTY_DEFAULT_COLLECTION_TYPE)); |
|
|
464 |
editorDefaultProps.setProperty(PROP_ONE_TO_MANY_OLD_STYLE.getLocalName(), "" + store.getBoolean(JPAEditorPreferenceInitializer.PROPERTY_ONE_TO_MANY_OLD_STYLE)); //$NON-NLS-1$; |
| 465 |
|
| 466 |
|
| 432 |
return editorDefaultProps; |
467 |
return editorDefaultProps; |
| 433 |
} |
468 |
} |
| 434 |
|
469 |
|