1 11 package org.eclipse.ui.internal.registry; 12 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.IWorkbenchConstants; 17 import org.eclipse.ui.internal.WorkbenchPlugin; 18 19 22 public class ActionSetPartAssociationsReader extends RegistryReader { 23 private ActionSetRegistry registry; 24 private static final String TAG_EXTENSION="actionSetPartAssociation"; private static final String TAG_PART="part"; private static final String ATT_ID="id"; private static final String ATT_TARGET_ID="targetID"; 29 32 public ActionSetPartAssociationsReader() { 33 super(); 34 } 35 public ActionSetPartAssociationsReader(ActionSetRegistry registry) { 37 this.registry = registry; 38 } 39 40 43 private boolean processExtension(IConfigurationElement element) { 44 String actionSetId = element.getAttribute(ATT_TARGET_ID); 45 IConfigurationElement [] children = element.getChildren(); 46 for (int i = 0; i < children.length; i++) { 47 IConfigurationElement child = children[i]; 48 String type = child.getName(); 49 if (type.equals(TAG_PART)) { 50 String partId = child.getAttribute(ATT_ID); 51 if (partId != null) 52 registry.addAssociation(actionSetId, partId); 53 } else { 54 WorkbenchPlugin.log("Unable to process element: " + type + 56 " in action set part associations extension: " + element.getDeclaringExtension().getUniqueIdentifier()); 58 } 59 } 60 return true; 61 } 62 63 66 public boolean readElement(IConfigurationElement element) { 68 String type = element.getName(); 69 if (type.equals(TAG_EXTENSION)) { 70 return processExtension(element); 71 } 72 return false; 73 } 74 75 78 public void readRegistry(IExtensionRegistry in, ActionSetRegistry out) 79 { 80 registry = out; 81 readRegistry(in, PlatformUI.PLUGIN_ID, IWorkbenchConstants.PL_ACTION_SET_PART_ASSOCIATIONS); 82 } 83 } 84 | Popular Tags |