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

Collapse All | Expand All

(-)plugin.xml (-1 / +1 lines)
Lines 938-944 Link Here
938
		<page
938
		<page
939
			id="org.eclipse.jpt.jpa.ui.preferences"
939
			id="org.eclipse.jpt.jpa.ui.preferences"
940
			name="%javaPersistenceNode"
940
			name="%javaPersistenceNode"
941
			class="org.eclipse.ui.internal.dialogs.EmptyPreferencePage"/>
941
			class="org.eclipse.jpt.jpa.ui.internal.preferences.JptPerferencesPage"/>
942
		
942
		
943
		<page
943
		<page
944
			id="org.eclipse.jpt.jpa.ui.jpaPreferences"
944
			id="org.eclipse.jpt.jpa.ui.jpaPreferences"
(-)property_files/jpt_ui.properties (+6 lines)
Lines 44-49 Link Here
44
DatabaseSchemaWizardPage_connectionInfo=(Note: JPA project must have a connection and it must be active to select a schema)
44
DatabaseSchemaWizardPage_connectionInfo=(Note: JPA project must have a connection and it must be active to select a schema)
45
DatabaseSchemaWizardPage_schemaInfo=(Note: Must have active connection to select schema)
45
DatabaseSchemaWizardPage_schemaInfo=(Note: Must have active connection to select schema)
46
46
47
DontShowAgainDialog_doNotShowWarning = Don't show me this warning again
48
47
Error_openingEditor=Error Opening Editor
49
Error_openingEditor=Error Opening Editor
48
50
49
General_browse=Br&owse...
51
General_browse=Br&owse...
Lines 118-123 Link Here
118
JpaMakePersistentWizardPage_mappingFileDoesNotExistError=The XML mapping file does not exist
120
JpaMakePersistentWizardPage_mappingFileDoesNotExistError=The XML mapping file does not exist
119
JpaMakePersistentWizardPage_mappingFileNotListedInPersistenceXmlError=The XML mapping file is not listed in the persistence.xml
121
JpaMakePersistentWizardPage_mappingFileNotListedInPersistenceXmlError=The XML mapping file is not listed in the persistence.xml
120
122
123
JptPreferencesPage_DoNotShowDialogs=Dialogs
124
JptPreferencesPage_DoNotShowText=Clear all 'do not show again' settings and show all hidden dialogs again.
125
JptPreferencesPage_ClearButtonText=&Clear
126
121
JpaPreferencesPage_Description=Expand the tree to edit preferences for a particular JPA feature.
127
JpaPreferencesPage_Description=Expand the tree to edit preferences for a particular JPA feature.
122
128
123
JpaProblemSeveritiesPage_Description=Select the severity level for the following optional Java Persistence validation problems:
129
JpaProblemSeveritiesPage_Description=Select the severity level for the following optional Java Persistence validation problems:
(-)property_files/jpt_ui_entity_gen.properties (-1 lines)
Lines 104-110 Link Here
104
GenerateEntitiesWizard_assocEditor_tableJoin=Table &join:
104
GenerateEntitiesWizard_assocEditor_tableJoin=Table &join:
105
GenerateEntitiesWizard_assocEditor_joinedWhen=The table rows are joined when:\n%s
105
GenerateEntitiesWizard_assocEditor_joinedWhen=The table rows are joined when:\n%s
106
GenerateEntitiesWizard_assocEditor_genAssoc=Generate &this association
106
GenerateEntitiesWizard_assocEditor_genAssoc=Generate &this association
107
GenerateEntitiesWizard_doNotShowWarning = Don't show me this warning again
108
107
109
selectCascadeDlgTitle=Select Cascade
108
selectCascadeDlgTitle=Select Cascade
110
selectTableDlgTitle=Table Selection
109
selectTableDlgTitle=Table Selection
(-)src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java (+4 lines)
Lines 49-54 Link Here
49
	public static String DatabaseSchemaWizardPage_schema;
