1 32 33 package it.businesslogic.ireport.gui.library.objects; 34 import it.businesslogic.ireport.TextFieldReportElement; 35 import it.businesslogic.ireport.gui.FieldPatternDialog; 36 import it.businesslogic.ireport.gui.MainFrame; 37 import it.businesslogic.ireport.gui.event.ReportElementChangedEvent; 38 import it.businesslogic.ireport.gui.library.*; 39 import javax.swing.JOptionPane ; 40 44 public class DateObject extends AbstractLibraryObject { 45 46 private static javax.swing.ImageIcon defaultIcon; 47 48 static { 49 50 defaultIcon = new javax.swing.ImageIcon (AbstractLibraryObject.class.getResource("/it/businesslogic/ireport/icons/library/date.png")); 51 } 52 53 54 public DateObject() { 55 } 56 57 public String getName() 58 { 59 return it.businesslogic.ireport.util.I18n.getString("gui.library.objects.currentdate","Current date"); 60 } 61 62 public void drop(java.awt.dnd.DropTargetDropEvent dtde) { 63 64 FieldPatternDialog fpd = new FieldPatternDialog(MainFrame.getMainInstance(),true); 65 fpd.setOnlyDate(true); 66 fpd.setVisible(true); 67 if (fpd.getDialogResult() == JOptionPane.OK_OPTION) 68 { 69 TextFieldReportElement re = getReportFrame().dropNewTextField( dtde.getLocation(), "new java.util.Date()", "java.util.Date", "Report"); 70 re.setPattern(fpd.getPattern()); 71 getReportFrame().fireReportListenerReportElementsChanged(new ReportElementChangedEvent(getReportFrame(), re, ReportElementChangedEvent.CHANGED)); 72 } 73 } 74 75 public javax.swing.ImageIcon getIcon() 76 { 77 return defaultIcon; 78 } 79 80 } 81 | Popular Tags |