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 285895
Collapse All | Expand All

(-)plugin.properties (+1 lines)
Lines 55-60 Link Here
55
55
56
persistenceEditor=Persistence XML Editor
56
persistenceEditor=Persistence XML Editor
57
57
58
jpaProblemSeveritiesPageName=Errors/Warnings
58
jpaPreferencePage = Java Persistence
59
jpaPreferencePage = Java Persistence
59
60
60
jpaProjectPropertiesPage = Java Persistence
61
jpaProjectPropertiesPage = Java Persistence
(-)plugin.xml (-2 / +31 lines)
Lines 1-6 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.2"?>
2
<?eclipse version="3.2"?>
3
<plugin>
3
<plugin
4
>
4
	
5
	
5
	<extension-point 
6
	<extension-point 
6
		id="jpaPlatformUis" 
7
		id="jpaPlatformUis" 
Lines 790-796 Link Here
790
		</objectContribution>
791
		</objectContribution>
791
		
792
		
792
	</extension>
793
	</extension>
793
	
794
795
	<extension
796
       point="org.eclipse.ui.preferencePages">
797
    <page
798
          id="org.eclipse.jpt.ui.preferences"
799
          class="org.eclipse.jpt.ui.internal.preferences.JpaPreferencesPage"
800
          name="%jpaPreferencePage">
801
    </page>
802
    <page
803
          category="org.eclipse.jpt.ui.preferences"
804
          class="org.eclipse.jpt.ui.internal.preferences.JpaProblemSeveritiesPage"
805
          id="org.eclipse.jpt.ui.preferences.problemSeverities"
806
          name="%jpaProblemSeveritiesPageName">
807
    </page>
808
	</extension>
794
	
809
	
795
	<extension
810
	<extension
796
		point="org.eclipse.ui.propertyPages">
811
		point="org.eclipse.ui.propertyPages">
Lines 808-813 Link Here
808
		        </adapt>
823
		        </adapt>
809
			</enabledWhen>
824
			</enabledWhen>
810
		</page>
825
		</page>
826
		<page
827
         id="org.eclipse.jpt.ui.propertyPages.problemSeverities"
828
         name="%jpaProblemSeveritiesPageName"
829
         category="org.eclipse.jpt.ui.jpaProjectPropertiesPage"
830
         class="org.eclipse.jpt.ui.internal.preferences.JpaProblemSeveritiesPage">
831
			<enabledWhen>
832
				<adapt type="org.eclipse.core.resources.IProject">
833
			        <test 
834
			            forcePluginActivation="true"
835
			            property="org.eclipse.wst.common.project.facet.core.projectFacet"
836
			            value="jpt.jpa"/>
837
		        </adapt>
838
			</enabledWhen>
839
		</page>
811
	</extension>
840
	</extension>
812
	
841
	
813
	  		
842
	  		
(-)property_files/jpt_ui.properties (+9 lines)
Lines 104-109 Link Here
104
JpaFacetWizardPage_metamodelSourceFolderLabel=Source Folder
104
JpaFacetWizardPage_metamodelSourceFolderLabel=Source Folder
105
JpaFacetWizardPage_none=<None>
105
JpaFacetWizardPage_none=<None>
106
106
107
JpaPreferencesPage_Description=Expand the tree to edit preferences for a specific feature.
108
109
JpaProblemSeveritiesPage_Default=Default
110
JpaProblemSeveritiesPage_Description=Select the severity level for the following optional Java Persistence validation problems:
111
JpaProblemSeveritiesPage_Error=Error
112
JpaProblemSeveritiesPage_Ignore=Ignore
113
JpaProblemSeveritiesPage_Info=Info
114
JpaProblemSeveritiesPage_Warning=Warning
115
107
MappingFileWizard_title=New Mapping File
116
MappingFileWizard_title=New Mapping File
108
MappingFileWizardPage_title=Mapping file
117
MappingFileWizardPage_title=Mapping file
109
MappingFileWizardPage_desc=Specify mapping file location and properties
118
MappingFileWizardPage_desc=Specify mapping file location and properties
(-)src/org/eclipse/jpt/ui/internal/JptUiMessages.java (-1 / +8 lines)
Lines 3-9 Link Here
3
 * This program and the accompanying materials are made available under the
3
 * This program and the accompanying materials are made available under the
4
 * terms of the Eclipse Public License v1.0, which accompanies this distribution
4
 * terms of the Eclipse Public License v1.0, which accompanies this distribution
5
 * and is available at http://www.eclipse.org/legal/epl-v10.html.
5
 * and is available at http://www.eclipse.org/legal/epl-v10.html.
6
 * 
6
 *
7
 * Contributors:
7
 * Contributors:
8
 *     Oracle - initial API and implementation
8
 *     Oracle - initial API and implementation
9
 ******************************************************************************/
9
 ******************************************************************************/
Lines 118-123 Link Here
118
	public static String PackageChooserPane_dialogTitle;
118
	public static String PackageChooserPane_dialogTitle;
119
	public static String PersistenceItemLabelProviderFactory_persistenceLabel;
119
	public static String PersistenceItemLabelProviderFactory_persistenceLabel;