49
	public static String DatabaseSchemaWizardPage_schema;
50
	public static String DatabaseSchemaWizardPage_connectionInfo;
50
	public static String DatabaseSchemaWizardPage_connectionInfo;
51
	public static String DatabaseSchemaWizardPage_schemaInfo;
51
	public static String DatabaseSchemaWizardPage_schemaInfo;
52
	public static String DontShowAgainDialog_doNotShowWarning;
52
	public static String Error_openingEditor;
53
	public static String Error_openingEditor;
53
	public static String General_browse;
54
	public static String General_browse;
54
	public static String General_revert;
55
	public static String General_revert;
Lines 132-137 Link Here
132
	public static String OverwriteConfirmerDialog_title;
133
	public static String OverwriteConfirmerDialog_title;
133
	public static String PersistenceItemLabelProviderFactory_persistenceLabel;
134
	public static String PersistenceItemLabelProviderFactory_persistenceLabel;
134
	public static String EntitiesGenerator_jobName;
135
	public static String EntitiesGenerator_jobName;
136
	public static String JptPreferencesPage_DoNotShowDialogs;
137
	public static String JptPreferencesPage_DoNotShowText;
138
	public static String JptPreferencesPage_ClearButtonText;
135
	public static String JpaPreferencesPage_Description;
139
	public static String JpaPreferencesPage_Description;
136
	public static String JpaProblemSeveritiesPage_Description;
140
	public static String JpaProblemSeveritiesPage_Description;
137
	public static String JpaProblemSeveritiesPage_Error;
141
	public static String JpaProblemSeveritiesPage_Error;
(-)src/org/eclipse/jpt/jpa/ui/internal/dialogs/DontShowAgainDialog.java (+67 lines)
Added Link Here
1
package org.eclipse.jpt.jpa.ui.internal.dialogs;
2
3
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
4
import org.eclipse.core.runtime.preferences.InstanceScope;
5
import org.eclipse.jface.dialogs.Dialog;
6
import org.eclipse.jpt.common.ui.JptCommonUiPlugin;
7
import org.eclipse.jpt.common.utility.internal.iterables.ArrayListIterable;
8
import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
9
import org.eclipse.swt.SWT;
10
import org.eclipse.swt.events.SelectionEvent;
11
import org.eclipse.swt.events.SelectionListener;
12
import org.eclipse.swt.layout.GridData;
13
import org.eclipse.swt.widgets.Button;
14
import org.eclipse.swt.widgets.Composite;
15
import org.eclipse.swt.widgets.Control;
16
import org.eclipse.swt.widgets.Shell;
17
18
19
/**
20
 * A <code>DontShowAgainDialog</code> is a dialog that has a check box allowing the
21
 * option to no longer show the dialog in the future.  All such dialogs should 
22
 * descend from this dialog and add a preference key for its option as a static
23
 * variable to this class.  This class provides a central location to store these
24
 * preference keys so that workspace preferences may reset all such preferences.
25
 */
