Index: /waeup/branches/ulif-layout/src/waeup/browser/viewlets.py
===================================================================
--- /waeup/branches/ulif-layout/src/waeup/browser/viewlets.py	(revision 4786)
+++ /waeup/branches/ulif-layout/src/waeup/browser/viewlets.py	(revision 4787)
@@ -30,4 +30,76 @@
 
 #
+# Baseclasses that give some defaults for really used viewlets.
+#
+class ActionButton(grok.Viewlet):
+    """A base for action buttons.
+
+    An action button provides an icon, some text and links to a
+    target.  If you want to set a different text, icon or target name
+    for some active button below, just override the approriate
+    attribute in the concerned viewlet.
+
+    Action buttons provide by default dynamic attributes
+
+     * ``alt``
+          An alternative text for the icon. By default the same as
+          the text.
+
+     * ``icon_url``
+          The URL of the icon.
+
+     * ``target_url``
+          The URL of the link target.
+
+    """
+    grok.baseclass()
+    grok.context(IWAeUPObject)
+    grok.template('actionbutton')
+    grok.viewletmanager(ActionBar)
+    icon = 'actionicon_modify.png' # File must exist in static/
+    target = '@@manage' # link to this viewname.
+    text = 'Edit settings' # Text to display on the button
+
+    @property
+    def alt(self):
+        """Alternative text for icon.
+        """
+        return self.text
+
+    @property
+    def icon_url(self):
+        """Get the icon URL.
+        """
+        return self.view.static[self.icon]()
+
+    @property
+    def target_url(self):
+        """Get a URL to the target...
+        """
+        return self.view.url(self.view.context, self.target)
+
+    
+class ManageActionButton(ActionButton):
+    """A base for 'edit' buttons
+    """
+    grok.baseclass()
+    grok.order(2)
+    grok.require('waeup.manageUniversity')
+    icon = 'actionicon_modify.png'
+    target = '@@manage'
+    text = 'Edit settings'
+
+class AddActionButton(ActionButton):
+    """A base for 'add' buttons.
+    """
+    grok.baseclass()
+    grok.order(4)
+    grok.require('waeup.manageUniversity')
+    icon = 'actionicon_addfavorite.png'
+    target = 'add'
+    text = 'Add'
+
+
+#
 # General viewlets (for more than one page/context)
 #
@@ -153,71 +225,52 @@
 #
 # Manage ("Edit settings") actions...
-#    
-class ManageUniversityAction(grok.Viewlet):
-    grok.viewletmanager(ActionBar)
-    grok.context(IUniversity)
-    grok.view(UniversityPage)
-    grok.require('waeup.manageUniversity')
-    grok.order(2)
-    grok.template('manageaction')
-
-class GoToFacultiesAction(grok.Viewlet):
-    grok.viewletmanager(ActionBar)
-    grok.context(IUniversity)
-    grok.view(UniversityPage)
-    grok.require('waeup.manageUniversity')
-    grok.order(3)
-    grok.template('gotofacultiesaction')
-
-class ManageFacultiesAction(ManageUniversityAction):
+#
+class ManageUniversityActionButton(ManageActionButton):
+    """ 'Edit settings' button for University instances.
+    """
+    grok.context(IUniversity)
+    grok.view(UniversityPage)
+    
+class ManageFacultiesActionButton(ManageActionButton):
+    """ 'Edit settings' button for faculty container.
+    """
     grok.context(IFacultyContainer)
     grok.view(FacultyContainerPage)
-    grok.template('manageaction')
-
-class ManageDataCenterAction(ManageUniversityAction):
+
+class ManageDataCenterActionButton(ManageActionButton):
+    """ 'Edit settings' button for datacenter.
+    """
     grok.context(IDataCenter)
     grok.view(DatacenterPage)
-    grok.template('manageaction')
-    grok.require('waeup.manageUniversity')
-
-class ManageFacultyAction(ManageUniversityAction):
+    
+class ManageFacultyActionButton(ManageActionButton):
     """ 'Edit settings' button for faculties.
     """
     grok.context(IFaculty)
     grok.view(FacultyPage)
