001: /*
002: * Copyright (C) 2006 Methodhead Software LLC. All rights reserved.
003: *
004: * This file is part of TransferCM.
005: *
006: * TransferCM is free software; you can redistribute it and/or modify it under the
007: * terms of the GNU General Public License as published by the Free Software
008: * Foundation; either version 2 of the License, or (at your option) any later
009: * version.
010: *
011: * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
012: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
013: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
014: * details.
015: *
016: * You should have received a copy of the GNU General Public License along with
017: * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
018: * Fifth Floor, Boston, MA 02110-1301 USA
019: */
020:
021: package com.methodhead.shim;
022:
023: import javax.servlet.http.HttpServletRequest;
024: import javax.servlet.http.HttpServletResponse;
025: import javax.servlet.jsp.JspWriter;
026: import org.apache.struts.action.ActionMapping;
027: import org.apache.struts.action.ActionForward;
028: import org.apache.struts.action.DynaActionForm;
029: import java.io.IOException;
030:
031: /**
032: * A module that can be inserted into a panel and managed by shim.
033: */
034: public interface Module {
035:
036: // constants ////////////////////////////////////////////////////////////////
037:
038: // constructors /////////////////////////////////////////////////////////////
039:
040: // methods //////////////////////////////////////////////////////////////////
041:
042: /**
043: * Returns a short descriptive name for the module.
044: */
045: public String getName();
046:
047: /**
048: * Sets the module's <tt>page</tt> and <tt>panel</tt>. This method is called
049: * before any other operations are performed.
050: */
051: public void init(Page page, String panel);
052:
053: /**
054: * Creates the module. This method is called when a module is instantiated
055: * for a page and panel. The module should be initialized such that future
056: * calls to {@link #configure configure()} and {@link #display display()} are
057: * successful. Note that this method is also called when a template is
058: * changed for a page, giving modules an opportunity to reset (or leave
059: * alone) the data associated with the panel.
060: */
061: public void create();
062:
063: /**
064: * Returns <tt>true</tt> if the module has a configuration interface; that
065: * is, if {@link #configure configure()} actually does something.
066: */
067: public boolean isConfigurable();
068:
069: /**
070: * Manages the configuration interface for the module.
071: */
072: public ActionForward configure(ActionMapping mapping,
073: DynaActionForm form, HttpServletRequest request,
074: HttpServletResponse response);
075:
076: /**
077: * Returns <tt>true</tt> if the module can be updated in the rich text
078: * editor; if so, {@link #update update()} must be implemented.
079: */
080: public boolean isEditable();
081:
082: /**
083: * Updates the module with <tt>text</tt> submitted from the rich text editor.
084: */
085: public void update(String text);
086:
087: /**
088: * Displays the module.
089: */
090: public void display(HttpServletRequest request,
091: HttpServletResponse response, JspWriter out)
092: throws IOException;
093:
094: /**
095: * Destroys the module, freeing any resources associated with the module.
096: */
097: public void destroy();
098:
099: /**
100: * Copies any resources associated with the module for <tt>page</tt>.
101: */
102: public void copyTo(Page page);
103: }
|