1 11 package org.eclipse.team.internal.ui.registry; 12 13 import org.eclipse.core.runtime.*; 14 import org.eclipse.osgi.util.NLS; 15 import org.eclipse.team.core.diff.IThreeWayDiff; 16 import org.eclipse.team.internal.ui.TeamUIMessages; 17 import org.eclipse.team.internal.ui.TeamUIPlugin; 18 19 public class TeamDecoratorDescription { 20 21 private static final String TAG_TEAM_DECORATOR = "teamDecorator"; private static final String ATT_REPOSITORY_ID = "repositoryId"; private static final String ATT_DECORATOR_ID = "decoratorId"; private static final String ATT_DECORATED_DIRECTION_ID = "decoratedDirection"; private static final String OUTGOING_FLAG = "OUTGOING"; private static final String INCOMING_FLAG = "INCOMING"; 28 private String repositoryId; 29 private String decoratorId; 30 private int decoratedDirection; 31 32 public TeamDecoratorDescription(IExtension extension) throws CoreException { 33 readExtension(extension); 34 } 35 36 39 protected void readExtension(IExtension extension) throws CoreException { 40 String id = extension.getUniqueIdentifier(); IConfigurationElement[] elements = extension.getConfigurationElements(); 43 int count = elements.length; 44 for (int i = 0; i < count; i++) { 45 IConfigurationElement element = elements[i]; 46 String name = element.getName(); 47 if (name.equalsIgnoreCase(TAG_TEAM_DECORATOR)) { 48 repositoryId = element.getAttribute(ATT_REPOSITORY_ID); 49 decoratorId = element.getAttribute(ATT_DECORATOR_ID); 50 String flags = element.getAttribute(ATT_DECORATED_DIRECTION_ID); 51 if (flags == null) { 52 decoratedDirection = IThreeWayDiff.INCOMING | IThreeWayDiff.OUTGOING; 53 } else { 54 if (flags.indexOf(INCOMING_FLAG) != -1) { 55 decoratedDirection |= IThreeWayDiff.INCOMING; 56 } 57 if (flags.indexOf(OUTGOING_FLAG) != -1) { 58 decoratedDirection |= IThreeWayDiff.OUTGOING; 59 } 60 if (decoratedDirection == 0) { 61 decoratedDirection = IThreeWayDiff.INCOMING | IThreeWayDiff.OUTGOING; 62 } 63 } 64 } 65 } 66 if (repositoryId == null) 67 fail(NLS.bind(TeamUIMessages.TeamContentProviderDescriptor_1, new String [] { ATT_REPOSITORY_ID, TAG_TEAM_DECORATOR, id == null ? "" : id})); if (repositoryId == null) 69 fail(NLS.bind(TeamUIMessages.TeamContentProviderDescriptor_1, new String [] { ATT_DECORATOR_ID, TAG_TEAM_DECORATOR, id == null ? "" : id})); } 71 72 protected void fail(String reason) throws CoreException { 73 throw new CoreException(new Status(IStatus.ERROR, TeamUIPlugin.ID, 0, reason, null)); 74 } 75 76 public String getDecoratorId() { 77 return decoratorId; 78 } 79 80 public String getRepositoryId() { 81 return repositoryId; 82 } 83 84 public int getDecoratedDirectionFlags() { 85 return decoratedDirection; 86 } 87 } 88 | Popular Tags |