use of teamdash.wbs.ChangeHistory.Entry in project processdash by dtuma.
the class ProjectHistoryBridgedAbstract method initTimeDelta.
protected void initTimeDelta(ManifestEntry changeHist) {
// these back to UTC timestamps.
if (timeDelta == 0 && changeHist != null) {
try {
Element xml = parseXml(changeHist.getStream());
ChangeHistory changes = new ChangeHistory(xml);
Entry lastChange = changes.getLastEntry();
long lastTimestamp = lastChange.getTimestamp().getTime();
timeDelta = changeHist.lastMod - lastTimestamp;
// the file modification time can normally differ from the
// change timestamp by a second or two; but we are only
// interested in the delta caused by time zone differences.
// round the delta to an even half-hour interval.
double fraction = timeDelta / (30.0 * DateUtils.MINUTES);
timeDelta = (int) Math.round(fraction) * 30 * DateUtils.MINUTES;
} catch (Exception e) {
}
}
}
use of teamdash.wbs.ChangeHistory.Entry in project processdash by dtuma.
the class TeamProjectMergeCoordinator method recordMergedChangeHistoryEntries.
private void recordMergedChangeHistoryEntries() {
ChangeHistory baseChanges = new ChangeHistory(baseDir.getDirectory());
ChangeHistory mainChanges = new ChangeHistory(mainDir.getDirectory());
Entry lastBaseChange = baseChanges.getLastEntry();
if (lastBaseChange == null)
return;
String lastBaseChangeUid = lastBaseChange.getUid();
boolean sawLastBaseChange = false;
for (Entry mainChange : mainChanges.getEntries()) {
if (sawLastBaseChange)
mergedChanges.add(mainChange);
else if (mainChange.getUid().equals(lastBaseChangeUid))
sawLastBaseChange = true;
}
}
use of teamdash.wbs.ChangeHistory.Entry in project processdash by dtuma.
the class WBSReplaceAction method confirmLostChanges.
/**
* Display a dialog to the user warning them about changes they are about
* to overwrite, and get confirmation that they wish to continue.
*/
private boolean confirmLostChanges(File srcFile, List<Entry> lostChanges) {
if (lostChanges == null || lostChanges.isEmpty())
return true;
boolean sameWbs = true;
if (lostChanges.get(0) == null) {
lostChanges.remove(0);
sameWbs = false;
}
Object[] items = new Object[lostChanges.size()];
for (int i = 0; i < items.length; i++) {
Entry e = lostChanges.get(i);
items[i] = resources.format("Lost_Changes.Item_FMT", e.getUser(), e.getTimestamp());
}
JList list = new JList(items);
JScrollPane sp = new JScrollPane(list);
Dimension d = list.getPreferredSize();
d.height = Math.min(d.height + 5, 200);
sp.setPreferredSize(d);
String title = resources.getString("Lost_Changes.Title");
Object[] message = new Object[] { resources.formatStrings("Lost_Changes.Header_FMT", srcFile.getPath()), " ", resources.getStrings(sameWbs ? "Lost_Changes.Same_WBS_Message" : "Lost_Changes.Different_WBS_Message"), sp, resources.getString("Lost_Changes.Footer") };
int userChoice = JOptionPane.showConfirmDialog(wbsEditor.frame, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
return userChoice == JOptionPane.YES_OPTION;
}
use of teamdash.wbs.ChangeHistory.Entry in project processdash by dtuma.
the class WBSReplaceAction method getMostRecentCommonChange.
/**
* Search through the change history of the current team project and the
* replacement project, and find the most recent change entry that they
* have in common. If they have no changes in common, returns null.
*/
private Entry getMostRecentCommonChange(File replacementDir) {
// make a list of the change UIDs for the main WBS.
Set<String> wbsEntryUids = new HashSet<String>();
for (Entry e : wbsEditor.changeHistory.getEntries()) wbsEntryUids.add(e.getUid());
// Load the change history for the replacement file.
ChangeHistory replacementHist = new ChangeHistory(replacementDir);
List<Entry> replacementChanges = replacementHist.getEntries();
// find the latest change history that is shared in common.
for (int i = replacementChanges.size(); i-- > 0; ) {
Entry e = replacementChanges.get(i);
String uid = e.getUid();
if (wbsEntryUids.contains(uid))
return e;
}
// no common change entry was found.
return null;
}
use of teamdash.wbs.ChangeHistory.Entry in project processdash by dtuma.
the class WBSReplaceAction method getChangesThatWillBeLost.
/**
* Get a list of past edits to the current team project that will be
* overwritten if the replacement proceeds.
*/
private List<Entry> getChangesThatWillBeLost(File replacementDir) {
List<Entry> wbsChanges = wbsEditor.changeHistory.getEntries();
Entry e = getMostRecentCommonChange(replacementDir);
if (e == null) {
// condition has occurred.
if (!wbsChanges.isEmpty())
wbsChanges.add(0, null);
return wbsChanges;
}
// make a list of the entries in the current team project that follow
// the most common change ancestor.
List<Entry> result = new ArrayList<Entry>();
for (int i = wbsChanges.size(); i-- > 0; ) {
Entry w = wbsChanges.get(i);
if (w.getUid().equals(e.getUid()))
break;
result.add(0, w);
}
return result;
}
Aggregations