1 32 33 package it.businesslogic.ireport.undo; 34 import it.businesslogic.ireport.gui.event.*; 35 import it.businesslogic.ireport.*; 36 import it.businesslogic.ireport.gui.*; 37 import it.businesslogic.ireport.util.*; 38 import java.awt.*; 39 40 import java.util.*; 41 42 52 public class BandDraggedOperation implements it.businesslogic.ireport.UndoOperation { 53 54 57 private Vector transformations = null; 58 private int bandDelta = 0; 59 60 private JReportFrame jrf = null; 61 62 private Band band; 63 64 65 public BandDraggedOperation(JReportFrame jrf, Band band) { 66 this.transformations = new Vector(); 67 this.band = band; 68 this.jrf = jrf; 69 } 70 71 public void redo() 72 { 73 if (jrf == null) return; 74 75 band.setHeight( band.getHeight() + bandDelta); 76 77 Enumeration e = this.getTransformations().elements(); 79 while ( e.hasMoreElements() ) 80 { 81 ElementTransformation pe = (ElementTransformation)e.nextElement(); 82 ReportElement element = pe.element; 83 86 element.getPosition().x = pe.newBounds.x; 87 element.getPosition().y = pe.newBounds.y; 88 element.setWidth(pe.newBounds.width); 89 element.setHeight(pe.newBounds.height); 90 91 element.updateBounds(); 92 jrf.fireReportListenerReportElementsChanged(new ReportElementChangedEvent(jrf, element , ReportElementChangedEvent.CHANGED)); 93 } 96 jrf.setIsDocDirty(true); 97 jrf.getReportPanel().repaint(); 98 } 99 100 public void undo() 101 { 102 if (jrf == null) return; 103 104 band.setHeight( band.getHeight() - bandDelta ); 105 106 for (int i= this.getTransformations().size()-1; i>=0; --i) 108 { 109 ElementTransformation pe = (ElementTransformation)getTransformations().get(i); 110 ReportElement element = pe.element; 111 114 element.getPosition().x = pe.oldBounds.x; 115 element.getPosition().y = pe.oldBounds.y; 116 element.setWidth(pe.oldBounds.width); 117 element.setHeight(pe.oldBounds.height); 118 119 element.updateBounds(); 120 jrf.fireReportListenerReportElementsChanged(new ReportElementChangedEvent(jrf, element , ReportElementChangedEvent.CHANGED)); 121 } 124 jrf.setIsDocDirty(true); 125 jrf.getReportPanel().repaint(); 126 } 127 128 public String toString() 129 { 130 return "band resize"; 131 } 132 133 140 public java.util.Vector getTransformations() { 141 return transformations; 142 } 143 144 148 public void setTransformations(java.util.Vector transformations) { 149 this.transformations = transformations; 150 } 151 152 159 public void addElement(ReportElement element, Rectangle oldBounds, Rectangle newBounds) { 160 161 ElementTransformation et = new ElementTransformation(); 162 et.element = element; 163 et.oldBounds = oldBounds; 164 et.newBounds = newBounds; 165 getTransformations().add(et); 166 } 167 168 172 public it.businesslogic.ireport.Band getBand() { 173 return band; 174 } 175 176 180 public void setBand(it.businesslogic.ireport.Band band) { 181 this.band = band; 182 } 183 184 188 public int getBandDelta() { 189 return bandDelta; 190 } 191 192 196 public void setBandDelta(int bandDelta) { 197 this.bandDelta = bandDelta; 198 } 199 200 } 201 202 | Popular Tags |