readded the delete window command
This commit is contained in:
@@ -50,14 +50,7 @@ func (lc *LayoutController) registerHooks() {
|
||||
lc.newWindowAction()
|
||||
case 'x':
|
||||
lc.Messages <- "calling delete window\n"
|
||||
// Delete selected window
|
||||
// bus.Emit(ui.LogEv{Log: })
|
||||
// wRef, err := getCurNodeRef(tree)
|
||||
// if err != nil {
|
||||
// bus.Emit(ui.LogEv{Log: " -> " + err.Error()})
|
||||
// break
|
||||
// }
|
||||
// bus.Emit(ui.DestroyWindowEv{ID: wRef.ID})
|
||||
lc.deleteWindow()
|
||||
case 'm':
|
||||
lc.Messages <- "calling window manipulation tool\n"
|
||||
// Go into move mode
|
||||
@@ -331,3 +324,27 @@ func (lc *LayoutController) saveLayout() {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// deleteWindow will delete the currently highlighted window in the layoutTree
|
||||
// - get the currently highlighted element
|
||||
// - tell the LayoutToolView too delete it
|
||||
func (lc *LayoutController) deleteWindow() {
|
||||
// Delete the window first
|
||||
// Get the selected node info
|
||||
curNode := lc.LayoutToolView.LayoutTree.Tree.GetCurrentNode()
|
||||
if curNode == nil {
|
||||
lc.Messages <- "couldn't get a hold of currently selected node\n"
|
||||
return
|
||||
}
|
||||
win := curNode.GetReference().(*models.UIWindow)
|
||||
|
||||
// Delete it
|
||||
err := lc.DevService.DeleteWindow(win.WID)
|
||||
if err != nil {
|
||||
lc.Messages <- "failed to delete window: " + err.Error() + "\n"
|
||||
return
|
||||
}
|
||||
|
||||
// Reflect the deletion in the view
|
||||
lc.LayoutToolView.DeleteWindowByNode(curNode)
|
||||
}
|
||||
|
||||
@@ -60,3 +60,7 @@ func (cds *CDashService) SaveLayout(layoutPath string) error {
|
||||
func (cds *CDashService) UpdateWindow(idx int16, win *cdashdisplay.UIWindow) error {
|
||||
return cds.CDash.UpdateWindow(idx, win)
|
||||
}
|
||||
|
||||
func (cds *CDashService) DeleteWindow(idx int16) error {
|
||||
return cds.CDash.DestroyWindow(idx)
|
||||
}
|
||||
|
||||
@@ -249,3 +249,18 @@ func (ltv *LayoutToolView) ShowWindowFormByID(idx int16) {
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
func (ltv *LayoutToolView) DeleteWindowByNode(node *tview.TreeNode) {
|
||||
root := ltv.LayoutTree.Tree.GetRoot()
|
||||
if root == nil {
|
||||
// We should do something I guess
|
||||
return
|
||||
}
|
||||
|
||||
root.RemoveChild(node)
|
||||
|
||||
// We have to delete it from the map
|
||||
// This isn't very safe now is it?
|
||||
delete(ltv.FormQuickAccess, node.GetReference().(*models.UIWindow).WID)
|
||||
// Did we delete everything ???
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user