return; // We are just saving the file, so this message is most likely due
// to bad timing. If not, we'll handle it on the next polling.
//Util.pr("File '"+file.getPath()+"' has been modified.");
updatedExternally = true;
final ChangeScanner scanner = new ChangeScanner(frame, BasePanel.this);
// Adding the sidepane component is Swing work, so we must do this in the Swing
// thread:
Thread t = new Thread() {
public void run() {
// Check if there is already a notification about external
// changes:
boolean hasAlready = sidePaneManager.hasComponent(FileUpdatePanel.NAME);
if (hasAlready) {
sidePaneManager.hideComponent(FileUpdatePanel.NAME);
sidePaneManager.unregisterComponent(FileUpdatePanel.NAME);
}
FileUpdatePanel pan = new FileUpdatePanel(frame, BasePanel.this,
sidePaneManager, getFile(), scanner);
sidePaneManager.register(FileUpdatePanel.NAME, pan);
sidePaneManager.show(FileUpdatePanel.NAME);
//setUpdatedExternally(false);
//scanner.displayResult();
}
};
// Test: running scan automatically in background
if ((BasePanel.this.getFile() != null) &&
!Util.waitForFileLock(BasePanel.this.getFile(), 10)) {
// The file is locked even after the maximum wait. Do nothing.
System.err.println("File updated externally, but change scan failed because the file is locked.");
// Perturb the stored timestamp so successive checks are made:
Globals.fileUpdateMonitor.perturbTimestamp(getFileMonitorHandle());
return;
}
scanner.changeScan(BasePanel.this.getFile());
try {
scanner.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
if (scanner.changesFound()) {
SwingUtilities.invokeLater(t);
} else {
setUpdatedExternally(false);
//System.out.println("No changes found.");
}