blob: a5137a21765d71721fa0dc7d8f7cfe15e42cc8ed (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/*******************************************************************************
* Copyright (c) 2010 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.framework.ui.skynet.render;
import java.io.File;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.plugin.core.util.Jobs;
import org.eclipse.osee.framework.skynet.core.utility.FileWatcher;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
final class ArtifactEditFileWatcher extends FileWatcher {
public ArtifactEditFileWatcher(long time, TimeUnit unit) {
super(time, unit);
}
@Override
public synchronized void run() {
try {
for (Map.Entry<File, Long> entry : filesToWatch.entrySet()) {
final File file = entry.getKey();
final Long storedLastModified = entry.getValue();
Long latestLastModified = file.lastModified();
boolean requiresUpdate = false;
if (!storedLastModified.equals(latestLastModified)) {
entry.setValue(latestLastModified);
if (file.exists()) {
requiresUpdate = true;
}
}
if (requiresUpdate) {
UpdateArtifactJob updateJob = new UpdateArtifactJob();
updateJob.setWorkingFile(file);
updateJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
if (event.getResult().isOK()) {
OseeLog.log(SkynetGuiPlugin.class, Level.INFO,
"Updated artifact linked to: " + file.getAbsolutePath());
}
}
});
Jobs.startJob(updateJob);
}
}
} catch (Exception ex) {
OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
}
}
}
|