1 11 package org.eclipse.ui.internal.themes; 12 13 import java.util.Set ; 14 15 import org.eclipse.core.commands.common.EventManager; 16 import org.eclipse.jface.resource.ColorRegistry; 17 import org.eclipse.jface.resource.FontRegistry; 18 import org.eclipse.jface.util.IPropertyChangeListener; 19 import org.eclipse.jface.util.PropertyChangeEvent; 20 import org.eclipse.ui.themes.ITheme; 21 22 25 public class CascadingTheme extends EventManager implements ITheme { 26 27 private CascadingFontRegistry fontRegistry; 28 29 private CascadingColorRegistry colorRegistry; 30 31 private ITheme currentTheme; 32 33 private IPropertyChangeListener listener = new IPropertyChangeListener() { 34 35 public void propertyChange(PropertyChangeEvent event) { 36 fire(event); 37 } 38 }; 39 40 44 public CascadingTheme(ITheme currentTheme, 45 CascadingColorRegistry colorRegistry, 46 CascadingFontRegistry fontRegistry) { 47 this.currentTheme = currentTheme; 48 this.colorRegistry = colorRegistry; 49 this.fontRegistry = fontRegistry; 50 51 fontRegistry.addListener(listener); 52 colorRegistry.addListener(listener); 53 } 54 55 58 protected void fire(PropertyChangeEvent event) { 59 Object [] listeners = getListeners(); 60 for (int i = 0; i < listeners.length; i++) { 61 ((IPropertyChangeListener) listeners[i]).propertyChange(event); 62 } 63 } 64 65 68 public void addPropertyChangeListener(IPropertyChangeListener listener) { 69 addListenerObject(listener); 70 } 71 72 75 public void removePropertyChangeListener(IPropertyChangeListener listener) { 76 removeListenerObject(listener); 77 } 78 79 82 public String getId() { 83 return currentTheme.getId(); 84 } 85 86 89 public String getLabel() { 90 return currentTheme.getLabel(); 91 } 92 93 96 public ColorRegistry getColorRegistry() { 97 return colorRegistry; 98 } 99 100 103 public FontRegistry getFontRegistry() { 104 return fontRegistry; 105 } 106 107 110 public void dispose() { 111 colorRegistry.removeListener(listener); 112 fontRegistry.removeListener(listener); 113 } 114 115 118 public String getString(String key) { 119 return currentTheme.getString(key); 120 } 121 122 125 public int getInt(String key) { 126 return currentTheme.getInt(key); 127 } 128 129 132 public boolean getBoolean(String key) { 133 return currentTheme.getBoolean(key); 134 } 135 136 139 public Set keySet() { 140 return currentTheme.keySet(); 141 } 142 143 } 144 | Popular Tags |