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 working set extensions from the registry.
20: */
21: public class WorkingSetRegistryReader extends RegistryReader {
22:
23: private WorkingSetRegistry registry;
24:
25: /**
26: * Create a new instance of this reader.
27: */
28: public WorkingSetRegistryReader() {
29: super ();
30: }
31:
32: /**
33: * Create a new instance of this reader.
34: *
35: * @param registry the registry to populate
36: */
37: public WorkingSetRegistryReader(WorkingSetRegistry registry) {
38: super ();
39: this .registry = registry;
40: }
41:
42: /**
43: * Overrides method in RegistryReader.
44: *
45: * @see RegistryReader#readElement(IConfigurationElement)
46: */
47: public boolean readElement(IConfigurationElement element) {
48: if (element.getName().equals(
49: IWorkbenchRegistryConstants.TAG_WORKING_SET)) {
50: try {
51: WorkingSetDescriptor desc = new WorkingSetDescriptor(
52: element);
53: registry.addWorkingSetDescriptor(desc);
54: } catch (CoreException e) {
55: // log an error since its not safe to open a dialog here
56: WorkbenchPlugin
57: .log(
58: "Unable to create working set descriptor.", e.getStatus());//$NON-NLS-1$
59: }
60: return true;
61: }
62:
63: return false;
64: }
65:
66: /**
67: * Reads the working set extensions within a registry.
68: *
69: * @param in the plugin registry to read from
70: * @param out the working set registry to store read entries in.
71: */
72: public void readWorkingSets(IExtensionRegistry in,
73: WorkingSetRegistry out) {
74: registry = out;
75: readRegistry(in, PlatformUI.PLUGIN_ID,
76: IWorkbenchRegistryConstants.PL_WORKINGSETS);
77: }
78: }
|