Changeset 111

Show
Ignore:
Timestamp:
02/07/06 14:47:59
Author:
douglm
Message:

Delete a couple of actions and add action to select view type.
Changes to CalSvc? to support currentView and currentSubscriptions
select calendar actions seesm to work now.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/appcommon/src/org/bedework/appcommon/BedeworkDefs.java

    r2 r111  
    6464  /** These names are internal 
    6565   */ 
    66   public static final String[] viewTypeNames = 
     66  public static final String[] viewPeriodNames = 
    6767    {"todayView", "dayView", "weekView", "monthView", "yearView"}; 
    6868 
     
    8282  public static final int yearView = 4; 
    8383 
    84   /** The default view - this may be redundent 
     84  /** XXX - take out of syspars. The default view - this may be redundent 
    8585   */ 
    8686  public static final int defaultView = weekView; 
     87 
     88  /* Selection type constants */ 
     89 
     90  /** Display using a view */ 
     91  public static final String selectionTypeView = "view"; 
     92 
     93  /** Display using a subscription */ 
     94  public static final String selectionTypeSubscription = "subscription"; 
     95 
     96  /** Display using a calendar */ 
     97  public static final String selectionTypeCalendar = "calendar"; 
     98 
     99  /** Display using a search */ 
     100  public static final String selectionTypeSearch = "search"; 
     101 
     102  /** Display using a 'filter' */ 
     103  public static final String selectionTypeFiltered = "filtered"; 
    87104} 
    88105 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/BwCalendar.java

    r99 r111  
    5656import org.bedework.calfacade.base.BwShareableContainedDbentity; 
    5757 
     58import java.net.URLEncoder; 
    5859import java.util.Collection; 
    5960import java.util.Iterator; 
     
    325326  } 
    326327 
     328  /** Generate an encoded url referring to this calendar. 
     329   * 
     330   * XXX This should not be here 
     331   * @return String encoded url (or path) 
     332   * @throws CalFacadeException 
     333   */ 
     334  public String getEncodedPath() throws CalFacadeException { 
     335    try { 
     336      return URLEncoder.encode(getPath(), "UTF-8"); 
     337    } catch (Throwable t) { 
     338      throw new CalFacadeException(t); 
     339    } 
     340  } 
     341 
    327342  /** Create a copy of this object but do not clone the children 
    328343   * 
  • trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java

    r86 r111  
    137137  private BwView currentView; 
    138138 
     139  private Collection currentSubscriptions; 
     140 
    139141  /** Used to see if applications need to force a refresh 
    140142   */ 
     
    623625    } 
    624626 
     627    if ((path.length() > 1) && 
     628        (path.startsWith(CalFacadeDefs.bwUriPrefix))) { 
     629      path = path.substring(CalFacadeDefs.bwUriPrefix.length()); 
     630    } 
     631 
    625632    if ((path.length() > 1) && path.endsWith("/")) { 
    626633      return getCal().getCalendar(path.substring(0, path.length() - 1)); 
     
    723730  } 
    724731 
    725   public void setCurrentView(BwView val) throws CalFacadeException { 
    726     currentView = val; 
    727   } 
     732  public BwView findView(String val) throws CalFacadeException { 
     733    if (val == null) { 
     734      BwPreferences prefs = getPreferences(); 
     735 
     736      val = prefs.getPreferredView(); 
     737      if (val == null) { 
     738        return null; 
     739      } 
     740    } 
     741 
     742    Collection views = getViews(); 
     743    Iterator it = views.iterator(); 
     744    while (it.hasNext()) { 
     745      BwView view = (BwView)it.next(); 
     746 
     747      if (view.getName().equals(val)) { 
     748        return view; 
     749      } 
     750    } 
     751 
     752    return null; 
     753  } 
     754 
     755  public boolean addViewSubscription(String name, 
     756                                     BwSubscription sub) throws CalFacadeException { 
     757 
     758    BwPreferences prefs = getPreferences(); 
     759    checkOwnerOrSuper(prefs); 
     760 
     761    BwView view = findView(name); 
     762 
     763    if (view == null) { 
     764      return false; 
     765    } 
     766 
     767    view.addSubscription(sub); 
     768 
     769    dbi.updatePreferences(prefs); 
     770 
     771    return true; 
     772  } 
     773 
     774  public boolean removeViewSubscription(String name, 
     775                                        BwSubscription sub) throws CalFacadeException { 
     776 
     777    BwPreferences prefs = getPreferences(); 
     778    checkOwnerOrSuper(prefs); 
     779 
     780    BwView view = findView(name); 
     781 
     782    if (view == null) { 
     783      return false; 
     784    } 
     785 
     786    view.removeSubscription(sub); 
     787 
     788    dbi.updatePreferences(prefs); 
     789 
     790    return true; 
     791  } 
     792 
     793  public Collection getViews() throws CalFacadeException { 
     794    return getPreferences().getViews(); 
     795  } 
     796 
     797  /* ==================================================================== 
     798   *                   Current selection 
     799   * This defines how we select events to display. 
     800   * ==================================================================== */ 
    728801 
    729802  public boolean setCurrentView(String val) throws CalFacadeException { 
     
    739812      if (val.equals(view.getName())) { 
    740813        currentView = view; 
     814        currentSubscriptions = null; 
    741815 
    742816        if (debug) { 
     
    752826  } 
    753827 
    754   public BwView findView(String val) throws CalFacadeException { 
    755     if (val == null) { 
    756       BwPreferences prefs = getPreferences(); 
    757  
    758       val = prefs.getPreferredView(); 
    759       if (val == null) { 
    760         return null; 
    761       } 
    762     } 
    763  
    764     Collection views = getViews(); 
    765     Iterator it = views.iterator(); 
    766     while (it.hasNext()) { 
    767       BwView view = (BwView)it.next(); 
    768  
    769       if (view.getName().equals(val)) { 
    770         return view; 
    771       } 
    772     } 
    773  
    774     return null; 
    775   } 
    776  
    777   public boolean addViewSubscription(String name, 
    778                                      BwSubscription sub) throws CalFacadeException { 
    779  
    780     BwPreferences prefs = getPreferences(); 
    781     checkOwnerOrSuper(prefs); 
    782  
    783     BwView view = findView(name); 
    784  
    785     if (view == null) { 
    786       return false; 
    787     } 
    788  
    789     view.addSubscription(sub); 
    790  
    791     dbi.updatePreferences(prefs); 
    792  
    793     return true; 
    794   } 
    795  
    796   public boolean removeViewSubscription(String name, 
    797                                         BwSubscription sub) throws CalFacadeException { 
    798  
    799     BwPreferences prefs = getPreferences(); 
    800     checkOwnerOrSuper(prefs); 
    801  
    802     BwView view = findView(name); 
    803  
    804     if (view == null) { 
    805       return false; 
    806     } 
    807  
    808     view.removeSubscription(sub); 
    809  
    810     dbi.updatePreferences(prefs); 
    811  
    812     return true; 
    813   } 
    814  
    815828  public BwView getCurrentView() throws CalFacadeException { 
    816829    return currentView; 
    817830  } 
    818831 
    819   public Collection getViews() throws CalFacadeException { 
    820     return getPreferences().getViews(); 
     832  public void setCurrentSubscriptions(Collection val) throws CalFacadeException { 
     833    currentSubscriptions = val; 
     834    if (val != null) { 
     835      currentView = null; 
     836    } 
     837  } 
     838 
     839  public Collection getCurrentSubscriptions() throws CalFacadeException { 
     840    return currentSubscriptions; 
    821841  } 
    822842 
     
    13931413      it = currentView.iterateSubscriptions(); 
    13941414    } else { 
    1395       Collection subs = getSubscriptions(); 
     1415      Collection subs = getCurrentSubscriptions(); 
     1416      if (subs == null) { 
     1417        // Try set of users subscriptions. 
     1418        subs = getSubscriptions(); 
     1419      } 
     1420 
    13961421      if (subs == null) { 
    13971422        sub = new BwSubscription(); 
  • trunk/calendar3/calsvci/src/org/bedework/calsvci/CalSvcI.java

    r55 r111  
    589589  public abstract boolean removeView(BwView val) throws CalFacadeException; 
    590590 
    591   /** Set the view we are interested in. null means reset to default. 
    592    * 
    593    * @param  val     BwView - null for default 
    594    * @throws CalFacadeException 
    595    */ 
    596   public abstract void setCurrentView(BwView val) throws CalFacadeException; 
    597  
    598   /** Set the view to the given named view. null means reset to default. 
    599    * 
    600    * @param  val     String view name - null for default 
    601    * @return boolean false - view not found. 
    602    * @throws CalFacadeException 
    603    */ 
    604   public abstract boolean setCurrentView(String val) throws CalFacadeException; 
    605  
    606591  /** Find the named view. 
    607592   * 
     
    632617                                                 BwSubscription sub) throws CalFacadeException; 
    633618 
     619  /** Return the collection of views - named collections of subscriptions 
     620   * 
     621   * @return collection of views 
     622   * @throws CalFacadeException 
     623   */ 
     624  public abstract Collection getViews() throws CalFacadeException; 
     625 
     626  /* ==================================================================== 
     627   *                   Current selection 
     628   * This defines how we select events to display. 
     629   * ==================================================================== */ 
     630 
     631  /** Set the view to the given named view. Null means reset to default. 
     632   * Unset current subscriptions. 
     633   * 
     634   * @param  val     String view name - null for default 
     635   * @return boolean false - view not found. 
     636   * @throws CalFacadeException 
     637   */ 
     638  public abstract boolean setCurrentView(String val) throws CalFacadeException; 
     639 
    634640  /** Get the current view we have set 
    635641   * 
     
    639645  public abstract BwView getCurrentView() throws CalFacadeException; 
    640646 
    641   /** Return the collection of views - named collections of subscriptions 
    642    * 
    643    * @return collection of views 
    644    * @throws CalFacadeException 
    645    */ 
    646   public abstract Collection getViews() throws CalFacadeException; 
     647  /** Set the view to the given collection of subscriptions. 
     648   * Unset current view. 
     649   * 
     650   * @param  val     Collection 
     651   * @throws CalFacadeException 
     652   */ 
     653  public abstract void setCurrentSubscriptions(Collection val) 
     654          throws CalFacadeException; 
     655 
     656  /** Get the current subscriptions we have set 
     657   * 
     658   * @return Collection of BwSubscription or null 
     659   * @throws CalFacadeException 
     660   */ 
     661  public abstract Collection getCurrentSubscriptions() throws CalFacadeException; 
    647662 
    648663  /* ==================================================================== 
  • trunk/calendar3/webclient/war/WEB-INF/struts-config.xml

    r104 r111  
    196196 
    197197    <action    path="/setSelection" 
    198                type="org.bedework.webclient.BwSelectViewAction" 
    199                name="calForm" 
    200                scope="session" 
    201                validate="false"> 
    202       <forward name="noViewDef" path="/showMain.rdo" redirect="true" /> 
     198               type="org.bedework.webcommon.misc.SetSelectionAction" 
     199               name="calForm" 
     200               scope="session" 
     201               validate="false"> 
     202      <forward name="notFound" path="/showMain.rdo" redirect="true" /> 
    203203    </action> 
    204204 
  • trunk/calendar3/webclient/war/docs/emitCalendar.jsp

    r92 r111  
    1010  <calendarCollection><bean:write name="calendar" property="calendarCollection" /></calendarCollection> 
    1111  <mailListId><bean:write name="calendar" property="mailListId" /></mailListId> 
     12  <url><bean:write name="calendar" property="encodedPath" /></url> 
    1213 
    1314  <logic:iterate name="calendar" property="children" id="cal"> 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/BwAbstractAction.java

    r65 r111  
    328328  } 
    329329 
     330  protected BwCalendar findCalendar(String url, 
     331                             BwActionFormBase form) throws CalFacadeException { 
     332    if (url == null) { 
     333      return null; 
     334    } 
     335 
     336    CalSvcI svci = form.fetchSvci(); 
     337 
     338    return svci.getCalendar(url); 
     339  } 
     340 
    330341  /** Return null if group is chosen else return a forward name. 
    331342   * 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/BwActionFormBase.java

    r55 r111  
    9898 * @author  Mike Douglass     douglm@rpi.edu 
    9999 */ 
    100 public class BwActionFormBase extends UtilActionForm
     100public class BwActionFormBase extends UtilActionForm implements BedeworkDefs
    101101  /** This object will be set up appropriately for the kind of client, 
    102102   * e.g. admin, guest etc. 
     
    284284 
    285285  /* .................................................................... 
     286   *                       Selection type 
     287   * .................................................................... */ 
     288 
     289  // ENUM 
     290  private String selectionType = selectionTypeView; 
     291 
     292  /* .................................................................... 
    286293   *                       View period 
    287294   * .................................................................... */ 
     
    290297 
    291298  static { 
    292     for (int i = 0; i < BedeworkDefs.viewTypeNames.length; i++) { 
    293       viewTypeMap.put(BedeworkDefs.viewTypeNames[i], new Integer(i)); 
     299    for (int i = 0; i < BedeworkDefs.viewPeriodNames.length; i++) { 
     300      viewTypeMap.put(BedeworkDefs.viewPeriodNames[i], new Integer(i)); 
    294301    } 
    295302  } 
     
    908915   */ 
    909916  public String[] getViewTypeNames() { 
    910     return BedeworkDefs.viewTypeNames; 
     917    return BedeworkDefs.viewPeriodNames; 
    911918  } 
    912919 
     
    916923   */ 
    917924  public String getViewTypeName(int i) { 
    918     return BedeworkDefs.viewTypeNames[i]; 
     925    return BedeworkDefs.viewPeriodNames[i]; 
    919926  } 
    920927 
     
    990997    } 
    991998 
    992     return BedeworkDefs.viewTypeNames[vt]; 
     999    return BedeworkDefs.viewPeriodNames[vt]; 
    9931000  } 
    9941001 
     
    10621069        curViewPeriod = -1; 
    10631070 
    1064         for (int i = 1; i < BedeworkDefs.viewTypeNames.length; i++) { 
    1065           if (BedeworkDefs.viewTypeNames[i].startsWith(vn)) { 
     1071        for (int i = 1; i < BedeworkDefs.viewPeriodNames.length; i++) { 
     1072          if (BedeworkDefs.viewPeriodNames[i].startsWith(vn)) { 
    10661073            curViewPeriod = i; 
    10671074            break; 
     
    11941201  } 
    11951202 
     1203  /* .................................................................... 
     1204   *                       Selection type 
     1205   * .................................................................... */ 
     1206 
     1207  /** 
     1208   * @param val 
     1209   */ 
     1210  public void setSelectionType(String val) { 
     1211    selectionType = val; 
     1212  } 
     1213 
     1214  /** 
     1215   * @return String 
     1216   */ 
     1217  public String getSelectionType() { 
     1218    return selectionType; 
     1219  } 
     1220 
    11961221  /* ==================================================================== 
    11971222   *                   Views