120
	public static String EntitiesGenerator_jobName;
120
	public static String EntitiesGenerator_jobName;
121
	public static String JpaPreferencesPage_Description;
122
	public static String JpaProblemSeveritiesPage_Default;
123
	public static String JpaProblemSeveritiesPage_Description;
124
	public static String JpaProblemSeveritiesPage_Error;
125
	public static String JpaProblemSeveritiesPage_Ignore;
126
	public static String JpaProblemSeveritiesPage_Info;
127
	public static String JpaProblemSeveritiesPage_Warning;
121
128
122
	private static final String BUNDLE_NAME = "jpt_ui"; //$NON-NLS-1$
129
	private static final String BUNDLE_NAME = "jpt_ui"; //$NON-NLS-1$
123
	private static final Class<?> BUNDLE_CLASS = JptUiMessages.class;
130
	private static final Class<?> BUNDLE_CLASS = JptUiMessages.class;
(-)src/org/eclipse/jpt/ui/internal/JptUiValidationPreferenceMessages.java (-2 / +2 lines)
Lines 14-21 Link Here
14
	public static String PERSISTENCE_NO_PERSISTENCE_UNIT;
14
	public static String PERSISTENCE_NO_PERSISTENCE_UNIT;
15
	public static String PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS;
15
	public static String PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS;
16
	public static String PERSISTENCE_XML_INVALID_CONTENT;
16
	public static String PERSISTENCE_XML_INVALID_CONTENT;
17
	public static String PERSISTENCE_UNIT_LEVEL_CATEGORY;
18
17
18
	public static String PERSISTENCE_UNIT_LEVEL_CATEGORY;
19
	public static String PERSISTENCE_UNIT_UNSPECIFIED_MAPPING_FILE;
19
	public static String PERSISTENCE_UNIT_UNSPECIFIED_MAPPING_FILE;
20
	public static String PERSISTENCE_UNIT_UNSUPPORTED_MAPPING_FILE_CONTENT;
20
	public static String PERSISTENCE_UNIT_UNSUPPORTED_MAPPING_FILE_CONTENT;
21
	public static String PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE;
21
	public static String PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE;
Lines 121-125 Link Here
121
		throw new UnsupportedOperationException();
121
		throw new UnsupportedOperationException();
122
	}
122
	}
123
123
124
	
124
125
}
125
}
(-)src/org/eclipse/jpt/ui/internal/preferences/JpaPreferencesPage.java (+68 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Oracle. All rights reserved.
3
 * This program and the accompanying materials are made available under the
4
 * terms of the Eclipse Public License v1.0, which accompanies this distribution
5
 * and is available at http://www.eclipse.org/legal/epl-v10.html.
6
 *
7
 * Contributors:
8
 *     Oracle - initial API and implementation
9
 ******************************************************************************/
10
package org.eclipse.jpt.ui.internal.preferences;
11
12
import org.eclipse.jface.preference.PreferencePage;
13
import org.eclipse.jpt.ui.JptUiPlugin;
14
import org.eclipse.jpt.ui.internal.JptUiMessages;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.layout.GridData;
17
import org.eclipse.swt.layout.GridLayout;
18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Control;
20
import org.eclipse.swt.widgets.Label;
21
import org.eclipse.ui.IWorkbench;
22
import org.eclipse.ui.IWorkbenchPreferencePage;
23
24
/**
25
 * This is the root of the Java Persistence preferences hierarchy in the IDE
26
 * preferences dialog.
27
 * <p>
28
 * Structure:
29
 * <p>
30
 * Java Persistence<br>
31
 *  |- Errors/Warnings
32
 *
33
 * @version 2.2
34
 * @since 2.2
35
 */
36
public class JpaPreferencesPage extends PreferencePage
37
                                implements IWorkbenchPreferencePage {
38
39
	/**
40
	 * Creates a new <code>JpaPreferencesPage</code>.
41
	 */
42
	public JpaPreferencesPage() {
43
		super();
44
	}
45
46
	/**
47
	 * {@inheritDoc}
48
	 */
49
	@Override
50
	protected Control createContents(Composite parent) {
51
		parent = new Composite(parent, SWT.NONE);
52
		parent.setLayout(new GridLayout(1, false));
53
54
		// Message label
55
		Label label = new Label(parent, SWT.NONE);
56
		label.setText(JptUiMessages.JpaPreferencesPage_Description);
57
		label.setData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, true));
58
59
		return parent;
60
	}
61
62
	/**
63
	 * {@inheritDoc}
64
	 */
65
	public void init(IWorkbench workbench) {
66
		setPreferenceStore(JptUiPlugin.instance().getPreferenceStore());
67
	}
