KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > activities > ws > RegistryTriggerPoint


1 /*******************************************************************************
2  * Copyright (c) 2005, 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.activities.ws;
12
13 import java.util.HashMap JavaDoc;
14 import java.util.Map JavaDoc;
15
16 import org.eclipse.core.runtime.IConfigurationElement;
17 import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
18
19 /**
20  * @since 3.1
21  */

22 public class RegistryTriggerPoint extends AbstractTriggerPoint {
23
24     private String JavaDoc id;
25
26     private IConfigurationElement element;
27
28     private Map JavaDoc hints;
29
30     /**
31      * Create a new instance of this class.
32      *
33      * @param id the id of the trigger point
34      * @param element the defining configuration element
35      */

36     public RegistryTriggerPoint(String JavaDoc id, IConfigurationElement element) {
37         this.id = id;
38         this.element = element;
39     }
40
41     /*
42      * (non-Javadoc)
43      *
44      * @see org.eclipse.ui.activities.ITriggerPoint#getId()
45      */

46     public String JavaDoc getId() {
47         return id;
48     }
49
50     /*
51      * (non-Javadoc)
52      *
53      * @see org.eclipse.ui.activities.ITriggerPoint#getStringHint(java.lang.String)
54      */

55     public String JavaDoc getStringHint(String JavaDoc key) {
56         return (String JavaDoc) getHints().get(key);
57     }
58
59     /*
60      * (non-Javadoc)
61      *
62      * @see org.eclipse.ui.activities.ITriggerPoint#getBooleanHint(java.lang.String)
63      */

64     public boolean getBooleanHint(String JavaDoc key) {
65         return Boolean.valueOf(getStringHint(key)).booleanValue();
66     }
67
68     /**
69      * Lazily create the hints.
70      *
71      * @return the hint map
72      */

73     private Map JavaDoc getHints() {
74         if (hints == null) {
75             hints = new HashMap JavaDoc();
76
77             IConfigurationElement[] hintElements = element
78                     .getChildren(IWorkbenchRegistryConstants.TAG_HINT);
79             for (int i = 0; i < hintElements.length; i++) {
80                 String JavaDoc id = hintElements[i]
81                         .getAttribute(IWorkbenchRegistryConstants.ATT_ID);
82                 String JavaDoc value = hintElements[i]
83                         .getAttribute(IWorkbenchRegistryConstants.ATT_VALUE);
84
85                 if (id != null && value != null) {
86                     hints.put(id, value);
87                 }
88             }
89         }
90
91         return hints;
92     }
93 }
94
Popular Tags