Browse Source

Merge branch 'release/10.0' of http://cloud.finedevelop.com:2015/scm/~mata.li/designrel into release/10.0

final/10.0
Mata.Li 6 years ago
parent
commit
0714eea7b0
  1. 6
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java
  2. 59
      designer-base/src/main/java/com/fr/design/gui/HyperlinkFilterHelper.java
  3. 475
      designer-base/src/main/java/com/fr/design/gui/columnrow/ColumnRowPane.java
  4. 38
      designer-base/src/main/java/com/fr/design/gui/controlpane/NameableCreator.java
  5. 6
      designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/OldShortCutFactory.java
  6. 25
      designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/ShortCutFactory.java
  7. 33
      designer-base/src/main/java/com/fr/design/gui/frpane/BaseHyperlinkGroup.java
  8. 22
      designer-base/src/main/java/com/fr/design/gui/frpane/HyperLinkGroupFilter.java
  9. 19
      designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupType.java
  10. 39
      designer-base/src/main/java/com/fr/design/gui/frpane/UICorrelationComboBoxPane.java
  11. 16
      designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java
  12. 12
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/DataPaneHelper.java
  13. 83
      designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java
  14. 8
      designer-chart/src/main/java/com/fr/design/module/FormHyperlinkGroup.java
  15. 23
      designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java
  16. 32
      designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java
  17. 44
      designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java
  18. 22
      designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartShortCutFactory.java
  19. 16
      designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapHyperLinkPane.java
  20. 260
      designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java
  21. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java
  22. 17
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  23. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java
  24. 16
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java
  25. 16
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java
  26. 15
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManeger.java
  27. 94
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java
  28. 80
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/SearchManegerTest.java

6
designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java

@ -35,6 +35,7 @@ public class JDBCDefPane extends JPanel {
public static final String DRIVER_TYPE = "driver_type";
public static final String USER_NAME = "user_name";
public static final int TIME_MULTIPLE = 1000;
private static final String EMPTY_DB = StringUtils.EMPTY;
private static Map<String, DriverURLName[]> jdbcMap = new HashMap<String, DriverURLName[]>();
@ -64,7 +65,7 @@ public class JDBCDefPane extends JPanel {
private UITextField userNameTextField;
private JPasswordField passwordTextField;
// 请不要改动dbtype,只应该最后添加
private final String[] dbtype = {"", "Oracle", "DB2", "SQL Server", "MySQL", "Sybase", "Access", "Derby", "Postgre","SQLite","Inceptor", "Others"};
private final String[] dbtype = {EMPTY_DB, "Oracle", "DB2", "SQL Server", "MySQL", "Sybase", "Access", "Derby", "Postgre","SQLite","Inceptor", "Others"};
// carl:DBCP的一些属性
private IntegerEditor DBCP_INITIAL_SIZE = new IntegerEditor();
@ -182,6 +183,9 @@ public class JDBCDefPane extends JPanel {
break;
}
}
if (!out) {
this.dbtypeComboBox.setSelectedItem(EMPTY_DB);
}
}
this.driverComboBox.setSelectedItem(jdbcDatabase.getDriver());
this.urlTextField.setText(jdbcDatabase.getURL());

59
designer-base/src/main/java/com/fr/design/gui/HyperlinkFilterHelper.java

@ -1,59 +0,0 @@
package com.fr.design.gui;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.general.ComparatorUtils;
/**
* Created by mengao on 2017/9/22.
* 单元格超链图表超链在不同类型模版中下拉选项不同
*/
public class HyperlinkFilterHelper {
public static boolean whetherAddHyperlink4cell(String itemName) {
JTemplate jTemplate = getCurrentEditingTemplate();
if (jTemplate == null) {
return false;
}
//先屏蔽掉这个,之后还有别的
String[] names = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ Hyperlink_Chart_Float")};
for (String name : names) {
if (!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, name)) {
return false;
}
}
return whetherAddFormLink(jTemplate, itemName);
}
public static boolean whetherAddHyperlink4Chart(String itemName) {
JTemplate jTemplate = getCurrentEditingTemplate();
if (jTemplate == null) {
return false;
}
//先屏蔽掉这个,之后还有别的
String[] names = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ Hyperlink_Chart_Float"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Chart_Cell")};
for (String name : names) {
if (!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, name)) {
if (jTemplate.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB && ComparatorUtils.equals(itemName, names[0])) {
//表单报表块中图表悬浮元素超链,只屏蔽联动悬浮元素
return false;
} else if (jTemplate.getEditingReportIndex() == BaseJForm.FORM_TAB) {
//表单图表超链屏蔽掉联动悬浮元素和联动单元格
return false;
}
}
}
return whetherAddFormLink(jTemplate, itemName);
}
private static JTemplate getCurrentEditingTemplate() {
return HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
}
private static boolean whetherAddFormLink(JTemplate jTemplate, String itemName) {
String formName = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Form_Link");
return !(jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, formName));
}
}

475
designer-base/src/main/java/com/fr/design/gui/columnrow/ColumnRowPane.java

