1 11 package org.eclipse.team.internal.ui.synchronize; 12 13 import org.eclipse.jface.resource.JFaceResources; 14 import org.eclipse.jface.viewers.*; 15 import org.eclipse.osgi.util.NLS; 16 import org.eclipse.swt.SWT; 17 import org.eclipse.swt.graphics.*; 18 import org.eclipse.team.internal.core.subscribers.*; 19 import org.eclipse.team.internal.ui.TeamUIMessages; 20 import org.eclipse.team.internal.ui.TeamUIPlugin; 21 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; 22 import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; 23 24 27 public class ChangeSetLabelDecorator extends LabelProvider implements ILabelDecorator, IFontDecorator{ 28 29 private Font boldFont; 30 private ActiveChangeSetManager collector; 31 32 public ChangeSetLabelDecorator(ISynchronizePageConfiguration configuration) { 33 ISynchronizeParticipant participant = configuration.getParticipant(); 34 if (participant instanceof IChangeSetProvider) { 35 this.collector = ((IChangeSetProvider)participant).getChangeSetCapability().getActiveChangeSetManager(); 36 } 37 } 38 39 public String decorateText(String input, Object element) { 40 String text = input; 41 if (element instanceof ChangeSetDiffNode) { 42 ChangeSet set = ((ChangeSetDiffNode)element).getSet(); 43 if (set instanceof ActiveChangeSet && isDefaultActiveSet((ActiveChangeSet)set)) { 44 text = NLS.bind(TeamUIMessages.CommitSetDiffNode_0, new String [] { text }); 45 } 46 } 47 return text; 48 } 49 50 public void dispose() { 51 if(boldFont != null) { 52 boldFont.dispose(); 53 } 54 } 55 56 public Font decorateFont(Object element) { 57 if (element instanceof ChangeSetDiffNode) { 58 ChangeSet set = ((ChangeSetDiffNode)element).getSet(); 59 if (set instanceof ActiveChangeSet && isDefaultActiveSet((ActiveChangeSet)set)) { 60 if (boldFont == null) { 61 Font defaultFont = JFaceResources.getDefaultFont(); 62 FontData[] data = defaultFont.getFontData(); 63 for (int i = 0; i < data.length; i++) { 64 data[i].setStyle(SWT.BOLD); 65 } 66 boldFont = new Font(TeamUIPlugin.getStandardDisplay(), data); 67 } 68 return boldFont; 69 } 70 } 71 return null; 72 } 73 74 private boolean isDefaultActiveSet(ActiveChangeSet set) { 75 return collector.isDefault(set); 76 } 77 78 81 public Image decorateImage(Image image, Object element) { 82 return image; 83 } 84 85 } 86 | Popular Tags |