01: /*******************************************************************************
02: * Copyright (c) 2005, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.intro.impl.model;
11:
12: import java.util.Hashtable;
13: import java.util.Map;
14:
15: import org.eclipse.core.runtime.IConfigurationElement;
16: import org.eclipse.ui.internal.intro.impl.model.util.BundleUtil;
17: import org.osgi.framework.Bundle;
18: import org.w3c.dom.Element;
19:
20: public class IntroTheme extends AbstractIntroIdElement {
21: private static final String ATT_PATH = "path"; //$NON-NLS-1$
22: private String name;
23: private String path;
24: private Hashtable properties;
25:
26: public IntroTheme(IConfigurationElement element) {
27: super (element);
28: name = element.getAttribute(name);
29: path = element.getAttribute(ATT_PATH);
30: path = BundleUtil
31: .getResolvedResourceLocation(path, getBundle());
32: loadProperties(element);
33: }
34:
35: public IntroTheme(Element element, Bundle bundle) {
36: super (element, bundle);
37: }
38:
39: public IntroTheme(Element element, Bundle bundle, String base) {
40: super (element, bundle, base);
41: }
42:
43: public String getName() {
44: return name;
45: }
46:
47: public String getPath() {
48: return path;
49: }
50:
51: public int getType() {
52: return THEME;
53: }
54:
55: public Map getProperties() {
56: return properties;
57: }
58:
59: private void loadProperties(IConfigurationElement element) {
60: IConfigurationElement[] children = element
61: .getChildren("property"); //$NON-NLS-1$
62: if (children.length == 0)
63: return;
64: properties = new Hashtable();
65: for (int i = 0; i < children.length; i++) {
66: IConfigurationElement property = children[i];
67: String name = property.getAttribute("name"); //$NON-NLS-1$
68: String value = property.getAttribute("value"); //$NON-NLS-1$
69: if (name != null && value != null)
70: properties.put(name, value);
71: }
72: }
73: }
|