objdictgen/objdictedit.py
author greg
Wed, 16 Sep 2009 15:19:58 +0200
changeset 592 b98df76c6fd5
parent 580 2ae92a99ac10
child 608 daa1e1c3fba4
permissions -rwxr-xr-x
fix warnings with msvc compiler
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     1
#!/usr/bin/env python
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     3
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     4
#This file is part of CanFestival, a library implementing CanOpen Stack. 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     5
#
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     6
#Copyright (C): Edouard TISSERANT, Francis DUPIN and Laurent BESSARD
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     7
#
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     8
#See COPYING file for copyrights details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     9
#
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    10
#This library is free software; you can redistribute it and/or
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    11
#modify it under the terms of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    12
#License as published by the Free Software Foundation; either
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    13
#version 2.1 of the License, or (at your option) any later version.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    14
#
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    15
#This library is distributed in the hope that it will be useful,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    16
#but WITHOUT ANY WARRANTY; without even the implied warranty of
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    17
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    18
#Lesser General Public License for more details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    19
#
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    20
#You should have received a copy of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    21
#License along with this library; if not, write to the Free Software
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    22
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    23
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    24
import wx
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    25
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    26
from types import *
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    27
import os, re, platform, sys, time, traceback, getopt
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    28
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    29
__version__ = "$Revision: 1.48 $"
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    30
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    31
if __name__ == '__main__':
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    32
    def usage():
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    33
        print _("\nUsage of objdictedit.py :")
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    34
        print "\n   %s [Filepath, ...]\n"%sys.argv[0]
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    35
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    36
    try:
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    37
        opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    38
    except getopt.GetoptError:
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    39
        # print help information and exit:
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    40
        usage()
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    41
        sys.exit(2)
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    42
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    43
    for o, a in opts:
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    44
        if o in ("-h", "--help"):
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    45
            usage()
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    46
            sys.exit()
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    47
    
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    48
    app = wx.PySimpleApp()
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    49
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    50
ScriptDirectory = os.path.split(os.path.realpath(__file__))[0]
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    51
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    52
# Import module for internationalization
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    53
import gettext
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    54
import __builtin__
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    55
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    56
# Get folder containing translation files
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    57
localedir = os.path.join(ScriptDirectory,"locale")
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    58
# Get the default language
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    59
langid = wx.LANGUAGE_DEFAULT
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    60
# Define translation domain (name of translation files)
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    61
domain = "objdictgen"
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    62
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    63
# Define locale for wx
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    64
loc = __builtin__.__dict__.get('loc', None)
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    65
if loc is None:
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    66
    loc = wx.Locale(langid)
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    67
    __builtin__.__dict__['loc'] = loc
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    68
# Define location for searching translation files
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    69
loc.AddCatalogLookupPathPrefix(localedir)
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    70
# Define locale domain
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    71
loc.AddCatalog(domain)
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    72
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    73
if __name__ == '__main__':
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
    74
    __builtin__.__dict__['_'] = wx.GetTranslation
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    75
206
6787754b251b Bugs corrected on objdictedit and networkdict
greg
parents: 205
diff changeset
    76
from node import OD_Subindex, OD_MultipleSubindexes, OD_IdenticalSubindexes, OD_IdenticalIndexes
6787754b251b Bugs corrected on objdictedit and networkdict
greg
parents: 205
diff changeset
    77
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    78
from nodemanager import *
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
    79
from subindextable import *
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
    80
