1 19 20 package org.netbeans.modules.merge.builtin.visualizer; 21 22 import java.awt.Color ; 23 import java.awt.Component ; 24 import java.io.IOException ; 26 import java.io.Serializable ; 27 import java.util.Iterator ; 28 import java.util.Set ; 29 30 import org.openide.util.NbBundle; 31 import org.openide.util.WeakListeners; 32 import org.openide.windows.TopComponent; 33 34 import org.netbeans.api.diff.Difference; 35 import org.netbeans.api.diff.StreamSource; 36 import org.netbeans.spi.diff.MergeVisualizer; 37 38 43 public class GraphicalMergeVisualizer extends MergeVisualizer implements Serializable { 44 45 private Color colorUnresolvedConflict = new java.awt.Color (255, 160, 180); 46 private Color colorResolvedConflict = new java.awt.Color (180, 255, 180); 47 private Color colorOtherConflict = new java.awt.Color (160, 200, 255); 48 49 50 private MergeDialogComponent merge; 51 52 static final long serialVersionUID =-2175410667258166512L; 53 54 public GraphicalMergeVisualizer() { 55 merge = null; 56 } 58 59 62 public String getDisplayName() { 63 return NbBundle.getMessage(GraphicalMergeVisualizer.class, "GraphicalMergeVisualizer.displayName"); 64 } 65 66 69 public String getShortDescription() { 70 return NbBundle.getMessage(GraphicalMergeVisualizer.class, "GraphicalMergeVisualizer.shortDescription"); 71 } 72 73 86 public Component createView(Difference[] diffs, StreamSource source1, 87 StreamSource source2, StreamSource result) throws IOException { 88 synchronized (this) { 89 if (merge == null) { 91 Set opened = TopComponent.getRegistry().getOpened(); 92 for (Iterator it = opened.iterator(); it.hasNext(); ) { 93 Object component = it.next(); 94 if (component instanceof MergeDialogComponent) { 95 merge = (MergeDialogComponent) component; 96 break; 97 } 98 } 99 if (merge == null) { 100 merge = new MergeDialogComponent(); 101 } 102 } 103 } 104 if (!merge.isOpened()) merge.open(); 105 106 MergePanel panel = new MergePanel(); 107 MergeControl control = new MergeControl(panel); 108 control.initialize(diffs, source1, source2, result, 109 colorUnresolvedConflict, colorResolvedConflict, 110 colorOtherConflict); 111 merge.addVetoableChangeListener(WeakListeners.vetoableChange(control, merge)); 112 merge.addMergePanel(panel); 113 return merge; 114 } 115 116 119 public java.awt.Color getColorUnresolvedConflict() { 120 return colorUnresolvedConflict; 121 } 122 123 126 public void setColorUnresolvedConflict(java.awt.Color colorUnresolvedConflict) { 127 this.colorUnresolvedConflict = colorUnresolvedConflict; 128 } 129 130 133 public java.awt.Color getColorResolvedConflict() { 134 return colorResolvedConflict; 135 } 136 137 140 public void setColorResolvedConflict(java.awt.Color colorResolvedConflict) { 141 this.colorResolvedConflict = colorResolvedConflict; 142 } 143 144 147 public java.awt.Color getColorOtherConflict() { 148 return colorOtherConflict; 149 } 150 151 154 public void setColorOtherConflict(java.awt.Color colorOtherConflict) { 155 this.colorOtherConflict = colorOtherConflict; 156 } 157 158 } 159 | Popular Tags |