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.activities.ws;
11:
12: import java.util.HashMap;
13: import java.util.Map;
14:
15: import org.eclipse.core.runtime.IConfigurationElement;
16: import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
17:
18: /**
19: * @since 3.1
20: */
21: public class RegistryTriggerPoint extends AbstractTriggerPoint {
22:
23: private String id;
24:
25: private IConfigurationElement element;
26:
27: private Map hints;
28:
29: /**
30: * Create a new instance of this class.
31: *
32: * @param id the id of the trigger point
33: * @param element the defining configuration element
34: */
35: public RegistryTriggerPoint(String id, IConfigurationElement element) {
36: this .id = id;
37: this .element = element;
38: }
39:
40: /*
41: * (non-Javadoc)
42: *
43: * @see org.eclipse.ui.activities.ITriggerPoint#getId()
44: */
45: public String getId() {
46: return id;
47: }
48:
49: /*
50: * (non-Javadoc)
51: *
52: * @see org.eclipse.ui.activities.ITriggerPoint#getStringHint(java.lang.String)
53: */
54: public String getStringHint(String key) {
55: return (String) getHints().get(key);
56: }
57:
58: /*
59: * (non-Javadoc)
60: *
61: * @see org.eclipse.ui.activities.ITriggerPoint#getBooleanHint(java.lang.String)
62: */
63: public boolean getBooleanHint(String key) {
64: return Boolean.valueOf(getStringHint(key)).booleanValue();
65: }
66:
67: /**
68: * Lazily create the hints.
69: *
70: * @return the hint map
71: */
72: private Map getHints() {
73: if (hints == null) {
74: hints = new HashMap();
75:
76: IConfigurationElement[] hintElements = element
77: .getChildren(IWorkbenchRegistryConstants.TAG_HINT);
78: for (int i = 0; i < hintElements.length; i++) {
79: String id = hintElements[i]
80: .getAttribute(IWorkbenchRegistryConstants.ATT_ID);
81: String value = hintElements[i]
82: .getAttribute(IWorkbenchRegistryConstants.ATT_VALUE);
83:
84: if (id != null && value != null) {
85: hints.put(id, value);
86: }
87: }
88: }
89:
90: return hints;
91: }
92: }
|