package com.fr.plugin.cell.highlight; import com.fr.base.Style; import com.fr.plugin.ExtraClassManager; import com.fr.plugin.PluginLicense; import com.fr.plugin.PluginLicenseManager; import com.fr.plugin.cell.highlight.fun.MyCellFunctionProcessor; import com.fr.report.cell.cellattr.highlight.AbstractStyleHighlightAction; import com.fr.stable.Constants; import com.fr.stable.fun.FunctionHelper; import com.fr.stable.fun.FunctionProcessor; import com.fr.stable.fun.impl.AbstractFunctionProcessor; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; /** * @author richie * @date 2015-03-26 * @since 8.0 */ public class MyHighlightAction extends AbstractStyleHighlightAction { private static final FunctionProcessor PPP = new AbstractFunctionProcessor() { @Override public int getId() { return FunctionHelper.generateFunctionID(MyConstants.PLUGIN_ID); } @Override public String getLocaleKey() { return "Plugin-Highlight_Align"; } }; private int align = Constants.RIGHT; public MyHighlightAction() { this(Constants.RIGHT, 0); } public MyHighlightAction(int align, int scope) { super(scope); this.align = align; } public int getAlign() { return align; } @Override protected Style modStyle(Style style) { FunctionProcessor processor= ExtraClassManager.getInstance().getFunctionProcessor(); if(processor!=null){ processor.recordFunction(PPP); } PluginLicense pluginLicense = PluginLicenseManager.getInstance().getPluginLicenseByID(MyConstants.PLUGIN_ID); if (pluginLicense != null && pluginLicense.isAvailable()) { return style.deriveHorizontalAlignment(align); } return style; } @Override public void readXML(XMLableReader reader) { if (reader.isChildNode()) { String tagName = reader.getTagName(); if (tagName.equals("MyAlign")) { align = reader.getAttrAsInt("align", Constants.RIGHT); } } } @Override public void writeXML(XMLPrintWriter writer) { writer.startTAG("MyAlign").attr("align", align); writer.end(); } public Object clone() throws CloneNotSupportedException { MyHighlightAction cloned = (MyHighlightAction)super.clone(); cloned.align = align; return cloned; } }