72 |
self.connectionNames.sort() |
self.connectionNames.sort() |
73 |
self.connectionCache = {} |
self.connectionCache = {} |
74 |
|
|
75 |
EVT_SIZE(self, self.__OnSize) |
## EVT_SIZE(self, self.__OnSize) |
76 |
|
|
77 |
self.current = None |
self.current = None |
78 |
|
|
79 |
self.scroller = self.scroll = scroll = wxSplitterScrolledWindow(self, -1, |
|
80 |
style=wxVSCROLL|wxNO_BORDER|wxCLIP_CHILDREN) |
self.scroller = scroller = wxSplitterScrolledWindow(self, -1, #(50,50), (350, 250), |
81 |
self.splitter = splitter = wxThinSplitterWindow(scroll, -1, |
style=wxNO_BORDER | wxCLIP_CHILDREN | wxVSCROLL) |
82 |
style=wxSP_3DBORDER|wxCLIP_CHILDREN) |
self.splitter = splitter = wxThinSplitterWindow(scroller, -1, style=wxSP_3DBORDER | wxCLIP_CHILDREN) |
83 |
splitter.SetSashSize(2) |
splitter.SetSashSize(2) |
|
self.tree = tree = TreeCtrl(splitter) |
|
|
list = ListWindow(splitter, -1, |
|
|
style=wxNO_BORDER|wxTR_EDIT_LABELS ) |
|
84 |
|
|
85 |
|
print dir(scroller) |
86 |
|
|
87 |
|
self.tree = tree = TreeCtrl(splitter, self) |
88 |
|
root = self.tree.AddRoot('Schema') |
89 |
|
tree.SetItemHasChildren(root, 1) |
90 |
|
tree.SetPyData(root, self) |
91 |
|
for connection in self.connectionNames: |
92 |
|
ConnectionNode(self, tree, root, connection=connection) |
93 |
|
tree.Expand(root) |
94 |
|
|
95 |
|
|
96 |
|
valueWindow = ListWindow(splitter) |
97 |
|
|
98 |
|
splitter.SplitVertically(tree, valueWindow, 150) |
99 |
|
scroller.SetTargetWindow(tree) |
100 |
|
scroller.EnableScrolling(False, False) |
101 |
|
|
102 |
|
valueWindow.SetTreeCtrl(tree) |
103 |
|
tree.SetCompanionWindow(valueWindow) |
104 |
|
|
105 |
|
sizer = wxBoxSizer(wxVERTICAL) |
106 |
|
sizer.Add(scroller, 1, wxEXPAND|wxALL, 0) |
107 |
|
self.SetAutoLayout(True) |
108 |
|
self.SetSizer(sizer) |
109 |
|
|
|
splitter.SplitVertically(self.tree, list) |
|
|
scroll.SetTargetWindow(tree) |
|
|
scroll.EnableScrolling(1, 1) |
|
|
list.SetTreeCtrl(self.tree) |
|
|
tree.SetCompanionWindow(list) |
|
110 |
|
|
111 |
# EventAware provided by ToolBase |
# EventAware provided by ToolBase |
112 |
## self.registerEventListeners({ |
## self.registerEventListeners({ |
116 |
## 'ObjectDeleted' : self.onDeleteObject, |
## 'ObjectDeleted' : self.onDeleteObject, |
117 |
## }) |
## }) |
118 |
|
|
|
root = self.tree.AddRoot('Schema') |
|
|
tree.SetItemHasChildren(root, 1) |
|
|
tree.SetPyData(root, self) |
|
119 |
self.expanded = 1 |
self.expanded = 1 |
120 |
EVT_TREE_BEGIN_DRAG(self, self.tree.GetId(), self.OnBeginDrag) |
EVT_TREE_BEGIN_DRAG(self, self.tree.GetId(), self.OnBeginDrag) |
121 |
EVT_TREE_BEGIN_RDRAG(self, self.tree.GetId(), self.OnBeginRDrag) |
EVT_TREE_BEGIN_RDRAG(self, self.tree.GetId(), self.OnBeginRDrag) |
|
EVT_TREE_BEGIN_RDRAG(self, self.tree.GetId(), self.OnBeginRDrag) |
|
122 |
|
|
|
for connection in self.connectionNames: |
|
|
ConnectionNode(self, tree, root, connection=connection) |
|
|
|
|
|
splitter.SetSashPosition(100) |
|
|
tree.Expand(root) |
|
123 |
|
|
124 |
def createToolbar(self, parent): |
def createToolbar(self, parent): |
125 |
return _SchemaToolbar(parent, self.instance) |
return _SchemaToolbar(parent, self.instance) |
126 |
|
|
127 |
def __OnSize(self, event): |
def __OnSize(self, event): |
128 |
self.scroll.SetSize(self.GetClientSize()) |
# self.scroll.SetSize(self.GetClientSize()) |
129 |
## self.scroller.SetScrollbars(10,10,10,10) |
# self.scroller.SetScrollbars(10,10,10,10) |
130 |
# This is some hackery since the earlier |
# This is some hackery since the earlier |
131 |
# SetSashPosition is doing absolutely no good :( |
# SetSashPosition is doing absolutely no good :( |
132 |
if self.splitter.GetSashPosition() < 30: |
if self.splitter.GetSashPosition() < 30: |
133 |
self.splitter.SetSashPosition(int(self.splitter.GetSizeTuple()[0]*.6)) |
self.splitter.SetSashPosition(int(self.splitter.GetSizeTuple()[0]*.6)) |
134 |
|
|
135 |
|
event.Skip() |
136 |
|
|
137 |
# Since this class is the root node, we need to |
# Since this class is the root node, we need to |
138 |
# emulate part of the Node class |
# emulate part of the Node class |
139 |
def getColumn(self, i=0): |
def getColumn(self, i=0): |
214 |
|
|
215 |
class TreeCtrl(wxRemotelyScrolledTreeCtrl): |
class TreeCtrl(wxRemotelyScrolledTreeCtrl): |
216 |
|
|
217 |
def __init__(self, parent): |
def __init__(self, parent, tool): |
218 |
wxRemotelyScrolledTreeCtrl.__init__(self, parent, -1, |
wxRemotelyScrolledTreeCtrl.__init__(self, parent, -1, |
219 |
style=wxTR_HAS_BUTTONS|wxTR_NO_LINES| |
style=wxTR_HAS_BUTTONS|wxTR_NO_LINES| #wxTR_HIDE_ROOT| |
220 |
wxTR_ROW_LINES|wxNO_BORDER|wxTR_MULTIPLE) |
wxTR_ROW_LINES|wxNO_BORDER|wxTR_MULTIPLE) |
221 |
|
|
222 |
EVT_TREE_ITEM_EXPANDING(self, self.GetId(), self.OnExpand) |
self.tool = tool |
223 |
|
EVT_TREE_ITEM_EXPANDING(self, self.GetId(), self.__OnExpand) |
224 |
|
|
225 |
|
|
226 |
def OnExpand(self, event): |
def __OnExpand(self, event): |
227 |
parent = event.GetItem() |
parent = event.GetItem() |
228 |
if self.GetChildrenCount(parent) > 0: |
if self.GetChildrenCount(parent) > 0: |
229 |
return |
return |
231 |
node = self.GetPyData(parent) |
node = self.GetPyData(parent) |
232 |
if node and not node.expanded: |
if node and not node.expanded: |
233 |
node.expand() |
node.expand() |
234 |
|
self.tool.scroller.AdjustScrollbars() |
235 |
|
self.tool.splitter.Refresh() |
236 |
|
|
237 |
event.Skip() |
event.Skip() |
238 |
|
|
239 |
|
|
240 |
|
|
241 |
class ListWindow(wxTreeCompanionWindow): |
class ListWindow(wxTreeCompanionWindow): |
242 |
def __init__(self, *args, **parms): |
def __init__(self, parent): |
243 |
wxTreeCompanionWindow.__init__(self, *args, **parms) |
wxTreeCompanionWindow.__init__(self, parent, -1, |
244 |
|
style=wxNO_BORDER ) |
245 |
self.SetBackgroundColour("WHITE") |
self.SetBackgroundColour("WHITE") |
246 |
|
## EVT_ERASE_BACKGROUND(self, self._OnEraseBackground) |
247 |
|
|
248 |
|
def _OnEraseBackground(self, evt): |
249 |
|
pass |
250 |
|
|
251 |
|
|
252 |
# This method is called to draw each item in the value window |
# This method is called to draw each item in the value window |
253 |
def DrawItem(self, dc, itemId, rect): |
def DrawItem(self, dc, itemId, rect): |
254 |
tree = self.GetTreeCtrl() |
tree = self.GetTreeCtrl() |
255 |
if tree: |
if tree: |
256 |
try: |
text = tree.GetPyData(itemId).getColumn() |
257 |
text = tree.GetPyData(itemId).getColumn() |
pen = wxPen(wxSystemSettings_GetSystemColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID) |
258 |
pen = wxPen(wxSystemSettings_GetSystemColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID) |
dc.SetPen(pen) |
259 |
dc.SetPen(pen) |
dc.SetBrush(wxBrush(self.GetBackgroundColour(), wxSOLID)) |
260 |
dc.SetBrush(wxBrush(self.GetBackgroundColour(), wxSOLID)) |
dc.DrawRectangle(rect.x, rect.y, rect.width+1, rect.height+1) |
261 |
dc.DrawRectangle(rect.x, rect.y, rect.width+1, rect.height+1) |
dc.SetTextForeground("BLACK") |
262 |
dc.SetTextForeground("BLACK") |
dc.SetBackgroundMode(wxTRANSPARENT) |
263 |
dc.SetBackgroundMode(wxTRANSPARENT) |
tw, th = dc.GetTextExtent(text) |
264 |
tw, th = dc.GetTextExtent(text) |
x = 5 |
265 |
x = 5 |
y = rect.y + max(0, (rect.height - th) / 2) |
266 |
y = rect.y + max(0, (rect.height - th) / 2) |
dc.DrawText(text, x, y) |
|
dc.DrawText(text, x, y) |
|
|
except: |
|
|
raise |
|
267 |
|
|
268 |
|
|
269 |
|
|
323 |
tree = self.tree |
tree = self.tree |
324 |
schemas = self.dataObject.getSchemaList(self.type) |
schemas = self.dataObject.getSchemaList(self.type) |
325 |
if not schemas: |
if not schemas: |
326 |
return |
return |
327 |
schemas.sort() |
schemas.sort() |
328 |
for schema in schemas: |
for schema in schemas: |
329 |
TableNode(self.navigator, self.tree, self.node, |
TableNode(self.navigator, self.tree, self.node, |