-    grok.template('manageaction')
-    grok.require('waeup.manageUniversity')
-
-class ManageDepartmentAction(ManageUniversityAction):
+
+class ManageDepartmentActionButton(ManageActionButton):
     """ 'Edit settings' button for departments.
     """
     grok.context(IDepartment)
     grok.view(DepartmentPage)
-    grok.template('manageaction')
-    grok.require('waeup.manageUniversity')
-
-class ManageCourseAction(ManageUniversityAction):
+
+class ManageCourseActionButton(ManageActionButton):
     """ 'Edit settings' button for courses.
     """
     grok.context(ICourse)
     grok.view(CoursePage)
-    grok.template('manageaction')
-    grok.require('waeup.manageUniversity')
-
-class ManageCertificateAction(ManageUniversityAction):
+    
+class ManageCertificateActionButton(ManageActionButton):
     """ 'Edit settings' button for certificates.
     """
     grok.context(ICertificate)
     grok.view(CertificatePage)
-    grok.template('manageaction')
-    grok.require('waeup.manageUniversity')
-
-class ManageCertificateCourseAction(ManageUniversityAction):
-    """ 'Edit settings' button for certificatecourses.
+
+class ManageCertificateCourseActionButton(ManageActionButton):
+    """ 'Edit settings' button for certificate courses.
     """
     grok.context(ICertificateCourse)
     grok.view(CertificateCoursePage)
-    grok.template('manageaction')
-    grok.require('waeup.manageUniversity')
 
 #
@@ -285,59 +338,34 @@
         return '%s/@@%s' % (self.view.url(self.view.context), self.addview_name)
 
-class AddFacultiesAction(AddAction):
+class AddFacultyActionButton(AddActionButton):
     grok.context(IFacultyContainer)
     grok.view(FacultyContainerPage)
-    grok.order(4)
-    grok.template('addaction')
-    grok.require('waeup.manageUniversity')
-
-    addview_name = 'add'
-    addlink_text = 'Add faculty'
-
-class AddDepartmentsAction(AddAction):
+    text = 'Add faculty'
+    
+class AddDepartmentActionButton(AddActionButton):
     grok.context(IFaculty)
     grok.view(FacultyPage)
-    grok.order(4)
-    grok.template('addaction')
-    grok.require('waeup.manageUniversity')
-
-    addview_name = 'add'
-    addlink_text = 'Add department'
-
-class AddCertificateAction(AddAction):
-    """Add-certificate button for department index page.
-    """
+    text = 'Add department'
+
+class AddCertificateActionButton(AddActionButton):
     grok.context(IDepartment)
     grok.view(DepartmentPage)
     grok.order(3)
-    grok.template('addaction')
-    grok.require('waeup.manageUniversity')
-
-    addview_name = 'addcertificate'
-    addlink_text = 'Add certificate'
-
-class AddCourseAction(AddAction):
-    """Add-course button for department index page.
-    """
+    text = 'Add certificate'
+    target = 'addcertificate'
+    
+class AddCourseActionButton(AddActionButton):
     grok.context(IDepartment)
     grok.view(DepartmentPage)
     grok.order(4)
-    grok.template('addaction')
-    grok.require('waeup.manageUniversity')
-
-    addview_name = 'addcourse'
-    addlink_text = 'Add course'
-
-class AddCertificateCourseAction(AddAction):
-    """Add-course button for certificate index page.
-    """
+    text = 'Add course'
+    target = 'addcourse'
+
+class AddCertificateActionButton(AddActionButton):
     grok.context(ICertificate)
     grok.view(CertificatePage)
     grok.order(4)
-    grok.template('addaction')
-    grok.require('waeup.manageUniversity')
-
-    addview_name = 'addcertificatecourse'
-    addlink_text = 'Add course'
+    text = 'Add course reference'
+    target = 'addcertificatecourse'
 
 
