1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-19 14:15:50 +02:00

[181939] avoid subsystem plugin activation just for enablement checking

This commit is contained in:
Martin Oberhuber 2007-07-18 12:47:41 +00:00
parent 24ad145262
commit 05993ebe36

View file

@ -15,6 +15,7 @@
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Martin Oberhuber (Wind River) - [181939] avoid subsystem plugin activation just for enablement checking
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.ui; package org.eclipse.rse.ui;
@ -29,6 +30,7 @@ import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
import org.eclipse.rse.internal.ui.SystemResources; import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.ui.widgets.InheritableEntryField; import org.eclipse.rse.ui.widgets.InheritableEntryField;
import org.eclipse.rse.ui.widgets.SystemHistoryCombo; import org.eclipse.rse.ui.widgets.SystemHistoryCombo;
@ -1102,9 +1104,10 @@ public class SystemWidgetHelpers {
* Return the list of all registered valid system types. * Return the list of all registered valid system types.
* *
* A system type is considered valid, if at least one subsystem * A system type is considered valid, if at least one subsystem
* configuration is registered against it. The list is ordered * configuration is registered against it, and the system type
* alphabetically by system type label according to international * is enabled in the Preferences.
* unicode rules, in the current Locale. * The list is ordered alphabetically by system type label
* according to international unicode rules, in the current Locale.
* *
* @param restrictIds An array of system type IDs to restrict the * @param restrictIds An array of system type IDs to restrict the
* returned list of valid system types to only those requested, * returned list of valid system types to only those requested,
@ -1112,30 +1115,47 @@ public class SystemWidgetHelpers {
* @return an ordered list of all registered valid system types. * @return an ordered list of all registered valid system types.
*/ */
public static IRSESystemType[] getValidSystemTypes(String[] restrictIds) { public static IRSESystemType[] getValidSystemTypes(String[] restrictIds) {
// Step 1: Get all static configured valid system types,
// According to what subsystem configurations are registered.
if (validSystemTypes==null) { if (validSystemTypes==null) {
IRSESystemType[] systemTypes = RSECorePlugin.getTheCoreRegistry().getSystemTypes(); IRSESystemType[] systemTypes = RSECorePlugin.getTheCoreRegistry().getSystemTypes();
ArrayList list = new ArrayList(systemTypes.length); ArrayList list = new ArrayList(systemTypes.length);
//TODO check if we shouldn't better get the IRSESystemTypeAdapter and check for isEnabled()
//This would do more than checking validity but also enablement
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
ISubSystemConfigurationProxy[] ssfProxies = sr.getSubSystemConfigurationProxies();
for (int i=0; i<systemTypes.length; i++) { for (int i=0; i<systemTypes.length; i++) {
ISubSystemConfiguration[] configurations = sr.getSubSystemConfigurationsBySystemType(systemTypes[i], false); for (int j=0; j<ssfProxies.length; j++) {
if (configurations != null && configurations.length > 0) { if (ssfProxies[j].appliesToSystemType(systemTypes[i])) {
list.add(systemTypes[i]); list.add(systemTypes[i]);
break;
}
} }
} }
systemTypes = (IRSESystemType[])list.toArray(new IRSESystemType[list.size()]); systemTypes = (IRSESystemType[])list.toArray(new IRSESystemType[list.size()]);
sortSystemTypesByLabel(systemTypes); sortSystemTypesByLabel(systemTypes);
validSystemTypes = systemTypes;
} }
if (restrictIds==null) { // Step 2: Restrict the list if requested
return validSystemTypes; boolean filtered = false;
} else { java.util.List result = new ArrayList(validSystemTypes.length);
java.util.List result = new ArrayList(validSystemTypes.length); java.util.List restrictList = (restrictIds==null) ? null : Arrays.asList(restrictIds);
java.util.List restrictList = Arrays.asList(restrictIds); for(int i=0; i<validSystemTypes.length; i++) {
for(int i=0; i<validSystemTypes.length; i++) { IRSESystemType systemType = validSystemTypes[i];
if (restrictList.contains(validSystemTypes[i].getId())) { if (restrictList==null || restrictList.contains(systemType)) {
result.add(validSystemTypes[i]); // Step 3: check enablement in Preferences
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(RSESystemTypeAdapter.class));
if (adapter != null && adapter.isEnabled(systemType)) {
result.add(systemType);
} else {
filtered = true;
} }
} }
}
if (filtered) {
return (IRSESystemType[])result.toArray(new IRSESystemType[result.size()]); return (IRSESystemType[])result.toArray(new IRSESystemType[result.size()]);
} else {
return validSystemTypes;
} }
} }