View Javadoc

1   /*
2    * Created on 22.04.2004
3    *
4    * To change the template for this generated file go to
5    * Window - Preferences - Java - Code Generation - Code and Comments
6    */
7   package net.stff.ical.gui.struts.actions;
8   
9   import java.io.IOException;
10  
11  import javax.servlet.ServletException;
12  import javax.servlet.http.HttpServletResponse;
13  
14  import net.stff.ical.beans.CalendarData;
15  import net.stff.ical.gui.struts.formbeans.EditCalendarsBean;
16  import net.stff.util.SessionObject;
17  
18  import org.apache.struts.action.ActionForm;
19  import org.apache.struts.action.ActionForward;
20  import org.apache.struts.action.ActionMapping;
21  import org.apache.struts.actions.DispatchAction;
22  
23  /***
24   * @author buntekuh
25   *
26    */
27  public class EditCalendarsAction extends DispatchAction {
28  
29  	public ActionForward add(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
30  		EditCalendarsBean f= (EditCalendarsBean)form;
31  		SessionObject so = SessionObject.get(request);
32  		CalendarData data = (CalendarData)so.getObject("icalData", request);
33  		data.setUser(request.getRemoteUser());
34  		data.getManager().addCalendar(f.getCalname(), request.getRemoteUser());
35   	    
36  		return mapping.findForward("success");
37  	}
38  	
39  	public ActionForward edit(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
40  		
41  		return mapping.findForward("success");
42  	}
43  	
44  	public ActionForward setcolor(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
45  		EditCalendarsBean f= (EditCalendarsBean)form;
46  		SessionObject so = SessionObject.get(request);
47  		CalendarData data = (CalendarData)so.getObject("icalData", request);
48  		data.setUser(request.getRemoteUser());
49  		//ICal cal= data.getManager().getCalendar(f.getSelected());
50  		data.getManager().setColor(f.getSelected(), f.getColor(), request.getRemoteUser());
51  		
52  		return mapping.findForward("success");
53  	}
54  	
55  	public ActionForward check(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
56  	
57  		EditCalendarsBean f= (EditCalendarsBean)form;
58  		SessionObject so = SessionObject.get(request);
59  		CalendarData data = (CalendarData)so.getObject("icalData", request);
60  		data.setUser(request.getRemoteUser());
61  	    
62  		data.getManager().setShown(f.getSelected(), f.isChecked(), request.getRemoteUser());
63  		return mapping.findForward("success");
64  	}
65  	
66  	public ActionForward rename(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
67  		
68  			EditCalendarsBean f= (EditCalendarsBean)form;
69  			SessionObject so = SessionObject.get(request);
70  			CalendarData data = (CalendarData)so.getObject("icalData", request);
71  			data.setUser(request.getRemoteUser());
72  		    
73  			data.getManager().rename(f.getCalname(), f.getNewname(), request.getRemoteUser());
74  			return mapping.findForward("success");
75  		}
76  	public ActionForward delete(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
77  		
78  			EditCalendarsBean f= (EditCalendarsBean)form;
79  			SessionObject so = SessionObject.get(request);
80  			CalendarData data = (CalendarData)so.getObject("icalData", request);
81  			data.setUser(request.getRemoteUser());
82  		    
83  			if ((data.getCurrentICal() != null) && (data.getCurrentICal().getName().equals(f.getCalname()))){
84  				data.setCurrentICal(null);
85  			}
86  			data.getManager().delete(f.getCalname(), request.getRemoteUser());
87  			
88  			return mapping.findForward("success");
89  		}
90  		
91  	public ActionForward select(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
92  		
93  			EditCalendarsBean f= (EditCalendarsBean)form;
94  			SessionObject so = SessionObject.get(request);
95  			CalendarData data = (CalendarData)so.getObject("icalData", request);
96  			data.setUser(request.getRemoteUser());
97  		    
98  			data.setCurrentICal(f.getSelected(), request.getRemoteUser());
99  			data.getManager().setShown(f.getSelected(), true, request.getRemoteUser());
100 			return mapping.findForward("success");
101 		}
102 		
103 	
104 			
105 }