From 23feb71c1abc7c1a1ec076043b2630c92fdaecf1 Mon Sep 17 00:00:00 2001
From: Luke Leighton <lkcl@lkcl.net>
Date: Sun, 12 Sep 2010 16:26:53 +0100
Subject: [PATCH 13/34] simplification and bug-correction on cSimplePanel

---
 gnumed/gnumed/client/ProxiedWeb/gui/GNUmedWeb.py   |    8 ++-
 gnumed/gnumed/client/ProxiedWeb/gui/MainPanel.py   |   68 ++------------------
 .../client/ProxiedWeb/gui/PatientsearchPanel.py    |   11 ++--
 .../gnumed/client/ProxiedWeb/gui/WebguiHelpers.py  |   15 ++--
 .../client/ProxiedWeb/gui/public/gnumedweb.xml     |   47 +++++++++++++-
 5 files changed, 72 insertions(+), 77 deletions(-)

diff --git a/gnumed/gnumed/client/ProxiedWeb/gui/GNUmedWeb.py b/gnumed/gnumed/client/ProxiedWeb/gui/GNUmedWeb.py
index 24a5599..6ffe384 100644
--- a/gnumed/gnumed/client/ProxiedWeb/gui/GNUmedWeb.py
+++ b/gnumed/gnumed/client/ProxiedWeb/gui/GNUmedWeb.py
@@ -21,8 +21,12 @@ class gmTopLevelLayer:
         self.loginpanel = cLoginPanel() # fires logged out on UI load
         self.afterloginpanel = cMainPanel(self, Spacing=8, Width="100%")
 
-        self.maindisplay = DockPanel(HorizontalAlignment=HasAlignment.ALIGN_CENTER,
-                          VerticalAlignment=HasAlignment.ALIGN_MIDDLE, BorderWidth=1, Padding=8,Width="100%") 
+        self.maindisplay = DockPanel(
+                          HorizontalAlignment=HasAlignment.ALIGN_CENTER,
+                          VerticalAlignment=HasAlignment.ALIGN_MIDDLE,
+                          BorderWidth=1,
+                          Padding=8,
+                          Width="100%") 
 
         RootPanel().add(self.maindisplay)
 
diff --git a/gnumed/gnumed/client/ProxiedWeb/gui/MainPanel.py b/gnumed/gnumed/client/ProxiedWeb/gui/MainPanel.py
index 99f3ad3..ece5271 100644
--- a/gnumed/gnumed/client/ProxiedWeb/gui/MainPanel.py
+++ b/gnumed/gnumed/client/ProxiedWeb/gui/MainPanel.py
@@ -4,9 +4,12 @@ from pyjamas.ui.HTML import HTML
 from pyjamas.ui.MenuBar import MenuBar
 from pyjamas.ui.MenuItem import MenuItem
 from pyjamas.ui.DecoratorPanel import DecoratedTabPanel
-from pyjamas.ui.Image import Image
 from pyjamas import Window
 
+from pyjamas.builder.Builder import Builder, HTTPUILoader
+import GMWevents
+import Remote
+
 from TestPanel import cTestPanel
 from PatientsummaryPanel import cPatientsummaryPanel
 from PatientsearchPanel import cPatientsearchPanel
@@ -15,10 +18,8 @@ from SaveCommand import cSaveCommand
 from LogoutCommand import cLogoutCommand
 
 #======================================================
-class cMainPanel(VerticalPanel):
-    def __init__(self, app, **kwargs):
-        self.app = app
-        VerticalPanel.__init__(self, **kwargs)
+class cMainPanel(cOpenCommand, cSaveCommand, cLogoutCommand):
+    def __init__(self):
 
         # tab panel
         self.fTabs = DecoratedTabPanel(Size=("1024px", "100%"))
@@ -35,62 +36,5 @@ class cMainPanel(VerticalPanel):
         self.opencmd = cOpenCommand(app)
         self.logoutcmd = cLogoutCommand(app)
 
