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-2003 Free Software Foundation |
20 |
# |
# |
21 |
# FILE: |
# FILE: |
22 |
# reports/Instance.py |
# reports/Instance.py |
28 |
# |
# |
29 |
|
|
30 |
from gnue.designer.reports import properties as reportsProperties |
from gnue.designer.reports import properties as reportsProperties |
31 |
from gnue.designer.Instance import BaseInstance |
from gnue.designer.base.Instance import BaseInstance |
32 |
import Incubator |
from gnue.common.FileUtils import dyn_import |
33 |
|
from gnue.common import GDebug |
34 |
import wizards |
import wizards |
35 |
|
|
36 |
# Tool support... |
# Tool support... |
37 |
from LayoutEditor import LayoutEditor |
from LayoutEditor import LayoutEditor |
38 |
from TreeView import TreeView |
from TreeView import TreeView |
39 |
from gnue.designer.PropertyEditor import PropertyEditor |
from gnue.designer.base.tools.PropertyEditor import PropertyEditor |
40 |
from gnue.designer.DataSourceEditor import DataSourceEditor |
from gnue.designer.base.tools.DataSourceEditor import DataSourceEditor |
41 |
from gnue.designer.SchemaViewer import SchemaViewer |
from gnue.designer.base.tools.SchemaViewer import SchemaViewer |
42 |
from gnue.designer.TriggerEditor import TriggerEditor |
from gnue.designer.base.tools.TriggerEditor import TriggerEditor |
43 |
|
from gnue.designer.base.tools.EventEditor import EventEditor |
44 |
|
|
45 |
from gnue.reports import GRReport, GRParser, GRLayout |
from gnue.reports.base import GRReport, GRParser, GRSources, GRParameters, GRSortOptions |
46 |
|
from gnue.reports.base import layout as GRLayout |
47 |
|
|
48 |
|
|
49 |
class Instance(BaseInstance): |
class Instance(BaseInstance): |
50 |
|
|
51 |
def __init__(self, app, *args, **params): |
def __init__(self, app, *args, **params): |
|
self.incubator = Incubator |
|
52 |
self.properties = reportsProperties |
self.properties = reportsProperties |
53 |
|
|
54 |
#self._tableMappings = {} |
#self._tableMappings = {} |
55 |
BaseInstance.__init__(self, app, *args, **params) |
BaseInstance.__init__(self, app, *args, **params) |
56 |
|
|
57 |
|
report = self.rootObject |
58 |
|
report._parameters = report.findChildOfType('GRParameters') or \ |
59 |
|
self.incubator.createObject(report, 'parameters', report, select=0) |
60 |
|
report._sortoptions = report.findChildOfType('GRSortOptions') or \ |
61 |
|
self.incubator.createObject(report, 'sortoptions', report, select=0) |
62 |
|
report._sources = report.findChildOfType('GRSources') or \ |
63 |
|
self.incubator.createObject(report, 'sources', report, select=0) |
64 |
|
report._layout = report.findChildOfType('GRLayout') or \ |
65 |
|
self.incubator.createObject(report, 'layout', report, select=0) |
66 |
|
|
67 |
|
|
68 |
|
|
69 |
def loadBuffer(self, buffer): |
def loadBuffer(self, buffer): |
70 |
report = GRParser.loadFile (buffer, self, initialize=0) |
report = GRParser.loadFile (buffer, self, initialize=0) |
71 |
report.name = 'report' |
report.name = 'report' |
72 |
|
|
73 |
|
# Find which filter is in use... yes, this is ugly |
74 |
|
namespace = report.findChildOfType('GRLayout')._findNamespace() |
75 |
|
filter = namespace.split(':')[-1] |
76 |
|
|
77 |
|
try: |
78 |
|
filtersupport = dyn_import('gnue.designer.reports.%s.FilterSupport' % filter) |
79 |
|
usingDefault = 0 |
80 |
|
except ImportError: |
81 |
|
GDebug.printMesg(2,'No filter support for %s; using default') |
82 |
|
filtersupport = dyn_import('gnue.designer.reports.Default.FilterSupport') |
83 |
|
usingDefault = 1 |
84 |
|
|
85 |
|
self.filter = filtersupport.FilterSupport(self, report) |
86 |
|
if usingDefault: |
87 |
|
self.filter.setNamespace(namespace) |
88 |
|
|
89 |
|
self.incubator = self.filter.INCUBATORCLASS(self) |
90 |
|
|
91 |
return report |
return report |
92 |
|
|
93 |
|
|
94 |
def loadEmpty(self): |
def loadEmpty(self, style=None): |
95 |
report = GRReport.GRReport() |
report = GRReport.GRReport() |
96 |
report.title = "Untitled report" |
report.title = "Untitled report" |
97 |
report.name = 'report' |
report.name = 'report' |
98 |
|
GRParameters.GRParameters(report)._buildObject() |
99 |
|
GRSortOptions.GRSortOptions(report)._buildObject() |
100 |
|
GRSources.GRSources(report)._buildObject() |
101 |
|
GRLayout.GRLayout(report)._buildObject() |
102 |
|
|
103 |
|
# Find which filter is in use... yes, this is ugly |
104 |
|
namespace = style or "GNUe:Reports:Standard" |
105 |
|
filter = (namespace).split(':')[-1] |
106 |
|
|
107 |
|
try: |
108 |
|
filtersupport = dyn_import('gnue.designer.reports.%s.FilterSupport' % filter) |
109 |
|
usingDefault = 0 |
110 |
|
except ImportError: |
111 |
|
GDebug.printMesg(2,'No filter support for %s; using default') |
112 |
|
filtersupport = dyn_import('gnue.designer.reports.Default.FilterSupport') |
113 |
|
usingDefault = 1 |
114 |
|
|
115 |
|
self.filter = filtersupport.FilterSupport(self, report) |
116 |
|
if usingDefault: |
117 |
|
self.filter.setNamespace(namespace) |
118 |
|
|
119 |
|
self.incubator = self.filter.INCUBATORCLASS(self) |
120 |
|
|
121 |
|
self.filter.initAsNew() |
122 |
|
|
123 |
|
report._buildObject() |
124 |
return report |
return report |
125 |
|
|
126 |
|
|
127 |
def inventoryObject(self, object): |
def inventoryObject(self, object): |
128 |
pass |
pass |
|
|
|
|
def createVisualEditor(self): |
|
|
return LayoutEditor(self, self) |
|
129 |
|
|
130 |
|
|
131 |
def createTools(self): |
def createTools(self): |
132 |
self.addTool(_('propertyEditor'), _('Property Inspector'), PropertyEditor) |
self.addTool('propertyEditor', _('Property Inspector'), PropertyEditor, 'F10') |
133 |
## TODO: Causing a segfault with Wizards!!!! |
self.addTool('treeEditor', _('Object Navigator'), TreeView, 'F8') |
134 |
self.addTool(_('treeEditor'), _('Object Navigator'), TreeView) |
self.addTool('schemaViewer', _('Schema Navigator'), SchemaViewer) |
135 |
self.addTool('triggerEditor', _('Event Editor'), TriggerEditor) |
self.addToolSeparator() |
136 |
|
self.addTool('datasourceEditor',_('Data Source Editor'), DataSourceEditor) |
137 |
|
#self.addTool('groupEditor', _('Group Editor'), GroupEditor, 'F5') |
138 |
|
#self.addTool('fieldEditor', _('Field Editor'), FieldEditor, 'F6') |
139 |
|
self.addToolSeparator() |
140 |
|
self.addTool('eventEditor', _('Trigger Inspector'), EventEditor, 'F7') |
141 |
|
self.addTool('triggerEditor', _('Code Editor'), TriggerEditor, 'F12') |
142 |
|
|
143 |
self.addTool(_('schemaViewer'), _('Schema Navigator'), SchemaViewer) |
# Add filter-specific tools |
144 |
|
self.filter.addTools() |
145 |
|
|
146 |
|
|
147 |
|
def createWizards(self): |
148 |
self.loadWizards(wizards) |
self.loadWizards(wizards) |
149 |
|
|
150 |
|
# Used by TemplateParser to build a wizard.current dict |
151 |
|
def buildWizardCurrentDict(self): |
152 |
|
report = self.rootObject |
153 |
|
return { 'report': report, |
154 |
|
'sources': report._sources, |
155 |
|
'parameters': report._parameters, |
156 |
|
'layout': report._layout, |
157 |
|
'sortoptions': report._sortoptions, |
158 |
|
'object': self._currentObject } |
159 |
|
|
160 |
def preSave(self): |
def preSave(self): |
|
pass |
|
|
|
|
|
# Hack having to do with UIwxpython import |
|
|
def uiEventTrap(self, event): |
|
|
pass |
|
|
|
|
|
|
|
161 |
|
|
162 |
|
# Resort the main sections to a logical order |
163 |
|
report = self.rootObject |
164 |
|
for o in [report._parameters, report._sortoptions, |
165 |
|
report._sources, report._layout]: |
166 |
|
report._children.pop(report._children.index(o)) |
167 |
|
if len(o._children): |
168 |
|
report._children.append(o) |
169 |
|
|
170 |
|
|