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 965-971 Link Here
965
		<page
965
		<page
966
			id="org.eclipse.jpt.jpa.ui.preferences"
966
			id="org.eclipse.jpt.jpa.ui.preferences"
967
			name="%javaPersistenceNode"
967
			name="%javaPersistenceNode"
968
			class="org.eclipse.ui.internal.dialogs.EmptyPreferencePage"/>
968
			class="org.eclipse.jpt.jpa.ui.internal.preferences.JptPerferencesPage"/>
969
		
969
		
970
		<page
970
		<page
971
			id="org.eclipse.jpt.jpa.ui.jpaPreferences"
971
			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
OptionalMessageDialog_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=General settings for JPA development:
127
JpaPreferencesPage_description=General settings for JPA development:
122
JpaPreferencesPage_jpqlEditor=JPQL Editing
128
JpaPreferencesPage_jpqlEditor=JPQL Editing
123
JpaPreferencesPage_jpqlEditor_description=Specify the case for JPQL identifiers used with content assist.
129
JpaPreferencesPage_jpqlEditor_description=Specify the case for JPQL identifiers used with content assist.
(-)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 OptionalMessageDialog_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 135-140 Link Here
135
	public static String OverwriteConfirmerDialog_title;
136
	public static String OverwriteConfirmerDialog_title;
136
	public static String PersistenceItemLabelProviderFactory_persistenceLabel;
137
	public static String PersistenceItemLabelProviderFactory_persistenceLabel;
137
	public static String EntitiesGenerator_jobName;
138
	public static String EntitiesGenerator_jobName;
139
	public static String JptPreferencesPage_DoNotShowDialogs;
140
	public static String JptPreferencesPage_DoNotShowText;
141
	public static String JptPreferencesPage_ClearButtonText;
138
	public static String JpaPreferencesPage_description;
142
	public static String JpaPreferencesPage_description;
139
	public static String JpaPreferencesPage_jpqlEditor;
143
	public static String JpaPreferencesPage_jpqlEditor;
140
	public static String JpaPreferencesPage_jpqlEditor_description;
144
	public static String JpaPreferencesPage_jpqlEditor_description;
(-)src/org/eclipse/jpt/jpa/ui/internal/dialogs/OptionalMessageDialog.java (+107 lines)
Added Link Here
1
package org.eclipse.jpt.jpa.ui.internal.dialogs;
2
3
import org.eclipse.jdt.internal.ui.JavaPlugin;
4
import org.eclipse.jface.dialogs.IDialogConstants;
5
import org.eclipse.jface.dialogs.IDialogSettings;
6
import org.eclipse.jface.dialogs.MessageDialog;
7
import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
8
import org.eclipse.swt.SWT;
9
import org.eclipse.swt.events.SelectionAdapter;
10
import org.eclipse.swt.events.SelectionEvent;
11
import org.eclipse.swt.layout.GridData;
12
import org.eclipse.swt.widgets.Button;
13
import org.eclipse.swt.widgets.Composite;
14
import org.eclipse.swt.widgets.Control;
15
import org.eclipse.swt.widgets.Shell;
16
17
18
/**
19
 * A <code>OptionalMessageDialog</code> is a dialog that has a check box allowing the
20
 * option to no longer show the dialog in the future. 
21
 */
