KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > intro > impl > model > ExtensionMap


1 /*******************************************************************************
2  * Copyright (c) 2007 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
12 package org.eclipse.ui.internal.intro.impl.model;
13
14 import java.util.HashMap JavaDoc;
15 import java.util.Map JavaDoc;
16
17 /**
18  * This package maintains the mapping between extension ids in the registry and extension ids
19  * as defined in extension files. It also allows a configurer to change the page which will be
20  * displayed when the welcome screen is shown.
21  */

22
23 public class ExtensionMap {
24     
25     private static ExtensionMap instance;
26     private static String JavaDoc startPage;
27     private Map JavaDoc extensions = new HashMap JavaDoc();
28     
29     private ExtensionMap() {
30         
31     }
32     
33     /**
34      * Get the one and only instance of this class
35      * @return
36      */

37     static public ExtensionMap getInstance() {
38         if (instance == null) {
39             instance = new ExtensionMap();
40         }
41         return instance;
42     }
43
44     /**
45      * Save an association beteen an anchorId and pluginId
46      * @param anchorId the id of an anchor
47      * @param pluginId the plugin which contributed that anchor
48      */

49     public void putPluginId(String JavaDoc anchorId, String JavaDoc pluginId) {
50         if (anchorId != null) {
51             extensions.put(anchorId, pluginId);
52         }
53     }
54     
55     /**
56      * Lookup in which plugin
57      * @param anchorId
58      * @return the plugin which contributed that anchor
59      */

60     public String JavaDoc getPluginId(String JavaDoc anchorId) {
61         return (String JavaDoc)extensions.get(anchorId);
62     }
63
64     /**
65      * Clear the map and content page
66      */

67     public void clear() {
68         extensions = new HashMap JavaDoc();
69         startPage = null;
70     }
71
72     /**
73      * called to determine if the configurer has overriden the start page
74      * @return the new start page or null.
75      */

76     public String JavaDoc getStartPage() {
77         return startPage;
78     }
79     
80     /**
81      * Allows a configurer to override the page which is displayed when
82      * the welcome screen is first shown
83      * @param contentPage
84      */

85     public void setStartPage(String JavaDoc contentPage) {
86         startPage = contentPage;
87     }
88
89 }
90
Popular Tags