19 package org.sleuthkit.autopsy.communications;
21 import com.google.common.collect.ImmutableSet;
22 import com.google.common.eventbus.EventBus;
23 import com.mxgraph.model.mxCell;
24 import java.util.Collection;
25 import java.util.HashSet;
33 final class LockedVertexModel {
35 private final EventBus eventBus =
new EventBus();
42 private final Set<mxCell> lockedVertices =
new HashSet<>();
44 void registerhandler(Object handler) {
45 eventBus.register(handler);
48 void unregisterhandler(Object handler) {
49 eventBus.unregister(handler);
58 void lock(Collection<mxCell> vertices) {
59 lockedVertices.addAll(vertices);
60 eventBus.post(
new VertexLockEvent(
true, vertices));
69 void unlock(Collection<mxCell> vertices) {
70 lockedVertices.removeAll(vertices);
71 eventBus.post(
new VertexLockEvent(
false, vertices));
74 boolean isVertexLocked(mxCell vertex) {
75 return lockedVertices.contains(vertex);
80 lockedVertices.clear();
84 return lockedVertices.isEmpty();
91 final static class VertexLockEvent {
93 private final boolean locked;
94 private final Set<mxCell> vertices;
99 public Set<mxCell> getVertices() {
107 public boolean isLocked() {
111 VertexLockEvent(
boolean locked, Collection< mxCell> vertices) {
112 this.vertices = ImmutableSet.copyOf(vertices);
113 this.locked = locked;