22
public abstract class OptionalMessageDialog extends MessageDialog {
23
24
	private static final String CHECKBOX_TEXT = JptUiMessages.OptionalMessageDialog_doNotShowWarning;
25
26
	// Dialog store id constants
27
	private static final String STORE_ID= "OptionalMessageDialog.hide."; //$NON-NLS-1$
28
29
	public static final int NOT_SHOWN= IDialogConstants.CLIENT_ID + 1;
30
31
	private final String id;
32
33
	private final String checkBoxText;
34
	
35
	/**
36
	 * Creates a dialog with the given parent.
37
	 * 
38
	 * @param parentShell
39
	 *            object that returns the current parent shell 
40
	 */
41
	public OptionalMessageDialog(String id, Shell parentShell, String dialogTitle, String dialogMessage, int dialogType, String[] buttonLabels, int defaultButtonIndex) {
42
		this(id, parentShell, dialogTitle, dialogMessage, dialogType, buttonLabels, defaultButtonIndex, CHECKBOX_TEXT);
43
	}
44
	
45
	/**
46
	 * Creates a dialog with the given parent and a checkbox with the labeled with the text in <code>checkBoxText</code>
47
	 * 
48
	 * @param parentShell
49
	 *            object that returns the current parent shell 
50
	 */	
51
	public OptionalMessageDialog(String id, Shell parentShell, String dialogTitle, String dialogMessage, int dialogType, String[] buttonLabels, int defaultButtonIndex, String checkBoxText) {
52
		super(parentShell, dialogTitle, null, dialogMessage, dialogType, buttonLabels, defaultButtonIndex);
53
		this.id = id;
54
		this.checkBoxText = checkBoxText;
55
	}
56
	
57
    @Override
58
    protected Control createCustomArea(Composite parent) {
59
    	final Button checkbox = new Button(parent, SWT.CHECK);
60
    	checkbox.setText(this.checkBoxText);
61
    	checkbox.setSelection(false);
62
    	checkbox.setLayoutData(new GridData(GridData.FILL_BOTH));
63
    	checkbox.addSelectionListener(new SelectionAdapter() {
64
			public void widgetSelected(SelectionEvent e) {
65
				setDialogEnabled(id, !((Button)e.widget).getSelection());
66
			}
67
    	});
68
    	return checkbox;
69
    }
70
71
	/**
72
	 * Returns this dialog settings
73
	 *
74
	 * @return the settings to be used
75
	 */
76
	private static IDialogSettings getDialogSettings() {
77
		IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings();
78
		settings= settings.getSection(STORE_ID);
79
		if (settings == null)
80
			settings= JavaPlugin.getDefault().getDialogSettings().addNewSection(STORE_ID);
81
		return settings;
82
	}
83
84
	/**
85
	 * Answers whether the optional dialog is enabled and should be shown.
86
	 */
87
	public static boolean isDialogEnabled(String key) {
88
		IDialogSettings settings= getDialogSettings();
89
		return !settings.getBoolean(key);
90
	}
91
92
	/**
93
	 * Sets whether the optional dialog is enabled and should be shown.
94
	 */
95
	public static void setDialogEnabled(String key, boolean isEnabled) {
96
		IDialogSettings settings= getDialogSettings();
97
		settings.put(key, !isEnabled);
98
	}
99
100
	/**
101
	 * Clears all remembered information about hidden dialogs
102
	 */
103
	public static void clearAllRememberedStates() {
104
		IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings();
105
		settings.addNewSection(STORE_ID);
106
	}
107
}
(-)src/org/eclipse/jpt/jpa/ui/internal/preferences/JpaPreferencesPage.java (-1 / +2 lines)
Lines 29-35 Link Here
29
import org.eclipse.ui.IWorkbenchPreferencePage;
29
import org.eclipse.ui.IWorkbenchPreferencePage;
30
30
31
/**
31
/**
32
 * This is the root of the Java Persistence preferences hierarchy in the IDE preferences dialog.
32
 * This is the root of the JPA preferences hierarchy in the IDE
33
 * preferences dialog.
33
 * <p>
34
 * <p>
34
 * Structure:
35
 * Structure:
35
 * <p>
36
 * <p>
(-)src/org/eclipse/jpt/jpa/ui/internal/preferences/JptPerferencesPage.java (+81 lines)
Added Link Here
1
package org.eclipse.jpt.jpa.ui.internal.preferences;
2
3
import org.eclipse.jface.dialogs.IDialogConstants;
4
import org.eclipse.jface.preference.PreferencePage;
5
import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin;
6
import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
7
import org.eclipse.jpt.jpa.ui.internal.dialogs.OptionalMessageDialog;
8
import org.eclipse.swt.SWT;
9
import org.eclipse.swt.events.SelectionEvent;
10
import org.eclipse.swt.events.SelectionListener;
11
import org.eclipse.swt.layout.GridData;
12
import org.eclipse.swt.layout.GridLayout;
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.Group;
17
import org.eclipse.swt.widgets.Label;
18
import org.eclipse.ui.IWorkbench;
19
import org.eclipse.ui.IWorkbenchPreferencePage;
20
21
/**
22
 * This is the root of the Java Persistence preferences hierarchy in the IDE
23
 * preferences dialog.
24
 * <p>
25
 * Structure:
26
 * <p>
27
 * Java Persistence<br>
28
 *
29
 * @version 2.2
30
 * @since 2.2
31
 */
