KickJava   Java API By Example, From Geeks To Geeks.

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


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 PerspectiveRegistryReader extends RegistryReader {
23     private PerspectiveRegistry registry;
24
25     /**
26      * RegistryViewReader constructor comment.
27      *
28      * @param out the output registry
29      */

30     public PerspectiveRegistryReader(PerspectiveRegistry out) {
31         super();
32         registry = out;
33     }
34
35     /**
36      * readElement method comment.
37      */

38     // for dynamic UI - change access from protected to public
39
protected boolean readElement(IConfigurationElement element) {
40         if (element.getName().equals(IWorkbenchRegistryConstants.TAG_PERSPECTIVE)) {
41             try {
42                 PerspectiveDescriptor desc = new PerspectiveDescriptor(element.getAttribute(IWorkbenchRegistryConstants.ATT_ID), element);
43                 registry.addPerspective(desc);
44             } catch (CoreException e) {
45                 // log an error since its not safe to open a dialog here
46
WorkbenchPlugin.log(
47                         "Unable to create layout descriptor.", e.getStatus());//$NON-NLS-1$
48
}
49             return true;
50         }
51
52         return false;
53     }
54
55     /**
56      * Read the view extensions within a registry.
57      *
58      * @param in the registry to read
59      */

60     public void readPerspectives(IExtensionRegistry in) {
61         readRegistry(in, PlatformUI.PLUGIN_ID,
62                 IWorkbenchRegistryConstants.PL_PERSPECTIVES);
63     }
64 }
65
Popular Tags