blob: 6761ce36fab9e437a08d75cec35795d7910cf39d (
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
package org.eclipse.osee.ats.util.widgets;
import org.eclipse.osee.ats.artifact.TeamWorkFlowArtifact;
import org.eclipse.osee.ats.internal.AtsPlugin;
import org.eclipse.osee.ats.util.widgets.XWorkingBranch.BranchStatus;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
public class XWorkingBranchEnablement {
boolean populated = false;
boolean workingBranchInWork = false;
boolean committedBranchExists = false;
Branch workingBranch = null;
private final TeamWorkFlowArtifact teamArt;
public XWorkingBranchEnablement(TeamWorkFlowArtifact teamArt) {
this.teamArt = teamArt;
}
public boolean isCreateBranchButtonEnabled() {
try {
ensurePopulated();
return !workingBranchInWork && !committedBranchExists;
} catch (OseeCoreException ex) {
OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, ex);
}
return false;
}
public boolean isShowArtifactExplorerButtonEnabled() {
try {
ensurePopulated();
return workingBranch != null && !getStatus().equals(BranchStatus.Changes_NotPermitted);
} catch (OseeCoreException ex) {
OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, ex);
}
return false;
}
public boolean isShowChangeReportButtonEnabled() {
try {
ensurePopulated();
return workingBranchInWork || committedBranchExists;
} catch (OseeCoreException ex) {
OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, ex);
}
return false;
}
public boolean isDeleteBranchButtonEnabled() {
try {
ensurePopulated();
return workingBranchInWork && !committedBranchExists;
} catch (OseeCoreException ex) {
OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, ex);
}
return false;
}
public void refresh() {
populated = false;
}
public BranchStatus getStatus() throws OseeCoreException {
ensurePopulated();
if (teamArt != null && committedBranchExists) {
return BranchStatus.Changes_NotPermitted;
} else if (teamArt != null && workingBranchInWork) {
return BranchStatus.Changes_InProgress;
} else {
return BranchStatus.Not_Started;
}
}
private synchronized void ensurePopulated() throws OseeCoreException {
if (populated) {
return;
}
workingBranchInWork = teamArt.getBranchMgr().isWorkingBranchInWork();
committedBranchExists = teamArt.getBranchMgr().isCommittedBranchExists();
workingBranch = teamArt.getWorkingBranch();
populated = true;
}
public Branch getWorkingBranch() {
return workingBranch;
}
}
|