68
}
(-)src/org/eclipse/jpt/ui/internal/preferences/JpaProblemSeveritiesPage.java (+618 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 Oracle. All rights reserved.
3
 * This program and the accompanying materials are made available under the
4
 * terms of the Eclipse Public License v1.0, which accompanies this distribution
5
 * and is available at http://www.eclipse.org/legal/epl-v10.html.
6
 *
7
 * Contributors:
8
 *     Oracle - initial API and implementation
9
 ******************************************************************************/
10
package org.eclipse.jpt.ui.internal.preferences;
11
12
import java.lang.reflect.Field;
13
import java.util.ArrayList;
14
import java.util.List;
15
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
17
import org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage;
18
import org.eclipse.jdt.internal.ui.preferences.ScrolledPageContent;
19
import org.eclipse.jface.dialogs.IDialogSettings;
20
import org.eclipse.jface.layout.PixelConverter;
21
import org.eclipse.jface.resource.JFaceResources;
22
import org.eclipse.jpt.core.JptCorePlugin;
23
import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
24
import org.eclipse.jpt.core.internal.validation.JpaValidationPreferences;
25
import org.eclipse.jpt.ui.JptUiPlugin;
26
import org.eclipse.jpt.ui.internal.JptUiMessages;
27
import org.eclipse.jpt.ui.internal.JptUiValidationPreferenceMessages;
28
import org.eclipse.swt.SWT;
29
import org.eclipse.swt.events.SelectionAdapter;
30
import org.eclipse.swt.events.SelectionEvent;
31
import org.eclipse.swt.events.SelectionListener;
32
import org.eclipse.swt.layout.GridData;
33
import org.eclipse.swt.layout.GridLayout;
34
import org.eclipse.swt.widgets.Combo;
35
import org.eclipse.swt.widgets.Composite;
36
import org.eclipse.swt.widgets.Control;
37
import org.eclipse.swt.widgets.Label;
38
import org.eclipse.ui.IWorkbench;
39
import org.eclipse.ui.forms.events.ExpansionAdapter;
40
import org.eclipse.ui.forms.events.ExpansionEvent;
41
import org.eclipse.ui.forms.widgets.ExpandableComposite;
42
43
/**
44
 * This page shows the Java Persistence validation options. It supports
45
 * workspace and project levels severities.
46
 *
47
 * @version 2.2
48
 * @since 2.2
49
 */
50
@SuppressWarnings({"restriction", "nls"})
51
public class JpaProblemSeveritiesPage extends PropertyAndPreferencePage {
52
53
	/**
54
	 * The list of <code>Combo</code>s is cached in order to perform a revert of
55
	 * the properties.
56
	 */
57
	private List<Combo> combos;
58
59
	/**
60
	 * The position of the "Error" choice in the combo's model.
61
	 */
62
	private final int DEFAULT_INDEX = 0;
63
64
	/**
65
	 * The position of the "Error" choice in the combo's model.
66
	 */
67
	private final int ERROR_INDEX = 1;
68
69
	/**
70
	 * The list of <code>ExpandableComposite</code> is cached in order to save
71
	 * and restore the expansion state.
72
	 */
73
	private List<ExpandableComposite> expandablePanes;
74
75
	/**
76
	 * The position of the "Ignore" choice in the combo's model.
77
	 */
78
	private final int IGNORE_INDEX = 3;
79
80
	/**
81
	 * The position of the "Info" choice in the combo's model.
82
	 */
83
	private final int INFO_INDEX = 4;
84
85
	/**
86
	 * The unique identifier for this page when it is shown in the IDE
87
	 * preferences dialog.
88
	 */
89
	private final String JPT_PREFERENCES_PROBLEM_SEVERITIES_ID = "org.eclipse.jpt.ui.preferences.problemSeverities";
90
91
	/**
92
	 * The unique identifier for this page when it is shown in the project
93
	 * preferences dialog.
94
	 */
95
	private final String JPT_PROPERTY_PAGES_PROBLEM_SEVERITIES_ID = "org.eclipse.jpt.ui.propertyPages.problemSeverities";
96
97
	/**
98
	 * A constant used to store and retrieve the preference key (message ID) from
99
	 * the combo.
100
	 */
101
	private final String PREFERENCE_KEY = "preferenceKey";
102
103
	/**
104
	 * The scrollable pane used to show the content of this page.
105
	 */
106
	private ScrolledPageContent scrollable;
107
108
	/**
109
	 * The possible choices which describes the severity of a single problem.
110
	 */
111
	private String[] severityDisplayStrings;
112
113
	/**
114
	 * The position of the "Warning" choice in the combo's model.
115
	 */
116
	private final int WARNING_INDEX = 2;
117
118
	/**
119
	 * Constant used to store the expansion state of each expandable pane.
120
	 */
121
	public static final String SETTINGS_EXPANDED = "expanded";
122
123
	/**
124
	 * The preference key used to retrieve the dialog settings where the expansion
125
	 * states have been stored.
126
	 */
127
	public static final String SETTINGS_SECTION_NAME = "JpaProblemSeveritiesPage";
128
129
	/**
130
	 * Creates a new <code>JpaProblemSeveritiesPage</code>.
131
	 */
132
	public JpaProblemSeveritiesPage() {
133
		super();
134
		initialize();
135
	}
136
137
	private void addAttributeLevelCategory(Composite parent) {
138
139
		parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.ATTRIBUTE_LEVEL_CATEGORY);
140
141
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.MAPPING_UNRESOLVED_MAPPED_BY,      JpaValidationMessages.MAPPING_UNRESOLVED_MAPPED_BY);
142
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.MAPPING_INVALID_MAPPED_BY,         JpaValidationMessages.MAPPING_INVALID_MAPPED_BY);
143
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.MAPPING_MAPPED_BY_WITH_JOIN_TABLE, JpaValidationMessages.MAPPING_MAPPED_BY_WITH_JOIN_TABLE);
144
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.MAPPING_MAPPED_BY_ON_BOTH_SIDES,   JpaValidationMessages.MAPPING_MAPPED_BY_ON_BOTH_SIDES);
145
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.TARGET_ENTITY_NOT_DEFINED,         JpaValidationMessages.TARGET_ENTITY_NOT_DEFINED);
146
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.TARGET_ENTITY_IS_NOT_AN_ENTITY,    JpaValidationMessages.TARGET_ENTITY_IS_NOT_AN_ENTITY);
147
	}
