1 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 20 abstract public class UIContentEditor extends UISimpleForm implements ExplorerListener { 21 final static public String PREVIEW_CONTENT_ACTION = "preview" ; 22 final static public String EDIT_CURRENT_CONTENT_ACTION = "editCurrent" ; 23 final static public String SAVE_CONTENT_ACTION = "saveContent" ; 24 final static public String CANCEL_ACTION = "cancel" ; 25 26 final static public String CONTENT_PREVIEW_RENDERER = "ContentPreviewRenderer" ; 27 final static public String CONTENT_FORM_RENDERER = "SimpleFormRenderer" ; 28 29 protected String 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 getContent() { return content_.getValue() ; } 51 52 public void setContent(String s) { content_.setValue(s) ; } 53 54 public String getContentType() { return contentType_ ; } 55 public void setContentType(String 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 { 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 { 72 UIContentEditor uiEditor = (UIContentEditor) event.getComponent() ; 73 uiEditor.setRendererType(CONTENT_FORM_RENDERER) ; 74 } 75 } 76 } | Popular Tags |