KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > registry > ViewRegistryReader


1 /*******************************************************************************
2  * Copyright (c) 2000, 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 package org.eclipse.ui.internal.registry;
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.WorkbenchPlugin;
18
19 /**
20  * A strategy to read view extensions from the registry.
21  */

22 public class ViewRegistryReader extends RegistryReader {
23     /**
24      * General view category id
25      */

26     public static String JavaDoc GENERAL_VIEW_ID = "org.eclipse.ui"; //$NON-NLS-1$
27

28     private ViewRegistry viewRegistry;
29
30     /**
31      * RegistryViewReader constructor comment.
32      */

33     public ViewRegistryReader() {
34         super();
35     }
36
37     /**
38      * Reads the category element.
39      */

40     protected void readCategory(IConfigurationElement element) {
41         try {
42             viewRegistry.add(new Category(element));
43         } catch (CoreException e) {
44             // log an error since its not safe to show a dialog here
45
WorkbenchPlugin.log(
46                     "Unable to create view category.", e.getStatus());//$NON-NLS-1$
47
}
48     }
49
50     /**
51      * readElement method comment.
52      */

53     protected boolean readElement(IConfigurationElement element) {
54         if (element.getName().equals(IWorkbenchRegistryConstants.TAG_VIEW)) {
55             readView(element);
56             return true;
57         }
58         if (element.getName().equals(IWorkbenchRegistryConstants.TAG_CATEGORY)) {
59             readCategory(element);
60             readElementChildren(element);
61             return true;
62         }
63         if (element.getName().equals(IWorkbenchRegistryConstants.TAG_STICKYVIEW)) {
64             readSticky(element);
65             return true;
66         }
67
68         return false;
69     }
70
71     /**
72      * Reads the sticky view element.
73      */

74     protected void readSticky(IConfigurationElement element) {
75         try {
76             viewRegistry.add(new StickyViewDescriptor(element));
77         } catch (CoreException e) {
78             // log an error since its not safe to open a dialog here
79
WorkbenchPlugin.log(
80                     "Unable to create sticky view descriptor.", e.getStatus());//$NON-NLS-1$
81

82         }
83     }
84
85     /**
86      * Reads the view element.
87      */

88     protected void readView(IConfigurationElement element) {
89         try {
90             viewRegistry.add(new ViewDescriptor(element));
91         } catch (CoreException e) {
92             // log an error since its not safe to open a dialog here
93
WorkbenchPlugin.log(
94                     "Unable to create view descriptor.", e.getStatus());//$NON-NLS-1$
95
}
96     }
97
98     /**
99      * Read the view extensions within a registry.
100      * @param in the extension registry
101      * @param out the view registry
102      */

103     public void readViews(IExtensionRegistry in, ViewRegistry out) {
104         // this does not seem to really ever be throwing an the exception
105
viewRegistry = out;
106         readRegistry(in, PlatformUI.PLUGIN_ID, IWorkbenchRegistryConstants.PL_VIEWS);
107     }
108 }
109
Popular Tags