From: Dan B. <dan...@us...> - 2008-11-03 01:38:14
|
Update of /cvsroot/jmri/jmri/jmrit/operations/trains In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15148/src/jmri/jmrit/operations/trains Modified Files: Train.java Log Message: Warn user when terminating a train if manifest wasn't printed Index: Train.java =================================================================== RCS file: /cvsroot/jmri/jmri/jmrit/operations/trains/Train.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Train.java 2 Nov 2008 17:29:06 -0000 1.17 --- Train.java 3 Nov 2008 01:38:08 -0000 1.18 *************** *** 73,76 **** --- 73,77 ---- protected boolean _built = false; // when true, a train manifest has been built protected boolean _build = true; // when true, build this train + protected boolean _printed = false; // when true, manifest has been printed protected Route _route = null; protected TrainIcon _locoIcon = null; *************** *** 564,567 **** --- 565,569 ---- TrainBuilder tb = new TrainBuilder(); tb.build(this); + setPrinted(false); } *************** *** 616,629 **** } - public static void printReport(File file, String name, boolean isPreview){ - printReport(file, name, isPreview, ""); - } - - public void printBuildReport(){ if(_built && TrainManager.instance().getBuildReport()){ File buildFile = TrainManagerXml.instance().getTrainBuildReportFile(getName()); boolean isPreview = TrainManager.instance().getPrintPreview(); ! printReport(buildFile, "Train Build Report", isPreview); } } --- 618,626 ---- } public void printBuildReport(){ if(_built && TrainManager.instance().getBuildReport()){ File buildFile = TrainManagerXml.instance().getTrainBuildReportFile(getName()); boolean isPreview = TrainManager.instance().getPrintPreview(); ! printReport(buildFile, "Train Build Report", isPreview, ""); } } *************** *** 634,638 **** boolean isPreview = TrainManager.instance().getPrintPreview(); printReport(file, "Train Manifest", isPreview, Setup.getFontName()); ! }else{ String string = "Need to build train (" +getName()+ ") before printing manifest"; log.debug(string); --- 631,637 ---- boolean isPreview = TrainManager.instance().getPrintPreview(); printReport(file, "Train Manifest", isPreview, Setup.getFontName()); ! if (!isPreview) ! setPrinted(true); ! } else { String string = "Need to build train (" +getName()+ ") before printing manifest"; log.debug(string); *************** *** 649,652 **** --- 648,659 ---- log.debug("Train ("+getName()+") not selected, skipping printing manifest"); } + + private void setPrinted (boolean printed){ + _printed = printed; + } + + public boolean getPrinted(){ + return _printed; + } /** *************** *** 659,663 **** trainIconRl.setTrainIconY(_locoIcon.getY()); RouteManagerXml.setDirty(true); ! } else{ JOptionPane.showMessageDialog(null, "See Operations -> Settings to enable Set X&Y", "Set X&Y is disabled", --- 666,670 ---- trainIconRl.setTrainIconY(_locoIcon.getY()); RouteManagerXml.setDirty(true); ! } else { JOptionPane.showMessageDialog(null, "See Operations -> Settings to enable Set X&Y", "Set X&Y is disabled", *************** *** 666,675 **** } public void terminateIfSelected(){ ! if(_build && _built) while(_built) move(); ! else log.debug("Train ("+getName()+") not selected or built, skipping terminate train"); } --- 673,694 ---- } + /** + * Terminate train if build checkbox is selected by user. + * Warns user if the train manifest hasn't been printed. + */ public void terminateIfSelected(){ ! if(_build && _built){ ! if (!_printed){ ! if (JOptionPane.showConfirmDialog(null, ! "Warning, train manifest hasn't been printed!", ! "Terminate Train ("+getName()+")?", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) { ! return; ! } ! } while(_built) move(); ! } else { log.debug("Train ("+getName()+") not selected or built, skipping terminate train"); + } } *************** *** 757,761 **** _locoIcon.setTrain(this); // add throttle if JMRI loco roster entry exsist - // TODO: add consist throttle if engine is in a consist RosterEntry entry = Roster.instance().entryFromTitle(iconEngine.getNumber()); if (entry == null){ --- 776,779 ---- *************** *** 890,893 **** --- 908,912 ---- setCurrent(null); setBuilt(false); + setPrinted(false); firePropertyChange(NUMBERCARS, Integer.toString(oldNum), Integer.toString(0)); } *************** *** 964,967 **** --- 983,988 ---- if ((a = e.getAttribute("build")) != null) _build = a.getValue().equals("true"); + if ((a = e.getAttribute("printed")) != null) + _printed = a.getValue().equals("true"); if ((a = e.getAttribute("status")) != null ) _status = a.getValue(); if ((a = e.getAttribute("comment")) != null ) _comment = a.getValue(); *************** *** 1017,1027 **** e.setAttribute("built", getBuilt()?"true":"false"); e.setAttribute("build", getBuild()?"true":"false"); e.setAttribute("status", getStatus()); e.setAttribute("comment", getComment()); return e; } - - public void propertyChange(java.beans.PropertyChangeEvent e) { if(Control.showProperty && log.isDebugEnabled()) --- 1038,1047 ---- e.setAttribute("built", getBuilt()?"true":"false"); e.setAttribute("build", getBuild()?"true":"false"); + e.setAttribute("printed", getPrinted()?"true":"false"); e.setAttribute("status", getStatus()); e.setAttribute("comment", getComment()); return e; } public void propertyChange(java.beans.PropertyChangeEvent e) { if(Control.showProperty && log.isDebugEnabled()) |