在項目開發(fā)過程中插件調(diào)試非常的麻煩,需要修改里面的代碼,編譯出class,需要重新打包插件。然后把之前的刪除,重新安裝最新的。調(diào)試過程比較繁瑣,而且不能調(diào)試,十分的不方便。下面給大家介紹如何調(diào)試插件。
需要工具:eclipse,finereport報表工具
具體說明
1、 新建工程
新建java工程,在此不贅述
2、 添加依賴,啟動設(shè)計器
若要能啟動設(shè)計器需要依賴的jar包很多。具體如下:
A、 jetty相關(guān)的jar包
B、 設(shè)計器相關(guān)的jar包
C、 其他相關(guān)的jar包
選中如圖所示jar包
3、 添加main函數(shù)
主函數(shù)代碼為:
import com.fr.start.Designer;
public class MainFrame {
publicstatic void main(String[] args) {
newDesigner(args);
}
}
4、 啟動設(shè)計器
效果如下:
注:會有一些報錯,不用關(guān)心,這個是缺少某些插件所依賴的包導(dǎo)致的
比如如上圖,就是缺少文本框身份證驗證插件導(dǎo)致的問題。如果你有強(qiáng)迫癥,可以把插件相關(guān)的包也全都添加進(jìn)來。
5、 開發(fā)插件
將代碼添加進(jìn)工程,
ActualLocaleFinder.java 的代碼為:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package com.fr.plugin.designer; import com.fr.stable.fun.impl.AbstractLocaleFinder; public class ActualLocaleFinder extends AbstractLocaleFinder { @Override /** * 返回路徑 * @return 同上 */ public String find() { return "com/fr/plugin/designer/resource/locale/search" ; } } SearchTemplateAction.java 的代碼為: package com.fr.plugin.designer; import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; import com.fr.general.Inter; import javax.swing.*; import java.awt.event.ActionEvent; /** * Created by Administrator on 2015/7/22 0022. */ public class SearchTemplateAction extends UpdateAction{ public SearchTemplateAction(){ //國際化文件配置在search.properties中 this .setName(Inter.getLocText( "FR-Designer_Template-Tree-Search" )); this .setSmallIcon(BaseUtils.readIcon( "/com/fr/plugin/designer/resource/search.png" )); } @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog( null , "This is Search Demo" ); //TemplateFileTree繼承JTree, 可通過setSelectedTemplatePath選中模板, 可以用遍歷JTree的方法來遍歷該tree. //TemplateFileTree tree = TemplateTreePane.getInstance().getTemplateFileTree(); } } |
如圖中代碼,設(shè)計器效果如下圖:
也可以進(jìn)行debug調(diào)試,比如在代碼中加斷點。
如果大家對java debug不會用的,我再此也不做介紹了,可以到百度搜下。
以上介紹就是調(diào)試報表插件的全部內(nèi)容,希望大家喜歡。