Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 45666fa80b463116de0937581e9429f017a65b1a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*******************************************************************************
 * Copyright (c) 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.ui.internal.intro.impl.model;

import java.util.HashMap;
import java.util.Map;

/**
 * This package maintains the mapping between extension ids in the registry and extension ids
 * as defined in extension files. It also allows a configurer to change the page which will be 
 * displayed when the welcome screen is shown.
 */

public class ExtensionMap {
	
	private static ExtensionMap instance;
	private static String startPage;
	private Map<String, String> extensions = new HashMap<>();
	
	private ExtensionMap() {
		
	}
	
	/**
	 * Get the one and only instance of this class
	 * @return
	 */
	static public ExtensionMap getInstance() {
		if (instance == null) {
			instance = new ExtensionMap();
		}
		return instance;
	}

	/**
	 * Save an association beteen an anchorId and pluginId
	 * @param anchorId the id of an anchor
	 * @param pluginId the plugin which contributed that anchor
	 */
	public void putPluginId(String anchorId, String pluginId) {
		if (anchorId != null) {
		    extensions.put(anchorId, pluginId);
		}
	}
	
	/**
	 * Lookup in which plugin 
	 * @param anchorId
	 * @return the plugin which contributed that anchor
	 */
	public String getPluginId(String anchorId) {
		return (String)extensions.get(anchorId);
	}

	/**
	 * Clear the map and content page
	 */
	public void clear() {
		extensions = new HashMap<>();
		startPage = null;
	}

	/**
	 * called to determine if the configurer has overriden the start page
	 * @return the new start page or null.
	 */
	public String getStartPage() {
		return startPage;
	}
	
	/**
	 * Allows a configurer to override the page which is displayed when 
	 * the welcome screen is first shown
	 * @param contentPage
	 */
	public void setStartPage(String contentPage) {
		startPage = contentPage;
	}

}

Back to the top