[cig-commits] r11631 - in cs/portal/trunk/seismo/SeismoWebPortal: . static/css static/icons

leif at geodynamics.org leif at geodynamics.org
Fri Mar 28 19:41:41 PDT 2008


Author: leif
Date: 2008-03-28 19:41:41 -0700 (Fri, 28 Mar 2008)
New Revision: 11631

Modified:
   cs/portal/trunk/seismo/SeismoWebPortal/gui.py
   cs/portal/trunk/seismo/SeismoWebPortal/models.py
   cs/portal/trunk/seismo/SeismoWebPortal/static/css/style.css
   cs/portal/trunk/seismo/SeismoWebPortal/static/icons/model.gif
   cs/portal/trunk/seismo/SeismoWebPortal/views.py
Log:
Began implementing the Event Viewer.


Modified: cs/portal/trunk/seismo/SeismoWebPortal/gui.py
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/gui.py	2008-03-29 00:05:01 UTC (rev 11630)
+++ cs/portal/trunk/seismo/SeismoWebPortal/gui.py	2008-03-29 02:41:41 UTC (rev 11631)
@@ -39,7 +39,7 @@
 
     def icon(self):
         if hasattr(self, 'iconURL'):
-            return '<img src="%s" width=32 height=32 style="vertical-align: bottom;">' % self.iconURL
+            return '<img class="icon" src="%s">' % self.iconURL
         return ''
 
 
@@ -104,8 +104,8 @@
 
 class Directory(Node):
 
-    def __init__(self, name, title, contents):
-        Node.__init__(self, name, title)
+    def __init__(self, name, title, contents, url = None):
+        Node.__init__(self, name, title, url = url)
         self.contents = contents
         
         self.index = {}
@@ -214,3 +214,13 @@
 
 class EventFinder(Navigator):
     iconURL = "/specfem3dglobe/icons/eventfinder.gif"
+
+
+class EventViewer(Navigator):
+    
+    def __init__(self, url, title, root, event):
+        Navigator.__init__(self, url, title, root)
+        self.event = event
+
+    def icon(self):
+        return self.event.icon()

Modified: cs/portal/trunk/seismo/SeismoWebPortal/models.py
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/models.py	2008-03-29 00:05:01 UTC (rev 11630)
+++ cs/portal/trunk/seismo/SeismoWebPortal/models.py	2008-03-29 02:41:41 UTC (rev 11631)
@@ -123,7 +123,7 @@
 
     def icon(self):
         ss = self.singleSource
-        return ss and ss.beachball() or '<img src="/specfem3dglobe/icons/document.gif">'
+        return ss and ss.beachball() or '<img class="icon" src="/specfem3dglobe/icons/document.gif">'
 
     def save(self):
         super(Event, self).save()
@@ -196,7 +196,7 @@
 
     def beachball(self):
         src = "/specfem3dglobe/beachballs/%d.gif" % self.id
-        return """<img src="%s">""" % src
+        return '<img class="icon" src="%s">' % src
 
     def cmtSolution(self):
         from cmt import CMTSolution

Modified: cs/portal/trunk/seismo/SeismoWebPortal/static/css/style.css
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/static/css/style.css	2008-03-29 00:05:01 UTC (rev 11630)
+++ cs/portal/trunk/seismo/SeismoWebPortal/static/css/style.css	2008-03-29 02:41:41 UTC (rev 11631)
@@ -628,8 +628,14 @@
 
 
 
-/* icon views */
+/* icons */
 
