KickJava   Java API By Example, From Geeks To Geeks.

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


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 working set extensions from the registry.
21  */

22 public class WorkingSetRegistryReader extends RegistryReader {
23     
24
25     private WorkingSetRegistry registry;
26
27     /**
28      * Create a new instance of this reader.
29      */

30     public WorkingSetRegistryReader() {
31         super();
32     }
33
34     /**
35      * Create a new instance of this reader.
36      *
37      * @param registry the registry to populate
38      */

39     public WorkingSetRegistryReader(WorkingSetRegistry registry) {
40         super();
41         this.registry = registry;
42     }
43
44     /**
45      * Overrides method in RegistryReader.
46      *
47      * @see RegistryReader#readElement(IConfigurationElement)
48      */

49     public boolean readElement(IConfigurationElement element) {
50         if (element.getName().equals(IWorkbenchRegistryConstants.TAG_WORKING_SET)) {
51             try {
52                 WorkingSetDescriptor desc = new WorkingSetDescriptor(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, WorkingSetRegistry out) {
73         registry = out;
74         readRegistry(in, PlatformUI.PLUGIN_ID,
75                 IWorkbenchRegistryConstants.PL_WORKINGSETS);
76     }
77 }
78
Popular Tags