148
149
	/**
150
	 * Creates and adds to the given <code>Composite</code> an expandable pane
151
	 * where its content can be shown or hidden depending on the expansion state.
152
	 *
153
	 * @param parent The parent container
154
	 * @param text The title of the expandable section
155
	 * @return The container to which widgets can be added, which is a child of
156
	 * the expandable pane
157
	 */
158
	private Composite addExpandableSection(Composite parent, String text) {
159
160
		ExpandableComposite expandablePane = new ExpandableComposite(
161
			parent,
162
			SWT.NONE,
163
			ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT
164
		);
165
166
		expandablePane.setText(text);
167
		expandablePane.setExpanded(false);
168
		expandablePane.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
169
		expandablePane.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
170
		expandablePane.addExpansionListener(buildExpansionListener());
171
172
		scrollable.adaptChild(expandablePane);
173
		expandablePanes.add(expandablePane);
174
175
		parent = new Composite(expandablePane, SWT.NONE);
176
		parent.setLayout(new GridLayout(2, false));
177
		expandablePane.setClient(parent);
178
179
		return parent;
180
	}
181
182
	private void addImpliedAssociationCategory(Composite parent) {
183
184
		parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.IMPLIED_ASSOCIATION_CATEGORY);
185
186
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_TABLE,                  JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_TABLE);
187
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_NAME,                   JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_NAME);
188
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME);
189
	}
190
191
	private void addImpliedAttributeCategory(Composite parent) {
192
193
		parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.IMPLIED_ATTRIBUTE_CATEGORY);
194
195
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_CATALOG,                                       JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_CATALOG);
196
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_SCHEMA,                                        JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_SCHEMA);
197
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_NAME,                                          JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_NAME);
198
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_COLUMN_UNRESOLVED_TABLE,                                             JpaValidationMessages.VIRTUAL_ATTRIBUTE_COLUMN_UNRESOLVED_TABLE);
199
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_TABLE,                                    JpaValidationMessages.VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_TABLE);
200
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_COLUMN_UNRESOLVED_NAME,                                              JpaValidationMessages.VIRTUAL_ATTRIBUTE_COLUMN_UNRESOLVED_NAME);
201
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_NAME,                                     JpaValidationMessages.VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_NAME);
202
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_TABLE,                                        JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_TABLE);
203
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_NAME,                                         JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_NAME);
204
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_NAME_MULTIPLE_JOIN_COLUMNS,                   JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_NAME_MULTIPLE_JOIN_COLUMNS);
205
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME,                       JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME);
206
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME_MULTIPLE_JOIN_COLUMNS);
207
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_IS_NOT_AN_ENTITY,                                      JpaValidationMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_IS_NOT_AN_ENTITY);
208
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_NOT_DEFINED,                                           JpaValidationMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_NOT_DEFINED);
209
	}
210
211
	private void addInheritanceStrategoryCategory(Composite parent) {
212
213
		parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.INHERITANCE_CATEGORY);
214
215
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.DISCRIMINATOR_COLUMN_UNRESOLVED_NAME,             JpaValidationMessages.DISCRIMINATOR_COLUMN_UNRESOLVED_NAME);
216
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.ENTITY_TABLE_PER_CLASS_NOT_SUPPORTED_ON_PLATFORM, JpaValidationMessages.ENTITY_TABLE_PER_CLASS_NOT_SUPPORTED_ON_PLATFORM);
217
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.ENTITY_TABLE_PER_CLASS_NOT_PORTABLE_ON_PLATFORM,  JpaValidationMessages.ENTITY_TABLE_PER_CLASS_NOT_PORTABLE_ON_PLATFORM);
218
	}
219
220
	/**
221
	 * Creates and adds to the given parent a labeled combo where the possible
222
	 * choices are "Ignore", "Error" and "Warning".
223
	 *
224
	 * @param parent The parent to which the widgets are added
225
	 * @param labelText The text labelling the combo
226
	 * @param preferenceKey The key used to retrieve and to store the value
227
	 * associated with the validation problem
228
	 */
