1 |
# |
# |
|
# Copyright 2001 Free Software Foundation |
|
|
# |
|
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 |
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 |
20 |
|
# |
21 |
# FILE: |
# FILE: |
22 |
# DataSourceEditor.py |
# DataSourceEditor.py |
23 |
# |
# |
31 |
from wxPython.wx import * |
from wxPython.wx import * |
32 |
from gnue.common import GDebug, GDataSource, GConfig |
from gnue.common import GDebug, GDataSource, GConfig |
33 |
from gnue.common import RuntimeSettings |
from gnue.common import RuntimeSettings |
|
import Incubator |
|
34 |
|
|
35 |
class DataSourceEditor(wxPanel): |
class DataSourceEditor(wxPanel): |
36 |
def __init__(self, instance, rootObject, parentWindow): |
def __init__(self, instance, rootObject, parentWindow): |
50 |
style=wxLC_REPORT| # wxLC_EDIT_LABELS| |
style=wxLC_REPORT| # wxLC_EDIT_LABELS| |
51 |
wxLC_HRULES|wxLC_VRULES|wxLC_SINGLE_SEL) |
wxLC_HRULES|wxLC_VRULES|wxLC_SINGLE_SEL) |
52 |
|
|
53 |
self.list.InsertColumn(0,'Name') |
self.list.InsertColumn(0,_('Name')) |
54 |
self.list.InsertColumn(1,'Source') |
self.list.InsertColumn(1,_('Source')) |
55 |
self.list.InsertColumn(2,'Connection') |
self.list.InsertColumn(2,_('Connection')) |
56 |
|
|
57 |
self.notebook = wxNotebook(self.splitter, -1, style=wxNB_BOTTOM) |
self.notebook = wxNotebook(self.splitter, -1, style=wxNB_BOTTOM) |
58 |
|
|
60 |
self.referencesPanel = ReferencesViewer(self, self.notebook) |
self.referencesPanel = ReferencesViewer(self, self.notebook) |
61 |
self.schemaPanel = SchemaViewer(self, self.notebook) |
self.schemaPanel = SchemaViewer(self, self.notebook) |
62 |
|
|
63 |
self.notebook.AddPage(self.propertyPanel, 'Properties') |
self.notebook.AddPage(self.propertyPanel, _('Properties')) |
64 |
self.notebook.AddPage(self.referencesPanel, 'References') |
self.notebook.AddPage(self.referencesPanel, _('References')) |
65 |
self.notebook.AddPage(self.schemaPanel, 'Schema') |
self.notebook.AddPage(self.schemaPanel, _('Schema')) |
66 |
|
|
67 |
self.splitter.SplitHorizontally(self.list, self.notebook,200) |
self.splitter.SplitHorizontally(self.list, self.notebook,200) |
68 |
|
|
327 |
attributes['database'] = \ |
attributes['database'] = \ |
328 |
hasattr(self.current,'database') and self.current.database or '' |
hasattr(self.current,'database') and self.current.database or '' |
329 |
|
|
330 |
Incubator.createObject(self.instance, self.rootObject, 'datasource', |
self.instance.incubator.createObject(self.instance, self.rootObject, 'datasource', |
331 |
parent=self.rootObject, attributes=attributes) |
parent=self.rootObject, attributes=attributes) |
332 |
|
|
333 |
|
|
354 |
self.AddSimpleTool(self.addButtonId, |
self.AddSimpleTool(self.addButtonId, |
355 |
wxImage(iamges_dir+gConfig('tb_insert'), |
wxImage(iamges_dir+gConfig('tb_insert'), |
356 |
wxBITMAP_TYPE_PNG).ConvertToBitmap(), |
wxBITMAP_TYPE_PNG).ConvertToBitmap(), |
357 |
"Create Data Source", |
_("Create Data Source"), |
358 |
"Create a new data source") |
_("Create a new data source")) |
359 |
|
|
360 |
self.AddSimpleTool(self.deleteButtonId, |
self.AddSimpleTool(self.deleteButtonId, |
361 |
wxImage(iamges_dir+gConfig('tb_delete'), |
wxImage(iamges_dir+gConfig('tb_delete'), |
362 |
wxBITMAP_TYPE_PNG).ConvertToBitmap(), |
wxBITMAP_TYPE_PNG).ConvertToBitmap(), |
363 |
"Delete Data Source", |
_("Delete Data Source"), |
364 |
"Delete the currently selected data source") |
_("Delete the currently selected data source")) |
365 |
|
|
366 |
EVT_TOOL(self, self.addButtonId, editor.OnAddDSSelected) |
EVT_TOOL(self, self.addButtonId, editor.OnAddDSSelected) |
367 |
EVT_TOOL(self, self.deleteButtonId, editor.OnDeleteDSSelected) |
EVT_TOOL(self, self.deleteButtonId, editor.OnDeleteDSSelected) |
411 |
self.list = wxListCtrl(self, -1, pos=wxPoint(0,0), |
self.list = wxListCtrl(self, -1, pos=wxPoint(0,0), |
412 |
style=wxLC_REPORT|wxLC_HRULES|wxLC_VRULES) |
style=wxLC_REPORT|wxLC_HRULES|wxLC_VRULES) |
413 |
|
|
414 |
self.list.InsertColumn(REF_NAME, 'Reference') |
self.list.InsertColumn(REF_NAME, _('Reference')) |
415 |
self.list.InsertColumn(REF_REFR, 'Referrer') |
self.list.InsertColumn(REF_REFR, _('Referrer')) |
416 |
self.list.InsertColumn(REF_TYPE, 'Type', wxLIST_FORMAT_RIGHT) |
self.list.InsertColumn(REF_TYPE, _('Type'), wxLIST_FORMAT_RIGHT) |
417 |
|
|
418 |
EVT_SIZE(self, self.OnSize) |
EVT_SIZE(self, self.OnSize) |
419 |
|
|
452 |
for i in range(len(mfields)): |
for i in range(len(mfields)): |
453 |
addLine( self, "%s.%s" % (mastertable, mfields[i]), |
addLine( self, "%s.%s" % (mastertable, mfields[i]), |
454 |
"%s.%s" % (item.name, dfields[i]), |
"%s.%s" % (item.name, dfields[i]), |
455 |
"Detail Datasource" ) |
_("Detail Datasource") ) |
456 |
|
|
457 |
|
|
458 |
for field in self.current._fieldFkReferences.keys(): |
for field in self.current._fieldFkReferences.keys(): |
459 |
for item in self.current._fieldFkReferences[field]: |
for item in self.current._fieldFkReferences[field]: |
460 |
addLine( self, "%s.%s" % (mastertable, field), |
addLine( self, "%s.%s" % (mastertable, field), |
461 |
"%s.%s" % (item._parent.name, item.name), |
"%s.%s" % (item._parent.name, item.name), |
462 |
"Dropdown Entry" ) |
_("Dropdown Entry") ) |
463 |
|
|
464 |
|
|
465 |
for block in self.current._blockReferences: |
for block in self.current._blockReferences: |
473 |
|
|
474 |
addLine( self, "%s.%s" % (mastertable, item.field), |
addLine( self, "%s.%s" % (mastertable, item.field), |
475 |
"%s.%s" % (block.name, item.name), |
"%s.%s" % (block.name, item.name), |
476 |
"Entry" ) |
_("Entry")) |
477 |
|
|
478 |
index = 0 |
index = 0 |
479 |
self.list.DeleteAllItems() |
self.list.DeleteAllItems() |
523 |
self.list = wxListCtrl(self, -1, pos=wxPoint(0,0), |
self.list = wxListCtrl(self, -1, pos=wxPoint(0,0), |
524 |
style=wxLC_REPORT|wxLC_HRULES|wxLC_VRULES) |
style=wxLC_REPORT|wxLC_HRULES|wxLC_VRULES) |
525 |
|
|
526 |
self.list.InsertColumn(SCH_FIELD, 'Field') |
self.list.InsertColumn(SCH_FIELD, _('Field')) |
527 |
self.list.InsertColumn(SCH_TYPE, 'Base Type') |
self.list.InsertColumn(SCH_TYPE, _('Base Type')) |
528 |
self.list.InsertColumn(SCH_SIZE, 'Size', wxLIST_FORMAT_RIGHT) |
self.list.InsertColumn(SCH_SIZE, _('Size'), wxLIST_FORMAT_RIGHT) |
529 |
self.list.InsertColumn(SCH_NATIVE,'Native Type') |
self.list.InsertColumn(SCH_NATIVE,_('Native Type')) |
530 |
self.list.InsertColumn(SCH_REQ, 'Required') |
self.list.InsertColumn(SCH_REQ, _('Required')) |
531 |
|
|
532 |
self.schemaMap = [] |
self.schemaMap = [] |
533 |
|
|
545 |
|
|
546 |
# TODO: Some other form of feedback |
# TODO: Some other form of feedback |
547 |
if not hasattr(self.editor,'_schemaMessageDisplayed'): |
if not hasattr(self.editor,'_schemaMessageDisplayed'): |
548 |
print "You are not logged in to %s... not retrieving schema" % (conn) |
print _("You are not logged in to %s... not retrieving schema") % (conn) |
549 |
self.editor._schemaMessageDisplayed = 1 |
self.editor._schemaMessageDisplayed = 1 |
550 |
|
|
551 |
return |
return |