diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/OptionalMessageDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/OptionalMessageDialog.java index 209157f6e3b..ab1c4049ca1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/OptionalMessageDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/OptionalMessageDialog.java @@ -11,6 +11,9 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.dialogs; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -22,10 +25,6 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.dialogs.MessageDialog; - import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.CUIMessages; @@ -35,14 +34,15 @@ import org.eclipse.cdt.internal.ui.CUIMessages; * to choose that the dialog isn't shown again the next time. */ public class OptionalMessageDialog extends MessageDialog { - // String constants for widgets private static final String CHECKBOX_TEXT= CUIMessages.OptionalMessageDialog_dontShowAgain; // Dialog store id constants private static final String STORE_ID= "OptionalMessageDialog.hide."; //$NON-NLS-1$ + private static final String KEY_DETAIL = ".detail"; //$NON-NLS-1$ public static final int NOT_SHOWN= IDialogConstants.CLIENT_ID + 1; + public static final int NO_DETAIL= -1; private Button fHideDialogCheckBox; private String fId; @@ -109,6 +109,26 @@ public class OptionalMessageDialog extends MessageDialog { return !settings.getBoolean(key); } + /** + * Sets a detail for the dialog. + */ + public static void setDialogDetail(String key, int detail) { + IDialogSettings settings= getDialogSettings(); + settings.put(key+KEY_DETAIL, detail); + } + + /** + * Returns the detail for this dialog, or NO_DETAIL, if none. + */ + public static int getDialogDetail(String key) { + IDialogSettings settings= getDialogSettings(); + try { + return settings.getInt(key+KEY_DETAIL); + } catch (NumberFormatException e) { + return NO_DETAIL; + } + } + /** * Sets whether the optional dialog is enabled and should be shown. */ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java index 29b72ab58db..5f5ddae64d8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java @@ -12,11 +12,14 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.preferences; +import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -35,7 +38,9 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.internal.ui.ICHelpContextIds; +import org.eclipse.cdt.internal.ui.dialogs.OptionalMessageDialog; import org.eclipse.cdt.internal.ui.util.PixelConverter; +import org.eclipse.cdt.internal.ui.util.SWTUtil; /** * The page for general C/C++ preferences. @@ -148,6 +153,34 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements gd2 = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd2.verticalIndent = GROUP_VINDENT; noteControl.setLayoutData(gd2); + + GridLayout layout = new GridLayout(); + layout.numColumns= 2; + + Group dontAskGroup= new Group(parent, SWT.NONE); + dontAskGroup.setLayout(layout); + dontAskGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + dontAskGroup.setText(PreferencesMessages.CPluginPreferencePage_cdtDialogs_group); + + Label label= new Label(dontAskGroup, SWT.WRAP); + label.setText(PreferencesMessages.CPluginPreferencePage_clearDoNotShowAgainSettings_label); + GridData data= new GridData(GridData.FILL, GridData.CENTER, true, false); + data.widthHint= convertVerticalDLUsToPixels(50); + label.setLayoutData(data); + + Button clearButton= new Button(dontAskGroup, SWT.PUSH); + clearButton.setText(PreferencesMessages.CPluginPreferencePage_clear_button); + clearButton.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false)); + clearButton.addSelectionListener(new SelectionListener() { + public void widgetSelected(SelectionEvent e) { + OptionalMessageDialog.clearAllRememberedStates(); + } + public void widgetDefaultSelected(SelectionEvent e) { + OptionalMessageDialog.clearAllRememberedStates(); + } + }); + SWTUtil.setButtonDimensionHint(clearButton); + Dialog.applyDialogFont(parent); } @Override protected Composite createNoteComposite(Font font, Composite composite, diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java index 56398c741a2..92efa6b1e90 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java @@ -298,6 +298,9 @@ public final class PreferencesMessages extends NLS { public static String CPluginPreferencePage_6; public static String CPluginPreferencePage_7; public static String CPluginPreferencePage_caption; + public static String CPluginPreferencePage_cdtDialogs_group; + public static String CPluginPreferencePage_clear_button; + public static String CPluginPreferencePage_clearDoNotShowAgainSettings_label; public static String CPluginPreferencePage_structuralParseMode_label; public static String CPluginPreferencePage_note; public static String CPluginPreferencePage_performanceHint; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties index ec1e8400f64..70888aa5123 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties @@ -336,6 +336,9 @@ CPluginPreferencePage_5=Building project dependencies CPluginPreferencePage_6=Projects with dependencies will still be build regardless CPluginPreferencePage_7=Build referenced projects only when there are Eclipse qresource changes within the projects CPluginPreferencePage_caption= General settings for C/C++ Development: +CPluginPreferencePage_cdtDialogs_group=CDT Dialogs +CPluginPreferencePage_clear_button=Clear +CPluginPreferencePage_clearDoNotShowAgainSettings_label=Clear all 'do not show again' settings and show all hidden dialogs again CPluginPreferencePage_structuralParseMode_label= &Follow unindexed header files when producing the outline view CPluginPreferencePage_note= Note: CPluginPreferencePage_performanceHint= Enabling this preference may have negative impact on performance. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java index 1668e1c9692..874812e16ca 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java @@ -88,6 +88,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { protected ArrayList exported; protected SashForm sashForm; protected ICLanguageSetting [] ls; // all languages known + private boolean fHadSomeModification; protected final static String[] BUTTONS = {ADD_STR, EDIT_STR, DEL_STR, UIMessages.getString("AbstractLangsListTab.2"), //$NON-NLS-1$ @@ -407,6 +408,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { private void performAdd(ICLanguageSettingEntry ent) { if (ent != null) { + fHadSomeModification= true; if ((toAllCfgs || toAllLang) && ! (getResDesc() instanceof ICMultiResourceDescription)) { addToAll(ent); } else { @@ -465,6 +467,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { ICLanguageSettingEntry ent = doEdit(old); toAllLang = false; if (ent != null) { + fHadSomeModification= true; if (isWModifyMode() && (lang instanceof MultiLanguageSetting)) { performMulti(ent, old); } else { @@ -479,6 +482,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { private void performDelete(int n) { if (n == -1) return; + fHadSomeModification= true; int[] ids = table.getSelectionIndices(); if (isWModifyMode() && (lang instanceof MultiLanguageSetting)) { for (int x=ids.length-1; x>=0; x--) { @@ -607,6 +611,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { @Override protected void performApply(ICResourceDescription src, ICResourceDescription dst) { + fHadSomeModification= false; if (page.isMultiCfg()) { ICLanguageSetting [] sr = ls; if (dst instanceof ICMultiItemsHolder) { @@ -636,6 +641,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { @Override protected void performDefaults() { + fHadSomeModification= true; TreeItem[] tis = langTree.getItems(); for (int i=0; i it = itabs.iterator(); + while(it.hasNext()) { + InternalTab tab = it.next(); + if (tab != null) { + ICPropertyTab tabtab = tab.tab; + if (tabtab instanceof AbstractLangsListTab) { + final AbstractLangsListTab langListTab = (AbstractLangsListTab) tabtab; + switch(langListTab.getKind()) { + case ICSettingEntry.INCLUDE_PATH: + case ICSettingEntry.MACRO: + case ICSettingEntry.INCLUDE_FILE: + case ICSettingEntry.MACRO_FILE: + if (langListTab.hadSomeModification()) { + return true; + } + break; + } + } + } + } + return false; + } + + private void rebuildIndex() { + final Shell shell= getShell(); + final String title= getTitle(); + final String msg= UIMessages.getString("AbstractPage.rebuildIndex.question"); //$NON-NLS-1$ + int result= OptionalMessageDialog.open(PREF_ASK_REINDEX, + shell, title, null /* default image */, msg, MessageDialog.QUESTION, + new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, 0); + if (result == OptionalMessageDialog.NOT_SHOWN) { + result= OptionalMessageDialog.getDialogDetail(PREF_ASK_REINDEX); + } else if (result != SWT.DEFAULT) { + OptionalMessageDialog.setDialogDetail(PREF_ASK_REINDEX, result); + } + if (result == 0) { // first button + final IProject project = getProject(); + CCorePlugin.getIndexManager().reindex(CoreModel.getDefault().create(project)); + } + } + private void populateConfigurations() { IProject prj = getProject(); // Do nothing in case of Preferences page. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties index 725a8cb7c2e..dcf7b418582 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties @@ -350,6 +350,7 @@ AbstractPage.6=Configuration: AbstractPage.7=Exclude resource from build AbstractPage.8=Cannot apply AbstractPage.9=Internal error +AbstractPage.rebuildIndex.question=Changes to the include search paths or defined symbols will not be reflected in the index until it is rebuilt. Do you wish to rebuild it now? AbstractLangsListTab.0=Show built-in values AbstractLangsListTab.1=Languages