disable delete, copy, paste during runtime

This commit is contained in:
Huy Pham 2020-02-24 11:17:06 -08:00
parent ddaba7c477
commit 1dca477e6d
2 changed files with 9 additions and 3 deletions

View file

@ -1064,3 +1064,6 @@ class CoreClient:
def service_been_modified(self, node_id: int) -> bool:
return node_id in self.modified_service_nodes
def is_runtime_state(self):
return self.state == core_pb2.SessionState.RUNTIME

View file

@ -656,8 +656,11 @@ class CanvasGraph(tk.Canvas):
delete selected nodes and any data that relates to it
"""
logging.debug("press delete key")
if not self.app.core.is_runtime_state():
nodes = self.delete_selection_objects()
self.core.delete_graph_nodes(nodes)
else:
logging.debug("node deletion is disabled during runtime")
def double_click(self, event: tk.Event):
selected = self.get_selected(event)
@ -850,7 +853,7 @@ class CanvasGraph(tk.Canvas):
self.core.create_link(edge, source, dest)
def copy(self):
if self.selection:
if self.selection and not self.app.core.is_runtime_state():
logging.debug("to copy %s nodes", len(self.selection))
self.to_copy = self.selection.keys()