mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Offer to rebuild index when modifying include search path, bug 144085.
This commit is contained in:
parent
d08c94b474
commit
d877f1c0b1
7 changed files with 136 additions and 5 deletions
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -88,6 +88,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
|
|||
protected ArrayList<ICSettingEntry> 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<tis.length; i++) {
|
||||
Object ob = tis[i].getData();
|
||||
|
@ -781,4 +787,12 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
|
|||
columnToFit.setWidth(table.getBounds().width - 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the tab was modified by the user in any way. The flag is
|
||||
* cleared after pressing apply or ok.
|
||||
* @since 5.1
|
||||
*/
|
||||
protected final boolean hadSomeModification() {
|
||||
return fHadSomeModification;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ import org.eclipse.core.runtime.Preferences;
|
|||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.eclipse.help.HelpSystem;
|
||||
import org.eclipse.help.IContext;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.jface.preference.IPreferencePageContainer;
|
||||
|
@ -70,6 +72,7 @@ import org.eclipse.ui.PlatformUI;
|
|||
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
|
||||
import org.eclipse.ui.dialogs.PropertyPage;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
|
@ -80,12 +83,14 @@ import org.eclipse.cdt.core.settings.model.ICFolderDescription;
|
|||
import org.eclipse.cdt.core.settings.model.ICMultiItemsHolder;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||
import org.eclipse.cdt.core.settings.model.MultiItemsHolder;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
import org.eclipse.cdt.internal.ui.dialogs.OptionalMessageDialog;
|
||||
|
||||
/**
|
||||
* It is a parent for all standard CDT property pages
|
||||
|
@ -136,6 +141,8 @@ implements
|
|||
private static final int SAVE_MODE_APPLY = 2;
|
||||
private static final int SAVE_MODE_APPLYOK = 3;
|
||||
|
||||
private static final String PREF_ASK_REINDEX = "askReindex"; //$NON-NLS-1$
|
||||
|
||||
private final Image IMG_WARN = CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_WARNING);
|
||||
/*
|
||||
* Dialog widgets
|
||||
|
@ -589,6 +596,7 @@ implements
|
|||
}
|
||||
final ICResourceDescription local_cfgd = lc;
|
||||
|
||||
final boolean rebuildIndex= isIndexerAffected();
|
||||
IRunnableWithProgress runnable = new IRunnableWithProgress() {
|
||||
|
||||
private void sendOK() {
|
||||
|
@ -650,9 +658,58 @@ implements
|
|||
UIMessages.getString("AbstractPage.9"), e1, true); //$NON-NLS-1$
|
||||
return false;
|
||||
} catch (InterruptedException e) {}
|
||||
|
||||
if (rebuildIndex)
|
||||
rebuildIndex();
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isIndexerAffected() {
|
||||
ICProjectDescription desc= CoreModel.getDefault().getProjectDescription(getProject(), false);
|
||||
if (desc == null || desc.isCdtProjectCreating())
|
||||
return false;
|
||||
|
||||
Iterator<InternalTab> 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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue