PyutDocument.py :  » UML » Python-UML-Tool » pyut-1.4.0 » src » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » UML » Python UML Tool 
Python UML Tool » pyut 1.4.0 » src » PyutDocument.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

__version__ = "$Revision: 1.8 $"
__author__  = "EI6, eivd, Group Dutoit - Roux"
__date__    = "2002-03-14"
__PyUtVersion__ = "1.0"
# local TODO :
# - do more tests
# - add shortcuts (appframe.py)

#from wxPython.wx import *
#import wx
from UmlClassDiagramsFrame import UmlClassDiagramsFrame
from UmlSequenceDiagramsFrame import UmlSequenceDiagramsFrame
from AppFrame import *
from pyutUtils import displayError
from PyutConsts import *


#>-----------------------------------------------------------------------

def shorterFilename(filename):
    """
    Return a shorter filename to display

    @param filename file name to display
    @return String better file name
    @since 1.0
    @author C.Dutoit <dutoitc@hotmail.com>
    """
    import os
    return os.path.split(filename)[1]


##############################################################################

class PyutDocument:
    """
    Document : Contain a document : frames, properties, ...

    :author: C.Dutoit 
    :contact: <dutoitc@hotmail.com>
    :version: $Revision: 1.8 $
    """

    #>------------------------------------------------------------------------

    def __init__(self, parentFrame, project, type):
        """
        Constructor.

        @param type : Type of document; one cited in PyutConsts.py
        @author C.Dutoit
        """
        self._parentFrame = None
        self._project = project
        self._treeRoot = None      # Root of the project entry in the tree
        self._treeRootParent = None# Parent of the project root entry
        self._tree     = None      # Tree i'm belonging to
        self._type     = type

        print "PyutDocument using type " , type
        if (type==CLASS_DIAGRAM):
            self._title = DiagramsLabels[type]
            self._frame = UmlClassDiagramsFrame(parentFrame)
        elif (type==SEQUENCE_DIAGRAM):
            self._title = DiagramsLabels[type]
            self._frame = UmlSequenceDiagramsFrame(parentFrame)
        elif (type==USECASE_DIAGRAM):
            self._title = DiagramsLabels[type]
            self._frame = UmlClassDiagramsFrame(parentFrame)
        else:
            displayError("Unsuported diagram type; replacing by class diagram")
            self._title = DiagramsLabels[CLASS_DIAGRAM]
            self._frame = UmlClassDiagramsFrame(parentFrame)


    #>------------------------------------------------------------------------

    def getType(self):
        """
        Return the document's type

        @author C.Dutoit
        @return String : the document's type as string
        """
        return self._type
    
    #>------------------------------------------------------------------------

    def getDiagramTitle(self):
        """
        Return the filename for captions

        @author C.Dutoit
        @return String : the caption
        """
        return self._project.getFilename() + "/" + self._title

    #>------------------------------------------------------------------------

    def getFrame(self):
        """
        Return the document's frame

        @author C.Dutoit
        @return xxxFrame this document's frame
        """
        return self._frame

    #>------------------------------------------------------------------------

    def addToTree(self, tree, root):
        self._tree = tree
        self._treeRootParent = root
        # Add the project to the project tree
        self._treeRoot = tree.AppendItem(
                         self._treeRootParent, 
                         self._title)
        #self._tree.Expand(self._treeRoot)
        self._tree.SetPyData(self._treeRoot, self._frame)

    #>------------------------------------------------------------------------
    
    def updateTreeText(self):
        """
        Update the tree text for this document

        @author C.Dutoit
        """
        self._tree.SetItemText(self._treeRoot, self._title)

    #>------------------------------------------------------------------------

    def removeFromTree(self):
        """
        Remove this document.
        """
        # Remove from tree
        self._tree.Delete(self._treeRoot)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.