26
public abstract class DontShowAgainDialog extends Dialog {
27
28
	public static final String DONT_SHOW_OVERWRITE_WARNING_DIALOG = "DONT_SHOW_OVERWRITE_WARNING_DIALOG"; //$NON-NLS-1$
29
30
	public static Iterable<String> allPreferenceKeys() {
31
		return new ArrayListIterable<String>(new String[] {DONT_SHOW_OVERWRITE_WARNING_DIALOG});
32
	}
33
	
34
	public static IEclipsePreferences getDontShowPreferences() {
35
		return InstanceScope.INSTANCE.getNode(JptCommonUiPlugin.PLUGIN_ID); 
36
	}
37
	
38
	/**
39
	 * Creates a dialog with the given parent.
40
	 * 
41
	 * @param parentShell
42
	 *            object that returns the current parent shell 
43
	 */
44
	public DontShowAgainDialog(Shell parentShell) {
45
		super(parentShell);
46
	}
47
	
48
    protected Control createDontShowControl(Composite composite) {
49
    	
50
    	final Button checkbox = new Button(composite, SWT.CHECK);
51
    	checkbox.setText(JptUiMessages.DontShowAgainDialog_doNotShowWarning);
52
    	checkbox.setSelection(false);
53
    	final IEclipsePreferences pref = getDontShowPreferences(); 
54
    	checkbox.setLayoutData(new GridData(GridData.FILL_BOTH));
55
    	checkbox.addSelectionListener(new SelectionListener (){
56
    		public void widgetDefaultSelected(SelectionEvent e) {}
57
			public void widgetSelected(SelectionEvent e) {
58
				boolean b = checkbox.getSelection();
59
                pref.putBoolean(getPreferenceKey(), b);
60
			}
61
    	});
62
    	return checkbox;
63
    }
64
65
    protected abstract String getPreferenceKey();
66
    
67
}
(-)src/org/eclipse/jpt/jpa/ui/internal/preferences/JpaPreferencesPage.java (-1 / +1 lines)
Lines 22-28 Link Here
22
import org.eclipse.ui.IWorkbenchPreferencePage;
22
import org.eclipse.ui.IWorkbenchPreferencePage;
23
23
24
/**
24
/**
25
 * This is the root of the Java Persistence preferences hierarchy in the IDE
25
 * This is the root of the JPA preferences hierarchy in the IDE
26
 * preferences dialog.
26
 * preferences dialog.
27
 * <p>
27
 * <p>
28
 * Structure:
28
 * Structure:
(-)src/org/eclipse/jpt/jpa/ui/internal/preferences/JptPerferencesPage.java (+86 lines)
Added Link Here
1
package org.eclipse.jpt.jpa.ui.internal.preferences;
2
3
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
4
import org.eclipse.jface.dialogs.IDialogConstants;
5
import org.eclipse.jface.preference.PreferencePage;
6
import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin;
7
import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
8
import org.eclipse.jpt.jpa.ui.internal.dialogs.DontShowAgainDialog;
9
import org.eclipse.swt.SWT;
10
import org.eclipse.swt.events.SelectionEvent;
11
import org.eclipse.swt.events.SelectionListener;
12
import org.eclipse.swt.layout.GridData;
13
import org.eclipse.swt.layout.GridLayout;
14
import org.eclipse.swt.widgets.Button;
15
import org.eclipse.swt.widgets.Composite;
16
import org.eclipse.swt.widgets.Control;
17
import org.eclipse.swt.widgets.Group;
18
import org.eclipse.swt.widgets.Label;
19
import org.eclipse.ui.IWorkbench;
20
import org.eclipse.ui.IWorkbenchPreferencePage;
21
22
/**
23
 * This is the root of the Java Persistence preferences hierarchy in the IDE
24
 * preferences dialog.
25
 * <p>
26
 * Structure:
27
 * <p>
28
 * Java Persistence<br>
29
 *
30
 * @version 2.2
31
 * @since 2.2
32
 */