-        # menu
-        self.menu = MenuBar()
-
-        menuGNUmed = MenuBar(True)
-        subMenuGoToPlugin = MenuBar(True)
-        subMenuGoToPlugin.addItem("Patient summary", True, self)
-        subMenuGoToPlugin.addItem("<strike>Strikethrough</strike>", True, self)
-        subMenuGoToPlugin.addItem("<u>Underlined</u>", True, self)
-        menuGNUmed.addItem(MenuItem("Go to plugin",subMenuGoToPlugin))
-        menuGNUmed.addItem("Preferences", True, self.opencmd)
-        menuGNUmed.addItem("Logout", True, self.logoutcmd)
-        
-        menuPerson = MenuBar(True)
-        menuPerson.addItem("Register person", True, self)
-        menuPerson.addItem("<font color='#FFFF00'><b>Banana</b></font>", True, self)
-        menuPerson.addItem("<font color='#FFFFFF'><b>Coconut</b></font>", True, self)
-        menuPerson.addItem("<font color='#8B4513'><b>Donut</b></font>", True, self)
-
-        menuEMR = MenuBar(True)
-        menuEMR.addItem("Bling", self)
-        menuEMR.addItem("Ginormous", self)
-        menuEMR.addItem("<code>w00t!</code>", True, self)
-
-        menuCorrespondence = MenuBar(True)
-        subMenu = MenuBar(True)
-        subMenu.addItem("<code>Code</code>", True, self)
-        subMenu.addItem("<strike>Strikethrough</strike>", True, self)
-        subMenu.addItem("<u>Underlined</u>", True, self)
-        menuCorrespondence.addItem(MenuItem("Submenu",subMenu))
-        
-        menuTools = MenuBar(True)
-        menuKnowledge = MenuBar(True)
-        menuOffice = MenuBar(True)
-        menuHelp = MenuBar(True)
-
-
-        self.menu.addItem(MenuItem("GNUmed", menuGNUmed))
-        self.menu.addItem(MenuItem("Person", menuPerson))
-        self.menu.addItem(MenuItem("EMR", menuEMR))
-        self.menu.addItem(MenuItem("Correspondence", menuCorrespondence))
-        self.menu.addItem(MenuItem("Tools", menuTools))
-        self.menu.addItem(MenuItem("Knowledge", menuKnowledge))
-        self.menu.addItem(MenuItem("Office", menuOffice))
-        self.menu.addItem(MenuItem("Help", menuHelp))
-
-        self.menu.setWidth("100%")
-        
         self.searchpanel = cPatientsearchPanel(app)
 
-        # add tabs and menu
-        self.add(self.menu)
-        self.add(self.searchpanel)
-        self.add(self.fTabs)
-
-    #--------------------------------------------------
-    def execute(self):
-        Window.alert("Thank you for selecting a menu item.")
-
-
diff --git a/gnumed/gnumed/client/ProxiedWeb/gui/PatientsearchPanel.py b/gnumed/gnumed/client/ProxiedWeb/gui/PatientsearchPanel.py
index 96ce39b..e41ce19 100644
--- a/gnumed/gnumed/client/ProxiedWeb/gui/PatientsearchPanel.py
+++ b/gnumed/gnumed/client/ProxiedWeb/gui/PatientsearchPanel.py
@@ -9,10 +9,11 @@ from pyjamas.ui.Button import Button
 
 from WebguiHelpers import cSimplePopup
 
+import Remote
+
 #======================================================
 class cPatientsearchPanel(HorizontalPanel):
-    def __init__(self, app, **kwargs):
-        self.app = app
+    def __init__(self, **kwargs):
         HorizontalPanel.__init__(self, **kwargs)
 
 	self.patientphoto = Image("images/empty-face-in-bust.png")
@@ -33,7 +34,7 @@ class cPatientsearchPanel(HorizontalPanel):
         # demonstrate proxy & callMethod()
         if sender == self.search_button:
 		search_term = self.searchbox.getText()
-                id = self.app.remote_py.search_patient(self, search_term)
+                id = Remote.svc.search_patient(self, search_term)
 
     #--------------------------------------------------
     def onRemoteResponse(self, response, request_info):
@@ -55,7 +56,7 @@ class cPatientsearchPanel(HorizontalPanel):
             #self.status.setText("HTTP error %d: %s" % 
             #                    (code, message))
             msg = "HTTP error %d: %s" % (code, message)
-            self.popup = cSimplePopup(app, contents = msg)
+            self.popup = cSimplePopup(contents = msg)
         else:
             code = errobj['code']
             #if message['message'] == 'Cannot request login parameters.':
@@ -64,4 +65,4 @@ class cPatientsearchPanel(HorizontalPanel):
             #    self.status.setText("JSONRPC Error %s: %s" %
             #                    (code, message))
             msg = ("JSONRPC Error %s: %s" % (code, message))
-            self.popup = cSimplePopup(app, contents = msg)
\ No newline at end of file
+            self.popup = cSimplePopup(contents = msg)
diff --git a/gnumed/gnumed/client/ProxiedWeb/gui/WebguiHelpers.py b/gnumed/gnumed/client/ProxiedWeb/gui/WebguiHelpers.py
index 3da5993..d3214b5 100644
--- a/gnumed/gnumed/client/ProxiedWeb/gui/WebguiHelpers.py
+++ b/gnumed/gnumed/client/ProxiedWeb/gui/WebguiHelpers.py
@@ -1,16 +1,17 @@
 from pyjamas.ui.PopupPanel import PopupPanel
+from pyjamas.ui.HTML import HTML
 
 #======================================================
 class cSimplePopup(PopupPanel):
-    def __init__(self, app, contents, **kwargs):
-        self.app = app
-        contents = contents
-        contents.addClickListener(getattr(self, "onClick"))
+    def __init__(self, txt, **kwargs):
+        txt = HTML(txt)
+        txt.addClickListener(self)
 
-        PopupPanel.__init__(self, autoHide=True, **kwargs)
-        self.add(content)
-        self.setStyleName("showcase-popup")
+        PopupPanel.__init__(self, autoHide=True, StyleName="showcase-popup",
+                            **kwargs)
+        self.add(txt)
         self.show()
         
     def onClick(self, sender=None):
         self.hide()
+
diff --git a/gnumed/gnumed/client/ProxiedWeb/gui/public/gnumedweb.xml b/gnumed/gnumed/client/ProxiedWeb/gui/public/gnumedweb.xml
index d3ea67e..0ffaada 100644
--- a/gnumed/gnumed/client/ProxiedWeb/gui/public/gnumedweb.xml
+++ b/gnumed/gnumed/client/ProxiedWeb/gui/public/gnumedweb.xml
@@ -5,7 +5,7 @@
 	<property name="version" value="0.1" />
 </properties>
 <components>
-	<component id="LoginPanel" name="VerticalPanel" type="Panel" index="None" left="313" top="363" visible="True">
+	<component id="LoginPanel" name="VerticalPanel" type="Panel" index="None" left="384" top="455" visible="True">
 		<properties name="elements">
 		</properties>
 		<properties name="layout">
@@ -98,5 +98,50 @@
 			</component>
 		</components>
 	</component>
+	<component id="MainPanel" name="VerticalPanel" type="Panel" index="None" left="374" top="317" visible="True">
+		<properties name="elements">
+		</properties>
+		<properties name="layout">
+			<property name="spacing" value="8" />
+			<property name="padding" value="0" />
+			<property name="width" value="100%" />
+			<property name="border" value="1" />
+		</properties>
+		<properties name="common">
+			<property name="name" value="MainPanel" />
+		</properties>
+		<components>
+			<component id="MenuBar1" name="MenuBar" type="Widget" index="0">
+				<properties name="widget">
+					<property name="0" value="(0, u'GNUmed', u'GNUmed', '')" />
+					<property name="1" value="(1, u'plugin', u'Go To Plugin', '')" />
+					<property name="2" value="(2, u'patientsummary', u'Patient Summary', '')" />
+					<property name="3" value="(1, u'preferences', u'Preferences', '')" />
+					<property name="4" value="(1, u'logout', u'Logout', u'onMenuItemLogout')" />
+					<property name="5" value="(0, u'Person', u'Person', '')" />
+					<property name="6" value="(1, u'registerperson', u'Register Person', u'onMenuItemRegisterPerson')" />
+					<property name="7" value="(0, u'EMR', u'EMR', '')" />
+					<property name="8" value="(0, u'Correspondance', u'Correspondance', '')" />
+					<property name="9" value="(0, u'Tools', u'Tools', '')" />
+					<property name="10" value="(0, u'Knowledge', u'Knowledge', '')" />
+					<property name="11" value="(0, u'Office', u'Office', '')" />
+					<property name="12" value="(0, u'Help', u'Help', '')" />
+					<property name="vertical" value="False" />
+				</properties>
+				<properties name="common">
+					<property name="name" value="MenuBar1" />
+				</properties>
+			</component>
+			<component id="TabPanel1" name="TabPanel" type="Panel" index="1">
+				<properties name="layout">
+					<property name="width" value="100%" />
+					<property name="height" value="100%" />
+				</properties>
+				<properties name="common">
+					<property name="name" value="TabPanel1" />
+				</properties>
+			</component>
+		</components>
+	</component>
 </components>
 </pyjsglade>
-- 
1.7.1

