Autopsy  4.20.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
LockedVertexModel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2018 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.communications;
20 
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;
26 import java.util.Set;
27 
33 final class LockedVertexModel {
34 
35  private final EventBus eventBus = new EventBus();
36 
42  private final Set<mxCell> lockedVertices = new HashSet<>();
43 
44  void registerhandler(Object handler) {
45  eventBus.register(handler);
46  }
47 
48  void unregisterhandler(Object handler) {
49  eventBus.unregister(handler);
50  }
51 
58  void lock(Collection<mxCell> vertices) {
59  lockedVertices.addAll(vertices);
60  eventBus.post(new VertexLockEvent(true, vertices));
61  }
62 
69  void unlock(Collection<mxCell> vertices) {
70  lockedVertices.removeAll(vertices);
71  eventBus.post(new VertexLockEvent(false, vertices));
72  }
73 
74  boolean isVertexLocked(mxCell vertex) {
75  return lockedVertices.contains(vertex);
76 
77  }
78 
79  void clear() {
80  lockedVertices.clear();
81  }
82 
83  boolean isEmpty() {
84  return lockedVertices.isEmpty();
85  }
86 
91  final static class VertexLockEvent {
92 
93  private final boolean locked;
94  private final Set<mxCell> vertices;
95 
99  public Set<mxCell> getVertices() {
100  return vertices;
101  }
102 
107  public boolean isLocked() {
108  return locked;
109  }
110 
111  VertexLockEvent(boolean locked, Collection< mxCell> vertices) {
112  this.vertices = ImmutableSet.copyOf(vertices);
113  this.locked = locked;
114  }
115  }
116 }

Copyright © 2012-2022 Basis Technology. Generated on: Tue Aug 1 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.