01: /*******************************************************************************
02: * Copyright (c) 2000, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.registry;
11:
12: import org.eclipse.core.runtime.CoreException;
13: import org.eclipse.core.runtime.IConfigurationElement;
14: import org.eclipse.core.runtime.IExtensionRegistry;
15: import org.eclipse.ui.PlatformUI;
16: import org.eclipse.ui.internal.WorkbenchPlugin;
17:
18: /**
19: * A strategy to read view extensions from the registry.
20: */
21: public class PerspectiveRegistryReader extends RegistryReader {
22: private PerspectiveRegistry registry;
23:
24: /**
25: * RegistryViewReader constructor comment.
26: *
27: * @param out the output registry
28: */
29: public PerspectiveRegistryReader(PerspectiveRegistry out) {
30: super ();
31: registry = out;
32: }
33:
34: /**
35: * readElement method comment.
36: */
37: // for dynamic UI - change access from protected to public
38: protected boolean readElement(IConfigurationElement element) {
39: if (element.getName().equals(
40: IWorkbenchRegistryConstants.TAG_PERSPECTIVE)) {
41: try {
42: PerspectiveDescriptor desc = new PerspectiveDescriptor(
43: element
44: .getAttribute(IWorkbenchRegistryConstants.ATT_ID),
45: element);
46: registry.addPerspective(desc);
47: } catch (CoreException e) {
48: // log an error since its not safe to open a dialog here
49: WorkbenchPlugin
50: .log(
51: "Unable to create layout descriptor.", e.getStatus());//$NON-NLS-1$
52: }
53: return true;
54: }
55:
56: return false;
57: }
58:
59: /**
60: * Read the view extensions within a registry.
61: *
62: * @param in the registry to read
63: */
64: public void readPerspectives(IExtensionRegistry in) {
65: readRegistry(in, PlatformUI.PLUGIN_ID,
66: IWorkbenchRegistryConstants.PL_PERSPECTIVES);
67: }
68: }
|