1 /******************************************************************************* 2 * Copyright (c) 2004, 2006 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.ui.themes; 12 13 import java.util.Set; 14 15 import org.eclipse.jface.resource.ColorRegistry; 16 import org.eclipse.jface.resource.FontRegistry; 17 import org.eclipse.jface.util.IPropertyChangeListener; 18 19 /** 20 * A theme is a collection of colors, fonts and supporting data that may 21 * be used by plugins to help provide uniform look and feel to their components. 22 * The workbench has a default theme (one whos id has the value {@link org.eclipse.ui.themes.IThemeManager#DEFAULT_THEME}) 23 * that defines the initial values for a collection of fonts and colors. Other 24 * themes may extend and override the default theme to provide new values. 25 * 26 * <p> 27 * Clients may obtain themes via {@link org.eclipse.ui.themes.IThemeManager#getTheme(String)}. 28 * </p> 29 * 30 * <p> 31 * This interface is not intended to be implemented or extended by clients. 32 * </p> 33 * 34 * @see org.eclipse.ui.IWorkbench#getThemeManager() 35 * @since 3.0 36 */ 37 public interface ITheme { 38 39 /** 40 * Adds a property listener to the theme. Any events fired by the 41 * underlying registries will cause an event to be fired. This event is the 42 * same event that was fired by the registry. As such, the "source" 43 * attribute of the event will not be this theme, but rather the color or 44 * font registry. 45 * 46 * @param listener the listener to add 47 */ 48 void addPropertyChangeListener(IPropertyChangeListener listener); 49 50 /** 51 * Dispose of this theme. This method is called by the workbench when 52 * appropriate and should never be called by a user. 53 */ 54 void dispose(); 55 56 /** 57 * Get arbitrary data associated with this theme. 58 * 59 * @param key the key 60 * @return the data, or the default value <code>false</code> if none exists 61 * or if the value cannot be treated as a boolean. 62 */ 63 boolean getBoolean(String key); 64 65 /** 66 * Return this themes color registry. 67 * 68 * @return this themes color registry 69 */ 70 ColorRegistry getColorRegistry(); 71 72 /** 73 * Return this themes font registry. 74 * 75 * @return this themes font registry 76 */ 77 FontRegistry getFontRegistry(); 78 79 /** 80 * Returns the id of this theme. 81 * 82 * @return the id of this theme. Guaranteed not to be <code>null</code>. 83 */ 84 String getId(); 85 86 /** 87 * Get arbitrary data associated with this theme. 88 * 89 * @param key the key 90 * @return the data, or the default value <code>0</code> if none exists or 91 * if the value cannot be treated as an integer. 92 */ 93 public int getInt(String key); 94 95 /** 96 * Returns the label of this theme. 97 * 98 * @return the label of this theme. Guaranteed not be <code>null</code>. 99 */ 100 String getLabel(); 101 102 /** 103 * Get arbitrary data associated with this theme. 104 * 105 * @param key the key 106 * @return the data, or <code>null</code> if none exists. 107 */ 108 String getString(String key); 109 110 /** 111 * Get the set of keys associated with this theme. 112 * 113 * @return the Set of keys 114 */ 115 Set keySet(); 116 117 /** 118 * Removes a property listener from the theme. 119 * 120 * @param listener the listener to remove 121 */ 122 void removePropertyChangeListener(IPropertyChangeListener listener); 123 } 124