+#portal-globalnav img.icon {
+    width: 32px;
+    height: 32px;
+    vertical-align: bottom;
+}
+
 .icon table {
     display: inline;
     text-align: center;

Modified: cs/portal/trunk/seismo/SeismoWebPortal/static/icons/model.gif
===================================================================
(Binary files differ)

Modified: cs/portal/trunk/seismo/SeismoWebPortal/views.py
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/views.py	2008-03-29 00:05:01 UTC (rev 11630)
+++ cs/portal/trunk/seismo/SeismoWebPortal/views.py	2008-03-29 02:41:41 UTC (rev 11631)
@@ -276,7 +276,7 @@
     ModelClass = obj.__class__
 
     specialClasses = {
-        Event: configEvent,
+        Event: eventViewer,
         StationList: configStationList,
         Specfem3DGlobeMesh: configSpecfem3DGlobeMesh,
         Specfem3DGlobeParameters: configSpecfem3DGlobeParameters,
@@ -1107,28 +1107,34 @@
 def eventWindows(event, url, desktop):
     view = gui.ChildWindow(url, "View")
     edit = gui.ChildWindow(url + "edit/", "Edit")
-    properties = gui.ChildWindow(url + "properties/", "Properties")
-    menuBar = [
-        gui.Menu("actionMenu", "actions", "Actions",
-                 [gui.MenuItem(url + "delete/", "Delete"),
-                  ]
-                 ),
-        ]
-    view.menuBar = edit.menuBar = properties.menuBar = menuBar
     desktop.activeWindow.insertWindow(view)
     if event.singleSource:
         desktop.activeWindow.insertWindow(edit)
-    desktop.activeWindow.insertWindow(properties)
-    return view, edit, properties
+    return view, edit
 
 
-def configEvent(event, url, request, path, desktop):
+def eventViewer(event, url, request, path, desktop):
     from list_detail import object_detail
 
     objId = event.id # Ouch!
+
+    eventName = event.fsNode.name
     
+    if event.singleSource:
+        zero = gui.File("mechanism", "Source Mechanism", url = url)
+    else:
+        zero = gui.Directory("sources", "Sources", [], url = url)
+    navtree = gui.Directory("events", "Events", [
+        zero,
+        gui.File("properties", "Properties", url = url + "properties/"),
+        ])
+    appWindow = gui.EventViewer(url, eventName + " - Event Viewer", navtree, event)
+    desktop.insertWindow(appWindow)
+    desktop.selectWindow(appWindow)
+    
     if not path:
-        view, edit, properties = eventWindows(event, url, desktop)
+        appWindow.path.append(zero)
+        view, edit = eventWindows(event, url, desktop)
         return object_detail(
             request,
             desktop,
@@ -1139,13 +1145,22 @@
 
     name = path.pop(0)
     if name == "edit":
-        view, edit, properties = eventWindows(event, url, desktop)
+        appWindow.path.append(zero)
+        view, edit = eventWindows(event, url, desktop)
         return manipulate_event(request, path, desktop, object_id = objId, action = 'edit', window = edit)
     if name == "properties":
-        view, edit, properties = eventWindows(event, url, desktop)
+        appWindow.path.append(navtree.index['properties'])
+        menuBar = [
+            gui.Menu("actionMenu", "actions", "Actions",
+                     [gui.MenuItem(url + "delete/", "Delete"),
+                      ]
+                     ),
+            ]
+        properties = gui.ChildWindow(url + "properties/", "Properties")
+        properties.menuBar = menuBar
+        desktop.activeWindow.insertWindow(properties)
         return manipulate_event(request, path, desktop, object_id = objId, action = 'properties', window = properties)
     if name == "delete":
-        view, edit, properties = eventWindows(event, url, desktop)
         return moveObjectToTrash(event, request, "/specfem3dglobe/home/")
 
     index = Index({
@@ -1166,8 +1181,16 @@
     from list_detail import object_detail
     from create_update import update_object, delete_object
 
+    appWindow = desktop.activeWindow
+
     objId = intOr404(name)
     url = eventUrl + "%d/" % objId
+
+    source = get_object_or_404(Source, id=objId) # Ouch!
+    sourcesFolder = appWindow.root.contents[0]
+    navIcon = gui.File(name, source.eventName, url = url)
+    sourcesFolder.appendNode(navIcon)
+    appWindow.path.extend([sourcesFolder, navIcon])
     
     view = gui.ChildWindow(url, "View")
     edit = gui.ChildWindow(url + "edit/", "Edit")
@@ -1179,8 +1202,8 @@
         ]
     
     view.menuBar = edit.menuBar = menuBar
-    desktop.activeWindow.insertWindow(view)
-    desktop.activeWindow.insertWindow(edit)
+    appWindow.insertWindow(view)
+    appWindow.insertWindow(edit)
 
     if not path:
         return object_detail(request, desktop, view, object_id = objId, queryset = Source.objects.all())



More information about the cig-commits mailing list