@ -1,8 +1,17 @@
package com.fr.design.gui.columnrow;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ispinner.ColumnRowSpinner;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.gui.ispinner.UpperCaseSpinner;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.stable.ColumnRow;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import javax.swing.JFormattedTextField;
import javax.swing.JPanel;
@ -16,19 +25,9 @@ import javax.swing.text.AbstractDocument;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.DocumentFilter;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.gui.ispinner.UpperCaseSpinner;
import com.fr.design.gui.ispinner.ColumnRowSpinner;
import com.fr.general.ComparatorUtils;
import com.fr.stable.ColumnRow;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
/**
* the component to edit ColumnRow
@ -37,224 +36,228 @@ import com.fr.design.utils.gui.GUICoreUtils;
*/
public class ColumnRowPane extends JPanel implements UIObserver {
private static final long serialVersionUID = 1L;
private static String[] columnarray = new String[1000];
private static String[] rowarray = new String[5000];
protected UpperCaseSpinner columnSpinner;
protected UIBasicSpinner rowSpinner;
static {
for (int i = 1; i < 1000; i++) {
columnarray[i - 1] = StableUtils.convertIntToABC(i);
}
for (int i = 1; i < 5000; i++) {
rowarray[i - 1] = StringUtils.EMPTY + i;
}
}
protected DocumentListener d = new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
String rolText = ((DefaultEditor) columnSpinner.getEditor()).getTextField().getText();
String rowText = ((DefaultEditor) rowSpinner.getEditor()).getTextField().getText();
if (rolText == null || rolText.length() == 0 || rowText == null || rowText.length() == 0) {
return;
}
int col = StableUtils.convertABCToInt(rolText) - 1;
int row = Integer.parseInt(rowText) - 1;
setColumnRow(ColumnRow.valueOf(col, row));
}
@Override
public void insertUpdate(DocumentEvent e) {
int col = StableUtils.convertABCToInt(((DefaultEditor) columnSpinner.getEditor()).getTextField().getText()) - 1;
int row = Integer.parseInt(((DefaultEditor) rowSpinner.getEditor()).getTextField().getText()) - 1;
setColumnRow(ColumnRow.valueOf(col, row));
}
@Override
public void changedUpdate(DocumentEvent e) {
}
};
private UIObserverListener uiObserverListener;
private ColumnRow cr;
public ColumnRowPane() {
this.initComponents();
iniListener();
}
/**
* 初始化元素
*/
public void initComponents() {
this.setLayout(new GridLayout(0, 2, IntervalConstants.INTERVAL_L6, 0));
initColSpinner();
this.add(columnSpinner, BorderLayout.WEST);
initRowSpinner();
this.add(rowSpinner);
this.addDocumentListener(d);
}
private void iniListener() {
if (shouldResponseChangeListener()) {
this.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (uiObserverListener == null) {
return;
}
uiObserverListener.doChange();
}
});
}
}
protected void initRowSpinner() {
rowSpinner = new ColumnRowSpinner((new SpinnerListModel(rowarray))) {
public boolean shouldResponseChangeListener() {
return false;
}
};
rowSpinner.setPreferredSize(new Dimension(60, 24));
JFormattedTextField rftf = GUICoreUtils.getSpinnerTextField(rowSpinner);
if (rftf != null) {
rftf.setColumns(4); // specify more width than we need
rftf.setHorizontalAlignment(UITextField.LEFT);
}
}
protected void initColSpinner() {
SpinnerListModel columnSpinnerListModel = new SpinnerListModel(columnarray);
columnSpinner = new UpperCaseSpinner(columnSpinnerListModel) {
public boolean shouldResponseChangeListener() {
return false;
}
};
columnSpinner.setPreferredSize(new Dimension(60, 24));
JFormattedTextField cftf = GUICoreUtils.getSpinnerTextField(columnSpinner);
if (cftf != null) {
cftf.setColumns(3); // specify more width than we need
cftf.setHorizontalAlignment(UITextField.LEFT);
}
((AbstractDocument) cftf.getDocument()).setDocumentFilter(new DocumentFilter() {
public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException {
fb.insertString(offset, string.toUpperCase(), attr);
}
public void replace(FilterBypass fb, int offset, int length, String string, AttributeSet attr) throws BadLocationException {
if (string != null) {
string = string.toUpperCase();
}
fb.replace(offset, length, string, attr);
}
});
}
protected void addDocumentListener(DocumentListener l) {
((DefaultEditor) columnSpinner.getEditor()).getTextField().getDocument().addDocumentListener(l);
((DefaultEditor) rowSpinner.getEditor()).getTextField().getDocument().addDocumentListener(l);
}
private void removeDocumentListener(DocumentListener l) {
((DefaultEditor) columnSpinner.getEditor()).getTextField().getDocument().removeDocumentListener(l);
((DefaultEditor) rowSpinner.getEditor()).getTextField().getDocument().removeDocumentListener(l);
}
/**
* columnSpinner与rowSpinner应该整体考虑设置ColumnRow应该只触发一次事件
*
* @param columnRow
*/
public void setColumnRow(ColumnRow columnRow) {
if (!ComparatorUtils.equals(cr, columnRow)) {
setGlobalName();
removeDocumentListener(d);
cr = columnRow;
addDocumentListener(d);
fireChanged();
}
}
public void setGlobalName(){
}
public void populate(ColumnRow columnRow) {
cr = columnRow;
int column = columnRow.getColumn();
if (column < 0) {
column = 0;
}
removeDocumentListener(d);
columnSpinner.setValue(StableUtils.convertIntToABC(column + 1));
int row = columnRow.getRow();
// shoc 小于0就蹦了
if (row < 0) {
row = 0;
}
rowSpinner.setValue("" + (row + 1));
addDocumentListener(d);
fireChanged();
}
public ColumnRow update() {
return cr;
}
/**
* 添加一个listener到listenerList中
* @param l 监听
*/
public void addChangeListener(ChangeListener l) {
this.listenerList.add(ChangeListener.class, l);
}
/**
* 从listenerList中移除一个listener
* @param l 监听
*/
public void removeChangeListener(ChangeListener l) {
this.listenerList.remove(ChangeListener.class, l);
}
// august: Process the listeners last to first
protected void fireChanged() {
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == ChangeListener.class) {
((ChangeListener) listeners[i + 1]).stateChanged(new ChangeEvent(this));
}
}
}
/**
* 给组件登记一个观察者监听事件
* @param listener 监听
*/
public void registerChangeListener(UIObserverListener listener) {
uiObserverListener = listener;
}
/**
* 组件是否需要响应添加的观察者事件
* @return 如果需要响应观察者事件则返回true否则返回false
*/
public boolean shouldResponseChangeListener() {
return true;
}
private static final long serialVersionUID = 1L;
private static String[] columnarray = new String[1000];
private static String[] rowarray = new String[5000];
protected UpperCaseSpinner columnSpinner;
protected UIBasicSpinner rowSpinner;
static {
for (int i = 1; i <= 1000; i++) {
columnarray[i - 1] = StableUtils.convertIntToABC(i);
}
for (int i = 1; i <= 5000; i++) {
rowarray[i - 1] = StringUtils.EMPTY + i;
}
}
protected DocumentListener d = new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
String rolText = ((DefaultEditor) columnSpinner.getEditor()).getTextField().getText();
String rowText = ((DefaultEditor) rowSpinner.getEditor()).getTextField().getText();
if (rolText == null || rolText.length() == 0 || rowText == null || rowText.length() == 0) {
return;
}
int col = StableUtils.convertABCToInt(rolText) - 1;
int row = Integer.parseInt(rowText) - 1;
setColumnRow(ColumnRow.valueOf(col, row));
}
@Override
public void insertUpdate(DocumentEvent e) {
int col = StableUtils.convertABCToInt(((DefaultEditor) columnSpinner.getEditor()).getTextField().getText()) - 1;
int row = Integer.parseInt(((DefaultEditor) rowSpinner.getEditor()).getTextField().getText()) - 1;
setColumnRow(ColumnRow.valueOf(col, row));
}
@Override
public void changedUpdate(DocumentEvent e) {
}
};
private UIObserverListener uiObserverListener;
private ColumnRow cr;
public ColumnRowPane() {
this.initComponents();
iniListener();
}
/**
* 初始化元素
*/
public void initComponents() {
this.setLayout(new GridLayout(0, 2, IntervalConstants.INTERVAL_L6, 0));
initColSpinner();
this.add(columnSpinner, BorderLayout.WEST);
initRowSpinner();
this.add(rowSpinner);
this.addDocumentListener(d);
}
private void iniListener() {
if (shouldResponseChangeListener()) {
this.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (uiObserverListener == null) {
return;
}
uiObserverListener.doChange();
}
});
}
}
protected void initRowSpinner() {
rowSpinner = new ColumnRowSpinner((new SpinnerListModel(rowarray))) {
public boolean shouldResponseChangeListener() {
return false;
}
};
rowSpinner.setPreferredSize(new Dimension(60, 24));
JFormattedTextField rftf = GUICoreUtils.getSpinnerTextField(rowSpinner);
if (rftf != null) {
rftf.setColumns(4); // specify more width than we need
rftf.setHorizontalAlignment(UITextField.LEFT);
}
}
protected void initColSpinner() {
SpinnerListModel columnSpinnerListModel = new SpinnerListModel(columnarray);
columnSpinner = new UpperCaseSpinner(columnSpinnerListModel) {
public boolean shouldResponseChangeListener() {
return false;
}
};
columnSpinner.setPreferredSize(new Dimension(60, 24));
JFormattedTextField cftf = GUICoreUtils.getSpinnerTextField(columnSpinner);
if (cftf != null) {
cftf.setColumns(3); // specify more width than we need
cftf.setHorizontalAlignment(UITextField.LEFT);
}
((AbstractDocument) cftf.getDocument()).setDocumentFilter(new DocumentFilter() {
public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException {
fb.insertString(offset, string.toUpperCase(), attr);
}
public void replace(FilterBypass fb, int offset, int length, String string, AttributeSet attr) throws BadLocationException {
if (string != null) {
string = string.toUpperCase();
}
fb.replace(offset, length, string, attr);
}
});
}
protected void addDocumentListener(DocumentListener l) {
((DefaultEditor) columnSpinner.getEditor()).getTextField().getDocument().addDocumentListener(l);
((DefaultEditor) rowSpinner.getEditor()).getTextField().getDocument().addDocumentListener(l);
}
private void removeDocumentListener(DocumentListener l) {
((DefaultEditor) columnSpinner.getEditor()).getTextField().getDocument().removeDocumentListener(l);
((DefaultEditor) rowSpinner.getEditor()).getTextField().getDocument().removeDocumentListener(l);
}
/**
* columnSpinner与rowSpinner应该整体考虑设置ColumnRow应该只触发一次事件
*
* @param columnRow
*/
public void setColumnRow(ColumnRow columnRow) {
if (!ComparatorUtils.equals(cr, columnRow)) {
setGlobalName();
removeDocumentListener(d);
cr = columnRow;
addDocumentListener(d);
fireChanged();
}
}
public void setGlobalName() {
}
public void populate(ColumnRow columnRow) {
cr = columnRow;
int column = columnRow.getColumn();
if (column < 0) {
column = 0;
}
removeDocumentListener(d);
columnSpinner.setValue(StableUtils.convertIntToABC(column + 1));
int row = columnRow.getRow();
// shoc 小于0就蹦了
if (row < 0) {
row = 0;
}
rowSpinner.setValue("" + (row + 1));
addDocumentListener(d);
fireChanged();
}
public ColumnRow update() {
return cr;
}
/**
* 添加一个listener到listenerList中
*
* @param l 监听
*/
public void addChangeListener(ChangeListener l) {
this.listenerList.add(ChangeListener.class, l);
}
/**
* 从listenerList中移除一个listener
*
* @param l 监听
*/
public void removeChangeListener(ChangeListener l) {
this.listenerList.remove(ChangeListener.class, l);
}
// august: Process the listeners last to first
protected void fireChanged() {
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == ChangeListener.class) {
((ChangeListener) listeners[i + 1]).stateChanged(new ChangeEvent(this));
}
}
}
/**
* 给组件登记一个观察者监听事件
*
* @param listener 监听
*/
public void registerChangeListener(UIObserverListener listener) {
uiObserverListener = listener;
}
/**
* 组件是否需要响应添加的观察者事件
*
* @return 如果需要响应观察者事件则返回true否则返回false
*/
public boolean shouldResponseChangeListener() {
return true;
}
}

