KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > themes > ThemeElementCategory


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.internal.themes;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.IConfigurationElement;
15 import org.eclipse.ui.IPluginContribution;
16 import org.eclipse.ui.internal.WorkbenchPlugin;
17 import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
18 import org.eclipse.ui.themes.IThemePreview;
19
20 /**
21  * @since 3.0
22  */

23 public class ThemeElementCategory implements IPluginContribution,
24         IThemeElementDefinition {
25
26     private String JavaDoc description;
27
28     private IConfigurationElement element;
29
30     private String JavaDoc id;
31
32     private String JavaDoc parentId;
33
34     private String JavaDoc label;
35
36     private String JavaDoc pluginId;
37
38     /**
39      *
40      * @param label
41      * @param id
42      * @param parentId
43      * @param description
44      * @param pluginId
45      * @param element
46      */

47     public ThemeElementCategory(String JavaDoc label, String JavaDoc id, String JavaDoc parentId,
48             String JavaDoc description, String JavaDoc pluginId, IConfigurationElement element) {
49
50         this.label = label;
51         this.id = id;
52         this.parentId = parentId;
53         this.description = description;
54         this.pluginId = pluginId;
55         this.element = element;
56     }
57
58     /**
59      * @return Returns the <code>IColorExample</code> for this category. If one
60      * is not available, <code>null</code> is returned.
61      * @throws CoreException thrown if there is a problem instantiating the preview
62      */

63     public IThemePreview createPreview() throws CoreException {
64         String JavaDoc classString = element.getAttribute(IWorkbenchRegistryConstants.ATT_CLASS);
65         if (classString == null || "".equals(classString)) { //$NON-NLS-1$
66
return null;
67         }
68         return (IThemePreview) WorkbenchPlugin.createExtension(element,
69                 IWorkbenchRegistryConstants.ATT_CLASS);
70     }
71
72     /**
73      * @return Returns the description.
74      */

75     public String JavaDoc getDescription() {
76         return description;
77     }
78
79     /**
80      * @return Returns the element.
81      */

82     public IConfigurationElement getElement() {
83         return element;
84     }
85
86     /* (non-Javadoc)
87      * @see org.eclipse.ui.internal.themes.IThemeElementDefinition#getId()
88      */

89     public String JavaDoc getId() {
90         return id;
91     }
92
93     /* (non-Javadoc)
94      * @see org.eclipse.ui.internal.themes.IThemeElementDefinition#getLabel()
95      */

96     public String JavaDoc getName() {
97         return label;
98     }
99
100     /* (non-Javadoc)
101      * @see org.eclipse.ui.IPluginContribution#getLocalId()
102      */

103     public String JavaDoc getLocalId() {
104         return id;
105     }
106
107     /* (non-Javadoc)
108      * @see org.eclipse.ui.IPluginContribution#getPluginId()
109      */

110     public String JavaDoc getPluginId() {
111         return pluginId;
112     }
113
114     /**
115      * @return Returns the parentId. May be <code>null</code>.
116      */

117     public String JavaDoc getParentId() {
118         return parentId;
119     }
120     
121     /* (non-Javadoc)
122      * @see java.lang.Object#equals(java.lang.Object)
123      */

124     public boolean equals(Object JavaDoc obj) {
125         if (obj instanceof ThemeElementCategory) {
126             return getId().equals(((ThemeElementCategory)obj).getId());
127         }
128         return false;
129     }
130     
131     /* (non-Javadoc)
132      * @see java.lang.Object#hashCode()
133      */

134     public int hashCode() {
135         return id.hashCode();
136     }
137 }
138
Popular Tags