229
	private void addLabeledCombo(Composite parent,
230
	                             String labelText,
231
	                             String preferenceKey) {
232
233
234
		Label label = new Label(parent, SWT.NONE);
235
		label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
236
		label.setText(labelText);
237
238
		Combo combo = new Combo(parent, SWT.READ_ONLY);
239
		combo.setItems(severityDisplayStrings);
240
		combo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
241
		combo.setData(PREFERENCE_KEY, preferenceKey);
242
		combo.select(convertPreferenceValueToIndex(preferenceKey));
243
		combo.addSelectionListener(buildComboSelectionListener());
244
245
		scrollable.adaptChild(combo);
246
		combos.add(combo);
247
	}
248
249
	private void addPersistenceLevelCategory(Composite parent) {
250
251
		parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_LEVEL_CATEGORY);
252
253
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_UNSPECIFIED_MAPPING_FILE,                      JpaValidationMessages.PERSISTENCE_UNIT_UNSPECIFIED_MAPPING_FILE);
254
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_UNSUPPORTED_MAPPING_FILE_CONTENT,              JpaValidationMessages.PERSISTENCE_UNIT_UNSUPPORTED_MAPPING_FILE_CONTENT);
255
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE,                      JpaValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE);
256
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_INVALID_MAPPING_FILE,                          JpaValidationMessages.PERSISTENCE_UNIT_INVALID_MAPPING_FILE);
257
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_DUPLICATE_MAPPING_FILE,                        JpaValidationMessages.PERSISTENCE_UNIT_DUPLICATE_MAPPING_FILE);
258
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_UNSPECIFIED_CLASS,                             JpaValidationMessages.PERSISTENCE_UNIT_UNSPECIFIED_CLASS);
259
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_NONEXISTENT_CLASS,                             JpaValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_CLASS);
260
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_INVALID_CLASS,                                 JpaValidationMessages.PERSISTENCE_UNIT_INVALID_CLASS);
261
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_DUPLICATE_CLASS,                               JpaValidationMessages.PERSISTENCE_UNIT_DUPLICATE_CLASS);
262
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_REDUNDANT_CLASS,                               JpaValidationMessages.PERSISTENCE_UNIT_REDUNDANT_CLASS);
263
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_DUPLICATE_JAR_FILE,                            JpaValidationMessages.PERSISTENCE_UNIT_DUPLICATE_JAR_FILE);
264
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_UNSPECIFIED_JAR_FILE,                          JpaValidationMessages.PERSISTENCE_UNIT_UNSPECIFIED_JAR_FILE);
265
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING,              JpaValidationMessages.PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING);
266
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE,                          JpaValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE);
267
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.MAPPING_FILE_EXTRANEOUS_PERSISTENCE_UNIT_DEFAULTS,              JpaValidationMessages.MAPPING_FILE_EXTRANEOUS_PERSISTENCE_UNIT_DEFAULTS);
268
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT,    JpaValidationMessages.PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT);
269
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT, JpaValidationMessages.PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT);
270
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENT_TYPE_UNSPECIFIED_CLASS,                              JpaValidationMessages.PERSISTENT_TYPE_UNSPECIFIED_CLASS);
271
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENT_TYPE_UNRESOLVED_CLASS,                               JpaValidationMessages.PERSISTENT_TYPE_UNRESOLVED_CLASS);
272
	}
273
274
	private void addPhysicalMappingCategory(Composite parent) {
275
276
		parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.PHYSICAL_MAPPING_CATEGORY);
277
278
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.TABLE_UNRESOLVED_CATALOG,                                            JpaValidationMessages.TABLE_UNRESOLVED_CATALOG);
279
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.TABLE_UNRESOLVED_SCHEMA,                                             JpaValidationMessages.TABLE_UNRESOLVED_SCHEMA);
280
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.TABLE_UNRESOLVED_NAME,                                               JpaValidationMessages.TABLE_UNRESOLVED_NAME);
281
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.SECONDARY_TABLE_UNRESOLVED_CATALOG,                                  JpaValidationMessages.SECONDARY_TABLE_UNRESOLVED_CATALOG);
282
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.SECONDARY_TABLE_UNRESOLVED_SCHEMA,                                   JpaValidationMessages.SECONDARY_TABLE_UNRESOLVED_SCHEMA);
283
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.SECONDARY_TABLE_UNRESOLVED_NAME,                                     JpaValidationMessages.SECONDARY_TABLE_UNRESOLVED_NAME);
284
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.JOIN_TABLE_UNRESOLVED_CATALOG,                                       JpaValidationMessages.JOIN_TABLE_UNRESOLVED_CATALOG);
285
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.JOIN_TABLE_UNRESOLVED_SCHEMA,                                        JpaValidationMessages.JOIN_TABLE_UNRESOLVED_SCHEMA);
286
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.JOIN_TABLE_UNRESOLVED_NAME,                                          JpaValidationMessages.JOIN_TABLE_UNRESOLVED_NAME);
287
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.COLUMN_UNRESOLVED_TABLE,                                             JpaValidationMessages.COLUMN_UNRESOLVED_TABLE);
288
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.COLUMN_UNRESOLVED_NAME,                                              JpaValidationMessages.COLUMN_UNRESOLVED_NAME);
289
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.JOIN_COLUMN_UNRESOLVED_TABLE,                                        JpaValidationMessages.JOIN_COLUMN_UNRESOLVED_TABLE);
290
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.JOIN_COLUMN_UNRESOLVED_NAME,                                         JpaValidationMessages.JOIN_COLUMN_UNRESOLVED_NAME);
291
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.JOIN_COLUMN_UNRESOLVED_NAME_MULTIPLE_JOIN_COLUMNS,                   JpaValidationMessages.JOIN_COLUMN_UNRESOLVED_NAME_MULTIPLE_JOIN_COLUMNS);
292
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME,                       JpaValidationMessages.JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME);
293
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME_MULTIPLE_JOIN_COLUMNS);
294
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME,                             JpaValidationMessages.PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME);
295
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME,           JpaValidationMessages.PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME);
296
	}
