KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > ObjectActionContributorReader


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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;
12
13 import org.eclipse.core.runtime.IConfigurationElement;
14 import org.eclipse.core.runtime.IExtensionRegistry;
15 import org.eclipse.core.runtime.Platform;
16 import org.eclipse.ui.PlatformUI;
17 import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
18 import org.eclipse.ui.internal.registry.RegistryReader;
19
20 /**
21  * This reader loads the popup menu manager with all the
22  * popup menu contributors found in the workbench registry.
23  */

24 public class ObjectActionContributorReader extends RegistryReader {
25
26     private ObjectActionContributorManager manager;
27
28     /**
29      * Creates popup menu contributor from this element.
30      */

31     protected void processObjectContribution(IConfigurationElement element) {
32         String JavaDoc objectClassName = element.getAttribute(IWorkbenchRegistryConstants.ATT_OBJECTCLASS);
33         if (objectClassName == null) {
34             logMissingAttribute(element, IWorkbenchRegistryConstants.ATT_OBJECTCLASS);
35             return;
36         }
37
38         IObjectContributor contributor = new ObjectActionContributor(element);
39         manager.registerContributor(contributor, objectClassName);
40     }
41
42     /**
43      * Implements abstract method to handle configuration elements.
44      */

45     protected boolean readElement(IConfigurationElement element) {
46         String JavaDoc tagName = element.getName();
47         if (tagName.equals(IWorkbenchRegistryConstants.TAG_OBJECT_CONTRIBUTION)) {
48             processObjectContribution(element);
49             return true;
50         }
51         if (tagName.equals(IWorkbenchRegistryConstants.TAG_VIEWER_CONTRIBUTION)) {
52             return true;
53         }
54
55         return false;
56     }
57
58     /**
59      * Reads the registry and registers popup menu contributors
60      * found there.
61      *
62      * @param mng the manager to read into
63      */

64     public void readPopupContributors(ObjectActionContributorManager mng) {
65         setManager(mng);
66         IExtensionRegistry registry = Platform.getExtensionRegistry();
67         readRegistry(registry, PlatformUI.PLUGIN_ID,
68                 IWorkbenchRegistryConstants.PL_POPUP_MENU);
69     }
70
71     /**
72      * Set the manager to read into.
73      *
74      * @param mng the manager
75      */

76     public void setManager(ObjectActionContributorManager mng) {
77         manager = mng;
78     }
79 }
80
Popular Tags