32
public class JptPerferencesPage extends PreferencePage implements IWorkbenchPreferencePage {
33
34
	@Override
35
	protected Control createContents(Composite parent) {
36
        
37
		Composite container= new Composite(parent, SWT.NONE);
38
		GridLayout layout= new GridLayout();
39
		layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
40
		layout.marginWidth= 0;
41
		layout.verticalSpacing= convertVerticalDLUsToPixels(10);
42
		layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
43
		container.setLayout(layout);
44
45
		layout = new GridLayout();
46
		layout.numColumns= 2;
47
48
		Group dontAskGroup = new Group(container, SWT.NONE);
49
		dontAskGroup.setLayout(layout);
50
		dontAskGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
51
		dontAskGroup.setText(JptUiMessages.JptPreferencesPage_DoNotShowDialogs);
52
53
		Label label = new Label(dontAskGroup, SWT.WRAP);
54
		label.setText(JptUiMessages.JptPreferencesPage_DoNotShowText);
55
		GridData data= new GridData(GridData.FILL, GridData.CENTER, true, false);
56
		data.widthHint= convertVerticalDLUsToPixels(50);
57
		label.setLayoutData(data);
58
		
59
		Button button = new Button(dontAskGroup, SWT.PUSH);
60
		button.setText(JptUiMessages.JptPreferencesPage_ClearButtonText);
61
		button.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
62
		button.addSelectionListener(new SelectionListener() {
63
			public void widgetSelected(SelectionEvent e) {
64
				unhideAllDialogs();
65
			}
66
			public void widgetDefaultSelected(SelectionEvent e) {
67
				unhideAllDialogs();
68
			}
69
		});
70
		
71
		return container;
72
	}
73
74
	public void init(IWorkbench workbench) {
75
		setPreferenceStore(JptJpaUiPlugin.instance().getPreferenceStore());
76
	}
77
	
78
	private final void unhideAllDialogs() {
79
		OptionalMessageDialog.clearAllRememberedStates();
80
	}
81
}
(-)src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java (-58 / +18 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 22-33 Link Here
22
import org.eclipse.core.runtime.IStatus;
23
import org.eclipse.core.runtime.IStatus;
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.InstanceScope;
27
import org.eclipse.jdt.core.IPackageFragment;
26
import org.eclipse.jdt.core.IPackageFragment;
28
import org.eclipse.jdt.core.IPackageFragmentRoot;
27
import org.eclipse.jdt.core.IPackageFragmentRoot;
29
import org.eclipse.jface.dialogs.Dialog;
30
import org.eclipse.jface.dialogs.IDialogConstants;
28
import org.eclipse.jface.dialogs.IDialogConstants;
29
import org.eclipse.jface.dialogs.MessageDialog;
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;
33
import org.eclipse.jface.resource.ResourceManager;
32
import org.eclipse.jface.resource.ResourceManager;
Lines 53-69 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.OptionalMessageDialog;
56
import org.eclipse.osgi.util.NLS;
56
import org.eclipse.osgi.util.NLS;
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;
61
import org.eclipse.swt.layout.GridLayout;
62
import org.eclipse.swt.widgets.Button;
63
import org.eclipse.swt.widgets.Composite;
57
import org.eclipse.swt.widgets.Composite;
64
import org.eclipse.swt.widgets.Control;
65
import org.eclipse.swt.widgets.Display;
58
import org.eclipse.swt.widgets.Display;
66
import org.eclipse.swt.widgets.Label;
67
import org.eclipse.swt.widgets.Shell;
59
import org.eclipse.swt.widgets.Shell;
68
import org.eclipse.ui.INewWizard;
60
import org.eclipse.ui.INewWizard;
69
import org.eclipse.ui.IWorkbench;
61
import org.eclipse.ui.IWorkbench;
Lines 73-80 Link Here
73
	
65
	
74
	public static final String HELP_CONTEXT_ID = JptJpaUiPlugin.PLUGIN_ID + ".GenerateEntitiesFromSchemaWizard"; //$NON-NLS-1$
66
	public static final String HELP_CONTEXT_ID = JptJpaUiPlugin.PLUGIN_ID + ".GenerateEntitiesFromSchemaWizard"; //$NON-NLS-1$
75
67
76
	private static final String DONT_SHOW_OVERWRITE_WARNING_DIALOG = "DONT_SHOW_OVERWRITE_WARNING_DIALOG"; //$NON-NLS-1$
77
78
	private JpaProject jpaProject;
68
	private JpaProject jpaProject;
79
69
80
	private IStructuredSelection selection;
70
	private IStructuredSelection selection;
Lines 251-259 Link Here
251
	}
