util/MiniTextControler.py
author Laurent Bessard
Thu, 15 Nov 2012 23:00:53 +0100
changeset 883 235a9ec83b95
parent 806 abf1afc1f04d
child 1347 533741e5075c
permissions -rw-r--r--
Adding support for defining specific global variables for ConfTreeNodes
Fix bug when defining function block instances as global variables
14
eb9fdd316a40 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
     1
"""
725
31dade089db5 refactoring
Edouard Tisserant
parents: 722
diff changeset
     2
Minimal tab controller for a simple text editor
14
eb9fdd316a40 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
     3
"""
eb9fdd316a40 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
     4
725
31dade089db5 refactoring
Edouard Tisserant
parents: 722
diff changeset
     5
import os
14
eb9fdd316a40 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
     6
65
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
     7
class MiniTextControler:
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
     8
    
806
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
     9
    def __init__(self, filepath, controller):
65
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    10
        self.FilePath = filepath
806
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
    11
        self.BaseController = controller
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
    12
    
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
    13
    def __del__(self):
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
    14
        self.BaseController = None
716
180e4a7d945c Adding search field for finding function or function block in library tree
laurent
parents: 715
diff changeset
    15
    
718
5d4dc150b956 refactoring
Edouard Tisserant
parents: 717
diff changeset
    16
    def CTNFullName(self):
716
180e4a7d945c Adding search field for finding function or function block in library tree
laurent
parents: 715
diff changeset
    17
        return ""
180e4a7d945c Adding search field for finding function or function block in library tree
laurent
parents: 715
diff changeset
    18
    
74
8a726a62fbfc Some bugs fixed
lbessard
parents: 66
diff changeset
    19
    def SetEditedElementText(self, tagname, text):
65
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    20
        file = open(self.FilePath, "w")
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    21
        file.write(text)
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    22
        file.close()
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    23
        
273
d15a20eb2b8b Bug with debug mode when displaying code fixed
greg
parents: 256
diff changeset
    24
    def GetEditedElementText(self, tagname, debug = False):
65
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    25
        if os.path.isfile(self.FilePath):
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    26
            file = open(self.FilePath, "r")
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    27
            text = file.read()
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    28
            file.close()
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    29
            return text
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    30
        return ""
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    31
    
273
d15a20eb2b8b Bug with debug mode when displaying code fixed
greg
parents: 256
diff changeset
    32
    def GetEditedElementInterfaceVars(self, tagname, debug = False):
74
8a726a62fbfc Some bugs fixed
lbessard
parents: 66
diff changeset
    33
        return []
8a726a62fbfc Some bugs fixed
lbessard
parents: 66
diff changeset
    34
    
273
d15a20eb2b8b Bug with debug mode when displaying code fixed
greg
parents: 256
diff changeset
    35
    def GetEditedElementType(self, tagname, debug = False):
74
8a726a62fbfc Some bugs fixed
lbessard
parents: 66
diff changeset
    36
        return "program"
8a726a62fbfc Some bugs fixed
lbessard
parents: 66
diff changeset
    37
    
806
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
    38
    def GetBlockType(self, type, inputs = None, debug = False):
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
    39
        return self.BaseController.GetBlockType(type, inputs, debug)
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
    40
    
273
d15a20eb2b8b Bug with debug mode when displaying code fixed
greg
parents: 256
diff changeset
    41
    def GetBlockTypes(self, tagname = "", debug = False):
806
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
    42
        return self.BaseController.GetBlockTypes(tagname, debug)
74
8a726a62fbfc Some bugs fixed
lbessard
parents: 66
diff changeset
    43
    
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 624
diff changeset
    44
    def GetDataTypes(self, tagname = "", basetypes = True, only_locatables = False, debug = False):
806
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
    45
        return self.BaseController.GetDataTypes(tagname, basetypes, only_locatables, debug)
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 624
diff changeset
    46
    
273
d15a20eb2b8b Bug with debug mode when displaying code fixed
greg
parents: 256
diff changeset
    47
    def GetEnumeratedDataValues(self, debug = False):
806
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
    48
        return self.BaseController.GetEnumeratedDataValues(debug)
74
8a726a62fbfc Some bugs fixed
lbessard
parents: 66
diff changeset
    49
    
65
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    50
    def StartBuffering(self):
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    51
        pass
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    52
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    53
    def EndBuffering(self):
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    54
        pass
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    55
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    56
    def BufferProject(self):
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    57
        pass
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    58