33
public class JptPerferencesPage extends PreferencePage implements IWorkbenchPreferencePage {
34
35
	@Override
36
	protected Control createContents(Composite parent) {
37
        
38
		Composite container= new Composite(parent, SWT.NONE);
39
		GridLayout layout= new GridLayout();
40
		layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
41
		layout.marginWidth= 0;
42
		layout.verticalSpacing= convertVerticalDLUsToPixels(10);
43
		layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
44
		container.setLayout(layout);
45
46
		layout = new GridLayout();
47
		layout.numColumns= 2;
48
49
		Group dontAskGroup = new Group(container, SWT.NONE);
50
		dontAskGroup.setLayout(layout);
51
		dontAskGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
52
		dontAskGroup.setText(JptUiMessages.JptPreferencesPage_DoNotShowDialogs);
53
54
		Label label = new Label(dontAskGroup, SWT.WRAP);
55
		label.setText(JptUiMessages.JptPreferencesPage_DoNotShowText);
56
		GridData data= new GridData(GridData.FILL, GridData.CENTER, true, false);
57
		data.widthHint= convertVerticalDLUsToPixels(50);
58
		label.setLayoutData(data);
59
		
60
		Button button = new Button(dontAskGroup, SWT.PUSH);
61
		button.setText(JptUiMessages.JptPreferencesPage_ClearButtonText);
62
		button.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
63
		button.addSelectionListener(new SelectionListener() {
64
			public void widgetSelected(SelectionEvent e) {
65
				unhideAllDialogs();
66
			}
67
			public void widgetDefaultSelected(SelectionEvent e) {
68
				unhideAllDialogs();
69
			}
70
		});
71
		
72
		return container;
73
	}
74
75
	public void init(IWorkbench workbench) {
76
		setPreferenceStore(JptJpaUiPlugin.instance().getPreferenceStore());
77
	}
78
	
79
	private final void unhideAllDialogs() {
80
		Iterable<String> preferenceKeys = DontShowAgainDialog.allPreferenceKeys();
81
		for (String preferenceKey : preferenceKeys) {
82
	    	final IEclipsePreferences pref = DontShowAgainDialog.getDontShowPreferences(); 
83
            pref.putBoolean(preferenceKey, false);
84
		}
85
	}
86
}
(-)src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java (-27 / +11 lines)
Lines 12-17 Link Here
12
12
13
import java.io.File;
13
import java.io.File;
14
import java.io.IOException;
14
import java.io.IOException;
15
15
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IResourceRuleFactory;
18
import org.eclipse.core.resources.IResourceRuleFactory;
Lines 23-32 Link Here
23
import org.eclipse.core.runtime.Platform;
24
import org.eclipse.core.runtime.Platform;
24
import org.eclipse.core.runtime.Status;
25
import org.eclipse.core.runtime.Status;
25
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
26
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
26
import org.eclipse.core.runtime.preferences.InstanceScope;
27
import org.eclipse.jdt.core.IPackageFragment;
27
import org.eclipse.jdt.core.IPackageFragment;
28
import org.eclipse.jdt.core.IPackageFragmentRoot;
28
import org.eclipse.jdt.core.IPackageFragmentRoot;
29
import org.eclipse.jface.dialogs.Dialog;
30
import org.eclipse.jface.dialogs.IDialogConstants;
29
import org.eclipse.jface.dialogs.IDialogConstants;
31
import org.eclipse.jface.resource.JFaceResources;
30
import org.eclipse.jface.resource.JFaceResources;
32
import org.eclipse.jface.resource.LocalResourceManager;
31
import org.eclipse.jface.resource.LocalResourceManager;
Lines 53-65 Link Here
53
import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin;
52
import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin;
54
import org.eclipse.jpt.jpa.ui.internal.JptUiIcons;
53
import org.eclipse.jpt.jpa.ui.internal.JptUiIcons;
55
import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
54
import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
55
import org.eclipse.jpt.jpa.ui.internal.dialogs.DontShowAgainDialog;
56
import org.eclipse.osgi.util.NLS;
56
import org.eclipse.osgi.util.NLS;
57
import org.eclipse.swt.SWT;
57
import org.eclipse.swt.SWT;
58
import org.eclipse.swt.events.SelectionEvent;
59
import org.eclipse.swt.events.SelectionListener;
60
import org.eclipse.swt.layout.GridData;
58
import org.eclipse.swt.layout.GridData;
61
import org.eclipse.swt.layout.GridLayout;
59
import org.eclipse.swt.layout.GridLayout;
62
import org.eclipse.swt.widgets.Button;
63
import org.eclipse.swt.widgets.Composite;
60
import org.eclipse.swt.widgets.Composite;
64
import org.eclipse.swt.widgets.Control;
61
import org.eclipse.swt.widgets.Control;
65
import org.eclipse.swt.widgets.Display;
62
import org.eclipse.swt.widgets.Display;
Lines 73-80 Link Here
73
	
