commit
568ca0d806
17 changed files with 414 additions and 0 deletions
@ -0,0 +1,15 @@ |
|||||||
|
# 自定义条件属性 |
||||||
|
当前已有的条件属性包含下图中的几种类型 |
||||||
|
|
||||||
|
 |
||||||
|
|
||||||
|
在特殊情况下,已有的几种类型并不能完全满足需求,典型的就是,根据不同的条件把单元格内的内容做不同的对齐。 |
||||||
|
这个时候,就可以使用条件属性接口```com.fr.design.fun.HighlightProvider```以及其抽象类```com.fr.design.fun.impl.AbstractHighlightProvider```了。 |
||||||
|
通过这个接口可以制作出如下如所示的插件效果 |
||||||
|
|
||||||
|
 |
||||||
|
|
||||||
|
可以看到多出了一个"我的条件属性"的项,当然这个名字是可以根据实际情况修改的。 |
||||||
|
选择了以后,就可以设置单元格的对齐方式了 |
||||||
|
|
||||||
|
 |
@ -0,0 +1,117 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||||
|
<project basedir="." default="jar" name="plugin"> |
||||||
|
<!-- JDK路径,根据自己机器上实际位置修改--> |
||||||
|
<property name="jdk.home" value="/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home"/> |
||||||
|
|
||||||
|
<property name="libs" value="${basedir}/lib"/> |
||||||
|
<property name="publicLibs" value=""/> |
||||||
|
<property name="destLoc" value="."/> |
||||||
|
<property name="classes" value="classes"/> |
||||||
|
<xmlproperty file="${basedir}/plugin.xml"/> |
||||||
|
<property name="current-version" value="${plugin.version}"/> |
||||||
|
|
||||||
|
<!-- 插件版本--> |
||||||
|
<property name="plugin-version" value="${current-version}"/> |
||||||
|
<!-- 插件名字--> |
||||||
|
<property name="plugin-name" value="align-highlight"/> |
||||||
|
<property name="plugin-jar" value="fr-plugin-${plugin-name}-${plugin-version}.jar"/> |
||||||
|
|
||||||
|
<target name="prepare"> |
||||||
|
<delete dir="${classes}"/> |
||||||
|
<delete dir="fr-plugin-${plugin-name}-${plugin-version}"/> |
||||||
|
<xmlproperty file="${basedir}/plugin.xml"/> |
||||||
|
<delete dir="${destLoc}/${plugin.name}"/> |
||||||
|
</target> |
||||||
|
<path id="compile.classpath"> |
||||||
|
<fileset dir="${libs}"> |
||||||
|
<include name="**/*.jar"/> |
||||||
|
</fileset> |
||||||
|
<fileset dir="${publicLibs}"> |
||||||
|
<include name="**/*.jar"/> |
||||||
|
</fileset> |
||||||
|
</path> |
||||||
|
<patternset id="resources4Jar"> |
||||||
|
<exclude name="**/.settings/**"/> |
||||||
|
<exclude name=".classpath"/> |
||||||
|
<exclude name=".project"/> |
||||||
|
|
||||||
|
<exclude name="**/*.java"/> |
||||||
|
<exclude name="**/*.db"/> |
||||||
|
<exclude name="**/*.g"/> |
||||||
|
<exclude name="**/package.html"/> |
||||||
|
</patternset> |
||||||
|
<target name="copy_resources"> |
||||||
|
<echo message="从${resources_from}拷贝图片,JS,CSS等资源文件"/> |
||||||
|
<delete dir="tmp"/> |
||||||
|
<copy todir="tmp"> |
||||||
|
<fileset dir="${resources_from}\src"> |
||||||
|
<patternset refid="resources4Jar"/> |
||||||
|
</fileset> |
||||||
|
</copy> |
||||||
|
<copy todir="${classes}"> |
||||||
|
<fileset dir="tmp"/> |
||||||
|
</copy> |
||||||
|
<delete dir="tmp"/> |
||||||
|
</target> |
||||||
|
<target name="compile_javas"> |
||||||
|
<echo message="编译${compile_files}下的Java文件"/> |
||||||
|
<javac destdir="${classes}" debug="false" optimize="on" source="${source_jdk_version}" |
||||||
|
target="${target_jdk_version}" |
||||||
|
fork="true" memoryMaximumSize="512m" listfiles="false" srcdir="${basedir}" |
||||||
|
executable="${compile_jdk_version}/bin/javac"> |
||||||
|
<src path="${basedir}/src"/> |
||||||
|
<exclude name="**/.svn/**"/> |
||||||
|
<compilerarg line="-encoding UTF8 "/> |
||||||
|
<classpath refid="compile.classpath"/> |
||||||
|
</javac> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="jar_classes"> |
||||||
|
<echo message="打Jar包:${jar_name}"/> |
||||||
|
<delete file="${basedir}/${jar_name}"/> |
||||||
|
<jar jarfile="${basedir}/${jar_name}"> |
||||||
|
<fileset dir="${classes}"> |
||||||
|
</fileset> |
||||||
|
</jar> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="super_jar" depends="prepare"> |
||||||
|
<antcall target="copy_resources"> |
||||||
|
<param name="resources_from" value="${basedir}"/> |
||||||
|
</antcall> |
||||||
|
<antcall target="compile_javas"> |
||||||
|
<param name="source_jdk_version" value="1.6"/> |
||||||
|
<param name="target_jdk_version" value="1.6"/> |
||||||
|
<param name="compile_jdk_version" value="${jdk.home}"/> |
||||||
|
<param name="compile_files" value="${basedir}/src"/> |
||||||
|
</antcall> |
||||||
|
<echo message="compile plugin success!"/> |
||||||
|
|
||||||
|
<antcall target="jar_classes"> |
||||||
|
<param name="jar_name" value="${plugin-jar}"/> |
||||||
|
</antcall> |
||||||
|
<delete dir="${classes}"/> |
||||||
|
|
||||||
|
</target> |
||||||
|
<target name="jar" depends="super_jar"> |
||||||
|
<antcall target="zip"/> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="zip"> |
||||||
|
<property name="plugin-folder" value="fr-plugin-${plugin-name}-${plugin-version}"/> |
||||||
|
<echo message="----------zip files----------"/> |
||||||
|
<mkdir dir="${plugin-folder}"/> |
||||||
|
<copy todir="${plugin-folder}"> |
||||||
|
<fileset dir="."> |
||||||
|
<include name="${plugin-jar}"/> |
||||||
|
<include name="plugin.xml"/> |
||||||
|
</fileset> |
||||||
|
</copy> |
||||||
|
<zip destfile="${basedir}/${plugin-folder}.zip" basedir="."> |
||||||
|
<include name="${plugin-folder}/*.jar"/> |
||||||
|
<include name="${plugin-folder}/plugin.xml"/> |
||||||
|
</zip> |
||||||
|
<xmlproperty file="${basedir}/plugin.xml"/> |
||||||
|
<move file="${plugin-folder}.zip" todir="${destLoc}/${plugin.name}"/> |
||||||
|
</target> |
||||||
|
</project> |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 63 KiB |
After Width: | Height: | Size: 46 KiB |
@ -0,0 +1,23 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<module type="JAVA_MODULE" version="4"> |
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false"> |
||||||
|
<output url="file://$MODULE_DIR$/../../../env/8.0/WebReport/WEB-INF/classes" /> |
||||||
|
<content url="file://$MODULE_DIR$"> |
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> |
||||||
|
</content> |
||||||
|
<orderEntry type="jdk" jdkName="jdk1.8" jdkType="JavaSDK" /> |
||||||
|
<orderEntry type="sourceFolder" forTests="false" /> |
||||||
|
<orderEntry type="library" name="lib" level="project" /> |
||||||
|
<orderEntry type="module" module-name="base" /> |
||||||
|
<orderEntry type="module" module-name="base-basic" /> |
||||||
|
<orderEntry type="module" module-name="base-calculate" /> |
||||||
|
<orderEntry type="module" module-name="base-data" /> |
||||||
|
<orderEntry type="module" module-name="base-file" /> |
||||||
|
<orderEntry type="module" module-name="base-performance" /> |
||||||
|
<orderEntry type="module" module-name="base-stable" /> |
||||||
|
<orderEntry type="module" module-name="chart-base" /> |
||||||
|
<orderEntry type="module" module-name="designer" /> |
||||||
|
<orderEntry type="module" module-name="engine" /> |
||||||
|
<orderEntry type="module" module-name="designer_base" /> |
||||||
|
</component> |
||||||
|
</module> |
@ -0,0 +1,23 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin> |
||||||
|
<id>com.fr.plugin.cell.highlight.align</id> |
||||||
|
<name><![CDATA[单元格对齐条件属性]]></name> |
||||||
|
<active>yes</active> |
||||||
|
<version>2.1</version> |
||||||
|
<env-version>8.0</env-version> |
||||||
|
<jartime>2016-03-20</jartime> |
||||||
|
<price>1000</price> |
||||||
|
<vendor email="solution@finereport.com">solution.richie</vendor> |
||||||
|
<description><![CDATA[可以设置单元格为左对齐,右对齐以及居中对齐]]></description> |
||||||
|
<change-notes><![CDATA[ |
||||||
|
<p>[2016-01-20]增加了插件功能说明</p> |
||||||
|
<p>[2016-03-21]增加了国际化支持(美国英语)</p> |
||||||
|
]]></change-notes> |
||||||
|
<extra-core> |
||||||
|
<LocaleFinder class="com.fr.plugin.cell.highlight.MyCellHighlightLocaleFinder"/> |
||||||
|
</extra-core> |
||||||
|
<extra-report> |
||||||
|
</extra-report> |
||||||
|
<extra-designer> |
||||||
|
<HighlightProvider class="com.fr.plugin.cell.highlight.MyCellHighlight"/> |
||||||
|
</extra-designer> |
||||||
|
</plugin> |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 4.3 KiB |
@ -0,0 +1,30 @@ |
|||||||
|
package com.fr.plugin.cell.highlight; |
||||||
|
|
||||||
|
import com.fr.design.condition.ConditionAttrSingleConditionPane; |
||||||
|
import com.fr.design.condition.ConditionAttributesPane; |
||||||
|
import com.fr.design.fun.impl.AbstractHighlightProvider; |
||||||
|
import com.fr.stable.fun.Authorize; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author richie |
||||||
|
* @date 2015-03-26 |
||||||
|
* @since 8.0 |
||||||
|
*/ |
||||||
|
@Authorize(callSignKey = MyConstants.PLUGIN_ID) |
||||||
|
public class MyCellHighlight extends AbstractHighlightProvider { |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<?> classForHighlightAction() { |
||||||
|
return MyHighlightAction.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ConditionAttrSingleConditionPane appearanceForCondition(ConditionAttributesPane conditionAttributesPane) { |
||||||
|
return new MyHighlightPane(conditionAttributesPane); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
package com.fr.plugin.cell.highlight; |
||||||
|
|
||||||
|
import com.fr.stable.fun.impl.AbstractLocaleFinder; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 16/1/22. |
||||||
|
*/ |
||||||
|
public class MyCellHighlightLocaleFinder extends AbstractLocaleFinder { |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String find() { |
||||||
|
return "com/fr/plugin/cell/highlight/locale/align"; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,10 @@ |
|||||||
|
package com.fr.plugin.cell.highlight; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 16/3/30. |
||||||
|
*/ |
||||||
|
public class MyConstants { |
||||||
|
|
||||||
|
public static final String PLUGIN_ID = "com.fr.plugin.cell.highlight.align"; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,84 @@ |
|||||||
|
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; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,57 @@ |
|||||||
|
package com.fr.plugin.cell.highlight; |
||||||
|
|
||||||
|
import com.fr.design.condition.ConditionAttrSingleConditionPane; |
||||||
|
import com.fr.design.condition.ConditionAttributesPane; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
import com.fr.design.gui.icombobox.UIDictionaryComboBox; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.report.cell.cellattr.highlight.HighlightAction; |
||||||
|
import com.fr.stable.Constants; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author richie |
||||||
|
* @date 2015-03-26 |
||||||
|
* @since 8.0 |
||||||
|
*/ |
||||||
|
public class MyHighlightPane extends ConditionAttrSingleConditionPane<HighlightAction> { |
||||||
|
private UIDictionaryComboBox<Integer> alignComboBox; |
||||||
|
private JComboBox scopeComboBox; |
||||||
|
|
||||||
|
public MyHighlightPane(ConditionAttributesPane conditionAttributesPane) { |
||||||
|
super(conditionAttributesPane); |
||||||
|
this.alignComboBox = new UIDictionaryComboBox<Integer>( |
||||||
|
new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT}, |
||||||
|
new String[]{ |
||||||
|
Inter.getLocText("Plugin-Highlight_Align_Left"), |
||||||
|
Inter.getLocText("Plugin-Highlight_Align_Center"), |
||||||
|
Inter.getLocText("Plugin-Highlight_Align_Right")} |
||||||
|
); |
||||||
|
add(alignComboBox); |
||||||
|
this.scopeComboBox = new UIComboBox(new String[]{ |
||||||
|
Inter.getLocText("Utils-Current_Cell"), |
||||||
|
Inter.getLocText("Utils-Current_Row"), |
||||||
|
Inter.getLocText("Utils-Current_Column")}); |
||||||
|
|
||||||
|
this.add(this.scopeComboBox); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String nameForPopupMenuItem() { |
||||||
|
return Inter.getLocText("Plugin-Highlight_Align"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populate(HighlightAction condition) { |
||||||
|
MyHighlightAction action = (MyHighlightAction) condition; |
||||||
|
scopeComboBox.setSelectedIndex(action.getScope()); |
||||||
|
alignComboBox.setSelectedItem(action.getAlign()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public HighlightAction update() { |
||||||
|
return new MyHighlightAction(alignComboBox.getSelectedItem(), scopeComboBox.getSelectedIndex()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
package com.fr.plugin.cell.highlight.fun; |
||||||
|
|
||||||
|
import com.fr.plugin.cell.highlight.MyConstants; |
||||||
|
import com.fr.stable.fun.FunctionHelper; |
||||||
|
import com.fr.stable.fun.FunctionProcessor; |
||||||
|
import com.fr.stable.fun.impl.AbstractFunctionProcessor; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 16/1/22. |
||||||
|
*/ |
||||||
|
public class MyCellFunctionProcessor extends AbstractFunctionProcessor { |
||||||
|
|
||||||
|
private static MyCellFunctionProcessor instance = new MyCellFunctionProcessor(); |
||||||
|
|
||||||
|
public static FunctionProcessor getInstance() { |
||||||
|
return instance; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getId() { |
||||||
|
return FunctionHelper.generateFunctionID(MyConstants.PLUGIN_ID); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getLocaleKey() { |
||||||
|
return "Plugin-Highlight_Align"; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,4 @@ |
|||||||
|
Plugin-Highlight_Align=Align |
||||||
|
Plugin-Highlight_Align_Left=Left |
||||||
|
Plugin-Highlight_Align_Center=Center |
||||||
|
Plugin-Highlight_Align_Right=Right |
Loading…
Reference in new issue