38
designer-base/src/main/java/com/fr/design/gui/controlpane/NameableCreator.java

@ -5,25 +5,25 @@ import com.fr.design.gui.ilist.ListModelElement;
import com.fr.js.JavaScript;
import com.fr.stable.Nameable;
import javax.swing.*;
import javax.swing.Icon;
public interface NameableCreator {
public String menuName();
public Icon menuIcon();
public String createTooltip();
public Nameable createNameable(UnrepeatedNameHelper helper);
public Class<? extends BasicBeanPane> getUpdatePane();
public Object acceptObject2Populate(Object ob);
public void saveUpdatedBean(ListModelElement wrapper, Object bean);
public Class <? extends JavaScript> getHyperlink();
public boolean isNeedParameterWhenPopulateJControlPane();
String menuName();
Icon menuIcon();
String createTooltip();
Nameable createNameable(UnrepeatedNameHelper helper);
Class<? extends BasicBeanPane> getUpdatePane();
Object acceptObject2Populate(Object ob);
void saveUpdatedBean(ListModelElement wrapper, Object bean);
Class<? extends JavaScript> getHyperlink();
boolean isNeedParameterWhenPopulateJControlPane();
}

6
designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/OldShortCutFactory.java

@ -2,13 +2,14 @@ package com.fr.design.gui.controlpane.shortcutfactory;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.gui.HyperlinkFilterHelper;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.controlpane.ShortCut4JControlPane;
import com.fr.design.gui.controlpane.ShortCutListenerProvider;
import com.fr.design.gui.frpane.HyperLinkGroupFilter;
import com.fr.design.menu.LineSeparator;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut;
import com.fr.design.module.DesignModuleFactory;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
@ -83,7 +84,8 @@ public class OldShortCutFactory extends AbstractShortCutFactory {
private void wrapActionListener(NameableCreator[] creators) {
for (final NameableCreator creator : creators) {
if (!HyperlinkFilterHelper.whetherAddHyperlink4cell(creator.menuName())) {
HyperLinkGroupFilter filter = DesignModuleFactory.getHyperlinkGroupType().getFilter();
if (!filter.filter(creator.getHyperlink())) {
continue;
}
boolean isTrue = ComparatorUtils.equals(creator.menuName(), Inter.getLocText("Datasource-Stored_Procedure")) ||

25
designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/ShortCutFactory.java

@ -3,14 +3,15 @@ package com.fr.design.gui.controlpane.shortcutfactory;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.gui.HyperlinkFilterHelper;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.controlpane.ShortCut4JControlPane;
import com.fr.design.gui.controlpane.ShortCutListenerProvider;
import com.fr.design.gui.frpane.HyperLinkGroupFilter;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.menu.LineSeparator;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut;
import com.fr.design.module.DesignModuleFactory;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
@ -36,11 +37,11 @@ public class ShortCutFactory extends AbstractShortCutFactory {
@Override
public ShortCut4JControlPane[] createShortCuts() {
return new ShortCut4JControlPane[]{
copyItemShortCut(),
moveUpItemShortCut(),
moveDownItemShortCut(),
sortItemShortCut(),
removeItemShortCut()
copyItemShortCut(),
moveUpItemShortCut(),
moveDownItemShortCut(),
sortItemShortCut(),
removeItemShortCut()
};
}
@ -77,7 +78,7 @@ public class ShortCutFactory extends AbstractShortCutFactory {
Object object = this.getValue(UIButton.class.getName());
if (!(object instanceof AbstractButton)) {
// 直接使用默认UI
UIButton button = new UIButton();
UIButton button = new UIButton();
// 添加一个名字作为自动化测试用
button.setName(getName());
@ -124,7 +125,8 @@ public class ShortCutFactory extends AbstractShortCutFactory {
/**
* 生成UIButton
* @return 菜单按钮
*
* @return 菜单按钮
*/
public UIButton createUIButton() {
createdButton = super.createUIButton();
@ -139,7 +141,8 @@ public class ShortCutFactory extends AbstractShortCutFactory {
private void wrapActionListener(NameableCreator[] creators) {
for (final NameableCreator creator : creators) {
if (!whetherAdd(creator.menuName())) {
HyperLinkGroupFilter filter = DesignModuleFactory.getHyperlinkGroupType().getFilter();
if (!filter.filter(creator.getHyperlink())) {
continue;
}
boolean isTrue = ComparatorUtils.equals(creator.menuName(), com.fr.design.i18n.Toolkit.i18nText("Datasource-Stored_Procedure")) ||
@ -163,9 +166,5 @@ public class ShortCutFactory extends AbstractShortCutFactory {
});
}
}
protected boolean whetherAdd(String itemName){
return HyperlinkFilterHelper.whetherAddHyperlink4cell(itemName);
}
}
}

33
designer-base/src/main/java/com/fr/design/gui/frpane/BaseHyperlinkGroup.java

@ -2,6 +2,7 @@ package com.fr.design.gui.frpane;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.module.DesignModuleFactory;
import com.fr.js.JavaScript;
/**
* 基础的超级链接类型, 不包括图表相关超链.
@ -11,13 +12,29 @@ import com.fr.design.module.DesignModuleFactory;
*/
public class BaseHyperlinkGroup implements HyperlinkGroupType {
/**
* 返回支持的超级链接类型
*
* @return
*/
public NameableCreator[] getHyperlinkCreators() {
return DesignModuleFactory.getCreators4Hyperlink();
}
/**
* 返回支持的超级链接类型
*
* @return NameableCreator[]
*/
public NameableCreator[] getHyperlinkCreators() {
return DesignModuleFactory.getCreators4Hyperlink();
}
@Override
public HyperLinkGroupFilter getFilter() {
return new HyperLinkGroupFilter() {
@Override
public boolean filter(Class<? extends JavaScript> clazz) {
return true;
}
@Override
public boolean filter(Object object) {
return true;
}
};
}
}

22
designer-base/src/main/java/com/fr/design/gui/frpane/HyperLinkGroupFilter.java

@ -0,0 +1,22 @@
package com.fr.design.gui.frpane;
import com.fr.js.JavaScript;
public interface HyperLinkGroupFilter {
/**
* @param clazz clazz
* @return 是否可用返回true表示可用返回false表示不可用
*/
boolean filter(Class<? extends JavaScript> clazz);
/**
* 兼容老图表
*
* @param object object
* @return 是否可用返回true表示可用返回false表示不可用
* @see HyperLinkGroupFilter#filter(Class)
*/
boolean filter(Object object);
}

19
designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupType.java

@ -3,16 +3,21 @@ package com.fr.design.gui.frpane;
import com.fr.design.gui.controlpane.NameableCreator;
/**
* 超级链接 支持的类型 种类.
* 超级链接 支持的类型 种类.
*
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2013-6-26 下午04:41:55
*/
public interface HyperlinkGroupType {
/**
* 返回支持的超级链接类型
* @return NameableCreator[]
*/
public NameableCreator[] getHyperlinkCreators();
/**
* 返回支持的超级链接类型
*
* @return NameableCreator[]
*/
NameableCreator[] getHyperlinkCreators();
HyperLinkGroupFilter getFilter();
}

39
designer-base/src/main/java/com/fr/design/gui/frpane/UICorrelationComboBoxPane.java

@ -8,7 +8,6 @@ import com.fr.design.dialog.DialogActionListener;
import com.fr.design.dialog.UIDialog;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.HyperlinkFilterHelper;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.imenutable.UIMenuNameableCreator;
@ -16,9 +15,9 @@ import com.fr.design.gui.imenutable.UIMenuTable;
import com.fr.design.hyperlink.ReportletHyperlinkPane;
import com.fr.design.hyperlink.WebHyperlinkPane;
import com.fr.design.javascript.EmailPane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.js.AbstractJavaScript;
import com.fr.js.EmailJavaScript;
import com.fr.js.ReportletHyperlink;
@ -26,10 +25,17 @@ import com.fr.js.WebHyperlink;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
@ -76,6 +82,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 刷新下拉列表和按钮
*
* @param values 下拉列表里的值
*/
public void refreshMenuAndAddMenuAction(List<? extends UIMenuNameableCreator> values) {
@ -88,7 +95,8 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
if (values.size() > 1) {
for (UIMenuNameableCreator value : values) {
final String itemName = value.getName();
if(!HyperlinkFilterHelper.whetherAddHyperlink4Chart(itemName)){
HyperLinkGroupFilter filter = DesignModuleFactory.getHyperlinkGroupType().getFilter();
if (!filter.filter(value.getObj())) {
continue;
}
UIMenuItem item = new UIMenuItem(itemName);
@ -238,6 +246,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 增加布局
*
* @param name 名字
* @param comp 组件
*/
@ -247,6 +256,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 删除组件
*
* @param comp 组件
*/
public void removeLayoutComponent(Component comp) {
@ -255,6 +265,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 获得组件的大小
*
* @param parent 上层容器
* @return 组件的大小
*/
@ -265,6 +276,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 最小的布局大小
*
* @param parent 上层容器
* @return 最小的大小
*/
@ -274,6 +286,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 布局容器
*
* @param parent 上层容器
*/
public void layoutContainer(Container parent) {
@ -287,6 +300,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 增加监听事件
*
* @param l 监听的对象
*/
public void addChangeListener(ChangeListener l) {
@ -296,6 +310,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 删除监听事件
*
* @param l 需要删除的事件
*/
public void removeChangeListener(ChangeListener l) {
@ -337,6 +352,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 更新并且重载 当前列表的值
*
* @param list 更新的列表
*/
public void populateBean(List list) {
@ -353,14 +369,14 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 重置每个条目的名字
*/
public void resetItemName(){
for(int i = 0; i < tablePane.getRowCount(); i++){
public void resetItemName() {
for (int i = 0; i < tablePane.getRowCount(); i++) {
UIMenuNameableCreator line = tablePane.getLine(i);
Object obj = line.getObj();
if(obj instanceof AbstractJavaScript){
AbstractJavaScript script = (AbstractJavaScript)obj;
if (obj instanceof AbstractJavaScript) {
AbstractJavaScript script = (AbstractJavaScript) obj;
String itemName = script.getItemName();
if(!StringUtils.isBlank(itemName)){
if (!StringUtils.isBlank(itemName)) {
line.setName(itemName);
}
}
@ -369,6 +385,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 测试例子界面
*
* @param args 参数向量
*/
public static void main(String... args) {
@ -397,6 +414,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 注册观察者监听事件
*
* @param listener 观察者监听事件
*/
public void registerChangeListener(UIObserverListener listener) {
@ -406,6 +424,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 是否需要响应事件
*
* @return 需要相应
*/
public boolean shouldResponseChangeListener() {

16
designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java

@ -15,6 +15,7 @@ import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.List;
import java.util.Vector;
/**
@ -131,6 +132,21 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser
return new Dimension(super.getPreferredSize().width + SIZE5, SIZE);
}
public void refreshBoxItems(List list) {
Object ob = getSelectedItem();
removeAllItems();
for (Object o : list) {
addItem(o);
}
getModel().setSelectedItem(ob);
}
public void clearBoxItems() {
removeAllItems();
}
/**
* 鼠标进入事件
*/

12
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/DataPaneHelper.java

@ -21,15 +21,7 @@ public class DataPaneHelper {
return;
}
Object ob = box.getSelectedItem();
box.removeAllItems();
int length = list.size();
for (int i = 0; i < length; i++) {
box.addItem(list.get(i));
}
box.getModel().setSelectedItem(ob);
box.refreshBoxItems(list);
}
/**
@ -39,7 +31,7 @@ public class DataPaneHelper {
*/
public static void clearBoxItems(UIComboBox box) {
if (box != null) {
box.removeAllItems();
box.clearBoxItems();
}
}

83
designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java

@ -7,11 +7,16 @@ import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperPoplinkPane;
import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperRelateCellLinkPane;
import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperRelateFloatLinkPane;
import com.fr.design.chart.series.SeriesCondition.impl.FormHyperlinkPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.frpane.BaseHyperlinkGroup;
import com.fr.design.gui.frpane.HyperLinkGroupFilter;
import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.general.ComparatorUtils;
import com.fr.js.FormHyperlinkProvider;
import com.fr.js.JavaScript;
import com.fr.stable.ArrayUtils;
import com.fr.stable.bridge.StableFactory;
@ -31,12 +36,84 @@ public class ChartHyperlinkGroup extends BaseHyperlinkGroup {
public NameableCreator[] getHyperlinkCreators() {
FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class);
NameableCreator[] realted4CharthyperUse = {
NameableCreator[] related4ChartHyper = {
new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Float_Chart"), ChartHyperPoplink.class, ChartHyperPoplinkPane.ChartNoRename.class),
new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Cell"), ChartHyperRelateCellLink.class, ChartHyperRelateCellLinkPane.ChartNoRename.class),
new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Float"), ChartHyperRelateFloatLink.class, ChartHyperRelateFloatLinkPane.ChartNoRename.class),
new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Hyperlink_Form_Link"), formHyperlink.getClass(), FormHyperlinkPane.class)};
return (NameableCreator[]) ArrayUtils.addAll(super.getHyperlinkCreators(), realted4CharthyperUse);
return ArrayUtils.addAll(super.getHyperlinkCreators(), related4ChartHyper);
}
@Override
public HyperLinkGroupFilter getFilter() {
return new HyperLinkGroupFilter() {
@Override
public boolean filter(Class<? extends JavaScript> clazz) {
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template == null) {
return false;
}
if (template.isJWorkBook()) {
// 如果是普通报表单元格,那么没有 FormHyperlink 选项
FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class);
//返回true表示可用,返回false表示不可用
return !ComparatorUtils.equals(clazz, formHyperlink.getClass());
} else {
// 如果是决策报表
Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class};
for (Class aClass : classes) {
if (template.getEditingReportIndex() == BaseJForm.FORM_TAB) {
// 编辑的是决策报表中的图表,那么没有ChartHyperRelateFloatLink 和 ChartHyperRelateCellLink 选项,有FormHyperlink 选项
if (ComparatorUtils.equals(aClass, clazz)) {
return false;
}
} else if (template.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB) {
// 编辑的是决策报表中的报表块,那么没有 ChartHyperRelateFloatLink,有ChartHyperRelateCellLink 和 FormHyperlink 选项
return !ComparatorUtils.equals(clazz, ChartHyperRelateFloatLink.class);
}
}
}
return true;
}
/**
* 兼容老图表
* @param object
* @return
*/
@Override
public boolean filter(Object object) {
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template == null) {
return false;
}
if (template.isJWorkBook()) {
// 如果是普通报表单元格,那么没有 FormHyperlink 选项
FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class);
//返回true表示可用,返回false表示不可用
return !ComparatorUtils.equals(object.getClass(), formHyperlink.getClass());
} else {
// 如果是决策报表
Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class};
for (Class aClass : classes) {
if (template.getEditingReportIndex() == BaseJForm.FORM_TAB) {
// 编辑的是决策报表中的图表,那么没有ChartHyperRelateFloatLink 和 ChartHyperRelateCellLink 选项,有FormHyperlink 选项
if (ComparatorUtils.equals(aClass, object.getClass())) {
return false;
}
} else if (template.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB) {
// 编辑的是决策报表中的报表块,那么没有 ChartHyperRelateFloatLink,有ChartHyperRelateCellLink 和 FormHyperlink 选项
return !ComparatorUtils.equals(object.getClass(), ChartHyperRelateFloatLink.class);
}
}
}
return true;
}
};
}
}

8
designer-chart/src/main/java/com/fr/design/module/FormHyperlinkGroup.java

@ -8,7 +8,6 @@ import com.fr.design.chart.series.SeriesCondition.impl.FormHyperlinkPane;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.frpane.BaseHyperlinkGroup;
import com.fr.js.FormHyperlinkProvider;
import com.fr.stable.ArrayUtils;
import com.fr.stable.bridge.StableFactory;
@ -23,15 +22,16 @@ public class FormHyperlinkGroup extends BaseHyperlinkGroup {
/**
* 返回支持的超级链接类型
*
* @return NameableCreator[]
*/
public NameableCreator[] getHyperlinkCreators() {
FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class);
NameableCreator[] realted4CharthyperUse = {
FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class);
NameableCreator[] related4ChartHyper = {
new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Float_Chart"), ChartHyperPoplink.class, ChartHyperPoplinkPane.ChartNoRename.class),
new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Cell"), ChartHyperRelateCellLink.class, ChartHyperRelateCellLinkPane.ChartNoRename.class),
new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Hyperlink_Form_Link"), formHyperlink.getClass(), FormHyperlinkPane.class)};
return (NameableCreator[]) ArrayUtils.addAll(super.getHyperlinkCreators(), realted4CharthyperUse);
return ArrayUtils.addAll(super.getHyperlinkCreators(), related4ChartHyper);
}
}

23
designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java

@ -10,13 +10,14 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.general.GeneralUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.Arrays;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
/**
* Created by shine on 2018/3/2.
@ -52,8 +53,8 @@ public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataC
this.setBorder(BorderFactory.createEmptyBorder(2, 24, 0, 15));
this.add(panel, BorderLayout.NORTH);
if (hasCustomFieldPane()) {
customFieldComboBoxPane = new ExtendedCustomFieldComboBoxPane(hasNoneItem());
customFieldComboBoxPane = createExtendedCustomFieldComboBoxPane();
if (customFieldComboBoxPane != null) {
this.add(customFieldComboBoxPane, BorderLayout.CENTER);
}
@ -64,12 +65,8 @@ public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataC
return new JPanel();
}
protected boolean hasCustomFieldPane() {
return false;
}
protected boolean hasNoneItem() {
return false;
protected ExtendedCustomFieldComboBoxPane createExtendedCustomFieldComboBoxPane() {
return null;
}
protected Component[] fieldComponents() {
@ -99,7 +96,7 @@ public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataC
if (dataConfig != null) {
populate((T) dataConfig);
if (hasCustomFieldPane()) {
if (customFieldComboBoxPane != null) {
customFieldComboBoxPane.populateBean(dataConfig);
}
}
@ -118,7 +115,7 @@ public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataC
ExtendedTableDataSet dataSet = new ExtendedTableDataSet();
dataSet.setDataConfig(update());
if (hasCustomFieldPane()) {
if (customFieldComboBoxPane != null) {
customFieldComboBoxPane.updateBean(dataSet.getDataConfig());
}

32
designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java

@ -11,12 +11,16 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itable.UITable;
import com.fr.design.gui.itable.UITableEditor;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox;
import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper;
import com.fr.stable.StringUtils;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
@ -26,10 +30,6 @@ import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
/**
* Created by shine on 2018/9/12.
@ -39,16 +39,10 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
private UseFieldValuePane useFieldValuePane;
private boolean hasNoneItem = false;
private CustomFieldNamePane customFieldNamePane;
private List<String> fieldList = new ArrayList<String>();
public ExtendedCustomFieldComboBoxPane(boolean hasNoneItem) {
this.hasNoneItem = hasNoneItem;
}
@Override
protected void initLayout() {
this.setLayout(new BorderLayout(0, 6));
@ -76,6 +70,10 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
return StringUtils.EMPTY;
}
protected boolean valueComboBoxHasNone() {
return false;
}
public void checkBoxUse(boolean hasUse) {
jcb.setEnabled(hasUse);
useFieldValuePane.checkBoxUse(hasUse);
@ -125,11 +123,7 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
private void initComponents() {
series = new UIComboBox();
value = new UIComboBox();
if (hasNoneItem) {
value.addItem(Toolkit.i18nText("Fine-Design_Chart_Use_None"));
}
value = valueComboBoxHasNone() ? new UIComboBoxWithNone() : new UIComboBox();
function = new CalculateComboBox();
@ -158,17 +152,11 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
public void clearAllBoxList() {
DataPaneHelper.clearBoxItems(series);
DataPaneHelper.clearBoxItems(value);
if (hasNoneItem) {
value.addItem(Toolkit.i18nText("Fine-Design_Chart_Use_None"));
}
}
public void refreshBoxListWithSelectTableData(List columnNameList) {
DataPaneHelper.refreshBoxItems(series, columnNameList);
DataPaneHelper.refreshBoxItems(value, columnNameList);
if (hasNoneItem) {
value.addItem(Toolkit.i18nText("Fine-Design_Chart_Use_None"));
}
}
@Override

44
designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java

@ -0,0 +1,44 @@
package com.fr.extended.chart;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.i18n.Toolkit;
import java.util.List;
/**
* Created by shine on 2018/9/27.
*/
public class UIComboBoxWithNone extends UIComboBox {
private static String getNoneLocaleString() {
return Toolkit.i18nText("Fine-Design_Chart_Use_None");
}
@Override
public void refreshBoxItems(List list) {
super.refreshBoxItems(list);
addNoneItem();
}
@Override
public void clearBoxItems() {
super.clearBoxItems();
addNoneItem();
}
private void addNoneItem() {
addItem(getNoneLocaleString());
}
@Override
public void setSelectedItem(Object anObject) {
super.setSelectedItem(anObject);
if (getSelectedIndex() == -1) {//找不到的都选中无。中文的无 英文下是none。
super.setSelectedItem(getNoneLocaleString());
}
}
}

22
designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartShortCutFactory.java

@ -1,10 +1,7 @@
package com.fr.van.chart.custom.component;
import com.fr.design.gui.HyperlinkFilterHelper;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.controlpane.shortcutfactory.ShortCutFactory;
import com.fr.design.gui.controlpane.ShortCutListenerProvider;
import com.fr.design.menu.ShortCut;
import com.fr.design.gui.controlpane.shortcutfactory.ShortCutFactory;
/**
* Created by plough on 2018/8/13.
@ -17,21 +14,4 @@ class VanChartShortCutFactory extends ShortCutFactory {
public static VanChartShortCutFactory newInstance(ShortCutListenerProvider listenerProvider) {
return new VanChartShortCutFactory(listenerProvider);
}
@Override
public ShortCut createAddItemMenuDef(NameableCreator[] creators) {
return new AddVanChartItemMenuDef(creators);
}
private class AddVanChartItemMenuDef extends AddItemMenuDef {
AddVanChartItemMenuDef(NameableCreator[] creators) {
super(creators);
}
@Override
protected boolean whetherAdd(String itemName) {
return HyperlinkFilterHelper.whetherAddHyperlink4Chart(itemName);
}
}
}

16
designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapHyperLinkPane.java

@ -1,7 +1,11 @@
package com.fr.van.chart.map.designer.other;
import com.fr.base.BaseFormula;
import com.fr.base.FormulaBuilder;
import com.fr.chart.chartattr.Plot;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.extended.chart.HyperLinkPara;
import com.fr.extended.chart.HyperLinkParaHelper;
import com.fr.js.NameJavaScriptGroup;
import com.fr.plugin.chart.map.VanChartMapPlot;
import com.fr.plugin.chart.type.MapType;
@ -11,6 +15,8 @@ import com.fr.van.chart.map.designer.VanMapAreaPointAndLineGroupPane;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Created by hufan on 2016/12/20.
@ -193,6 +199,16 @@ public class VanChartMapHyperLinkPane extends BasicScrollPane<Plot> {
protected NameJavaScriptGroup populateHotHyperLink(Plot plot) {
return ((VanChartMapPlot)plot).getLineHotHyperLink();
}
@Override
protected Map<String, BaseFormula> getHyperLinkEditorMap() {
FormulaBuilder builder = BaseFormula.createFormulaBuilder();
Map<String, BaseFormula> map = new LinkedHashMap<>();
for (HyperLinkPara para : HyperLinkParaHelper.LINE_MAP) {
map.put(para.getName(), builder.build(para.getFormulaContent()));
}
return map;
}
};
}

260
designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java

@ -7,6 +7,7 @@ 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;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
@ -28,140 +29,143 @@ import java.util.List;
import java.util.Set;
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;
private FormSubmitJavaScriptPane formSubmitScriptPane;
private Commit2DBJavaScriptPane commit2DBJavaScriptPane;
// 自定义事件
private CustomActionPane customActionPane;
// 发送邮件
private EmailPane emailPane;
private static final String JS = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JavaScript");
private static final String FORMSUBMIT = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JavaScript_Form_Submit");
private static final String DBCOMMIT = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JavaScript_Commit_To_Database");
private static final String CUSTOMACTION= com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JavaScript_Custom_Submit");
private static final String EMAIL = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Email_Sent_Email");
private Listener listener;
public ListenerEditPane() {
this.initComponents(new String[0]);
}
private UITextField nameText;
private UIComboBox styleBox;
private CardLayout card;
private List<FurtherBasicBeanPane<? extends JavaScript>> cards;
private JPanel hyperlinkPane;
public ListenerEditPane(String[] defaultArgs) {
this.initComponents(defaultArgs);
}
private static final String JS = Toolkit.i18nText("Fine-Design_Report_JavaScript");
private static final String DBCOMMIT = Toolkit.i18nText("Fine-Design_Basic_JavaScript_Commit_To_Database");
private static final String CUSTOMACTION = Toolkit.i18nText("Fine-Design_Report_Submit_Type_Custom");
private static final String EMAIL = Toolkit.i18nText("Fine-Design_Report_Email_Sent_Email");
/**
* 初始化各个组件
* @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);
nameText.setEditable(false);
namePane.add(nameText, BorderLayout.WEST);
String[] style = {JS, DBCOMMIT, CUSTOMACTION,EMAIL};
styleBox = new UIComboBox(style);
namePane.add(styleBox);
namePane = GUICoreUtils.createFlowPane(new Component[]{new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Event_Name") + ":"), nameText, new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Event_Type") + ":"), styleBox}, FlowLayout.LEFT);
namePane.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Event_Name_Type")));
this.add(namePane, BorderLayout.NORTH);
card = new CardLayout();
hyperlinkPane = FRGUIPaneFactory.createCardLayout_S_Pane();
hyperlinkPane.setLayout(card);
javaScriptPane = new JavaScriptImplPane(defaultArgs);
hyperlinkPane.add(JS, javaScriptPane);
// 提交入库
List dbmaniList = new ArrayList();
dbmaniList.add(autoCreateDBManipulationPane());
commit2DBJavaScriptPane = new Commit2DBJavaScriptPane(JavaScriptActionPane.defaultJavaScriptActionPane,
dbmaniList);
hyperlinkPane.add(DBCOMMIT, commit2DBJavaScriptPane);
// 自定义事件
customActionPane = new CustomActionPane();
hyperlinkPane.add(CUSTOMACTION, customActionPane);
// 发送邮件
emailPane = new EmailPane();
hyperlinkPane.add(EMAIL,emailPane);
cards.add(javaScriptPane);
cards.add(commit2DBJavaScriptPane);
cards.add(customActionPane);
cards.add(emailPane);
//其他事件
addOtherEvent();
hyperlinkPane.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JavaScript_Set")));
this.add(hyperlinkPane);
styleBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
card.show(hyperlinkPane, styleBox.getSelectedItem().toString());
}
});
}
private Listener 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);
}
}
}
public ListenerEditPane() {
this.initComponents(new String[0]);
}
public ListenerEditPane(String[] defaultArgs) {
this.initComponents(defaultArgs);
}
/**
* 根据有无单元格创建 DBManipulationPane
* @return 有单元格有智能添加单元格等按钮返回 SmartInsertDBManipulationPane
* 初始化各个组件
*
* @param defaultArgs 初始化参数
*/
private DBManipulationPane autoCreateDBManipulationPane() {
JTemplate jTemplate = DesignerContext.getDesignerFrame().getSelectedJTemplate();
return jTemplate.createDBManipulationPane();
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Event_Set");
}
@Override
public void populateBean(Listener listener) {
this.listener = listener;
if (this.listener == null) {
this.listener = new Listener();
}
this.nameText.setText(listener.getEventName());
JavaScript js = listener.getAction();
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 initComponents(String[] defaultArgs) {
cards = new ArrayList<>();
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel namePane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
nameText = new UITextField(8);
nameText.setEditable(false);
namePane.add(nameText, BorderLayout.WEST);
final String[] style = {JS, DBCOMMIT, CUSTOMACTION, EMAIL};
styleBox = new UIComboBox(style);
namePane.add(styleBox);
namePane = GUICoreUtils.createFlowPane(new Component[]{
new UILabel(" " + Toolkit.i18nText("Fine-Design_Report_Event_Name") + ":"),
nameText,
new UILabel(" " + Toolkit.i18nText("Fine-Design_Report_Event_Type") + ":"),
styleBox},
FlowLayout.LEFT);
namePane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Report_Event_Name_Type")));
this.add(namePane, BorderLayout.NORTH);
card = new CardLayout();
hyperlinkPane = FRGUIPaneFactory.createCardLayout_S_Pane();
hyperlinkPane.setLayout(card);
JavaScriptImplPane javaScriptPane = new JavaScriptImplPane(defaultArgs);
hyperlinkPane.add(JS, javaScriptPane);
// 提交入库
List dbManiList = new ArrayList();
dbManiList.add(autoCreateDBManipulationPane());
Commit2DBJavaScriptPane commit2DBJavaScriptPane = new Commit2DBJavaScriptPane(JavaScriptActionPane.defaultJavaScriptActionPane,
dbManiList);
hyperlinkPane.add(DBCOMMIT, commit2DBJavaScriptPane);
// 自定义事件
CustomActionPane customActionPane = new CustomActionPane();
hyperlinkPane.add(CUSTOMACTION, customActionPane);
// 发送邮件
EmailPane emailPane = new EmailPane();
hyperlinkPane.add(EMAIL, emailPane);
cards.add(javaScriptPane);
cards.add(commit2DBJavaScriptPane);
cards.add(customActionPane);
cards.add(emailPane);
//其他事件
addOtherEvent();
hyperlinkPane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Report_JavaScript_Set")));
this.add(hyperlinkPane);
styleBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
Object selected = styleBox.getSelectedItem();
if (selected == null) {
return;
}
card.show(hyperlinkPane, selected.toString());
}
});
}
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
*/
private DBManipulationPane autoCreateDBManipulationPane() {
JTemplate jTemplate = DesignerContext.getDesignerFrame().getSelectedJTemplate();
return jTemplate.createDBManipulationPane();
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Report_Event_Set");
}
@Override
public void populateBean(Listener listener) {
this.listener = listener;
if (this.listener == null) {
this.listener = new Listener();
}
this.nameText.setText(listener.getEventName());
JavaScript js = listener.getAction();
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();
}
public void checkValid() throws Exception {
this.cards.get(this.styleBox.getSelectedIndex()).checkValid();
}
@Override
public Listener updateBean(){
this.listener.setEventName(this.nameText.getText());
FurtherBasicBeanPane<? extends JavaScript> pane = this.cards.get(this.styleBox.getSelectedIndex());
this.listener.setAction(pane.updateBean());
return this.listener;
}
@Override
public Listener updateBean() {
this.listener.setEventName(this.nameText.getText());
FurtherBasicBeanPane<? extends JavaScript> pane = this.cards.get(this.styleBox.getSelectedIndex());
this.listener.setAction(pane.updateBean());
return this.listener;
}
}

4
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java

@ -7,6 +7,7 @@ import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.AssistUtils;
import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils;
import org.apache.commons.codec.digest.DigestUtils;
@ -14,6 +15,7 @@ import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
/**
* Created by alex.sung on 2018/8/3.
@ -85,7 +87,7 @@ public class RobotModel extends AlphaCellModel {
@Override
public void doAction() {
try {
Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_PREVIEW + super.getName()));
Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_PREVIEW + URLEncoder.encode(super.getName(), EncodeConstants.ENCODING_UTF_8)));
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
} catch (URISyntaxException e) {

17
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -947,11 +947,13 @@ public class AlphaFineDialog extends UIDialog {
Thread sendThread = new Thread(new Runnable() {
@Override
public void run() {
RecentSearchManager searchManager = RecentSearchManager.getInstance();
searchManager.addModel(storeText, cellModel);
sendDataToServer(storeText, cellModel);
TemplateInfoCollector.getInstance().sendTemplateInfo();
ErrorInfoUploader.getInstance().sendErrorInfo();
if(StringUtils.isNotEmpty(storeText)){
RecentSearchManager searchManager = RecentSearchManager.getInstance();
searchManager.addModel(storeText, cellModel);
sendDataToServer(storeText, cellModel);
TemplateInfoCollector.getInstance().sendTemplateInfo();
ErrorInfoUploader.getInstance().sendErrorInfo();
}
}
});
sendThread.start();
@ -1376,10 +1378,11 @@ public class AlphaFineDialog extends UIDialog {
private void initBackPane() {
backPane = new JPanel(new BorderLayout());
JLabel jLabel = new JLabel(" < " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Back"));
jLabel.setPreferredSize(new Dimension(680, 20));
jLabel.setPreferredSize(new Dimension(80, 20));
jLabel.setFont(AlphaFineConstants.SMALL_FONT);
jLabel.setForeground(AlphaFineConstants.DARK_GRAY);
backPane.add(jLabel, BorderLayout.CENTER);
jLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
backPane.add(jLabel, BorderLayout.WEST);
jLabel.addMouseListener(new MouseAdapter() {
@Override

4
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java

@ -7,6 +7,7 @@ import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.RobotModel;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
@ -23,6 +24,7 @@ import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLEncoder;
/**
@ -58,7 +60,7 @@ public class RobotPreviewPane extends JPanel {
.replaceAll("\\('", StringUtils.EMPTY)
.replaceAll("'\\)", StringUtils.EMPTY);
try {
Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_PREVIEW + s));
Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_PREVIEW + URLEncoder.encode(s, EncodeConstants.ENCODING_UTF_8)));
} catch (IOException e1) {
FineLoggerFactory.getLogger().error(e1.getMessage());
} catch (URISyntaxException e1) {

16
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java

@ -3,16 +3,9 @@ package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.cell.model.RobotModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.json.JSONUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import java.io.IOException;
import com.fr.third.org.apache.commons.codec.digest.DigestUtils;
@ -37,6 +30,7 @@ public class ComplementAdviceManager {
/**
* 从接口中获取补全建议结果
*
* @param searchText
* @return
*/
@ -50,11 +44,9 @@ public class ComplementAdviceManager {
try {
String result = HttpToolbox.get(url);
AlphaFineHelper.checkCancel();
allModelList = AlphaFineHelper.getModelListFromJSONArray(result,"keywords");
} catch(ClassCastException | JSONException e){
FineLoggerFactory.getLogger().error("complement advice search error: " + e.getMessage());
} catch (IOException e1) {
FineLoggerFactory.getLogger().error("complement advice get result error: " + e1.getMessage());
allModelList = AlphaFineHelper.getModelListFromJSONArray(result, "keywords");
} catch (Exception e) {
FineLoggerFactory.getLogger().debug("complement advice search error. search str {}", searchText[j]);
}
}
if (searchResult.isEmpty()) {

16
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java

@ -12,14 +12,12 @@ import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.CodeUtils;
import com.fr.stable.StringUtils;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
@ -54,7 +52,7 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
return new SearchResult();
}
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance);
if(noConnectList != null){
if (noConnectList != null) {
return noConnectList;
}
for (int j = 0; j < searchText.length; j++) {
@ -76,10 +74,8 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
}
}
}
} catch (JSONException e) {
FineLoggerFactory.getLogger().error("recommend search error! :" + e.getMessage());
} catch (IOException e) {
FineLoggerFactory.getLogger().error("recommend search get result error! :" + e.getMessage());
} catch (Exception e) {
FineLoggerFactory.getLogger().debug("recommend search get result error! search str {}", searchText[j]);
}
}
@ -113,7 +109,7 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
/**
* 将推荐接口获取的数据分别放入显示部分显示更多的list
*/
private void getRecommendSearchResult(){
private void getRecommendSearchResult() {
if (recommendModelList.size() > AlphaFineConstants.RECOMMEND_MAX_ITEM_NUM) {
if (recommendModelList.size() > AlphaFineConstants.SHOW_SIZE) {
modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.RECOMMEND));
@ -131,7 +127,7 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
/**
* 将补全接口获取的数据分别放入显示部分显示更多的list
*/
private void getComplementAdviceSearchResult(){
private void getComplementAdviceSearchResult() {
if (complementAdviceModelList.size() > AlphaFineConstants.SHOW_SIZE) {
modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.RECOMMEND));
modelList.addAll(complementAdviceModelList.subList(0, AlphaFineConstants.SHOW_SIZE));
@ -145,7 +141,7 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
/**
* 将推荐接口和补全接口获取的数据分别放入显示部分显示更多的list
*/
private void getRecommendAndAdviceSearchResult(){
private void getRecommendAndAdviceSearchResult() {
if (recommendModelList.size() + complementAdviceModelList.size() > AlphaFineConstants.SHOW_SIZE) {
modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.RECOMMEND));
if (recommendModelList.size() > AlphaFineConstants.RECOMMEND_MAX_ITEM_NUM) {

15
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManeger.java

@ -9,14 +9,11 @@ import com.fr.design.mainframe.alphafine.cell.model.RobotModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.third.org.apache.commons.codec.digest.DigestUtils;
import java.io.IOException;
/**
* Created by alex.sung on 2018/8/3.
*/
@ -27,7 +24,7 @@ public class SimilarSearchManeger implements AlphaFineSearchProvider {
public static SimilarSearchManeger getInstance() {
if (instance == null) {
synchronized (SimilarSearchManeger.class){
synchronized (SimilarSearchManeger.class) {
if (instance == null) {
instance = new SimilarSearchManeger();
}
@ -44,7 +41,7 @@ public class SimilarSearchManeger implements AlphaFineSearchProvider {
return new SearchResult();
}
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance);
if(noConnectList != null){
if (noConnectList != null) {
return noConnectList;
}
SearchResult allModelList = new SearchResult();
@ -54,11 +51,9 @@ public class SimilarSearchManeger implements AlphaFineSearchProvider {
try {
String result = HttpToolbox.get(url);
AlphaFineHelper.checkCancel();
allModelList = AlphaFineHelper.getModelListFromJSONArray(result,"title");
} catch (ClassCastException | JSONException e) {
FineLoggerFactory.getLogger().error("similar search error: " + e.getMessage());
} catch (IOException e) {
FineLoggerFactory.getLogger().error("similar search get result error: " + e.getMessage());
allModelList = AlphaFineHelper.getModelListFromJSONArray(result, "title");
} catch (Exception e) {
FineLoggerFactory.getLogger().debug("similar search error.search str {}", searchText[j]);
}
}
moreModelList.clear();

94
designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java

@ -0,0 +1,94 @@
package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
public class ModelTest {
@Test
public void documentModelTest() {
DocumentModel documentModel = new DocumentModel("name", "content", 1);
Assert.assertEquals("name", documentModel.getName());
Assert.assertEquals("content", documentModel.getContent());
Assert.assertEquals(1, documentModel.getDocumentId());
Assert.assertEquals(AlphaFineConstants.DOCUMENT_DOC_URL + documentModel.getDocumentId() + ".html", documentModel.getDocumentUrl());
Assert.assertEquals(AlphaFineConstants.DOCUMENT_INFORMATION_URL + documentModel.getDocumentId(), documentModel.getInformationUrl());
Assert.assertEquals(documentModel.getStoreInformation(), documentModel.getInformationUrl());
Assert.assertEquals(CellType.DOCUMENT, documentModel.getType());
Assert.assertEquals(true, documentModel.hasAction());
Assert.assertEquals(true, documentModel.isNeedToSendToServer());
documentModel.setDescription("test");
Assert.assertEquals("test", documentModel.getDescription());
DocumentModel another = new DocumentModel("another", "another", 1);
documentModel.doAction();
Assert.assertTrue(another.equals(documentModel));
Assert.assertNotNull(documentModel.modelToJson());
}
@Test
public void bottomModelTest() {
BottomModel bottomModel = new BottomModel();
Assert.assertEquals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Internet_Forum"), bottomModel.getGoToWeb());
Assert.assertEquals(CellType.BOTTOM, bottomModel.getType());
try {
Assert.assertEquals(JSONObject.EMPTY, bottomModel.modelToJson());
} catch (JSONException e) {
e.printStackTrace();
}
Assert.assertEquals(true, bottomModel.hasAction());
bottomModel.doAction();
}
@Test
public void fileModelTest() {
FileModel fileModel = new FileModel("name", "test\\\\");
Assert.assertEquals(CellType.FILE, fileModel.getType());
Assert.assertNotNull(fileModel.modelToJson());
FileModel anotherFileModel = new FileModel("anotherFileModel", "test\\\\");
Assert.assertTrue(anotherFileModel.equals(fileModel));
}
@Test
public void moreModelTest() {
MoreModel moreModel = new MoreModel("name");
Assert.assertTrue(!moreModel.hasAction());
Assert.assertTrue(!moreModel.isNeedToSendToServer());
Assert.assertEquals(CellType.MORE, moreModel.getType());
}
@Test
public void noResultModelTest() {
NoResultModel noResultModel = new NoResultModel("test");
Assert.assertTrue(!noResultModel.hasAction());
Assert.assertTrue(!noResultModel.isNeedToSendToServer());
Assert.assertEquals(CellType.NO_RESULT, noResultModel.getType());
}
@Test
public void pluginModelTest() {
PluginModel pluginModel = new PluginModel("name", "content", "url", "version", "jartime", "link", "pluginId", CellType.PLUGIN, 10000, 1);
Assert.assertTrue(pluginModel.hasAction());
Assert.assertTrue(pluginModel.isNeedToSendToServer());
Assert.assertEquals(CellType.PLUGIN, pluginModel.getType());
Assert.assertNotNull(pluginModel.modelToJson());
}
@Test
public void robotModelTest(){
RobotModel robotModel = new RobotModel("title","content");
Assert.assertTrue(robotModel.hasAction());
Assert.assertTrue(robotModel.isNeedToSendToServer());
Assert.assertEquals(CellType.ROBOT, robotModel.getType());
try {
Assert.assertNotNull(robotModel.modelToJson());
} catch (JSONException e) {
e.printStackTrace();
}
}
}

80
designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/SearchManegerTest.java

@ -0,0 +1,80 @@
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.json.JSONObject;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
public class SearchManegerTest {
SimilarSearchManeger similarSearchManeger;
ComplementAdviceManager complementAdviceManager;
DocumentSearchManager documentSearchManager;
PluginSearchManager pluginSearchManager;
RecommendSearchManager recommendSearchManager;
RecentSearchManager recentSearchManager;
ActionSearchManager actionSearchManager;
FileSearchManager fileSearchManager;
SegmentationManager segmentationManager;
@Before
public void setUp() {
recentSearchManager = RecentSearchManager.getInstance();
recommendSearchManager = RecommendSearchManager.getInstance();
similarSearchManeger = SimilarSearchManeger.getInstance();
complementAdviceManager = ComplementAdviceManager.getInstance();
documentSearchManager = DocumentSearchManager.getInstance();
pluginSearchManager = PluginSearchManager.getInstance();
actionSearchManager = ActionSearchManager.getInstance();
fileSearchManager = FileSearchManager.getInstance();
segmentationManager = SegmentationManager.getInstance();
}
@Test
public void getSearchResultTest() {
//检测网络情况
Assert.assertTrue(AlphaFineHelper.isNetworkOk());
//正常搜索情况
SearchResult lessModelList;
lessModelList = recentSearchManager.getLessSearchResult(new String[]{"数据集"});
Assert.assertNotNull(lessModelList);
lessModelList = similarSearchManeger.getLessSearchResult(new String[]{"数据集"});
Assert.assertEquals(lessModelList.get(1).getType(), CellType.ROBOT);
lessModelList = complementAdviceManager.getAllSearchResult(new String[]{"数据集"});
Assert.assertEquals(lessModelList.get(1).getType(), CellType.ROBOT);
//返回MoreSearchResult
SearchResult moreModelList;
moreModelList = similarSearchManeger.getMoreSearchResult("数据集");
Assert.assertNotNull(moreModelList);
moreModelList = recommendSearchManager.getMoreSearchResult("数据集");
Assert.assertNotNull(moreModelList);
}
@Test
public void getModelFromCloudTest() {
Assert.assertNotNull(SimilarSearchManeger.getModelFromCloud(new JSONObject()));
Assert.assertNotNull(DocumentSearchManager.getModelFromCloud(new JSONObject()));
Assert.assertNotNull(PluginSearchManager.getModelFromCloud(new JSONObject()));
}
@Test
public void isNeedSegmentationTest() {
Assert.assertEquals(segmentationManager.isNeedSegmentation("多维数据集"), true);
}
@Test
public void startSegmentationTest() {
String[] result = {"结果报表", "结果", "报表"};
Assert.assertEquals(segmentationManager.startSegmentation("结果报表"), result);
}
}
Loading…
Cancel
Save