1 14 package org.jahia.services.htmleditors; 15 16 import java.util.Hashtable ; 17 import org.jahia.registries.ServicesRegistry; 18 import java.io.Serializable ; 19 20 28 29 public class JahiaHtmlEditor implements Serializable , HtmlEditor, Comparable { 30 31 private static final org.apache.log4j.Logger logger = 32 org.apache.log4j.Logger.getLogger (JahiaHtmlEditor.class); 33 34 private String id; 35 private String displayName; 36 private String includeFile; 37 private String compatibilityTesterClass; 38 private String baseDirectory; 39 private boolean enableCSS = false; 40 private int rank; 41 private boolean fullScreenOnly = false; 42 private boolean fullScreenCapable = false; 43 private Hashtable cssList = new Hashtable (); 44 45 public JahiaHtmlEditor( String id, 46 String displayName, 47 String baseDirectory, 48 String includeFile, 49 String compatibilityTesterClass, 50 boolean enableCSS, 51 int rank ){ 52 this.id = id; 53 this.displayName = displayName; 54 this.baseDirectory = baseDirectory; 55 this.includeFile = includeFile; 56 this.compatibilityTesterClass = compatibilityTesterClass; 57 this.enableCSS = enableCSS; 58 this.rank = rank; 59 } 60 61 66 public String getId(){ 67 return this.id; 68 } 69 70 75 public String getDisplayName(){ 76 return this.displayName; 77 } 78 79 86 public String getBaseDirectory(){ 87 return this.baseDirectory; 88 } 89 90 99 public String getIncludeFile(){ 100 return this.includeFile; 101 } 102 103 111 public boolean isClientCapable(ClientCapabilities clientCapabilities){ 112 if (compatibilityTesterClass != null) { 113 try { 114 Class compatibilityKlass = Class.forName( 115 compatibilityTesterClass); 116 Object objInstance = compatibilityKlass.newInstance(); 117 if (!(objInstance instanceof EditorCompatibilityTesteable)) { 118 logger.error("The class " + compatibilityTesterClass + " is not an HTML editor compatibility class !"); 119 return false; 120 } 121 EditorCompatibilityTesteable compatibilityTester = (EditorCompatibilityTesteable) objInstance; 122 return compatibilityTester.isCompatible(clientCapabilities); 123 } catch (ClassNotFoundException cnfe) { 124 logger.error("Error while testing HTML editor compatibility with current user's browser platform", cnfe); 125 } catch (InstantiationException ie) { 126 logger.error("Error while creating instance of HTML editor compatibility tester", ie); 127 } catch (IllegalAccessException iae) { 128 logger.error("Error while creating instance of HTML editor compatibility tester", iae); 129 } 130 return false; 131 } else { 132 return true; 133 } 134 } 135 136 142 public boolean isSiteAuthorized(int siteID){ 143 boolean res = ServicesRegistry.getInstance() 144 .getHtmlEditorsService() 145 .isSiteAutorized(siteID,this.getId()); 146 return res; 147 } 148 149 154 public boolean enableCSS(){ 155 return this.enableCSS; 156 } 157 158 162 public int getRank() { 163 return this.rank; 164 } 165 166 public int compareTo(Object o) throws ClassCastException { 167 JahiaHtmlEditor right = (JahiaHtmlEditor) o; 170 if ((getRank() != -1) && (right.getRank() != -1)) { 171 return new Integer (getRank()).compareTo(new Integer (right.getRank())); 172 } 173 return getDisplayName().compareTo(right.getDisplayName()); 174 } 175 176 } 177 | Popular Tags |