1 |
# |
# |
2 |
# This file is part of GNU Enterprise. |
# This file is part of GNU Enterprise. |
3 |
# |
# |
4 |
# GNU Enterprise is free software; you can redistribute it |
# GNU Enterprise is free software; you can redistribute it |
5 |
# and/or modify it under the terms of the GNU General Public |
# and/or modify it under the terms of the GNU General Public |
6 |
# License as published by the Free Software Foundation; either |
# License as published by the Free Software Foundation; either |
7 |
# version 2, or (at your option) any later version. |
# version 2, or (at your option) any later version. |
8 |
# |
# |
9 |
# GNU Enterprise is distributed in the hope that it will be |
# GNU Enterprise is distributed in the hope that it will be |
10 |
# useful, but WITHOUT ANY WARRANTY; without even the implied |
# useful, but WITHOUT ANY WARRANTY; without even the implied |
11 |
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
12 |
# PURPOSE. See the GNU General Public License for more details. |
# PURPOSE. See the GNU General Public License for more details. |
13 |
# |
# |
14 |
# You should have received a copy of the GNU General Public |
# You should have received a copy of the GNU General Public |
15 |
# License along with program; see the file COPYING. If not, |
# License along with program; see the file COPYING. If not, |
16 |
# write to the Free Software Foundation, Inc., 59 Temple Place |
# write to the Free Software Foundation, Inc., 59 Temple Place |
17 |
# - Suite 330, Boston, MA 02111-1307, USA. |
# - Suite 330, Boston, MA 02111-1307, USA. |
18 |
# |
# |
19 |
# Copyright 2001-2002 Free Software Foundation |
# Copyright 2001-2002 Free Software Foundation |
20 |
# |
# |
21 |
# FILE: |
# FILE: |
22 |
# reports/TreeView.py |
# reports/TreeView.py |
23 |
# |
# |
24 |
# DESCRIPTION: |
# DESCRIPTION: |
25 |
# |
# |
26 |
# NOTES: |
# NOTES: |
27 |
# |
# |
28 |
# TODO: all the SetItemImage lines in this file have been commented out as on win32 it was segfaulting |
# TODO: all the SetItemImage lines in this file have been commented out as on win32 it was segfaulting |
29 |
|
|
30 |
import sys, os |
import sys, os |
31 |
from wxPython.wx import * |
from wxPython.wx import * |
32 |
from gnue.common import GDebug |
from gnue.common import GDebug |
33 |
from gnue.reports import GRReport, GRLayout, GRSources, GRParameters, GRSortOptions |
from gnue.reports import GRReport, GRLayout, GRSources, GRParameters, GRSortOptions |
34 |
from gnue.designer.PopupMenu import ObjectMenu |
from gnue.designer.PopupMenu import ObjectMenu |
35 |
from gnue.designer.Icons import treeIconMap, treeIconList |
from gnue.designer.Icons import treeIconMap, treeIconList |
36 |
from gnue.designer.TreeView import TreeView as BaseTreeView |
from gnue.designer.TreeView import TreeView as BaseTreeView |
37 |
|
|
38 |
class TreeView (BaseTreeView): |
class TreeView (BaseTreeView): |
39 |
def __init__(self, instance, root, parent): |
def __init__(self, instance, root, parent): |
40 |
|
|
41 |
self.rootDescr = 'Report' |
self.rootDescr = 'Report' |
42 |
BaseTreeView.__init__(self, instance, root, parent) |
BaseTreeView.__init__(self, instance, root, parent) |
43 |
|
|
44 |
self.rootObject._treeItemReportParameters = \ |
self.SetPyData(self.rootObject._treeItem, self.rootObject) |
45 |
self.AppendItem(self.rootObject._treeItem, _("Parameters")) |
|
46 |
self.SetItemImage(self.rootObject._treeItemReportParameters, treeIconMap['properties']) |
self.rootObject.walk(self.inventoryObject) |
47 |
self.rootObject._treeItemReportSortoptions = \ |
|
48 |
self.AppendItem(self.rootObject._treeItem, _("Sortoptions")) |
def inventoryObject (self, object): |
49 |
self.SetItemImage(self.rootObject._treeItemReportSortoptions, treeIconMap['properties']) |
if object != self.rootObject: |
50 |
self.rootObject._treeItemDataSources = \ |
# TODO: icons for reports wanted (btami) |
51 |
self.AppendItem(self.rootObject._treeItem, _("Data Sources")) |
icon = 'properties' |
52 |
self.SetItemImage(self.rootObject._treeItemDataSources, treeIconMap['datasource']) |
parentTreeItem = object._parent._treeItem |
53 |
self.rootObject._treeItemReportLayout = \ |
if isinstance(object, GRParameters.GRParameters): |
54 |
self.AppendItem(self.rootObject._treeItem, _("Report Layout")) |
icon = 'properties' |
55 |
self.SetItemImage(self.rootObject._treeItemReportLayout, treeIconMap['page']) |
elif isinstance(object, GRSortOptions.GRSortOptions): |
56 |
self.SetPyData(self.rootObject._treeItem, self.rootObject) |
icon = 'properties' |
57 |
|
elif isinstance(object, GRSources.GRSources): |
58 |
self.SetPyData(self.rootObject._treeItemReportParameters, ObjectMenu(self.instance,None)) |
icon = 'datasource' |
59 |
self.SetPyData(self.rootObject._treeItemReportSortoptions, ObjectMenu(self.instance,None)) |
elif isinstance(object, GRLayout.GRLayout): |
60 |
self.SetPyData(self.rootObject._treeItemDataSources, ObjectMenu(self.instance,None)) |
icon = 'page' |
61 |
self.SetPyData(self.rootObject._treeItemReportLayout, ObjectMenu(self.instance,None)) |
elif object._type == 'GRSsection': |
62 |
|
icon = 'block' |
63 |
self.rootObject.walk(self.inventoryObject) |
elif object._type == 'GRSumm': |
64 |
|
icon = 'entry' |
65 |
|
elif object._type == 'GRFiled': |
66 |
def inventoryObject (self, object): |
icon = 'entry' |
67 |
if object != self.rootObject: |
|
68 |
icon = 'properties' |
object._treeItem = self.AppendItem(parentTreeItem, |
69 |
try: |
"%s" % object.getDescription()) |
70 |
parentTreeItem = object._parent._treeItem |
self.SetPyData(object._treeItem, object) |
71 |
except AttributeError: |
self.SetItemImage(object._treeItem, treeIconMap[icon]) |
72 |
parentTreeItem = None |
|
73 |
if isinstance(object, GRParameters.GRParameter): |
|
|
parentTreeItem = self.rootObject._treeItemReportParameters |
|
|
icon = 'properties' |
|
|
elif isinstance(object, GRSortOptions.GRSortOption): |
|
|
parentTreeItem = self.rootObject._treeItemReportSortoptions |
|
|
icon = 'properties' |
|
|
elif isinstance(object, GRSources.GRDataSource): |
|
|
parentTreeItem = self.rootObject._treeItemDataSources |
|
|
icon = 'datasource' |
|
|
elif isinstance(object, GRLayout.GRSection): |
|
|
parentTreeItem = self.rootObject._treeItemReportLayout |
|
|
icon = 'page' |
|
|
elif object._type == 'GRSumm': |
|
|
icon = 'block' |
|
|
elif object._type == 'GRFiled': |
|
|
icon = 'entry' |
|
|
|
|
|
object._treeItem = self.AppendItem(parentTreeItem, |
|
|
"%s" % object.getDescription()) |
|
|
self.SetPyData(object._treeItem, object) |
|
|
#self.SetItemImage(object._treeItem, treeIconMap[icon]) |
|
|
|
|
|
|
|