daniel 8 years ago
parent
commit
a263dabccd
  1. 106
      designer/src/com/fr/design/javascript/ListenerEditPane.java
  2. 11
      designer/src/com/fr/design/widget/CellWidgetCardPane.java
  3. 7
      designer_base/src/com/fr/design/gui/frpane/ListenerUpdatePane.java
  4. 6
      designer_base/src/com/fr/design/gui/frpane/UIComboBoxPane.java
  5. 19
      designer_base/src/com/fr/design/javascript/JavaScriptActionPane.java
  6. 15
      designer_base/src/com/fr/design/locale/designer.properties
  7. 16
      designer_base/src/com/fr/design/locale/designer_en_US.properties
  8. 17
      designer_base/src/com/fr/design/locale/designer_ja_JP.properties
  9. 17
      designer_base/src/com/fr/design/locale/designer_ko_KR.properties
  10. 15
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties
  11. 15
      designer_base/src/com/fr/design/locale/designer_zh_TW.properties
  12. 40
      designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java
  13. 31
      designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java

106
designer/src/com/fr/design/javascript/ListenerEditPane.java

@ -6,13 +6,15 @@ import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.fun.JavaScriptActionProvider;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
@ -22,19 +24,14 @@ import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.write.submit.DBManipulationPane;
import com.fr.form.event.Listener;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.js.Commit2DBJavaScript;
import com.fr.js.CustomActionJavaScript;
import com.fr.js.EmailJavaScript;
import com.fr.js.FormSubmitJavaScript;
import com.fr.js.JavaScript;
import com.fr.js.JavaScriptImpl;
public class ListenerEditPane extends BasicBeanPane<Listener> {
private UITextField nameText;
private UIComboBox styleBox;
private CardLayout card;
private List<FurtherBasicBeanPane<? extends JavaScript>> cards;
private JPanel hyperlinkPane;
private JavaScriptImplPane javaScriptPane;
@ -45,11 +42,11 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
// 发送邮件
private EmailPane emailPane;
private static final String JS = Inter.getLocText("JavaScript");
private static final String FORMSUBMIT = Inter.getLocText("JavaScript-Form_Submit");
private static final String DBCOMMIT = Inter.getLocText("JavaScript-Commit_to_Database");
private static final String CUSTOMACTION= Inter.getLocText(new String[]{"Custom", "RWA-Submit"});
private static final String EMAIL = Inter.getLocText("Email_sentEmail");
private static final String JS = Inter.getLocText("FR-Designer_JavaScript");
private static final String FORMSUBMIT = Inter.getLocText("FR-Designer_JavaScript_Form_Submit");
private static final String DBCOMMIT = Inter.getLocText("FR-Designer_JavaScript_Commit_to_Database");
private static final String CUSTOMACTION= Inter.getLocText(new String[]{"FR-Designer_JavaScript_Custom", "FR-Designer_RWA_Submit"});
private static final String EMAIL = Inter.getLocText("FR-Designer_Email_sentEmail");
private Listener listener;
@ -66,6 +63,7 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
* @param defaultArgs 初始化参数
*/
public void initComponents(String[] defaultArgs) {
cards = new ArrayList<FurtherBasicBeanPane<? extends JavaScript>>();
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel namePane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
nameText = new UITextField(8);
@ -74,19 +72,14 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
String[] style = {JS, DBCOMMIT, CUSTOMACTION,EMAIL};
styleBox = new UIComboBox(style);
namePane.add(styleBox);
namePane = GUICoreUtils.createFlowPane(new Component[]{new UILabel(" " + Inter.getLocText("Event_Name") + ":"), nameText, new UILabel(" " + Inter.getLocText("Event_Type") + ":"), styleBox}, FlowLayout.LEFT);
namePane.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("Event_Name_Type")));
namePane = GUICoreUtils.createFlowPane(new Component[]{new UILabel(" " + Inter.getLocText("FR-Designer_Event_Name") + ":"), nameText, new UILabel(" " + Inter.getLocText("FR-Designer_Event_Type") + ":"), styleBox}, FlowLayout.LEFT);
namePane.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("FR-Designer_Event_Name_Type")));
this.add(namePane, BorderLayout.NORTH);
card = new CardLayout();
hyperlinkPane = FRGUIPaneFactory.createCardLayout_S_Pane();
hyperlinkPane.setLayout(card);
// js
javaScriptPane = new JavaScriptImplPane(defaultArgs);
hyperlinkPane.add(JS, javaScriptPane);
// formSubmitScriptPane = new FormSubmitJavaScriptPane(JavaScriptActionPane.defaultJavaScriptActionPane
// .createCallButton());
// hyperlinkPane.add(FORMSUBMIT, formSubmitScriptPane);
// 提交入库
List dbmaniList = new ArrayList();
dbmaniList.add(autoCreateDBManipulationPane());
@ -96,14 +89,17 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
// 自定义事件
customActionPane = new CustomActionPane();
hyperlinkPane.add(CUSTOMACTION, customActionPane);
// 发送邮件
emailPane = new EmailPane();
hyperlinkPane.add(EMAIL,emailPane);
hyperlinkPane.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("JavaScript_Set")));
cards.add(javaScriptPane);
cards.add(commit2DBJavaScriptPane);
cards.add(customActionPane);
cards.add(emailPane);
//其他事件
addOtherEvent();
hyperlinkPane.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("FR-Designer_JavaScript_Set")));
this.add(hyperlinkPane);
styleBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
card.show(hyperlinkPane, styleBox.getSelectedItem().toString());
@ -111,6 +107,19 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
});
}
private void addOtherEvent(){
Set<JavaScriptActionProvider> javaScriptActionProviders = ExtraDesignClassManager.getInstance().getArray(JavaScriptActionProvider.XML_TAG);
if (javaScriptActionProviders != null) {
for (JavaScriptActionProvider jsp : javaScriptActionProviders) {
FurtherBasicBeanPane pane = jsp.getJavaScriptActionPane();
String title = pane.title4PopupWindow();
styleBox.addItem(title);
hyperlinkPane.add(title, pane);
cards.add(pane);
}
}
}
/**
* 根据有无单元格创建 DBManipulationPane
* @return 有单元格有智能添加单元格等按钮返回 SmartInsertDBManipulationPane
@ -122,7 +131,7 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
@Override
protected String title4PopupWindow() {
return Inter.getLocText("Event_Set");
return Inter.getLocText("FR-Designer_Event_Set");
}
@Override
@ -131,47 +140,28 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
if (this.listener == null) {
this.listener = new Listener();
}
this.nameText.setText(listener.getEventName());
JavaScript js = listener.getAction();
if (js instanceof JavaScriptImpl) {
styleBox.setSelectedItem(JS);
card.show(hyperlinkPane, JS);
javaScriptPane.populateBean((JavaScriptImpl)js);
} else if (js instanceof FormSubmitJavaScript){
styleBox.setSelectedItem(FORMSUBMIT);
card.show(hyperlinkPane, FORMSUBMIT);
formSubmitScriptPane.populateBean((FormSubmitJavaScript)js);
} else if (js instanceof Commit2DBJavaScript) {
styleBox.setSelectedItem(DBCOMMIT);
card.show(hyperlinkPane, DBCOMMIT);
commit2DBJavaScriptPane.populateBean((Commit2DBJavaScript)js);
} else if (js instanceof EmailJavaScript){
styleBox.setSelectedItem(EMAIL);
card.show(hyperlinkPane, EMAIL);
emailPane.populateBean((EmailJavaScript)js);
} else if (js instanceof CustomActionJavaScript){
styleBox.setSelectedItem(CUSTOMACTION);
card.show(hyperlinkPane, CUSTOMACTION);
customActionPane.populateBean((CustomActionJavaScript) js);
for (int i = 0; i < this.cards.size(); i++) {
FurtherBasicBeanPane pane = cards.get(i);
if (pane.accept(js)) {
styleBox.setSelectedItem(pane.title4PopupWindow());
card.show(hyperlinkPane, pane.title4PopupWindow());
pane.populateBean(js);
return;
}
}
}
public void checkValid() throws Exception{
this.cards.get(this.styleBox.getSelectedIndex()).checkValid();
}
@Override
public Listener updateBean(){
this.listener.setEventName(this.nameText.getText());
if (ComparatorUtils.equals(styleBox.getSelectedItem(), JS)) {
this.listener.setAction(javaScriptPane.updateBean());
} else if (ComparatorUtils.equals(styleBox.getSelectedItem(), FORMSUBMIT)) {
this.listener.setAction(formSubmitScriptPane.updateBean());
} else if (ComparatorUtils.equals(styleBox.getSelectedItem(), DBCOMMIT)) {
this.listener.setAction(commit2DBJavaScriptPane.updateBean());
} else if (ComparatorUtils.equals(styleBox.getSelectedItem(),EMAIL)){
this.listener.setAction(emailPane.updateBean());
} else if (ComparatorUtils.equals(styleBox.getSelectedItem(), CUSTOMACTION)){
this.listener.setAction(customActionPane.updateBean());
}
FurtherBasicBeanPane<? extends JavaScript> pane = this.cards.get(this.styleBox.getSelectedIndex());
this.listener.setAction(pane.updateBean());
return this.listener;
}
}

11
designer/src/com/fr/design/widget/CellWidgetCardPane.java

@ -51,8 +51,8 @@ public class CellWidgetCardPane extends BasicPane {
formPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
eventTabPane = new WidgetEventPane(pane);
formPane.add(eventTabPane, BorderLayout.CENTER);
tabbedPane.add(Inter.getLocText("Attribute"), attriPane);
tabbedPane.add(Inter.getLocText("Form-Editing_Listeners"), formPane);
tabbedPane.add(Inter.getLocText("FR-Designer_Attribute"), attriPane);
tabbedPane.add(Inter.getLocText("FR-Designer_Form_Editing_Listeners"), formPane);
presPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
cardPaneForPresent = FRGUIPaneFactory.createCardLayout_S_Pane();
@ -88,7 +88,7 @@ public class CellWidgetCardPane extends BasicPane {
widgetPropertyPane = new BasicWidgetPropertySettingPane();
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
northPane.setBorder(BorderFactory.createEmptyBorder(5, 8, 0, 8));
JPanel basic = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Form-Basic_Properties"));
JPanel basic = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Form_Basic_Properties"));
northPane.add(basic);
basic.add(widgetPropertyPane);
attriPane.add(northPane, BorderLayout.NORTH);
@ -155,13 +155,14 @@ public class CellWidgetCardPane extends BasicPane {
*/
public void checkValid() throws Exception {
currentEditorDefinePane.checkValid();
eventTabPane.checkValid();
}
//:jackie 如果选择的项有形态,则将形态面板加入tab面板
private void addPresPane(boolean add) {
if (add) {
tabbedPane.add(this.presPane, 1);
tabbedPane.setTitleAt(1, Inter.getLocText("DS-Dictionary"));
tabbedPane.setTitleAt(1, Inter.getLocText("FR-Designer_DS_Dictionary"));
} else {
tabbedPane.remove(presPane);
}
@ -170,7 +171,7 @@ public class CellWidgetCardPane extends BasicPane {
private void addTreeSettingPane(boolean add) {
if (add) {
tabbedPane.add(this.cardPaneForTreeSetting, 1);
tabbedPane.setTitleAt(1, Inter.getLocText("Create_Tree"));
tabbedPane.setTitleAt(1, Inter.getLocText("FR-Designer_Create_Tree"));
} else {
tabbedPane.remove(this.cardPaneForTreeSetting);
}

7
designer_base/src/com/fr/design/gui/frpane/ListenerUpdatePane.java

@ -29,7 +29,7 @@ public abstract class ListenerUpdatePane extends BasicBeanPane<Listener> {
@Override
protected String title4PopupWindow() {
return Inter.getLocText("Event");
return Inter.getLocText("FR-Designer_Event");
}
@Override
@ -45,4 +45,9 @@ public abstract class ListenerUpdatePane extends BasicBeanPane<Listener> {
return editing;
}
@Override
public void checkValid() throws Exception{
actionPane.checkValid();
}
}

6
designer_base/src/com/fr/design/gui/frpane/UIComboBoxPane.java

@ -133,6 +133,12 @@ public abstract class UIComboBoxPane<T> extends BasicBeanPane<T> {
return cards.get(jcb.getSelectedIndex()).updateBean();
}
@Override
public void checkValid() throws Exception {
cards.get(jcb.getSelectedIndex()).checkValid();
}
public int getSelectedIndex() {
return jcb.getSelectedIndex();
}

19
designer_base/src/com/fr/design/javascript/JavaScriptActionPane.java

@ -43,15 +43,6 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
contentDBManiPane = new ArrayList();
contentDBManiPane.add(createDBManipulationPane());
paneList.add(new Commit2DBJavaScriptPane(this, contentDBManiPane));
paneList.add(new ProcessJSImplPane() {
private static final long serialVersionUID = 1;
@Override
protected Editor[] getCorrespondEditors() {
return isForm() ? ValueEditorPaneFactory.formEditors() : ValueEditorPaneFactory.extendedEditors();
}
}
);
paneList.add(initEmaiPane());
Set<JavaScriptActionProvider> javaScriptActionProviders = ExtraDesignClassManager.getInstance().getArray(JavaScriptActionProvider.XML_TAG);
if (javaScriptActionProviders != null) {
@ -84,14 +75,14 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
* @return 返回按钮对象
*/
public UIButton createCallButton() {
UIButton callButton = new UIButton(Inter.getLocText("Set_Callback_Function"));
UIButton callButton = new UIButton(Inter.getLocText("FR-Designer_Set_Callback_Function"));
callButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final JavaScriptActionPane callPane = new JavaScriptActionPane() {
@Override
protected String title4PopupWindow() {
return Inter.getLocText("Set_Callback_Function");
return Inter.getLocText("FR-Designer_Set_Callback_Function");
}
@Override
@ -162,7 +153,7 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
@Override
protected String title4PopupWindow() {
return Inter.getLocText("Set_Callback_Function");
return Inter.getLocText("FR-Designer_Set_Callback_Function");
}
@Override
@ -179,10 +170,10 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
* 生成界面默认的组建
*
* @return 返回生成的面板
*/
public static JavaScriptActionPane createDefault() {
return new JavaScriptActionPane() {
@Override
public DBManipulationPane createDBManipulationPane() {
return new DBManipulationPane();
@ -190,7 +181,7 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
@Override
protected String title4PopupWindow() {
return Inter.getLocText("Set_Callback_Function");
return Inter.getLocText("FR-Designer_Set_Callback_Function");
}
@Override

15
designer_base/src/com/fr/design/locale/designer.properties

@ -493,3 +493,18 @@ FR-Designer_Exporting=Exporting
FR-Designer_Export-PDF=PDF
FR-Designer_Button_OK=OK
FR-Designer_Button_Cancel=Cancel
FR-Designer_JavaScript=
FR-Designer_JavaScript_Form_Submit=
FR-Designer_JavaScript_Commit_to_Database=
FR-Designer_JavaScript_Custom=
FR-Designer_RWA_Submit=
FR-Designer_Event_Name=
FR-Designer_Event_Type=
FR-Designer_Event_Name_Type=
FR-Designer_JavaScript_Set=
FR-Designer_Attribute=
FR-Designer_Form_Editing_Listeners=
FR-Designer_Form_Basic_Properties=
FR-Designer_DS_Dictionary=
FR-Designer_Create_Tree=
FR-Designer_Set_Callback_Function=

16
designer_base/src/com/fr/design/locale/designer_en_US.properties

@ -493,3 +493,19 @@ FR-Designer_Export-PDF=PDF
FR-Designer_Properties_Mobile=MobileProperties
FR-Designer_Button_OK=OK
FR-Designer_Button_Cancel=Cancel
FR-Designer_JavaScript=JavaScript
FR-Designer_JavaScript_Form_Submit=Form Submit
FR-Designer_JavaScript_Commit_to_Database=Commit to DB
FR-Designer_JavaScript_Custom=Custom
FR-Designer_RWA_Submit=Submit
FR-Designer_Event_Name=Event Name
FR-Designer_Event_Type=Event Type
FR-Designer_Event_Name_Type=Event Name and Type
FR-Designer_JavaScript_Set=JavaScript Set
FR-Designer_Attribute=Attribute
FR-Designer_Form_Editing_Listeners=Event editing
FR-Designer_Form_Basic_Properties=Basic Property
FR-Designer_DS_Dictionary=Data Dictionary
FR-Designer_Create_Tree=Build Tree
FR-Designer_Set_Callback_Function=Set Callback Function

17
designer_base/src/com/fr/design/locale/designer_ja_JP.properties

@ -471,4 +471,19 @@ FR-Designer_Exported_successfully=\u5C0E\u51FA\u6210\u529F
FR-Designer_Exporting=\u5C0E\u51FA\u3057\u3066\u3044\u307E\u3059
FR-Designer_Export-PDF=PDF\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8FR-Designer_Button_OK=FR-Designer_Button_OK=\u78BA\u5B9A
FR-Designer_Button_Cancel=\u30AD\u30E3\u30F3\u30BB\u30EB
\
\uFFFD
FR-Designer_JavaScript=
FR-Designer_JavaScript_Form_Submit=
FR-Designer_JavaScript_Commit_to_Database=
FR-Designer_JavaScript_Custom=
FR-Designer_RWA_Submit=
FR-Designer_Event_Name=
FR-Designer_Event_Type=
FR-Designer_Event_Name_Type=
FR-Designer_JavaScript_Set=
FR-Designer_Attribute=
FR-Designer_Form_Editing_Listeners=
FR-Designer_Form_Basic_Properties=
FR-Designer_DS_Dictionary=
FR-Designer_Create_Tree=
FR-Designer_Set_Callback_Function=

17
designer_base/src/com/fr/design/locale/designer_ko_KR.properties

@ -466,4 +466,19 @@ FR-Designer_Exported_successfully=\uB0B4\uBCF4\uB0B4\uAE30\uC131\uACF5
FR-Designer_Exporting=\uB0B4\uBCF4\uB0B4\uAE30\uC911
FR-Designer_Export-PDF=PDF\uC11C\uC2DDFR-Designer_Properties=\uFFFD
FR-Designer_Button_OK=\uD655\uC778FR-Designer_Button_Cancel=\uCDE8\uC18C
\
\uFFFD
FR-Designer_JavaScript=
FR-Designer_JavaScript_Form_Submit=
FR-Designer_JavaScript_Commit_to_Database=
FR-Designer_JavaScript_Custom=
FR-Designer_RWA_Submit=
FR-Designer_Event_Name=
FR-Designer_Event_Type=
FR-Designer_Event_Name_Type=
FR-Designer_JavaScript_Set=
FR-Designer_Attribute=
FR-Designer_Form_Editing_Listeners=
FR-Designer_Form_Basic_Properties=
FR-Designer_DS_Dictionary=
FR-Designer_Create_Tree=
FR-Designer_Set_Callback_Function=

15
designer_base/src/com/fr/design/locale/designer_zh_CN.properties

@ -497,3 +497,18 @@ FR-Designer_Export-PDF=PDF\u683C\u5F0F
FR-Designer_Properties_Mobile=\u624B\u673A\u5C5E\u6027
FR-Designer_Button_OK=\u786E\u5B9A
FR-Designer_Button_Cancel=\u53D6\u6D88
FR-Designer_JavaScript=JavaScript\u811A\u672C
FR-Designer_JavaScript_Form_Submit=\u8868\u5355\u63D0\u4EA4
FR-Designer_JavaScript_Commit_to_Database=\u63D0\u4EA4\u5165\u5E93
FR-Designer_JavaScript_Custom=\u81EA\u5B9A\u4E49
FR-Designer_RWA_Submit=\u63D0\u4EA4
FR-Designer_Event_Name=\u4E8B\u4EF6\u540D
FR-Designer_Event_Type=\u4E8B\u4EF6\u7C7B\u578B
FR-Designer_Event_Name_Type=\u4E8B\u4EF6\u540D\u5B57\u548C\u7C7B\u578B
FR-Designer_JavaScript_Set=JS\u8BBE\u7F6E
FR-Designer_Attribute=\u5C5E\u6027
FR-Designer_Form_Editing_Listeners=\u4E8B\u4EF6\u7F16\u8F91
FR-Designer_Form_Basic_Properties=\u57FA\u672C\u5C5E\u6027
FR-Designer_DS_Dictionary=\u6570\u636E\u5B57\u5178
FR-Designer_Create_Tree=\u6784\u5EFA\u6811
FR-Designer_Set_Callback_Function=\u8BBE\u7F6E\u56DE\u8C03\u51FD\u6570

15
designer_base/src/com/fr/design/locale/designer_zh_TW.properties

@ -485,3 +485,18 @@ FR-Designer_Export-PDF=PDF\u683C\u5F0F
FR-Designer_Properties_Mobile=\u624B\u6A5F\u5C6C\u6027
FR-Designer_Button_OK=\u78BA\u5B9A
FR-Designer_Button_Cancel=\u53D6\u6D88
FR-Designer_JavaScript=
FR-Designer_JavaScript_Form_Submit=
FR-Designer_JavaScript_Commit_to_Database=
FR-Designer_JavaScript_Custom=
FR-Designer_RWA_Submit=
FR-Designer_Event_Name=
FR-Designer_Event_Type=
FR-Designer_Event_Name_Type=
FR-Designer_JavaScript_Set=
FR-Designer_Attribute=
FR-Designer_Form_Editing_Listeners=
FR-Designer_Form_Basic_Properties=
FR-Designer_DS_Dictionary=
FR-Designer_Create_Tree=
FR-Designer_Set_Callback_Function=

40
designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java

@ -25,13 +25,18 @@ import com.fr.general.*;
import com.fr.plugin.PluginCollector;
import com.fr.plugin.PluginLicenseManager;
import com.fr.plugin.PluginMessage;
import com.fr.design.extra.ChartTypeInterfaceCloseableHandler;
import com.fr.plugin.proxy.PluginInstanceProxyFactory;
import com.fr.plugin.proxy.PluginInvocationHandler;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EnvChangedListener;
import com.fr.stable.StringUtils;
import com.fr.stable.collections.map.CloseableContainedMap;
import com.fr.stable.fun.Authorize;
import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider;
import com.fr.stable.plugin.PluginReadListener;
import com.fr.stable.plugin.PluginSimplify;
import com.fr.stable.plugin.closeable.Closeable;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
@ -43,13 +48,12 @@ import java.util.*;
*/
public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraChartDesignClassManagerProvider {
private static ClassLoader loader = Thread.currentThread().getContextClassLoader();
private static ChartTypeInterfaceManager classManager = null;
private static LinkedHashMap<String, LinkedHashMap<String, IndependentChartUIProvider>> chartTypeInterfaces = new LinkedHashMap<String, LinkedHashMap<String, IndependentChartUIProvider>>();
private static LinkedHashMap<String, CloseableContainedMap<String, IndependentChartUIProvider, LinkedHashMap>> chartTypeInterfaces =
new LinkedHashMap<>();
public synchronized static ChartTypeInterfaceManager getInstance() {
if (classManager == null) {
@ -135,7 +139,8 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
if (chartTypeInterfaces.containsKey(ChartTypeManager.CHART_PRIORITY)){
return;
}
LinkedHashMap<String, IndependentChartUIProvider> chartUIList = new LinkedHashMap<String, IndependentChartUIProvider>();
CloseableContainedMap<String, IndependentChartUIProvider, LinkedHashMap> chartUIList =
new CloseableContainedMap<>(LinkedHashMap.class);
chartUIList.put(ChartConstants.COLUMN_CHART, new ColumnIndependentChartInterface());
chartUIList.put(ChartConstants.LINE_CHART, new LineIndependentChartInterface());
chartUIList.put(ChartConstants.BAR_CHART, new BarIndependentChartInterface());
@ -173,6 +178,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
}
private String getIconPath(String priority, String plotID) {
if (chartTypeInterfaces.get(priority) != null && chartTypeInterfaces.get(priority).get(plotID) != null) {
return chartTypeInterfaces.get(priority).get(plotID).getIconPath();
}else {
@ -184,11 +190,12 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
if (chartTypeInterfaces != null){
if (!chartTypeInterfaces.containsKey(priority)){
//新建一个具体图表列表
LinkedHashMap<String, IndependentChartUIProvider> chartUIList = new LinkedHashMap<String, IndependentChartUIProvider>();
CloseableContainedMap<String, IndependentChartUIProvider, LinkedHashMap> chartUIList
= new CloseableContainedMap<>(LinkedHashMap.class);
chartUIList.put(plotID, provider);
chartTypeInterfaces.put(priority, chartUIList);
}else {
LinkedHashMap<String, IndependentChartUIProvider> chartUIList = chartTypeInterfaces.get(priority);
Map<String, IndependentChartUIProvider> chartUIList = chartTypeInterfaces.get(priority);
if (!chartUIList.containsKey(plotID)) {
chartUIList.put(plotID, provider);
}
@ -210,23 +217,27 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
if (authorize != null) {
PluginLicenseManager.getInstance().registerPaid(authorize, simplify);
}
IndependentChartUIProvider provider = (IndependentChartUIProvider) clazz.newInstance();
if (PluginCollector.getCollector().isError(provider, IndependentChartUIProvider.CURRENT_API_LEVEL, simplify.getPluginName()) || !containsChart(plotID)) {
IndependentChartUIProvider provider = getProxyObj(plotID, simplify, clazz);
if (PluginCollector.getCollector().isError(provider, IndependentChartUIProvider.CURRENT_API_LEVEL, simplify.getPluginName())) {
PluginMessage.remindUpdate(className);
} else {
ChartTypeInterfaceManager.getInstance().addChartTypeInterface(provider, priority, plotID);
addChartTypeInterface(provider, priority, plotID);
}
} catch (ClassNotFoundException e) {
FRLogger.getLogger().error("class not found:" + e.getMessage());
} catch (IllegalAccessException | InstantiationException e) {
FRLogger.getLogger().error("object create error:" + e.getMessage());
} catch (NoSuchMethodException e) {
FRLogger.getLogger().error(e.getMessage());
}
}
}
//UI对应的chart如果没有加载,UI也不必加进去了
private boolean containsChart(String plotID) {
return ChartTypeManager.getInstance().containsPlot(plotID);
private IndependentChartUIProvider getProxyObj(String plotID, PluginSimplify simplify, Class<?> clazz) throws IllegalAccessException, InstantiationException, NoSuchMethodException {
PluginInstanceProxyFactory factory = new PluginInstanceProxyFactory(clazz, simplify);
PluginInvocationHandler handler = new ChartTypeInterfaceCloseableHandler(plotID);
return (IndependentChartUIProvider) factory.addProxy(Closeable.class, handler).getProxyObj();
}
@ -254,7 +265,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
}
String[] names = new String[getChartSize(priority)];
if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority)) {
HashMap<String, IndependentChartUIProvider> chartUIList = chartTypeInterfaces.get(priority);
Map<String, IndependentChartUIProvider> chartUIList = chartTypeInterfaces.get(priority);
Iterator iterator = chartUIList.entrySet().iterator();
int i = 0;
while (iterator.hasNext()){
@ -273,6 +284,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
* @return
*/
public String getTitle4PopupWindow(String priority, String plotID){
if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority) && chartTypeInterfaces.get(priority).containsKey(plotID)) {
IndependentChartUIProvider provider = chartTypeInterfaces.get(priority).get(plotID);
return provider.getPlotTypeTitle4PopupWindow();

31
designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java

@ -0,0 +1,31 @@
package com.fr.design.extra;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.plugin.proxy.CloseableInvocationHandler;
/**
* Created by juhaoyu on 2016/12/27.
*/
public class ChartTypeInterfaceCloseableHandler extends CloseableInvocationHandler {
private final String plotID;
public ChartTypeInterfaceCloseableHandler(String plotID) throws NoSuchMethodException {
super();
this.plotID = plotID;
}
@Override
protected boolean invokeIsClosed() {
//UI对应的chart如果关闭或者不存在,则UI关闭
return super.invokeIsClosed() || !containsChart();
}
private boolean containsChart() {
return ChartTypeManager.getInstance().containsPlot(plotID);
}
}
Loading…
Cancel
Save