1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 01:35:39 +02:00

[235148] get rid of dead code for caching

This commit is contained in:
Martin Oberhuber 2008-06-03 08:51:37 +00:00
parent 359627faa0
commit 9e2fc1d12d

View file

@ -9,12 +9,11 @@
* Uwe Stieber (Wind River) - initial API and implementation.
* Javier Montalvo Orus (Symbian) - [174992] default wizard hides special ones
* David McKnight (IBM) - [216252] MessageFormat.format -> NLS.bind
* Martin Oberhuber (Wind River) - [235148] get rid of dead code for caching
*******************************************************************************/
package org.eclipse.rse.ui.wizards.newconnection;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.jface.viewers.IStructuredSelection;
@ -32,7 +31,6 @@ import org.eclipse.rse.ui.wizards.registries.RSEAbstractWizardRegistry;
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class RSENewConnectionWizardRegistry extends RSEAbstractWizardRegistry {
private final Map cache = new HashMap();
// Initialize-On-Demand Holder Class idiom:
// Lazy initialization and thread-safe single instance.
@ -53,7 +51,6 @@ public class RSENewConnectionWizardRegistry extends RSEAbstractWizardRegistry {
*/
protected RSENewConnectionWizardRegistry() {
super();
cache.clear();
}
protected IRSEWizardRegistryElement createWizardRegistryElementFor(IConfigurationElement element) {
@ -103,46 +100,34 @@ public class RSENewConnectionWizardRegistry extends RSEAbstractWizardRegistry {
IRSENewConnectionWizardDescriptor descriptor = null;
String id = systemType.getId();
if (cache.containsKey(id)) {
Object candidate = cache.get(id);
if (candidate instanceof IRSENewConnectionWizardDescriptor) {
descriptor = (IRSENewConnectionWizardDescriptor)candidate;
} else {
cache.remove(id);
}
}
// check if there is any wizard explicitly registered for the given system type
if (descriptor == null) {
// Get the list of all wizards and always walk through _all_ of them
// to find possible duplicates (which will be notified as warnings to
// the user)
IRSEWizardRegistryElement[] elements = getElements();
for (int i = 0; i < elements.length; i++) {
IRSEWizardRegistryElement element = elements[i];
if (element instanceof IRSENewConnectionWizardDescriptor) {
IRSENewConnectionWizardDescriptor candidate = (IRSENewConnectionWizardDescriptor)element;
if(candidate != defaultDescriptor)
{
String[] systemTypeIds = candidate.getSystemTypeIds();
if (Arrays.asList(systemTypeIds).contains(id)) {
if (descriptor == null) {
descriptor = candidate;
} else {
String message = "Duplicated new connection wizard registration for system type ''{0}'' (wizard id = {1})."; //$NON-NLS-1$
message = NLS.bind(message, id, candidate.getId());
RSECorePlugin.getDefault().getLogger().logWarning(message);
}
// Get the list of all wizards and always walk through _all_ of them
// to find possible duplicates (which will be notified as warnings to
// the user)
IRSEWizardRegistryElement[] elements = getElements();
for (int i = 0; i < elements.length; i++) {
IRSEWizardRegistryElement element = elements[i];
if (element instanceof IRSENewConnectionWizardDescriptor) {
IRSENewConnectionWizardDescriptor candidate = (IRSENewConnectionWizardDescriptor) element;
if (candidate != defaultDescriptor) {
String[] systemTypeIds = candidate.getSystemTypeIds();
if (Arrays.asList(systemTypeIds).contains(id)) {
if (descriptor == null) {
descriptor = candidate;
} else {
String message = "Duplicated new connection wizard registration for system type ''{0}'' (wizard id = {1})."; //$NON-NLS-1$
message = NLS.bind(message, id, candidate.getId());
RSECorePlugin.getDefault().getLogger().logWarning(message);
}
}
}
}
}
// if the descriptor here is still null, always return the default RSE
// new connection wizard descriptor
if (descriptor == null) {
descriptor = defaultDescriptor;
}
// if the descriptor here is still null, always return the default RSE
// new connection wizard descriptor
if (descriptor == null) {
descriptor = defaultDescriptor;
}
return descriptor;