KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2004, 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
12 package org.eclipse.ui.internal.intro.impl.model.loader;
13
14 import org.eclipse.ui.internal.intro.impl.model.ExtensionMap;
15 import org.eclipse.ui.internal.intro.impl.model.IntroModelRoot;
16 import org.eclipse.ui.internal.intro.impl.util.Log;
17
18 /**
19  * Manages all Intro plugin extension points. Currently, there are two:
20  * org.eclipse.ui.intro.config & org.eclipse.ui.intro.configExtension. <br>
21  * The model is lazily loaded on per need basis. This happens when a page is
22  * asked for its children, or when the model is trying to resolve includes or
23  * extensions. <br>
24  */

25
26 public class ExtensionPointManager extends BaseExtensionPointManager {
27
28     // singleton instance. Can be retrieved from here or from the Intro Plugin.
29
private static ExtensionPointManager inst = new ExtensionPointManager();
30
31     // The root model class that represents a full/combined OOBBE config. This
32
// model is loaded based on an introId when the customizableIntroPart tries
33
// to load a model based on introId. This is different when includes and
34
// extension aer resolved because in tnose cases models are being loaded
35
// given an id and not an introId.
36
private IntroModelRoot currentModel;
37
38     // the id of the intro part contribution who's model (config) we are trying
39
// to load. The customizableIntroPart loads this id and loads the model that
40
// is bound to this intro id (ie: has this id as an introId).
41
private String JavaDoc introId;
42
43     /*
44      * Prevent creation.
45      */

46     private ExtensionPointManager() {
47         super();
48     }
49
50     /**
51      * @return Returns the inst.
52      */

53     public static ExtensionPointManager getInst() {
54         return inst;
55     }
56
57     /**
58      * Load the intro model given the current intro id.
59      */

60     private void loadCurrentModel() {
61         currentModel = loadModel(ATT_CONFIG_INTRO_ID, this.introId);
62     }
63
64     /**
65      * @return Returns the Intro Model root. Note: Prefereed way of getting to
66      * the intro model root is throught the intro plugin.
67      */

68     public IntroModelRoot getCurrentModel() {
69         if (currentModel == null)
70             // we never loaded this model before, or we tried before and we
71
// failed. Load it. Get the correct config element based on
72
// config introId, and log any extra contributions.
73
loadCurrentModel();
74         return currentModel;
75     }
76
77     /**
78      * Load an intro model given a config id.
79      *
80      * @param configId
81      * @return
82      */

83     public IntroModelRoot getModel(String JavaDoc configId) {
84         IntroModelRoot model = getCachedModel(configId);
85         if (model == null) {
86             // we never loaded this model before, or we tried before and we
87
// failed. Load it. Get the correct config element based on
88
// config id, and log any extra contributions.
89
model = loadModel(ATT_ID, configId);
90         }
91         return model;
92     }
93
94     /**
95      * @param introPartId
96      * The introPartId to set.
97      */

98     public void setIntroId(String JavaDoc introId) {
99         this.introId = introId;
100         // we do not have to clean model here. remove cached model, if it
101
// exists.
102
this.currentModel = null;
103     }
104
105     public void clear() {
106         currentModel = null;
107         sharedConfigExtensionsManager = null;
108         introModels.clear();
109         ExtensionMap.getInstance().clear();
110         if (Log.logInfo)
111             Log.info("Cleared Intro model"); //$NON-NLS-1$
112
}
113
114
115 }
116
Popular Tags