1 11 package org.eclipse.team.internal.ui.registry; 12 13 import org.eclipse.core.runtime.*; 14 import org.eclipse.jface.resource.ImageDescriptor; 15 import org.eclipse.team.internal.ui.TeamUIPlugin; 16 import org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor; 17 18 public class SynchronizeParticipantDescriptor implements ISynchronizeParticipantDescriptor { 19 public static final String ATT_ID = "id"; public static final String ATT_NAME = "name"; public static final String ATT_ICON = "icon"; public static final String ATT_CLASS = "class"; private static final String ATT_PERSISTENT = "persistent"; 25 private String label; 26 private String className; 27 private String id; 28 private boolean persistent; 29 private ImageDescriptor imageDescriptor; 30 private String description; 31 32 private IConfigurationElement configElement; 33 34 37 public SynchronizeParticipantDescriptor(IConfigurationElement e, String desc) throws CoreException { 38 configElement = e; 39 description = desc; 40 loadFromExtension(); 41 } 42 43 public IConfigurationElement getConfigurationElement() { 44 return configElement; 45 } 46 47 53 public String getDescription() { 54 return description; 55 } 56 57 public String getId() { 58 return id; 59 } 60 61 public ImageDescriptor getImageDescriptor() { 62 if (imageDescriptor != null) 63 return imageDescriptor; 64 String iconName = configElement.getAttribute(ATT_ICON); 65 if (iconName == null) 66 return null; 67 imageDescriptor = TeamUIPlugin.getImageDescriptorFromExtension(configElement.getDeclaringExtension(), iconName); 68 return imageDescriptor; 69 } 70 71 public String getName() { 72 return label; 73 } 74 75 78 public boolean isPersistent() { 79 return persistent; 80 } 81 82 85 private void loadFromExtension() throws CoreException { 86 String identifier = configElement.getAttribute(ATT_ID); 87 label = configElement.getAttribute(ATT_NAME); 88 className = configElement.getAttribute(ATT_CLASS); 89 String persistentString = configElement.getAttribute(ATT_PERSISTENT); 90 if(persistentString == null) { 91 persistent = true; 92 } else { 93 persistent = Boolean.valueOf(persistentString).booleanValue(); 94 } 95 if ((label == null) || (className == null) || (identifier == null)) { 97 throw new CoreException(new Status(IStatus.ERROR, configElement.getNamespace(), 0, "Invalid extension (missing label or class name): " + identifier, null)); 99 } 100 id = identifier; 101 } 102 103 107 public String toString() { 108 return "Synchronize Participant(" + getId() + ")"; } 110 } 111 | Popular Tags |