KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > intro > IntroRegistryReader


1 /*******************************************************************************
2  * Copyright (c) 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.intro;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.IConfigurationElement;
15 import org.eclipse.core.runtime.IExtensionRegistry;
16 import org.eclipse.ui.PlatformUI;
17 import org.eclipse.ui.internal.IWorkbenchConstants;
18 import org.eclipse.ui.internal.WorkbenchPlugin;
19 import org.eclipse.ui.internal.registry.RegistryReader;
20
21 /**
22  * Introduction registry reader.
23  *
24  * @since 3.0
25  */

26 public class IntroRegistryReader extends RegistryReader {
27     private static final String JavaDoc TAG_INTRO = "intro";//$NON-NLS-1$
28
private static final String JavaDoc TAG_INTROPRODUCTBINDING = "introProductBinding";//$NON-NLS-1$
29
private IntroRegistry introRegistry;
30
31     /**
32      */

33     public IntroRegistryReader() {
34         super();
35     }
36     
37     /* (non-Javadoc)
38      * @see org.eclipse.ui.internal.registry.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement)
39      */

40     protected boolean readElement(IConfigurationElement element) {
41         if (element.getName().equals(TAG_INTRO)) {
42             readIntro(element);
43             return true;
44         }
45         else if (element.getName().equals(TAG_INTROPRODUCTBINDING)) {
46             readBinding(element);
47             return true;
48         }
49         return false;
50     }
51
52     /**
53      * Read binding information.
54      *
55      * @param element the configuration element to be read.
56      */

57     private void readBinding(IConfigurationElement element) {
58         try {
59             introRegistry.addBinding(element);
60         }
61         catch (CoreException e) {
62             // log an error since its not safe to open a dialog here
63
WorkbenchPlugin.log(IntroMessages.getString("Intro.could_not_create_binding") , e.getStatus());//$NON-NLS-1$
64
}
65     }
66
67     /**
68      * Read introduction information.
69      *
70      * @param element the configuration element to read.
71      */

72     private void readIntro(IConfigurationElement element) {
73         try {
74             IIntroDescriptor descriptor = new IntroDescriptor(element);
75             introRegistry.add(descriptor);
76         }
77         catch (CoreException e) {
78             // log an error since its not safe to open a dialog here
79
WorkbenchPlugin.log(IntroMessages.getString("Intro.could_not_create_descriptor") , e.getStatus());//$NON-NLS-1$
80
}
81     }
82     
83     /**
84      * Read all introdcution extensions from the registry.
85      *
86      * @param in the registry to read.
87      * @param out the registry to populate.
88      */

89     public void readIntros(IExtensionRegistry in, IntroRegistry out) {
90         introRegistry = out;
91         readRegistry(in, PlatformUI.PLUGIN_ID, IWorkbenchConstants.PL_INTRO);
92     }
93 }
94
Popular Tags