from commondialogs import *
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    81
from doc_index.DS301_index import *
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    82
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    83
try:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    84
    import wx.html
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    85
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    86
    EVT_HTML_URL_CLICK = wx.NewId()
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    87
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    88
    class HtmlWindowUrlClick(wx.PyEvent):
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    89
        def __init__(self, linkinfo):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    90
            wx.PyEvent.__init__(self)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    91
            self.SetEventType(EVT_HTML_URL_CLICK)
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    92
            self.linkinfo = (linkinfo.GetHref(), linkinfo.GetTarget())
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    93
            
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    94
    class UrlClickHtmlWindow(wx.html.HtmlWindow):
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    95
        """ HTML window that generates and OnLinkClicked event.
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    96
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    97
        Use this to avoid having to override HTMLWindow
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    98
        """
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    99
        def OnLinkClicked(self, linkinfo):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   100
            wx.PostEvent(self, HtmlWindowUrlClick(linkinfo))
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   101
        
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   102
        def Bind(self, event, handler, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   103
            if event == HtmlWindowUrlClick:
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   104
                self.Connect(-1, -1, EVT_HTML_URL_CLICK, handler)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   105
            else:
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   106
                wx.html.HtmlWindow.Bind(event, handler, source=source, id=id, id2=id2)
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   107
    
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   108
#-------------------------------------------------------------------------------
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   109
#                                Html Frame
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   110
#-------------------------------------------------------------------------------
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   111
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   112
    [ID_HTMLFRAME, ID_HTMLFRAMEHTMLCONTENT] = [wx.NewId() for _init_ctrls in range(2)]
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   113
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   114
    class HtmlFrame(wx.Frame):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   115
        def _init_ctrls(self, prnt):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   116
            wx.Frame.__init__(self, id=ID_HTMLFRAME, name='HtmlFrame',
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   117
                  parent=prnt, pos=wx.Point(320, 231), size=wx.Size(853, 616),
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   118
                  style=wx.DEFAULT_FRAME_STYLE, title='')
273
58b39f97e352 Some bugs fixed
lbessard
parents: 258
diff changeset
   119
            self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   120
            
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   121
            self.HtmlContent = UrlClickHtmlWindow(id=ID_HTMLFRAMEHTMLCONTENT,
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   122
                  name='HtmlContent', parent=self, pos=wx.Point(0, 0),
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   123
                  size=wx.Size(-1, -1), style=wx.html.HW_SCROLLBAR_AUTO|wx.html.HW_NO_SELECTION)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   124
            self.HtmlContent.Bind(HtmlWindowUrlClick, self.OnLinkClick)
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   125
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   126
        def __init__(self, parent, opened):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   127
            self._init_ctrls(parent)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   128
            self.HtmlFrameOpened = opened
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   129
        
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   130
        def SetHtmlCode(self, htmlcode):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   131
            self.HtmlContent.SetPage(htmlcode)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   132
            
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   133
        def SetHtmlPage(self, htmlpage):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   134
            self.HtmlContent.LoadPage(htmlpage)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   135
            
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   136
        def OnCloseFrame(self, event):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   137
            self.HtmlFrameOpened.remove(self.GetTitle())
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   138
            event.Skip()
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   139
        
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   140
        def OnLinkClick(self, event):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   141
            url = event.linkinfo[0]
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   142
            try:
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   143
                import webbrowser
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   144
            except ImportError:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   145
                wx.MessageBox(_('Please point your browser at: %s') % url)
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   146
            else:
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   147
                webbrowser.open(url)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   148
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   149
    Html_Window = True
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   150
except:
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   151
    Html_Window = False
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   152
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   153
[ID_OBJDICTEDIT, ID_OBJDICTEDITFILEOPENED, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   154
 ID_OBJDICTEDITHELPBAR,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   155
] = [wx.NewId() for _init_ctrls in range(3)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   156
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   157
[ID_OBJDICTEDITFILEMENUIMPORTEDS, ID_OBJDICTEDITFILEMENUEXPORTEDS, 
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   158
 ID_OBJDICTEDITFILEMENUEXPORTC,
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   159
] = [wx.NewId() for _init_coll_FileMenu_Items in range(3)]
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   160
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   161
[ID_OBJDICTEDITEDITMENUNODEINFOS, ID_OBJDICTEDITEDITMENUDS301PROFILE, 
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   162
 ID_OBJDICTEDITEDITMENUDS302PROFILE, ID_OBJDICTEDITEDITMENUOTHERPROFILE, 
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   163
] = [wx.NewId() for _init_coll_EditMenu_Items in range(4)]
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   164
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   165
[ID_OBJDICTEDITADDMENUSDOSERVER, ID_OBJDICTEDITADDMENUSDOCLIENT, 
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   166
 ID_OBJDICTEDITADDMENUPDOTRANSMIT, ID_OBJDICTEDITADDMENUPDORECEIVE, 
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   167
 ID_OBJDICTEDITADDMENUMAPVARIABLE, ID_OBJDICTEDITADDMENUUSERTYPE, 
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   168
] = [wx.NewId() for _init_coll_AddMenu_Items in range(6)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   169
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   170
class objdictedit(wx.Frame):
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   171
    def _init_coll_MenuBar_Menus(self, parent):
485
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   172
        if self.ModeSolo:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   173
            parent.Append(menu=self.FileMenu, title=_('File'))
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   174
        parent.Append(menu=self.EditMenu, title=_('Edit'))
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   175
        parent.Append(menu=self.AddMenu, title=_('Add'))
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   176
        parent.Append(menu=self.HelpMenu, title=_('Help'))
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   177
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   178
    def _init_coll_FileMenu_Items(self, parent):
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   179
        parent.Append(help='', id=wx.ID_NEW,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   180
              kind=wx.ITEM_NORMAL, text=_('New\tCTRL+N'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   181
        parent.Append(help='', id=wx.ID_OPEN,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   182
              kind=wx.ITEM_NORMAL, text=_('Open\tCTRL+O'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   183
        parent.Append(help='', id=wx.ID_CLOSE,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   184
              kind=wx.ITEM_NORMAL, text=_('Close\tCTRL+W'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   185
        parent.AppendSeparator()
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   186
        parent.Append(help='', id=wx.ID_SAVE,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   187
              kind=wx.ITEM_NORMAL, text=_('Save\tCTRL+S'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   188
        parent.Append(help='', id=wx.ID_SAVEAS,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   189
              kind=wx.ITEM_NORMAL, text=_('Save As...\tALT+S'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   190
        parent.AppendSeparator()
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   191
        parent.Append(help='', id=ID_OBJDICTEDITFILEMENUIMPORTEDS,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   192
              kind=wx.ITEM_NORMAL, text=_('Import EDS file'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   193
        parent.Append(help='', id=ID_OBJDICTEDITFILEMENUEXPORTEDS,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   194
              kind=wx.ITEM_NORMAL, text=_('Export to EDS file'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   195
        parent.Append(help='', id=ID_OBJDICTEDITFILEMENUEXPORTC,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   196
              kind=wx.ITEM_NORMAL, text=_('Build Dictionary\tCTRL+B'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   197
        parent.AppendSeparator()
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   198
        parent.Append(help='', id=wx.ID_EXIT,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   199
              kind=wx.ITEM_NORMAL, text=_('Exit'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   200
        self.Bind(wx.EVT_MENU, self.OnNewMenu, id=wx.ID_NEW)
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   201
        self.Bind(wx.EVT_MENU, self.OnOpenMenu, id=wx.ID_OPEN)
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   202
        self.Bind(wx.EVT_MENU, self.OnCloseMenu, id=wx.ID_CLOSE)
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   203
        self.Bind(wx.EVT_MENU, self.OnSaveMenu, id=wx.ID_SAVE)
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   204
        self.Bind(wx.EVT_MENU, self.OnSaveAsMenu, id=wx.ID_SAVEAS)
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   205
        self.Bind(wx.EVT_MENU, self.OnImportEDSMenu,
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   206
              id=ID_OBJDICTEDITFILEMENUIMPORTEDS)
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   207
        self.Bind(wx.EVT_MENU, self.OnExportEDSMenu,
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   208
              id=ID_OBJDICTEDITFILEMENUEXPORTEDS)
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   209
        self.Bind(wx.EVT_MENU, self.OnExportCMenu,
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   210
              id=ID_OBJDICTEDITFILEMENUEXPORTC)
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   211
        self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT)
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   212
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   213
    def _init_coll_EditMenu_Items(self, parent):
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   214
        parent.Append(help='', id=wx.ID_REFRESH,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   215
              kind=wx.ITEM_NORMAL, text=_('Refresh\tCTRL+R'))
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   216
        parent.AppendSeparator()
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   217
        parent.Append(help='', id=wx.ID_UNDO,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   218
              kind=wx.ITEM_NORMAL, text=_('Undo\tCTRL+Z'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   219
        parent.Append(help='', id=wx.ID_REDO,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   220
              kind=wx.ITEM_NORMAL, text=_('Redo\tCTRL+Y'))
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   221
        parent.AppendSeparator()
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   222
        parent.Append(help='', id=ID_OBJDICTEDITEDITMENUNODEINFOS,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   223
              kind=wx.ITEM_NORMAL, text=_('Node infos'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   224
        parent.Append(help='', id=ID_OBJDICTEDITEDITMENUDS301PROFILE,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   225
              kind=wx.ITEM_NORMAL, text=_('DS-301 Profile'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   226
        parent.Append(help='', id=ID_OBJDICTEDITEDITMENUDS302PROFILE,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   227
              kind=wx.ITEM_NORMAL, text=_('DS-302 Profile'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   228
        parent.Append(help='', id=ID_OBJDICTEDITEDITMENUOTHERPROFILE,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   229
              kind=wx.ITEM_NORMAL, text=_('Other Profile'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   230
        self.Bind(wx.EVT_MENU, self.OnRefreshMenu, id=wx.ID_REFRESH)
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   231
        self.Bind(wx.EVT_MENU, self.OnUndoMenu, id=wx.ID_UNDO)
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   232
        self.Bind(wx.EVT_MENU, self.OnRedoMenu, id=wx.ID_REDO)
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   233
        self.Bind(wx.EVT_MENU, self.OnNodeInfosMenu,
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   234
              id=ID_OBJDICTEDITEDITMENUNODEINFOS)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   235
        self.Bind(wx.EVT_MENU, self.OnCommunicationMenu,
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   236
              id=ID_OBJDICTEDITEDITMENUDS301PROFILE)
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   237
        self.Bind(wx.EVT_MENU, self.OnOtherCommunicationMenu,
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   238
              id=ID_OBJDICTEDITEDITMENUDS302PROFILE)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   239
        self.Bind(wx.EVT_MENU, self.OnEditProfileMenu,
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   240
              id=ID_OBJDICTEDITEDITMENUOTHERPROFILE)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   241
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   242
    def _init_coll_AddMenu_Items(self, parent):
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   243
        parent.Append(help='', id=ID_OBJDICTEDITADDMENUSDOSERVER,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   244
              kind=wx.ITEM_NORMAL, text=_('SDO Server'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   245
        parent.Append(help='', id=ID_OBJDICTEDITADDMENUSDOCLIENT,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   246
              kind=wx.ITEM_NORMAL, text=_('SDO Client'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   247
        parent.Append(help='', id=ID_OBJDICTEDITADDMENUPDOTRANSMIT,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   248
              kind=wx.ITEM_NORMAL, text=_('PDO Transmit'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   249
        parent.Append(help='', id=ID_OBJDICTEDITADDMENUPDORECEIVE,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   250
              kind=wx.ITEM_NORMAL, text=_('PDO Receive'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   251
        parent.Append(help='', id=ID_OBJDICTEDITADDMENUMAPVARIABLE,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   252
              kind=wx.ITEM_NORMAL, text=_('Map Variable'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   253
        parent.Append(help='', id=ID_OBJDICTEDITADDMENUUSERTYPE,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   254
              kind=wx.ITEM_NORMAL, text=_('User Type'))
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   255
        self.Bind(wx.EVT_MENU, self.OnAddSDOServerMenu,
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   256
              id=ID_OBJDICTEDITADDMENUSDOSERVER)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   257
        self.Bind(wx.EVT_MENU, self.OnAddSDOClientMenu,
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   258
              id=ID_OBJDICTEDITADDMENUSDOCLIENT)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   259
        self.Bind(wx.EVT_MENU, self.OnAddPDOTransmitMenu,
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   260
              id=ID_OBJDICTEDITADDMENUPDOTRANSMIT)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   261
        self.Bind(wx.EVT_MENU, self.OnAddPDOReceiveMenu,
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   262
              id=ID_OBJDICTEDITADDMENUPDORECEIVE)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   263
        self.Bind(wx.EVT_MENU, self.OnAddMapVariableMenu,
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   264
              id=ID_OBJDICTEDITADDMENUMAPVARIABLE)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   265
        self.Bind(wx.EVT_MENU, self.OnAddUserTypeMenu,
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   266
              id=ID_OBJDICTEDITADDMENUUSERTYPE)
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   267
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   268
    def _init_coll_HelpMenu_Items(self, parent):
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   269
        parent.Append(help='', id=wx.ID_HELP,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   270
              kind=wx.ITEM_NORMAL, text=_('DS-301 Standard\tF1'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   271
        self.Bind(wx.EVT_MENU, self.OnHelpDS301Menu, id=wx.ID_HELP)
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   272
        parent.Append(help='', id=wx.ID_HELP_CONTEXT,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   273
              kind=wx.ITEM_NORMAL, text=_('CAN Festival Docs\tF2'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   274
        self.Bind(wx.EVT_MENU, self.OnHelpCANFestivalMenu, id=wx.ID_HELP_CONTEXT)
485
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   275
        if Html_Window and self.ModeSolo:
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   276
            parent.Append(help='', id=wx.ID_ABOUT,
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   277
                  kind=wx.ITEM_NORMAL, text=_('About'))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   278
            self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   279
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   280
    def _init_coll_HelpBar_Fields(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   281
        parent.SetFieldsCount(3)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   282
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   283
        parent.SetStatusText(number=0, text='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   284
        parent.SetStatusText(number=1, text='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   285
        parent.SetStatusText(number=2, text='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   286
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   287
        parent.SetStatusWidths([100, 110, -1])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   288
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   289
    def _init_utils(self):
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   290
        self.MenuBar = wx.MenuBar()
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   291
        self.MenuBar.SetEvtHandlerEnabled(True)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   292
485
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   293
        if self.ModeSolo:
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   294
            self.FileMenu = wx.Menu(title='')
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   295
        self.EditMenu = wx.Menu(title='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   296
        self.AddMenu = wx.Menu(title='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   297
        self.HelpMenu = wx.Menu(title='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   298
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   299
        self._init_coll_MenuBar_Menus(self.MenuBar)
485
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   300
        if self.ModeSolo:
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   301
            self._init_coll_FileMenu_Items(self.FileMenu)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   302
        self._init_coll_EditMenu_Items(self.EditMenu)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   303
        self._init_coll_AddMenu_Items(self.AddMenu)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   304
        self._init_coll_HelpMenu_Items(self.HelpMenu)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   305
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   306
    def _init_ctrls(self, prnt):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   307
        wx.Frame.__init__(self, id=ID_OBJDICTEDIT, name='objdictedit',
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   308
              parent=prnt, pos=wx.Point(149, 178), size=wx.Size(1000, 700),
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   309
              style=wx.DEFAULT_FRAME_STYLE, title=_('Objdictedit'))
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   310
        self._init_utils()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   311
        self.SetClientSize(wx.Size(1000, 700))
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   312
        self.SetMenuBar(self.MenuBar)
273
58b39f97e352 Some bugs fixed
lbessard
parents: 258
diff changeset
   313
        self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
485
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   314
        if not self.ModeSolo:
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   315
            self.Bind(wx.EVT_MENU, self.OnSaveMenu, id=wx.ID_SAVE)
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   316
            accel = wx.AcceleratorTable([wx.AcceleratorEntry(wx.ACCEL_CTRL, 83, wx.ID_SAVE)])
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   317
            self.SetAcceleratorTable(accel)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   318
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   319
        self.FileOpened = wx.Notebook(id=ID_OBJDICTEDITFILEOPENED,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   320
              name='FileOpened', parent=self, pos=wx.Point(0, 0),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   321
              size=wx.Size(0, 0), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   322
        self.FileOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   323
              self.OnFileSelectedChanged, id=ID_OBJDICTEDITFILEOPENED)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   324
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   325
        self.HelpBar = wx.StatusBar(id=ID_OBJDICTEDITHELPBAR, name='HelpBar',
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   326
              parent=self, style=wx.ST_SIZEGRIP)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   327
        self._init_coll_HelpBar_Fields(self.HelpBar)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   328
        self.SetStatusBar(self.HelpBar)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   329
485
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   330
    def __init__(self, parent, manager = None, filesOpen = []):
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   331
        self.ModeSolo = manager == None
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   332
        self._init_ctrls(parent)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   333
        self.HtmlFrameOpened = []
485
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   334
        self.BusId = None
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   335
        self.Closing = False
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   336
        
410
cbed250c4303 .ico icons work with either windows or linux
etisserant
parents: 409
diff changeset
   337
        icon = wx.Icon(os.path.join(ScriptDirectory,"networkedit.ico"),wx.BITMAP_TYPE_ICO)
409
f2920812471e add icon support in init
greg
parents: 408
diff changeset
   338
        self.SetIcon(icon)
f2920812471e add icon support in init
greg
parents: 408
diff changeset
   339
        
485
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   340
        if self.ModeSolo:
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   341
            self.Manager = NodeManager()
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   342
            for filepath in filesOpen:
527
7d5c74cc8f91 - Fix bug with relative path when node opened from command line
greg
parents: 512
diff changeset
   343
                result = self.Manager.OpenFileInCurrent(os.path.abspath(filepath))
512
e84806c0ada4 Some instance type test improved
lbessard
parents: 491
diff changeset
   344
                if isinstance(result, (IntType, LongType)):
485
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   345
                    new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   346
                    new_editingpanel.SetIndex(result)
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   347
                    self.FileOpened.AddPage(new_editingpanel, "")
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   348
        else:
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   349
            self.Manager = manager
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   350
            for index in self.Manager.GetBufferIndexes():
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 280
diff changeset
   351
                new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
485
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   352
                new_editingpanel.SetIndex(index)
232
e435bbec1759 Bug on file loading from shell command fixed
lbessard
parents: 227
diff changeset
   353
                self.FileOpened.AddPage(new_editingpanel, "")
485
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   354
        
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   355
        if self.Manager.GetBufferNumber() > 0:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   356
            window = self.FileOpened.GetPage(0)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   357
            if window:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   358
                self.Manager.ChangeCurrentNode(window.GetIndex())
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   359
                self.FileOpened.SetSelection(0)
485
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   360
        
258
8f7725451453 Some bugs fixed:
lbessard
parents: 254
diff changeset
   361
        if self.Manager.CurrentDS302Defined():
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   362
            self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUDS302PROFILE, True)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   363
        else:
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   364
            self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUDS302PROFILE, False)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   365
        self.RefreshEditMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   366
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   367
        self.RefreshProfileMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   368
        self.RefreshTitle()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   369
        self.RefreshMainMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   370
485
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   371
    def SetBusId(self, bus_id):
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   372
        self.BusId = bus_id
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   373
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   374
    def GetBusId(self):
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   375
        return self.BusId
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   376
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   377
    def IsClosing(self):
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   378
        return self.Closing
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   379
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   380
    def OnAddSDOServerMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   381
        self.Manager.AddSDOServerToCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   382
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   383
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   384
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   385
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   386
    def OnAddSDOClientMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   387
        self.Manager.AddSDOClientToCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   388
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   389
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   390
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   391
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   392
    def OnAddPDOTransmitMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   393
        self.Manager.AddPDOTransmitToCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   394
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   395
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   396
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   397
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   398
    def OnAddPDOReceiveMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   399
        self.Manager.AddPDOReceiveToCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   400
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   401
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   402
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   403
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   404
    def OnAddMapVariableMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   405
        self.AddMapVariable()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   406
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   407
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   408
    def OnAddUserTypeMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   409
        self.AddUserType()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   410
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   411
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   412
    def OnFileSelectedChanged(self, event):
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   413
        if not self.Closing:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   414
            selected = event.GetSelection()
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   415
            # At init selected = -1
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   416
            if selected >= 0:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   417
                window = self.FileOpened.GetPage(selected)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   418
                if window:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   419
                    self.Manager.ChangeCurrentNode(window.GetIndex())
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   420
                    wx.CallAfter(self.RefreshBufferState)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   421
                    self.RefreshStatusBar()
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   422
                    self.RefreshProfileMenu()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   423
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   424
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   425
    def OnHelpDS301Menu(self, event):
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   426
        find_index = False
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   427
        selected = self.FileOpened.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   428
        if selected >= 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   429
            window = self.FileOpened.GetPage(selected)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   430
            result = window.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   431
            if result:
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   432
                find_index = True
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   433
                index, subIndex = result
158
b505f7116a1c Moved DS-301 PDF into objdictgen. Fixed installation on linux. Now TestMasterSlave is also installed in $PREFIX/bin.
etisserant
parents: 149
diff changeset
   434
                result = OpenPDFDocIndex(index, ScriptDirectory)
512
e84806c0ada4 Some instance type test improved
lbessard
parents: 491
diff changeset
   435
                if isinstance(result, (StringType, UnicodeType)):
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   436
                    message = wx.MessageDialog(self, result, _("ERROR"), wx.OK|wx.ICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   437
                    message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   438
                    message.Destroy()
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   439
        if not find_index:
158
b505f7116a1c Moved DS-301 PDF into objdictgen. Fixed installation on linux. Now TestMasterSlave is also installed in $PREFIX/bin.
etisserant
parents: 149
diff changeset
   440
            result = OpenPDFDocIndex(None, ScriptDirectory)
512
e84806c0ada4 Some instance type test improved
lbessard
parents: 491
diff changeset
   441
            if isinstance(result, (StringType, UnicodeType)):
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   442
                message = wx.MessageDialog(self, result, _("ERROR"), wx.OK|wx.ICON_ERROR)
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   443
                message.ShowModal()
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   444
                message.Destroy()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   445
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   446
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   447
    def OnHelpCANFestivalMenu(self, event):
158
b505f7116a1c Moved DS-301 PDF into objdictgen. Fixed installation on linux. Now TestMasterSlave is also installed in $PREFIX/bin.
etisserant
parents: 149
diff changeset
   448
        #self.OpenHtmlFrame("CAN Festival Reference", os.path.join(ScriptDirectory, "doc/canfestival.html"), wx.Size(1000, 600))
341
7ff01f109bbc Windows related enhancements
etisserant
parents: 334
diff changeset
   449
        if wx.Platform == '__WXMSW__':
386
0f56a144ba5f Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents: 348
diff changeset
   450
            readerpath = get_acroversion()
0f56a144ba5f Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents: 348
diff changeset
   451
            readerexepath = os.path.join(readerpath,"AcroRd32.exe")
0f56a144ba5f Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents: 348
diff changeset
   452
            if(os.path.isfile(readerexepath)):
408
f85552acc2bf fixed bug to open pdf with acrobat reader on Win32 in objdictedit and networkedit
greg
parents: 386
diff changeset
   453
                os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", '"%s"'%os.path.join(ScriptDirectory, "doc","manual_en.pdf"))
569
ecaac955c16a fix message dialog when objdictedit can't find the pdf reader
greg
parents: 548
diff changeset
   454
            else:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   455
                message = wx.MessageDialog(self, _("Check if Acrobat Reader is correctly installed on your computer"), _("ERROR"), wx.OK|wx.ICON_ERROR)
569
ecaac955c16a fix message dialog when objdictedit can't find the pdf reader
greg
parents: 548
diff changeset
   456
                message.ShowModal()
ecaac955c16a fix message dialog when objdictedit can't find the pdf reader
greg
parents: 548
diff changeset
   457
                message.Destroy()
ecaac955c16a fix message dialog when objdictedit can't find the pdf reader
greg
parents: 548
diff changeset
   458
        else:
ecaac955c16a fix message dialog when objdictedit can't find the pdf reader
greg
parents: 548
diff changeset
   459
            try:
ecaac955c16a fix message dialog when objdictedit can't find the pdf reader
greg
parents: 548
diff changeset
   460
                os.system("xpdf -remote CANFESTIVAL %s %d &"%(os.path.join(ScriptDirectory, "doc/manual_en.pdf"),16))
ecaac955c16a fix message dialog when objdictedit can't find the pdf reader
greg
parents: 548
diff changeset
   461
            except:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   462
                message = wx.MessageDialog(self, _("Check if xpdf is correctly installed on your computer"), _("ERROR"), wx.OK|wx.ICON_ERROR)
569
ecaac955c16a fix message dialog when objdictedit can't find the pdf reader
greg
parents: 548
diff changeset
   463
                message.ShowModal()
ecaac955c16a fix message dialog when objdictedit can't find the pdf reader
greg
parents: 548
diff changeset
   464
                message.Destroy()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   465
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   466
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   467
    def OnAboutMenu(self, event):
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   468
        self.OpenHtmlFrame(_("About CAN Festival"), os.path.join(ScriptDirectory, "doc/about.html"), wx.Size(500, 450))
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   469
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   470
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   471
    def OpenHtmlFrame(self, title, file, size):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   472
        if title not in self.HtmlFrameOpened:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   473
            self.HtmlFrameOpened.append(title)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   474
            window = HtmlFrame(self, self.HtmlFrameOpened)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   475
            window.SetTitle(title)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   476
            window.SetHtmlPage(file)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   477
            window.SetClientSize(size)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   478
            window.Show()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   479
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   480
    def OnQuitMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   481
        self.Close()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   482
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   483
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   484
    def OnCloseFrame(self, event):
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   485
        self.Closing = True
485
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   486
        if not self.ModeSolo:
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   487
            if getattr(self, "_onclose", None) != None:
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   488
                self._onclose()
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   489
            event.Skip()
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   490
        elif self.Manager.OneFileHasChanged():
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   491
            dialog = wx.MessageDialog(self, _("There are changes, do you want to save?"),  _("Close Application"), wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   492
            answer = dialog.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   493
            dialog.Destroy()
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   494
            if answer == wx.ID_YES:
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   495
                for i in xrange(self.Manager.GetBufferNumber()):
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   496
                    if self.Manager.CurrentIsSaved():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   497
                        self.Manager.CloseCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   498
                    else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   499
                        self.Save()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   500
                        self.Manager.CloseCurrent(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   501
                event.Skip()
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   502
            elif answer == wx.ID_NO:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   503
                event.Skip()
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   504
            else:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   505
                event.Veto()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   506
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   507
            event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   508
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   509
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   510
#                             Refresh Functions
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   511
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   512
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   513
    def RefreshTitle(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   514
        if self.FileOpened.GetPageCount() > 0:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   515
            self.SetTitle(_("Objdictedit - %s")%self.Manager.GetCurrentFilename())
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   516
        else:
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   517
            self.SetTitle(_("Objdictedit"))
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   518
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   519
    def OnRefreshMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   520
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   521
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   522
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   523
    def RefreshCurrentIndexList(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   524
        selected = self.FileOpened.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   525
        window = self.FileOpened.GetPage(selected)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   526
        window.RefreshIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   527
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   528
    def RefreshStatusBar(self):
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   529
        selected = self.FileOpened.GetSelection()
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   530
        if selected >= 0:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   531
            window = self.FileOpened.GetPage(selected)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   532
            selection = window.GetSelection()
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   533
            if selection:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   534
                index, subIndex = selection
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   535
                if self.Manager.IsCurrentEntry(index):
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   536
                    self.HelpBar.SetStatusText(_("Index: 0x%04X")%index, 0)
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   537
                    self.HelpBar.SetStatusText(_("Subindex: 0x%02X")%subIndex, 1)
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   538
                    entryinfos = self.Manager.GetEntryInfos(index)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   539
                    name = entryinfos["name"]
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   540
                    category = _("Optional")
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   541
                    if entryinfos["need"]:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   542
                        category = _("Mandatory")
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   543
                    struct = "VAR"
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   544
                    number = ""
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   545
                    if entryinfos["struct"] & OD_IdenticalIndexes:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   546
                        number = _(" possibly defined %d times")%entryinfos["nbmax"]
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   547
                    if entryinfos["struct"] & OD_IdenticalSubindexes:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   548
                        struct = "REC"
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   549
                    elif entryinfos["struct"] & OD_MultipleSubindexes:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   550
                        struct = "ARRAY"
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   551
                    text = _("%s: %s entry of struct %s%s.")%(name,category,struct,number)
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   552
                    self.HelpBar.SetStatusText(text, 2)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   553
                else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   554
                    for i in xrange(3):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   555
                        self.HelpBar.SetStatusText("", i)
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   556
            else:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   557
                for i in xrange(3):
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   558
                    self.HelpBar.SetStatusText("", i)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   559
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   560
    def RefreshMainMenu(self):
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   561
        if self.FileOpened.GetPageCount() > 0:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   562
            if self.ModeSolo:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   563
                self.MenuBar.EnableTop(1, True)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   564
                self.MenuBar.EnableTop(2, True)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   565
                self.FileMenu.Enable(wx.ID_CLOSE, True)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   566
                self.FileMenu.Enable(wx.ID_SAVE, True)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   567
                self.FileMenu.Enable(wx.ID_SAVEAS, True)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   568
                self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUEXPORTEDS, True)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   569
                self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUEXPORTC, True)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   570
            else:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   571
                self.MenuBar.EnableTop(0, True)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   572
                self.MenuBar.EnableTop(1, True)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   573
        else:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   574
            if self.ModeSolo:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   575
                self.MenuBar.EnableTop(1, False)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   576
                self.MenuBar.EnableTop(2, False)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   577
                self.FileMenu.Enable(wx.ID_CLOSE, False)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   578
                self.FileMenu.Enable(wx.ID_SAVE, False)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   579
                self.FileMenu.Enable(wx.ID_SAVEAS, False)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   580
                self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUEXPORTEDS, False)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   581
                self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUEXPORTC, False)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   582
            else:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   583
                self.MenuBar.EnableTop(0, False)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   584
                self.MenuBar.EnableTop(1, False)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   585
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   586
    def RefreshEditMenu(self):
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   587
        if self.FileOpened.GetPageCount() > 0:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   588
            undo, redo = self.Manager.GetCurrentBufferState()
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   589
            self.EditMenu.Enable(wx.ID_UNDO, undo)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   590
            self.EditMenu.Enable(wx.ID_REDO, redo)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   591
        else:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   592
            self.EditMenu.Enable(wx.ID_UNDO, False)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   593
            self.EditMenu.Enable(wx.ID_REDO, False)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   594
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   595
    def RefreshProfileMenu(self):
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   596
        profile = self.Manager.GetCurrentProfileName()
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   597
        edititem = self.EditMenu.FindItemById(ID_OBJDICTEDITEDITMENUOTHERPROFILE)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   598
        if edititem:
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   599
            length = self.AddMenu.GetMenuItemCount()
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   600
            for i in xrange(length-6):
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   601
                additem = self.AddMenu.FindItemByPosition(6)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   602
                self.AddMenu.Delete(additem.GetId())
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   603
            if profile not in ("None", "DS-301"):
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   604
                edititem.SetText(_("%s Profile")%profile)
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   605
                edititem.Enable(True)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   606
                self.AddMenu.AppendSeparator()
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   607
                for text, indexes in self.Manager.GetCurrentSpecificMenu():
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   608
                    new_id = wx.NewId()
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   609
                    self.AddMenu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=text)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   610
                    self.Bind(wx.EVT_MENU, self.GetProfileCallBack(text), id=new_id)
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   611
            else:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   612
                edititem.SetText(_("Other Profile"))
491
2ad3dedf6c6a Segmentation Fault on closing fixed
lbessard
parents: 488
diff changeset
   613
                edititem.Enable(False)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   614
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   615
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   616
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   617
#                            Buffer Functions
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   618
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   619
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   620
    def RefreshBufferState(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   621
        fileopened = self.Manager.GetAllFilenames()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   622
        for idx, filename in enumerate(fileopened):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   623
            self.FileOpened.SetPageText(idx, filename)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   624
        self.RefreshEditMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   625
        self.RefreshTitle()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   626
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   627
    def OnUndoMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   628
        self.Manager.LoadCurrentPrevious()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   629
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   630
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   631
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   632
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   633
    def OnRedoMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   634
        self.Manager.LoadCurrentNext()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   635
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   636
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   637
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   638
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   639
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   640
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   641
#                         Load and Save Funtions
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   642
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   643
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   644
    def OnNewMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   645
        self.FilePath = ""
258
8f7725451453 Some bugs fixed:
lbessard
parents: 254
diff changeset
   646
        dialog = CreateNodeDialog(self)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   647
        if dialog.ShowModal() == wx.ID_OK:
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   648
            name, id, nodetype, description = dialog.GetValues()
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
   649
            profile, filepath = dialog.GetProfile()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
   650
            NMT = dialog.GetNMTManagement()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
   651
            options = dialog.GetOptions()
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   652
            result = self.Manager.CreateNewNode(name, id, nodetype, description, profile, filepath, NMT, options)
512
e84806c0ada4 Some instance type test improved
lbessard
parents: 491
diff changeset
   653
            if isinstance(result, (IntType, LongType)):
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 280
diff changeset
   654
                new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   655
                new_editingpanel.SetIndex(result)
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
   656
                self.FileOpened.AddPage(new_editingpanel, "")
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   657
                self.FileOpened.SetSelection(self.FileOpened.GetPageCount() - 1)
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   658
                self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUDS302PROFILE, False)
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
   659
                if "DS302" in options:
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   660
                    self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUDS302PROFILE, True)
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
   661
                self.RefreshBufferState()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
   662
                self.RefreshProfileMenu()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
   663
                self.RefreshMainMenu()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   664
            else:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   665
                message = wx.MessageDialog(self, result, _("ERROR"), wx.OK|wx.ICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   666
                message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   667
                message.Destroy()
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 280
diff changeset
   668
        dialog.Destroy()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   669
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   670
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   671
    def OnOpenMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   672
        filepath = self.Manager.GetCurrentFilePath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   673
        if filepath != "":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   674
            directory = os.path.dirname(filepath)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   675
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   676
            directory = os.getcwd()
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   677
        dialog = wx.FileDialog(self, _("Choose a file"), directory, "",  _("OD files (*.od)|*.od|All files|*.*"), wx.OPEN|wx.CHANGE_DIR)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   678
        if dialog.ShowModal() == wx.ID_OK:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   679
            filepath = dialog.GetPath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   680
            if os.path.isfile(filepath):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   681
                result = self.Manager.OpenFileInCurrent(filepath)
512
e84806c0ada4 Some instance type test improved
lbessard
parents: 491
diff changeset
   682
                if isinstance(result, (IntType, LongType)):
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 280
diff changeset
   683
                    new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   684
                    new_editingpanel.SetIndex(result)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   685
                    self.FileOpened.AddPage(new_editingpanel, "")
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   686
                    self.FileOpened.SetSelection(self.FileOpened.GetPageCount() - 1)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   687
                    if self.Manager.CurrentDS302Defined(): 
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   688
                        self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUDS302PROFILE, True)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   689
                    else:
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   690
                        self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUDS302PROFILE, False)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   691
                    self.RefreshEditMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   692
                    self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   693
                    self.RefreshProfileMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   694
                    self.RefreshMainMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   695
                else:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   696
                    message = wx.MessageDialog(self, result, _("Error"), wx.OK|wx.ICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   697
                    message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   698
                    message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   699
        dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   700
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   701
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   702
    def OnSaveMenu(self, event):
485
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   703
        if not self.ModeSolo and getattr(self, "_onsave", None) != None:
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   704
            self._onsave()
488
01ab26d29117 Fixed missing refresh of title bar on Save.
etisserant
parents: 485
diff changeset
   705
            self.RefreshBufferState()
485
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   706
        else:
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
   707
            self.Save()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   708
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   709
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   710
    def OnSaveAsMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   711
        self.SaveAs()
30
a5dd050b28cb Some bugs found corrected
lbessard
parents: 0
diff changeset
   712
        event.Skip()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   713
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   714
    def Save(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   715
        result = self.Manager.SaveCurrentInFile()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   716
        if not result:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   717
            self.SaveAs()
512
e84806c0ada4 Some instance type test improved
lbessard
parents: 491
diff changeset
   718
        elif not isinstance(result, (StringType, UnicodeType)):
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   719
            self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   720
        else:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   721
            message = wx.MessageDialog(self, result, _("Error"), wx.OK|wx.ICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   722
            message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   723
            message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   724
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   725
    def SaveAs(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   726
        filepath = self.Manager.GetCurrentFilePath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   727
        if filepath != "":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   728
            directory, filename = os.path.split(filepath)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   729
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   730
            directory, filename = os.getcwd(), "%s.od"%self.Manager.GetCurrentNodeInfos()[0]
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   731
        dialog = wx.FileDialog(self, _("Choose a file"), directory, filename,  _("OD files (*.od)|*.od|All files|*.*"), wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   732
        if dialog.ShowModal() == wx.ID_OK:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   733
            filepath = dialog.GetPath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   734
            if os.path.isdir(os.path.dirname(filepath)):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   735
                result = self.Manager.SaveCurrentInFile(filepath)
512
e84806c0ada4 Some instance type test improved
lbessard
parents: 491
diff changeset
   736
                if not isinstance(result, (StringType, UnicodeType)):
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   737
                    self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   738
                else:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   739
                    message = wx.MessageDialog(self, result, _("Error"), wx.OK|wx.ICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   740
                    message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   741
                    message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   742
            else:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   743
                message = wx.MessageDialog(self, _("%s is not a valid folder!")%os.path.dirname(filepath), _("Error"), wx.OK|wx.ICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   744
                message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   745
                message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   746
        dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   747
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   748
    def OnCloseMenu(self, event):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   749
        answer = wx.ID_YES
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   750
        result = self.Manager.CloseCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   751
        if not result:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   752
            dialog = wx.MessageDialog(self, _("There are changes, do you want to save?"),  _("Close File"), wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   753
            answer = dialog.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   754
            dialog.Destroy()
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   755
            if answer == wx.ID_YES:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   756
                self.OnSaveMenu(event)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   757
                if self.Manager.CurrentIsSaved():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   758
                    self.Manager.CloseCurrent()
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   759
            elif answer == wx.ID_NO:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   760
                self.Manager.CloseCurrent(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   761
        if self.FileOpened.GetPageCount() > self.Manager.GetBufferNumber():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   762
            current = self.FileOpened.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   763
            self.FileOpened.DeletePage(current)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   764
            if self.FileOpened.GetPageCount() > 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   765
                self.FileOpened.SetSelection(min(current, self.FileOpened.GetPageCount() - 1))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   766
            self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   767
            self.RefreshMainMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   768
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   769
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   770
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   771
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   772
#                         Import and Export Functions
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   773
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   774
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   775
    def OnImportEDSMenu(self, event):
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   776
        dialog = wx.FileDialog(self, _("Choose a file"), os.getcwd(), "",  _("EDS files (*.eds)|*.eds|All files|*.*"), wx.OPEN|wx.CHANGE_DIR)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   777
        if dialog.ShowModal() == wx.ID_OK:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   778
            filepath = dialog.GetPath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   779
            if os.path.isfile(filepath):
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   780
                result = self.Manager.ImportCurrentFromEDSFile(filepath)
512
e84806c0ada4 Some instance type test improved
lbessard
parents: 491
diff changeset
   781
                if isinstance(result, (IntType, LongType)):
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 280
diff changeset
   782
                    new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   783
                    new_editingpanel.SetIndex(result)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   784
                    self.FileOpened.AddPage(new_editingpanel, "")
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   785
                    self.FileOpened.SetSelection(self.FileOpened.GetPageCount() - 1)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   786
                    self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   787
                    self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   788
                    self.RefreshProfileMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   789
                    self.RefreshMainMenu()
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   790
                    message = wx.MessageDialog(self, _("Import successful"), _("Information"), wx.OK|wx.ICON_INFORMATION)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   791
                    message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   792
                    message.Destroy()
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   793
                else:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   794
                    message = wx.MessageDialog(self, result, _("Error"), wx.OK|wx.ICON_ERROR)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   795
                    message.ShowModal()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   796
                    message.Destroy()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   797
            else:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   798
                message = wx.MessageDialog(self, _("\"%s\" is not a valid file!")%filepath, _("Error"), wx.OK|wx.ICON_ERROR)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   799
                message.ShowModal()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   800
                message.Destroy()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   801
        dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   802
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   803
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   804
    def OnExportEDSMenu(self, event):
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   805
        dialog = wx.FileDialog(self, _("Choose a file"), os.getcwd(), self.Manager.GetCurrentNodeInfos()[0], _("EDS files (*.eds)|*.eds|All files|*.*"), wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   806
        if dialog.ShowModal() == wx.ID_OK:
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   807
            filepath = dialog.GetPath()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   808
            if os.path.isdir(os.path.dirname(filepath)):
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   809
                path, extend = os.path.splitext(filepath)
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   810
                if extend in ("", "."):
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   811
                    filepath = path + ".eds"
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   812
                result = self.Manager.ExportCurrentToEDSFile(filepath)
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   813
                if not result:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   814
                    message = wx.MessageDialog(self, _("Export successful"), _("Information"), wx.OK|wx.ICON_INFORMATION)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   815
                    message.ShowModal()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   816
                    message.Destroy()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   817
                else:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   818
                    message = wx.MessageDialog(self, result, _("Error"), wx.OK|wx.ICON_ERROR)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   819
                    message.ShowModal()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   820
                    message.Destroy()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   821
            else:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   822
                message = wx.MessageDialog(self, _("\"%s\" is not a valid folder!")%os.path.dirname(filepath), _("Error"), wx.OK|wx.ICON_ERROR)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   823
                message.ShowModal()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   824
                message.Destroy()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   825
        dialog.Destroy()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   826
        event.Skip()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   827
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   828
    def OnExportCMenu(self, event):
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   829
        dialog = wx.FileDialog(self, _("Choose a file"), os.getcwd(), self.Manager.GetCurrentNodeInfos()[0],  _("CANFestival C files (*.c)|*.c|All files|*.*"), wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   830
        if dialog.ShowModal() == wx.ID_OK:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   831
            filepath = dialog.GetPath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   832
            if os.path.isdir(os.path.dirname(filepath)):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   833
                path, extend = os.path.splitext(filepath)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   834
                if extend in ("", "."):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   835
                    filepath = path + ".c"
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   836
                result = self.Manager.ExportCurrentToCFile(filepath)
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   837
                if not result:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   838
                    message = wx.MessageDialog(self, _("Export successful"), _("Information"), wx.OK|wx.ICON_INFORMATION)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   839
                    message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   840
                    message.Destroy()
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   841
                else:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   842
                    message = wx.MessageDialog(self, result, _("Error"), wx.OK|wx.ICON_ERROR)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   843
                    message.ShowModal()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   844
                    message.Destroy()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   845
            else:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   846
                message = wx.MessageDialog(self, _("\"%s\" is not a valid folder!")%os.path.dirname(filepath), _("Error"), wx.OK|wx.ICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   847
                message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   848
                message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   849
        dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   850
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   851
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   852
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   853
#                          Editing Profiles functions
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   854
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   855
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   856
    def OnCommunicationMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   857
        dictionary,current = self.Manager.GetCurrentCommunicationLists()
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   858
        self.EditProfile(_("Edit DS-301 Profile"), dictionary, current)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   859
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   860
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   861
    def OnOtherCommunicationMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   862
        dictionary,current = self.Manager.GetCurrentDS302Lists()
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   863
        self.EditProfile(_("Edit DS-302 Profile"), dictionary, current)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   864
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   865
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   866
    def OnEditProfileMenu(self, event):
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   867
        title = _("Edit %s Profile")%self.Manager.GetCurrentProfileName()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   868
        dictionary,current = self.Manager.GetCurrentProfileLists()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   869
        self.EditProfile(title, dictionary, current)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   870
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   871
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   872
    def EditProfile(self, title, dictionary, current):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   873
        dialog = CommunicationDialog(self)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   874
        dialog.SetTitle(title)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   875
        dialog.SetIndexDictionary(dictionary)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   876
        dialog.SetCurrentList(current)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   877
        dialog.RefreshLists()
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   878
        if dialog.ShowModal() == wx.ID_OK:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   879
            new_profile = dialog.GetCurrentList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   880
            addinglist = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   881
            removinglist = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   882
            for index in new_profile:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   883
                if index not in current:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   884
                    addinglist.append(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   885
            for index in current:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   886
                if index not in new_profile:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   887
                    removinglist.append(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   888
            self.Manager.ManageEntriesOfCurrent(addinglist, removinglist)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   889
            self.Manager.BufferCurrentNode()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   890
            self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   891
            self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   892
        dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   893
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   894
    def GetProfileCallBack(self, text):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   895
        def ProfileCallBack(event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   896
            self.Manager.AddSpecificEntryToCurrent(text)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   897
            self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   898
            self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   899
            event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   900
        return ProfileCallBack
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   901
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   902
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   903
#                         Edit Node informations function
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   904
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   905
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   906
    def OnNodeInfosMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   907
        dialog = NodeInfosDialog(self)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   908
        name, id, type, description = self.Manager.GetCurrentNodeInfos()
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   909
        defaultstringsize = self.Manager.GetCurrentNodeDefaultStringSize()
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   910
        dialog.SetValues(name, id, type, description, defaultstringsize)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   911
        if dialog.ShowModal() == wx.ID_OK:
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   912
            name, id, type, description, defaultstringsize = dialog.GetValues()
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   913
            self.Manager.SetCurrentNodeInfos(name, id, type, description)
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 410
diff changeset
   914
            self.Manager.SetCurrentNodeDefaultStringSize(defaultstringsize)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   915
            self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   916
            self.RefreshProfileMenu()
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   917
            selected = self.FileOpened.GetSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   918
            if selected >= 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   919
                window = self.FileOpened.GetPage(selected)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   920
                window.RefreshTable()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   921
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   922
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   923
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   924
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   925
#                           Add User Types and Variables
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   926
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   927
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   928
    def AddMapVariable(self):
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   929
        index = self.Manager.GetCurrentNextMapIndex()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   930
        if index:
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   931
            dialog = MapVariableDialog(self)
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   932
            dialog.SetIndex(index)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   933
            if dialog.ShowModal() == wx.ID_OK:
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   934
                index, name, struct, number = dialog.GetValues()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   935
                result = self.Manager.AddMapVariableToCurrent(index, name, struct, number)
512
e84806c0ada4 Some instance type test improved
lbessard
parents: 491
diff changeset
   936
                if not isinstance(result, (StringType, UnicodeType)):
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   937
                    self.RefreshBufferState()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   938
                    self.RefreshCurrentIndexList()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   939
                else:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   940
                    message = wx.MessageDialog(self, result, _("Error"), wx.OK|wx.ICON_ERROR)
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   941
                    message.ShowModal()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   942
                    message.Destroy()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   943
            dialog.Destroy()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   944
        else:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   945
            message = wx.MessageDialog(self, result, _("No map variable index left!"), wx.OK|wx.ICON_ERROR)
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   946
            message.ShowModal()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   947
            message.Destroy()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   948
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   949
    def AddUserType(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   950
        dialog = UserTypeDialog(self)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   951
        dialog.SetTypeList(self.Manager.GetCustomisableTypes())
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   952
        if dialog.ShowModal() == wx.ID_OK:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   953
            type, min, max, length = dialog.GetValues()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   954
            result = self.Manager.AddUserTypeToCurrent(type, min, max, length)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   955
            if not result:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   956
                self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   957
                self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   958
            else:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   959
                message = wx.MessageDialog(self, result, _("Error"), wx.OK|wx.ICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   960
                message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   961
                message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   962
        dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   963
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   964
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   965
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   966
#                               Exception Handler
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   967
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   968
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   969
Max_Traceback_List_Size = 20
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   970
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   971
def Display_Exception_Dialog(e_type,e_value,e_tb):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   972
    trcbck_lst = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   973
    for i,line in enumerate(traceback.extract_tb(e_tb)):
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   974
        trcbck = " " + str(i+1) + _(". ")
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   975
        if line[0].find(os.getcwd()) == -1:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   976
            trcbck += _("file : ") + str(line[0]) + _(",   ")
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   977
        else:
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   978
            trcbck += _("file : ") + str(line[0][len(os.getcwd()):]) + _(",   ")
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   979
        trcbck += _("line : ") + str(line[1]) + _(",   ") + _("function : ") + str(line[2])
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   980
        trcbck_lst.append(trcbck)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   981
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   982
    # Allow clicking....
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   983
    cap = wx.Window_GetCapture()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   984
    if cap:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   985
        cap.ReleaseMouse()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   986
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   987
    dlg = wx.SingleChoiceDialog(None, 
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   988
        _("""
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   989
An error happens.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   990
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   991
Click on OK for saving an error report.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   992
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   993
Please contact LOLITech at:
548
ecb8b7c6cf17 change LoliTech phone number for bug report
greg
parents: 534
diff changeset
   994
+33 (0)3 29 57 60 42
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   995
bugs_objdictedit@lolitech.fr
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   996
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   997
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   998
Error:
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
   999
""") +
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
  1000
        str(e_type) + _(" : ") + str(e_value), 
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
  1001
        _("Error"),
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1002
        trcbck_lst)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1003
    try:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1004
        res = (dlg.ShowModal() == wx.ID_OK)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1005
    finally:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1006
        dlg.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1007
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1008
    return res
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1009
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1010
def Display_Error_Dialog(e_value):
580
2ae92a99ac10 Adding support for internationalization
laurent
parents: 569
diff changeset
  1011
    message = wx.MessageDialog(None, str(e_value), _("Error"), wx.OK|wx.ICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1012
    message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1013
    message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1014
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1015
def get_last_traceback(tb):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1016
    while tb.tb_next:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1017
        tb = tb.tb_next
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1018
    return tb
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1019
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1020
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1021
def format_namespace(d, indent='    '):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1022
    return '\n'.join(['%s%s: %s' % (indent, k, repr(v)[:10000]) for k, v in d.iteritems()])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1023
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1024
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1025
ignored_exceptions = [] # a problem with a line in a module is only reported once per session
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1026
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
  1027
def AddExceptHook(path, app_version='[No version]'):#, ignored_exceptions=[]):
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1028
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1029
    def handle_exception(e_type, e_value, e_traceback):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1030
        traceback.print_exception(e_type, e_value, e_traceback) # this is very helpful when there's an exception in the rest of this func
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1031
        last_tb = get_last_traceback(e_traceback)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1032
        ex = (last_tb.tb_frame.f_code.co_filename, last_tb.tb_frame.f_lineno)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1033
        if str(e_value).startswith("!!!"):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1034
            Display_Error_Dialog(e_value)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1035
        elif ex not in ignored_exceptions:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1036
            ignored_exceptions.append(ex)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1037
            result = Display_Exception_Dialog(e_type,e_value,e_traceback)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1038
            if result:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1039
                info = {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1040
                    'app-title' : wx.GetApp().GetAppName(), # app_title
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1041
                    'app-version' : app_version,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1042
                    'wx-version' : wx.VERSION_STRING,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1043
                    'wx-platform' : wx.Platform,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1044
                    'python-version' : platform.python_version(), #sys.version.split()[0],
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1045
                    'platform' : platform.platform(),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1046
                    'e-type' : e_type,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1047
                    'e-value' : e_value,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1048
                    'date' : time.ctime(),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1049
                    'cwd' : os.getcwd(),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1050
                    }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1051
                if e_traceback:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1052
                    info['traceback'] = ''.join(traceback.format_tb(e_traceback)) + '%s: %s' % (e_type, e_value)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1053
                    last_tb = get_last_traceback(e_traceback)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1054
                    exception_locals = last_tb.tb_frame.f_locals # the locals at the level of the stack trace where the exception actually occurred
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1055
                    info['locals'] = format_namespace(exception_locals)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1056
                    if 'self' in exception_locals:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1057
                        info['self'] = format_namespace(exception_locals['self'].__dict__)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1058
                
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1059
                output = open(path+os.sep+"bug_report_"+info['date'].replace(':','-').replace(' ','_')+".txt",'w')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1060
                lst = info.keys()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1061
                lst.sort()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1062
                for a in lst:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1063
                    output.write(a+":\n"+str(info[a])+"\n\n")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1064
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1065
    #sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1066
    sys.excepthook = handle_exception
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1067
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1068
if __name__ == '__main__':
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
  1069
    wx.InitAllImageHandlers()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1070
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1071
    # Install a exception handle for bug reports
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
  1072
    AddExceptHook(os.getcwd(),__version__)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1073
    
485
24b506ea314b Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents: 418
diff changeset
  1074
    frame = objdictedit(None, filesOpen = args)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1075
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1076
    frame.Show()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1077
    app.MainLoop()