zack 6 years ago
parent
commit
ba26e95ea5
  1. 118
      build.xml
  2. 6
      demo-design-rightSelection.iml
  3. 15
      plugin.xml
  4. 18
      pom.xml
  5. BIN
      screenshots/demo.png
  6. 41
      src/main/java/com/fr/plugin/designer/MyActionImpl.java
  7. 46
      src/main/java/com/fr/plugin/designer/MyCopyAction.java
  8. 40
      src/main/java/com/fr/plugin/designer/MyCutAction.java

118
build.xml

@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="jar" name="plugin">
<!-- JDK路径,根据自己机器上实际位置修改-->
<property name="jdk.home" value="D:\Program Files\java\jdk1.8"/>
<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="right_selection"/>
<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}" includeantruntime="false"
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>

6
demo-design-rightSelection.iml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

15
plugin.xml

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin>
<id>com.fr.plugin.designer.right.selection</id>
<name><![CDATA[右键菜单插件]]></name>
<active>yes</active>
<version>1.0</version>
<env-version>9.0</env-version>
<jartime>2018-11-13</jartime>
<vendor>zack</vendor>
<description/>
<change-notes/>
<function-recorder class="com.fr.plugin.designer.MyActionImpl"/>
<extra-designer>
<RightSelectionHandlerProvider class="com.fr.plugin.designer.MyActionImpl"/>
</extra-designer>
</plugin>

18
pom.xml

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.fr.plugin</groupId>
<artifactId>starter</artifactId>
<version>10.0</version>
</parent>
<packaging>jar</packaging>
<artifactId>demo-design-rightSelection</artifactId>
<build>
<!---如果要更改调试插件,改这里的配置就可以了-->
<outputDirectory>E:/默认工程/WebReport90/WEB-INF/plugins/plugin-com.fr.plugin.designer.right.selection-1.0/classes</outputDirectory>
</build>
</project>

BIN
screenshots/demo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

41
src/main/java/com/fr/plugin/designer/MyActionImpl.java

@ -0,0 +1,41 @@
package com.fr.plugin.designer;
import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.TargetComponent;
import com.fr.design.fun.impl.AbstractRightSelectionHandlerProvider;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.BaseFormDesigner;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.selection.SelectableElement;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.FloatSelection;
import com.fr.plugin.transform.ExecuteFunctionRecord;
import com.fr.plugin.transform.FunctionRecorder;
import java.util.List;
@FunctionRecorder
public class MyActionImpl extends AbstractRightSelectionHandlerProvider {
@Override
@ExecuteFunctionRecord
public void dmlMenu(TargetComponent ePane, UIPopupMenu popupMenu) {
popupMenu.add(new MyCopyAction(ePane).createMenuItem());
}
@Override
public boolean accept(SelectableElement selectableElement) {
return selectableElement instanceof CellSelection || selectableElement instanceof FloatSelection;
}
@Override
public void dmlUpdateActions(BaseFormDesigner formDesigner ,List<UpdateAction> actions) {
actions.add(new MyCutAction((FormDesigner) formDesigner));
}
@Override
public boolean accept(BaseFormDesigner formDesigner) {
return formDesigner instanceof FormDesigner;
}
}

46
src/main/java/com/fr/plugin/designer/MyCopyAction.java

@ -0,0 +1,46 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.plugin.designer;
import com.fr.base.BaseUtils;
import com.fr.design.actions.TemplateComponentAction;
import com.fr.design.designer.TargetComponent;
import com.fr.general.Inter;
import javax.swing.KeyStroke;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
/**
* Cut.
*/
public class MyCopyAction extends TemplateComponentAction {
/**
* Constructor
*/
public MyCopyAction(TargetComponent t) {
super(t);
this.setName(Inter.getLocText("新增插件菜单测试"));
this.setMnemonic('T');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER));
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
TargetComponent editPane = getEditingComponent();
if (editPane == null) {
return false;
}
return editPane.cut();
}
@Override
public void actionPerformed(ActionEvent evt) {
System.out.println(111111);
}
}

40
src/main/java/com/fr/plugin/designer/MyCutAction.java

@ -0,0 +1,40 @@
package com.fr.plugin.designer;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UndoableAction;
import com.fr.design.mainframe.FormDesigner;
import com.fr.general.Inter;
import javax.swing.KeyStroke;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
/**
* 注意表单和参数面板的右键扩展必须是UndoableAction的子类
*/
public class MyCutAction extends UndoableAction {
public MyCutAction(FormDesigner t) {
this.setName(Inter.getLocText("M_Edit-Cut"));
this.setMnemonic('T');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER));
}
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("3333333");
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
return false;
}
@Override
public void prepare4Undo() {
}
}
Loading…
Cancel
Save