297
298
	private void addProjectLevelCategory(Composite parent) {
299
300
		parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.PROJECT_LEVEL_CATEGORY);
301
302
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.NO_JPA_PROJECT,                         JpaValidationMessages.NO_JPA_PROJECT);
303
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PROJECT_NO_CONNECTION,                  JpaValidationMessages.PROJECT_NO_CONNECTION);
304
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PROJECT_INVALID_CONNECTION,             JpaValidationMessages.PROJECT_INVALID_CONNECTION);
305
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PROJECT_INACTIVE_CONNECTION,            JpaValidationMessages.PROJECT_INACTIVE_CONNECTION);
306
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PROJECT_NO_PERSISTENCE_XML,             JpaValidationMessages.PROJECT_NO_PERSISTENCE_XML);
307
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PROJECT_MULTIPLE_PERSISTENCE_XML,       JpaValidationMessages.PROJECT_MULTIPLE_PERSISTENCE_XML);
308
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_NO_PERSISTENCE_UNIT,        JpaValidationMessages.PERSISTENCE_NO_PERSISTENCE_UNIT);
309
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS, JpaValidationMessages.PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS);
310
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_XML_INVALID_CONTENT,        JpaValidationMessages.PERSISTENCE_XML_INVALID_CONTENT);
311
	}
312
313
	private void addQueriesGeneratorsCategory(Composite parent) {
314
315
		parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.QUERIES_GENERATORS_CATEGORY);
316
317
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.GENERATOR_DUPLICATE_NAME,             JpaValidationMessages.GENERATOR_DUPLICATE_NAME);
318
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.ID_MAPPING_UNRESOLVED_GENERATOR_NAME, JpaValidationMessages.ID_MAPPING_UNRESOLVED_GENERATOR_NAME);
319
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.GENERATED_VALUE_UNRESOLVED_GENERATOR, JpaValidationMessages.GENERATED_VALUE_UNRESOLVED_GENERATOR);
320
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.QUERY_DUPLICATE_NAME,                 JpaValidationMessages.QUERY_DUPLICATE_NAME);
321
	}
322
323
	private void addTypeLevelCategory(Composite parent) {
324
325
		parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.TYPE_LEVEL_CATEGORY);
326
327
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.ENTITY_NO_ID,                                            JpaValidationMessages.ENTITY_NO_ID);
328
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.ENTITY_SINGLE_TABLE_DESCENDANT_DEFINES_TABLE,            JpaValidationMessages.ENTITY_SINGLE_TABLE_DESCENDANT_DEFINES_TABLE);
329
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.ENTITY_ABSTRACT_TABLE_PER_CLASS_DEFINES_TABLE,           JpaValidationMessages.ENTITY_ABSTRACT_TABLE_PER_CLASS_DEFINES_TABLE);
330
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.ENTITY_ABSTRACT_DISCRIMINATOR_VALUE_DEFINED,             JpaValidationMessages.ENTITY_ABSTRACT_DISCRIMINATOR_VALUE_DEFINED);
331
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_VALUE_DEFINED,      JpaValidationMessages.ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_VALUE_DEFINED);
332
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.ENTITY_NON_ROOT_DISCRIMINATOR_COLUMN_DEFINED,            JpaValidationMessages.ENTITY_NON_ROOT_DISCRIMINATOR_COLUMN_DEFINED);
333
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_COLUMN_DEFINED,     JpaValidationMessages.ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_COLUMN_DEFINED);
334
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENT_ATTRIBUTE_UNSPECIFIED_NAME,                   JpaValidationMessages.PERSISTENT_ATTRIBUTE_UNSPECIFIED_NAME);
335
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENT_ATTRIBUTE_UNRESOLVED_NAME,                    JpaValidationMessages.PERSISTENT_ATTRIBUTE_UNRESOLVED_NAME);
336
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENT_ATTRIBUTE_INHERITED_ATTRIBUTES_NOT_SUPPORTED, JpaValidationMessages.PERSISTENT_ATTRIBUTE_INHERITED_ATTRIBUTES_NOT_SUPPORTED);
337
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENT_ATTRIBUTE_INVALID_MAPPING,                    JpaValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_MAPPING);
338
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENT_ATTRIBUTE_FINAL_FIELD,                        JpaValidationMessages.PERSISTENT_ATTRIBUTE_FINAL_FIELD);
339
		addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENT_ATTRIBUTE_PUBLIC_FIELD,                       JpaValidationMessages.PERSISTENT_ATTRIBUTE_PUBLIC_FIELD);
