1 11 12 package org.eclipse.ui.handlers; 13 14 import java.util.Hashtable ; 15 16 import org.eclipse.core.runtime.IConfigurationElement; 17 import org.eclipse.core.runtime.IExecutableExtension; 18 import org.eclipse.jface.commands.ToggleState; 19 20 41 public final class RegistryToggleState extends ToggleState implements 42 IExecutableExtension { 43 44 52 private final void readDefault(final String defaultString) { 53 if ("true".equalsIgnoreCase(defaultString)) { setValue(Boolean.TRUE); 55 } 56 } 57 58 66 private final void readPersisted(final String persistedString) { 67 if ("false".equalsIgnoreCase(persistedString)) { setShouldPersist(false); 69 } 70 71 setShouldPersist(true); 72 } 73 74 public final void setInitializationData( 75 final IConfigurationElement configurationElement, 76 final String propertyName, final Object data) { 77 if (data instanceof String ) { 78 readDefault((String ) data); 80 setShouldPersist(true); 81 82 } else if (data instanceof Hashtable ) { 83 final Hashtable parameters = (Hashtable ) data; 84 final Object defaultObject = parameters.get("default"); if (defaultObject instanceof String ) { 86 readDefault((String ) defaultObject); 87 } 88 89 final Object persistedObject = parameters.get("persisted"); if (persistedObject instanceof String ) { 91 readPersisted((String ) persistedObject); 92 } 93 94 } else { 95 setShouldPersist(true); 96 97 } 98 } 99 } 100 | Popular Tags |