mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Added "shared", "ui-edit-entries", "ui-clear-entries" to
LanguageSettingsProviderAssociation extension point. Removed "Shared provider" checkbox from UI.
This commit is contained in:
parent
6c57d8f72e
commit
6a4136bf96
6 changed files with 175 additions and 72 deletions
|
@ -545,12 +545,14 @@
|
|||
<class-association
|
||||
class="org.eclipse.cdt.make.core.scannerconfig.AbstractBuildCommandParser"
|
||||
icon="icons/obj16/log_obj.gif"
|
||||
page="org.eclipse.cdt.make.internal.ui.preferences.GCCBuildCommandParserOptionPage">
|
||||
page="org.eclipse.cdt.make.internal.ui.preferences.GCCBuildCommandParserOptionPage"
|
||||
shared="false">
|
||||
</class-association>
|
||||
<class-association
|
||||
class="org.eclipse.cdt.make.core.scannerconfig.AbstractBuiltinSpecsDetector"
|
||||
icon="icons/obj16/inspect_system.gif"
|
||||
page="org.eclipse.cdt.make.internal.ui.scannerconfig.BuiltinSpecsDetectorOptionPage">
|
||||
page="org.eclipse.cdt.make.internal.ui.scannerconfig.BuiltinSpecsDetectorOptionPage"
|
||||
shared="true">
|
||||
</class-association>
|
||||
</extension>
|
||||
<extension
|
||||
|
|
|
@ -652,7 +652,8 @@
|
|||
point="org.eclipse.cdt.ui.LanguageSettingsProviderAssociation">
|
||||
<id-association
|
||||
id="org.eclipse.cdt.managedbuilder.core.LanguageSettingsProvider"
|
||||
icon="icons/obj16/mbs.gif">
|
||||
icon="icons/obj16/mbs.gif"
|
||||
shared="true">
|
||||
</id-association>
|
||||
</extension>
|
||||
|
||||
|
|
|
@ -3805,7 +3805,8 @@
|
|||
<extension point="org.eclipse.cdt.ui.LanguageSettingsProviderAssociation">
|
||||
<id-association
|
||||
id="org.eclipse.cdt.ui.user.LanguageSettingsProvider"
|
||||
icon="icons/obj16/person-me.gif">
|
||||
icon="icons/obj16/person-me.gif"
|
||||
shared="false">
|
||||
</id-association>
|
||||
</extension>
|
||||
<extension point="org.eclipse.cdt.ui.cPropertyTab">
|
||||
|
|
|
@ -77,6 +77,27 @@
|
|||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="shared" type="boolean">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="ui-edit-entries" type="boolean">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="ui-clear-entries" type="boolean">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
|
@ -112,6 +133,27 @@
|
|||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="shared" type="boolean">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="ui-clear-entries" type="boolean">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="ui-edit-entries" type="boolean">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
|
|
|
@ -29,12 +29,18 @@ public class LanguageSettingsProviderAssociationManager {
|
|||
private static final String ATTR_CLASS = "class"; //$NON-NLS-1$
|
||||
private static final String ATTR_ICON = "icon"; //$NON-NLS-1$
|
||||
private static final String ATTR_PAGE = "page"; //$NON-NLS-1$
|
||||
private static final String ATTR_SHARED = "shared"; //$NON-NLS-1$
|
||||
private static final String ATTR_UI_CLEAR_ENTRIES = "ui-clear-entries"; //$NON-NLS-1$
|
||||
private static final String ATTR_UI_EDIT_ENTRIES = "ui-edit-entries"; //$NON-NLS-1$
|
||||
|
||||
static private List<URL> loadedIcons = null;
|
||||
static private Map<String, URL> fImagesUrlById = null;
|
||||
static private Map<String, URL> fImagesUrlByClass = null;
|
||||
static private List<String> fRegirestedIds = null;
|
||||
static private List<String> fRegisteredClasses = null;
|
||||
private static List<URL> loadedIcons = null;
|
||||
private static Map<String, URL> fImagesUrlById = null;
|
||||
private static Map<String, URL> fImagesUrlByClass = null;
|
||||
private static List<String> fRegirestedIds = null;
|
||||
private static List<String> fRegisteredClasses = null;
|
||||
|
||||
private static Map<String, Map<String, String>> fAssociationsById = null;
|
||||
private static Map<String, Map<String, String>> fAssociationsByClass = null;
|
||||
|
||||
private static void loadExtensions() {
|
||||
if (loadedIcons!=null) {
|
||||
|
@ -46,6 +52,9 @@ public class LanguageSettingsProviderAssociationManager {
|
|||
if (fRegirestedIds==null) fRegirestedIds = new ArrayList<String>();
|
||||
if (fRegisteredClasses==null) fRegisteredClasses = new ArrayList<String>();
|
||||
|
||||
if (fAssociationsById==null) fAssociationsById = new HashMap<String, Map<String, String>>();
|
||||
if (fAssociationsByClass==null) fAssociationsByClass = new HashMap<String, Map<String, String>>();
|
||||
|
||||
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
||||
IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, LANGUAGE_SETTINGS_PROVIDER_UI);
|
||||
if (extension != null) {
|
||||
|
@ -59,14 +68,28 @@ public class LanguageSettingsProviderAssociationManager {
|
|||
URL url = getIconUrl(cfgEl);
|
||||
fImagesUrlById.put(id, url);
|
||||
fRegirestedIds.add(id);
|
||||
|
||||
Map<String, String> properties = new HashMap<String, String>();
|
||||
sensiblePut(properties, ATTR_PAGE, cfgEl.getAttribute(ATTR_PAGE));
|
||||
sensiblePut(properties, ATTR_SHARED, cfgEl.getAttribute(ATTR_SHARED));
|
||||
sensiblePut(properties, ATTR_UI_CLEAR_ENTRIES, cfgEl.getAttribute(ATTR_UI_CLEAR_ENTRIES));
|
||||
sensiblePut(properties, ATTR_UI_EDIT_ENTRIES, cfgEl.getAttribute(ATTR_UI_EDIT_ENTRIES));
|
||||
fAssociationsById.put(id, properties);
|
||||
} else if (cfgEl.getName().equals(ELEM_CLASS_ASSOCIATION)) {
|
||||
String className = cfgEl.getAttribute(ATTR_CLASS);
|
||||
URL url = getIconUrl(cfgEl);
|
||||
fImagesUrlByClass.put(className, url);
|
||||
String pageClass = cfgEl.getAttribute(ATTR_PAGE);
|
||||
if (pageClass!=null && pageClass.trim().length()>0) {
|
||||
if (pageClass!=null && pageClass.length()>0) {
|
||||
fRegisteredClasses.add(className);
|
||||
}
|
||||
|
||||
Map<String, String> properties = new HashMap<String, String>();
|
||||
sensiblePut(properties, ATTR_PAGE, cfgEl.getAttribute(ATTR_PAGE));
|
||||
sensiblePut(properties, ATTR_SHARED, cfgEl.getAttribute(ATTR_SHARED));
|
||||
sensiblePut(properties, ATTR_UI_CLEAR_ENTRIES, cfgEl.getAttribute(ATTR_UI_CLEAR_ENTRIES));
|
||||
sensiblePut(properties, ATTR_UI_EDIT_ENTRIES, cfgEl.getAttribute(ATTR_UI_EDIT_ENTRIES));
|
||||
fAssociationsByClass.put(className, properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +97,11 @@ public class LanguageSettingsProviderAssociationManager {
|
|||
|
||||
}
|
||||
|
||||
private static void sensiblePut(Map<String, String> properties, String key, String value) {
|
||||
if (value != null)
|
||||
properties.put(key, value);
|
||||
}
|
||||
|
||||
private static URL getIconUrl(IConfigurationElement config) {
|
||||
URL url = null;
|
||||
try {
|
||||
|
@ -242,5 +270,66 @@ public class LanguageSettingsProviderAssociationManager {
|
|||
return optionsPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TODO for id or closest superclass.
|
||||
* @param provider TODO
|
||||
* @return TODO
|
||||
*/
|
||||
private static boolean getBooleanAttribute(ILanguageSettingsProvider provider, String attr) {
|
||||
loadExtensions();
|
||||
|
||||
String id = provider.getId();
|
||||
|
||||
Map<String, String> properties = fAssociationsById.get(id);
|
||||
if (properties != null) {
|
||||
return Boolean.parseBoolean(properties.get(attr));
|
||||
}
|
||||
|
||||
for (Class<?> clazz=provider.getClass();clazz!=null;clazz=clazz.getSuperclass()) {
|
||||
String className = clazz.getCanonicalName();
|
||||
properties = fAssociationsByClass.get(className);
|
||||
if (properties != null) {
|
||||
return Boolean.parseBoolean(properties.get(attr));
|
||||
}
|
||||
|
||||
// this does not check for superinterfaces, feel free to implement as needed
|
||||
for (Class<?> iface : clazz.getInterfaces()) {
|
||||
String interfaceName = iface.getCanonicalName();
|
||||
properties = fAssociationsByClass.get(interfaceName);
|
||||
if (properties != null) {
|
||||
return Boolean.parseBoolean(properties.get(attr));
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns TODO for id or closest superclass.
|
||||
* @param provider TODO
|
||||
* @return TODO
|
||||
*/
|
||||
public static boolean shouldBeShared(ILanguageSettingsProvider provider) {
|
||||
return getBooleanAttribute(provider, ATTR_SHARED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TODO for id or closest superclass.
|
||||
* @param provider TODO
|
||||
* @return TODO
|
||||
*/
|
||||
public static boolean isToClear(ILanguageSettingsProvider provider) {
|
||||
return getBooleanAttribute(provider, ATTR_UI_CLEAR_ENTRIES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TODO for id or closest superclass.
|
||||
* @param provider TODO
|
||||
* @return TODO
|
||||
*/
|
||||
public static boolean isToEditEntries(ILanguageSettingsProvider provider) {
|
||||
return getBooleanAttribute(provider, ATTR_UI_EDIT_ENTRIES);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -118,7 +118,6 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
|
|||
private Button enableProvidersCheckBox;
|
||||
private StatusMessageLine fStatusLine;
|
||||
|
||||
private Button globalProviderCheckBox = null;
|
||||
private Link linkWorkspacePreferences = null;
|
||||
private Button projectStorageCheckBox = null;
|
||||
|
||||
|
@ -303,9 +302,35 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
|
|||
|
||||
tableProvidersViewer.addCheckStateListener(new ICheckStateListener() {
|
||||
@Override
|
||||
public void checkStateChanged(CheckStateChangedEvent e) {
|
||||
saveCheckedProviders(e.getElement());
|
||||
tableProvidersViewer.update(e.getElement(), null);
|
||||
public void checkStateChanged(CheckStateChangedEvent event) {
|
||||
// TODO: clean-up - too many manipulations in this method
|
||||
|
||||
ILanguageSettingsProvider provider = (ILanguageSettingsProvider) event.getElement();
|
||||
saveCheckedProviders(provider);
|
||||
|
||||
int pos = presentedProviders.indexOf(provider);
|
||||
tableProviders.setSelection(pos);
|
||||
|
||||
if (event.getChecked() && LanguageSettingsManager.isWorkspaceProvider(provider)) {
|
||||
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
|
||||
if (!LanguageSettingsProviderAssociationManager.shouldBeShared(rawProvider)) {
|
||||
// Switch to local provider instance
|
||||
try {
|
||||
if (rawProvider instanceof ILanguageSettingsEditableProvider) {
|
||||
provider = ((ILanguageSettingsEditableProvider) rawProvider).cloneShallow();
|
||||
}
|
||||
} catch (CloneNotSupportedException e) {
|
||||
CUIPlugin.log("Error cloning provider " + provider.getId(), e);
|
||||
}
|
||||
|
||||
replaceSelectedProvider(provider);
|
||||
ICConfigurationDescription cfgDescription = getConfigurationDescription();
|
||||
initializeOptionsPage(provider, cfgDescription);
|
||||
displaySelectedOptionPage();
|
||||
}
|
||||
}
|
||||
|
||||
tableProvidersViewer.update(provider, null);
|
||||
}});
|
||||
|
||||
createOptionsControl();
|
||||
|
@ -331,37 +356,6 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
|
|||
return link;
|
||||
}
|
||||
|
||||
// Called from globalProviderCheckBox listener
|
||||
private ILanguageSettingsProvider toggleGlobalProvider(ILanguageSettingsProvider oldProvider, boolean toGlobal) {
|
||||
ILanguageSettingsProvider newProvider = null;
|
||||
|
||||
String id = oldProvider.getId();
|
||||
if (toGlobal) {
|
||||
newProvider = LanguageSettingsManager.getWorkspaceProvider(id);
|
||||
} else {
|
||||
// Local provider instance chosen
|
||||
try {
|
||||
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(oldProvider);
|
||||
if (rawProvider instanceof ILanguageSettingsEditableProvider) {
|
||||
newProvider = ((ILanguageSettingsEditableProvider) rawProvider).cloneShallow();
|
||||
}
|
||||
} catch (CloneNotSupportedException e) {
|
||||
CUIPlugin.log("Error cloning provider " + oldProvider.getId(), e);
|
||||
}
|
||||
}
|
||||
if (newProvider!=null) {
|
||||
replaceSelectedProvider(newProvider);
|
||||
|
||||
ICConfigurationDescription cfgDescription = getConfigurationDescription();
|
||||
initializeOptionsPage(newProvider, cfgDescription);
|
||||
displaySelectedOptionPage();
|
||||
} else {
|
||||
newProvider = oldProvider;
|
||||
}
|
||||
|
||||
return newProvider;
|
||||
}
|
||||
|
||||
private void replaceSelectedProvider(ILanguageSettingsProvider newProvider) {
|
||||
int pos = tableProviders.getSelectionIndex();
|
||||
presentedProviders.set(pos, newProvider);
|
||||
|
@ -394,28 +388,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
|
|||
groupOptionsPage.setLayout(new GridLayout(2, false));
|
||||
|
||||
if (!page.isForPrefs()) {
|
||||
if (globalProviderCheckBox==null) {
|
||||
globalProviderCheckBox = new Button(groupOptionsPage, SWT.CHECK);
|
||||
globalProviderCheckBox.setText("Share setting entries between projects (global provider)");
|
||||
globalProviderCheckBox.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
boolean isGlobal = globalProviderCheckBox.getSelection();
|
||||
ILanguageSettingsProvider provider = getSelectedProvider();
|
||||
if (isGlobal != LanguageSettingsManager.isWorkspaceProvider(provider)) {
|
||||
provider = toggleGlobalProvider(provider, isGlobal);
|
||||
}
|
||||
projectStorageCheckBox.setSelection(provider instanceof LanguageSettingsSerializableProvider
|
||||
&& LanguageSettingsManager.isStoringEntriesInProjectArea((LanguageSettingsSerializableProvider) provider));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
widgetSelected(e);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (projectStorageCheckBox == null) {
|
||||
projectStorageCheckBox = new Button(groupOptionsPage, SWT.CHECK);
|
||||
projectStorageCheckBox.setText("Store entries in project settings folder (supporting project miration)");
|
||||
projectStorageCheckBox.addSelectionListener(new SelectionAdapter() {
|
||||
|
@ -603,11 +576,6 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
|
|||
|
||||
boolean isChecked = tableProvidersViewer.getChecked(provider);
|
||||
if (!page.isForPrefs()) {
|
||||
boolean isRawProviderEditable = rawProvider instanceof ILanguageSettingsEditableProvider;
|
||||
globalProviderCheckBox.setSelection(isGlobal);
|
||||
globalProviderCheckBox.setEnabled(isChecked && isRawProviderEditable);
|
||||
globalProviderCheckBox.setVisible(provider!=null);
|
||||
|
||||
projectStorageCheckBox.setEnabled(!isGlobal);
|
||||
projectStorageCheckBox.setVisible(rawProvider instanceof LanguageSettingsSerializableProvider);
|
||||
projectStorageCheckBox.setSelection(provider instanceof LanguageSettingsSerializableProvider
|
||||
|
|
Loading…
Add table
Reference in a new issue