340
	}
341
342
	private SelectionListener buildComboSelectionListener() {
343
		return new SelectionAdapter() {
344
			@Override
345
			public void widgetSelected(SelectionEvent e) {
346
				Combo combo = (Combo) e.widget;
347
				String preferenceKey = (String) combo.getData(PREFERENCE_KEY);
348
				String value = convertToPreferenceValue(combo.getSelectionIndex());
349
				updatePreference(preferenceKey, value);
350
			}
351
		};
352
	}
353
354
	private ExpansionAdapter buildExpansionListener() {
355
		return new ExpansionAdapter() {
356
			@Override
357
			public void expansionStateChanged(ExpansionEvent e) {
358
				JpaProblemSeveritiesPage.this.expansionStateChanged();
359
			}
360
		};
361
	}
362
363
	protected String[] buildSeverityDisplayStrings() {
364
		String[] severities = new String[5];
365
		severities[DEFAULT_INDEX] = JptUiMessages.JpaProblemSeveritiesPage_Default;
366
		severities[ERROR_INDEX]   = JptUiMessages.JpaProblemSeveritiesPage_Error;
367
		severities[WARNING_INDEX] = JptUiMessages.JpaProblemSeveritiesPage_Warning;
368
		severities[IGNORE_INDEX]  = JptUiMessages.JpaProblemSeveritiesPage_Ignore;
369
		severities[INFO_INDEX]    = JptUiMessages.JpaProblemSeveritiesPage_Info;
370
		return severities;
371
	}
372
373
	protected int convertPreferenceValueToIndex(String preferenceKey) {
374
		String severity = preferenceValue(preferenceKey);
375
376
		if (JpaValidationPreferences.HIGH_SEVERITY.equals(severity)) {
377
			return ERROR_INDEX;
378
		}
379
380
		if (JpaValidationPreferences.NORMAL_SEVERITY.equals(severity)) {
381
			return WARNING_INDEX;
382
		}
383
384
		if (JpaValidationPreferences.LOW_SEVERITY.equals(severity)) {
385
			return INFO_INDEX;
386
		}
387
388
		if (JpaValidationPreferences.IGNORE.equals(severity)) {
389
			return IGNORE_INDEX;
390
		}
391
392
		return DEFAULT_INDEX;
393
	}
394
395
	protected String convertToPreferenceValue(int selectionIndex) {
396
		switch (selectionIndex) {
397
			case ERROR_INDEX:   return JpaValidationPreferences.HIGH_SEVERITY;
398
			case WARNING_INDEX: return JpaValidationPreferences.NORMAL_SEVERITY;
399
			case INFO_INDEX:    return JpaValidationPreferences.LOW_SEVERITY;
400
			case IGNORE_INDEX:  return JpaValidationPreferences.IGNORE;
401
			default:            return null;
402
		}
403
	}
404
405
	/**
406
	 * {@inheritDoc}
407
	 */
408
	@Override
409
	protected Control createPreferenceContent(Composite parent) {
410
411
		PixelConverter pixelConverter = new PixelConverter(parent);
412
413
		// Create a container because the caller will set the GridData and we need
414
		// to change the heightHint of the first child and we also need to set the
415
		// font otherwise the layout won't be calculated correctly
416
		Composite container = new Composite(parent, SWT.NONE);
417
		container.setFont(parent.getFont());
418
		GridLayout layout = new GridLayout(1, false);
419
		layout.marginHeight = 0;
420
		layout.marginWidth  = 0;
421
		container.setLayout(layout);
422
423
		// Create the main composite of this page
424
		scrollable = new ScrolledPageContent(container);
425
426
		GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
427
		gridData.heightHint = pixelConverter.convertHeightInCharsToPixels(20);
428
		scrollable.setLayoutData(gridData);
429
430
		// Update the layout of the ScrolledPageContent's body
431
		layout = new GridLayout(1, false);
432
		layout.marginHeight = 0;
433
		layout.marginWidth  = 0;
434
435
		parent = scrollable.getBody();
436
		parent.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
437
		parent.setLayout(layout);
438
439
		// Add each expandable category
440
		addProjectLevelCategory(parent);
441
		addPersistenceLevelCategory(parent);
442
		addTypeLevelCategory(parent);
443
		addAttributeLevelCategory(parent);
444
		addPhysicalMappingCategory(parent);
445
		addImpliedAttributeCategory(parent);
446
		addImpliedAssociationCategory(parent);
447
		addInheritanceStrategoryCategory(parent);
448
		addQueriesGeneratorsCategory(parent);
449
450
		// Restore the expansion states
451
		restoreSectionExpansionStates(dialogPreferences());
452
453
		return container;
454
	}
455
456
	protected IDialogSettings dialogPreferences() {
457
		IDialogSettings rootSettings = JptUiPlugin.instance().getDialogSettings();
458
		IDialogSettings settings = rootSettings.getSection(SETTINGS_SECTION_NAME);
459
		if (settings == null) {
460
			settings = rootSettings.addNewSection(SETTINGS_SECTION_NAME);
461
		}
462
		return settings;
463
	}
