Copyright : (c) Uni Bremen 2003-2007
Maintainer : raider@informatik.uni-bremen.de
Portability : non-portable
This Modul provides a function to display a Library Dependency Graph.
type NodeEdgeList = ([DaVinciNode LibName], [DaVinciArc (IO String)])
{- | Creates a new uDrawGraph Window and shows the Library Dependency Graph of
showLibGraph gInfo@(GInfo { windowCount = wc
, libGraphLock = lock}) = do
isEmpty <- isEmptyMVar lock
graph <- newIORef daVinciSort
nodesEdges <- newIORef (([], []) :: NodeEdgeList)
[ Button "Reload Library" $ reloadLibGraph gInfo graph nodesEdges
, Button "Translate Library" $ translate gInfo
, Button "Show Logic Graph" $ showLogicGraph daVinciSort
graphParms = globalMenu $$
GraphTitle "Library Graph" $$
AllowClose (closeGInfo gInfo) $$
FileMenuAct ExitMenuOption (Just (exitGInfo gInfo)) $$
graph' <- newGraph daVinciSort graphParms
addNodesAndEdges gInfo graph' nodesEdges
-- | Reloads all Libraries and the Library Dependency Graph
reloadLibGraph :: GInfo -> IORef DaVinciGraphTypeSyn -> IORef NodeEdgeList
reloadLibGraph gInfo graph nodesEdges = do
b <- warningDialog "Reload library" warnTxt
when b $ reloadLibGraph' gInfo graph nodesEdges
[ "Are you sure to recreate Library?"
, "All development graph windows will be closed and proofs will be lost."
, "", "This operation can not be undone." ]
-- | Reloads all Libraries and the Library Dependency Graph
reloadLibGraph' :: GInfo -> IORef DaVinciGraphTypeSyn -> IORef NodeEdgeList
reloadLibGraph' gInfo@(GInfo { hetcatsOpts = opts
, libName = ln }) graph nodesEdges = do
graph' <- readIORef graph
(nodes, edges) <- readIORef nodesEdges
let libfile = libNameToFile ln
m <- anaLib opts { outtypes = [] } libfile
Nothing -> errorDialog "Error" $ "Error when reloading file '"
mapM_ (deleteArc graph') edges
mapM_ (deleteNode graph') nodes
addNodesAndEdges gInfo graph' nodesEdges
nwst = case i_state ost of
Just ist -> ost { i_state = Just $ ist { i_libEnv = le
writeIORef (intState gInfo) nwst
translate :: GInfo -> IO ()
b <- warningDialog "Translate library" warnTxt
when b $ translate' gInfo
translate' :: GInfo -> IO ()
translate' gInfo@(GInfo { libName = ln }) = do
mle <- translateGraph gInfo
nwst = case i_state ost of
Just ist -> ost { i_state = Just $ ist { i_libEnv = le
, filename = libNameToFile ln }
writeIORef (intState gInfo) nwst
-- | Reloads the open graphs
closeOpenWindows :: GInfo -> IO ()
closeOpenWindows (GInfo { openGraphs = iorOpenGrpahs
, windowCount = wCount }) = do
oGrpahs <- readIORef iorOpenGrpahs
-- | Adds the Librarys and the Dependencies to the Graph
addNodesAndEdges :: GInfo -> DaVinciGraphTypeSyn -> IORef NodeEdgeList -> IO ()
addNodesAndEdges gInfo@(GInfo { hetcatsOpts = opts}) graph nodesEdges = do
ost <- readIORef $ intState gInfo
subNodeMenu = LocalMenu (
UDG.Menu Nothing [
Button "Show Graph" $ mShowGraph gInfo,
Button "Show
spec/View Names" $ showSpec le])
subNodeTypeParms = subNodeMenu $$$
ValueTitle (return . show) $$$
Color (getColor opts Green True True) $$$
subNodeType <- newNodeType graph subNodeTypeParms
subNodeList <- mapM (newNode graph subNodeType) keys
subArcMenu = LocalMenu (
UDG.Menu Nothing [])
subArcTypeParms = subArcMenu $$$
Color (getColor opts Black False False) $$$
subArcType <- newArcType graph subArcTypeParms
let insertSubArc (node1, node2) = newArc graph subArcType (return "")
subArcList <- mapM insertSubArc $ getLibDeps le
writeIORef nodesEdges (subNodeList, subArcList)
-- | Creates a list of all LibName pairs, which have a dependency
getLibDeps :: LibEnv -> [(LibName, LibName)]
mShowGraph :: GInfo -> LibName -> IO ()
mShowGraph gInfo@(GInfo {hetcatsOpts = opts}) ln = do
putIfVerbose opts 3 "Converting Graph"
gInfo' <- copyGInfo gInfo ln
convertGraph gInfo' "Development Graph" showLibGraph
let gi = graphInfo gInfo'
-- | Displays the Specs of a Library in a Textwindow
showSpec :: LibEnv -> LibName -> IO ()
createTextDisplay ("Contents of " ++ show ln)
$ unlines . map show .
Map.keys . globalEnv