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 46 public class PasteStyleOperation implements it.businesslogic.ireport.UndoOperation { 47 48 private Vector transformations = null; 49 50 private JReportFrame jrf = null; 51 private CrosstabReportElement crosstabReportElement = null; 52 53 54 public PasteStyleOperation(JReportFrame jrf, CrosstabReportElement crosstabReportElement) { 55 this.setCrosstabReportElement(crosstabReportElement); 56 this.transformations = new Vector(); 57 this.jrf = jrf; 58 } 59 60 61 public PasteStyleOperation(JReportFrame jrf) { 62 this(jrf, null); 63 } 64 65 public void redo() 66 { 67 if (jrf == null) return; 68 69 Enumeration e = this.getTransformations().elements(); 71 while ( e.hasMoreElements() ) 72 { 73 PasteStyledElementItem ri = (PasteStyledElementItem)e.nextElement(); 74 ReportElement element = ri.getElement(); 75 JReportFrame.applyStyle( element, ri.getNewStyle() ); 76 77 jrf.fireReportListenerReportElementsChanged(new ReportElementChangedEvent(jrf, getCrosstabReportElement(), element , ReportElementChangedEvent.CHANGED)); 78 } 81 jrf.getMainFrame().getElementPropertiesDialog().updateSelection(); 82 if (getCrosstabReportElement() != null) jrf.getCrosstabEditor(getCrosstabReportElement()).getPanelEditor().repaint(); 83 else jrf.getReportPanel().repaint(); 84 } 85 86 public void undo() 87 { 88 if (jrf == null) return; 89 90 Enumeration e = this.getTransformations().elements(); 92 while ( e.hasMoreElements() ) 93 { 94 PasteStyledElementItem ri = (PasteStyledElementItem)e.nextElement(); 95 ReportElement element = ri.getElement(); 96 JReportFrame.applyStyle( element, ri.getOriginalStyle() ); 97 98 jrf.fireReportListenerReportElementsChanged(new ReportElementChangedEvent(jrf, getCrosstabReportElement(), element , ReportElementChangedEvent.CHANGED)); 99 } 102 jrf.getMainFrame().getElementPropertiesDialog().updateSelection(); 103 if (getCrosstabReportElement() != null) jrf.getCrosstabEditor(getCrosstabReportElement()).getPanelEditor().repaint(); 104 else jrf.getReportPanel().repaint(); 105 } 106 107 public String toString() 108 { 109 return "paste style"; 110 } 111 112 119 public java.util.Vector getTransformations() { 120 return transformations; 121 } 122 123 127 public void setTransformations(java.util.Vector transformations) { 128 this.transformations = transformations; 129 } 130 131 138 public void addElement(ReportElement element, ReportElement originalStyle, ReportElement newStyle) { 139 140 PasteStyledElementItem et = new PasteStyledElementItem(element,originalStyle,newStyle); 141 getTransformations().add(et); 142 } 143 144 public CrosstabReportElement getCrosstabReportElement() { 145 return crosstabReportElement; 146 } 147 148 public void setCrosstabReportElement(CrosstabReportElement crosstabReportElement) { 149 this.crosstabReportElement = crosstabReportElement; 150 } 151 152 } 153 154 | Popular Tags |