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:
parent
359627faa0
commit
9e2fc1d12d
1 changed files with 42 additions and 57 deletions
|
@ -9,12 +9,11 @@
|
||||||
* Uwe Stieber (Wind River) - initial API and implementation.
|
* Uwe Stieber (Wind River) - initial API and implementation.
|
||||||
* Javier Montalvo Orus (Symbian) - [174992] default wizard hides special ones
|
* Javier Montalvo Orus (Symbian) - [174992] default wizard hides special ones
|
||||||
* David McKnight (IBM) - [216252] MessageFormat.format -> NLS.bind
|
* 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;
|
package org.eclipse.rse.ui.wizards.newconnection;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
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.
|
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||||
*/
|
*/
|
||||||
public class RSENewConnectionWizardRegistry extends RSEAbstractWizardRegistry {
|
public class RSENewConnectionWizardRegistry extends RSEAbstractWizardRegistry {
|
||||||
private final Map cache = new HashMap();
|
|
||||||
|
|
||||||
// Initialize-On-Demand Holder Class idiom:
|
// Initialize-On-Demand Holder Class idiom:
|
||||||
// Lazy initialization and thread-safe single instance.
|
// Lazy initialization and thread-safe single instance.
|
||||||
|
@ -53,7 +51,6 @@ public class RSENewConnectionWizardRegistry extends RSEAbstractWizardRegistry {
|
||||||
*/
|
*/
|
||||||
protected RSENewConnectionWizardRegistry() {
|
protected RSENewConnectionWizardRegistry() {
|
||||||
super();
|
super();
|
||||||
cache.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IRSEWizardRegistryElement createWizardRegistryElementFor(IConfigurationElement element) {
|
protected IRSEWizardRegistryElement createWizardRegistryElementFor(IConfigurationElement element) {
|
||||||
|
@ -103,46 +100,34 @@ public class RSENewConnectionWizardRegistry extends RSEAbstractWizardRegistry {
|
||||||
IRSENewConnectionWizardDescriptor descriptor = null;
|
IRSENewConnectionWizardDescriptor descriptor = null;
|
||||||
String id = systemType.getId();
|
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
|
// 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
|
||||||
// Get the list of all wizards and always walk through _all_ of them
|
// to find possible duplicates (which will be notified as warnings to
|
||||||
// to find possible duplicates (which will be notified as warnings to
|
// the user)
|
||||||
// the user)
|
IRSEWizardRegistryElement[] elements = getElements();
|
||||||
IRSEWizardRegistryElement[] elements = getElements();
|
for (int i = 0; i < elements.length; i++) {
|
||||||
for (int i = 0; i < elements.length; i++) {
|
IRSEWizardRegistryElement element = elements[i];
|
||||||
IRSEWizardRegistryElement element = elements[i];
|
if (element instanceof IRSENewConnectionWizardDescriptor) {
|
||||||
if (element instanceof IRSENewConnectionWizardDescriptor) {
|
IRSENewConnectionWizardDescriptor candidate = (IRSENewConnectionWizardDescriptor) element;
|
||||||
IRSENewConnectionWizardDescriptor candidate = (IRSENewConnectionWizardDescriptor)element;
|
if (candidate != defaultDescriptor) {
|
||||||
if(candidate != defaultDescriptor)
|
String[] systemTypeIds = candidate.getSystemTypeIds();
|
||||||
{
|
if (Arrays.asList(systemTypeIds).contains(id)) {
|
||||||
String[] systemTypeIds = candidate.getSystemTypeIds();
|
if (descriptor == null) {
|
||||||
if (Arrays.asList(systemTypeIds).contains(id)) {
|
descriptor = candidate;
|
||||||
if (descriptor == null) {
|
} else {
|
||||||
descriptor = candidate;
|
String message = "Duplicated new connection wizard registration for system type ''{0}'' (wizard id = {1})."; //$NON-NLS-1$
|
||||||
} else {
|
message = NLS.bind(message, id, candidate.getId());
|
||||||
String message = "Duplicated new connection wizard registration for system type ''{0}'' (wizard id = {1})."; //$NON-NLS-1$
|
RSECorePlugin.getDefault().getLogger().logWarning(message);
|
||||||
message = NLS.bind(message, id, candidate.getId());
|
|
||||||
RSECorePlugin.getDefault().getLogger().logWarning(message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if the descriptor here is still null, always return the default RSE
|
// if the descriptor here is still null, always return the default RSE
|
||||||
// new connection wizard descriptor
|
// new connection wizard descriptor
|
||||||
if (descriptor == null) {
|
if (descriptor == null) {
|
||||||
descriptor = defaultDescriptor;
|
descriptor = defaultDescriptor;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return descriptor;
|
return descriptor;
|
||||||
|
|
Loading…
Add table
Reference in a new issue