464
465
	/**
466
	 * {@inheritDoc}
467
	 */
468
	@Override
469
	public void dispose() {
470
		storeSectionExpansionStates(dialogPreferences());
471
		super.dispose();
472
	}
473
474
	/**
475
	 * Revalidates the layout in order to show or hide the vertical scroll bar
476
	 * after a section was either expanded or collapsed. This unfortunately does
477
	 * not happen automatically.
478
	 */
479
	protected void expansionStateChanged() {
480
		scrollable.reflow(true);
481
	}
482
483
	/**
484
	 * {@inheritDoc}
485
	 */
486
	@Override
487
	protected String getPreferencePageID() {
488
		return JPT_PREFERENCES_PROBLEM_SEVERITIES_ID;
489
	}
490
491
	/**
492
	 * {@inheritDoc}
493
	 */
494
	@Override
495
	protected String getPropertyPageID() {
496
		return JPT_PROPERTY_PAGES_PROBLEM_SEVERITIES_ID;
497
	}
498
499
	/**
500
	 * {@inheritDoc}
501
	 */
502
	@Override
503
	protected boolean hasProjectSpecificOptions(IProject project) {
504
		IEclipsePreferences projectPreferences = JptCorePlugin.getProjectPreferences(project);
505
506
		// Iterate through all the message IDs
507
		for (Field field : JpaValidationMessages.class.getFields()) {
508
			try {
509
				// Retrieve the value
510
				String value = (String) field.get(null);
511
512
				// Skip this one
513
				if (JpaValidationMessages.BUNDLE_NAME.equals(value)) {
514
					continue;
515
				}
516
517
				// Check to see if there is a value associated with the message ID
518
				if (projectPreferences.get(value, null) != null) {
519
					return true;
520
				}
521
			}
522
			catch (Exception exception) {
523
				// I think we can safely ignore any problem
524
			}
525
		}
526
527
		return false;
528
	}
529
530
	/**
531
	 * {@inheritDoc}
532
	 */
533
	@Override
534
	public void init(IWorkbench workbench) {
535
		setPreferenceStore(JptUiPlugin.instance().getPreferenceStore());
536
		setDescription(JptUiMessages.JpaProblemSeveritiesPage_Description);
537
	}
538
539
	/**
540
	 * Initializes this page.
541
	 */
542
	protected void initialize() {
543
		combos                 = new ArrayList<Combo>();
544
		expandablePanes        = new ArrayList<ExpandableComposite>();
545
		severityDisplayStrings = buildSeverityDisplayStrings();
546
	}
547
548
	/**
549
	 * {@inheritDoc}
550
	 */
551
	@Override
552
	protected void performDefaults() {
553
		super.performDefaults();
554
		revertToDefault();
555
	}
556
557
	protected String preferenceValue(String preferenceKey) {
558
		if (isProjectPreferencePage()) {
559
			return JpaValidationPreferences.getProjectLevelProblemPreference(getProject(), preferenceKey);
560
		}
561
		return JpaValidationPreferences.getWorkspaceLevelProblemPreference(preferenceKey);
562
	}
563
564
	protected void restoreSectionExpansionStates(IDialogSettings settings) {
565
566
		for (int index = expandablePanes.size(); --index >= 0; ) {
567
568
			ExpandableComposite expandablePane = expandablePanes.get(index);
569
570
			if (settings == null) {
571
				// Only expand the first node by default
572
				expandablePane.setExpanded(index == 0);
573
			}
574
			else {
575
				expandablePane.setExpanded(settings.getBoolean(SETTINGS_EXPANDED + index));
576
			}
577
		}
578
	}
579
580
	protected void revertToDefault() {
581
582
		int defaultValue = DEFAULT_INDEX;
583
584
		for (Combo combo : combos) {
585
			String preferenceKey = (String) combo.getData(PREFERENCE_KEY);
586
			String value = convertToPreferenceValue(defaultValue);
587
			updatePreference(preferenceKey, value);
588
			combo.select(defaultValue);
589
		}
590
	}
591
592
	protected void storeSectionExpansionStates(IDialogSettings settings) {
593
594
		for (int index = expandablePanes.size(); --index >= 0; ) {
595
			ExpandableComposite expandablePane = expandablePanes.get(index);
596
			settings.put(SETTINGS_EXPANDED + index, expandablePane.isExpanded());
597
		}
598
	}
599
600
	protected void updatePreference(String preferenceKey, String value) {
601
		if (isProjectPreferencePage()) {
602
			if (value != null) {
603
				JpaValidationPreferences.setProjectLevelProblemPreference(getProject(), preferenceKey, value);
604
			}
605
			else {
606
				JpaValidationPreferences.removeProjectLevelProblemPreference(getProject(), preferenceKey);
607
			}
608
		}
609
		else {
610
			if (value != null) {
611
				JpaValidationPreferences.setWorkspaceLevelProblemPreference(preferenceKey, value);
612
			}
613
			else {
614
				JpaValidationPreferences.removeWorkspaceLevelProblemPreference(preferenceKey);
615
			}
616
		}
617
	}
618
}

Return to bug 285895