Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorddunne2010-07-16 19:27:01 +0000
committerddunne2010-07-16 19:27:01 +0000
commiteb47541da5d0a181569c0fa9a908d226d9a89142 (patch)
treea586fdef26d3efcd5bfc058cb6d81e1f855362cd
parent7e1166f8f6cce76a282c8ec4b1c0bc02c2906cb7 (diff)
downloadorg.eclipse.osee-eb47541da5d0a181569c0fa9a908d226d9a89142.tar.gz
org.eclipse.osee-eb47541da5d0a181569c0fa9a908d226d9a89142.tar.xz
org.eclipse.osee-eb47541da5d0a181569c0fa9a908d226d9a89142.zip
Events - UI
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAEditor.java19
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAEditorEventManager.java3
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlService.java1177
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/HttpAttributeTagger.java5
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/InternalEventManager.java16
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event2/ArtifactEvent.java5
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java107
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerEventManager.java112
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/IArtifactExplorerEventHandler.java18
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationsComposite.java49
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/AbstractArtifactEditor.java2
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/AbstractEventArtifactEditor.java89
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditor.java13
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorEventManager.java151
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/IArtifactEditorEventHandler.java30
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/revert/RevertWizardPage.java80
16 files changed, 998 insertions, 878 deletions
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAEditor.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAEditor.java
index 9882822e4c2..45bea98d201 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAEditor.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAEditor.java
@@ -56,12 +56,9 @@ import org.eclipse.osee.framework.skynet.core.event.IArtifactReloadEventListener
import org.eclipse.osee.framework.skynet.core.event.IArtifactsPurgedEventListener;
import org.eclipse.osee.framework.skynet.core.event.IBranchEventListener;
import org.eclipse.osee.framework.skynet.core.event.IFrameworkTransactionEventListener;
-import org.eclipse.osee.framework.skynet.core.event.IRelationModifiedEventListener;
import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
import org.eclipse.osee.framework.skynet.core.event.Sender;
import org.eclipse.osee.framework.skynet.core.event2.BranchEvent;
-import org.eclipse.osee.framework.skynet.core.relation.RelationEventType;
-import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.skynet.core.utility.LoadedArtifacts;
@@ -104,7 +101,7 @@ import org.eclipse.ui.part.MultiPageEditorPart;
*
* @author Donald G. Dunne
*/
-public class SMAEditor extends AbstractArtifactEditor implements ISMAEditorEventHandler, ISelectedAtsArtifacts, IDirtiableEditor, IActionable, IArtifactReloadEventListener, IAtsMetricsProvider, IArtifactsPurgedEventListener, IRelationModifiedEventListener, IFrameworkTransactionEventListener, IBranchEventListener, IXTaskViewer {
+public class SMAEditor extends AbstractArtifactEditor implements ISMAEditorEventHandler, ISelectedAtsArtifacts, IDirtiableEditor, IActionable, IArtifactReloadEventListener, IAtsMetricsProvider, IArtifactsPurgedEventListener, IFrameworkTransactionEventListener, IBranchEventListener, IXTaskViewer {
public static final String EDITOR_ID = "org.eclipse.osee.ats.editor.SMAEditor";
private StateMachineArtifact sma;
private int workFlowPageIndex, metricsPageIndex, attributesPageIndex;
@@ -659,20 +656,6 @@ public class SMAEditor extends AbstractArtifactEditor implements ISMAEditorEvent
}
@Override
- public void handleRelationModifiedEvent(Sender sender, RelationEventType relationEventType, RelationLink link, Branch branch, String relationType) {
- try {
- if (branch.getId() != AtsUtil.getAtsBranch().getId()) {
- return;
- }
- if (link.getArtifactA().equals(sma) || link.getArtifactB().equals(sma)) {
- onDirtied();
- }
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
- }
-
- @Override
public String getActionDescription() {
return null;
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAEditorEventManager.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAEditorEventManager.java
index 1c2e757e77b..87682dc2dad 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAEditorEventManager.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAEditorEventManager.java
@@ -65,7 +65,7 @@ public class SMAEditorEventManager implements IArtifactEventListener {
handlers.remove(handler);
}
}
- System.out.println("SMAEditor: handleArtifactModified called [" + artifactEvent + "] - sender " + sender + "");
+ System.out.println("SMAEditor: handleArtifactEvent called [" + artifactEvent + "] - sender " + sender + "");
try {
if (artifactEvent.getBranchGuid() == null || !artifactEvent.getBranchGuid().equals(
AtsUtil.getAtsBranch().getGuid())) {
@@ -74,7 +74,6 @@ public class SMAEditorEventManager implements IArtifactEventListener {
} catch (OseeCoreException ex) {
return;
}
- System.out.println("SMAEditor: handleArtifactModified called [" + artifactEvent + "] - sender " + sender + "");
for (final ISMAEditorEventHandler handler : handlers) {
final StateMachineArtifact sma = handler.getSMAEditor().getSma();
ActionArtifact actionArt = null;
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlService.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlService.java
index 21f1adba4ef..391977f7d8f 100644
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlService.java
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlService.java
@@ -73,592 +73,593 @@ import org.osgi.util.tracker.ServiceTracker;
*/
public class AccessControlService implements IAccessControlService {
- private static final String ACCESS_POINT_ID = "osee.access.point";
-
- private final String INSERT_INTO_ARTIFACT_ACL =
- "INSERT INTO OSEE_ARTIFACT_ACL (art_id, permission_id, privilege_entity_id, branch_id) VALUES (?, ?, ?, ?)";
- private final String INSERT_INTO_BRANCH_ACL =
- "INSERT INTO OSEE_BRANCH_ACL (permission_id, privilege_entity_id, branch_id) VALUES (?, ?, ?)";
-
- private final String UPDATE_ARTIFACT_ACL =
- "UPDATE OSEE_ARTIFACT_ACL SET permission_id = ? WHERE privilege_entity_id =? AND art_id = ? AND branch_id = ?";
- private final String UPDATE_BRANCH_ACL =
- "UPDATE OSEE_BRANCH_ACL SET permission_id = ? WHERE privilege_entity_id =? AND branch_id = ?";
-
- private final String GET_ALL_ARTIFACT_ACCESS_CONTROL_LIST =
- "SELECT aac1.*, art1.art_type_id FROM osee_artifact art1, osee_artifact_acl aac1 WHERE art1.art_id = aac1.privilege_entity_id";
- private final String GET_ALL_BRANCH_ACCESS_CONTROL_LIST =
- "SELECT bac1.*, art1.art_type_id FROM osee_artifact art1, osee_branch_acl bac1 WHERE art1.art_id = bac1.privilege_entity_id";
-
- private final String DELETE_ARTIFACT_ACL_FROM_BRANCH = "DELETE FROM OSEE_ARTIFACT_ACL WHERE branch_id =?";
- private final String DELETE_BRANCH_ACL_FROM_BRANCH = "DELETE FROM OSEE_BRANCH_ACL WHERE branch_id =?";
-
- private final String USER_GROUP_MEMBERS =
- "SELECT b_art_id FROM osee_relation_link WHERE a_art_id =? AND rel_link_type_id =? ORDER BY b_art_id";
-
- private DoubleKeyHashMap<Integer, AccessObject, PermissionEnum> accessControlListCache;
- private HashCollection<AccessObject, Integer> objectToSubjectCache; // <subjectId, groupId>
- private HashCollection<Integer, Integer> subjectToGroupCache; // <groupId, subjectId>
- private HashCollection<Integer, Integer> groupToSubjectsCache; // <artId, branchId>
- private Map<Integer, Integer> objectToBranchLockCache; // object, subject
- private Map<Integer, Integer> lockedObjectToSubject; // subject, permission
- private HashCollection<Integer, PermissionEnum> subjectToPermissionCache;
-
- private final IOseeCachingService cachingService;
- private final IOseeDatabaseService databaseService;
-
- public AccessControlService(IOseeDatabaseService databaseService, IOseeCachingService cachingService) {
- super();
- this.cachingService = cachingService;
- this.databaseService = databaseService;
- reloadCache();
- }
-
- private ArtifactTypeCache getArtifactTypeCache() {
- return cachingService.getArtifactTypeCache();
- }
-
- private RelationTypeCache getRelationTypeCache() {
- return cachingService.getRelationTypeCache();
- }
-
- private BranchCache getBranchCache() {
- return cachingService.getBranchCache();
- }
-
- private IOseeDatabaseService getDatabaseService() {
- return databaseService;
- }
-
- public synchronized void reloadCache() {
- initializeCaches();
- try {
- populateAccessControlLists();
- } catch (Exception ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
-
- private void initializeCaches() {
- accessControlListCache = new DoubleKeyHashMap<Integer, AccessObject, PermissionEnum>();
- objectToSubjectCache = new HashCollection<AccessObject, Integer>();
- subjectToGroupCache = new HashCollection<Integer, Integer>();
- groupToSubjectsCache = new HashCollection<Integer, Integer>();
- objectToBranchLockCache = new HashMap<Integer, Integer>();
- lockedObjectToSubject = new HashMap<Integer, Integer>();
- subjectToPermissionCache = new HashCollection<Integer, PermissionEnum>();
- }
-
- private void populateAccessControlLists() throws OseeCoreException {
- populateArtifactAccessControlList();
- populateBranchAccessControlList();
- }
-
- private void populateBranchAccessControlList() throws OseeCoreException {
- IOseeStatement chStmt = getDatabaseService().getStatement();
- try {
- chStmt.runPreparedQuery(GET_ALL_BRANCH_ACCESS_CONTROL_LIST);
- while (chStmt.next()) {
- Integer subjectId = chStmt.getInt("privilege_entity_id");
- Integer branchId = chStmt.getInt("branch_id");
- int subjectArtifactTypeId = chStmt.getInt("art_type_id");
- PermissionEnum permission = PermissionEnum.getPermission(chStmt.getInt("permission_id"));
- BranchAccessObject branchAccessObject = BranchAccessObject.getBranchAccessObject(branchId);
-
- accessControlListCache.put(subjectId, branchAccessObject, permission);
- objectToSubjectCache.put(branchAccessObject, subjectId);
-
- ArtifactType subjectArtifactType = getArtifactTypeCache().getById(subjectArtifactTypeId);
- ArtifactType toCheck = getArtifactTypeCache().get(CoreArtifactTypes.UserGroup);
- if (subjectArtifactType.inheritsFrom(toCheck)) {
- populateGroupMembers(subjectId);
- }
- }
- } finally {
- chStmt.close();
- }
- }
-
- private void populateArtifactAccessControlList() throws OseeCoreException {
- IOseeStatement chStmt = getDatabaseService().getStatement();
- try {
- chStmt.runPreparedQuery(GET_ALL_ARTIFACT_ACCESS_CONTROL_LIST);
-
- while (chStmt.next()) {
- Integer subjectId = chStmt.getInt("privilege_entity_id");
- Integer objectId = chStmt.getInt("art_id");
- Integer branchId = chStmt.getInt("branch_id");
- int subjectArtifactTypeId = chStmt.getInt("art_type_id");
- PermissionEnum permission = PermissionEnum.getPermission(chStmt.getInt("permission_id"));
-
- if (permission.equals(PermissionEnum.LOCK)) {
- objectToBranchLockCache.put(objectId, branchId);
- lockedObjectToSubject.put(objectId, subjectId);
- } else {
- AccessObject accessObject = ArtifactAccessObject.getArtifactAccessObject(objectId, branchId);
- cacheAccessObject(objectId, subjectId, permission, accessObject);
-
- ArtifactType subjectArtifactType = getArtifactTypeCache().getById(subjectArtifactTypeId);
- ArtifactType toCheck = getArtifactTypeCache().get(CoreArtifactTypes.UserGroup);
- if (subjectArtifactType.inheritsFrom(toCheck)) {
- populateGroupMembers(subjectId);
- }
- }
- }
- } finally {
- chStmt.close();
- }
- }
-
- private void populateGroupMembers(Integer groupId) throws OseeCoreException {
- if (!groupToSubjectsCache.containsKey(groupId)) {
- Integer groupMember;
-
- IOseeStatement chStmt = getDatabaseService().getStatement();
- try {
- RelationType relationType = getRelationTypeCache().get(CoreRelationTypes.Users_User);
- chStmt.runPreparedQuery(USER_GROUP_MEMBERS, groupId, relationType.getId());
-
- // get group members and populate subjectToGroupCache
- while (chStmt.next()) {
- groupMember = chStmt.getInt("b_art_id");
- subjectToGroupCache.put(groupMember, groupId);
- groupToSubjectsCache.put(groupId, groupMember);
- }
- } finally {
- chStmt.close();
- }
- }
- }
-
- public boolean checkSubjectPermission(Artifact subject, PermissionEnum permission) {
- boolean isValid = false;
-
- if (subjectToPermissionCache.containsKey(subject.getArtId())) {
- for (PermissionEnum subjectPermission : subjectToPermissionCache.getValues(subject.getArtId())) {
- if (subjectPermission.getRank() >= permission.getRank()) {
- isValid = true;
- }
- }
- }
- return isValid;
- }
-
- public boolean checkObjectListPermission(Collection<?> objectList, PermissionEnum permission) throws OseeCoreException {
- boolean isValid = true;
-
- if (objectList.isEmpty()) {
- isValid = false;
- }
-
- for (Object object : objectList) {
- isValid &= hasPermission(object, permission);
- }
- return isValid;
- }
-
- @Override
- public boolean hasPermission(Object object, PermissionEnum permission) throws OseeCoreException {
- return hasPermission(UserManager.getUser(), object, permission);
- }
-
- public PermissionEnum getObjectPermission(Artifact subject, Object object) throws OseeCoreException {
- for (PermissionEnum permissionEnum : PermissionEnum.values()) {
- boolean result = hasPermission(subject, object, permissionEnum);
- System.out.println("subject " + subject + " object " + object + " permission " + permissionEnum.name() + " -> " + result);
- if (result) {
- return permissionEnum;
- }
- }
- return PermissionEnum.FULLACCESS;
- }
-
- @Override
- public AccessData getAccessData(IBasicArtifact<?> userArtifact, Collection<?> objectsToCheck) throws OseeCoreException {
- ILifecycleService service = getLifecycleService();
- AccessData accessData = new AccessData();
- AbstractLifecycleVisitor<?> visitor = new AccessProviderVisitor(userArtifact, objectsToCheck, accessData);
- IStatus status = service.dispatch(new NullProgressMonitor(), visitor, ACCESS_POINT_ID);
- try {
- Operations.checkForErrorStatus(status);
- } catch (Exception ex) {
- OseeExceptions.wrapAndThrow(ex);
- }
- return accessData;
- }
-
- private boolean hasPermission(IBasicArtifact<?> subject, Object object, PermissionEnum permission) throws OseeCoreException {
- AccessData accessData = getAccessData(subject, Collections.singletonList(object));
- return accessData.matchesAll(permission);
- }
-
- private ILifecycleService getLifecycleService() throws OseeCoreException {
- Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
- ServiceTracker tracker = new ServiceTracker(bundle.getBundleContext(), ILifecycleService.class.getName(), null);
- tracker.open(true);
- Object serviceObject = tracker.getService();
- tracker.close();
- if (serviceObject instanceof ILifecycleService) {
- return (ILifecycleService) serviceObject;
- } else {
- throw new OseeStateException("Lifecycle service is unavailable");
- }
- }
-
- public PermissionEnum getBranchPermission(IBasicArtifact<?> subject, Branch branch) {
- PermissionEnum userPermission = null;
- AccessObject accessObject = BranchAccessObject.getBranchAccessObjectFromCache(branch);
-
- if (accessObject == null) {
- userPermission = PermissionEnum.FULLACCESS;
- } else {
- userPermission = acquirePermissionRank(subject, accessObject);
- }
- return userPermission;
- }
-
- public PermissionEnum getArtifactPermission(IBasicArtifact<?> subject, Artifact artifact) {
- PermissionEnum userPermission = null;
- AccessObject accessObject = null;
-
- // The artifact is new and has not been persisted.
- if (!artifact.isInDb()) {
- return PermissionEnum.FULLACCESS;
- }
-
- Integer artId = artifact.getArtId();
- Integer branchId = artifact.getBranch().getId();
- Integer lockedBranchId;
-
- // accessObject = accessObjectCache.get(artId, branchId);
- accessObject = ArtifactAccessObject.getArtifactAccessObjectFromCache(artId, branchId);
-
- if (objectToBranchLockCache.containsKey(artId)) {
- lockedBranchId = objectToBranchLockCache.get(artId);
-
- // this object is locked under a different branch
- if (lockedBranchId.intValue() != branchId.intValue()) {
- userPermission = PermissionEnum.LOCK;
- }
- }
-
- if (userPermission == null && accessObject != null) {
- userPermission = acquirePermissionRank(subject, accessObject);
- }
- return userPermission;
- }
-
- private PermissionEnum acquirePermissionRank(IBasicArtifact<?> subject, AccessObject accessObject) {
- PermissionEnum userPermission = null;
- int subjectId = subject.getArtId();
-
- userPermission = accessControlListCache.get(subjectId, accessObject);
-
- if (subjectToGroupCache.containsKey(subjectId)) {
- for (int groupPermissionId : subjectToGroupCache.getValues(subjectId)) {
- PermissionEnum groupPermission = accessControlListCache.get(groupPermissionId, accessObject);
-
- if (groupPermission != null) {
- if (userPermission == null) {
- userPermission = groupPermission;
- }
-
- if (groupPermission.getRank() > userPermission.getRank()) {
- userPermission = groupPermission;
- }
- }
- }
- }
- return userPermission;
- }
-
- public void persistPermission(AccessControlData data) {
- persistPermission(data, false);
- }
-
- public void setPermission(Artifact subject, Object object, PermissionEnum permission) {
- AccessObject accessObject = getAccessObject(object);
-
- boolean newAccessControlData = !accessControlListCache.containsKey(subject.getArtId(), accessObject);
-
- if (newAccessControlData || permission != accessControlListCache.get(subject.getArtId(), accessObject)) {
- AccessControlData data = new AccessControlData(subject, accessObject, permission, newAccessControlData);
- persistPermission(data);
- }
- }
-
- public void persistPermission(AccessControlData data, boolean recurse) {
- Artifact subject = data.getSubject();
- PermissionEnum permission = data.getPermission();
-
- if (data.isDirty()) {
- data.setNotDirty();
-
- try {
- if (data.getObject() instanceof ArtifactAccessObject) {
- ArtifactAccessObject artifactAccessObject = (ArtifactAccessObject) data.getObject();
-
- if (data.isBirth()) {
- getDatabaseService().runPreparedUpdate(INSERT_INTO_ARTIFACT_ACL, artifactAccessObject.getArtId(),
- data.getPermission().getPermId(), data.getSubject().getArtId(), artifactAccessObject.getId());
- } else {
- getDatabaseService().runPreparedUpdate(UPDATE_ARTIFACT_ACL, data.getPermission().getPermId(),
- data.getSubject().getArtId(), artifactAccessObject.getArtId(), artifactAccessObject.getId());
- }
-
- if (recurse) {
- Artifact artifact =
- ArtifactQuery.getArtifactFromId(artifactAccessObject.getArtId(),
- BranchManager.getBranch(artifactAccessObject.getId()));
- AccessControlData childAccessControlData = null;
-
- for (Artifact child : artifact.getChildren()) {
- AccessObject accessObject = getAccessObject(child);
-
- if (objectToSubjectCache.containsKey(accessObject)) {
- Collection<Integer> subjectIds = objectToSubjectCache.getValues(accessObject);
-
- for (int subjectId : subjectIds) {
- if (subjectId == subject.getArtId()) {
- childAccessControlData = new AccessControlData(subject, accessObject, permission, false);
- }
- }
- }
-
- if (childAccessControlData == null) {
- childAccessControlData = new AccessControlData(subject, accessObject, permission, true);
- }
- persistPermission(childAccessControlData, true);
- }
- }
- } else if (data.getObject() instanceof BranchAccessObject) {
- BranchAccessObject branchAccessObject = (BranchAccessObject) data.getObject();
-
- if (data.isBirth()) {
- getDatabaseService().runPreparedUpdate(INSERT_INTO_BRANCH_ACL, data.getPermission().getPermId(),
- data.getSubject().getArtId(), branchAccessObject.getId());
- } else {
- getDatabaseService().runPreparedUpdate(UPDATE_BRANCH_ACL, data.getPermission().getPermId(),
- data.getSubject().getArtId(), branchAccessObject.getId());
- }
- }
- cacheAccessControlData(data);
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
- }
-
- private void cacheAccessControlData(AccessControlData data) throws OseeCoreException {
- AccessObject accessObject = data.getObject();
- int subjectId = data.getSubject().getArtId();
- PermissionEnum permission = data.getPermission();
-
- if (!permission.equals(PermissionEnum.LOCK)) {
- accessControlListCache.put(subjectId, accessObject, permission);
- objectToSubjectCache.put(accessObject, subjectId);
-
- populateGroupMembers(subjectId);
- }
- }
-
- public List<AccessControlData> getAccessControlList(Object object) {
- List<AccessControlData> datas = new LinkedList<AccessControlData>();
- AccessObject accessObject = null;
-
- try {
- accessObject = AccessObject.getAccessObjectFromCache(object);
-
- if (accessObject == null) {
- return datas;
- }
-
- datas = generateAccessControlList(accessObject);
-
- } catch (Exception ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- return datas;
- }
-
- public List<AccessControlData> generateAccessControlList(AccessObject accessObject) throws OseeCoreException {
- List<AccessControlData> datas = new LinkedList<AccessControlData>();
-
- Collection<Integer> subjects = objectToSubjectCache.getValues(accessObject);
- if (subjects == null) {
- return datas;
- }
-
- for (int subjectId : subjects) {
- Artifact subject = UserManager.getUserByArtId(subjectId);
- PermissionEnum permissionEnum = accessControlListCache.get(subjectId, accessObject);
- AccessControlData accessControlData =
- new AccessControlData(subject, accessObject, permissionEnum, false, false);
- if (accessObject instanceof ArtifactAccessObject) {
- accessControlData.setArtifactPermission(permissionEnum);
- accessControlData.setBranchPermission(getBranchPermission(subject, accessObject));
- } else if (accessObject instanceof BranchAccessObject) {
- accessControlData.setBranchPermission(getBranchPermission(subject, accessObject));
- }
- datas.add(accessControlData);
- }
-
- return datas;
- }
-
- private PermissionEnum getBranchPermission(IBasicArtifact<?> subject, Object object) throws OseeCoreException {
- int branchId = ((AccessObject) object).getId();
- Branch branch = BranchManager.getBranch(branchId);
-
- return getBranchPermission(subject, branch);
- }
-
- public void removeAccessControlDataIf(boolean removeFromDb, AccessControlData data) throws OseeDataStoreException {
- int subjectId = data.getSubject().getArtId();
- AccessObject accessControlledObject = data.getObject();
- if (removeFromDb) {
- accessControlledObject.removeFromDatabase(subjectId);
- }
-
- if (accessControlledObject instanceof ArtifactAccessObject) {
- accessControlledObject.removeFromCache();
- }
- deCacheAccessControlData(data);
- }
-
- private void deCacheAccessControlData(AccessControlData data) {
- if (data == null) {
- throw new IllegalArgumentException("Can not remove a null AccessControlData.");
- }
-
- AccessObject accessObject = data.getObject();
- Integer subjectId = data.getSubject().getArtId();
-
- accessControlListCache.remove(subjectId, accessObject);
- objectToSubjectCache.removeValue(accessObject, subjectId);
- Collection<Integer> members = groupToSubjectsCache.getValues(subjectId);
-
- if (members != null) {
- for (Integer member : members) {
- subjectToGroupCache.removeValue(member, subjectId);
- }
- }
- if (!objectToSubjectCache.containsKey(accessObject)) {
- accessObject.removeFromCache();
- }
- }
-
- public AccessObject getAccessObject(Object object) {
- return AccessObject.getAccessObject(object);
- }
-
- private void cacheAccessObject(Integer objectId, Integer subjectId, PermissionEnum permission, AccessObject accessObject) {
- accessControlListCache.put(subjectId, accessObject, permission);
- objectToSubjectCache.put(accessObject, subjectId);
- }
-
- public void lockObjects(Collection<Artifact> objects, Artifact subject) {
- AccessControlEvent event = new AccessControlEvent();
- event.setEventType(AccessControlEventType.ArtifactsLocked);
- Set<Artifact> lockedArts = new HashSet<Artifact>();
- for (Artifact object : objects) {
- Integer objectArtId = object.getArtId();
- Integer subjectArtId = subject.getArtId();
- Integer objectBranchId = object.getBranch().getId();
-
- if (!objectToBranchLockCache.containsKey(objectArtId)) {
- AccessObject accessObject = getAccessObject(object);
- AccessControlData data = new AccessControlData(subject, accessObject, PermissionEnum.LOCK, true);
- persistPermission(data);
- objectToBranchLockCache.put(objectArtId, objectBranchId);
- lockedObjectToSubject.put(objectArtId, subjectArtId);
- event.getArtifacts().add(object.getBasicGuidArtifact());
- lockedArts.add(object);
- }
- }
- try {
- OseeEventManager.kickAccessControlArtifactsEvent(this, event, new LoadedArtifacts(lockedArts));
- } catch (Exception ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
-
- public void unLockObjects(Collection<Artifact> objects, Artifact subject) throws OseeDataStoreException, OseeAuthenticationRequiredException {
- AccessControlEvent event = new AccessControlEvent();
- event.setEventType(AccessControlEventType.ArtifactsUnlocked);
- Set<Artifact> lockedArts = new HashSet<Artifact>();
- for (Artifact object : objects) {
- Integer objectArtId = object.getArtId();
- Integer branchId = object.getBranch().getId();
- Integer lockedBranchId;
-
- if (objectToBranchLockCache.containsKey(objectArtId) && canUnlockObject(object, subject)) {
- lockedBranchId = objectToBranchLockCache.get(objectArtId);
-
- if (branchId.equals(lockedBranchId)) {
- AccessObject accessObject = getAccessObject(object);
- removeAccessControlDataIf(true, new AccessControlData(subject, accessObject, PermissionEnum.LOCK, false));
- objectToBranchLockCache.remove(objectArtId);
- lockedObjectToSubject.remove(objectArtId);
- event.getArtifacts().add(object.getBasicGuidArtifact());
- lockedArts.add(object);
- }
- }
- }
- try {
- OseeEventManager.kickAccessControlArtifactsEvent(this, event, new LoadedArtifacts(lockedArts));
- } catch (Exception ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
-
- @Override
- public void removePermissions(IOseeBranch branch) throws OseeCoreException {
- Branch theBranch = getBranchCache().get(branch);
- getDatabaseService().runPreparedUpdate(DELETE_ARTIFACT_ACL_FROM_BRANCH, theBranch.getId());
- getDatabaseService().runPreparedUpdate(DELETE_BRANCH_ACL_FROM_BRANCH, theBranch.getId());
- }
-
- public boolean hasLock(Artifact object) {
- if (!object.isInDb()) {
- return false;
- }
-
- return objectToBranchLockCache.containsKey(object.getArtId());
- }
-
- public boolean canUnlockObject(Artifact object, Artifact subject) {
- Integer subjectId = lockedObjectToSubject.get(object.getArtId());
- return subjectId != null && subjectId.intValue() == subject.getArtId();
- }
-
- public Artifact getSubjectFromLockedObject(Object object) throws OseeCoreException {
- Artifact subject = null;
-
- if (object instanceof Artifact) {
- Integer subjectArtId = lockedObjectToSubject.get(((Artifact) object).getArtId());
-
- if (subjectArtId != null) {
- subject = UserManager.getUserByArtId(subjectArtId);
- }
- }
- return subject;
- }
-
- public boolean hasLockAccess(Artifact object) {
- boolean hasAccess = false;
-
- if (!object.isInDb()) {
- return true;
- }
-
- if (hasLock(object)) {
- hasAccess = objectToBranchLockCache.get(object.getArtId()) == object.getBranch().getId();
- }
- return hasAccess;
- }
-
- public boolean isOseeAdmin() throws OseeCoreException {
- return SystemGroup.OseeAdmin.isCurrentUserMember();
- }
+ private static final String ACCESS_POINT_ID = "osee.access.point";
+
+ private final String INSERT_INTO_ARTIFACT_ACL =
+ "INSERT INTO OSEE_ARTIFACT_ACL (art_id, permission_id, privilege_entity_id, branch_id) VALUES (?, ?, ?, ?)";
+ private final String INSERT_INTO_BRANCH_ACL =
+ "INSERT INTO OSEE_BRANCH_ACL (permission_id, privilege_entity_id, branch_id) VALUES (?, ?, ?)";
+
+ private final String UPDATE_ARTIFACT_ACL =
+ "UPDATE OSEE_ARTIFACT_ACL SET permission_id = ? WHERE privilege_entity_id =? AND art_id = ? AND branch_id = ?";
+ private final String UPDATE_BRANCH_ACL =
+ "UPDATE OSEE_BRANCH_ACL SET permission_id = ? WHERE privilege_entity_id =? AND branch_id = ?";
+
+ private final String GET_ALL_ARTIFACT_ACCESS_CONTROL_LIST =
+ "SELECT aac1.*, art1.art_type_id FROM osee_artifact art1, osee_artifact_acl aac1 WHERE art1.art_id = aac1.privilege_entity_id";
+ private final String GET_ALL_BRANCH_ACCESS_CONTROL_LIST =
+ "SELECT bac1.*, art1.art_type_id FROM osee_artifact art1, osee_branch_acl bac1 WHERE art1.art_id = bac1.privilege_entity_id";
+
+ private final String DELETE_ARTIFACT_ACL_FROM_BRANCH = "DELETE FROM OSEE_ARTIFACT_ACL WHERE branch_id =?";
+ private final String DELETE_BRANCH_ACL_FROM_BRANCH = "DELETE FROM OSEE_BRANCH_ACL WHERE branch_id =?";
+
+ private final String USER_GROUP_MEMBERS =
+ "SELECT b_art_id FROM osee_relation_link WHERE a_art_id =? AND rel_link_type_id =? ORDER BY b_art_id";
+
+ private DoubleKeyHashMap<Integer, AccessObject, PermissionEnum> accessControlListCache;
+ private HashCollection<AccessObject, Integer> objectToSubjectCache; // <subjectId, groupId>
+ private HashCollection<Integer, Integer> subjectToGroupCache; // <groupId, subjectId>
+ private HashCollection<Integer, Integer> groupToSubjectsCache; // <artId, branchId>
+ private Map<Integer, Integer> objectToBranchLockCache; // object, subject
+ private Map<Integer, Integer> lockedObjectToSubject; // subject, permission
+ private HashCollection<Integer, PermissionEnum> subjectToPermissionCache;
+
+ private final IOseeCachingService cachingService;
+ private final IOseeDatabaseService databaseService;
+
+ public AccessControlService(IOseeDatabaseService databaseService, IOseeCachingService cachingService) {
+ super();
+ this.cachingService = cachingService;
+ this.databaseService = databaseService;
+ reloadCache();
+ }
+
+ private ArtifactTypeCache getArtifactTypeCache() {
+ return cachingService.getArtifactTypeCache();
+ }
+
+ private RelationTypeCache getRelationTypeCache() {
+ return cachingService.getRelationTypeCache();
+ }
+
+ private BranchCache getBranchCache() {
+ return cachingService.getBranchCache();
+ }
+
+ private IOseeDatabaseService getDatabaseService() {
+ return databaseService;
+ }
+
+ public synchronized void reloadCache() {
+ initializeCaches();
+ try {
+ populateAccessControlLists();
+ } catch (Exception ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+
+ private void initializeCaches() {
+ accessControlListCache = new DoubleKeyHashMap<Integer, AccessObject, PermissionEnum>();
+ objectToSubjectCache = new HashCollection<AccessObject, Integer>();
+ subjectToGroupCache = new HashCollection<Integer, Integer>();
+ groupToSubjectsCache = new HashCollection<Integer, Integer>();
+ objectToBranchLockCache = new HashMap<Integer, Integer>();
+ lockedObjectToSubject = new HashMap<Integer, Integer>();
+ subjectToPermissionCache = new HashCollection<Integer, PermissionEnum>();
+ }
+
+ private void populateAccessControlLists() throws OseeCoreException {
+ populateArtifactAccessControlList();
+ populateBranchAccessControlList();
+ }
+
+ private void populateBranchAccessControlList() throws OseeCoreException {
+ IOseeStatement chStmt = getDatabaseService().getStatement();
+ try {
+ chStmt.runPreparedQuery(GET_ALL_BRANCH_ACCESS_CONTROL_LIST);
+ while (chStmt.next()) {
+ Integer subjectId = chStmt.getInt("privilege_entity_id");
+ Integer branchId = chStmt.getInt("branch_id");
+ int subjectArtifactTypeId = chStmt.getInt("art_type_id");
+ PermissionEnum permission = PermissionEnum.getPermission(chStmt.getInt("permission_id"));
+ BranchAccessObject branchAccessObject = BranchAccessObject.getBranchAccessObject(branchId);
+
+ accessControlListCache.put(subjectId, branchAccessObject, permission);
+ objectToSubjectCache.put(branchAccessObject, subjectId);
+
+ ArtifactType subjectArtifactType = getArtifactTypeCache().getById(subjectArtifactTypeId);
+ ArtifactType toCheck = getArtifactTypeCache().get(CoreArtifactTypes.UserGroup);
+ if (subjectArtifactType.inheritsFrom(toCheck)) {
+ populateGroupMembers(subjectId);
+ }
+ }
+ } finally {
+ chStmt.close();
+ }
+ }
+
+ private void populateArtifactAccessControlList() throws OseeCoreException {
+ IOseeStatement chStmt = getDatabaseService().getStatement();
+ try {
+ chStmt.runPreparedQuery(GET_ALL_ARTIFACT_ACCESS_CONTROL_LIST);
+
+ while (chStmt.next()) {
+ Integer subjectId = chStmt.getInt("privilege_entity_id");
+ Integer objectId = chStmt.getInt("art_id");
+ Integer branchId = chStmt.getInt("branch_id");
+ int subjectArtifactTypeId = chStmt.getInt("art_type_id");
+ PermissionEnum permission = PermissionEnum.getPermission(chStmt.getInt("permission_id"));
+
+ if (permission.equals(PermissionEnum.LOCK)) {
+ objectToBranchLockCache.put(objectId, branchId);
+ lockedObjectToSubject.put(objectId, subjectId);
+ } else {
+ AccessObject accessObject = ArtifactAccessObject.getArtifactAccessObject(objectId, branchId);
+ cacheAccessObject(objectId, subjectId, permission, accessObject);
+
+ ArtifactType subjectArtifactType = getArtifactTypeCache().getById(subjectArtifactTypeId);
+ ArtifactType toCheck = getArtifactTypeCache().get(CoreArtifactTypes.UserGroup);
+ if (subjectArtifactType.inheritsFrom(toCheck)) {
+ populateGroupMembers(subjectId);
+ }
+ }
+ }
+ } finally {
+ chStmt.close();
+ }
+ }
+
+ private void populateGroupMembers(Integer groupId) throws OseeCoreException {
+ if (!groupToSubjectsCache.containsKey(groupId)) {
+ Integer groupMember;
+
+ IOseeStatement chStmt = getDatabaseService().getStatement();
+ try {
+ RelationType relationType = getRelationTypeCache().get(CoreRelationTypes.Users_User);
+ chStmt.runPreparedQuery(USER_GROUP_MEMBERS, groupId, relationType.getId());
+
+ // get group members and populate subjectToGroupCache
+ while (chStmt.next()) {
+ groupMember = chStmt.getInt("b_art_id");
+ subjectToGroupCache.put(groupMember, groupId);
+ groupToSubjectsCache.put(groupId, groupMember);
+ }
+ } finally {
+ chStmt.close();
+ }
+ }
+ }
+
+ public boolean checkSubjectPermission(Artifact subject, PermissionEnum permission) {
+ boolean isValid = false;
+
+ if (subjectToPermissionCache.containsKey(subject.getArtId())) {
+ for (PermissionEnum subjectPermission : subjectToPermissionCache.getValues(subject.getArtId())) {
+ if (subjectPermission.getRank() >= permission.getRank()) {
+ isValid = true;
+ }
+ }
+ }
+ return isValid;
+ }
+
+ public boolean checkObjectListPermission(Collection<?> objectList, PermissionEnum permission) throws OseeCoreException {
+ boolean isValid = true;
+
+ if (objectList.isEmpty()) {
+ isValid = false;
+ }
+
+ for (Object object : objectList) {
+ isValid &= hasPermission(object, permission);
+ }
+ return isValid;
+ }
+
+ @Override
+ public boolean hasPermission(Object object, PermissionEnum permission) throws OseeCoreException {
+ return hasPermission(UserManager.getUser(), object, permission);
+ }
+
+ public PermissionEnum getObjectPermission(Artifact subject, Object object) throws OseeCoreException {
+ for (PermissionEnum permissionEnum : PermissionEnum.values()) {
+ boolean result = hasPermission(subject, object, permissionEnum);
+ System.out.println("subject " + subject + " object " + object + " permission " + permissionEnum.name() + " -> " + result);
+ if (result) {
+ return permissionEnum;
+ }
+ }
+ return PermissionEnum.FULLACCESS;
+ }
+
+ @Override
+ public AccessData getAccessData(IBasicArtifact<?> userArtifact, Collection<?> objectsToCheck) throws OseeCoreException {
+ ILifecycleService service = getLifecycleService();
+ AccessData accessData = new AccessData();
+ AbstractLifecycleVisitor<?> visitor = new AccessProviderVisitor(userArtifact, objectsToCheck, accessData);
+ IStatus status = service.dispatch(new NullProgressMonitor(), visitor, ACCESS_POINT_ID);
+ try {
+ Operations.checkForErrorStatus(status);
+ } catch (Exception ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ }
+ return accessData;
+ }
+
+ private boolean hasPermission(IBasicArtifact<?> subject, Object object, PermissionEnum permission) throws OseeCoreException {
+ AccessData accessData = getAccessData(subject, Collections.singletonList(object));
+ return accessData.matchesAll(permission);
+ }
+
+ private ILifecycleService getLifecycleService() throws OseeCoreException {
+ Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
+ ServiceTracker tracker = new ServiceTracker(bundle.getBundleContext(), ILifecycleService.class.getName(), null);
+ tracker.open(true);
+ Object serviceObject = tracker.getService();
+ tracker.close();
+ if (serviceObject instanceof ILifecycleService) {
+ return (ILifecycleService) serviceObject;
+ } else {
+ throw new OseeStateException("Lifecycle service is unavailable");
+ }
+ }
+
+ public PermissionEnum getBranchPermission(IBasicArtifact<?> subject, Branch branch) {
+ PermissionEnum userPermission = null;
+ AccessObject accessObject = BranchAccessObject.getBranchAccessObjectFromCache(branch);
+
+ if (accessObject == null) {
+ userPermission = PermissionEnum.FULLACCESS;
+ } else {
+ userPermission = acquirePermissionRank(subject, accessObject);
+ }
+ return userPermission;
+ }
+
+ public PermissionEnum getArtifactPermission(IBasicArtifact<?> subject, Artifact artifact) {
+ PermissionEnum userPermission = null;
+ AccessObject accessObject = null;
+
+ // The artifact is new and has not been persisted.
+ if (!artifact.isInDb()) {
+ return PermissionEnum.FULLACCESS;
+ }
+
+ Integer artId = artifact.getArtId();
+ Integer branchId = artifact.getBranch().getId();
+ Integer lockedBranchId;
+
+ // accessObject = accessObjectCache.get(artId, branchId);
+ accessObject = ArtifactAccessObject.getArtifactAccessObjectFromCache(artId, branchId);
+
+ if (objectToBranchLockCache.containsKey(artId)) {
+ lockedBranchId = objectToBranchLockCache.get(artId);
+
+ // this object is locked under a different branch
+ if (lockedBranchId.intValue() != branchId.intValue()) {
+ userPermission = PermissionEnum.LOCK;
+ }
+ }
+
+ if (userPermission == null && accessObject != null) {
+ userPermission = acquirePermissionRank(subject, accessObject);
+ }
+ return userPermission;
+ }
+
+ private PermissionEnum acquirePermissionRank(IBasicArtifact<?> subject, AccessObject accessObject) {
+ PermissionEnum userPermission = null;
+ int subjectId = subject.getArtId();
+
+ userPermission = accessControlListCache.get(subjectId, accessObject);
+
+ if (subjectToGroupCache.containsKey(subjectId)) {
+ for (int groupPermissionId : subjectToGroupCache.getValues(subjectId)) {
+ PermissionEnum groupPermission = accessControlListCache.get(groupPermissionId, accessObject);
+
+ if (groupPermission != null) {
+ if (userPermission == null) {
+ userPermission = groupPermission;
+ }
+
+ if (groupPermission.getRank() > userPermission.getRank()) {
+ userPermission = groupPermission;
+ }
+ }
+ }
+ }
+ return userPermission;
+ }
+
+ public void persistPermission(AccessControlData data) {
+ persistPermission(data, false);
+ }
+
+ public void setPermission(Artifact subject, Object object, PermissionEnum permission) {
+ AccessObject accessObject = getAccessObject(object);
+
+ boolean newAccessControlData = !accessControlListCache.containsKey(subject.getArtId(), accessObject);
+
+ if (newAccessControlData || permission != accessControlListCache.get(subject.getArtId(), accessObject)) {
+ AccessControlData data = new AccessControlData(subject, accessObject, permission, newAccessControlData);
+ persistPermission(data);
+ }
+ }
+
+ public void persistPermission(AccessControlData data, boolean recurse) {
+ Artifact subject = data.getSubject();
+ PermissionEnum permission = data.getPermission();
+
+ if (data.isDirty()) {
+ data.setNotDirty();
+
+ try {
+ if (data.getObject() instanceof ArtifactAccessObject) {
+ ArtifactAccessObject artifactAccessObject = (ArtifactAccessObject) data.getObject();
+
+ if (data.isBirth()) {
+ getDatabaseService().runPreparedUpdate(INSERT_INTO_ARTIFACT_ACL, artifactAccessObject.getArtId(),
+ data.getPermission().getPermId(), data.getSubject().getArtId(), artifactAccessObject.getId());
+ } else {
+ getDatabaseService().runPreparedUpdate(UPDATE_ARTIFACT_ACL, data.getPermission().getPermId(),
+ data.getSubject().getArtId(), artifactAccessObject.getArtId(), artifactAccessObject.getId());
+ }
+
+ if (recurse) {
+ Artifact artifact =
+ ArtifactQuery.getArtifactFromId(artifactAccessObject.getArtId(),
+ BranchManager.getBranch(artifactAccessObject.getId()));
+ AccessControlData childAccessControlData = null;
+
+ for (Artifact child : artifact.getChildren()) {
+ AccessObject accessObject = getAccessObject(child);
+
+ if (objectToSubjectCache.containsKey(accessObject)) {
+ Collection<Integer> subjectIds = objectToSubjectCache.getValues(accessObject);
+
+ for (int subjectId : subjectIds) {
+ if (subjectId == subject.getArtId()) {
+ childAccessControlData = new AccessControlData(subject, accessObject, permission, false);
+ }
+ }
+ }
+
+ if (childAccessControlData == null) {
+ childAccessControlData = new AccessControlData(subject, accessObject, permission, true);
+ }
+ persistPermission(childAccessControlData, true);
+ }
+ }
+ } else if (data.getObject() instanceof BranchAccessObject) {
+ BranchAccessObject branchAccessObject = (BranchAccessObject) data.getObject();
+
+ if (data.isBirth()) {
+ getDatabaseService().runPreparedUpdate(INSERT_INTO_BRANCH_ACL, data.getPermission().getPermId(),
+ data.getSubject().getArtId(), branchAccessObject.getId());
+ } else {
+ getDatabaseService().runPreparedUpdate(UPDATE_BRANCH_ACL, data.getPermission().getPermId(),
+ data.getSubject().getArtId(), branchAccessObject.getId());
+ }
+ }
+ cacheAccessControlData(data);
+ } catch (OseeCoreException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+ }
+
+ private void cacheAccessControlData(AccessControlData data) throws OseeCoreException {
+ AccessObject accessObject = data.getObject();
+ int subjectId = data.getSubject().getArtId();
+ PermissionEnum permission = data.getPermission();
+
+ if (!permission.equals(PermissionEnum.LOCK)) {
+ accessControlListCache.put(subjectId, accessObject, permission);
+ objectToSubjectCache.put(accessObject, subjectId);
+
+ populateGroupMembers(subjectId);
+ }
+ }
+
+ public List<AccessControlData> getAccessControlList(Object object) {
+ List<AccessControlData> datas = new LinkedList<AccessControlData>();
+ AccessObject accessObject = null;
+
+ try {
+ accessObject = AccessObject.getAccessObjectFromCache(object);
+
+ if (accessObject == null) {
+ return datas;
+ }
+
+ datas = generateAccessControlList(accessObject);
+
+ } catch (Exception ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ return datas;
+ }
+
+ public List<AccessControlData> generateAccessControlList(AccessObject accessObject) throws OseeCoreException {
+ List<AccessControlData> datas = new LinkedList<AccessControlData>();
+
+ Collection<Integer> subjects = objectToSubjectCache.getValues(accessObject);
+ if (subjects == null) {
+ return datas;
+ }
+
+ for (int subjectId : subjects) {
+ Artifact subject = UserManager.getUserByArtId(subjectId);
+ PermissionEnum permissionEnum = accessControlListCache.get(subjectId, accessObject);
+ AccessControlData accessControlData =
+ new AccessControlData(subject, accessObject, permissionEnum, false, false);
+ if (accessObject instanceof ArtifactAccessObject) {
+ accessControlData.setArtifactPermission(permissionEnum);
+ accessControlData.setBranchPermission(getBranchPermission(subject, accessObject));
+ } else if (accessObject instanceof BranchAccessObject) {
+ accessControlData.setBranchPermission(getBranchPermission(subject, accessObject));
+ }
+ datas.add(accessControlData);
+ }
+
+ return datas;
+ }
+
+ private PermissionEnum getBranchPermission(IBasicArtifact<?> subject, Object object) throws OseeCoreException {
+ int branchId = ((AccessObject) object).getId();
+ Branch branch = BranchManager.getBranch(branchId);
+
+ return getBranchPermission(subject, branch);
+ }
+
+ public void removeAccessControlDataIf(boolean removeFromDb, AccessControlData data) throws OseeDataStoreException {
+ int subjectId = data.getSubject().getArtId();
+ AccessObject accessControlledObject = data.getObject();
+ if (removeFromDb) {
+ accessControlledObject.removeFromDatabase(subjectId);
+ }
+
+ if (accessControlledObject instanceof ArtifactAccessObject) {
+ accessControlledObject.removeFromCache();
+ }
+ deCacheAccessControlData(data);
+ }
+
+ private void deCacheAccessControlData(AccessControlData data) {
+ if (data == null) {
+ throw new IllegalArgumentException("Can not remove a null AccessControlData.");
+ }
+
+ AccessObject accessObject = data.getObject();
+ Integer subjectId = data.getSubject().getArtId();
+
+ accessControlListCache.remove(subjectId, accessObject);
+ objectToSubjectCache.removeValue(accessObject, subjectId);
+ Collection<Integer> members = groupToSubjectsCache.getValues(subjectId);
+
+ if (members != null) {
+ for (Integer member : members) {
+ subjectToGroupCache.removeValue(member, subjectId);
+ }
+ }
+ if (!objectToSubjectCache.containsKey(accessObject)) {
+ accessObject.removeFromCache();
+ }
+ }
+
+ public AccessObject getAccessObject(Object object) {
+ return AccessObject.getAccessObject(object);
+ }
+
+ private void cacheAccessObject(Integer objectId, Integer subjectId, PermissionEnum permission, AccessObject accessObject) {
+ accessControlListCache.put(subjectId, accessObject, permission);
+ objectToSubjectCache.put(accessObject, subjectId);
+ }
+
+ public void lockObjects(Collection<Artifact> objects, Artifact subject) {
+ AccessControlEvent event = new AccessControlEvent();
+ event.setEventType(AccessControlEventType.ArtifactsLocked);
+ Set<Artifact> lockedArts = new HashSet<Artifact>();
+ for (Artifact object : objects) {
+ Integer objectArtId = object.getArtId();
+ Integer subjectArtId = subject.getArtId();
+ Integer objectBranchId = object.getBranch().getId();
+
+ if (!objectToBranchLockCache.containsKey(objectArtId)) {
+ AccessObject accessObject = getAccessObject(object);
+ AccessControlData data = new AccessControlData(subject, accessObject, PermissionEnum.LOCK, true);
+ persistPermission(data);
+ objectToBranchLockCache.put(objectArtId, objectBranchId);
+ lockedObjectToSubject.put(objectArtId, subjectArtId);
+ event.getArtifacts().add(object.getBasicGuidArtifact());
+ lockedArts.add(object);
+ }
+ }
+ try {
+ OseeEventManager.kickAccessControlArtifactsEvent(this, event, new LoadedArtifacts(lockedArts));
+ } catch (Exception ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+
+ public void unLockObjects(Collection<Artifact> objects, Artifact subject) throws OseeDataStoreException, OseeAuthenticationRequiredException {
+ AccessControlEvent event = new AccessControlEvent();
+ event.setEventType(AccessControlEventType.ArtifactsUnlocked);
+ Set<Artifact> lockedArts = new HashSet<Artifact>();
+ for (Artifact object : objects) {
+ Integer objectArtId = object.getArtId();
+ Integer branchId = object.getBranch().getId();
+ Integer lockedBranchId;
+
+ if (objectToBranchLockCache.containsKey(objectArtId) && canUnlockObject(object, subject)) {
+ lockedBranchId = objectToBranchLockCache.get(objectArtId);
+
+ if (branchId.equals(lockedBranchId)) {
+ AccessObject accessObject = getAccessObject(object);
+ removeAccessControlDataIf(true, new AccessControlData(subject, accessObject, PermissionEnum.LOCK, false));
+ objectToBranchLockCache.remove(objectArtId);
+ lockedObjectToSubject.remove(objectArtId);
+ event.getArtifacts().add(object.getBasicGuidArtifact());
+ lockedArts.add(object);
+ }
+ }
+ }
+ try {
+ OseeEventManager.kickAccessControlArtifactsEvent(this, event, new LoadedArtifacts(lockedArts));
+ } catch (Exception ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+
+ @Override
+ public void removePermissions(IOseeBranch branch) throws OseeCoreException {
+ Branch theBranch = getBranchCache().get(branch);
+ getDatabaseService().runPreparedUpdate(DELETE_ARTIFACT_ACL_FROM_BRANCH, theBranch.getId());
+ getDatabaseService().runPreparedUpdate(DELETE_BRANCH_ACL_FROM_BRANCH, theBranch.getId());
+ }
+
+ public boolean hasLock(Artifact object) {
+ if (!object.isInDb()) {
+ return false;
+ }
+
+ return objectToBranchLockCache.containsKey(object.getArtId());
+ }
+
+ public boolean canUnlockObject(Artifact object, Artifact subject) {
+ Integer subjectId = lockedObjectToSubject.get(object.getArtId());
+ return subjectId != null && subjectId.intValue() == subject.getArtId();
+ }
+
+ public Artifact getSubjectFromLockedObject(Object object) throws OseeCoreException {
+ Artifact subject = null;
+
+ if (object instanceof Artifact) {
+ Integer subjectArtId = lockedObjectToSubject.get(((Artifact) object).getArtId());
+
+ if (subjectArtId != null) {
+ subject = UserManager.getUserByArtId(subjectArtId);
+ }
+ }
+ return subject;
+ }
+
+ public boolean hasLockAccess(Artifact object) {
+ boolean hasAccess = false;
+
+ if (!object.isInDb()) {
+ return true;
+ }
+
+ if (hasLock(object)) {
+ hasAccess = objectToBranchLockCache.get(object.getArtId()) == object.getBranch().getId();
+ }
+ return hasAccess;
+ }
+
+ public boolean isOseeAdmin() throws OseeCoreException {
+ return SystemGroup.OseeAdmin.isCurrentUserMember();
+ }
+
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/HttpAttributeTagger.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/HttpAttributeTagger.java
index 8a8d6b93bc5..a62fe4d3498 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/HttpAttributeTagger.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/HttpAttributeTagger.java
@@ -137,6 +137,11 @@ public class HttpAttributeTagger {
}
}
+ /**
+ * <REM2>
+ *
+ * @author Donald G. Dunne
+ */
private final class EventRelay implements IArtifactEventListener, IFrameworkTransactionEventListener, IBranchEventListener, IArtifactsPurgedEventListener, IArtifactsChangeTypeEventListener, ITransactionEventListener, ITransactionsDeletedEventListener {
@Override
public void handleBranchEventREM1(Sender sender, BranchEventType branchModType, int branchId) {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/InternalEventManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/InternalEventManager.java
index cce3116a460..e0c84a6a4e3 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/InternalEventManager.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/InternalEventManager.java
@@ -264,18 +264,14 @@ public class InternalEventManager {
if (loadedArtifacts != null && !loadedArtifacts.getLoadedArtifacts().isEmpty()) {
branchId = loadedArtifacts.getLoadedArtifacts().iterator().next().getBranch().getId();
}
- Collection<Integer> artifactIds;
- Collection<Integer> artifactTypeIds;
if (loadedArtifacts != null) {
- artifactIds = loadedArtifacts.getAllArtifactIds();
- artifactTypeIds = loadedArtifacts.getAllArtifactTypeIds();
- } else {
- artifactIds = Collections.emptyList();
- artifactTypeIds = Collections.emptyList();
+ Collection<Integer> artifactIds = loadedArtifacts.getAllArtifactIds();
+ Collection<Integer> artifactTypeIds = loadedArtifacts.getAllArtifactTypeIds();
+
+ RemoteEventManager.kick(new NetworkAccessControlArtifactsEvent(
+ accessControlEvent.getEventType().name(), branchId == null ? -1 : branchId, artifactIds,
+ artifactTypeIds, sender.getNetworkSender()));
}
- RemoteEventManager.kick(new NetworkAccessControlArtifactsEvent(
- accessControlEvent.getEventType().name(), branchId == null ? -1 : branchId, artifactIds,
- artifactTypeIds, sender.getNetworkSender()));
}
} catch (OseeCoreException ex) {
OseeLog.log(Activator.class, Level.SEVERE, ex);
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event2/ArtifactEvent.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event2/ArtifactEvent.java
index 2dea7743085..31269aed0bf 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event2/ArtifactEvent.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event2/ArtifactEvent.java
@@ -8,6 +8,7 @@ import java.util.Set;
import java.util.logging.Level;
import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.event.IBasicGuidArtifact;
import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.logging.OseeLog;
@@ -42,6 +43,10 @@ public class ArtifactEvent extends FrameworkEvent {
this.branchGuid = value;
}
+ public boolean isForBranch(Branch branch) {
+ return getBranchGuid().equals(branch.getGuid());
+ }
+
public int getTransactionId() {
return transactionId;
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java
index 31796c327f1..2e6c9491c06 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java
@@ -41,7 +41,6 @@ import org.eclipse.jface.window.Window;
import org.eclipse.osee.framework.access.AccessControlManager;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.core.enums.PermissionEnum;
-import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeStateException;
import org.eclipse.osee.framework.core.model.Branch;
@@ -59,7 +58,6 @@ import org.eclipse.osee.framework.plugin.core.util.Jobs;
import org.eclipse.osee.framework.skynet.core.OseeSystemArtifacts;
import org.eclipse.osee.framework.skynet.core.UserManager;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.ArtifactModType;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.artifact.IBranchProvider;
@@ -69,18 +67,14 @@ import org.eclipse.osee.framework.skynet.core.event.BranchEventType;
import org.eclipse.osee.framework.skynet.core.event.FrameworkTransactionData;
import org.eclipse.osee.framework.skynet.core.event.FrameworkTransactionData.ChangeType;
import org.eclipse.osee.framework.skynet.core.event.IAccessControlEventListener;
-import org.eclipse.osee.framework.skynet.core.event.IArtifactModifiedEventListener;
import org.eclipse.osee.framework.skynet.core.event.IArtifactsChangeTypeEventListener;
import org.eclipse.osee.framework.skynet.core.event.IArtifactsPurgedEventListener;
import org.eclipse.osee.framework.skynet.core.event.IBranchEventListener;
import org.eclipse.osee.framework.skynet.core.event.IFrameworkTransactionEventListener;
-import org.eclipse.osee.framework.skynet.core.event.IRelationModifiedEventListener;
import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
import org.eclipse.osee.framework.skynet.core.event.Sender;
import org.eclipse.osee.framework.skynet.core.event2.AccessControlEvent;
import org.eclipse.osee.framework.skynet.core.event2.BranchEvent;
-import org.eclipse.osee.framework.skynet.core.relation.RelationEventType;
-import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.skynet.core.utility.LoadedArtifacts;
import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
@@ -119,6 +113,8 @@ import org.eclipse.osee.framework.ui.swt.Widgets;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.custom.TreeEditor;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.KeyAdapter;
@@ -157,9 +153,11 @@ import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.progress.UIJob;
/**
+ * <REM2> except for IRelationModifiedEventListener, IArtifactModifiedEventListener
+ *
* @author Ryan D. Brooks
*/
-public class ArtifactExplorer extends ViewPart implements IRebuildMenuListener, IAccessControlEventListener, IRelationModifiedEventListener, IArtifactModifiedEventListener, IFrameworkTransactionEventListener, IBranchEventListener, IArtifactsPurgedEventListener, IArtifactsChangeTypeEventListener, IActionable, ISelectionProvider, IBranchProvider {
+public class ArtifactExplorer extends ViewPart implements IArtifactExplorerEventHandler, IRebuildMenuListener, IAccessControlEventListener, IFrameworkTransactionEventListener, IBranchEventListener, IArtifactsPurgedEventListener, IArtifactsChangeTypeEventListener, IActionable, ISelectionProvider, IBranchProvider {
public static final String VIEW_ID = "org.eclipse.osee.framework.ui.skynet.ArtifactExplorer";
private static final String ROOT_GUID = "artifact.explorer.last.root_guid";
private static final String ROOT_BRANCH = "artifact.explorer.last.root_branch";
@@ -325,6 +323,13 @@ public class ArtifactExplorer extends ViewPart implements IRebuildMenuListener,
treeViewer = new TreeViewer(stackComposite);
myTree = treeViewer.getTree();
Tree tree = treeViewer.getTree();
+ final ArtifactExplorer fArtExplorere = this;
+ tree.addDisposeListener(new DisposeListener() {
+
+ public void widgetDisposed(DisposeEvent e) {
+ ArtifactExplorerEventManager.remove(fArtExplorere);
+ }
+ });
treeViewer.setContentProvider(new ArtifactContentProvider());
treeViewer.setLabelProvider(new ArtifactLabelProvider(artifactDecorator));
@@ -379,6 +384,7 @@ public class ArtifactExplorer extends ViewPart implements IRebuildMenuListener,
}
OseeEventManager.addListener(this);
+ ArtifactExplorerEventManager.add(this);
}
/**
@@ -1238,10 +1244,8 @@ public class ArtifactExplorer extends ViewPart implements IRebuildMenuListener,
@Override
public void dispose() {
OseeEventManager.removeListener(this);
+ ArtifactExplorerEventManager.remove(this);
super.dispose();
- if (treeViewer != null) {
- trees.remove(treeViewer.getTree());
- }
}
public String getActionDescription() {
@@ -1379,70 +1383,6 @@ public class ArtifactExplorer extends ViewPart implements IRebuildMenuListener,
}
@Override
- public void handleRelationModifiedEvent(Sender sender, RelationEventType relationEventType, final RelationLink link, Branch branch, String relationType) {
- try {
- if (this.branch == null || !this.branch.equals(branch)) {
- return;
- }
- if (link.isOfType(CoreRelationTypes.Default_Hierarchical__Child)) {
- Displays.ensureInDisplayThread(new Runnable() {
- @Override
- public void run() {
- try {
- // Since this is always a local event, artifact will always be in cache
- Artifact aArtifact = link.getArtifactIfLoaded(RelationSide.SIDE_A);
- if (aArtifact != null) {
- treeViewer.refresh(aArtifact);
- }
- Artifact bArtifact = link.getArtifactIfLoaded(RelationSide.SIDE_B);
- if (bArtifact != null) {
- treeViewer.refresh(bArtifact);
- }
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.INFO, ex);
- }
- }
- });
- }
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
- }
-
- @Override
- public void handleArtifactModifiedEvent(Sender sender, final ArtifactModType artifactModType, final Artifact artifact) {
- try {
- if (branch == null || !artifact.getBranch().equals(branch)) {
- return;
- }
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
- Displays.ensureInDisplayThread(new Runnable() {
- @Override
- public void run() {
- try {
- if (artifactModType == ArtifactModType.Deleted) {
- treeViewer.remove(artifact);
- } else if (artifactModType == ArtifactModType.Added) {
- if (artifact.getParent() != null) {
- treeViewer.refresh(artifact.getParent());
- }
- } else if (artifactModType == ArtifactModType.Changed) {
- treeViewer.refresh(artifact, true);
- } else if (artifactModType == ArtifactModType.Reverted) {
- if (artifact.hasParent()) {
- treeViewer.refresh(artifact.getParent());
- }
- }
- } catch (Exception ex) {
- // do nothing
- }
- }
- });
- }
-
- @Override
public void handleBranchEventREM1(Sender sender, BranchEventType branchModType, final int branchId) {
if (branchModType == BranchEventType.Committed && branch != null && branch.getId() == branchId) {
SkynetViews.closeView(VIEW_ID, getViewSite().getSecondaryId());
@@ -1593,4 +1533,23 @@ public class ArtifactExplorer extends ViewPart implements IRebuildMenuListener,
@Override
public void handleLocalBranchToArtifactCacheUpdateEvent(Sender sender) {
}
+
+ public TreeViewer getTreeViewer() {
+ return treeViewer;
+ }
+
+ public void setTreeViewer(TreeViewer treeViewer) {
+ this.treeViewer = treeViewer;
+ }
+
+ @Override
+ public ArtifactExplorer getArtifactExplorer() {
+ return this;
+ }
+
+ @Override
+ public boolean isDisposed() {
+ return treeViewer.getTree() == null || treeViewer.getTree().isDisposed();
+ }
+
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerEventManager.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerEventManager.java
new file mode 100644
index 00000000000..970fe74f638
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerEventManager.java
@@ -0,0 +1,112 @@
+/*
+ * Created on Jun 30, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.ui.skynet;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
+import org.eclipse.osee.framework.skynet.core.event.Sender;
+import org.eclipse.osee.framework.skynet.core.event2.ArtifactEvent;
+import org.eclipse.osee.framework.skynet.core.event2.artifact.EventBasicGuidArtifact;
+import org.eclipse.osee.framework.skynet.core.event2.artifact.EventModType;
+import org.eclipse.osee.framework.skynet.core.event2.artifact.IArtifactEventListener;
+import org.eclipse.osee.framework.skynet.core.event2.filter.IEventFilter;
+import org.eclipse.osee.framework.ui.plugin.util.Displays;
+
+/**
+ * Common location for event handling for ArtifactExplorers in order to keep number of registrations and processing to a
+ * minimum.
+ *
+ * @author Donald G. Dunne
+ */
+public class ArtifactExplorerEventManager implements IArtifactEventListener {
+
+ List<IArtifactExplorerEventHandler> handlers = new ArrayList<IArtifactExplorerEventHandler>();
+ static ArtifactExplorerEventManager instance;
+
+ public static void add(IArtifactExplorerEventHandler iWorldEventHandler) {
+ if (instance == null) {
+ instance = new ArtifactExplorerEventManager();
+ OseeEventManager.addListener(instance);
+ }
+ instance.handlers.add(iWorldEventHandler);
+ }
+
+ public static void remove(IArtifactExplorerEventHandler iWorldEventHandler) {
+ if (instance != null) {
+ instance.handlers.remove(iWorldEventHandler);
+ }
+ }
+
+ @Override
+ public List<? extends IEventFilter> getEventFilters() {
+ // Can't filter cause this class handles all artifact explorers which can care about different branches
+ return null;
+ }
+
+ @Override
+ public void handleArtifactEvent(final ArtifactEvent artifactEvent, Sender sender) {
+ for (IArtifactExplorerEventHandler handler : new CopyOnWriteArrayList<IArtifactExplorerEventHandler>(handlers)) {
+ if (handler.isDisposed()) {
+ handlers.remove(handler);
+ }
+ }
+ System.out.println("ArtifacExplorer: handleArtifactEvent called [" + artifactEvent + "] - sender " + sender + "");
+ final Collection<Artifact> modifiedArts =
+ artifactEvent.getCacheArtifacts(EventModType.Modified, EventModType.Reloaded);
+ final Collection<Artifact> relModifiedArts = artifactEvent.getRelCacheArtifacts();
+ final Collection<EventBasicGuidArtifact> deletedPurgedArts =
+ artifactEvent.get(EventModType.Deleted, EventModType.Purged);
+
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ if (!deletedPurgedArts.isEmpty()) {
+ for (IArtifactExplorerEventHandler handler : handlers) {
+ if (!handler.isDisposed()) {
+ handler.getArtifactExplorer().getTreeViewer().remove(
+ deletedPurgedArts.toArray(new Object[deletedPurgedArts.size()]));
+ }
+ }
+ }
+ for (IArtifactExplorerEventHandler handler : handlers) {
+ if (!handler.isDisposed()) {
+ for (Artifact artifact : modifiedArts) {
+ // Don't refresh deleted artifacts
+ if (artifact.isDeleted()) {
+ continue;
+ }
+ handler.getArtifactExplorer().getTreeViewer().update(artifact, null);
+ }
+
+ for (Artifact art : relModifiedArts) {
+ try {
+ // Don't refresh deleted artifacts
+ if (art.isDeleted()) {
+ continue;
+ }
+ if (!art.isDeleted()) {
+ handler.getArtifactExplorer().getTreeViewer().refresh(art);
+ if (art.getParent() != null) {
+ handler.getArtifactExplorer().getTreeViewer().refresh(art.getParent());
+ }
+ }
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ }
+ }
+ }
+ }
+ }
+ });
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/IArtifactExplorerEventHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/IArtifactExplorerEventHandler.java
new file mode 100644
index 00000000000..def8e0f3dc9
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/IArtifactExplorerEventHandler.java
@@ -0,0 +1,18 @@
+/*
+ * Created on Jun 30, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.ui.skynet;
+
+
+/**
+ * @author Donald G. Dunne
+ */
+public interface IArtifactExplorerEventHandler {
+
+ public ArtifactExplorer getArtifactExplorer();
+
+ public boolean isDisposed();
+
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationsComposite.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationsComposite.java
index 9cf2988fab7..f6f2dbf5d66 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationsComposite.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationsComposite.java
@@ -34,7 +34,6 @@ import org.eclipse.osee.framework.core.enums.IRelationEnumeration;
import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.core.exception.ArtifactDoesNotExist;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.type.RelationType;
import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.logging.OseeLevel;
@@ -43,11 +42,8 @@ import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactData;
import org.eclipse.osee.framework.skynet.core.event.FrameworkTransactionData;
import org.eclipse.osee.framework.skynet.core.event.IFrameworkTransactionEventListener;
-import org.eclipse.osee.framework.skynet.core.event.IRelationModifiedEventListener;
import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
import org.eclipse.osee.framework.skynet.core.event.Sender;
-import org.eclipse.osee.framework.skynet.core.relation.RelationEventType;
-import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
import org.eclipse.osee.framework.skynet.core.relation.RelationTypeSide;
import org.eclipse.osee.framework.skynet.core.relation.RelationTypeSideSorter;
@@ -88,7 +84,7 @@ import org.eclipse.ui.PlatformUI;
/**
* @author Ryan D. Brooks
*/
-public class RelationsComposite extends Composite implements IRelationModifiedEventListener, IFrameworkTransactionEventListener {
+public class RelationsComposite extends Composite implements IFrameworkTransactionEventListener {
private TreeViewer treeViewer;
private Tree tree;
private NeedSelectedArtifactListener needSelectedArtifactListener;
@@ -569,11 +565,6 @@ public class RelationsComposite extends Composite implements IRelationModifiedEv
this.packColumnData();
}
- /**
- * Performs the deletion functionality
- *
- * @param selection
- */
private void performDeleteArtifact(IStructuredSelection selection) {
try {
Set<Artifact> artifactsToBeDeleted = getSelectedArtifacts(selection);
@@ -597,12 +588,6 @@ public class RelationsComposite extends Composite implements IRelationModifiedEv
refresh();
}
- /**
- * Performs the deletion functionality
- *
- * @param selection
- * @throws ArtifactDoesNotExist
- */
private void performDeleteRelation(IStructuredSelection selection) throws ArtifactDoesNotExist {
if (artifact.isReadOnly()) {
MessageDialog.openError(
@@ -638,6 +623,7 @@ public class RelationsComposite extends Composite implements IRelationModifiedEv
}
}
}
+ editor.onDirtied();
}
public void refresh() {
@@ -668,9 +654,6 @@ public class RelationsComposite extends Composite implements IRelationModifiedEv
}
}
- /**
- * @return Returns the artifact.
- */
public Artifact getArtifact() {
return artifact;
}
@@ -757,11 +740,6 @@ public class RelationsComposite extends Composite implements IRelationModifiedEv
}
}
- /**
- * @param targetLink
- * @param dropTarget
- * @return
- */
private boolean relationLinkIsInSameGroup(WrapperForRelationLink targetLink, WrapperForRelationLink dropTarget) {
return targetLink.getRelationType().equals(dropTarget.getRelationType()) && //same type
(targetLink.getArtifactA().equals(dropTarget.getArtifactA()) || //either the A or B side is equal, meaning they are on the same side
@@ -807,6 +785,8 @@ public class RelationsComposite extends Composite implements IRelationModifiedEv
ArtifactDragDropSupport.performDragDrop(event, window,
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
window.createArtifactInformationBox();
+ treeViewer.refresh();
+ editor.onDirtied();
}
} catch (OseeCoreException ex) {
OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
@@ -821,32 +801,11 @@ public class RelationsComposite extends Composite implements IRelationModifiedEv
"org.eclipse.osee.framework.help.ui");
}
- /**
- * @return the toolBar
- */
public ToolBar getToolBar() {
return toolBar;
}
@Override
- public void handleRelationModifiedEvent(Sender sender, RelationEventType relationEventType, RelationLink link, Branch branch, String relationType) {
- try {
- if (link.getArtifactA().equals(this.artifact) || link.getArtifactB().equals(this.artifact)) {
- Displays.ensureInDisplayThread(new Runnable() {
- @Override
- public void run() {
- if (!treeViewer.getControl().isDisposed()) {
- treeViewer.refresh();
- }
- }
- });
- }
- } catch (Exception ex) {
- // do nothing
- }
- }
-
- @Override
public void handleFrameworkTransactionEvent(Sender sender, FrameworkTransactionData transData) throws OseeCoreException {
if (transData.isRelAddedChangedDeleted(this.artifact)) {
Displays.ensureInDisplayThread(new Runnable() {
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/AbstractArtifactEditor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/AbstractArtifactEditor.java
index d96aaa22781..8267ded2000 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/AbstractArtifactEditor.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/AbstractArtifactEditor.java
@@ -60,7 +60,7 @@ public abstract class AbstractArtifactEditor extends FormEditor implements IDirt
return (XFormToolkit) super.getToolkit();
}
- protected Artifact getArtifactFromEditorInput() {
+ public Artifact getArtifactFromEditorInput() {
return (Artifact) getEditorInput().getAdapter(Artifact.class);
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/AbstractEventArtifactEditor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/AbstractEventArtifactEditor.java
index f6111696ea1..5af7b269b7a 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/AbstractEventArtifactEditor.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/AbstractEventArtifactEditor.java
@@ -12,42 +12,42 @@ package org.eclipse.osee.framework.ui.skynet.artifact.editor;
import java.util.logging.Level;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.ArtifactModType;
import org.eclipse.osee.framework.skynet.core.event.AccessControlEventType;
import org.eclipse.osee.framework.skynet.core.event.BranchEventType;
import org.eclipse.osee.framework.skynet.core.event.FrameworkTransactionData;
import org.eclipse.osee.framework.skynet.core.event.IAccessControlEventListener;
-import org.eclipse.osee.framework.skynet.core.event.IArtifactModifiedEventListener;
import org.eclipse.osee.framework.skynet.core.event.IArtifactsChangeTypeEventListener;
import org.eclipse.osee.framework.skynet.core.event.IArtifactsPurgedEventListener;
import org.eclipse.osee.framework.skynet.core.event.IBranchEventListener;
import org.eclipse.osee.framework.skynet.core.event.IFrameworkTransactionEventListener;
-import org.eclipse.osee.framework.skynet.core.event.IRelationModifiedEventListener;
import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
import org.eclipse.osee.framework.skynet.core.event.Sender;
import org.eclipse.osee.framework.skynet.core.event2.AccessControlEvent;
import org.eclipse.osee.framework.skynet.core.event2.BranchEvent;
-import org.eclipse.osee.framework.skynet.core.relation.RelationEventType;
-import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
import org.eclipse.osee.framework.skynet.core.utility.LoadedArtifacts;
import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
+import org.eclipse.swt.graphics.Image;
/**
* @author Jeff C. Phillips
*/
-public abstract class AbstractEventArtifactEditor extends AbstractArtifactEditor {
+public abstract class AbstractEventArtifactEditor extends AbstractArtifactEditor implements IArtifactEditorEventHandler {
private final InternalEventHandler internalEventHandler;
public AbstractEventArtifactEditor() {
super();
- internalEventHandler = new InternalEventHandler();
- OseeEventManager.addListener(internalEventHandler);
+ if (OseeEventManager.isOldEvents()) {
+ internalEventHandler = new InternalEventHandler();
+ OseeEventManager.addListener(internalEventHandler);
+ } else {
+ internalEventHandler = null;
+ ArtifactEditorEventManager.add(this);
+ }
}
@Override
@@ -59,7 +59,7 @@ public abstract class AbstractEventArtifactEditor extends AbstractArtifactEditor
boolean wasDirty = false;
Artifact artifact = getArtifactFromEditorInput();
if (artifact != null) {
- if (!artifact.isDeleted()) {
+ if (!artifact.isDeleted()) {
wasDirty = super.isDirty() || artifact.isDirty();
}
}
@@ -68,33 +68,35 @@ public abstract class AbstractEventArtifactEditor extends AbstractArtifactEditor
protected abstract void checkEnabledTooltems();
- protected abstract void refreshDirtyArtifact();
+ public abstract void refreshDirtyArtifact();
+
+ public abstract void closeEditor();
- protected abstract void closeEditor();
+ public abstract void refreshRelations();
- protected abstract void refreshRelations();
+ public void setMainImage(Image titleImage) {
+ super.setTitleImage(titleImage);
+ }
@Override
public void dispose() {
super.dispose();
- OseeEventManager.removeListener(internalEventHandler);
+ if (OseeEventManager.isOldEvents()) {
+ OseeEventManager.removeListener(internalEventHandler);
+ }
}
- private final class InternalEventHandler implements IArtifactsPurgedEventListener, IBranchEventListener, IAccessControlEventListener, IArtifactModifiedEventListener, IArtifactsChangeTypeEventListener, IRelationModifiedEventListener, IFrameworkTransactionEventListener {
- @Override
- public void handleArtifactModifiedEvent(Sender sender, final ArtifactModType artifactModType, final Artifact artifact) {
- Displays.ensureInDisplayThread(new Runnable() {
- @Override
- public void run() {
- if (getArtifactFromEditorInput() == null || !getArtifactFromEditorInput().equals(artifact)) {
- return;
- }
- if (artifactModType == ArtifactModType.Added || artifactModType == ArtifactModType.Changed || artifactModType == ArtifactModType.Reverted) {
- refreshDirtyArtifact();
- }
- }
- });
- }
+ @Override
+ public AbstractEventArtifactEditor getEditor() {
+ return this;
+ }
+
+ /**
+ * <REM2> this entire listener can be removed cause handled through ArtifactEditorEventManager
+ *
+ * @author Donald G. Dunne
+ */
+ private final class InternalEventHandler implements IArtifactsPurgedEventListener, IBranchEventListener, IAccessControlEventListener, IArtifactsChangeTypeEventListener, IFrameworkTransactionEventListener {
@Override
public void handleArtifactsChangeTypeEvent(Sender sender, int toArtifactTypeId, final LoadedArtifacts loadedArtifacts) {
@@ -114,24 +116,6 @@ public abstract class AbstractEventArtifactEditor extends AbstractArtifactEditor
}
@Override
- public void handleRelationModifiedEvent(Sender sender, RelationEventType relationEventType, final RelationLink link, Branch branch, String relationType) {
- Displays.ensureInDisplayThread(new Runnable() {
- @Override
- public void run() {
- try {
- Artifact localArtifact = getArtifactFromEditorInput();
- if (link.getArtifactA().equals(localArtifact) || link.getArtifactB().equals(localArtifact)) {
- refreshRelations();
- onDirtied();
- }
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
- }
- });
- }
-
- @Override
public void handleFrameworkTransactionEvent(Sender sender, final FrameworkTransactionData transData) throws OseeCoreException {
Displays.ensureInDisplayThread(new Runnable() {
@Override
@@ -204,16 +188,7 @@ public abstract class AbstractEventArtifactEditor extends AbstractArtifactEditor
@Override
public void handleBranchEvent(Sender sender, final BranchEvent branchEvent) {
- Displays.ensureInDisplayThread(new Runnable() {
- @Override
- public void run() {
- if (branchEvent.getEventType() == BranchEventType.Committed) {
- if (getArtifactFromEditorInput().getBranch().getGuid() == branchEvent.getBranchGuid()) {
- closeEditor();
- }
- }
- }
- });
+ // Handled by ArtifactEditorEventManager
}
@Override
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditor.java
index 4b687b73417..9b28efc527f 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditor.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditor.java
@@ -137,7 +137,7 @@ public class ArtifactEditor extends AbstractEventArtifactEditor {
}
@Override
- protected void closeEditor() {
+ public void closeEditor() {
Displays.ensureInDisplayThread(new Runnable() {
@Override
public void run() {
@@ -147,12 +147,12 @@ public class ArtifactEditor extends AbstractEventArtifactEditor {
}
@Override
- protected void refreshDirtyArtifact() {
+ public void refreshDirtyArtifact() {
Jobs.startJob(new RefreshDirtyArtifactJob());
}
@Override
- protected void refreshRelations() {
+ public void refreshRelations() {
Jobs.startJob(new RefreshRelations());
}
@@ -174,7 +174,7 @@ public class ArtifactEditor extends AbstractEventArtifactEditor {
return formPage;
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Class adapter) {
if (adapter == IActionable.class) {
@@ -284,4 +284,9 @@ public class ArtifactEditor extends AbstractEventArtifactEditor {
}
});
}
+
+ @Override
+ public boolean isDisposed() {
+ return formPage == null || formPage.getPartControl() == null || formPage.getPartControl().isDisposed();
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorEventManager.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorEventManager.java
new file mode 100644
index 00000000000..87828448555
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorEventManager.java
@@ -0,0 +1,151 @@
+/*
+ * Created on Jun 30, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.ui.skynet.artifact.editor;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.event.AccessControlEventType;
+import org.eclipse.osee.framework.skynet.core.event.BranchEventType;
+import org.eclipse.osee.framework.skynet.core.event.IAccessControlEventListener;
+import org.eclipse.osee.framework.skynet.core.event.IBranchEventListener;
+import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
+import org.eclipse.osee.framework.skynet.core.event.Sender;
+import org.eclipse.osee.framework.skynet.core.event2.AccessControlEvent;
+import org.eclipse.osee.framework.skynet.core.event2.ArtifactEvent;
+import org.eclipse.osee.framework.skynet.core.event2.BranchEvent;
+import org.eclipse.osee.framework.skynet.core.event2.artifact.EventBasicGuidArtifact;
+import org.eclipse.osee.framework.skynet.core.event2.artifact.EventModType;
+import org.eclipse.osee.framework.skynet.core.event2.artifact.IArtifactEventListener;
+import org.eclipse.osee.framework.skynet.core.event2.filter.IEventFilter;
+import org.eclipse.osee.framework.ui.plugin.util.Displays;
+import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager;
+
+/**
+ * Common location for event handling for ArtifactExplorers in order to keep number of registrations and processing to a
+ * minimum.
+ *
+ * @author Donald G. Dunne
+ */
+public class ArtifactEditorEventManager implements IArtifactEventListener, IBranchEventListener, IAccessControlEventListener {
+
+ List<IArtifactEditorEventHandler> handlers = new ArrayList<IArtifactEditorEventHandler>();
+ static ArtifactEditorEventManager instance;
+
+ public static void add(IArtifactEditorEventHandler iWorldEventHandler) {
+ if (instance == null) {
+ instance = new ArtifactEditorEventManager();
+ OseeEventManager.addListener(instance);
+ }
+ instance.handlers.add(iWorldEventHandler);
+ }
+
+ public static void remove(IArtifactEditorEventHandler iWorldEventHandler) {
+ if (instance != null) {
+ instance.handlers.remove(iWorldEventHandler);
+ }
+ }
+
+ @Override
+ public List<? extends IEventFilter> getEventFilters() {
+ // Can't filter cause this class handles all artifact explorers which can care about different branches
+ return null;
+ }
+
+ @Override
+ public void handleArtifactEvent(final ArtifactEvent artifactEvent, Sender sender) {
+ for (IArtifactEditorEventHandler handler : new CopyOnWriteArrayList<IArtifactEditorEventHandler>(handlers)) {
+ if (handler.isDisposed()) {
+ handlers.remove(handler);
+ }
+ }
+ System.out.println("ArtifactEditorEventManager: handleArtifactEvent called [" + artifactEvent + "] - sender " + sender + "");
+ final Collection<Artifact> modifiedArts =
+ artifactEvent.getCacheArtifacts(EventModType.Modified, EventModType.Reloaded);
+ final Collection<Artifact> relModifiedArts = artifactEvent.getRelCacheArtifacts();
+ final Collection<EventBasicGuidArtifact> deletedPurgedChangedArts =
+ artifactEvent.get(EventModType.Deleted, EventModType.Purged);
+
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ if (!deletedPurgedChangedArts.isEmpty()) {
+ for (IArtifactEditorEventHandler handler : handlers) {
+ if (!handler.isDisposed() && handler.getArtifactFromEditorInput() != null && deletedPurgedChangedArts.contains(handler.getArtifactFromEditorInput())) {
+ handler.closeEditor();
+ }
+ }
+ }
+ for (IArtifactEditorEventHandler handler : handlers) {
+ if (!handler.isDisposed()) {
+ if (handler.getArtifactFromEditorInput() != null && modifiedArts.contains(handler.getArtifactFromEditorInput())) {
+ handler.refreshDirtyArtifact();
+ }
+
+ if (handler.getArtifactFromEditorInput() != null && relModifiedArts.contains(handler.getArtifactFromEditorInput())) {
+ handler.refreshRelations();
+ handler.getEditor().onDirtied();
+ }
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * Not used by REM2; remove when REM1 removed
+ */
+ @Override
+ public void handleBranchEventREM1(Sender sender, final BranchEventType branchModType, final int branchId) {
+ }
+
+ @Override
+ public void handleBranchEvent(Sender sender, final BranchEvent branchEvent) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ for (IArtifactEditorEventHandler handler : handlers) {
+ if (!handler.isDisposed()) {
+ if (branchEvent.getEventType() == BranchEventType.Committed) {
+ if (handler.getArtifactFromEditorInput().getBranch().getGuid() == branchEvent.getBranchGuid()) {
+ handler.closeEditor();
+ }
+ }
+ }
+ }
+ }
+ });
+ }
+
+ @Override
+ public void handleLocalBranchToArtifactCacheUpdateEvent(Sender sender) {
+ }
+
+ @Override
+ public void handleAccessControlArtifactsEvent(Sender sender, AccessControlEvent accessControlEvent) {
+ try {
+ if (accessControlEvent.getEventType() == AccessControlEventType.ArtifactsLocked || accessControlEvent.getEventType() == AccessControlEventType.ArtifactsUnlocked) {
+ for (final IArtifactEditorEventHandler handler : handlers) {
+ if (!handler.isDisposed()) {
+ if (accessControlEvent.getArtifacts().contains(handler.getArtifactFromEditorInput())) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ handler.setMainImage(ArtifactImageManager.getImage(handler.getArtifactFromEditorInput()));
+ }
+ });
+ }
+ }
+ }
+ }
+ } catch (Exception ex) {
+ // do nothing
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/IArtifactEditorEventHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/IArtifactEditorEventHandler.java
new file mode 100644
index 00000000000..24b30587811
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/IArtifactEditorEventHandler.java
@@ -0,0 +1,30 @@
+/*
+ * Created on Jun 30, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.ui.skynet.artifact.editor;
+
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @author Donald G. Dunne
+ */
+public interface IArtifactEditorEventHandler {
+
+ public AbstractEventArtifactEditor getEditor();
+
+ public boolean isDisposed();
+
+ public void refreshDirtyArtifact();
+
+ public void closeEditor();
+
+ public void refreshRelations();
+
+ public Artifact getArtifactFromEditorInput();
+
+ public void setMainImage(Image titleImage);
+
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/revert/RevertWizardPage.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/revert/RevertWizardPage.java
index cdd86163574..6afd871f60c 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/revert/RevertWizardPage.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/revert/RevertWizardPage.java
@@ -14,29 +14,16 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.osee.framework.core.enums.RelationSide;
-import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.plugin.core.util.Jobs;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.event.IRelationModifiedEventListener;
-import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
-import org.eclipse.osee.framework.skynet.core.event.Sender;
-import org.eclipse.osee.framework.skynet.core.relation.RelationEventType;
-import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
import org.eclipse.osee.framework.ui.skynet.ArtifactDoubleClick;
-import org.eclipse.osee.framework.ui.skynet.ArtifactExplorer;
import org.eclipse.osee.framework.ui.skynet.commandHandlers.RevertJob;
-import org.eclipse.osee.framework.ui.skynet.util.SkynetDragAndDrop;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.custom.TreeEditor;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -50,7 +37,7 @@ import org.eclipse.swt.widgets.Tree;
/**
* @author Theron Virgin
*/
-public class RevertWizardPage extends WizardPage implements IRelationModifiedEventListener {
+public class RevertWizardPage extends WizardPage {
private final List<List<Artifact>> artifacts;
public static final String VIEW_ID = "org.eclipse.osee.framework.ui.skynet.revert.RevertWizardPage";
@@ -97,10 +84,6 @@ public class RevertWizardPage extends WizardPage implements IRelationModifiedEve
}
};
- /**
- * @param pageName
- */
-
public RevertWizardPage(List<List<Artifact>> artifacts) {
super(TITLE);
this.artifacts = artifacts;
@@ -158,8 +141,6 @@ public class RevertWizardPage extends WizardPage implements IRelationModifiedEve
stackComposite.layout();
stackComposite.getParent().layout();
- new RevertDragAndDrop(tree, ArtifactExplorer.VIEW_ID);
-
gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.heightHint = 200;
gridData.widthHint = 75;
@@ -173,7 +154,6 @@ public class RevertWizardPage extends WizardPage implements IRelationModifiedEve
artifactSelectionBox.select(0);
setControl(parent);
- OseeEventManager.addListener(this);
}
private Button createButton(String text, String tooltip, Composite composite) {
@@ -189,65 +169,7 @@ public class RevertWizardPage extends WizardPage implements IRelationModifiedEve
}
public boolean closingPage() {
- OseeEventManager.removeListener(this);
return true;
}
- private class RevertDragAndDrop extends SkynetDragAndDrop {
-
- public RevertDragAndDrop(Tree tree, String viewId) {
- super(tree, tree, viewId);
- }
-
- @Override
- public Artifact[] getArtifacts() {
- IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
- Object[] objects = selection.toArray();
- Artifact[] artifacts = new Artifact[objects.length];
-
- for (int index = 0; index < objects.length; index++) {
- artifacts[index] = (Artifact) objects[index];
- }
-
- return artifacts;
- }
-
- @Override
- public void performDragOver(DropTargetEvent event) {
- event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND;
-
- if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) {
- event.detail = DND.DROP_COPY;
- } else if (isValidForArtifactDrop(event)) {
- event.detail = DND.DROP_MOVE;
- } else {
- event.detail = DND.DROP_NONE;
- }
- }
-
- private boolean isValidForArtifactDrop(DropTargetEvent event) {
- return false;
- }
- }
-
- @Override
- public void handleRelationModifiedEvent(Sender sender, RelationEventType relationEventType, RelationLink link, Branch branch, String relationType) {
- // Since this is always a local event, artifact will always be in cache
- try {
- Artifact aArtifact = link.getArtifactIfLoaded(RelationSide.SIDE_A);
- if (aArtifact != null) {
- treeViewer.refresh(aArtifact);
- }
- } catch (Exception ex) {
- //Ignore and hide
- }
- try {
- Artifact bArtifact = link.getArtifactIfLoaded(RelationSide.SIDE_B);
- if (bArtifact != null) {
- treeViewer.refresh(bArtifact);
- }
- } catch (Exception ex) {
- //Ignore and hide
- }
- }
}

Back to the top