KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > content > explorer > component > UIContentEditor


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.portlets.content.explorer.component;
6
7 import org.exoplatform.faces.core.component.UIHtmlTextArea;
8 import org.exoplatform.faces.core.component.UISimpleForm;
9 import org.exoplatform.faces.core.component.model.ComponentCell;
10 import org.exoplatform.faces.core.component.model.FormButton;
11 import org.exoplatform.faces.core.component.model.ListComponentCell;
12 import org.exoplatform.faces.core.component.model.Row;
13 import org.exoplatform.faces.core.event.ExoActionEvent;
14 import org.exoplatform.faces.core.event.ExoActionListener;
15 import org.exoplatform.portlets.content.explorer.component.model.NodeDescriptor;
16 /**
17  * @email: tuan08@users.sourceforge.net
18  * @version: $Id: UIContentEditor.java,v 1.1 2004/07/16 09:51:34 oranheim Exp $
19  */

20 abstract public class UIContentEditor extends UISimpleForm implements ExplorerListener {
21     final static public String JavaDoc PREVIEW_CONTENT_ACTION = "preview" ;
22     final static public String JavaDoc EDIT_CURRENT_CONTENT_ACTION = "editCurrent" ;
23     final static public String JavaDoc SAVE_CONTENT_ACTION = "saveContent" ;
24     final static public String JavaDoc CANCEL_ACTION = "cancel" ;
25     
26     final static public String JavaDoc CONTENT_PREVIEW_RENDERER = "ContentPreviewRenderer" ;
27     final static public String JavaDoc CONTENT_FORM_RENDERER = "SimpleFormRenderer" ;
28
29   protected String JavaDoc contentType_ ;
30   protected UIHtmlTextArea content_ ;
31
32   public UIContentEditor() {
33     super("contentForm", "post", null) ;
34     setId("UIContentEditor") ;
35     setClazz("UIContentEditor") ;
36
37     content_ = new UIHtmlTextArea("content", "", "100%", "400px") ;
38     add(new Row().
39         add(new ComponentCell(this, content_).
40             addColspan("2").addClazz("html-text-area")));
41     add(new Row().
42         add(new ListComponentCell().
43             add(new FormButton("#{UIContentEditor.button.save}", SAVE_CONTENT_ACTION)).
44             add(new FormButton("#{UIContentEditor.button.preview}", PREVIEW_CONTENT_ACTION )).
45             addColspan("2").addAlign("center"))) ;
46     addActionListener(PreviewContentActionListener.class, PREVIEW_CONTENT_ACTION) ;
47     addActionListener(EditCurrentActionListener.class, EDIT_CURRENT_CONTENT_ACTION) ;
48   }
49
50   public String JavaDoc getContent() { return content_.getValue() ; }
51   
52   public void setContent(String JavaDoc s) { content_.setValue(s) ; }
53   
54   public String JavaDoc getContentType() { return contentType_ ; }
55   public void setContentType(String JavaDoc s) {contentType_ = s; }
56
57   public void onModify(UIExplorer uiExplorer, NodeDescriptor node) {}
58   
59   public void onAddChild(UIExplorer uiExplorer, NodeDescriptor node) { }
60   
61   public void onRemove(UIExplorer uiExplorer, NodeDescriptor node) { }
62   
63   static public class PreviewContentActionListener extends ExoActionListener {
64         public void execute(ExoActionEvent event) throws Exception JavaDoc {
65       UIContentEditor uiEditor = (UIContentEditor) event.getComponent() ;
66             uiEditor.setRendererType(CONTENT_PREVIEW_RENDERER) ;
67         }
68     }
69   
70   static public class EditCurrentActionListener extends ExoActionListener {
71         public void execute(ExoActionEvent event) throws Exception JavaDoc {
72       UIContentEditor uiEditor = (UIContentEditor) event.getComponent() ;
73             uiEditor.setRendererType(CONTENT_FORM_RENDERER) ;
74         }
75     }
76 }
Popular Tags