241
	}
252
242
253
    public static boolean showOverwriteWarning(){
243
    public static boolean showOverwriteWarning(){
254
    	IEclipsePreferences pref = new InstanceScope().getNode(JptJpaUiPlugin.PLUGIN_ID); 
244
    	return OptionalMessageDialog.isDialogEnabled(OverwriteConfirmerDialog.ID);
255
    	boolean ret = ! pref.getBoolean( DONT_SHOW_OVERWRITE_WARNING_DIALOG, false) ;
256
    	return ret;
257
    }
245
    }
258
    
246
    
259
    // ********** overwrite confirmer **********
247
    // ********** overwrite confirmer **********
Lines 312-366 Link Here
312
300
313
	// ********** overwrite dialog **********
301
	// ********** overwrite dialog **********
314
302
315
	static class OverwriteConfirmerDialog extends Dialog {
303
	static class OverwriteConfirmerDialog extends OptionalMessageDialog {
316
		private final String className;
317
		private boolean yes = false;
304
		private boolean yes = false;
318
		private boolean yesToAll = false;
305
		private boolean yesToAll = false;
319
		private boolean no = false;
306
		private boolean no = false;
320
		private boolean noToAll = false;
307
		private boolean noToAll = false;
321
308
322
		OverwriteConfirmerDialog(Shell parent, String className) {
309
		private static final String ID= "dontShowOverwrite.warning"; //$NON-NLS-1$
323
			super(parent);
324
			this.className = className;
325
		}
326
310
327
		@Override
311
		OverwriteConfirmerDialog(Shell parent, String className) {
328
		protected void configureShell(Shell shell) {
312
			super(ID, parent,
329
			super.configureShell(shell);
313
					JptUiMessages.OverwriteConfirmerDialog_title,
330
			shell.setText(JptUiMessages.OverwriteConfirmerDialog_title);
314
					NLS.bind(JptUiMessages.OverwriteConfirmerDialog_text, className),
315
					MessageDialog.WARNING,
316
					new String[] {IDialogConstants.YES_LABEL, 
317
									IDialogConstants.YES_TO_ALL_LABEL, 
318
									IDialogConstants.NO_LABEL, 
319
									IDialogConstants.NO_TO_ALL_LABEL, 
320
									IDialogConstants.CANCEL_LABEL},
321
					2);
331
		}
322
		}
332
323
		
333
		@Override
334
		protected Control createDialogArea(Composite parent) {
335
			Composite composite = (Composite) super.createDialogArea(parent);
336
			GridLayout gridLayout = (GridLayout) composite.getLayout();
337
			gridLayout.numColumns = 1;
338
339
			Label text = new Label(composite, SWT.LEFT);
340
			text.setText(NLS.bind(JptUiMessages.OverwriteConfirmerDialog_text, this.className));
341
			text.setLayoutData(new GridData());
342
			
343
			createDontShowControl(composite);
344
			
345
			return composite;
346
		}
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
324
		@Override
365
		protected void createButtonsForButtonBar(Composite parent) {
325
		protected void createButtonsForButtonBar(Composite parent) {
366
			this.createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false);
326
			this.createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false);

Return to bug 310876