背景說明
目前插件開發(fā)調(diào)試非常麻煩,需要修改代碼,編譯出class,重新打插件包。然后刪除以前的,安裝最新的。過程繁雜,而且不能調(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)致的問題。如果你有強迫癥,可以把插件相關(guān)的包也全都添加進來。
5、 開發(fā)插件
將代碼添加進工程,
ActualLocaleFinder.java 的代碼為:
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è)計器效果如下圖:

也可以進行debug調(diào)試,比如在代碼中加斷點。


若java debug不會使用,可自行百度。