mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Restore Defaults in Preferences should take effect only after "Apply" or
"OK" button
This commit is contained in:
parent
01c3e2f0f5
commit
673e94acc7
1 changed files with 38 additions and 43 deletions
|
@ -650,24 +650,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ILanguageSettingsProvider> allAvailableProvidersSet = LanguageSettingsManager.getWorkspaceProviders();
|
List<ILanguageSettingsProvider> allAvailableProvidersSet = LanguageSettingsManager.getWorkspaceProviders();
|
||||||
|
sortByName(allAvailableProvidersSet);
|
||||||
// ensure sorting by name all unchecked providers
|
|
||||||
Collections.sort(allAvailableProvidersSet, new Comparator<ILanguageSettingsProvider>() {
|
|
||||||
@Override
|
|
||||||
public int compare(ILanguageSettingsProvider prov1, ILanguageSettingsProvider prov2) {
|
|
||||||
Boolean isTest1 = prov1.getId().matches(TEST_PLUGIN_ID_PATTERN);
|
|
||||||
Boolean isTest2 = prov2.getId().matches(TEST_PLUGIN_ID_PATTERN);
|
|
||||||
int result = isTest1.compareTo(isTest2);
|
|
||||||
if (result == 0) {
|
|
||||||
String name1 = prov1.getName();
|
|
||||||
String name2 = prov2.getName();
|
|
||||||
if (name1 != null && name2 != null) {
|
|
||||||
result = name1.compareTo(name2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for (ILanguageSettingsProvider provider : allAvailableProvidersSet) {
|
for (ILanguageSettingsProvider provider : allAvailableProvidersSet) {
|
||||||
String id = provider.getId();
|
String id = provider.getId();
|
||||||
|
@ -685,6 +668,26 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
|
||||||
tableProviders.setSelection(pos);
|
tableProviders.setSelection(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sortByName(List<ILanguageSettingsProvider> providers) {
|
||||||
|
// ensure sorting by name all unchecked providers
|
||||||
|
Collections.sort(providers, new Comparator<ILanguageSettingsProvider>() {
|
||||||
|
@Override
|
||||||
|
public int compare(ILanguageSettingsProvider prov1, ILanguageSettingsProvider prov2) {
|
||||||
|
Boolean isTest1 = prov1.getId().matches(TEST_PLUGIN_ID_PATTERN);
|
||||||
|
Boolean isTest2 = prov2.getId().matches(TEST_PLUGIN_ID_PATTERN);
|
||||||
|
int result = isTest1.compareTo(isTest2);
|
||||||
|
if (result == 0) {
|
||||||
|
String name1 = prov1.getName();
|
||||||
|
String name2 = prov2.getName();
|
||||||
|
if (name1 != null && name2 != null) {
|
||||||
|
result = name1.compareTo(name2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private ICOptionPage createOptionsPage(ILanguageSettingsProvider provider, ICConfigurationDescription cfgDescription) {
|
private ICOptionPage createOptionsPage(ILanguageSettingsProvider provider, ICConfigurationDescription cfgDescription) {
|
||||||
ICOptionPage optionsPage = null;
|
ICOptionPage optionsPage = null;
|
||||||
if (provider!=null) {
|
if (provider!=null) {
|
||||||
|
@ -1074,18 +1077,21 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (page.isForPrefs()) {
|
} else if (page.isForPrefs()) {
|
||||||
try {
|
presentedProviders = new ArrayList<ILanguageSettingsProvider>();
|
||||||
LanguageSettingsManager.setWorkspaceProviders(null);
|
for (ILanguageSettingsProvider provider : LanguageSettingsManager.getWorkspaceProviders()) {
|
||||||
} catch (CoreException e) {
|
if (!LanguageSettingsManager.isEqualExtensionProvider(provider, true)) {
|
||||||
CUIPlugin.log("Error serializing workspace language settings providers", e);
|
ILanguageSettingsProvider extProvider = LanguageSettingsManager.getExtensionProviderCopy(provider.getId(), true);
|
||||||
|
if (extProvider != null) {
|
||||||
|
provider = extProvider;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
presentedProviders = null;
|
presentedProviders.add(provider);
|
||||||
|
}
|
||||||
|
sortByName(presentedProviders);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateData(getResDesc());
|
updateData(getResDesc());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1093,26 +1099,15 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
|
||||||
protected void performApply(ICResourceDescription srcRcDescription, ICResourceDescription destRcDescription) {
|
protected void performApply(ICResourceDescription srcRcDescription, ICResourceDescription destRcDescription) {
|
||||||
// informOptionPages(true);
|
// informOptionPages(true);
|
||||||
|
|
||||||
if (!page.isForPrefs()) {
|
if (page.isForPrefs()) {
|
||||||
|
try {
|
||||||
|
LanguageSettingsManager.setWorkspaceProviders(presentedProviders);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CUIPlugin.log("Error serializing workspace language settings providers", e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
IResource rc = getResource();
|
IResource rc = getResource();
|
||||||
|
|
||||||
ICConfigurationDescription srcCfgDescription = srcRcDescription.getConfiguration();
|
|
||||||
ICConfigurationDescription destCfgDescription = destRcDescription.getConfiguration();
|
|
||||||
|
|
||||||
if (srcCfgDescription instanceof ILanguageSettingsProvidersKeeper
|
|
||||||
&& destCfgDescription instanceof ILanguageSettingsProvidersKeeper) {
|
|
||||||
|
|
||||||
List<ILanguageSettingsProvider> destProviders = new ArrayList<ILanguageSettingsProvider>();
|
|
||||||
List<ILanguageSettingsProvider> srcProviders = ((ILanguageSettingsProvidersKeeper) srcCfgDescription).getLanguageSettingProviders();
|
|
||||||
for (ILanguageSettingsProvider pro : srcProviders) {
|
|
||||||
// TODO: clone
|
|
||||||
destProviders.add(pro);
|
|
||||||
}
|
|
||||||
((ILanguageSettingsProvidersKeeper) destCfgDescription).setLanguageSettingProviders(destProviders);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!page.isForPrefs()) {
|
|
||||||
ICConfigurationDescription sd = srcRcDescription.getConfiguration();
|
ICConfigurationDescription sd = srcRcDescription.getConfiguration();
|
||||||
ICConfigurationDescription dd = destRcDescription.getConfiguration();
|
ICConfigurationDescription dd = destRcDescription.getConfiguration();
|
||||||
if (sd instanceof ILanguageSettingsProvidersKeeper && dd instanceof ILanguageSettingsProvidersKeeper) {
|
if (sd instanceof ILanguageSettingsProvidersKeeper && dd instanceof ILanguageSettingsProvidersKeeper) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue