Browse Source

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

research/10.0
Mata.Li 6 years ago
parent
commit
b1a0c72bf2
  1. 80
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 42
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  3. 10
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java
  4. 8
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java
  5. 38
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  6. 2
      designer-base/src/main/java/com/fr/design/extra/PluginUtils.java
  7. 9
      designer-base/src/main/java/com/fr/design/extra/PluginWebPane.java
  8. 24
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  9. 2
      designer-base/src/main/java/com/fr/design/fun/JavaScriptActionProvider.java
  10. 9
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractJavaScriptActionProvider.java
  11. 59
      designer-base/src/main/java/com/fr/design/gui/HyperlinkFilterHelper.java
  12. 39
      designer-base/src/main/java/com/fr/design/gui/columnrow/ColumnRowPane.java
  13. 20
      designer-base/src/main/java/com/fr/design/gui/controlpane/NameableCreator.java
  14. 7
      designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/OldShortCutFactory.java
  15. 12
      designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/ShortCutFactory.java
  16. 25
      designer-base/src/main/java/com/fr/design/gui/frpane/BaseHyperlinkGroup.java
  17. 21
      designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupType.java
  18. 30
      designer-base/src/main/java/com/fr/design/gui/frpane/UICorrelationComboBoxPane.java
  19. 16
      designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java
  20. 233
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java
  21. 330
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java
  22. 14
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java
  23. 54
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeComparator.java
  24. 87
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/JFileTree.java
  25. 2
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java
  26. 4
      designer-base/src/main/java/com/fr/design/icon/IconPathConstants.java
  27. 3
      designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java
  28. 7
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  29. 1
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  30. 6
      designer-base/src/main/java/com/fr/design/mingche.java
  31. 16
      designer-base/src/main/java/com/fr/design/onlineupdate/domain/UpdateConstants.java
  32. 5
      designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/RestoreResultDialog.java
  33. 36
      designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/UpdateMainDialog.java
  34. 1
      designer-base/src/main/java/com/fr/design/preview/MobilePreview.java
  35. 11
      designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListControlPane.java
  36. 16
      designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java
  37. 10
      designer-base/src/main/java/com/fr/file/FILEChooserPane.java
  38. 8
      designer-base/src/main/java/com/fr/file/FileNodeFILE.java
  39. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/control_checkbox_normal.png
  40. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/control_checkbox_part.png
  41. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/control_checkbox_selected.png
  42. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/user_search_normal.png
  43. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/user_search_normal@2x.png
  44. 6
      designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java
  45. 8
      designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java
  46. 3
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java
  47. 12
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/DataPaneHelper.java
  48. 81
      designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java
  49. 6
      designer-chart/src/main/java/com/fr/design/module/FormHyperlinkGroup.java
  50. 12
      designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java
  51. 8
      designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java
  52. 32
      designer-chart/src/main/java/com/fr/extended/chart/ExtendedOtherPane.java
  53. 44
      designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java
  54. 22
      designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartShortCutFactory.java
  55. 2
      designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPane.java
  56. 16
      designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapHyperLinkPane.java
  57. 19
      designer-chart/src/main/java/com/fr/van/chart/range/component/SectionIntervalConfigPaneWithOutNum.java
  58. 123
      designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java
  59. 5
      designer-form/src/main/java/com/fr/design/form/mobile/FormMobileAttrPane.java
  60. 2
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  61. 1
      designer-form/src/main/java/com/fr/design/mainframe/actions/FormMobileAttrAction.java
  62. 120
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java
  63. 7
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java
  64. 58
      designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java
  65. 199
      designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java
  66. 10
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java
  67. 23
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  68. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java
  69. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java
  70. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/BottomCellRender.java
  71. 39
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  72. 17
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java
  73. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java
  74. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java
  75. 14
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java
  76. 8
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java
  77. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java
  78. 8
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java
  79. 38
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java
  80. 16
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java
  81. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java
  82. 27
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java
  83. 2
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java
  84. 5
      designer-realize/src/main/java/com/fr/design/report/mobile/ReportMobileAttrPane.java
  85. 8
      designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java
  86. 6
      designer-realize/src/main/java/com/fr/design/webattr/ReportWebWidgetConstants.java
  87. 96
      designer-realize/src/main/java/com/fr/design/webattr/printsettings/AbstractNativePrintSettingPane.java
  88. 91
      designer-realize/src/main/java/com/fr/design/webattr/printsettings/GlobalNativePrintSettingPane.java
  89. 2
      designer-realize/src/main/java/com/fr/design/webattr/printsettings/NoClientPrintSettingPane.java
  90. 2
      designer-realize/src/main/java/com/fr/design/webattr/printsettings/PageMarginSettingPane.java
  91. 16
      designer-realize/src/main/java/com/fr/design/webattr/printsettings/PrintSettingPane.java
  92. 18
      designer-realize/src/main/java/com/fr/design/webattr/printsettings/ReportNativePrintSettingPane.java
  93. 17
      designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java
  94. 3
      designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java
  95. 5
      designer-realize/src/main/java/com/fr/start/preload/ImagePreLoader.java
  96. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/back@1x.png
  97. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/back@2x.png
  98. BIN
      designer-realize/src/main/resources/com/fr/start/jni/splash.dylib
  99. 94
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java
  100. 80
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/SearchManegerTest.java

80
designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java

@ -16,6 +16,7 @@ import com.fr.general.GeneralContext;
import com.fr.license.exception.RegistEditionException;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.EnvChangedListener;
import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace;
@ -51,19 +52,28 @@ public class EnvChangeEntrance {
});
}
private boolean envListOkAction(EnvListPane envListPane) {
private boolean envListOkAction(EnvListPane envListPane, PopTipStrategy strategy) {
final String selectedName = envListPane.updateEnvManager();
return switch2Env(selectedName);
return switch2Env(selectedName, strategy);
}
/**
* 切换到指定名称的工作目录
*
* @param envName 目标工作目录名称
*/
public void switch2Env(final String envName) {
switch2Env(envName, PopTipStrategy.LATER);
}
/**
* 切换到新环境
*
* @param envName 新工作环境名称
* @return 是否成功
*/
public boolean switch2Env(final String envName) {
private boolean switch2Env(final String envName, PopTipStrategy strategy) {
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName);
@ -71,8 +81,13 @@ public class EnvChangeEntrance {
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
boolean checkValid = workspace != null && selectedEnv.checkValid();
if (!checkValid) {
strategy.showTip(new PopTip() {
@Override
public void show() {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon"));
}
});
return false;
}
WorkContext.switchTo(workspace, new WorkContextCallback() {
@ -85,19 +100,34 @@ public class EnvChangeEntrance {
template.refreshToolArea();
}
DesignTableDataManager.fireDSChanged(new HashMap<String, String>());
if (WorkContext.getCurrent().isLocal()) {
//初始化一下serverTray
ServerTray.init();
}
}
});
} catch (AuthException | RegistEditionException e) {
// String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed");
// String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote");
strategy.showTip(new PopTip() {
@Override
public void show() {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon"));
}
});
return false;
} catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
strategy.showTip(new PopTip() {
@Override
public void show() {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon"));
}
});
return false;
}
TemplateTreePane.getInstance().refreshDockingView();
@ -131,13 +161,11 @@ public class EnvChangeEntrance {
@Override
public void doOk() {
envListDialog.dispose();
envListOkAction(envListPane);
envListOkAction(envListPane, PopTipStrategy.LATER);
}
@Override
public void doCancel() {
envListDialog.dispose();
}
});
@ -155,11 +183,9 @@ public class EnvChangeEntrance {
@Override
public void doOk() {
if (!envListOkAction(envListPane)) {
if (!envListOkAction(envListPane, PopTipStrategy.NOW)) {
System.exit(0);
}
}
@Override
@ -170,4 +196,40 @@ public class EnvChangeEntrance {
envListDialog.setVisible(true);
}
/**
* 提示显示策略
*/
enum PopTipStrategy {
/**
* 切换失败就马上提示失败不关闭选择列表对话框
*/
NOW {
@Override
void showTip(PopTip tip) {
tip.show();
}
},
/**
* 切换失败自动关闭选择列表对话框然后提示切换失败
*/
LATER {
@Override
void showTip(final PopTip tip) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
tip.show();
}
});
}
};
abstract void showTip(PopTip tip);
}
interface PopTip {
void show();
}
}

42
designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java

@ -155,8 +155,6 @@ public class PreferencePane extends BasicPane {
createServerPane(advancePane);
createJdkHomePane(advancePane);
JPanel oraclePane = FRGUIPaneFactory.createTitledBorderPane("Oracle" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Oracle_All_Tables"));
oracleSpace = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Show_All_Oracle_Tables"));
oraclePane.add(oracleSpace);
@ -470,42 +468,6 @@ public class PreferencePane extends BasicPane {
serverPortPane.add(choosePortPane, BorderLayout.CENTER);
}
private void createJdkHomePane(JPanel advancePane) {
double p = TableLayout.PREFERRED;
double rowSize[] = {p};
double columnSize[] = {p, p, p};
JPanel serverPortPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_JDK_Home"));
advancePane.add(serverPortPane);
jdkHomeTextField = new UITextField();
UIButton chooseBtn = new UIButton("...");
chooseBtn.setPreferredSize(new Dimension(20, 20));
JPanel panel = GUICoreUtils.createBorderLayoutPane(
jdkHomeTextField, BorderLayout.CENTER,
chooseBtn, BorderLayout.EAST
);
chooseBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnValue = fileChooser.showOpenDialog(PreferencePane.this);
if (returnValue == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
jdkHomeTextField.setText(file.getAbsolutePath());
}
}
});
panel.setPreferredSize(new Dimension(300, 20));
UILabel notiJlabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Work_After_Restart_Designer"));
UILabel serverPortLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_JDK_Home") + ":");
Component[][] portComponents = {
{serverPortLabel, panel, notiJlabel},
};
JPanel choosePortPane = TableLayoutHelper.createTableLayoutPane(portComponents, rowSize, columnSize);
serverPortPane.add(choosePortPane, BorderLayout.CENTER);
}
private JPanel createMemoryPane() {
JPanel memoryPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Caching_Template"));
UILabel memoryLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Max_Caching_Template"));
@ -575,8 +537,6 @@ public class PreferencePane extends BasicPane {
this.portEditor.setValue(new Integer(designerEnvManager.getEmbedServerPort()));
this.jdkHomeTextField.setText(designerEnvManager.getJdkHome());
this.oracleSpace.setSelected(designerEnvManager.isOracleSystemSpace());
this.cachingTemplateSpinner.setValue(designerEnvManager.getCachingTemplateLimit());
this.joinProductImprove.setSelected(designerEnvManager.isJoinProductImprove());
@ -636,8 +596,6 @@ public class PreferencePane extends BasicPane {
designerEnvManager.setJettyServerPort(portEditor.getValue().intValue());
designerEnvManager.setJdkHome(jdkHomeTextField.getText());
designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected());
designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue());
designerEnvManager.setJoinProductImprove(this.joinProductImprove.isSelected());

10
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java

@ -15,11 +15,13 @@ import com.fr.transaction.CallBackAdaptor;
import com.fr.transaction.Configurations;
import com.fr.transaction.WorkerFacade;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.connection.DBConnectAuth;
import javax.swing.SwingUtilities;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@ -62,8 +64,16 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel {
ConnectionConfig mgr = ConnectionConfig.getInstance();
Iterator<String> nameIt = mgr.getConnections().keySet().iterator();
Collection<String> noAuthConnections = WorkContext.getCurrent().get(DBConnectAuth.class).getNoAuthConnections();
if (noAuthConnections == null) {
return nameList.iterator();
}
while (nameIt.hasNext()) {
String conName = nameIt.next();
if (noAuthConnections.contains(conName)) {
continue;
}
Connection connection = mgr.getConnection(conName);
filterConnection(connection, conName, nameList);
}

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

@ -35,11 +35,12 @@ 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 OTHER_DB = "Others";
private static Map<String, DriverURLName[]> jdbcMap = new HashMap<String, DriverURLName[]>();
static {
jdbcMap.put("Others", new DriverURLName[]{new DriverURLName("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:odbc:"),
jdbcMap.put(OTHER_DB, new DriverURLName[]{new DriverURLName("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:odbc:"),
new DriverURLName("org.hsqldb.jdbcDriver", "jdbc:hsqldb:file:[PATH_TO_DB_FILES]"), new DriverURLName("com.inet.tds.TdsDriver", "jdbc:inetdae7:localhost:1433/"),
new DriverURLName("COM.cloudscape.JDBCDriver", "jdbc:cloudscape:/cloudscape/"),
new DriverURLName("com.internetcds.jdbc.tds.Driver", "jdbc:freetds:sqlserver://localhost/")});
@ -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 = {"Oracle", "DB2", "SQL Server", "MySQL", "Sybase", "Access", "Derby", "Postgre","SQLite","Inceptor", OTHER_DB};
// carl:DBCP的一些属性
private IntegerEditor DBCP_INITIAL_SIZE = new IntegerEditor();
@ -182,6 +183,9 @@ public class JDBCDefPane extends JPanel {
break;
}
}
if (!out) {
this.dbtypeComboBox.setSelectedItem(OTHER_DB);
}
}
this.driverComboBox.setSelectedItem(jdbcDatabase.getDriver());
this.urlTextField.setText(jdbcDatabase.getURL());

38
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java

@ -1,7 +1,6 @@
package com.fr.design.data.tabledata.tabledatapane;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.base.ParameterHelper;
import com.fr.data.core.db.TableProcedure;
@ -35,17 +34,25 @@ import com.fr.design.menu.SeparatorDef;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.sql.SqlUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JToolBar;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
@ -75,7 +82,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
ParameterTableModel model = new ParameterTableModel() {
@Override
public UITableEditAction[] createAction() {
return (UITableEditAction[]) ArrayUtils.add(super.createDBTableAction(), new RefreshAction());
return ArrayUtils.add(super.createDBTableAction(), new RefreshAction());
}
};
editorPane = new UITableEditorPane<ParameterProvider>(model);
@ -84,6 +91,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
connectionTableProcedurePane = new ConnectionTableProcedurePane() {
@Override
protected void filter(Connection connection, String conName, List<String> nameList) {
connection.addConnection(nameList, conName, new Class[]{JDBCDatabaseConnection.class, JNDIDatabaseConnection.class});
}
};
@ -95,7 +103,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
try {
document.insertString(sqlTextPane.getCaretPosition(), target.toString(), null);
} catch (BadLocationException e) {
FRContext.getLogger().error(e.getMessage(), e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
// 这里开始作色,本来可以给sqlTextPane添加DocumentListener来实现的,
// 后来发现insertString的时候,锁定了JTextPane,不能调用setXXX来作色,先这样了.
@ -104,10 +112,12 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
}
});
sqlTextPane.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// unsupport
// do nothing
}
@Override
public void focusLost(FocusEvent e) {
if (isPreviewOrRefreshButton(e)) {
checkParameter();
@ -146,7 +156,10 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
sqlSplitPane.add(box, BorderLayout.CENTER);
box.setMinimumSize(new Dimension(310, 400));
box.setMinimumSize(new Dimension(300, 400));
// 防止数据连接名过长时影响 split pane 分割效果
connectionTableProcedurePane.setMinimumSize(new Dimension(250, 400));
connectionTableProcedurePane.setMaximumSize(new Dimension(500, 400));
// 使用SplitPane
JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, connectionTableProcedurePane, sqlSplitPane);
mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor()));
@ -160,7 +173,6 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
}
private boolean isPreviewOrRefreshButton(FocusEvent e) {
if (e.getOppositeComponent() != null) {
String name = e.getOppositeComponent().getName();
@ -272,7 +284,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
if (StringUtils.isBlank(dbName) || StringUtils.isBlank(this.sqlTextPane.getText())) {
try {
throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + ".");
} catch (Exception e) {
} catch (Exception ignore) {
// JOptionPane.showMessageDialog(DBTableDataPane.this,
// com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + ".");
}
@ -303,13 +315,14 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
refresh();
}
@Override
public void checkEnabled() {
// unsupport
// do nothing
}
}
@ -320,6 +333,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
checkParameter();
PreviewTablePane.previewTableData(DBTableDataPane.this.updateBean());
@ -333,11 +347,13 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/text.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
final QueryPane pane = new QueryPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Define_Page_Query_SQL"));
pane.populate(pageQuery);
BasicDialog dialog = pane.showWindow(DesignerContext.getDesignerFrame());
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
pageQuery = pane.update();
checkParameter();

2
designer-base/src/main/java/com/fr/design/extra/PluginUtils.java

@ -230,7 +230,7 @@ public class PluginUtils {
jo.put("licDamaged", pluginContext.isLicDamaged());
jo.put("available", pluginContext.isAvailable());
jo.put("leftDays", pluginContext.getLeftDays());
jo.put("trial", pluginContext.isOnTrial());
jo.put("onTrial", pluginContext.isOnTrial());
jo.put("deadline", getDeadline(pluginContext));
jo.put("registerFailed", pluginContext.isRegisterFailed());
ja.put(jo);

9
designer-base/src/main/java/com/fr/design/extra/PluginWebPane.java

@ -4,6 +4,7 @@ import com.fr.base.TemplateUtils;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.EncodeConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import javafx.application.Platform;
@ -32,6 +33,9 @@ import java.util.Map;
public class PluginWebPane extends JFXPanel {
private static final String RESOURCE_URL = "resourceURL";
private static final String LANGUAGE = "language";
private static final String URL_PLUS = "+";
private static final String URL_SPACING = "%20";
private static final String URL_PREFIX = "file:///";
private WebEngine webEngine;
public PluginWebPane(final String installHome, final String mainJs) {
@ -75,8 +79,9 @@ public class PluginWebPane extends JFXPanel {
StringBuffer sb = new StringBuffer();
String line;
Map<String, Object> map4Tpl = new HashMap<String, Object>();
map4Tpl.put(RESOURCE_URL, "file:///" + URLEncoder.encode(installHome, "UTF-8"));
//URL中关于空格的编码与空格所在位置相关:空格被编码成+的情况只能在查询字符串部分出现,而被编码成%20则可以出现在路径和查询字符串中
//URLEncoder会将空格转成+,这边需要+转成%20
map4Tpl.put(RESOURCE_URL, URL_PREFIX + URLEncoder.encode(installHome, EncodeConstants.ENCODING_UTF_8).replace(URL_PLUS, URL_SPACING));
map4Tpl.put(LANGUAGE, GeneralContext.getLocale().toString());
while ((line = read.readLine()) != null) {
if (sb.length() > 0) {

24
designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java

@ -17,6 +17,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants;
import com.fr.stable.ProductConstants;
import com.fr.third.javax.annotation.Nonnull;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
@ -677,32 +678,29 @@ public class MutilTempalteTabPane extends JComponent {
//当前激活的模板
String filename = openedTemplate.get(selectedIndex).getPath();
filename = FilenameUtils.standard(filename);
if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) {
specifiedTemplate.stopEditing();
int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?",
ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION) {
specifiedTemplate.saveTemplate();
HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate);
// release lock
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(specifiedTemplate.getPath());
activeTemplate(filename);
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName()));
closeTpl(specifiedTemplate, filename);
} else if (returnVal == JOptionPane.NO_OPTION) {
closeTpl(specifiedTemplate, filename);
}
} else {
HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate);
// release lock
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(specifiedTemplate.getPath());
closeTpl(specifiedTemplate, filename);
}
activeTemplate(filename);
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName()));
}
private void closeTpl(@Nonnull JTemplate<?, ?> specifiedTemplate, @Nonnull String fileName) {
HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate);
// release lock
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(specifiedTemplate.getPath());
activeTemplate(fileName);
}
/**

2
designer-base/src/main/java/com/fr/design/fun/JavaScriptActionProvider.java

@ -18,4 +18,6 @@ public interface JavaScriptActionProvider extends Mutable{
FurtherBasicBeanPane<? extends JavaScript> getJavaScriptActionPane(JavaScriptActionPane pane);
boolean isSupportType();
}

9
designer-base/src/main/java/com/fr/design/fun/impl/AbstractJavaScriptActionProvider.java

@ -26,4 +26,13 @@ public abstract class AbstractJavaScriptActionProvider extends AbstractProvider
public FurtherBasicBeanPane<? extends JavaScript> getJavaScriptActionPane(JavaScriptActionPane pane) {
return getJavaScriptActionPane();
}
/**
* 判断是否是支持的类型cpt,frm默认是
* @return
*/
@Override
public boolean isSupportType(){
return true;
}
}

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));
}
}

39
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
@ -46,10 +45,10 @@ public class ColumnRowPane extends JPanel implements UIObserver {
protected UIBasicSpinner rowSpinner;
static {
for (int i = 1; i < 1000; i++) {
for (int i = 1; i <= 1000; i++) {
columnarray[i - 1] = StableUtils.convertIntToABC(i);
}
for (int i = 1; i < 5000; i++) {
for (int i = 1; i <= 5000; i++) {
rowarray[i - 1] = StringUtils.EMPTY + i;
}
}
@ -217,6 +216,7 @@ public class ColumnRowPane extends JPanel implements UIObserver {
/**
* 添加一个listener到listenerList中
*
* @param l 监听
*/
public void addChangeListener(ChangeListener l) {
@ -225,6 +225,7 @@ public class ColumnRowPane extends JPanel implements UIObserver {
/**
* 从listenerList中移除一个listener
*
* @param l 监听
*/
public void removeChangeListener(ChangeListener l) {
@ -244,6 +245,7 @@ public class ColumnRowPane extends JPanel implements UIObserver {
/**
* 给组件登记一个观察者监听事件
*
* @param listener 监听
*/
public void registerChangeListener(UIObserverListener listener) {
@ -252,6 +254,7 @@ public class ColumnRowPane extends JPanel implements UIObserver {
/**
* 组件是否需要响应添加的观察者事件
*
* @return 如果需要响应观察者事件则返回true否则返回false
*/
public boolean shouldResponseChangeListener() {

20
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();
String menuName();
public Icon menuIcon();
Icon menuIcon();
public String createTooltip();
String createTooltip();
public Nameable createNameable(UnrepeatedNameHelper helper);
Nameable createNameable(UnrepeatedNameHelper helper);
public Class<? extends BasicBeanPane> getUpdatePane();
Class<? extends BasicBeanPane> getUpdatePane();
public Object acceptObject2Populate(Object ob);
Object acceptObject2Populate(Object ob);
public void saveUpdatedBean(ListModelElement wrapper, Object bean);
void saveUpdatedBean(ListModelElement wrapper, Object bean);
public Class <? extends JavaScript> getHyperlink();
Class<? extends JavaScript> getHyperlink();
public boolean isNeedParameterWhenPopulateJControlPane();
boolean isNeedParameterWhenPopulateJControlPane();
}

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

@ -2,15 +2,17 @@ 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.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;
import com.fr.js.JavaScript;
import com.fr.stable.Filter;
import javax.swing.Icon;
import java.awt.event.ActionEvent;
@ -83,7 +85,8 @@ public class OldShortCutFactory extends AbstractShortCutFactory {
private void wrapActionListener(NameableCreator[] creators) {
for (final NameableCreator creator : creators) {
if (!HyperlinkFilterHelper.whetherAddHyperlink4cell(creator.menuName())) {
Filter<Class<? extends JavaScript>> filter = DesignModuleFactory.getHyperlinkGroupType().getFilter();
if (!filter.accept(creator.getHyperlink())) {
continue;
}
boolean isTrue = ComparatorUtils.equals(creator.menuName(), Inter.getLocText("Datasource-Stored_Procedure")) ||

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

@ -3,7 +3,6 @@ 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;
@ -11,7 +10,10 @@ 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.js.JavaScript;
import com.fr.stable.Filter;
import com.fr.stable.StringUtils;
import javax.swing.AbstractButton;
@ -124,6 +126,7 @@ public class ShortCutFactory extends AbstractShortCutFactory {
/**
* 生成UIButton
*
* @return 菜单按钮
*/
public UIButton createUIButton() {
@ -139,7 +142,8 @@ public class ShortCutFactory extends AbstractShortCutFactory {
private void wrapActionListener(NameableCreator[] creators) {
for (final NameableCreator creator : creators) {
if (!whetherAdd(creator.menuName())) {
Filter<Class<? extends JavaScript>> filter = DesignModuleFactory.getHyperlinkGroupType().getFilter();
if (!filter.accept(creator.getHyperlink())) {
continue;
}
boolean isTrue = ComparatorUtils.equals(creator.menuName(), com.fr.design.i18n.Toolkit.i18nText("Datasource-Stored_Procedure")) ||
@ -163,9 +167,5 @@ public class ShortCutFactory extends AbstractShortCutFactory {
});
}
}
protected boolean whetherAdd(String itemName){
return HyperlinkFilterHelper.whetherAddHyperlink4cell(itemName);
}
}
}

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

@ -2,6 +2,8 @@ package com.fr.design.gui.frpane;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.module.DesignModuleFactory;
import com.fr.js.JavaScript;
import com.fr.stable.Filter;
/**
* 基础的超级链接类型, 不包括图表相关超链.
@ -14,10 +16,31 @@ public class BaseHyperlinkGroup implements HyperlinkGroupType {
/**
* 返回支持的超级链接类型
*
* @return
* @return NameableCreator[]
*/
public NameableCreator[] getHyperlinkCreators() {
return DesignModuleFactory.getCreators4Hyperlink();
}
@Override
public Filter<Class<? extends JavaScript>> getFilter() {
return new Filter<Class<? extends JavaScript>>() {
@Override
public boolean accept(Class<? extends JavaScript> aClass) {
return true;
}
};
}
@Override
public Filter<Object> getOldFilter() {
return new Filter<Object>() {
@Override
public boolean accept(Object object) {
return true;
}
};
}
}

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

@ -1,9 +1,12 @@
package com.fr.design.gui.frpane;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.js.JavaScript;
import com.fr.stable.Filter;
/**
* 超级链接 支持的类型 种类.
*
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2013-6-26 下午04:41:55
*/
@ -11,8 +14,24 @@ public interface HyperlinkGroupType {
/**
* 返回支持的超级链接类型
*
* @return NameableCreator[]
*/
public NameableCreator[] getHyperlinkCreators();
NameableCreator[] getHyperlinkCreators();
/**
* 图表超链过滤
*
* @return 图表超链过滤
*/
Filter<Class<? extends JavaScript>> getFilter();
/**
* 老图表超链的过滤
*
* @return 老图表超链的过滤
*/
Filter<Object> getOldFilter();
}

30
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,20 +15,28 @@ 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;
import com.fr.js.WebHyperlink;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Filter;
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 +83,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 刷新下拉列表和按钮
*
* @param values 下拉列表里的值
*/
public void refreshMenuAndAddMenuAction(List<? extends UIMenuNameableCreator> values) {
@ -88,7 +96,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)){
Filter<Object> filter = DesignModuleFactory.getHyperlinkGroupType().getOldFilter();
if (!filter.accept(value.getObj())) {
continue;
}
UIMenuItem item = new UIMenuItem(itemName);
@ -238,6 +247,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 增加布局
*
* @param name 名字
* @param comp 组件
*/
@ -247,6 +257,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 删除组件
*
* @param comp 组件
*/
public void removeLayoutComponent(Component comp) {
@ -255,6 +266,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 获得组件的大小
*
* @param parent 上层容器
* @return 组件的大小
*/
@ -265,6 +277,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 最小的布局大小
*
* @param parent 上层容器
* @return 最小的大小
*/
@ -274,6 +287,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 布局容器
*
* @param parent 上层容器
*/
public void layoutContainer(Container parent) {
@ -287,6 +301,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 增加监听事件
*
* @param l 监听的对象
*/
public void addChangeListener(ChangeListener l) {
@ -296,6 +311,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 删除监听事件
*
* @param l 需要删除的事件
*/
public void removeChangeListener(ChangeListener l) {
@ -337,6 +353,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 更新并且重载 当前列表的值
*
* @param list 更新的列表
*/
public void populateBean(List list) {
@ -369,6 +386,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 测试例子界面
*
* @param args 参数向量
*/
public static void main(String... args) {
@ -397,6 +415,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
/**
* 注册观察者监听事件
*
* @param listener 观察者监听事件
*/
public void registerChangeListener(UIObserverListener listener) {
@ -406,6 +425,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();
}
/**
* 鼠标进入事件
*/

233
designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java

@ -0,0 +1,233 @@
package com.fr.design.gui.icombocheckbox;
import com.fr.base.BaseUtils;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.layout.FRGUIPaneFactory;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.List;
public class UICheckListPopup extends UIPopupMenu {
private List<ActionListener> listeners = new ArrayList<ActionListener>();
private List<JCheckBox> checkBoxList = new ArrayList<JCheckBox>();
private Object[] values;
private JPanel checkboxPane;
private UIScrollPane jScrollPane;
private Color mouseEnteredColor = UIConstants.CHECKBOX_HOVER_SELECTED;
private int maxDisplayNumber = 8;
public static final String COMMIT_EVENT = "commit";
public static final String SELECT_ALL = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_All");
private static final int CHECKBOX_HEIGHT = 25;
public UICheckListPopup(Object[] value) {
super();
values = value;
initComponent();
}
public void setMouseEnteredColor(Color color) {
this.mouseEnteredColor = color;
}
public void setMaxDisplayNumber(int maxDisplayNumber) {
this.maxDisplayNumber = maxDisplayNumber;
addCheckboxValues(values);
}
private void initComponent() {
checkboxPane = new JPanel();
checkboxPane.setLayout(new GridLayout(checkBoxList.size(), 1, 0, 0));
checkboxPane.setBackground(Color.WHITE);
jScrollPane = new UIScrollPane(checkboxPane);
this.setLayout(new BorderLayout());
this.add(jScrollPane, BorderLayout.CENTER);
addCheckboxValues(values);
}
public void addCheckboxValues(Object[] value) {
checkboxPane.removeAll();
checkBoxList.clear();
//全选加在第一个位置
addOneCheckValue(SELECT_ALL);
for (Object checkValue : value) {
addOneCheckValue(checkValue);
}
addSelectListener();
jScrollPane.setPreferredSize(new Dimension(200, checkBoxList.size() * CHECKBOX_HEIGHT + 10));
//超过1页的数量时显示滚动条
if (checkBoxList.size() > maxDisplayNumber) {
jScrollPane.setPreferredSize(new Dimension(200, maxDisplayNumber * CHECKBOX_HEIGHT));
}
checkboxPane.repaint();
jScrollPane.repaint();
}
private void addOneCheckValue(Object checkValue) {
JPanel checkPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
checkPane.setPreferredSize(new Dimension(185, CHECKBOX_HEIGHT));
final JCheckBox temp = createCheckbox();
final UILabel label = new UILabel(checkValue.toString());
label.setBackground(Color.WHITE);
label.setPreferredSize(new Dimension(156, 20));
checkPane.setBackground(Color.WHITE);
checkPane.add(temp);
checkPane.add(label);
addMouseListener(temp, label);
checkBoxList.add(temp);
checkboxPane.add(checkPane);
}
private JCheckBox createCheckbox() {
JCheckBox checkBox = new JCheckBox();
checkBox.setPreferredSize(new Dimension(20, 20));
checkBox.setBackground(Color.WHITE);
checkBox.setIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_NORMAL));
checkBox.setSelectedIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_SELECTED));
return checkBox;
}
/**
* 设置鼠标事件鼠标进入时背景色变换
*
* @param checkBox
* @param label
*/
private void addMouseListener(final JCheckBox checkBox, final UILabel label) {
label.addMouseListener(new MouseAdapter() {
public void mouseExited(MouseEvent e) {
label.setBackground(Color.WHITE);
}
public void mouseEntered(MouseEvent e) {
label.setOpaque(true);
label.setBackground(mouseEnteredColor);
}
@Override
public void mouseClicked(MouseEvent e) {
checkBox.doClick();
}
});
}
/**
* 单选框选中事件
*/
private void addSelectListener() {
for (int i = 0; i < checkBoxList.size(); i++) {
JCheckBox checkBox = checkBoxList.get(i);
if (i == 0) {
checkBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
//全选checkbox事件
doSelectAll(checkBoxList.get(0).isSelected());
}
});
} else {
checkBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
//do半选判断放在commit事件里
commit();
}
});
}
}
}
/**
* 全选
*
* @param isSelected 选中是true未选是false
*/
private void doSelectAll(boolean isSelected) {
for (int i = 1; i < checkBoxList.size(); i++) {
//全选和反全选都不考虑全选按钮本身
if (!SELECT_ALL.equals(checkBoxList.get(i).getText()))
checkBoxList.get(i).setSelected(isSelected);
}
}
/**
* 获取所有选中的值
*
* @return
*/
public Object[] getSelectedValues() {
List<Object> selectedValues = new ArrayList<Object>();
int selectCount = 0;
for (int i = 1; i < checkBoxList.size(); i++) {
if (checkBoxList.get(i).isSelected()) {
selectedValues.add(values[i - 1]);
selectCount++;
}
}
//全选半选切换
switchSelectIcon(selectCount);
return selectedValues.toArray(new Object[selectedValues.size()]);
}
/**
* 切换全选半选图片
*/
private void switchSelectIcon(int selectCount) {
JCheckBox checkBox = checkBoxList.get(0);
if (selectCount == 0) {
checkBox.setIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_NORMAL));
} else if (selectCount < checkBoxList.size() - 1) {
//虽然有选中,但是要判断此时全选状态去换图标
if (checkBoxList.get(0).isSelected()) {
checkBox.setSelectedIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_HATFSELECT));
} else {
checkBox.setIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_HATFSELECT));
}
} else {
//全选了,图标要换回来
checkBox.setSelectedIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_SELECTED));
}
}
public void commit() {
fireActionPerformed(new ActionEvent(this, 0, COMMIT_EVENT));
}
@Override
public Insets getInsets() {
return new Insets(0, 0, 0, 0);
}
public void addActionListener(ActionListener listener) {
if (!listeners.contains(listener))
listeners.add(listener);
}
public void removeActionListener(ActionListener listener) {
if (listeners.contains(listener)) {
listeners.remove(listener);
}
}
protected void fireActionPerformed(ActionEvent e) {
for (ActionListener l : listeners) {
l.actionPerformed(e);
}
}
}

330
designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java

@ -0,0 +1,330 @@
package com.fr.design.gui.icombocheckbox;
import com.fr.base.BaseUtils;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
/**
* 设计器下拉复选框组件
* 支持全选半选
* 可以设置悬停颜色一页最多显示单选框个数
* 可以省略显示
*/
public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNameObserver {
//下拉框的值
private Object[] values;
//已经选中的值
private Object[] selectedValues;
private List<ActionListener> listeners = new ArrayList<ActionListener>();
private UICheckListPopup popup;
private UITextField editor;
private UIButton arrowButton;
//选中的值之间显示的分隔符
private String valueSperator;
private static final String DEFAULT_VALUE_SPERATOR = ",";
private static final String OMIT_TEXT = "...";
private UIObserverListener uiObserverListener;
private GlobalNameListener globalNameListener = null;
private String multiComboName = StringUtils.EMPTY;
private boolean showOmitText = true;
public UIComboCheckBox(Object[] value) {
this(value, DEFAULT_VALUE_SPERATOR);
}
/**
* 自定义分隔符的复选框
*
* @param value
* @param valueSperator
*/
public UIComboCheckBox(Object[] value, String valueSperator) {
values = value;
this.valueSperator = valueSperator;
initComponent();
}
/**
* 设置鼠标悬停的背景色
*
* @param color
*/
public void setCheckboxEnteredColor(Color color) {
this.popup.setMouseEnteredColor(color);
}
/**
* 设置弹出框最多显示单选的个数超过显示滚动条
*/
public void setPopupMaxDisplayNumber(int maxDisplayNumber) {
this.popup.setMaxDisplayNumber(maxDisplayNumber);
}
/**
* 是否要超过文本框长度后显示省略号
*
* @param isShowOmitText
*/
public void isShowOmitText(boolean isShowOmitText) {
this.showOmitText = isShowOmitText;
}
private void initComponent() {
this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
this.popup = new UICheckListPopup(values);
this.popup.addActionListener(new PopupAction());
this.editor = createEditor();
this.arrowButton = createArrowButton();
this.add(editor);
this.add(arrowButton);
setText();
}
private UIButton createArrowButton() {
final UIButton arrowBtn = new UIButton();
arrowBtn.setNormalPainted(false);
arrowBtn.setPreferredSize(new Dimension(20, 5));
arrowBtn.setBackground(new Color(218, 218, 218));
arrowBtn.setOpaque(true);
arrowBtn.setIcon(getIcon());
arrowBtn.setExtraPainted(false);
addPopupListener(arrowBtn);
arrowBtn.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
arrowBtn.setBackground(new Color(200, 200, 200));
}
@Override
public void mouseExited(MouseEvent e) {
arrowBtn.setBackground(new Color(218, 218, 218));
}
});
return arrowBtn;
}
private UITextField createEditor() {
UITextField editor = new UITextField();
editor.setEditable(false);
editor.setPreferredSize(new Dimension(180, 20));
addPopupListener(editor);
return editor;
}
/**
* 弹出框事件
*
* @param component
*/
private void addPopupListener(Component component) {
component.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
togglePopup();
}
});
}
/**
* 刷新复选框的列表值
*
* @param value
*/
public void refreshCombo(Object[] value) {
this.values = value;
this.popup.addCheckboxValues(value);
}
/**
* 获取复选框选中的值
*
* @return 复选框选中的值
*/
public Object[] getSelectedValues() {
return popup.getSelectedValues();
}
private class PopupAction implements ActionListener {
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(UICheckListPopup.COMMIT_EVENT)) {
selectedValues = popup.getSelectedValues();
setText();
//把事件继续传递出去
fireActionPerformed(e);
}
}
}
private void togglePopup() {
if (this.arrowButton.isEnabled()) {
popup.show(this, 0, getHeight());
}
}
/**
* 清除文本框
*/
public void clearText() {
editor.setText(StringUtils.EMPTY);
}
/**
* 获取文本框内容
*/
public String getText() {
return editor.getText();
}
/**
* 文本框设置显示值
*/
private void setText() {
StringBuilder builder = new StringBuilder();
if (selectedValues != null) {
for (Object value : selectedValues) {
builder.append(value);
builder.append(valueSperator);
}
}
//去掉末尾多余的逗号
String text = builder.length() > 0 ? builder.substring(0, builder.length() - 1) : StringUtils.EMPTY;
//计算加省略号后的文本
editor.setText(this.showOmitText ? omitEditorText(editor, text) : text);
}
/**
* 根据字体大小计算得到省略后的文字
*
* @param textEditor
* @param text
* @return 省略后的文字
*/
private static String omitEditorText(UITextField textEditor, String text) {
char[] omitChars = OMIT_TEXT.toCharArray();
//获取字体的大小
FontMetrics fontMetrics = textEditor.getFontMetrics(textEditor.getFont());
//计算省略号的长度
int omitLength = fontMetrics.charsWidth(omitChars, 0, omitChars.length);
String omitText = StringUtils.EMPTY;
char[] chars = text.toCharArray();
for (int i = 1; i <= chars.length; i++) {
//如果原文本+省略号长度超过文本框
if (fontMetrics.charsWidth(chars, 0, i) + omitLength > textEditor.getPreferredSize().getWidth()) {
//从第i-1的位置截断再拼上省略号
omitText = text.substring(0, i - 2) + OMIT_TEXT;
break;
}
}
return omitText == StringUtils.EMPTY ? text : omitText;
}
/**
* 给组件登记一个观察者监听事件
*
* @param listener 观察者监听事件
*/
@Override
public void registerChangeListener(UIObserverListener listener) {
this.uiObserverListener = listener;
}
@Override
public void setGlobalName(String name) {
multiComboName = name;
}
/**
* 组件是否需要响应添加的观察者事件
*
* @return 如果需要响应观察者事件则返回true否则返回false
*/
@Override
public boolean shouldResponseChangeListener() {
return true;
}
/**
* 注册观察者监听事件
*
* @param listener 观察者监听事件
*/
@Override
public void registerNameListener(GlobalNameListener listener) {
globalNameListener = listener;
}
private Icon getIcon() {
return BaseUtils.readIcon(IconPathConstants.ARROW_ICON_PATH);
}
/**
* 组件是否需要响应观察者事件
*
* @return 如果需要响应观察者事件则返回true否则返回false
*/
@Override
public boolean shouldResponseNameListener() {
return true;
}
public void addActionListener(ActionListener listener) {
if (!listeners.contains(listener))
listeners.add(listener);
}
public void removeActionListener(ActionListener listener) {
if (listeners.contains(listener))
listeners.remove(listener);
}
protected void fireActionPerformed(ActionEvent e) {
for (ActionListener l : listeners) {
l.actionPerformed(e);
}
}
/**
* 简单的测试demo
* @param args
*/
public static void main(String args[]) {
UIComboCheckBox comboBox = new UIComboCheckBox(new Object[]
{"MATA", "HANA", "KAKA", "KUKA", "INFI", "LILY", "RIBO", "CUBE", "MATA", "HANA", "KAKA", "KUKA"});
comboBox.isShowOmitText(false);
comboBox.setPopupMaxDisplayNumber(6);
JPanel jPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
jPanel.add(comboBox);
JFrame jFrame = new JFrame();
jFrame.setVisible(true);
jFrame.setSize(600, 400);
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jFrame.add(jPanel, BorderLayout.CENTER);
}
}

14
designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java

@ -146,14 +146,14 @@ public class EnvFileTree extends RefreshableJTree {
*
* 返回currentTreeNode下是否找到了filePath
*/
private boolean selectFilePath(ExpandMutableTreeNode currentTreeNode, String prefix, String filePath, DefaultTreeModel m_model) {
private boolean selectFilePath(ExpandMutableTreeNode currentTreeNode, String prefix, String filePath, DefaultTreeModel model) {
FileNode fileNode = (FileNode) currentTreeNode.getUserObject();
String nodePath = fileNode.getName();
String currentTreePath = prefix + nodePath;
// 如果equals,说明找到了,不必再找下去了
if (ComparatorUtils.equals(new File(currentTreePath), new File(filePath))) {
this.setSelectionPath(new TreePath(m_model.getPathToRoot(currentTreeNode)));
this.setSelectionPath(new TreePath(model.getPathToRoot(currentTreeNode)));
return true;
}
// 如果当前路径是currentFilePath的ParentFile,则expandTreeNode,并继续往下找
@ -164,7 +164,7 @@ public class EnvFileTree extends RefreshableJTree {
for (int i = 0, len = currentTreeNode.getChildCount(); i < len; i++) {
ExpandMutableTreeNode childTreeNode = (ExpandMutableTreeNode) currentTreeNode.getChildAt(i);
if (selectFilePath(childTreeNode, prefix, filePath, m_model)) {
if (selectFilePath(childTreeNode, prefix, filePath, model)) {
return true;
}
}
@ -219,7 +219,7 @@ public class EnvFileTree extends RefreshableJTree {
resFns = tList.toArray(new FileNode[tList.size()]);
}
Arrays.sort(resFns, new FileNodeComparator());
Arrays.sort(resFns, new FileNodeComparator(FRContext.getFileNodes().getSupportedTypes()));
return resFns;
}
@ -248,8 +248,8 @@ public class EnvFileTree extends RefreshableJTree {
*/
public void refreshEnv() {
DefaultTreeModel m_model = (DefaultTreeModel) this.getModel();
ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) m_model.getRoot();
DefaultTreeModel model = (DefaultTreeModel) this.getModel();
ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) model.getRoot();
rootTreeNode.removeAllChildren();
FileNode[] fns;
@ -273,7 +273,7 @@ public class EnvFileTree extends RefreshableJTree {
rootTreeNode.add(node);
}
m_model.reload(rootTreeNode);
model.reload(rootTreeNode);
}
/*

54
designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeComparator.java

@ -1,6 +1,6 @@
package com.fr.design.gui.itree.filetree;
import com.fr.file.filetree.LocalFileNodes;
import com.fr.base.FRContext;
import com.fr.file.filetree.FileNode;
import java.util.Comparator;
@ -10,15 +10,43 @@ import java.util.Comparator;
* Directory is in the first. and normal file the in the last.
*/
public class FileNodeComparator implements Comparator<FileNode> {
// 正序还是倒序
private boolean isReverse = false;
/**
* 正序还是倒序
*/
private boolean isReverse;
/**
* 文件扩展名类型
*/
private String[] supportTypes;
/**
* @see FileNodeComparator#FileNodeComparator(boolean, String[])
* @deprecated
*/
@Deprecated
public FileNodeComparator() {
this(false);
}
public FileNodeComparator(String[] types) {
this(false, types);
}
/**
* @param reverse 是否是倒序{@code true} 倒序{@code false} 正序
* @see FileNodeComparator#FileNodeComparator(boolean, String[])
* @deprecated
*/
@Deprecated
public FileNodeComparator(boolean reverse) {
this.isReverse = reverse;
this.supportTypes = FRContext.getFileNodes().getSupportedTypes();
}
public FileNodeComparator(boolean reverse, String[] types) {
this.isReverse = reverse;
this.supportTypes = types;
}
/**
@ -50,22 +78,22 @@ public class FileNodeComparator implements Comparator<FileNode> {
}
/**
* 一个简单的递归判断算法
* @param nameNode1
* @param nameNode2
* @param i
* @return
* 一个简单的递归判断算法依据文件类型排序
*
* @param nameNode1 节点1
* @param nameNode2 节点2
* @param i i
* @return value
*/
private int groupByFileType(FileNode nameNode1, FileNode nameNode2,
int i) {
if (i < LocalFileNodes.FILE_TYPE.length) {
if (nameNode1.isFileType(LocalFileNodes.FILE_TYPE[i]))
if (nameNode2.isFileType(LocalFileNodes.FILE_TYPE[i]))
if (i < supportTypes.length) {
if (nameNode1.isFileType(supportTypes[i]))
if (nameNode2.isFileType(supportTypes[i]))
return nameNode1.getName().toLowerCase().compareTo(nameNode2.getName().toLowerCase());
else
return -1;
else if (nameNode2.isFileType(LocalFileNodes.FILE_TYPE[i]))
else if (nameNode2.isFileType(supportTypes[i]))
return 1;
else {
return groupByFileType(nameNode1, nameNode2, i + 1);

87
designer-base/src/main/java/com/fr/design/gui/itree/filetree/JFileTree.java

@ -1,5 +1,18 @@
package com.fr.design.gui.itree.filetree;
import com.fr.base.BaseUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.general.ComparatorUtils;
import com.fr.stable.ArrayUtils;
import com.fr.stable.project.ProjectConstants;
import javax.swing.Icon;
import javax.swing.JTree;
import javax.swing.filechooser.FileSystemView;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
@ -11,20 +24,6 @@ import java.util.Comparator;
import java.util.List;
import java.util.Stack;
import javax.swing.Icon;
import javax.swing.JTree;
import javax.swing.filechooser.FileSystemView;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import com.fr.base.BaseUtils;
import com.fr.general.ComparatorUtils;
import com.fr.stable.ArrayUtils;
import com.fr.stable.project.ProjectConstants;
/**
* File Tree.
@ -43,8 +42,8 @@ public class JFileTree extends AbstractFileTree {
private void init(FileFilter filter) {
this.fileFilter = filter;
DefaultTreeModel m_model = new DefaultTreeModel(new DefaultMutableTreeNode(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_My_Computer")));
this.setModel(m_model);
DefaultTreeModel treeModel = new DefaultTreeModel(new DefaultMutableTreeNode(Toolkit.i18nText("Fine-Design_Basic_My_Computer")));
this.setModel(treeModel);
this.putClientProperty("JTree.lineStyle", "Angled");
@ -65,8 +64,8 @@ public class JFileTree extends AbstractFileTree {
return;
}
DefaultTreeModel m_model = (DefaultTreeModel) this.getModel();
DefaultMutableTreeNode rootTreeNode = (DefaultMutableTreeNode) m_model.getRoot();
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.getModel();
DefaultMutableTreeNode rootTreeNode = (DefaultMutableTreeNode) defaultTreeModel.getRoot();
rootTreeNode.removeAllChildren();
for (int k = 0; k < rootFiles.length; k++) {
@ -78,7 +77,7 @@ public class JFileTree extends AbstractFileTree {
}
}
// richer:不是LocalEnv根本就不会运行到这儿
m_model.reload(rootTreeNode);
defaultTreeModel.reload(rootTreeNode);
if (rootFiles.length == 1) {
File expandFile = rootFiles[0];
@ -101,12 +100,9 @@ public class JFileTree extends AbstractFileTree {
}
DefaultMutableTreeNode currentTreeNode = this.getMutableTreeNode(selectedTreePath);
StringBuffer fBuf = new StringBuffer();
while (true) {
StringBuilder fBuf = new StringBuilder();
while (currentTreeNode != null) {
// 如果已经到了根节点,直接退出.
if (currentTreeNode == null) {
break;
}
Object object = currentTreeNode.getUserObject();
if (object instanceof RootFile) {
@ -128,6 +124,7 @@ public class JFileTree extends AbstractFileTree {
/**
* 通过文件夹寻找展开路径
*
* @param currentFile 当前文件
*/
public void selectFile(File currentFile) {
@ -181,16 +178,15 @@ public class JFileTree extends AbstractFileTree {
/**
* 列出当前所有的File
*
* @param currentTreeNode 当前文件节点
* @return 当前节点下的所有File
*/
@Override
public FileDirectoryNode[] listFileNodes(DefaultMutableTreeNode currentTreeNode) {
StringBuffer fBuf = new StringBuffer();
while (true) {
StringBuilder fBuf = new StringBuilder();
while (currentTreeNode != null) {
// 如果已经到了根节点,直接退出.
if (currentTreeNode == null) {
break;
}
Object object = currentTreeNode.getUserObject();
if (object instanceof RootFile) {
RootFile rootFileNode = (RootFile) object;
@ -220,7 +216,7 @@ public class JFileTree extends AbstractFileTree {
FileDirectoryNode[] fileNodes = new FileDirectoryNode[fileNodeList.size()];
fileNodeList.toArray(fileNodes);
// 对文件夹进行排序
Arrays.sort(fileNodes, new FileNodeComparator());
Arrays.sort(fileNodes, new FileDirectoryNodeComparator());
return fileNodes;
}
// 名字进行逐层反序的回加. 例: Doload ==> C:\java\Doload ,返回到文件夹的path,因为有可能是String. 所以加上instanceof
@ -240,6 +236,7 @@ public class JFileTree extends AbstractFileTree {
*/
private DefaultTreeCellRenderer fileTreeCellRenderer = new DefaultTreeCellRenderer() {
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean selected, boolean expanded, boolean leaf, int row,
boolean hasFocus) {
@ -247,11 +244,8 @@ public class JFileTree extends AbstractFileTree {
leaf, row, hasFocus);
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) value;
StringBuffer fBuf = new StringBuffer();
while(true) {
if (treeNode == null) {
break;
}
StringBuilder fBuf = new StringBuilder();
while (treeNode != null) {
Object userObj = treeNode.getUserObject();
if (userObj instanceof RootFile) {
RootFile rootFileNode = (RootFile) userObj;
@ -269,9 +263,9 @@ public class JFileTree extends AbstractFileTree {
Font oldFont = this.getFont();
if (ComparatorUtils.equals(currentFile.getName(), ProjectConstants.WEBINF_NAME)) {
this.setForeground(Color.blue);
this.setFont(new Font(oldFont.getName(),1,oldFont.getSize()));
this.setFont(new Font(oldFont.getName(), Font.BOLD, oldFont.getSize()));
} else {
this.setFont(new Font(oldFont.getName(),0,oldFont.getSize()));
this.setFont(new Font(oldFont.getName(), Font.PLAIN, oldFont.getSize()));
}
}
// 名字进行逐层反序的回加. 例: Doload ==> C:\java\Doload
@ -289,9 +283,10 @@ public class JFileTree extends AbstractFileTree {
/**
* 对文件夹进行排序 先文件夹 然后各种类型文件
*
* @author kunsnat
*/
public class FileNodeComparator implements Comparator {
public class FileDirectoryNodeComparator implements Comparator<FileDirectoryNode> {
/**
* This method should return > 0 if v1 is greater than v2, 0 if
* v1 is equal to v2, or < 0 if v1 is less than v2.
@ -302,21 +297,19 @@ public class JFileTree extends AbstractFileTree {
* @param v2 comparison value.值2
* @return < 0, 0, or > 0 for v1<v2, v1==v2, or v1>v2 .值1大于值2返回大于0相等返回0小于和大于相反
*/
public int compare(Object v1, Object v2) {
FileDirectoryNode nameNode1 = (FileDirectoryNode) v1;
FileDirectoryNode nameNode2 = (FileDirectoryNode) v2;
if (nameNode1.isDirectory()) {
if (nameNode2.isDirectory()) {
return nameNode1.getName().toLowerCase().compareTo(nameNode2.getName().toLowerCase());
@Override
public int compare(FileDirectoryNode v1, FileDirectoryNode v2) {
if (v1.isDirectory()) {
if (v2.isDirectory()) {
return v1.getName().toLowerCase().compareTo(v2.getName().toLowerCase());
} else {
return -1;
}
} else {
if (nameNode2.isDirectory()) {
if (v2.isDirectory()) {
return 1;
} else {
return nameNode1.getName().toLowerCase().compareTo(nameNode2.getName().toLowerCase());
return v1.getName().toLowerCase().compareTo(v2.getName().toLowerCase());
}
}
}

2
designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java

@ -217,7 +217,7 @@ public class TemplateFileTree extends EnvFileTree {
fileNodes = list.toArray(new FileNode[list.size()]);
}
Arrays.sort(fileNodes, new FileNodeComparator());
Arrays.sort(fileNodes, new FileNodeComparator(FRContext.getFileNodes().getSupportedTypes()));
return fileNodes;
}

4
designer-base/src/main/java/com/fr/design/icon/IconPathConstants.java

@ -33,4 +33,8 @@ public class IconPathConstants {
public static final String XMLA_ICON_PATH = "/com/fr/design/images/data/cube.png";
public static final String FORBID_ICON_PATH = "/com/fr/web/images/form/forbid.png";
public static final String EDIT_ICON_PATH = "/com/fr/design/images/control/newEdit.png";
public static final String ARROW_ICON_PATH = "com/fr/design/images/buttonicon/arrow.png";
public static final String CHECKBOX_NORMAL = "com/fr/design/images/buttonicon/control_checkbox_normal.png";
public static final String CHECKBOX_SELECTED = "com/fr/design/images/buttonicon/control_checkbox_selected.png";
public static final String CHECKBOX_HATFSELECT = "com/fr/design/images/buttonicon/control_checkbox_part.png";
}

3
designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java

@ -9,7 +9,6 @@ import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.write.submit.DBManipulationPane;
import com.fr.form.ui.WebContentUtils;
import com.fr.js.JavaScript;
import javax.swing.BorderFactory;
@ -46,9 +45,11 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
Set<JavaScriptActionProvider> javaScriptActionProviders = ExtraDesignClassManager.getInstance().getArray(JavaScriptActionProvider.XML_TAG);
if (javaScriptActionProviders != null) {
for (JavaScriptActionProvider jsp : javaScriptActionProviders) {
if(jsp.isSupportType()){
paneList.add(jsp.getJavaScriptActionPane(this));
}
}
}
// 自定义事件
// paneList.add(new CustomActionPane());
return paneList;

7
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -246,6 +246,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
new MkdirDialog();
stateChange();
}
}
@ -263,7 +264,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
@Override
public void actionPerformed(ActionEvent evt) {
selectedOperation.showInExplorer();
}
}
@ -281,10 +281,8 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
@Override
public void actionPerformed(ActionEvent evt) {
selectedOperation.refresh();
stateChange();
}
}
@ -322,6 +320,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
new FileRenameDialog(node);
MutilTempalteTabPane.getInstance().repaint();
stateChange();
}
}
@ -347,8 +346,8 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
WARNING_MESSAGE);
return;
}
selectedOperation.deleteFile();
stateChange();
}
}

1
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -1091,7 +1091,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
public void previewMenuActionPerformed(PreviewProvider provider) {
setPreviewType(provider);
WebPreviewUtils.preview(this, provider);
}
/**

6
designer-base/src/main/java/com/fr/design/mingche.java

@ -1,6 +0,0 @@
package com.fr.design;
public class mingche
{
}

16
designer-base/src/main/java/com/fr/design/onlineupdate/domain/UpdateConstants.java

@ -4,7 +4,11 @@ package com.fr.design.onlineupdate.domain;
* Created by XINZAI on 2018/8/21.
*/
import com.fr.third.org.apache.commons.collections4.collection.UnmodifiableCollection;
import com.fr.third.org.apache.commons.collections4.list.UnmodifiableList;
import java.awt.Color;
import java.util.Arrays;
/**
* 更新升级的常量
@ -28,7 +32,7 @@ public interface UpdateConstants {
int BYTE = 153600;
String[] JARS_FOR_SERVER_X = new String[]{
UnmodifiableList JARS_FOR_SERVER_X = new UnmodifiableList(Arrays.asList(new String[]{
"fine-activator-10.0.jar",
"fine-core-10.0.jar",
"fine-report-engine-10.0.jar",
@ -41,16 +45,16 @@ public interface UpdateConstants {
"fine-datasource-10.0.jar",
"fine-third-10.0.jar",
"fine-accumulator-10.0.jar"
};
}));
String[] JARS_FOR_DESIGNER_X = new String[]{
UnmodifiableList JARS_FOR_DESIGNER_X = new UnmodifiableList(Arrays.asList(new String[]{
"fine-report-designer-10.0.jar",
"aspectjrt.jar"
};
}));
String[] LOG_TYPE = new String[]{
UnmodifiableList LOG_TYPE = new UnmodifiableList(Arrays.asList(new String[]{
"REPORT", "MOBILE", "CHART", "PFC", "BI"
};
}));
}

5
designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/RestoreResultDialog.java

@ -27,6 +27,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -161,7 +162,7 @@ public class RestoreResultDialog extends JDialog {
}
private void putJarBackupFilesToInstallLib(String installHome, Map<String, String> map, java.util.List<String> list) {
String[] files = UpdateConstants.JARS_FOR_DESIGNER_X;
List<String> files = UpdateConstants.JARS_FOR_DESIGNER_X;
String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR;
for (String file : files) {
map.put(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, file),
@ -171,7 +172,7 @@ public class RestoreResultDialog extends JDialog {
}
private void putJarBackupFilesToInstallEnv(String installHome, Map<String, String> map, java.util.List<String> list) {
String[] files = UpdateConstants.JARS_FOR_SERVER_X;
List<String> files = UpdateConstants.JARS_FOR_SERVER_X;
String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR;
for (String file : files) {
map.put(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, file),

36
designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/UpdateMainDialog.java

@ -54,12 +54,7 @@ import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.*;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -445,8 +440,8 @@ public class UpdateMainDialog extends UIDialog {
return;
}
if (cacheFile.exists()) {
FileReader reader = new FileReader(cacheFile);
BufferedReader br = new BufferedReader(reader);
InputStreamReader streamReader = new InputStreamReader(new FileInputStream(cacheFile), "UTF-8");
BufferedReader br = new BufferedReader(streamReader);
String readStr, updateTimeStr;
while ((readStr = br.readLine()) != null) {
@ -468,7 +463,7 @@ public class UpdateMainDialog extends UIDialog {
}
}
br.close();
reader.close();
streamReader.close();
}
}
@ -492,8 +487,8 @@ public class UpdateMainDialog extends UIDialog {
if (endTime.equals(lastUpdateCacheTime) || jsonArray.length() == 0 || ComparatorUtils.compare(endTime, lastUpdateCacheTime) <= 0) {
return;
}
FileWriter fileWriter = new FileWriter(cacheFile, true);
BufferedWriter bufferWriter = new BufferedWriter(fileWriter);
OutputStreamWriter writerStream = new OutputStreamWriter(new FileOutputStream(cacheFile), "UTF-8");
BufferedWriter bufferWriter = new BufferedWriter(writerStream);
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jo = (JSONObject) jsonArray.get(i);
bufferWriter.write((String) jo.get("update") + '\t' + jo.get("title"));
@ -501,7 +496,7 @@ public class UpdateMainDialog extends UIDialog {
bufferWriter.flush();
}
bufferWriter.close();
fileWriter.close();
writerStream.close();
lastUpdateCacheState = UPDATE_CACHE_STATE_SUCCESS;
lastUpdateCacheTime = endTime;
cacheProperty.updateProperty("updateTime", lastUpdateCacheTime);
@ -680,7 +675,7 @@ public class UpdateMainDialog extends UIDialog {
jarCurrentLabel.setText(downloadFileConfig.optString("buildNO"));
}
private void backupFilesFromInstallEnv(String installHome, String todayBackupDir, String[] files) {
private void backupFilesFromInstallEnv(String installHome, String todayBackupDir, List<String> files) {
for (String file : files) {
try {
IOUtils.copy(
@ -692,7 +687,7 @@ public class UpdateMainDialog extends UIDialog {
}
}
private void backupFilesFromInstallLib(String installHome, String todayBackupDir, String[] files) {
private void backupFilesFromInstallLib(String installHome, String todayBackupDir, List<String> files) {
for (String file : files) {
try {
IOUtils.copy(
@ -736,21 +731,22 @@ public class UpdateMainDialog extends UIDialog {
}
//获取服务器jar包列表
private String[] getJARList4Server() {
private List<String> getJARList4Server() {
return UpdateConstants.JARS_FOR_SERVER_X;
}
//获取设计器jar包列表
private String[] getJARList4Designer() {
private List<String> getJARList4Designer() {
return UpdateConstants.JARS_FOR_DESIGNER_X;
}
//获取服务器jar包下载列表
private String[] getDownLoadJAR4Server() {
ArrayList<String> jarList = new ArrayList<String>();
List<String> serverItems = getJARList4Server();
for (DownloadItem downloadItem : downloadItems) {
String downloadItemName = downloadItem.getName();
if (ArrayUtils.contains(getJARList4Server(), downloadItemName)) {
if (serverItems.contains(downloadItemName)) {
jarList.add(downloadItemName);
}
}
@ -760,9 +756,10 @@ public class UpdateMainDialog extends UIDialog {
//获取设计器jar包下载列表
private String[] getDownLoadJAR4Designer() {
ArrayList<String> jarList = new ArrayList<String>();
List<String> designerJarItems = getJARList4Designer();
for (DownloadItem downloadItem : downloadItems) {
String downloadItemName = downloadItem.getName();
if (ArrayUtils.contains(getJARList4Designer(), downloadItemName)) {
if (designerJarItems.contains(downloadItemName)) {
jarList.add(downloadItemName);
}
}
@ -793,7 +790,8 @@ public class UpdateMainDialog extends UIDialog {
//判断是否是有效的日志内容
private boolean isValidLogInfo(String logContent) {
String log = logContent.toUpperCase();
for (String s : UpdateConstants.LOG_TYPE) {
List<String> logType = UpdateConstants.LOG_TYPE;
for (String s : logType) {
if (log.startsWith(s)) {
return true;
}

1
designer-base/src/main/java/com/fr/design/preview/MobilePreview.java

@ -1,7 +1,6 @@
package com.fr.design.preview;
import com.fr.design.fun.impl.AbstractPreviewProvider;
import java.util.HashMap;
import java.util.Map;

11
designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListControlPane.java

@ -253,23 +253,16 @@ public class AuthorityListControlPane extends BasicPane {
* @param authorities authority
*/
public void setAuthority(List<DesignAuthority> authorities) {
if (authorities == null || authorities.isEmpty()) {
return;
}
DefaultListModel<DesignAuthority> model = (DefaultListModel<DesignAuthority>) authorityList.getModel();
model.clear();
if (authorities != null && !authorities.isEmpty()) {
for (DesignAuthority authority : authorities) {
model.addElement(authority);
}
int size = model.getSize() - 1;
authorityList.setSelectedIndex(size);
authorityList.ensureIndexIsVisible(size);
}
authorityList.revalidate();
authorityList.repaint();
}

16
designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java

@ -1,5 +1,6 @@
package com.fr.design.remote.ui;
import com.fr.base.BaseUtils;
import com.fr.design.border.UITitledBorder;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.dialog.BasicPane;
@ -57,7 +58,7 @@ public class UserManagerPane extends BasicPane {
/**
* 每页个数
*/
private final int DEFAULT_NUM_EACH_PAGE = 50;
private static final int DEFAULT_NUM_EACH_PAGE = 50;
/**
* 获取的决策平台成员
@ -170,7 +171,7 @@ public class UserManagerPane extends BasicPane {
/**
* 搜索关键词变更监听
*/
private DocumentListener documentListener = new DocumentListener() {
private transient DocumentListener documentListener = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
keyWord = keyField.getText();
@ -240,13 +241,14 @@ public class UserManagerPane extends BasicPane {
);
// 搜索
JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
searchPanel.setBorder(BorderFactory.createEmptyBorder());
keyField.setPreferredSize(new Dimension(250, 20));
JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5));
searchPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
keyField.setPreferredSize(new Dimension(270, 20));
keyField.requestFocus();
keyField.addKeyListener(keyFieldKeyListener);
keyField.getDocument().addDocumentListener(documentListener);
keyButton.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Search"));
keyButton.setIcon(BaseUtils.readIcon("com/fr/design/images/buttonicon/user_search_normal.png"));
keyButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Search"));
keyButton.addActionListener(keyButtonActionListener);
searchPanel.add(keyField);
searchPanel.add(keyButton);
@ -367,9 +369,9 @@ public class UserManagerPane extends BasicPane {
final SwingWorker getMemberWorker = new SwingWorker<List<RemoteDesignMember>, Void>() {
@Override
protected List<RemoteDesignMember> doInBackground() {
addingMembers.clear();
String username = WorkContext.getCurrent().getConnection().getUserName();
synchronized (addingMembers) {
addingMembers.clear();
Collection<RemoteDesignMember> more = WorkContext.getCurrent().get(DecisionOperator.class).getMembers(username, keyword);
pageNum = 1;
if (!more.isEmpty()) {

10
designer-base/src/main/java/com/fr/file/FILEChooserPane.java

@ -23,7 +23,6 @@ import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.filetree.FileNode;
import com.fr.file.filetree.LocalFileNodes;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.file.filter.FILEFilter;
import com.fr.general.ComparatorUtils;
@ -693,14 +692,9 @@ public class FILEChooserPane extends BasicPane {
String appName = ProductConstants.APP_NAME;
JTemplate editing = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (editing == null || !editing.isChartBook()) {
String[] fileSuffix_local = LocalFileNodes.FILE_TYPE;
EnumSet<FileExtension> fileExtensions = EnumSet.of(FileExtension.CPT, FileExtension.CPTX, FileExtension.FRM, FileExtension.FRMX, FileExtension.CHT);
if (type == JFileChooser.OPEN_DIALOG) {
if (WorkContext.getCurrent().isLocal()) { //本地连接
this.addChooseFILEFilter(new ChooseFileFilter(fileSuffix_local, appName + Toolkit.i18nText("Fine-Design_Report_Template_File")));
} else {
this.addChooseFILEFilter(new ChooseFileFilter(fileExtensions, appName + Toolkit.i18nText("Fine-Design_Report_Template_File")));
}
this.addChooseFILEFilter(new ChooseFileFilter(FRContext.getFileNodes().getSupportedTypes(), appName + Toolkit.i18nText("Fine-Design_Report_Template_File")));
}
// ben:filefilter设置初值为cpt过滤

8
designer-base/src/main/java/com/fr/file/FileNodeFILE.java

@ -211,7 +211,7 @@ public class FileNodeFILE implements FILE {
try {
FileNode[] nodeArray;
nodeArray = listFile(node.getEnvPath());
Arrays.sort(nodeArray, new FileNodeComparator());
Arrays.sort(nodeArray, new FileNodeComparator(FRContext.getFileNodes().getSupportedTypes()));
return fileNodeArray2FILEArray(nodeArray, envPath);
} catch (Exception e) {
@ -240,7 +240,7 @@ public class FileNodeFILE implements FILE {
return FRContext.getFileNodes().list(rootFilePath);
}
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return new FileNode[0];
}
@ -280,7 +280,7 @@ public class FileNodeFILE implements FILE {
try {
return FRContext.getCommonOperator().fileLocked(node.getEnvPath());
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;
}
}
@ -304,7 +304,7 @@ public class FileNodeFILE implements FILE {
try {
return WorkContext.getWorkResource().exist(node.getEnvPath());
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;
}
}

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/control_checkbox_normal.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/control_checkbox_part.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/control_checkbox_selected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/user_search_normal.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/user_search_normal@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 844 B

6
designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java

@ -61,6 +61,7 @@ import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.injectable.PluginSingleInjection;
import com.fr.plugin.solution.closeable.CloseableContainedMap;
import com.fr.stable.ArrayUtils;
import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider;
import com.fr.van.chart.area.AreaIndependentVanChartInterface;
@ -107,6 +108,8 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
private static Map<String, String> idAndPriorityMap = new HashMap<String, String>();
public static final String TYPE_PANE_DEFAULT_TITLE = "DEFAULT_NAME";
public synchronized static ChartTypeInterfaceManager getInstance() {
return classManager;
@ -260,6 +263,9 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
String plotID = entry.getKey();
AbstractChartTypePane pane = entry.getValue().getPlotTypePane();
if (AssistUtils.equals(pane.title4PopupWindow(), TYPE_PANE_DEFAULT_TITLE)) {
continue;
}
pane.setPlotID(plotID);
paneList.add(pane);

8
designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java

@ -1,6 +1,7 @@
package com.fr.design.chart.fun.impl;
import com.fr.chart.chartattr.Plot;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.chart.fun.IndependentChartUIProvider;
import com.fr.design.condition.ConditionAttributesPane;
@ -40,7 +41,12 @@ public abstract class AbstractIndependentChartsUI extends AbstractProvider imple
@Override
public AbstractChartTypePane getPlotTypePane() {
return new PiePlotPane();
return new PiePlotPane() {
@Override
public String title4PopupWindow() {
return ChartTypeInterfaceManager.TYPE_PANE_DEFAULT_TITLE;
}
};
}
@Override

3
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java

@ -152,8 +152,9 @@ public class ChartTypePane extends AbstractChartAttrPane{
try{
Chart newDefaultChart = (Chart)((AbstractChartTypePane)getSelectedPane()).getDefaultChart().clone();
if(!chart.accept(newDefaultChart.getClass())){
if (!ComparatorUtils.equals(chart.getClass(), newDefaultChart.getClass())) {
//vanChart 和 chart 之间切换
//不同chart之间切换
editingCollection.removeNameObject(editingCollection.getSelectedIndex());
editingCollection.addChart(newDefaultChart);
chart = newDefaultChart;

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();
}
}

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

@ -7,12 +7,17 @@ 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.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.Filter;
import com.fr.stable.bridge.StableFactory;
/**
@ -31,12 +36,82 @@ 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 Filter<Class<? extends JavaScript>> getFilter() {
return new Filter<Class<? extends JavaScript>>() {
@Override
public boolean accept(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;
}
};
}
@Override
public Filter<Object> getOldFilter() {
return new Filter<Object>() {
@Override
public boolean accept(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;
}
};
}
}

6
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 = {
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);
}
}

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

@ -53,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();
customFieldComboBoxPane = createExtendedCustomFieldComboBoxPane();
if (customFieldComboBoxPane != null) {
this.add(customFieldComboBoxPane, BorderLayout.CENTER);
}
@ -65,8 +65,8 @@ public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataC
return new JPanel();
}
protected boolean hasCustomFieldPane() {
return false;
protected ExtendedCustomFieldComboBoxPane createExtendedCustomFieldComboBoxPane() {
return null;
}
protected Component[] fieldComponents() {
@ -96,7 +96,7 @@ public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataC
if (dataConfig != null) {
populate((T) dataConfig);
if (hasCustomFieldPane()) {
if (customFieldComboBoxPane != null) {
customFieldComboBoxPane.populateBean(dataConfig);
}
}
@ -115,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());
}

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

@ -38,6 +38,7 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
private static final String[] HEADS = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Field_Name"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Summary_Method")};
private UseFieldValuePane useFieldValuePane;
private CustomFieldNamePane customFieldNamePane;
private List<String> fieldList = new ArrayList<String>();
@ -69,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);
@ -118,7 +123,8 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
private void initComponents() {
series = new UIComboBox();
value = new UIComboBox();
value = valueComboBoxHasNone() ? new UIComboBoxWithNone() : new UIComboBox();
function = new CalculateComboBox();
Component[][] components = new Component[][]{

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

@ -16,22 +16,24 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.Arrays;
/**
* Created by shine on 2018/3/12.
*/
public class ExtendedOtherPane extends AbstractChartAttrPane {
public class ExtendedOtherPane<T extends AbstractChart> extends AbstractChartAttrPane {
private ExtendedChartHyperLinkPane hyperLinkPane;
private UIButtonGroup refreshEnabled;
private UISpinner autoRefreshTime;
private JPanel contentPane;
protected AbstractChart getAbstractChart(Chart chart) {
if (chart != null && chart instanceof AbstractChart) {
return (AbstractChart) chart;
private T chart;
protected void setChart(Chart chart) {
if (chart instanceof AbstractChart) {
this.chart = (T) chart;
}
return null;
}
@Override
@ -40,7 +42,7 @@ public class ExtendedOtherPane extends AbstractChartAttrPane {
return;
}
AbstractChart chart = getAbstractChart(collection.getSelectedChart());
setChart(collection.getSelectedChart());
if (chart != null) {
hyperLinkPane.populateBean(chart);
@ -57,7 +59,7 @@ public class ExtendedOtherPane extends AbstractChartAttrPane {
return;
}
AbstractChart chart = getAbstractChart(collection.getSelectedChart());
setChart(collection.getSelectedChart());
if (chart != null) {
hyperLinkPane.updateBean(chart);
@ -77,16 +79,20 @@ public class ExtendedOtherPane extends AbstractChartAttrPane {
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double[] columnSize = {f, e};
double[] rowSize = {p, p, p, p, p, p};
Component[][] components = new Component[][]{
new Component[]{createRefreshPane(), null},
new Component[]{createHyperlinkPane(), null}
};
Component[][] components = getComponents(createRefreshPane(), createHyperlinkPane());
double[] rowSize = new double[components.length];
Arrays.fill(rowSize, p);
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
protected Component[][] getComponents(JPanel refresh, JPanel hyperlink) {
return new Component[][]{
new Component[]{refresh, null},
new Component[]{hyperlink, null}
};
}
@Override
public String getIconPath() {
return null;

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 {
protected String getDefaultLocaleString() {
return Toolkit.i18nText("Fine-Design_Chart_Use_None");
}
@Override
public void refreshBoxItems(List list) {
super.refreshBoxItems(list);
addDefaultItem();
}
@Override
public void clearBoxItems() {
super.clearBoxItems();
addDefaultItem();
}
private void addDefaultItem() {
addItem(getDefaultLocaleString());
}
@Override
public void setSelectedItem(Object anObject) {
super.setSelectedItem(anObject);
if (getSelectedIndex() == -1) {//找不到的都选中无。中文的无 英文下是none。
super.setSelectedItem(getDefaultLocaleString());
}
}
}

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);
}
}
}

2
designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPane.java

@ -114,7 +114,7 @@ public class VanChartBackgroundPane extends BasicPane {
}
private void fireStateChanged() {
protected void fireStateChanged() {
Object[] listeners = listenerList.getListenerList();
ChangeEvent e = null;

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;
}
};
}

19
designer-chart/src/main/java/com/fr/van/chart/range/component/SectionIntervalConfigPaneWithOutNum.java

@ -1,9 +1,10 @@
package com.fr.van.chart.range.component;
import com.fr.chart.chartglyph.MapHotAreaColor;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.gui.style.series.MapColorPickerPaneWithFormula;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.JPanel;
@ -19,6 +20,10 @@ import java.awt.Dimension;
public class SectionIntervalConfigPaneWithOutNum extends MapColorPickerPaneWithFormula {
private BoldFontTextLabel numLabel;
public String getNameOfSubRange() {
return Toolkit.i18nText("Fine-Design_Chart_Range_Num");
}
public SectionIntervalConfigPaneWithOutNum(AbstractAttrNoScrollPane container) {
super(container);
getDesignTypeButtonGroup().addChangeListener(new ChangeListener() {
@ -33,6 +38,7 @@ public class SectionIntervalConfigPaneWithOutNum extends MapColorPickerPaneWithF
});
}
@Override
protected JPanel getUpControlPane(Component[][] components) {
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH;
@ -48,18 +54,25 @@ public class SectionIntervalConfigPaneWithOutNum extends MapColorPickerPaneWithF
@Override
protected Component[][] createComponents() {
numLabel = new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Divided_Stage"));
numLabel = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Value_Divided_Stage"));
setRegionVisible(false);
return new Component[][]{
new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Range_Num")),getDesignTypeButtonGroup()},
new Component[]{new BoldFontTextLabel(getNameOfSubRange()), getDesignTypeButtonGroup()},
new Component[]{numLabel, getRegionNumPane()},
};
}
@Override
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
return new Dimension((int) dim.getWidth(), (int) dim.getHeight() - (numLabel.isVisible() ? 0 : 30));
}
@Override
public void populateBean(MapHotAreaColor hotAreaColor) {
super.populateBean(hotAreaColor);
setRegionVisible(hotAreaColor.getUseType() == 1);
}
}

123
designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java

@ -7,26 +7,32 @@ import java.awt.Toolkit;
import java.awt.event.ContainerEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter;
import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.designer.properties.mobile.BodyMobilePropertyUI;
import com.fr.design.form.layout.FRFitLayout;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.PaddingMargin;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WLayout;
import com.fr.general.FRLogger;
import com.fr.general.FRScreen;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.stable.ArrayUtils;
import edu.emory.mathcs.backport.java.util.Arrays;
import javax.swing.JOptionPane;
@ -38,6 +44,7 @@ import javax.swing.JOptionPane;
public class XWFitLayout extends XLayoutContainer {
private static final long serialVersionUID = 8112908607102660176L;
private static final int EACH_ROW_COUNT = 4;
//由于屏幕分辨率不同,界面上的容器大小可能不是默认的100%,此时拖入组件时,保存的大小按照100%时的计算
protected double containerPercent = 1.0;
@ -1209,4 +1216,120 @@ public class XWFitLayout extends XLayoutContainer {
public boolean isMovable() {
return false;
}
public boolean switch2FitBodyLayout(XCreator creator) {
try {
XWFitLayout xfl = (XWFitLayout) creator.getBackupParent();
//备份一下组件间隔
int compInterval = xfl.toData().getCompInterval();
Component[] components = creator.getComponents();
Arrays.sort(components, new ComparatorComponentLocation());
xfl.getLayoutAdapter().removeBean(creator, creator.getWidth(), creator.getHeight());
xfl.remove(creator);
for (Component comp : components) {
XCreator xCreator = (XCreator) comp;
if (xCreator.shouldScaleCreator()) {
XLayoutContainer parentPanel = xCreator.initCreatorWrapper(xCreator.getHeight());
xfl.add(parentPanel, xCreator.toData().getWidgetName());
parentPanel.updateChildBound(xfl.getActualMinHeight());
continue;
}
xfl.add(xCreator);
}
//这边计算的时候会先把组件间隔去掉
moveComponents2FitLayout(xfl);
for (int i = 0; i < components.length; i++) {
Component comp = xfl.getComponent(i);
creator = (XCreator) comp;
creator.setBackupBound(components[i].getBounds());
}
//把组件间隔加上
if (xfl.toData().getCompInterval() != compInterval) {
xfl.moveContainerMargin();
xfl.moveCompInterval(xfl.getAcualInterval());
xfl.toData().setCompInterval(compInterval);
xfl.addCompInterval(xfl.getAcualInterval());
}
xfl.toData().setLayoutType(WBodyLayoutType.FIT);
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
formDesigner.getSelectionModel().setSelectedCreator(xfl);
return true;
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
return false;
}
}
private void moveComponents2FitLayout(XWFitLayout xwFitLayout) {
Component[] components = xwFitLayout.getComponents();
if (components.length == 0) {
xwFitLayout.updateBoundsWidget();
return;
}
int layoutWidth = xwFitLayout.getWidth() - xwFitLayout.toData().getMargin().getLeft() - xwFitLayout.toData().getMargin().getRight();
int layoutHeight = xwFitLayout.getHeight() - xwFitLayout.toData().getMargin().getTop() - xwFitLayout.toData().getMargin().getBottom();
int leftMargin = xwFitLayout.toData().getMargin().getLeft();
int topMargin = xwFitLayout.toData().getMargin().getTop();
xwFitLayout.toData().setCompInterval(0);
int row = (components.length / EACH_ROW_COUNT) + (components.length % EACH_ROW_COUNT == 0 ? 0 : 1);
//最后一行的列数不定
int column = components.length % EACH_ROW_COUNT == 0 ? EACH_ROW_COUNT : components.length % EACH_ROW_COUNT;
int componentWidth = layoutWidth / EACH_ROW_COUNT;
int componentHeight = layoutHeight / row;
for (int i = 0; i < row - 1; i++) {
for (int j = 0; j < EACH_ROW_COUNT; j++) {
components[EACH_ROW_COUNT * i + j].setBounds(
leftMargin + componentWidth * j,
topMargin + componentHeight * i,
j == EACH_ROW_COUNT - 1 ? layoutWidth - componentWidth * (EACH_ROW_COUNT - 1) : componentWidth,
componentHeight
);
}
}
//最后一行列数是特殊的,要单独处理
int lastRowWidth = layoutWidth / column;
int lastRowHeight = layoutHeight - componentHeight * (row - 1);
for (int i = 0; i < column; i++) {
components[EACH_ROW_COUNT * (row - 1) + i].setBounds(
leftMargin + lastRowWidth * i,
topMargin + componentHeight * (row - 1),
i == column - 1 ? layoutWidth - lastRowWidth * (column - 1) : lastRowWidth,
lastRowHeight
);
}
for (int i = 0; i < components.length; i++) {
if (components[i] instanceof XWCardMainBorderLayout) {
((XWCardMainBorderLayout) components[i]).recalculateChildWidth(components[i].getWidth(), false);
((XWCardMainBorderLayout) components[i]).recalculateChildHeight(components[i].getHeight(), false);
}
xwFitLayout.dealDirections((XCreator) components[i], false);
}
xwFitLayout.updateBoundsWidget();
}
//以组件的位置来确定先后顺序,y小的在前,x小的在前
private class ComparatorComponentLocation implements Comparator {
@Override
public int compare(Object o1, Object o2) {
if (((Component) o1).getY() < ((Component) o2).getY()) {
return -1;
} else if (((Component) o1).getY() > ((Component) o2).getY()) {
return 1;
} else {
if (((Component) o1).getX() < ((Component) o2).getX()) {
return -1;
} else if (((Component) o1).getX() > ((Component) o2).getX()) {
return 1;
} else {
return 0;
}
}
}
}
}

5
designer-form/src/main/java/com/fr/design/form/mobile/FormMobileAttrPane.java

@ -13,8 +13,6 @@ import java.awt.*;
* Created by fanglei on 2016/11/17.
*/
public class FormMobileAttrPane extends BasicBeanPane<FormMobileAttr>{
//工具栏容器
private MobileToolBarPane mobileToolBarPane;
// 模版设置面板
private FormMobileTemplateSettingsPane formMobileTemplateSettingsPane;
// 其他
@ -33,7 +31,6 @@ public class FormMobileAttrPane extends BasicBeanPane<FormMobileAttr>{
panel.setBorder(BorderFactory.createEmptyBorder(PADDING, PADDING, PADDING, PADDING));
panel.add(formMobileTemplateSettingsPane = new FormMobileTemplateSettingsPane());
panel.add(mobileToolBarPane = new MobileToolBarPane());
panel.add(formMobileOthersPane = new FormMobileOthersPane());
JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -47,7 +44,6 @@ public class FormMobileAttrPane extends BasicBeanPane<FormMobileAttr>{
if (ob == null) {
ob = new FormMobileAttr();
}
this.mobileToolBarPane.populateBean(ob);
this.formMobileTemplateSettingsPane.populateBean(ob);
this.formMobileOthersPane.populateBean(ob);
}
@ -55,7 +51,6 @@ public class FormMobileAttrPane extends BasicBeanPane<FormMobileAttr>{
@Override
public FormMobileAttr updateBean() {
FormMobileAttr formMobileAttr = new FormMobileAttr();
this.mobileToolBarPane.updateBean(formMobileAttr);
this.formMobileTemplateSettingsPane.updateBean(formMobileAttr);
this.formMobileOthersPane.updateBean(formMobileAttr);
return formMobileAttr;

2
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -6,9 +6,7 @@ import com.fr.base.Parameter;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignState;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.actions.file.WebPreviewUtils;
import com.fr.design.cell.FloatElementsProvider;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.TargetComponent;
import com.fr.design.designer.beans.actions.CopyAction;
import com.fr.design.designer.beans.actions.CutAction;

1
designer-form/src/main/java/com/fr/design/mainframe/actions/FormMobileAttrAction.java

@ -72,6 +72,7 @@ public class FormMobileAttrAction extends JTemplateAction<JForm> {
// 设置移动端属性并刷新界面
formTpl.setFormMobileAttr(formMobileAttr); // 会调整 body 的自适应布局,放到最后
((FormArea)jf.getFormDesign().getParent()).onMobileAttrModified();
jf.getFormDesign().getSelectionModel().setSelectedCreator(jf.getFormDesign().getRootComponent());
WidgetPropertyPane.getInstance().refreshDockingView();
jf.fireTargetModified();
}

120
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java

@ -124,7 +124,7 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
if (layoutType == WBodyLayoutType.ABSOLUTE) {
((XWFitLayout) creator.getBackupParent()).toData().resetStyle();
if (state == WBodyLayoutType.FIT.getTypeValue()) {
switch2FitBodyLayout();
((XWFitLayout)creator.getBackupParent()).switch2FitBodyLayout(creator);
}
}
layout.setBorderStyle((LayoutBorderStyle) borderStyleEditor.getValue());
@ -149,123 +149,5 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
return null;
}
private boolean switch2FitBodyLayout() {
try {
XWFitLayout xfl = (XWFitLayout) creator.getBackupParent();
//备份一下组件间隔
int compInterval = xfl.toData().getCompInterval();
Component[] components = creator.getComponents();
Arrays.sort(components, new ComparatorComponentLocation());
xfl.getLayoutAdapter().removeBean(creator, creator.getWidth(), creator.getHeight());
xfl.remove(creator);
for (Component comp : components) {
XCreator xCreator = (XCreator) comp;
if (xCreator.shouldScaleCreator()) {
XLayoutContainer parentPanel = xCreator.initCreatorWrapper(xCreator.getHeight());
xfl.add(parentPanel, xCreator.toData().getWidgetName());
parentPanel.updateChildBound(xfl.getActualMinHeight());
continue;
}
xfl.add(xCreator);
}
//这边计算的时候会先把组件间隔去掉
moveComponents2FitLayout(xfl);
for (int i = 0; i < components.length; i++) {
Component comp = xfl.getComponent(i);
XCreator creator = (XCreator) comp;
creator.setBackupBound(components[i].getBounds());
}
//把组件间隔加上
if (xfl.toData().getCompInterval() != compInterval) {
xfl.moveContainerMargin();
xfl.moveCompInterval(xfl.getAcualInterval());
xfl.toData().setCompInterval(compInterval);
xfl.addCompInterval(xfl.getAcualInterval());
}
xfl.toData().setLayoutType(WBodyLayoutType.FIT);
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
formDesigner.getSelectionModel().setSelectedCreator(xfl);
return true;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;
}
}
// 把绝对布局中的元素按规则移动到自适应布局中
// 规则:各元素按顺序放置,其中每行最多4个元素,超出则换行,各元素均分body的高度和宽度
private void moveComponents2FitLayout(XWFitLayout xwFitLayout) {
Component[] components = xwFitLayout.getComponents();
if (components.length == 0) {
xwFitLayout.updateBoundsWidget();
return;
}
int layoutWidth = xwFitLayout.getWidth() - xwFitLayout.toData().getMargin().getLeft() - xwFitLayout.toData().getMargin().getRight();
int layoutHeight = xwFitLayout.getHeight() - xwFitLayout.toData().getMargin().getTop() - xwFitLayout.toData().getMargin().getBottom();
int leftMargin = xwFitLayout.toData().getMargin().getLeft();
int topMargin = xwFitLayout.toData().getMargin().getTop();
xwFitLayout.toData().setCompInterval(0);
int row = (components.length / EACH_ROW_COUNT) + (components.length % EACH_ROW_COUNT == 0 ? 0 : 1);
//最后一行的列数不定
int column = components.length % EACH_ROW_COUNT == 0 ? EACH_ROW_COUNT : components.length % EACH_ROW_COUNT;
int componentWidth = layoutWidth / EACH_ROW_COUNT;
int componentHeight = layoutHeight / row;
for (int i = 0; i < row - 1; i++) {
for (int j = 0; j < EACH_ROW_COUNT; j++) {
components[EACH_ROW_COUNT * i + j].setBounds(
leftMargin + componentWidth * j,
topMargin + componentHeight * i,
j == EACH_ROW_COUNT - 1 ? layoutWidth - componentWidth * (EACH_ROW_COUNT - 1) : componentWidth,
componentHeight
);
}
}
//最后一行列数是特殊的,要单独处理
int lastRowWidth = layoutWidth / column;
int lastRowHeight = layoutHeight - componentHeight * (row - 1);
for (int i = 0; i < column; i++) {
components[EACH_ROW_COUNT * (row - 1) + i].setBounds(
leftMargin + lastRowWidth * i,
topMargin + componentHeight * (row - 1),
i == column - 1 ? layoutWidth - lastRowWidth * (column - 1) : lastRowWidth,
lastRowHeight
);
}
for (int i = 0; i < components.length; i++) {
if (components[i] instanceof XWCardMainBorderLayout) {
((XWCardMainBorderLayout) components[i]).recalculateChildWidth(components[i].getWidth(), false);
((XWCardMainBorderLayout) components[i]).recalculateChildHeight(components[i].getHeight(), false);
}
xwFitLayout.dealDirections((XCreator) components[i], false);
}
xwFitLayout.updateBoundsWidget();
}
//以组件的位置来确定先后顺序,y小的在前,x小的在前
private class ComparatorComponentLocation implements Comparator {
@Override
public int compare(Object o1, Object o2) {
if (((Component) o1).getY() < ((Component) o2).getY()) {
return -1;
} else if (((Component) o1).getY() > ((Component) o2).getY()) {
return 1;
} else {
if (((Component) o1).getX() < ((Component) o2).getX()) {
return -1;
} else if (((Component) o1).getX() > ((Component) o2).getX()) {
return 1;
} else {
return 0;
}
}
}
}
}

7
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java

@ -26,6 +26,7 @@ import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor;
import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor;
import com.fr.design.widget.ui.designer.AbstractDataModify;
import com.fr.design.widget.ui.designer.component.PaddingBoundPane;
import com.fr.form.main.Form;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteBodyLayout;
@ -136,9 +137,15 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
XLayoutContainer rootLayout = selectedBodyLayout(formDesigner);
if (rootLayout != formDesigner.getRootComponent()
&& formDesigner.getSelectionModel().getSelection().getSelectedCreator() == formDesigner.getRootComponent()) {
//原单例面板populate根据当前样式populate属性面板,现加入移动端逻辑:可能需要根据面板属性改变样式
Form form = formDesigner.getTarget();
if (form.getFormMobileAttr().isMobileOnly() && form.getFormMobileAttr().isAdaptivePropertyAutoMatch()) {
((XWFitLayout)formDesigner.getRootComponent()).switch2FitBodyLayout(rootLayout);
} else {
formDesigner.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{selectedBodyLayout(formDesigner).toData()}));
}
}
paddingBound.populate(ob);
layoutComboBox.setSelectedIndex(ob.getBodyLayoutType().getTypeValue());
adaptComboBox.setSelectedIndex(ob.getCompState());

58
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;
@ -34,19 +35,10 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
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 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");
private Listener listener;
@ -60,37 +52,43 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
/**
* 初始化各个组件
*
* @param defaultArgs 初始化参数
*/
public void initComponents(String[] defaultArgs) {
cards = new ArrayList<FurtherBasicBeanPane<? extends JavaScript>>();
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);
String[] style = {JS, DBCOMMIT, CUSTOMACTION,EMAIL};
final 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")));
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);
javaScriptPane = new JavaScriptImplPane(defaultArgs);
JavaScriptImplPane javaScriptPane = new JavaScriptImplPane(defaultArgs);
hyperlinkPane.add(JS, javaScriptPane);
// 提交入库
List dbmaniList = new ArrayList();
dbmaniList.add(autoCreateDBManipulationPane());
commit2DBJavaScriptPane = new Commit2DBJavaScriptPane(JavaScriptActionPane.defaultJavaScriptActionPane,
dbmaniList);
List dbManiList = new ArrayList();
dbManiList.add(autoCreateDBManipulationPane());
Commit2DBJavaScriptPane commit2DBJavaScriptPane = new Commit2DBJavaScriptPane(JavaScriptActionPane.defaultJavaScriptActionPane,
dbManiList);
hyperlinkPane.add(DBCOMMIT, commit2DBJavaScriptPane);
// 自定义事件
customActionPane = new CustomActionPane();
CustomActionPane customActionPane = new CustomActionPane();
hyperlinkPane.add(CUSTOMACTION, customActionPane);
// 发送邮件
emailPane = new EmailPane();
EmailPane emailPane = new EmailPane();
hyperlinkPane.add(EMAIL, emailPane);
cards.add(javaScriptPane);
cards.add(commit2DBJavaScriptPane);
@ -98,11 +96,16 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
cards.add(emailPane);
//其他事件
addOtherEvent();
hyperlinkPane.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JavaScript_Set")));
hyperlinkPane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Report_JavaScript_Set")));
this.add(hyperlinkPane);
styleBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
card.show(hyperlinkPane, styleBox.getSelectedItem().toString());
Object selected = styleBox.getSelectedItem();
if (selected == null) {
return;
}
card.show(hyperlinkPane, selected.toString());
}
});
}
@ -122,6 +125,7 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
/**
* 根据有无单元格创建 DBManipulationPane
*
* @return 有单元格有智能添加单元格等按钮返回 SmartInsertDBManipulationPane
*/
private DBManipulationPane autoCreateDBManipulationPane() {
@ -131,7 +135,7 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Event_Set");
return Toolkit.i18nText("Fine-Design_Report_Event_Set");
}
@Override

199
designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java

@ -20,15 +20,25 @@ import com.fr.general.DesUtils;
import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils;
import com.fr.general.http.HttpClient;
import com.fr.general.http.HttpToolbox;
import com.fr.intelli.record.FocusPoint;
import com.fr.intelli.record.MetricException;
import com.fr.intelli.record.MetricRegistry;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.log.message.ParameterMessage;
import com.fr.record.DBRecordXManager;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.query.QueryFactory;
import com.fr.stable.query.condition.QueryCondition;
import com.fr.stable.query.data.DataList;
import com.fr.stable.query.restriction.RestrictionFactory;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLTools;
@ -84,6 +94,15 @@ public class InformationCollector implements XMLReadable, XMLWriter {
public static final String TABLE_NAME = "fr_functionrecord";
public static final String FUNC_COLUMNNAME = "func";
public static final String COLUMN_TIME = "time";
public static final String TABLE_FUNCTION_RECORD = "function.record";
private static final String ATTR_ID = "id";
private static final String ATTR_TEXT = "text";
private static final String ATTR_SOURCE = "source";
private static final String ATTR_TIME = "time";
private static final String ATTR_TITLE = "title";
private static final String ATTR_USER_NAME = "username";
private static final String ATTR_UUID = "uuid";
private static InformationCollector collector;
@ -207,133 +226,44 @@ public class InformationCollector implements XMLReadable, XMLWriter {
private void sendFunctionsInfo(){
long currentTime = new Date().getTime();
long lastTime = getLastTimeMillis();
if (currentTime - lastTime <= DELTA) {
return;
}
// byte[] content = ArrayUtils.EMPTY_BYTE_ARRAY;
// Connection conn = null;
// Table table = new Table(TABLE_NAME);
// try {
// conn = DBRecordXManager.getDB().createConnection();
// ResultSet rs = selectAllFromLogDB(conn, table);
//
// if(rs == null){
// return;
// }
// content = getFunctionsContentAsByte(rs);
// } catch (Exception e) {
// FRContext.getLogger().error(e.getMessage(), e);
// } finally {
// DBUtils.closeConnection(conn);
// }
//
// HttpClient httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind("functions.info"));
// httpClient.setContent(content);
// httpClient.setTimeout(5000);
//
// if (!httpClient.isServerAlive()) {
// return;
// }
//
// String res = httpClient.getResponseText();
// boolean success = false;
// try {
// success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success");
// } catch (JSONException e) {
// FRContext.getLogger().error(e.getMessage(), e);
// }
// //服务器返回true, 说明已经获取成功, 清空当前记录的信息
// if (success) {
// deleteLogDB(conn, table);
// }
}
private void deleteLogDB(Connection conn, Table table) {
try {
conn = DBRecordXManager.getDB().createConnection();
Delete delete = new Delete(table);
delete.execute(conn);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
} finally {
DBUtils.closeConnection(conn);
}
}
private byte[] getFunctionsContentAsByte(ResultSet rs) throws JSONException{
com.fr.json.JSONObject content = new com.fr.json.JSONObject();
HashMap resultMap = new HashMap();
ArrayList<Map<String, Object>> content = null;
try {
while (rs.next()) {
com.fr.json.JSONObject js = new com.fr.json.JSONObject(rs.getString(FUNC_COLUMNNAME));
Map tempMap = js.toMap();
for (Object key : tempMap.keySet()) {
if(resultMap.containsKey(key)){
int cacheCount = Integer.parseInt(resultMap.get(key).toString());
int currentCount = Integer.parseInt(tempMap.get(key).toString());
resultMap.put(key, cacheCount + currentCount);
} else {
resultMap.put(key, tempMap.get(key));
}
}
content = getFunctionsContentAsByte(currentTime);
} catch (JSONException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
rs.close();
} catch (SQLException e) {
//这边不记,可能还没建表
boolean success = false;
String url = CloudCenter.getInstance().acquireUrlByKind(TABLE_FUNCTION_RECORD);
if(content.size() > 0){
for(int i=0; i<content.size(); i++){
success = sendFunctionRecord(url, content.get(i));
}
JSONArray functionArray = new JSONArray();
for(Object key : resultMap.keySet()){
com.fr.json.JSONObject jsonObject = new com.fr.json.JSONObject();
jsonObject.put("point", key);
jsonObject.put("times", resultMap.get(key));
functionArray.put(jsonObject);
//服务器返回true, 说明已经获取成功, 清空当前记录的信息
if (success) {
deleteFunctionRecords(currentTime);
}
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
content.put("username", MarketConfig.getInstance().getBbsUsername());
content.put("uuid", envManager.getUUID());
content.put("functions", functionArray);
try {
return content.toString().getBytes(EncodeConstants.ENCODING_UTF_8);
} catch (UnsupportedEncodingException e) {
FRContext.getLogger().error(e.getMessage(), e);
return ArrayUtils.EMPTY_BYTE_ARRAY;
}
}
private ResultSet selectAllFromLogDB(Connection conn, Table table) {
Select select = new Select(table, DialectFactory.generateDialect(conn));
PreparedStatement ps;
ResultSet rs;
private boolean sendFunctionRecord(String url, Map<String,Object> record) {
HashMap<String, String> para = new HashMap<>();
para.put("token", SiteCenterToken.generateToken());
para.put("content", new JSONObject(record).toString());
String res = null;
try {
ps = select.createPreparedStatement(conn);
} catch (SQLException e) {
return null;
res = HttpToolbox.get(url, para);
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
try {
rs = ps.executeQuery();
} catch (SQLException e) {
boolean success = false;
try {
ps.close();
} catch (SQLException e1) {
//这边不记,可能还没建表
}
return null;
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success");
} catch (JSONException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return rs;
return success;
}
/**
* 收集开始使用时间发送信息
*/
@ -494,6 +424,47 @@ public class InformationCollector implements XMLReadable, XMLWriter {
});
}
public static ArrayList getFunctionsContentAsByte(long currentTime) throws JSONException{
ArrayList<Map<String,Object>> records = new ArrayList<Map<String,Object>>();
QueryCondition condition = QueryFactory.create().addRestriction(
RestrictionFactory.lte(COLUMN_TIME, currentTime)
);
try {
DataList<FocusPoint> focusPoints = MetricRegistry.getMetric().find(FocusPoint.class,condition);
focusPoints.getList();
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
String bbsUserName = MarketConfig.getInstance().getBbsUsername();
String uuid = envManager.getUUID();
if(!focusPoints.isEmpty()){
for(FocusPoint focusPoint : focusPoints.getList()){
Map<String,Object> record = new HashMap<>();
record.put(ATTR_ID, focusPoint.getId());
record.put(ATTR_TEXT, focusPoint.getText());
record.put(ATTR_SOURCE, focusPoint.getSource());
record.put(ATTR_TIME, focusPoint.getTime().getTime());
record.put(ATTR_TITLE, focusPoint.getTitle());
record.put(ATTR_USER_NAME, bbsUserName);
record.put(ATTR_UUID, uuid);
records.add(record);
}
}
} catch (MetricException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return records;
}
private void deleteFunctionRecords(long currentTime) {
QueryCondition condition = QueryFactory.create().addRestriction(
RestrictionFactory.lte(COLUMN_TIME, currentTime)
);
try {
MetricRegistry.getMetric().clean(condition);
}catch (Exception e){
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
private class StartStopTime implements XMLReadable, XMLWriter {
private String startDate;

10
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java

@ -2,9 +2,11 @@ package com.fr.design.mainframe.alphafine;
import com.fr.base.extension.FileExtension;
import com.fr.general.CloudCenter;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.util.ArrayList;
/**
@ -138,4 +140,12 @@ public class AlphaFineConstants {
public static final int RECOMMEND_MAX_ITEM_NUM = 3;
public static final String BACK_ICON_NAME = "back@1x.png";
public static final ArrayList<String> CONJUNCTION = new ArrayList<String>() {{
add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Conjunction_HE"));
add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Conjunction_YU"));
add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Conjunction_DE"));
}};
}

23
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java

@ -14,8 +14,9 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.HotIssuesManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManeger;
import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManager;
import com.fr.general.ProcessCanceledException;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
@ -30,6 +31,7 @@ import java.util.List;
public class AlphaFineHelper {
public static final NoResultModel NO_CONNECTION_MODEL = new NoResultModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Connection_Failed"));
private static AlphaFineDialog alphaFineDialog;
private static final String URL_FOR_TEST_NETWORK = "https://www.baidu.com";
/**
* 弹出alphafine搜索面板
@ -130,6 +132,9 @@ public class AlphaFineHelper {
* @return
*/
public static SearchResult getNoConnectList(Object object) {
if (isNetworkOk()){
return null;
}
SearchResult result = new SearchResult();
if (object instanceof RecommendSearchManager) {
result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend")));
@ -137,7 +142,7 @@ public class AlphaFineHelper {
result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help")));
} else if (object instanceof PluginSearchManager) {
result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon")));
} else if (object instanceof SimilarSearchManeger) {
} else if (object instanceof SimilarSearchManager) {
result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Relation_Item")));
} else if (object instanceof HotIssuesManager) {
return new SearchResult();
@ -145,4 +150,18 @@ public class AlphaFineHelper {
result.add(AlphaFineHelper.NO_CONNECTION_MODEL);
return result;
}
/**
* 判断网络是否异常
* @return
*/
public static boolean isNetworkOk(){
try {
HttpToolbox.get(URL_FOR_TEST_NETWORK);
return true;
} catch (Exception ignore) {
// 网络异常
return false;
}
}
}

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

@ -6,7 +6,7 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.ActionSearchManager
import com.fr.design.mainframe.alphafine.search.manager.impl.DocumentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.FileSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManeger;
import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManager;
import com.fr.json.JSONObject;
/**
@ -34,7 +34,7 @@ public class CellModelHelper {
break;
case ROBOT:
case RECOMMEND_ROBOT:
cellModel = SimilarSearchManeger.getModelFromCloud(object.optJSONObject(RESULT));
cellModel = SimilarSearchManager.getModelFromCloud(object.optJSONObject(RESULT));
break;
}
return cellModel;

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) {

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/BottomCellRender.java

@ -24,7 +24,7 @@ public class BottomCellRender implements ListCellRenderer<Object> {
JPanel line = new JPanel();
line.setPreferredSize(new Dimension(200, 1));
line.setBackground(AlphaFineConstants.GRAY);
line.setBackground(AlphaFineConstants.WHITE);
panel.add(line, BorderLayout.NORTH);
goToWebLabel.setFont(AlphaFineConstants.MEDIUM_FONT);

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

@ -32,14 +32,13 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager
import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.SegmentationManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManeger;
import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManager;
import com.fr.design.mainframe.errorinfo.ErrorInfoUploader;
import com.fr.design.mainframe.templateinfo.TemplateInfoCollector;
import com.fr.form.main.Form;
import com.fr.form.main.FormIO;
import com.fr.general.ComparatorUtils;
import com.fr.general.http.HttpClient;
import com.fr.general.http.HttpToolbox;
import com.fr.io.TemplateWorkBookIO;
import com.fr.io.exporter.ImageExporter;
import com.fr.json.JSONException;
@ -49,7 +48,6 @@ import com.fr.main.impl.WorkBook;
import com.fr.stable.CodeUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.third.org.apache.http.client.methods.HttpGet;
import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
@ -241,28 +239,26 @@ public class AlphaFineDialog extends UIDialog {
hotPane.setLayout(new BorderLayout());
UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Hot"));
uiLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
uiLabel.setFont(AlphaFineConstants.SMALL_FONT);
uiLabel.setForeground(AlphaFineConstants.DARK_GRAY);
GridLayout gridLayout = new GridLayout(2, 3, 3, 3);
JPanel panel = new JPanel();
panel.setLayout(gridLayout);
try {
HttpGet getHelp = new HttpGet(AlphaFineConstants.ALPHA_HOT_SEARCH);
HttpToolbox.getHttpClient(AlphaFineConstants.ALPHA_HOT_SEARCH).execute(getHelp).getStatusLine();
if (AlphaFineHelper.isNetworkOk()) {
if (hotData == null) {
hotData = HotIssuesManager.getInstance().getHotIssues();
}
for (int i = 0; i < hotData.length; i++) {
panel.add(new HotIssueJpanel(hotData[i], i + 1));
}
} catch (Exception e) {
} else {
hotData = null;
for (int i = 0; i < AlphaFineConstants.HOT_ITEMS; i++) {
panel.add(new HotIssueJpanel(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Connection_Failed")}, i + 1));
}
}
hotPane.add(uiLabel, BorderLayout.NORTH);
hotPane.add(panel, BorderLayout.CENTER);
add(hotPane, BorderLayout.SOUTH);
@ -552,7 +548,7 @@ public class AlphaFineDialog extends UIDialog {
}
private void buildDocumentList(final String[] searchText) {
addSearchResult(DocumentSearchManager.getInstance().getLessSearchResult(getHotData(), searchText));
addSearchResult(DocumentSearchManager.getInstance().getLessSearchResult(searchText));
}
private void buildFileList(String searchStr, final String[] searchText) {
@ -560,24 +556,24 @@ public class AlphaFineDialog extends UIDialog {
}
private void buildActionList(final String[] searchText) {
addSearchResult(ActionSearchManager.getInstance().getLessSearchResult(getHotData(), searchText));
addSearchResult(ActionSearchManager.getInstance().getLessSearchResult(searchText));
}
private void buildPluginList(final String[] searchText) {
addSearchResult(PluginSearchManager.getInstance().getLessSearchResult(getHotData(), searchText));
addSearchResult(PluginSearchManager.getInstance().getLessSearchResult(searchText));
}
private void buildRecommendList(final String[] searchText) {
addSearchResult(RecommendSearchManager.getInstance().getLessSearchResult(getHotData(), searchText));
addSearchResult(RecommendSearchManager.getInstance().getLessSearchResult(searchText));
}
private void buildRecentList(final String[] searchText) {
addSearchResult(RecentSearchManager.getInstance().getLessSearchResult(getHotData(), searchText));
addSearchResult(RecentSearchManager.getInstance().getLessSearchResult(searchText));
}
private void buildSimilarList(final String[] searchText) {
addSearchResult(SimilarSearchManeger.getInstance().getLessSearchResult(getHotData(), searchText));
addSearchResult(SimilarSearchManager.getInstance().getLessSearchResult(searchText));
}
private synchronized void addSearchResult(SearchResult searchResult) {
@ -740,7 +736,7 @@ public class AlphaFineDialog extends UIDialog {
if (!isCancelled() && rightSearchResultPane != null) {
rightSearchResultPane.removeAll();
try {
rightSearchResultPane.add(new RobotPreviewPane((selectedValue).getName(), get()));
rightSearchResultPane.add(new RobotPreviewPane(selectedValue, get()));
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error("get hot item content error: " + e.getMessage());
} catch (ExecutionException e) {
@ -952,12 +948,14 @@ public class AlphaFineDialog extends UIDialog {
Thread sendThread = new Thread(new Runnable() {
@Override
public void run() {
if (StringUtils.isNotEmpty(storeText)) {
RecentSearchManager searchManager = RecentSearchManager.getInstance();
searchManager.addModel(storeText, cellModel);
sendDataToServer(storeText, cellModel);
TemplateInfoCollector.getInstance().sendTemplateInfo();
ErrorInfoUploader.getInstance().sendErrorInfo();
}
}
});
sendThread.start();
}
@ -1054,7 +1052,7 @@ public class AlphaFineDialog extends UIDialog {
break;
case ROBOT:
case RECOMMEND_ROBOT:
moreResult = SimilarSearchManeger.getInstance().getMoreSearchResult(searchTextField.getText());
moreResult = SimilarSearchManager.getInstance().getMoreSearchResult(searchTextField.getText());
break;
case RECOMMEND:
moreResult = RecommendSearchManager.getInstance().getMoreSearchResult(searchTextField.getText());
@ -1380,11 +1378,14 @@ 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 jLabel = new JLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Back"));
jLabel.setIcon(IconLoader.getIcon(AlphaFineConstants.IMAGE_URL + AlphaFineConstants.BACK_ICON_NAME));
jLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
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

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

@ -4,7 +4,10 @@ package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itextarea.UITextArea;
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;
@ -21,6 +24,7 @@ import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLEncoder;
/**
@ -28,13 +32,14 @@ import java.net.URL;
*/
public class RobotPreviewPane extends JPanel {
private static final int TITLE_AREA_HEIGHT = 30;
private static final int TITLE_AREA_HEIGHT = 15;
private static final int HOT_TITLE_AREA_HEIGHT = 30;
public RobotPreviewPane(String title, String content) {
public RobotPreviewPane(AlphaCellModel model, String content) {
this.setLayout(new BorderLayout());
this.setBackground(Color.WHITE);
this.setPreferredSize(new Dimension(AlphaFineConstants.RIGHT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT));
UITextArea titleArea = new UITextArea(title);
UITextArea titleArea = new UITextArea(model.getName());
titleArea.setBorder(null);
titleArea.setEditable(false);
titleArea.setForeground(AlphaFineConstants.BLUE);
@ -55,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) {
@ -76,7 +81,11 @@ public class RobotPreviewPane extends JPanel {
UIScrollPane jScrollPane = new UIScrollPane(editorPane);
jScrollPane.getVerticalScrollBar().setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
jScrollPane.setBorder(BorderFactory.createMatteBorder(5, 10, 0, 10, Color.white));
if (((RobotModel) model).isHotItemModel()) {
this.setPreferredSize(new Dimension(AlphaFineConstants.RIGHT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT - HOT_TITLE_AREA_HEIGHT));
} else {
this.setPreferredSize(new Dimension(AlphaFineConstants.RIGHT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT - TITLE_AREA_HEIGHT));
}
add(jScrollPane, BorderLayout.CENTER);
}
}

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java

@ -12,7 +12,7 @@ public interface AlphaFineSearchProvider {
* @param searchText
* @return
*/
SearchResult getLessSearchResult(String[][] data, String[] searchText);
SearchResult getLessSearchResult(String[] searchText);
/**
* 获取剩余条数

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

@ -57,7 +57,7 @@ public class ActionSearchManager implements AlphaFineSearchProvider {
}
@Override
public SearchResult getLessSearchResult(String[][] hotData, String[] searchText) {
public SearchResult getLessSearchResult(String[] searchText) {
filterModelList = new SearchResult();
lessModelList = new SearchResult();
moreModelList = new SearchResult();

14
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
*/
@ -51,10 +45,8 @@ public class ComplementAdviceManager {
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());
} catch (Exception e) {
FineLoggerFactory.getLogger().debug("complement advice search error. search str {}", searchText[j]);
}
}
if (searchResult.isEmpty()) {

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

@ -51,15 +51,17 @@ public class DocumentSearchManager implements AlphaFineSearchProvider {
}
@Override
public SearchResult getLessSearchResult(String[][] hotData, String[] searchText) {
public SearchResult getLessSearchResult(String[] searchText) {
lessModelList = new SearchResult();
moreModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainDocument()) {
if (ArrayUtils.isEmpty(searchText)) {
lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help")));
return lessModelList;
} else if (hotData == null) {
return AlphaFineHelper.getNoConnectList(instance);
}
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance);
if(noConnectList != null){
return noConnectList;
}
SearchResult searchResult = new SearchResult();
for (int j = 0; j < searchText.length; j++) {

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

@ -96,7 +96,7 @@ public class FileSearchManager implements AlphaFineSearchProvider {
}
@Override
public SearchResult getLessSearchResult(String[][] hotData, String[] searchText) {
public SearchResult getLessSearchResult(String[] searchText) {
return null;
}

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

@ -96,7 +96,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider {
}
@Override
public SearchResult getLessSearchResult(String[][] hotData, String[] searchText) {
public SearchResult getLessSearchResult(String[] searchText) {
this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult();
SearchResult searchResult = new SearchResult();
@ -104,8 +104,10 @@ public class PluginSearchManager implements AlphaFineSearchProvider {
if (ArrayUtils.isEmpty(searchText)) {
lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon")));
return lessModelList;
} else if (hotData == null) {
return AlphaFineHelper.getNoConnectList(instance);
}
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance);
if(noConnectList != null){
return noConnectList;
}
for (int j = 0; j < searchText.length; j++) {
try {

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

@ -45,9 +45,10 @@ import java.util.List;
*/
public class RecentSearchManager implements AlphaFineSearchProvider {
private static final int MAX_SIZE = 100;
private static volatile RecentSearchManager instance;
IndexReader indexReader = null;
IndexSearcher indexSearcher = null;
private static final RecentSearchManager INSTANCE = new RecentSearchManager();
private IndexReader indexReader = null;
//索引存储路径
private String path = ProductConstants.getEnvHome() + File.separator + "searchIndex";
//分词器,暂时先用这个
@ -57,25 +58,18 @@ public class RecentSearchManager implements AlphaFineSearchProvider {
private IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_40, analyzer);
private IndexWriter indexWriter = null;
private SearchResult recentModelList;
private SearchResult modelList;
public static RecentSearchManager getInstance() {
if (instance == null) {
synchronized (RecentSearchManager.class) {
if (instance == null) {
instance = new RecentSearchManager();
instance.initWriter();
}
}
}
return instance;
return INSTANCE;
}
@Override
public SearchResult getLessSearchResult(String[][] hotData, String[] searchText) {
this.modelList = new SearchResult();
for (int j = 0; j < searchText.length; j++) {
recentModelList = getRecentModelList(searchText[j]);
public SearchResult getLessSearchResult(String[] searchText) {
SearchResult modelList = new SearchResult();
for (String aSearchText : searchText) {
recentModelList = getRecentModelList(aSearchText);
}
if (recentModelList != null && recentModelList.size() > 0) {
modelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Latest")));
@ -93,7 +87,7 @@ public class RecentSearchManager implements AlphaFineSearchProvider {
return new SearchResult();
}
public synchronized SearchResult getRecentModelList(String searchText) {
private synchronized SearchResult getRecentModelList(String searchText) {
return searchBySort(searchText);
}
@ -121,7 +115,6 @@ public class RecentSearchManager implements AlphaFineSearchProvider {
try {
indexWriter.close();
indexReader = DirectoryReader.open(directory);
indexSearcher = new IndexSearcher(indexReader);
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
@ -130,8 +123,6 @@ public class RecentSearchManager implements AlphaFineSearchProvider {
/**
* 添加模型
*
* @param searchKey
* @param cellModel
*/
public void addModel(String searchKey, AlphaCellModel cellModel) {
if(cellModel == null){
@ -151,8 +142,6 @@ public class RecentSearchManager implements AlphaFineSearchProvider {
/**
* 写文档建立索引
*
* @param doc
*/
private void writeDoc(Document doc) {
try {
@ -166,9 +155,6 @@ public class RecentSearchManager implements AlphaFineSearchProvider {
/**
* 按序搜索
*
* @param key
* @return
*/
private synchronized SearchResult searchBySort(String key) {
recentModelList = new SearchResult();

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;
@ -46,14 +44,16 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
}
@Override
public SearchResult getLessSearchResult(String[][] hotData, String[] searchText) {
public SearchResult getLessSearchResult(String[] searchText) {
this.modelList = new SearchResult();
this.recommendModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainRecommend()) {
if (ArrayUtils.isEmpty(searchText)) {
return new SearchResult();
} else if(hotData == null){
return AlphaFineHelper.getNoConnectList(instance);
}
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance);
if (noConnectList != null) {
return noConnectList;
}
for (int j = 0; j < searchText.length; j++) {
searchText[j] = searchText[j].replaceAll(StringUtils.BLANK, StringUtils.EMPTY);
@ -74,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]);
}
}

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

@ -2,7 +2,6 @@ package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.stable.StringUtils;
import com.fr.third.ibm.icu.text.BreakIterator;
import java.util.ArrayList;
@ -72,7 +71,8 @@ public class SegmentationManager {
int start = itor.first();
for (int end = itor.next(); end != BreakIterator.DONE; start = end, end = itor.next()) {
String temp = searchText.substring(start, end);
if (!StringUtils.isEmpty(temp)) {
//去掉空和连词
if (StringUtils.isNotEmpty(temp) && !AlphaFineConstants.CONJUNCTION.contains(temp)) {
result.add(temp);
}
}

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

@ -9,27 +9,24 @@ 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.
*/
public class SimilarSearchManeger implements AlphaFineSearchProvider {
private static volatile SimilarSearchManeger instance;
public class SimilarSearchManager implements AlphaFineSearchProvider {
private static volatile SimilarSearchManager instance;
private SearchResult lessModelList;
private SearchResult moreModelList = new SearchResult();
public static SimilarSearchManeger getInstance() {
public static SimilarSearchManager getInstance() {
if (instance == null) {
synchronized (SimilarSearchManeger.class){
synchronized (SimilarSearchManager.class) {
if (instance == null) {
instance = new SimilarSearchManeger();
instance = new SimilarSearchManager();
}
}
}
@ -37,13 +34,15 @@ public class SimilarSearchManeger implements AlphaFineSearchProvider {
}
@Override
public SearchResult getLessSearchResult(String[][] hotData, String[] searchText) {
public SearchResult getLessSearchResult(String[] searchText) {
lessModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) {
if (ArrayUtils.isEmpty(searchText)) {
return new SearchResult();
} else if (hotData == null) {
return AlphaFineHelper.getNoConnectList(instance);
}
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance);
if (noConnectList != null) {
return noConnectList;
}
SearchResult allModelList = new SearchResult();
for (int j = 0; j < searchText.length; j++) {
@ -53,10 +52,8 @@ public class SimilarSearchManeger implements AlphaFineSearchProvider {
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());
} catch (Exception e) {
FineLoggerFactory.getLogger().debug("similar search error.search str {}", searchText[j]);
}
}
moreModelList.clear();

2
designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

@ -38,7 +38,7 @@ public class DesignerSocketIO {
}
private static Optional<Socket> socketIO = Optional.absent();
public static Status status = Status.Disconnected;
private static Status status = Status.Disconnected;
private static final Emitter.Listener printLog = new Emitter.Listener() {
@Override

5
designer-realize/src/main/java/com/fr/design/report/mobile/ReportMobileAttrPane.java

@ -15,8 +15,6 @@ public class ReportMobileAttrPane extends BasicBeanPane<ElementCaseMobileAttr>{
private ReportMobileTemplateSettingsPane reportMobileTemplateSettingsPane; // 模版设置面板
private AppFitBrowserPane appFitBrowserPane;
//工具栏容器
private MobileToolBarPane mobileToolBarPane;
// 其他
private MobileOthersPane mobileOthersPane;
@ -38,7 +36,6 @@ public class ReportMobileAttrPane extends BasicBeanPane<ElementCaseMobileAttr>{
appFitBrowserPane.setAppFitPreviewPane(appFitPreviewPane);
jPanel.add(appFitBrowserPane);
jPanel.add(mobileToolBarPane = new MobileToolBarPane());
jPanel.add(mobileOthersPane = new MobileOthersPane());
jPanel.add(appFitPreviewPane);
@ -52,7 +49,6 @@ public class ReportMobileAttrPane extends BasicBeanPane<ElementCaseMobileAttr>{
ob = new ElementCaseMobileAttr();
}
appFitBrowserPane.populateBean(ob);
mobileToolBarPane.populateBean(ob);
mobileOthersPane.populateBean(ob);
reportMobileTemplateSettingsPane.populateBean(ob);
}
@ -60,7 +56,6 @@ public class ReportMobileAttrPane extends BasicBeanPane<ElementCaseMobileAttr>{
@Override
public ElementCaseMobileAttr updateBean() {
ElementCaseMobileAttr caseMobileAttr = appFitBrowserPane.updateBean();
mobileToolBarPane.updateBean(caseMobileAttr);
mobileOthersPane.updateBean(caseMobileAttr);
reportMobileTemplateSettingsPane.updateBean(caseMobileAttr);

8
designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java

@ -10,16 +10,16 @@ import com.fr.config.ServerPreferenceConfig;
import com.fr.design.gui.frpane.LoadingBasicPane;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.webattr.printsettings.GlobalNativePrintSettingPane;
import com.fr.design.webattr.printsettings.PrintSettingPane;
import com.fr.report.core.ReportUtils;
import com.fr.report.web.WebPage;
import com.fr.report.web.WebView;
import com.fr.report.web.WebWrite;
import com.fr.web.attr.ReportWebAttr;
import javax.swing.*;
import java.awt.*;
import javax.swing.JPanel;
import java.awt.BorderLayout;
/**
* Edit Report Server Parameter.
@ -60,7 +60,7 @@ public class EditReportServerParameterPane extends LoadingBasicPane {
tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportServerP_Import_Css"), cssPane = new WebCssPane());
tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportServerP_Import_JavaScript"), jsPane = new WebJsPane());
tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Error_Handler_Template"), errorTemplatePane = new ErrorTemplatePane());
tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Print_Setting"), printSettingPane = new PrintSettingPane());
tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Print_Setting"), printSettingPane = new PrintSettingPane(new GlobalNativePrintSettingPane()));
}
@Override

6
designer-realize/src/main/java/com/fr/design/webattr/ReportWebWidgetConstants.java

@ -40,7 +40,6 @@ import com.fr.report.web.button.write.StashButton;
import com.fr.report.web.button.write.Submit;
import com.fr.report.web.button.write.SubmitForcibly;
import com.fr.report.web.button.write.Verify;
import com.fr.report.web.button.write.WriteOfflineHTML;
public class ReportWebWidgetConstants {
private ReportWebWidgetConstants() {
@ -57,7 +56,7 @@ public class ReportWebWidgetConstants {
public static WidgetOption[] getWriteToolBarInstance() {
return new WidgetOption[]{SUBMIT, VERIFY, EMAIL, EXPORT, PDF, EXCELP, EXCELO, EXCELS, WORD, NEW_PRINT, PRINT, FLASHPRINT, APPLETPRINT, PDFPRINT, IMPORTEXCELDATA, SHOWCELLVALUE,
APPENDCOLUMNROW, DELETECOLUMNROW, SETPRINTEROFFSET, WRITEOFFLINEHTML, CUSTOM_BUTTON, WRITESTASH, WRITESTASHCLEAR, IMPORTEXCELDATA_CUSTOMIZED,
APPENDCOLUMNROW, DELETECOLUMNROW, SETPRINTEROFFSET, CUSTOM_BUTTON, WRITESTASH, WRITESTASHCLEAR, IMPORTEXCELDATA_CUSTOMIZED,
IMPORTEXCEL, IMPORTEXCEL_COVER, IMPORTEXCEL_CLEAN, IMPORTEXCEL_APPEND};
}
@ -151,9 +150,6 @@ public class ReportWebWidgetConstants {
public static final WidgetOption CUSTOM_BUTTON = WidgetOptionFactory
.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Custom_Form_Button"), CustomToolBarButton.class);
// 输出离线html报表
public static final WidgetOption WRITEOFFLINEHTML = WidgetOptionFactory
.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Export-Offline-Html"), BaseUtils.readIcon("/com/fr/web/images/writeOffline.png"), WriteOfflineHTML.class);
// 数据暂存
public static final WidgetOption WRITESTASH = WidgetOptionFactory
.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine-Write_Stash"), BaseUtils.readIcon("/com/fr/web/images/edit/stash.png"), StashButton.class);

96
designer-realize/src/main/java/com/fr/design/webattr/printsettings/NativePrintSettingPane.java → designer-realize/src/main/java/com/fr/design/webattr/printsettings/AbstractNativePrintSettingPane.java

@ -7,7 +7,6 @@ import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.gui.itextfield.UINumberField;
@ -46,13 +45,15 @@ import java.util.regex.Pattern;
/**
* Created by plough on 2018/3/5.
*/
public class NativePrintSettingPane extends JPanel {
public abstract class AbstractNativePrintSettingPane extends JPanel {
private static final int ODD_INDEX = 0;
private static final int EVEN_INDEX = 1;
private static final String CUSTOM_PAPERSIZE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Custom");
private static final PaperSize DEFAULT_PAPERSIZE = PaperSize.PAPERSIZE_A4;
private UICheckBox isShowDialogCheck;
// 公共组件
private UICheckBox showDialogCheck;
private UICheckBox needSelectSheetCheck; // 打印需要指定 sheet
private UIComboBox printerComboBox;
private UIBasicSpinner copySpinner; // 份数
private UIRadioButton allPageRadioButton;
@ -75,7 +76,7 @@ public class NativePrintSettingPane extends JPanel {
private UnitFieldPane customWidthFieldPane;
private UnitFieldPane customHeightFieldPane;
public NativePrintSettingPane() {
AbstractNativePrintSettingPane() {
initComponents();
initListeners();
}
@ -83,25 +84,11 @@ public class NativePrintSettingPane extends JPanel {
private void initComponents() {
JPanel printPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel northPane = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(1, 0, 15);
UILabel tipDownload = GUICoreUtils.createTipLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Tip_Native_Print_Need_Client"));
northPane.add(tipDownload);
isShowDialogCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Show_Print_Setting_Window_When_Printing"));
isShowDialogCheck.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20));
UILabel tipCheck = GUICoreUtils.createTipLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Tip_Use_Default_Settings"));
JPanel checkPane = GUICoreUtils.createFlowPane(new Component[] {
isShowDialogCheck, tipCheck}, FlowLayout.LEFT);
northPane.add(checkPane);
northPane.setBorder(BorderFactory.createEmptyBorder(3, 10, 10, 0));
JPanel northPane = getHeaderPane();
printPane.add(northPane, BorderLayout.NORTH);
centerPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default_Settings"));
UIScrollPane scrollPane = new UIScrollPane(getNativePrintMainSettingPane());
scrollPane.setBorder(null);
scrollPane.setPreferredSize(new Dimension(600, 340));
centerPane.add(scrollPane);
centerPane.add(getNativePrintMainSettingPane());
printPane.add(centerPane, BorderLayout.CENTER);
@ -109,12 +96,53 @@ public class NativePrintSettingPane extends JPanel {
this.add(printPane, BorderLayout.CENTER);
}
private JPanel getHeaderPane() {
UILabel tipDownload = GUICoreUtils.createTipLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Tip_Native_Print_Need_Client"));
// 打印时需要打印设置窗口
showDialogCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Show_Print_Setting_Window_When_Printing"));
showDialogCheck.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20));
UILabel showDialogCheckTip = GUICoreUtils.createTipLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Tip_Use_Default_Settings"));
JPanel showDialogCheckPane = GUICoreUtils.createFlowPane(new Component[] {
showDialogCheck, showDialogCheckTip}, FlowLayout.LEFT);
// 打印需要指定 sheet
needSelectSheetCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Need_Select_Sheet_When_Printing"));
needSelectSheetCheck.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20));
UILabel needSelectSheetCheckTip = GUICoreUtils.createTipLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Tip_Invalid_In_Page_View"));
JPanel needSelectSheetCheckPane = GUICoreUtils.createFlowPane(new Component[] {
needSelectSheetCheck, needSelectSheetCheckTip}, FlowLayout.LEFT);
return createHeaderPane(tipDownload, showDialogCheckPane, needSelectSheetCheckPane);
}
abstract JPanel createHeaderPane(Component... comps);
JPanel createHeaderLayoutPane(Component... comps) {
// TableLayout
double p = TableLayout.PREFERRED;
double[] columnSize = {p};
double[] rowSize = new double[comps.length];
for (int i = 0; i < rowSize.length; i++) {
rowSize[i] = p;
}
Component[][] components = new Component[rowSize.length][columnSize.length];
for (int i = 0; i < rowSize.length; i++) {
components[i][0] = comps[i];
}
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 10);
}
private void initListeners() {
allPageRadioButton.addItemListener(getPageRaidoListener());
currentPageRadioButton.addItemListener(getPageRaidoListener());
customPageRadioButton.addItemListener(getPageRaidoListener());
doublePrintRadioButton.addItemListener(getPageRaidoListener());
isShowDialogCheck.addItemListener(new ItemListener() {
showDialogCheck.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
checkEnabled();
@ -166,7 +194,7 @@ public class NativePrintSettingPane extends JPanel {
printerPane.add(printerComboBox);
// 份数
copySpinner = new UIBasicSpinner(new SpinnerNumberModel(1, 0, Integer.MAX_VALUE, 1));
copySpinner = new UIBasicSpinner(new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 1));
GUICoreUtils.setColumnForSpinner(copySpinner, 5);
JPanel copyPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
copyPane.add(copySpinner);
@ -386,14 +414,17 @@ public class NativePrintSettingPane extends JPanel {
}
// 返回包含一个标签的 panel,标签始终位于 panel 顶部
private JPanel getTopAlignLabelPane(String labelText) {
JPanel getTopAlignLabelPane(String labelText) {
JPanel labelPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
labelPane.add(new UILabel(labelText), BorderLayout.NORTH);
labelPane.add(new JPanel(), BorderLayout.CENTER);
return labelPane;
}
public void populate(NativePrintAttr nativePrintAttr) {
isShowDialogCheck.setSelected(nativePrintAttr.isShowDialog());
extraPopulate(nativePrintAttr);
showDialogCheck.setSelected(nativePrintAttr.isShowDialog());
needSelectSheetCheck.setSelected(nativePrintAttr.isNeedSelectSheet());
printerComboBox.setSelectedItem(nativePrintAttr.getPrinterName());
copySpinner.setValue(nativePrintAttr.getCopy());
@ -441,11 +472,14 @@ public class NativePrintSettingPane extends JPanel {
checkEnabled();
}
public void update(NativePrintAttr nativePrintAttr) {
nativePrintAttr.setShowDialog(isShowDialogCheck.isSelected());
if (printerComboBox.getSelectedItem() != null) {
nativePrintAttr.setPrinterName(printerComboBox.getSelectedItem().toString());
protected void extraPopulate(NativePrintAttr nativePrintAttr) {
// do nothing
}
public void update(NativePrintAttr nativePrintAttr) {
extraUpdate(nativePrintAttr);
nativePrintAttr.setShowDialog(showDialogCheck.isSelected());
nativePrintAttr.setNeedSelectSheet(needSelectSheetCheck.isSelected());
nativePrintAttr.setCopy((int)copySpinner.getValue());
// 页码
@ -481,8 +515,12 @@ public class NativePrintSettingPane extends JPanel {
nativePrintAttr.setScalePercent((int)scalePercentField.getValue());
}
protected void extraUpdate(NativePrintAttr nativePrintAttr) {
// do nothing
}
// 刷新面板可用状态
public void checkEnabled() {
GUICoreUtils.setEnabled(centerPane, !isShowDialogCheck.isSelected());
GUICoreUtils.setEnabled(centerPane, !showDialogCheck.isSelected());
}
}

91
designer-realize/src/main/java/com/fr/design/webattr/printsettings/GlobalNativePrintSettingPane.java

@ -0,0 +1,91 @@
package com.fr.design.webattr.printsettings;
import com.fr.base.print.NativePrintAttr;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.Component;
/**
* 本地打印设置面板全局
* Created by plough on 2018/10/31.
*/
public class GlobalNativePrintSettingPane extends AbstractNativePrintSettingPane {
// 服务器配置面板特有的组件
private UICheckBox defaultDownloadUrlCheck; // 采用默认的软件下载地址
private UITextField customUrlFieldWin;
private UITextField customUrlFieldMac;
@Override
JPanel createHeaderPane(Component... comps) {
Component[] newComps = {
getDownloadUrlSettingPane()
};
Component[] allComps = new Component[comps.length + newComps.length];
System.arraycopy(comps, 0, allComps, 0, comps.length);
System.arraycopy(newComps, 0, allComps, comps.length, newComps.length);
JPanel headerPane = createHeaderLayoutPane(allComps);
headerPane.setBorder(BorderFactory.createEmptyBorder(2, 12, 5, 0));
return headerPane;
}
@Override
protected void extraUpdate(NativePrintAttr nativePrintAttr) {
if (defaultDownloadUrlCheck.isSelected()) {
nativePrintAttr.setUseDefaultDownloadUrl(true);
} else {
nativePrintAttr.setUseDefaultDownloadUrl(false);
nativePrintAttr.setCustomDownloadUrlMac(customUrlFieldMac.getText());
nativePrintAttr.setCustomDownloadUrlWin(customUrlFieldWin.getText());
}
}
@Override
protected void extraPopulate(NativePrintAttr nativePrintAttr) {
defaultDownloadUrlCheck.setSelected(nativePrintAttr.isUseDefaultDownloadUrl());
customUrlFieldMac.setText(nativePrintAttr.getCustomDownloadUrlMac());
customUrlFieldWin.setText(nativePrintAttr.getCustomDownloadUrlWin());
}
private JPanel getDownloadUrlSettingPane() {
defaultDownloadUrlCheck = GUICoreUtils.createNoBorderCheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default"));
JPanel downloadUrlSettingCheckPane = GUICoreUtils.createCheckboxAndDynamicPane(defaultDownloadUrlCheck, getCustomUrlSettingPane(), true);
downloadUrlSettingCheckPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
// TableLayout
double p = TableLayout.PREFERRED;
double[] rowSize = {p};
double[] columnSize = {p, p};
Component[][] components = {
{getTopAlignLabelPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Software_Download_Url") + ": "), downloadUrlSettingCheckPane}
};
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 15);
}
private JPanel getCustomUrlSettingPane() {
customUrlFieldWin = new UITextField(20);
customUrlFieldMac = new UITextField(20);
// TableLayout
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p};
double[] columnSize = {60, p};
Component[][] components = {
{new UILabel("windows: "), customUrlFieldWin},
{new UILabel("macOS: "), customUrlFieldMac}
};
JPanel urlSettingPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 10);
urlSettingPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
return urlSettingPane;
}
}

2
designer-realize/src/main/java/com/fr/design/webattr/printsettings/NoClientPrintSettingPane.java

@ -26,7 +26,7 @@ public class NoClientPrintSettingPane extends JPanel {
private PageMarginSettingPane pageMarginSettingPane;
private JPanel centerPane;
public NoClientPrintSettingPane() {
NoClientPrintSettingPane() {
initComponents();
initListeners();
}

2
designer-realize/src/main/java/com/fr/design/webattr/printsettings/PageMarginSettingPane.java

@ -19,7 +19,7 @@ public class PageMarginSettingPane extends JPanel {
private UnitFieldPane marginLeftUnitFieldPane;
private UnitFieldPane marginRightUnitFieldPane;
public PageMarginSettingPane() {
PageMarginSettingPane() {
initComponents();
}
private void initComponents() {

16
designer-realize/src/main/java/com/fr/design/webattr/printsettings/PrintSettingPane.java

@ -3,10 +3,10 @@ package com.fr.design.webattr.printsettings;
import com.fr.base.print.PrintSettingsAttrMark;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
@ -23,13 +23,17 @@ import java.awt.event.ItemListener;
public class PrintSettingPane extends BasicPane {
private UIRadioButton noClientPrintRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_No_Client_Print"));
private UIRadioButton nativePrintRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Native_Print"));
private NoClientPrintSettingPane noClientPrintSettingPane;
private NativePrintSettingPane nativePrintSettingPane;
private AbstractNativePrintSettingPane nativePrintSettingPane;
private CardLayout printCard;
private JPanel printPane;
public PrintSettingPane() {
this(new ReportNativePrintSettingPane());
}
public PrintSettingPane(AbstractNativePrintSettingPane nativePrintSettingPane) {
this.nativePrintSettingPane = nativePrintSettingPane;
initComponents();
initListener();
}
@ -50,12 +54,14 @@ public class PrintSettingPane extends BasicPane {
north.add(radioGroupPane);
noClientPrintSettingPane = new NoClientPrintSettingPane();
nativePrintSettingPane = new NativePrintSettingPane();
printCard = new CardLayout();
printPane = new JPanel();
printPane.setLayout(printCard);
printPane.add(noClientPrintRadioButton.getText(), noClientPrintSettingPane);
printPane.add(nativePrintRadioButton.getText(), nativePrintSettingPane);
UIScrollPane scrollPane = new UIScrollPane(nativePrintSettingPane);
scrollPane.setBorder(null);
printPane.add(nativePrintRadioButton.getText(), scrollPane);
north.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
allPanel.add(printPane, BorderLayout.CENTER);

18
designer-realize/src/main/java/com/fr/design/webattr/printsettings/ReportNativePrintSettingPane.java

@ -0,0 +1,18 @@
package com.fr.design.webattr.printsettings;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.Component;
/**
* 本地打印设置面板单模版
* Created by plough on 2018/10/31.
*/
public class ReportNativePrintSettingPane extends AbstractNativePrintSettingPane {
@Override
JPanel createHeaderPane(Component... comps) {
JPanel headerPane = createHeaderLayoutPane(comps);
headerPane.setBorder(BorderFactory.createEmptyBorder(2, 12, 12, 0));
return headerPane;
}
}

17
designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java

@ -10,7 +10,7 @@ import com.sun.javafx.iio.gif.GIFImageLoaderFactory;
import com.sun.javafx.tk.PlatformImage;
import com.sun.prism.Image;
import com.sun.prism.impl.PrismSettings;
import sun.util.logging.PlatformLogger;
import java.io.IOException;
import java.io.InputStream;
@ -22,8 +22,6 @@ import java.io.InputStream;
*/
class PrismImageLoader2 implements com.sun.javafx.tk.ImageLoader {
private static PlatformLogger imageioLogger = null;
private Image[] images;
private int[] delayTimes;
private int width;
@ -110,7 +108,6 @@ class PrismImageLoader2 implements com.sun.javafx.tk.ImageLoader {
return 40;
}
@Override
public int getLoopCount() {
return 0;
}
@ -174,21 +171,11 @@ class PrismImageLoader2 implements com.sun.javafx.tk.ImageLoader {
return image;
}
/**
* Returns the PlatformLogger for logging imageio-related activities.
*/
private static synchronized PlatformLogger getImageioLogger() {
if (imageioLogger == null) {
imageioLogger = PlatformLogger.getLogger("imageio");
}
return imageioLogger;
}
private class PrismLoadListener implements ImageLoadListener {
@Override
public void imageLoadWarning(ImageLoader loader, String message) {
getImageioLogger().warning(message);
}
@Override

3
designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java

@ -7,6 +7,7 @@ import com.fr.event.Listener;
import com.fr.module.Activator;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.record.analyzer.Metrics;
import com.fr.runtime.FineRuntime;
import com.fr.start.Designer;
import com.fr.start.ServerStarter;
import com.fr.start.SplashContext;
@ -63,7 +64,7 @@ public class DesignerStartup extends Activator {
DesignerContext.getDesignerFrame().getProgressDialog().setVisible(true);
startSub(StartFinishActivator.class);
FineRuntime.startFinish();
}
private void browserDemo() {

5
designer-realize/src/main/java/com/fr/start/preload/ImagePreLoader.java

@ -401,6 +401,9 @@ public class ImagePreLoader {
"com/fr/design/images/control/up.png",
"com/fr/design/images/control/down.png",
"com/fr/design/images/condition/bracket.png",
"com/fr/design/images/condition/unBracket.png"
"com/fr/design/images/condition/unBracket.png",
"com/fr/design/images/buttonicon/user_search_normal.png",
"com/fr/design/remote/images/icon_Member_normal@1x.png",
"/com/fr/design/images/buttonicon/add.png"
};
}

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/back@1x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/back@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

BIN
designer-realize/src/main/resources/com/fr/start/jni/splash.dylib

Binary file not shown.

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 {
SimilarSearchManager similarSearchManager;
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();
similarSearchManager = SimilarSearchManager.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 = similarSearchManager.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 = similarSearchManager.getMoreSearchResult("数据集");
Assert.assertNotNull(moreModelList);
moreModelList = recommendSearchManager.getMoreSearchResult("数据集");
Assert.assertNotNull(moreModelList);
}
@Test
public void getModelFromCloudTest() {
Assert.assertNotNull(SimilarSearchManager.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