70
	
74
	public static final String HELP_CONTEXT_ID = JptJpaUiPlugin.PLUGIN_ID + ".GenerateEntitiesFromSchemaWizard"; //$NON-NLS-1$
71
	public static final String HELP_CONTEXT_ID = JptJpaUiPlugin.PLUGIN_ID + ".GenerateEntitiesFromSchemaWizard"; //$NON-NLS-1$
75
72
76
	private static final String DONT_SHOW_OVERWRITE_WARNING_DIALOG = "DONT_SHOW_OVERWRITE_WARNING_DIALOG"; //$NON-NLS-1$
77
78
	private JpaProject jpaProject;
73
	private JpaProject jpaProject;
79
74
80
	private IStructuredSelection selection;
75
	private IStructuredSelection selection;
Lines 251-258 Link Here
251
	}
246
	}
252
247
253
    public static boolean showOverwriteWarning(){
248
    public static boolean showOverwriteWarning(){
254
    	IEclipsePreferences pref = new InstanceScope().getNode(JptJpaUiPlugin.PLUGIN_ID); 
249
    	IEclipsePreferences pref = DontShowAgainDialog.getDontShowPreferences(); 
255
    	boolean ret = ! pref.getBoolean( DONT_SHOW_OVERWRITE_WARNING_DIALOG, false) ;
250
    	boolean ret = ! pref.getBoolean(DontShowAgainDialog.DONT_SHOW_OVERWRITE_WARNING_DIALOG, false) ;
256
    	return ret;
251
    	return ret;
257
    }
252
    }
258
    
253
    
Lines 312-318 Link Here
312
307
313
	// ********** overwrite dialog **********
308
	// ********** overwrite dialog **********
314
309
315
	static class OverwriteConfirmerDialog extends Dialog {
310
	static class OverwriteConfirmerDialog extends DontShowAgainDialog {
316
		private final String className;
311
		private final String className;
317
		private boolean yes = false;
312
		private boolean yes = false;
318
		private boolean yesToAll = false;
313
		private boolean yesToAll = false;
Lines 323-328 Link Here
323
			super(parent);
318
			super(parent);
324
			this.className = className;
319
			this.className = className;
325
		}
320
		}
321
		
322
		@Override
323
		protected String getPreferenceKey() {
324
			return DONT_SHOW_OVERWRITE_WARNING_DIALOG;
325
		}
326
326
327
		@Override
327
		@Override
328
		protected void configureShell(Shell shell) {
328
		protected void configureShell(Shell shell) {
Lines 344-366 Link Here
344
			
344
			
345
			return composite;
345
			return composite;
346
		}
346
		}
347
	    
347
	    	    
348
	    protected Control createDontShowControl(Composite composite) {
349
	    	final Button checkbox = new Button( composite, SWT.CHECK );
350
	    	checkbox.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_doNotShowWarning );
351
	    	checkbox.setSelection(false);
352
	    	final IEclipsePreferences pref = new InstanceScope().getNode( JptJpaUiPlugin.PLUGIN_ID); 
353
	    	checkbox.setLayoutData( new GridData(GridData.FILL_BOTH) );
354
	    	checkbox.addSelectionListener(new SelectionListener (){
355
	    		public void widgetDefaultSelected(SelectionEvent e) {}
356
				public void widgetSelected(SelectionEvent e) {
357
					boolean b = checkbox.getSelection();
358
	                pref.putBoolean( DONT_SHOW_OVERWRITE_WARNING_DIALOG, b);
359
				}
360
	    	});
361
	    	return checkbox;
362
	    }
363
	    
364
		@Override
348
		@Override
365
		protected void createButtonsForButtonBar(Composite parent) {
349
		protected void createButtonsForButtonBar(Composite parent) {
366
			this.createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false);
350
			this.createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false);

Return to bug 310876