[310876] [321736] - Add "do not show again" option on applicable Dali dialogs, and provide a way to clear these messages. Patch from Les.
diff --git a/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF
index f804cd4..3e73642 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF
+++ b/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF
@@ -29,6 +29,10 @@
x-friends:="org.eclipse.jpt.jaxb.ui,
org.eclipse.jpt.jpa.db.ui,
org.eclipse.jpt.jpa.ui",
+ org.eclipse.jpt.common.ui.internal.dialogs;
+ x-friends:="org.eclipse.jpt.jaxb.ui,
+ org.eclipse.jpt.jpa.db.ui,
+ org.eclipse.jpt.jpa.ui",
org.eclipse.jpt.common.ui.internal.jface;
x-friends:="org.eclipse.jpt.jaxb.ui,
org.eclipse.jpt.jpa.db.ui,
diff --git a/common/plugins/org.eclipse.jpt.common.ui/property_files/jpt_common_ui.properties b/common/plugins/org.eclipse.jpt.common.ui/property_files/jpt_common_ui.properties
index aee4769..dd48cc6 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/property_files/jpt_common_ui.properties
+++ b/common/plugins/org.eclipse.jpt.common.ui/property_files/jpt_common_ui.properties
@@ -26,3 +26,5 @@
EnumComboViewer_defaultWithDefault=Default ({0})
NewNameStateObject_nameMustBeSpecified=A name must be specified.
NewNameStateObject_nameAlreadyExists=A query with this name already exists.
+
+OptionalMessageDialog_doNotShowWarning=Do not show this &message again
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/JptCommonUiMessages.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/JptCommonUiMessages.java
index 31a1080..75e1433 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/JptCommonUiMessages.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/JptCommonUiMessages.java
@@ -39,6 +39,8 @@
public static String EnumComboViewer_defaultWithDefault;
public static String NewNameStateObject_nameAlreadyExists;
public static String NewNameStateObject_nameMustBeSpecified;
+
+ public static String OptionalMessageDialog_doNotShowWarning;
private static final String BUNDLE_NAME = "jpt_common_ui"; //$NON-NLS-1$
private static final Class<?> BUNDLE_CLASS = JptCommonUiMessages.class;
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/dialogs/OptionalMessageDialog.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/dialogs/OptionalMessageDialog.java
new file mode 100644
index 0000000..bf281fc
--- /dev/null
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/dialogs/OptionalMessageDialog.java
@@ -0,0 +1,107 @@
+package org.eclipse.jpt.common.ui.internal.dialogs;
+
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * A <code>OptionalMessageDialog</code> is a dialog that has a check box allowing the
+ * option to no longer show the dialog in the future.
+ */
+public abstract class OptionalMessageDialog extends MessageDialog {
+
+ private static final String CHECKBOX_TEXT = JptCommonUiMessages.OptionalMessageDialog_doNotShowWarning;
+
+ // Dialog store id constants
+ private static final String STORE_ID = "OptionalMessageDialog.hide."; //$NON-NLS-1$
+
+ public static final int NOT_SHOWN = IDialogConstants.CLIENT_ID + 1;
+
+ private final String id;
+
+ private final String checkBoxText;
+
+ /**
+ * Creates a dialog with the given parent.
+ *
+ * @param parentShell
+ * object that returns the current parent shell
+ */
+ public OptionalMessageDialog(String id, Shell parentShell, String dialogTitle, String dialogMessage, int dialogType, String[] buttonLabels, int defaultButtonIndex) {
+ this(id, parentShell, dialogTitle, dialogMessage, dialogType, buttonLabels, defaultButtonIndex, CHECKBOX_TEXT);
+ }
+
+ /**
+ * Creates a dialog with the given parent and a checkbox with the labeled with the text in <code>checkBoxText</code>
+ *
+ * @param parentShell
+ * object that returns the current parent shell
+ */
+ public OptionalMessageDialog(String id, Shell parentShell, String dialogTitle, String dialogMessage, int dialogType, String[] buttonLabels, int defaultButtonIndex, String checkBoxText) {
+ super(parentShell, dialogTitle, null, dialogMessage, dialogType, buttonLabels, defaultButtonIndex);
+ this.id = id;
+ this.checkBoxText = checkBoxText;
+ }
+
+ @Override
+ protected Control createCustomArea(Composite parent) {
+ final Button checkbox = new Button(parent, SWT.CHECK);
+ checkbox.setText(this.checkBoxText);
+ checkbox.setSelection(false);
+ checkbox.setLayoutData(new GridData(GridData.FILL_BOTH));
+ checkbox.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ setDialogEnabled(id, !((Button)e.widget).getSelection());
+ }
+ });
+ return checkbox;
+ }
+
+ /**
+ * Returns this dialog settings
+ *
+ * @return the settings to be used
+ */
+ private static IDialogSettings getDialogSettings() {
+ IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings();
+ settings= settings.getSection(STORE_ID);
+ if (settings == null)
+ settings= JavaPlugin.getDefault().getDialogSettings().addNewSection(STORE_ID);
+ return settings;
+ }
+
+ /**
+ * Answers whether the optional dialog is enabled and should be shown.
+ */
+ public static boolean isDialogEnabled(String key) {
+ IDialogSettings settings= getDialogSettings();
+ return !settings.getBoolean(key);
+ }
+
+ /**
+ * Sets whether the optional dialog is enabled and should be shown.
+ */
+ public static void setDialogEnabled(String key, boolean isEnabled) {
+ IDialogSettings settings= getDialogSettings();
+ settings.put(key, !isEnabled);
+ }
+
+ /**
+ * Clears all remembered information about hidden dialogs
+ */
+ public static void clearAllRememberedStates() {
+ IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings();
+ settings.addNewSection(STORE_ID);
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties
index b974d28..4f9963d 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties
@@ -122,7 +122,7 @@
ClassesGeneratorUi_generatingClassesWarningTitle = Generating JAXB Classes
ClassesGeneratorUi_generatingClassesWarningMessage = \
Warning: Generating classes will overwrite existing files in your project.\
- \n\nAre you sure you want to continue?
+ \nAre you sure you want to continue?
# SchemaGenerator
SchemaGeneratorWizard_title = New JAXB Schema File
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/ClassesGeneratorUi.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/ClassesGeneratorUi.java
index 090e0ab..dea60c6 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/ClassesGeneratorUi.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/ClassesGeneratorUi.java
@@ -16,9 +16,11 @@
import org.eclipse.emf.common.util.URI;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jpt.common.ui.internal.dialogs.OptionalMessageDialog;
import org.eclipse.jpt.jaxb.core.JaxbProject;
import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
import org.eclipse.jpt.jaxb.core.SchemaLibrary;
@@ -28,6 +30,7 @@
import org.eclipse.jpt.jaxb.core.xsd.XsdUtil;
import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin;
import org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen.ClassesGeneratorWizard;
+import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.wst.xsd.contentmodel.internal.XSDImpl;
@@ -76,7 +79,7 @@
return;
}
- if(this.displayOverridingClassesWarning(wizard.getGeneratorOptions())) {
+ if(this.displayOverwritingClassesWarning(wizard.getGeneratorOptions())) {
this.generateJaxbClasses(
wizard.getLocalSchemaUri(),
wizard.getDestinationFolder(),
@@ -174,7 +177,7 @@
return JptJaxbCorePlugin.getJaxbProject(this.javaProject.getProject());
}
- private boolean isOverridingClasses(ClassesGeneratorOptions generatorOptions) {
+ private boolean isOverwritingClasses(ClassesGeneratorOptions generatorOptions) {
if(generatorOptions == null) {
throw new NullPointerException();
}
@@ -184,18 +187,42 @@
return true;
}
- private boolean displayOverridingClassesWarning(ClassesGeneratorOptions generatorOptions) {
+ private boolean displayOverwritingClassesWarning(ClassesGeneratorOptions generatorOptions) {
- if( ! this.isOverridingClasses(generatorOptions)) {
+ if( ! this.isOverwritingClasses(generatorOptions)
+ || !OptionalMessageDialog.isDialogEnabled(OverwriteConfirmerDialog.ID)) {
return true;
+ }else {
+ OverwriteConfirmerDialog dialog = new OverwriteConfirmerDialog(this.getShell());
+ return dialog.open() == IDialogConstants.YES_ID;
}
- return MessageDialog.openQuestion(
- this.getCurrentShell(),
- JptJaxbUiMessages.ClassesGeneratorUi_generatingClassesWarningTitle,
- JptJaxbUiMessages.ClassesGeneratorUi_generatingClassesWarningMessage);
}
private Shell getCurrentShell() {
return Display.getCurrent().getActiveShell();
}
+
+ // ********** overwrite dialog **********
+
+ static class OverwriteConfirmerDialog extends OptionalMessageDialog {
+
+ private static final String ID= "dontShowOverwriteJaxbClassesFromSchemas.warning"; //$NON-NLS-1$
+
+ OverwriteConfirmerDialog(Shell parent) {
+ super(ID, parent,
+ JptJaxbUiMessages.ClassesGeneratorUi_generatingClassesWarningTitle,
+ JptJaxbUiMessages.ClassesGeneratorUi_generatingClassesWarningMessage,
+ MessageDialog.WARNING,
+ new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL},
+ 1);
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ this.createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false);
+ this.createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true);
+ }
+
+ }
+
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java
index 364abbb..51b07c3 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java
@@ -21,10 +21,12 @@
import org.eclipse.emf.common.util.URI;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.jpt.common.ui.internal.dialogs.OptionalMessageDialog;
import org.eclipse.jpt.common.ui.internal.wizards.JavaProjectWizardPage;
import org.eclipse.jpt.jaxb.core.JaxbProject;
import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
@@ -37,6 +39,8 @@
import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons;
import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWizard;
import org.eclipse.wst.xsd.contentmodel.internal.XSDImpl;
@@ -156,7 +160,7 @@
}
if (this.performsGeneration) {
- if (displayOverridingClassesWarning(this.generatorOptions)) {
+ if (displayOverwritingClassesWarning(this.generatorOptions)) {
generateJaxbClasses();
addSchemaToLibrary();
}
@@ -268,15 +272,15 @@
return (IJavaProject)((IJavaElement)((IAdaptable)project).getAdapter(IJavaElement.class));
}
- private boolean displayOverridingClassesWarning(ClassesGeneratorOptions generatorOptions) {
+ private boolean displayOverwritingClassesWarning(ClassesGeneratorOptions generatorOptions) {
- if( ! this.isOverridingClasses(generatorOptions)) {
+ if( ! this.isOverridingClasses(generatorOptions)
+ || !OptionalMessageDialog.isDialogEnabled(OverwriteConfirmerDialog.ID)) {
return true;
+ } else {
+ OverwriteConfirmerDialog dialog = new OverwriteConfirmerDialog(this.getShell());
+ return dialog.open() == IDialogConstants.YES_ID;
}
- return MessageDialog.openQuestion(
- this.getShell(),
- JptJaxbUiMessages.ClassesGeneratorUi_generatingClassesWarningTitle,
- JptJaxbUiMessages.ClassesGeneratorUi_generatingClassesWarningMessage);
}
private boolean isOverridingClasses(ClassesGeneratorOptions generatorOptions) {
@@ -402,4 +406,26 @@
message
);
}
+
+ static class OverwriteConfirmerDialog extends OptionalMessageDialog {
+
+ private static final String ID= "dontShowOverwriteJaxbClassesFromSchemas.warning"; //$NON-NLS-1$
+
+ OverwriteConfirmerDialog(Shell parent) {
+ super(ID, parent,
+ JptJaxbUiMessages.ClassesGeneratorUi_generatingClassesWarningTitle,
+ JptJaxbUiMessages.ClassesGeneratorUi_generatingClassesWarningMessage,
+ MessageDialog.WARNING,
+ new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL},
+ 1);
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ this.createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false);
+ this.createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true);
+ }
+
+ }
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java
index 7641ab1..4f9550b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java
@@ -16,9 +16,11 @@
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jpt.common.ui.internal.dialogs.OptionalMessageDialog;
import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
@@ -31,6 +33,8 @@
import org.eclipse.jpt.jpa.eclipselink.ui.JptJpaEclipseLinkUiPlugin;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.ddlgen.wizards.GenerateDDLWizard;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
@@ -91,14 +95,12 @@
}
private boolean displayGeneratingDDLWarning() {
- String message = org.eclipse.osgi.util.NLS.bind(
- EclipseLinkUiMessages.EclipseLinkDDLGeneratorUi_generatingDDLWarningMessage,
- CR, CR + CR);
-
- return MessageDialog.openQuestion(
- this.getCurrentShell(),
- EclipseLinkUiMessages.EclipseLinkDDLGeneratorUi_generatingDDLWarningTitle,
- message);
+ if (!OptionalMessageDialog.isDialogEnabled(OverwriteConfirmerDialog.ID)) {
+ return true;
+ } else {
+ OverwriteConfirmerDialog dialog = new OverwriteConfirmerDialog(this.getCurrentShell());
+ return dialog.open() == IDialogConstants.YES_ID;
+ }
}
// ********** Persistence Unit **********
@@ -179,4 +181,26 @@
}
}
+ // ********** overwrite dialog **********
+
+ static class OverwriteConfirmerDialog extends OptionalMessageDialog {
+
+ private static final String ID= "dontShowOverwriteExistingTablesFromClasses.warning"; //$NON-NLS-1$
+
+ OverwriteConfirmerDialog(Shell parent) {
+ super(ID, parent,
+ EclipseLinkUiMessages.EclipseLinkDDLGeneratorUi_generatingDDLWarningTitle,
+ NLS.bind(EclipseLinkUiMessages.EclipseLinkDDLGeneratorUi_generatingDDLWarningMessage, CR, CR + CR),
+ MessageDialog.WARNING,
+ new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL},
+ 1);
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ this.createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false);
+ this.createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true);
+ }
+
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml b/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml
index 1064c87..b787030 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml
@@ -965,7 +965,7 @@
<page
id="org.eclipse.jpt.jpa.ui.preferences"
name="%javaPersistenceNode"
- class="org.eclipse.ui.internal.dialogs.EmptyPreferencePage"/>
+ class="org.eclipse.jpt.jpa.ui.internal.preferences.JptPreferencesPage"/>
<page
id="org.eclipse.jpt.jpa.ui.jpaPreferences"
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui.properties b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui.properties
index bfcc8b2..fbbdd9b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui.properties
@@ -119,6 +119,10 @@
JpaMakePersistentWizardPage_mappingFileDoesNotExistError=The XML mapping file does not exist
JpaMakePersistentWizardPage_mappingFileNotListedInPersistenceXmlError=The XML mapping file is not listed in the persistence.xml
+JptPreferencesPage_DoNotShowDialogs=Dialogs
+JptPreferencesPage_DoNotShowText=Clear all 'do not show again' settings and show all hidden dialogs again.
+JptPreferencesPage_ClearButtonText=&Clear
+
JpaPreferencesPage_description=General settings for JPA development:
JpaPreferencesPage_jpqlEditor=JPQL Editing
JpaPreferencesPage_jpqlEditor_description=Specify the case for JPQL identifiers used with content assist.
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_entity_gen.properties b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_entity_gen.properties
index 03ef64a..342cb08 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_entity_gen.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_entity_gen.properties
@@ -109,7 +109,6 @@
GenerateEntitiesWizard_assocEditor_tableJoin=Table &join:
GenerateEntitiesWizard_assocEditor_joinedWhen=The table rows are joined when:\n%s
GenerateEntitiesWizard_assocEditor_genAssoc=Generate &this association
-GenerateEntitiesWizard_doNotShowWarning = Don't show me this warning again
selectCascadeDlgTitle=Select Cascade
selectTableDlgTitle=Table Selection
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java
index 1eb5270..b589038 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java
@@ -136,6 +136,9 @@
public static String OverwriteConfirmerDialog_title;
public static String PersistenceItemLabelProviderFactory_persistenceLabel;
public static String EntitiesGenerator_jobName;
+ public static String JptPreferencesPage_DoNotShowDialogs;
+ public static String JptPreferencesPage_DoNotShowText;
+ public static String JptPreferencesPage_ClearButtonText;
public static String JpaPreferencesPage_description;
public static String JpaPreferencesPage_jpqlEditor;
public static String JpaPreferencesPage_jpqlEditor_description;
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/preferences/JpaPreferencesPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/preferences/JpaPreferencesPage.java
index 323950f..70a770c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/preferences/JpaPreferencesPage.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/preferences/JpaPreferencesPage.java
@@ -29,7 +29,8 @@
import org.eclipse.ui.IWorkbenchPreferencePage;
/**
- * This is the root of the Java Persistence preferences hierarchy in the IDE preferences dialog.
+ * This is the root of the JPA preferences hierarchy in the IDE
+ * preferences dialog.
* <p>
* Structure:
* <p>
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/preferences/JptPreferencesPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/preferences/JptPreferencesPage.java
new file mode 100644
index 0000000..f3ca65d
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/preferences/JptPreferencesPage.java
@@ -0,0 +1,81 @@
+package org.eclipse.jpt.jpa.ui.internal.preferences;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jpt.common.ui.internal.dialogs.OptionalMessageDialog;
+import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin;
+import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * This is the root of the Java Persistence preferences hierarchy in the IDE
+ * preferences dialog.
+ * <p>
+ * Structure:
+ * <p>
+ * Java Persistence<br>
+ *
+ * @version 2.2
+ * @since 2.2
+ */
+public class JptPreferencesPage extends PreferencePage implements IWorkbenchPreferencePage {
+
+ @Override
+ protected Control createContents(Composite parent) {
+
+ Composite container= new Composite(parent, SWT.NONE);
+ GridLayout layout= new GridLayout();
+ layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth= 0;
+ layout.verticalSpacing= convertVerticalDLUsToPixels(10);
+ layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ container.setLayout(layout);
+
+ layout = new GridLayout();
+ layout.numColumns= 2;
+
+ Group dontAskGroup = new Group(container, SWT.NONE);
+ dontAskGroup.setLayout(layout);
+ dontAskGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ dontAskGroup.setText(JptUiMessages.JptPreferencesPage_DoNotShowDialogs);
+
+ Label label = new Label(dontAskGroup, SWT.WRAP);
+ label.setText(JptUiMessages.JptPreferencesPage_DoNotShowText);
+ GridData data= new GridData(GridData.FILL, GridData.CENTER, true, false);
+ data.widthHint= convertVerticalDLUsToPixels(50);
+ label.setLayoutData(data);
+
+ Button button = new Button(dontAskGroup, SWT.PUSH);
+ button.setText(JptUiMessages.JptPreferencesPage_ClearButtonText);
+ button.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ unhideAllDialogs();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ unhideAllDialogs();
+ }
+ });
+
+ return container;
+ }
+
+ public void init(IWorkbench workbench) {
+ setPreferenceStore(JptJpaUiPlugin.instance().getPreferenceStore());
+ }
+
+ private final void unhideAllDialogs() {
+ OptionalMessageDialog.clearAllRememberedStates();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java
index 116dd01..2dd1e3c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java
@@ -12,6 +12,7 @@
import java.io.File;
import java.io.IOException;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceRuleFactory;
@@ -22,12 +23,10 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.LocalResourceManager;
import org.eclipse.jface.resource.ResourceManager;
@@ -36,6 +35,7 @@
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jpt.common.core.internal.utility.JDTTools;
+import org.eclipse.jpt.common.ui.internal.dialogs.OptionalMessageDialog;
import org.eclipse.jpt.jpa.core.EntityGeneratorDatabaseAnnotationNameBuilder;
import org.eclipse.jpt.jpa.core.JpaPlatform;
import org.eclipse.jpt.jpa.core.JpaProject;
@@ -54,16 +54,8 @@
import org.eclipse.jpt.jpa.ui.internal.JptUiIcons;
import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
@@ -73,8 +65,6 @@
public static final String HELP_CONTEXT_ID = JptJpaUiPlugin.PLUGIN_ID + ".GenerateEntitiesFromSchemaWizard"; //$NON-NLS-1$
- private static final String DONT_SHOW_OVERWRITE_WARNING_DIALOG = "DONT_SHOW_OVERWRITE_WARNING_DIALOG"; //$NON-NLS-1$
-
private JpaProject jpaProject;
private IStructuredSelection selection;
@@ -251,9 +241,7 @@
}
public static boolean showOverwriteWarning(){
- IEclipsePreferences pref = new InstanceScope().getNode(JptJpaUiPlugin.PLUGIN_ID);
- boolean ret = ! pref.getBoolean( DONT_SHOW_OVERWRITE_WARNING_DIALOG, false) ;
- return ret;
+ return OptionalMessageDialog.isDialogEnabled(OverwriteConfirmerDialog.ID);
}
// ********** overwrite confirmer **********
@@ -312,55 +300,27 @@
// ********** overwrite dialog **********
- static class OverwriteConfirmerDialog extends Dialog {
- private final String className;
+ static class OverwriteConfirmerDialog extends OptionalMessageDialog {
private boolean yes = false;
private boolean yesToAll = false;
private boolean no = false;
private boolean noToAll = false;
+ private static final String ID= "dontShowOverwriteEntitesFromSchemas.warning"; //$NON-NLS-1$
+
OverwriteConfirmerDialog(Shell parent, String className) {
- super(parent);
- this.className = className;
+ super(ID, parent,
+ JptUiMessages.OverwriteConfirmerDialog_title,
+ NLS.bind(JptUiMessages.OverwriteConfirmerDialog_text, className),
+ MessageDialog.WARNING,
+ new String[] {IDialogConstants.YES_LABEL,
+ IDialogConstants.YES_TO_ALL_LABEL,
+ IDialogConstants.NO_LABEL,
+ IDialogConstants.NO_TO_ALL_LABEL,
+ IDialogConstants.CANCEL_LABEL},
+ 2);
}
-
- @Override
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(JptUiMessages.OverwriteConfirmerDialog_title);
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- GridLayout gridLayout = (GridLayout) composite.getLayout();
- gridLayout.numColumns = 1;
-
- Label text = new Label(composite, SWT.LEFT);
- text.setText(NLS.bind(JptUiMessages.OverwriteConfirmerDialog_text, this.className));
- text.setLayoutData(new GridData());
-
- createDontShowControl(composite);
-
- return composite;
- }
-
- protected Control createDontShowControl(Composite composite) {
- final Button checkbox = new Button( composite, SWT.CHECK );
- checkbox.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_doNotShowWarning );
- checkbox.setSelection(false);
- final IEclipsePreferences pref = new InstanceScope().getNode( JptJpaUiPlugin.PLUGIN_ID);
- checkbox.setLayoutData( new GridData(GridData.FILL_BOTH) );
- checkbox.addSelectionListener(new SelectionListener (){
- public void widgetDefaultSelected(SelectionEvent e) {}
- public void widgetSelected(SelectionEvent e) {
- boolean b = checkbox.getSelection();
- pref.putBoolean( DONT_SHOW_OVERWRITE_WARNING_DIALOG, b);
- }
- });
- return checkbox;
- }
-
+
@Override
protected void createButtonsForButtonBar(Composite parent) {
this.createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false);