public void run() { // Loop over the registered files and see which have changed. // Use a copy of the list in case listener wants to alter the // list within its fileChanged method. Collection<File> files = new ArrayList<File>(files_.keySet()); for (Iterator<File> i = files.iterator(); i.hasNext(); ) { File file = i.next(); long lastModifiedTime = ((Long) files_.get(file)).longValue(); long newModifiedTime = file.exists() ? file.lastModified() : -1; // Check if file has changed if (newModifiedTime != lastModifiedTime) { // Register new modified time files_.put(file, new Long(newModifiedTime)); // Notify listeners for (Iterator<WeakReference<FileListener>> j = listeners_.iterator(); j.hasNext(); ) { WeakReference<FileListener> reference = j.next(); FileListener listener = (FileListener) reference.get(); // Remove from list if the back-end object has been GC'd if (listener == null) j.remove(); else listener.fileChanged(file); } } } }
/** * Called when a valid record is read from the table/query. * * @param bDisplayOption If true, display any changes. */ public void doValidRecord(boolean bDisplayOption) { super.doValidRecord(bDisplayOption); Record recApTrx = this.getOwner(); if (m_iDepartureEstimate == -1) { TrxStatus recTrxStatus = new TrxStatus( this.getOwner() .findRecordOwner()); // Rarely, but if it doesn't exist in the screen, add it! m_iDepartureEstimate = recTrxStatus.getTrxStatusID( TransactionType.ACCTPAY, ApTrx.AP_TRX_FILE, ApTrx.DEP_ESTIMATE); m_iDepartureEstimateManual = recTrxStatus.getTrxStatusID( TransactionType.ACCTPAY, ApTrx.AP_TRX_FILE, ApTrx.DEPARTURE_EST_MANUAL); recTrxStatus.free(); } if ((recApTrx.getField(ApTrx.TRX_STATUS_ID).getValue() == m_iDepartureEstimate) || (recApTrx.getField(ApTrx.TRX_STATUS_ID).getValue() == m_iDepartureEstimateManual)) { recApTrx .getField(ApTrx.INVOICE_AMOUNT) .moveFieldToThis(recApTrx.getField(ApTrx.DEPARTURE_ESTIMATE)); recApTrx .getField(ApTrx.INVOICE_BALANCE) .moveFieldToThis(recApTrx.getField(ApTrx.DEPARTURE_ESTIMATE)); recApTrx .getField(ApTrx.INVOICE_BALANCE_LOCAL) .moveFieldToThis(recApTrx.getField(ApTrx.DEPARTURE_ESTIMATE_LOCAL)); } }
/** Initialize class fields. */ public void init(Record record) { super.init(record); }