Browse Source

Merge pull request #4 in ~NEIL/design from release/10.0 to 10.0

* commit '1622209ed5178b22fcfed527398dde6096845d37': (40 commits)
  冲突
  超级链接对话框打开设置优化 回退
  REPORT-11831
  update
  CHART-3275 安装插件 图表类型不重启更新
  REPORT-11831
  ff
  REPORT-11520 超级链接对话框打开设置优化
  对话框打开超链支持标题和位置
  CHART-2665 & CHART-2886 堆积和坐标轴update返回一个新创建的conditionattr CHART-1882直接改报错即可 不用记住conditionattr
  CHART-2665 & CHART-2886 堆积和坐标轴update返回一个新创建的conditionattr CHART-1882直接改报错即可 不用记住conditionattr
  规范
  REPORT-11886 远程设计目录树刷新卡顿
  REPORT-11016 10.0版本mac上点击最大化会卡死
  REPORT-11993 普通用户远程设计数据连接权限设置无效
  无JIRA任务 findbugs问题
  无JIRA任务 findbugs问题
  REPORT-11880 SimilarSearchManeger拼错了....
  change to protected method
  CHART-3208 继承&创建含默认值“自动”的下拉选项
  ...
10.0
neil 6 years ago
parent
commit
2bb2d4e0c9
  1. 10
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java
  2. 682
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  3. 2
      designer-base/src/main/java/com/fr/design/extra/PluginUtils.java
  4. 233
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java
  5. 330
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java
  6. 14
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java
  7. 109
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeComparator.java
  8. 203
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/JFileTree.java
  9. 2
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java
  10. 4
      designer-base/src/main/java/com/fr/design/icon/IconPathConstants.java
  11. 6
      designer-base/src/main/java/com/fr/design/mingche.java
  12. 16
      designer-base/src/main/java/com/fr/design/onlineupdate/domain/UpdateConstants.java
  13. 5
      designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/RestoreResultDialog.java
  14. 42
      designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/UpdateMainDialog.java
  15. 8
      designer-base/src/main/java/com/fr/file/FileNodeFILE.java
  16. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/control_checkbox_normal.png
  17. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/control_checkbox_part.png
  18. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/control_checkbox_selected.png
  19. 32
      designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java
  20. 8
      designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java
  21. 12
      designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java
  22. 21
      designer-chart/src/main/java/com/fr/van/chart/column/VanChartCustomStackAndAxisConditionPane.java
  23. 9
      designer-chart/src/main/java/com/fr/van/chart/range/component/SectionIntervalConfigPaneWithOutNum.java
  24. 123
      designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java
  25. 5
      designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java
  26. 1
      designer-form/src/main/java/com/fr/design/mainframe/actions/FormMobileAttrAction.java
  27. 128
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java
  28. 27
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java
  29. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  30. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java
  31. 1
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java
  32. 10
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java
  33. BIN
      designer-realize/src/main/resources/com/fr/start/jni/splash.dylib
  34. 10
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/SearchManegerTest.java

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

682
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;
@ -53,334 +60,343 @@ import java.util.ArrayList;
import java.util.List;
public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
private static final int BOTTOM = 6;
private static final String PREVIEW_BUTTON = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview");
private static final int BOTTOM = 6;
private static final String PREVIEW_BUTTON = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview");
private static final String REFRESH_BUTTON = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh");
private ConnectionTableProcedurePane connectionTableProcedurePane;
private UITableEditorPane<ParameterProvider> editorPane;
private DBTableDataMenuHandler dbTableDataMenuHandler;
private SQLEditPane sqlTextPane;
private UICheckBox isShareCheckBox;
private MaxMemRowCountPanel maxPanel;
private String pageQuery = null;
private DBTableData dbTableData;
private void init() {
this.setLayout(new BorderLayout(4, 4));
sqlTextPane = new SQLEditPane();
sqlTextPane.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL);
ParameterTableModel model = new ParameterTableModel() {
@Override
public UITableEditAction[] createAction() {
return (UITableEditAction[]) ArrayUtils.add(super.createDBTableAction(), new RefreshAction());
}
};
editorPane = new UITableEditorPane<ParameterProvider>(model);
// 左边的Panel,上面是选择DatabaseConnection的ComboBox,下面DatabaseConnection对应的Table
connectionTableProcedurePane = new ConnectionTableProcedurePane() {
@Override
protected void filter(Connection connection, String conName, List<String> nameList) {
connection.addConnection(nameList, conName, new Class[]{JDBCDatabaseConnection.class, JNDIDatabaseConnection.class});
}
};
connectionTableProcedurePane.addDoubleClickListener(new DoubleClickSelectedNodeOnTreeListener() {
@Override
public void actionPerformed(TableProcedure target) {
Document document = sqlTextPane.getDocument();
try {
document.insertString(sqlTextPane.getCaretPosition(), target.toString(), null);
} catch (BadLocationException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
// 这里开始作色,本来可以给sqlTextPane添加DocumentListener来实现的,
// 后来发现insertString的时候,锁定了JTextPane,不能调用setXXX来作色,先这样了.
// sqlTextPane.syntaxTexts();
sqlTextPane.requestFocus();
}
});
sqlTextPane.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
// unsupport
}
public void focusLost(FocusEvent e) {
if (isPreviewOrRefreshButton(e)) {
checkParameter();
}
}
});
}
private void initMainSplitPane() {
Box box = new Box(BoxLayout.Y_AXIS);
JPanel northPane = new JPanel(new BorderLayout(4, 4));
JToolBar editToolBar = createToolBar();
northPane.add(editToolBar, BorderLayout.CENTER);
northPane.setBorder(BorderFactory.createEmptyBorder(0, 0, BOTTOM, 0));
RTextScrollPane sqlTextScrollPane = new RTextScrollPane(sqlTextPane);
sqlTextScrollPane.setLineNumbersEnabled(true);
sqlTextScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC));
sqlTextScrollPane.setPreferredSize(new Dimension(680, 600));
JPanel paraMeanPane = new JPanel(new BorderLayout());
paraMeanPane.setPreferredSize(new Dimension(680, 90));
UILabel paraMean = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Param_DES"));
paraMeanPane.add(paraMean, BorderLayout.CENTER);
box.add(northPane);
box.add(sqlTextScrollPane);
box.add(paraMeanPane);
box.add(editorPane);
JPanel sqlSplitPane = new JPanel(new BorderLayout(4, 4));
sqlSplitPane.add(box, BorderLayout.CENTER);
box.setMinimumSize(new Dimension(310, 400));
// 使用SplitPane
JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, connectionTableProcedurePane, sqlSplitPane);
mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor()));
mainSplitPane.setOneTouchExpandable(true);
this.add(mainSplitPane, BorderLayout.CENTER);
}
public DBTableDataPane() {
init();
initMainSplitPane();
}
private boolean isPreviewOrRefreshButton (FocusEvent e) {
if (e.getOppositeComponent() != null) {
String name = e.getOppositeComponent().getName();
return ComparatorUtils.equals(name, PREVIEW_BUTTON) || ComparatorUtils.equals(name, REFRESH_BUTTON);
}
return false;
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS-Database_Query");
}
private void refresh() {
String[] paramTexts = new String[2];
paramTexts[0] = SqlUtils.tryPureSqlText(sqlTextPane.getText());
paramTexts[1] = SqlUtils.tryPureSqlText(pageQuery);
List<ParameterProvider> existParameterList = editorPane.update();
Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]);
editorPane.populate(ParameterHelper.analyzeAndUnionSameParameters(paramTexts, ps));
}
private JToolBar createToolBar() {
// p:工具栏.
ToolBarDef toolBarDef = new ToolBarDef();
toolBarDef.addShortCut(new PreviewAction());
toolBarDef.addShortCut(SeparatorDef.DEFAULT);
toolBarDef.addShortCut(new EditPageQueryAction());
dbTableDataMenuHandler = ExtraDesignClassManager.getInstance().getSingle(DBTableDataMenuHandler.MARK_STRING);
if (dbTableDataMenuHandler != null) {
toolBarDef.addShortCut(SeparatorDef.DEFAULT);
toolBarDef.addShortCut(dbTableDataMenuHandler.createQueryAction());
}
isShareCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Is_Share_DBTableData"));
isShareCheckBox.setBackground(Color.WHITE);
maxPanel = new MaxMemRowCountPanel();
maxPanel.setBorder(null);
UIToolbar editToolBar = ToolBarDef.createJToolBar();
toolBarDef.updateToolBar(editToolBar);
editToolBar.add(isShareCheckBox);
editToolBar.add(maxPanel);
return editToolBar;
}
private void checkParameter() {
String[] paramTexts = new String[2];
paramTexts[0] = sqlTextPane.getText();
paramTexts[1] = pageQuery;
Parameter[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false);
if (parameters.length < 1 && editorPane.update().size() < 1) {
return;
}
boolean isIn = true;
List<ParameterProvider> list = editorPane.update();
List<String> name = new ArrayList<String>();
for (int i = 0; i < list.size(); i++) {
name.add(list.get(i).getName());
}
for (int i = 0; i < parameters.length; i++) {
if (!name.contains(parameters[i].getName())) {
isIn = false;
break;
}
}
if (list.size() == parameters.length && isIn) {
return;
}
// bug:34175 删了是否刷新对话框, 均直接刷新
refresh();
}
@Override
public void populateBean(DBTableData dbtabledata) {
this.dbTableData = dbtabledata;
if (dbTableDataMenuHandler != null) {
dbTableDataMenuHandler.populate(dbtabledata);
}
ParameterProvider[] parameters = null;
Calculator c = Calculator.createCalculator();
parameters = dbtabledata.getParameters(c);
editorPane.populate(parameters);
com.fr.data.impl.Connection db = null;
String query = null;
boolean isShare = false;
int maxMemeryRow = -1;
db = dbtabledata.getDatabase();
query = dbtabledata.getQuery();
isShare = dbtabledata.isShare();
maxMemeryRow = dbtabledata.getMaxMemRowCount();
this.pageQuery = dbtabledata.getPageQuerySql();
this.connectionTableProcedurePane.setSelectedDatabaseConnection(db);
this.sqlTextPane.setText(query);
this.sqlTextPane.requestFocus();
this.sqlTextPane.moveCaretPosition(this.sqlTextPane.getCaretPosition());
isShareCheckBox.setSelected(isShare);
maxPanel.setValue(maxMemeryRow);
}
@Override
public DBTableData updateBean() {
String dbName = this.connectionTableProcedurePane.getSelectedDatabaseConnnectonName();
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) {
// JOptionPane.showMessageDialog(DBTableDataPane.this,
// com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + ".");
}
}
List<ParameterProvider> parameterList = editorPane.update();
Parameter[] parameters = parameterList.toArray(new Parameter[parameterList.size()]);
dbTableData.setDatabase(new NameDatabaseConnection(dbName));
// p:必须先设置Parameters数组,因为setQuery里面会自动设置的
dbTableData.setParameters(parameters);
dbTableData.setQuery(this.sqlTextPane.getText());
dbTableData.setShare(isShareCheckBox.isSelected());
dbTableData.setMaxMemRowCount(maxPanel.getValue());
dbTableData.setPageQuerySql(this.pageQuery);
if (dbTableDataMenuHandler != null) {
dbTableDataMenuHandler.update();
}
return dbTableData;
}
protected class RefreshAction extends UITableEditAction {
public RefreshAction() {
this.setName(REFRESH_BUTTON);
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png"));
}
public void actionPerformed(ActionEvent e) {
refresh();
}
@Override
public void checkEnabled() {
// unsupport
}
}
private class PreviewAction extends UpdateAction {
public PreviewAction() {
this.setName(PREVIEW_BUTTON);
this.setMnemonic('P');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png"));
}
public void actionPerformed(ActionEvent evt) {
checkParameter();
PreviewTablePane.previewTableData(DBTableDataPane.this.updateBean());
}
}
private class EditPageQueryAction extends UpdateAction {
public EditPageQueryAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Page_Query"));
this.setMnemonic('L');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/text.png"));
}
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() {
public void doOk() {
pageQuery = pane.update();
checkParameter();
}
});
dialog.setVisible(true);
}
}
private class QueryPane extends BasicPane {
private SQLEditPane pageQueryPane;
private String title;
public QueryPane(String title) {
this.title = title;
this.initComponents();
}
public void initComponents() {
this.setLayout(new BorderLayout());
pageQueryPane = new SQLEditPane();
this.add(new JScrollPane(pageQueryPane));
}
public void populate(String text) {
if (StringUtils.isBlank(text)) {
return;
}
pageQueryPane.setText(text);
}
public String update() {
String text = pageQueryPane.getText();
if (StringUtils.isBlank(text)) {
return null;
} else {
return text;
}
}
@Override
protected String title4PopupWindow() {
return title;
}
}
private ConnectionTableProcedurePane connectionTableProcedurePane;
private UITableEditorPane<ParameterProvider> editorPane;
private DBTableDataMenuHandler dbTableDataMenuHandler;
private SQLEditPane sqlTextPane;
private UICheckBox isShareCheckBox;
private MaxMemRowCountPanel maxPanel;
private String pageQuery = null;
private DBTableData dbTableData;
private void init() {
this.setLayout(new BorderLayout(4, 4));
sqlTextPane = new SQLEditPane();
sqlTextPane.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL);
ParameterTableModel model = new ParameterTableModel() {
@Override
public UITableEditAction[] createAction() {
return ArrayUtils.add(super.createDBTableAction(), new RefreshAction());
}
};
editorPane = new UITableEditorPane<ParameterProvider>(model);
// 左边的Panel,上面是选择DatabaseConnection的ComboBox,下面DatabaseConnection对应的Table
connectionTableProcedurePane = new ConnectionTableProcedurePane() {
@Override
protected void filter(Connection connection, String conName, List<String> nameList) {
connection.addConnection(nameList, conName, new Class[]{JDBCDatabaseConnection.class, JNDIDatabaseConnection.class});
}
};
connectionTableProcedurePane.addDoubleClickListener(new DoubleClickSelectedNodeOnTreeListener() {
@Override
public void actionPerformed(TableProcedure target) {
Document document = sqlTextPane.getDocument();
try {
document.insertString(sqlTextPane.getCaretPosition(), target.toString(), null);
} catch (BadLocationException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
// 这里开始作色,本来可以给sqlTextPane添加DocumentListener来实现的,
// 后来发现insertString的时候,锁定了JTextPane,不能调用setXXX来作色,先这样了.
// sqlTextPane.syntaxTexts();
sqlTextPane.requestFocus();
}
});
sqlTextPane.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// do nothing
}
@Override
public void focusLost(FocusEvent e) {
if (isPreviewOrRefreshButton(e)) {
checkParameter();
}
}
});
}
private void initMainSplitPane() {
Box box = new Box(BoxLayout.Y_AXIS);
JPanel northPane = new JPanel(new BorderLayout(4, 4));
JToolBar editToolBar = createToolBar();
northPane.add(editToolBar, BorderLayout.CENTER);
northPane.setBorder(BorderFactory.createEmptyBorder(0, 0, BOTTOM, 0));
RTextScrollPane sqlTextScrollPane = new RTextScrollPane(sqlTextPane);
sqlTextScrollPane.setLineNumbersEnabled(true);
sqlTextScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC));
sqlTextScrollPane.setPreferredSize(new Dimension(680, 600));
JPanel paraMeanPane = new JPanel(new BorderLayout());
paraMeanPane.setPreferredSize(new Dimension(680, 90));
UILabel paraMean = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Param_DES"));
paraMeanPane.add(paraMean, BorderLayout.CENTER);
box.add(northPane);
box.add(sqlTextScrollPane);
box.add(paraMeanPane);
box.add(editorPane);
JPanel sqlSplitPane = new JPanel(new BorderLayout(4, 4));
sqlSplitPane.add(box, BorderLayout.CENTER);
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()));
mainSplitPane.setOneTouchExpandable(true);
this.add(mainSplitPane, BorderLayout.CENTER);
}
public DBTableDataPane() {
init();
initMainSplitPane();
}
private boolean isPreviewOrRefreshButton(FocusEvent e) {
if (e.getOppositeComponent() != null) {
String name = e.getOppositeComponent().getName();
return ComparatorUtils.equals(name, PREVIEW_BUTTON) || ComparatorUtils.equals(name, REFRESH_BUTTON);
}
return false;
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS-Database_Query");
}
private void refresh() {
String[] paramTexts = new String[2];
paramTexts[0] = SqlUtils.tryPureSqlText(sqlTextPane.getText());
paramTexts[1] = SqlUtils.tryPureSqlText(pageQuery);
List<ParameterProvider> existParameterList = editorPane.update();
Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]);
editorPane.populate(ParameterHelper.analyzeAndUnionSameParameters(paramTexts, ps));
}
private JToolBar createToolBar() {
// p:工具栏.
ToolBarDef toolBarDef = new ToolBarDef();
toolBarDef.addShortCut(new PreviewAction());
toolBarDef.addShortCut(SeparatorDef.DEFAULT);
toolBarDef.addShortCut(new EditPageQueryAction());
dbTableDataMenuHandler = ExtraDesignClassManager.getInstance().getSingle(DBTableDataMenuHandler.MARK_STRING);
if (dbTableDataMenuHandler != null) {
toolBarDef.addShortCut(SeparatorDef.DEFAULT);
toolBarDef.addShortCut(dbTableDataMenuHandler.createQueryAction());
}
isShareCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Is_Share_DBTableData"));
isShareCheckBox.setBackground(Color.WHITE);
maxPanel = new MaxMemRowCountPanel();
maxPanel.setBorder(null);
UIToolbar editToolBar = ToolBarDef.createJToolBar();
toolBarDef.updateToolBar(editToolBar);
editToolBar.add(isShareCheckBox);
editToolBar.add(maxPanel);
return editToolBar;
}
private void checkParameter() {
String[] paramTexts = new String[2];
paramTexts[0] = sqlTextPane.getText();
paramTexts[1] = pageQuery;
Parameter[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false);
if (parameters.length < 1 && editorPane.update().size() < 1) {
return;
}
boolean isIn = true;
List<ParameterProvider> list = editorPane.update();
List<String> name = new ArrayList<String>();
for (int i = 0; i < list.size(); i++) {
name.add(list.get(i).getName());
}
for (int i = 0; i < parameters.length; i++) {
if (!name.contains(parameters[i].getName())) {
isIn = false;
break;
}
}
if (list.size() == parameters.length && isIn) {
return;
}
// bug:34175 删了是否刷新对话框, 均直接刷新
refresh();
}
@Override
public void populateBean(DBTableData dbtabledata) {
this.dbTableData = dbtabledata;
if (dbTableDataMenuHandler != null) {
dbTableDataMenuHandler.populate(dbtabledata);
}
ParameterProvider[] parameters = null;
Calculator c = Calculator.createCalculator();
parameters = dbtabledata.getParameters(c);
editorPane.populate(parameters);
com.fr.data.impl.Connection db = null;
String query = null;
boolean isShare = false;
int maxMemeryRow = -1;
db = dbtabledata.getDatabase();
query = dbtabledata.getQuery();
isShare = dbtabledata.isShare();
maxMemeryRow = dbtabledata.getMaxMemRowCount();
this.pageQuery = dbtabledata.getPageQuerySql();
this.connectionTableProcedurePane.setSelectedDatabaseConnection(db);
this.sqlTextPane.setText(query);
this.sqlTextPane.requestFocus();
this.sqlTextPane.moveCaretPosition(this.sqlTextPane.getCaretPosition());
isShareCheckBox.setSelected(isShare);
maxPanel.setValue(maxMemeryRow);
}
@Override
public DBTableData updateBean() {
String dbName = this.connectionTableProcedurePane.getSelectedDatabaseConnnectonName();
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 ignore) {
// JOptionPane.showMessageDialog(DBTableDataPane.this,
// com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + ".");
}
}
List<ParameterProvider> parameterList = editorPane.update();
Parameter[] parameters = parameterList.toArray(new Parameter[parameterList.size()]);
dbTableData.setDatabase(new NameDatabaseConnection(dbName));
// p:必须先设置Parameters数组,因为setQuery里面会自动设置的
dbTableData.setParameters(parameters);
dbTableData.setQuery(this.sqlTextPane.getText());
dbTableData.setShare(isShareCheckBox.isSelected());
dbTableData.setMaxMemRowCount(maxPanel.getValue());
dbTableData.setPageQuerySql(this.pageQuery);
if (dbTableDataMenuHandler != null) {
dbTableDataMenuHandler.update();
}
return dbTableData;
}
protected class RefreshAction extends UITableEditAction {
public RefreshAction() {
this.setName(REFRESH_BUTTON);
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
refresh();
}
@Override
public void checkEnabled() {
// do nothing
}
}
private class PreviewAction extends UpdateAction {
public PreviewAction() {
this.setName(PREVIEW_BUTTON);
this.setMnemonic('P');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
checkParameter();
PreviewTablePane.previewTableData(DBTableDataPane.this.updateBean());
}
}
private class EditPageQueryAction extends UpdateAction {
public EditPageQueryAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Page_Query"));
this.setMnemonic('L');
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();
}
});
dialog.setVisible(true);
}
}
private class QueryPane extends BasicPane {
private SQLEditPane pageQueryPane;
private String title;
public QueryPane(String title) {
this.title = title;
this.initComponents();
}
public void initComponents() {
this.setLayout(new BorderLayout());
pageQueryPane = new SQLEditPane();
this.add(new JScrollPane(pageQueryPane));
}
public void populate(String text) {
if (StringUtils.isBlank(text)) {
return;
}
pageQueryPane.setText(text);
}
public String update() {
String text = pageQueryPane.getText();
if (StringUtils.isBlank(text)) {
return null;
} else {
return text;
}
}
@Override
protected String title4PopupWindow() {
return title;
}
}
}

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

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

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

@ -10,17 +10,45 @@ 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;
public FileNodeComparator() {
this(false);
}
public FileNodeComparator(boolean reverse) {
this.isReverse = reverse;
}
/**
* 正序还是倒序
*/
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;
}
/**
* 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.
@ -29,49 +57,48 @@ public class FileNodeComparator implements Comparator<FileNode> {
* @return < 0, 0, or > 0 for v1<v2, v1==v2, or v1>v2.
*/
public int compare(FileNode nameNode1, FileNode nameNode2) {
int returnVal;
int returnVal;
if (nameNode1.isDirectory()) {
if (nameNode2.isDirectory()) {
returnVal = nameNode1.getName().toLowerCase().compareTo(nameNode2.getName().toLowerCase());
returnVal = nameNode1.getName().toLowerCase().compareTo(nameNode2.getName().toLowerCase());
} else {
returnVal = -1;
returnVal = -1;
}
} else {
if (nameNode2.isDirectory()) {
returnVal = 1;
returnVal = 1;
} else {
returnVal=groupByFileType(nameNode1, nameNode2, 0);
returnVal = groupByFileType(nameNode1, nameNode2, 0);
}
}
if (isReverse) {
returnVal = 0 - returnVal;
returnVal = 0 - returnVal;
}
return returnVal;
}
/**
* 一个简单的递归判断算法
* @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) {
String[] supportTypes = FRContext.getFileNodes().getSupportedTypes();
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(supportTypes[i]))
return 1;
else{
return groupByFileType(nameNode1, nameNode2, i+1);
}
}else
return -1;
}
}
private int groupByFileType(FileNode nameNode1, FileNode nameNode2,
int 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(supportTypes[i]))
return 1;
else {
return groupByFileType(nameNode1, nameNode2, i + 1);
}
} else
return -1;
}
}

203
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,26 +24,12 @@ 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.
*/
public class JFileTree extends AbstractFileTree {
protected FileFilter fileFilter ;
protected FileFilter fileFilter;
public JFileTree() {
this(null);
@ -43,9 +42,9 @@ 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");
this.addTreeExpansionListener(this);
@ -57,7 +56,7 @@ public class JFileTree extends AbstractFileTree {
}
public void setRootFile(File rootFile) {
setRootFiles(new File[] { rootFile });
setRootFiles(new File[]{rootFile});
}
public void setRootFiles(File[] rootFiles) {
@ -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];
@ -96,22 +95,19 @@ public class JFileTree extends AbstractFileTree {
public File getSelectedFile() {
TreePath selectedTreePath = this.getSelectionPath();
if(selectedTreePath == null) {
if (selectedTreePath == null) {
return null;
}
DefaultMutableTreeNode currentTreeNode = this.getMutableTreeNode(selectedTreePath);
StringBuffer fBuf = new StringBuffer();
while (true) {
// 如果已经到了根节点,直接退出.
if (currentTreeNode == null) {
break;
}
StringBuilder fBuf = new StringBuilder();
while (currentTreeNode != null) {
// 如果已经到了根节点,直接退出.
Object object = currentTreeNode.getUserObject();
if (object instanceof RootFile) {
// 当前文件.
RootFile rootFileNode = (RootFile) object;
// 当前文件.
RootFile rootFileNode = (RootFile) object;
return new File(rootFileNode.getFile() + fBuf.toString());
}
@ -128,6 +124,7 @@ public class JFileTree extends AbstractFileTree {
/**
* 通过文件夹寻找展开路径
*
* @param currentFile 当前文件
*/
public void selectFile(File currentFile) {
@ -181,26 +178,25 @@ public class JFileTree extends AbstractFileTree {
/**
* 列出当前所有的File
*
* @param currentTreeNode 当前文件节点
* @return 当前节点下的所有File
*/
@Override
public FileDirectoryNode[] listFileNodes(DefaultMutableTreeNode currentTreeNode) {
StringBuffer fBuf = new StringBuffer();
while (true) {
// 如果已经到了根节点,直接退出.
if (currentTreeNode == null) {
break;
}
StringBuilder fBuf = new StringBuilder();
while (currentTreeNode != null) {
// 如果已经到了根节点,直接退出.
Object object = currentTreeNode.getUserObject();
if (object instanceof RootFile) {
RootFile rootFileNode = (RootFile) object;
RootFile rootFileNode = (RootFile) object;
// 当前文件. (rootFileNode + fBuf.toString = Path  local地址)
File currentFile = new File(rootFileNode.getFile() + fBuf.toString());
// 列出当前文件的所有子文件,要判断下是否是系统保护的文件 能否打开. 打不开的话显示为null
File[] files = currentFile.listFiles();
// 如果文件列表为null 或者为File[0] = []返回null
if (files == null ) {
return new FileDirectoryNode[0];
if (files == null) {
return new FileDirectoryNode[0];
}
List fileNodeList = new ArrayList();
for (int k = 0; k < files.length; k++) {
@ -211,8 +207,8 @@ public class JFileTree extends AbstractFileTree {
}
// 过滤只显示文件夹 并进行 名字简化
if (fileFilter.accept(tmpFile)) {
// newNode 传递 isDirectory属性 并且只显示文件夹名字
FileDirectoryNode newNode = FileDirectoryNode.createFileDirectoryNode(tmpFile);
// newNode 传递 isDirectory属性 并且只显示文件夹名字
FileDirectoryNode newNode = FileDirectoryNode.createFileDirectoryNode(tmpFile);
fileNodeList.add(newNode);
}
}
@ -220,78 +216,77 @@ 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
if (object instanceof FileDirectoryNode) {
FileDirectoryNode nameNode = (FileDirectoryNode)object;
fBuf.insert(0, nameNode.getName());
fBuf.insert(0, "/");
FileDirectoryNode nameNode = (FileDirectoryNode) object;
fBuf.insert(0, nameNode.getName());
fBuf.insert(0, "/");
}
// 逐层返回
currentTreeNode = (DefaultMutableTreeNode) currentTreeNode.getParent();
}
return new FileDirectoryNode[0];
}
/**
* cellRenderer: tree中显示文件的类型图标
* cellRenderer: tree中显示文件的类型图标
*/
private DefaultTreeCellRenderer fileTreeCellRenderer = new DefaultTreeCellRenderer() {
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean selected, boolean expanded, boolean leaf, int row,
boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, selected, expanded,
leaf, row, hasFocus);
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) value;
StringBuffer fBuf = new StringBuffer();
while(true) {
if (treeNode == null) {
break;
}
Object userObj = treeNode.getUserObject();
if (userObj instanceof RootFile) {
RootFile rootFileNode = (RootFile) userObj;
// 当前文件的全部路径. (rootFileNode + fBuf.toString = Path  local地址)
File currentFile = new File(rootFileNode.getFile() + fBuf.toString());
FileSystemView view = FileSystemView.getFileSystemView();
// File的全部路径.
// 得到本地tree图标
Icon tmpIcon = view.getSystemIcon(currentFile);
private DefaultTreeCellRenderer fileTreeCellRenderer = new DefaultTreeCellRenderer() {
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean selected, boolean expanded, boolean leaf, int row,
boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, selected, expanded,
leaf, row, hasFocus);
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) value;
StringBuilder fBuf = new StringBuilder();
while (treeNode != null) {
Object userObj = treeNode.getUserObject();
if (userObj instanceof RootFile) {
RootFile rootFileNode = (RootFile) userObj;
// 当前文件的全部路径. (rootFileNode + fBuf.toString = Path  local地址)
File currentFile = new File(rootFileNode.getFile() + fBuf.toString());
FileSystemView view = FileSystemView.getFileSystemView();
// File的全部路径.
// 得到本地tree图标
Icon tmpIcon = view.getSystemIcon(currentFile);
if (currentFile.isDirectory() && fBuf.length() > 0) {
tmpIcon=BaseUtils.readIcon("/com/fr/design/images/gui/folder.png");
tmpIcon = BaseUtils.readIcon("/com/fr/design/images/gui/folder.png");
}
this.setIcon(tmpIcon);
this.setName(null);
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()));
}else{
this.setFont(new Font(oldFont.getName(),0,oldFont.getSize()));
}
}
// 名字进行逐层反序的回加. 例: Doload ==> C:\java\Doload
if (userObj instanceof FileDirectoryNode ) {
FileDirectoryNode nameNode = (FileDirectoryNode)userObj;
fBuf.insert(0, nameNode.getName());
fBuf.insert(0, "/");
}
// 逐层往上 倒退返回
treeNode = (DefaultMutableTreeNode) treeNode.getParent();
}
return this;
}
};
this.setName(null);
Font oldFont = this.getFont();
if (ComparatorUtils.equals(currentFile.getName(), ProjectConstants.WEBINF_NAME)) {
this.setForeground(Color.blue);
this.setFont(new Font(oldFont.getName(), Font.BOLD, oldFont.getSize()));
} else {
this.setFont(new Font(oldFont.getName(), Font.PLAIN, oldFont.getSize()));
}
}
// 名字进行逐层反序的回加. 例: Doload ==> C:\java\Doload
if (userObj instanceof FileDirectoryNode) {
FileDirectoryNode nameNode = (FileDirectoryNode) userObj;
fBuf.insert(0, nameNode.getName());
fBuf.insert(0, "/");
}
// 逐层往上 倒退返回
treeNode = (DefaultMutableTreeNode) treeNode.getParent();
}
return this;
}
};
/**
* 对文件夹进行排序 先文件夹 然后各种类型文件
* 对文件夹进行排序 先文件夹 然后各种类型文件
*
* @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";
}

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 java.awt.Color;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* 更新升级的常量
@ -28,7 +32,7 @@ public interface UpdateConstants {
int BYTE = 153600;
String[] JARS_FOR_SERVER_X = new String[]{
List<String> JARS_FOR_SERVER_X = Collections.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[]{
List<String> JARS_FOR_DESIGNER_X = Collections.unmodifiableList(Arrays.asList(new String[]{
"fine-report-designer-10.0.jar",
"aspectjrt.jar"
};
}));
String[] LOG_TYPE = new String[]{
List<String> LOG_TYPE = Collections.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),

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

@ -23,11 +23,7 @@ import com.fr.design.onlineupdate.ui.widget.UpdateInfoTableCellRender;
import com.fr.design.onlineupdate.ui.widget.UpdateInfoTableModel;
import com.fr.design.onlineupdate.ui.widget.UpdateInfoTextAreaCellRender;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.DateUtils;
import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils;
import com.fr.general.SiteCenter;
import com.fr.general.*;
import com.fr.general.http.HttpClient;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
@ -58,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;
@ -443,8 +434,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) {
@ -466,7 +457,7 @@ public class UpdateMainDialog extends UIDialog {
}
}
br.close();
reader.close();
streamReader.close();
}
}
@ -490,8 +481,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"));
@ -499,7 +490,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);
@ -678,7 +669,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(
@ -690,7 +681,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(
@ -734,21 +725,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);
}
}
@ -758,9 +750,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);
}
}
@ -791,7 +784,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;
}

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

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

@ -37,7 +37,9 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.form.ui.ChartEditor;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.plugin.chart.PiePlot4VanChart;
import com.fr.plugin.chart.area.VanChartAreaPlot;
@ -57,10 +59,16 @@ import com.fr.plugin.chart.scatter.VanChartScatterPlot;
import com.fr.plugin.chart.structure.VanChartStructurePlot;
import com.fr.plugin.chart.treemap.VanChartTreeMapPlot;
import com.fr.plugin.chart.wordcloud.VanChartWordCloudPlot;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.injectable.PluginSingleInjection;
import com.fr.plugin.injectable.SpecialLevel;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
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 +115,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;
@ -116,6 +126,25 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
readDefault();
readVanChart();
PluginModule.registerAgent(PluginModule.ExtraChartDesign, classManager);
GeneralContext.listenPluginRunningChanged(new PluginEventListener() {
@Override
public void on(PluginEvent event) {
synchronized (ChartTypeInterfaceManager.class) {
//因为是CloseableContainedMap,所以不能在mount那边处理。
DesignModuleFactory.registerExtraWidgetOptions(ChartTypeInterfaceManager.initWidgetOption());
}
}
}, new PluginFilter() {
@Override
public boolean accept(PluginContext context) {
return context.contain(PluginModule.ExtraChartDesign, SpecialLevel.IndependentChartUIProvider.getTagName());
}
});
}
public static WidgetOption[] initWidgetOption() {
@ -260,6 +289,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

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

@ -10,25 +10,25 @@ import java.util.List;
*/
public class UIComboBoxWithNone extends UIComboBox {
private static String getNoneLocaleString() {
protected String getDefaultLocaleString() {
return Toolkit.i18nText("Fine-Design_Chart_Use_None");
}
@Override
public void refreshBoxItems(List list) {
super.refreshBoxItems(list);
addNoneItem();
addDefaultItem();
}
@Override
public void clearBoxItems() {
super.clearBoxItems();
addNoneItem();
addDefaultItem();
}
private void addNoneItem() {
addItem(getNoneLocaleString());
private void addDefaultItem() {
addItem(getDefaultLocaleString());
}
@ -37,7 +37,7 @@ public class UIComboBoxWithNone extends UIComboBox {
super.setSelectedItem(anObject);
if (getSelectedIndex() == -1) {//找不到的都选中无。中文的无 英文下是none。
super.setSelectedItem(getNoneLocaleString());
super.setSelectedItem(getDefaultLocaleString());
}
}

21
designer-chart/src/main/java/com/fr/van/chart/column/VanChartCustomStackAndAxisConditionPane.java

@ -34,8 +34,6 @@ public class VanChartCustomStackAndAxisConditionPane extends BasicBeanPane<Condi
protected UIButtonGroup<Integer> isStacked;
protected UIButtonGroup<Integer> isPercentStacked;
private ConditionAttr conditionAttr;
private LiteConditionPane liteConditionPane;
public VanChartCustomStackAndAxisConditionPane() {
@ -99,10 +97,12 @@ public class VanChartCustomStackAndAxisConditionPane extends BasicBeanPane<Condi
}
public void populateBean(ConditionAttr conditionAttr) {
this.conditionAttr = conditionAttr;
AttrSeriesStackAndAxis seriesStackAndAxis = (AttrSeriesStackAndAxis) conditionAttr.getExisted(AttrSeriesStackAndAxis.class);
XAxis = new UIButtonGroup<Integer>(seriesStackAndAxis.getXAxisNamesArray());
YAxis = new UIButtonGroup<Integer>(seriesStackAndAxis.getYAxisNameArray());
AttrSeriesStackAndAxis seriesStackAndAxis = conditionAttr.getExisted(AttrSeriesStackAndAxis.class);
if (XAxis == null || YAxis == null) {
XAxis = new UIButtonGroup<Integer>(seriesStackAndAxis.getXAxisNamesArray());
YAxis = new UIButtonGroup<Integer>(seriesStackAndAxis.getYAxisNameArray());
}
doLayoutPane();
XAxis.setSelectedIndex(seriesStackAndAxis.getXAxisIndex());
@ -129,11 +129,16 @@ public class VanChartCustomStackAndAxisConditionPane extends BasicBeanPane<Condi
}
public ConditionAttr updateBean() {
AttrSeriesStackAndAxis seriesStackAndAxis = (AttrSeriesStackAndAxis)conditionAttr.getExisted(AttrSeriesStackAndAxis.class); seriesStackAndAxis.setXAxisIndex(XAxis.getSelectedIndex());
ConditionAttr conditionAttr = new ConditionAttr();
AttrSeriesStackAndAxis seriesStackAndAxis = conditionAttr.getExisted(AttrSeriesStackAndAxis.class);
if (seriesStackAndAxis == null) {
seriesStackAndAxis = new AttrSeriesStackAndAxis();
conditionAttr.addDataSeriesCondition(seriesStackAndAxis);
}
seriesStackAndAxis.setXAxisIndex(XAxis.getSelectedIndex());
seriesStackAndAxis.setYAxisIndex(YAxis.getSelectedIndex());
updateStackAndPercent(seriesStackAndAxis);
conditionAttr.addDataSeriesCondition(seriesStackAndAxis);
AbstractCondition con = (AbstractCondition) this.liteConditionPane.updateBean();
conditionAttr.setCondition(con);

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

@ -3,6 +3,7 @@ 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;
@ -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() {
@ -49,12 +54,12 @@ 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()},
};
}

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/mainframe/FormParaWidgetPane.java

@ -22,9 +22,9 @@ import com.fr.form.ui.WidgetConfig;
import com.fr.form.ui.WidgetInfoConfig;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.injectable.SpecialLevel;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
@ -98,7 +98,8 @@ public class FormParaWidgetPane extends JPanel {
@Override
public boolean accept(PluginContext context) {
return context.contain(PluginModule.ExtraDesign, FormWidgetOptionProvider.XML_TAG);
return context.contain(PluginModule.ExtraDesign, FormWidgetOptionProvider.XML_TAG)
|| context.contain(PluginModule.ExtraChartDesign, SpecialLevel.IndependentChartUIProvider.getTagName());
}
});
}

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

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

@ -63,13 +63,13 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
watermarkEditor = new AccessibleBodyWatermarkEditor();
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style")), borderStyleEditor},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor}
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style")), borderStyleEditor},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor}
}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1);
JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
borderPane.add(jPanel, BorderLayout.CENTER);
UIExpandablePane advancedPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, borderPane );
UIExpandablePane advancedPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, borderPane);
centerPane.add(advancedPane, BorderLayout.NORTH);
this.add(centerPane, BorderLayout.NORTH);
}
@ -122,9 +122,9 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
}
if (layoutType == WBodyLayoutType.ABSOLUTE) {
((XWFitLayout)creator.getBackupParent()).toData().resetStyle();
((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;
}
}
}
}
}

27
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;
@ -81,8 +82,8 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
paddingBound = new PaddingBoundPane();
JPanel jp2 = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style")), stylePane},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor}
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style")), stylePane},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor}
}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1);
jp2.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
jPanel.add(paddingBound, BorderLayout.CENTER);
@ -136,8 +137,14 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
XLayoutContainer rootLayout = selectedBodyLayout(formDesigner);
if (rootLayout != formDesigner.getRootComponent()
&& formDesigner.getSelectionModel().getSelection().getSelectedCreator() == formDesigner.getRootComponent()) {
formDesigner.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{selectedBodyLayout(formDesigner).toData()}));
//原单例面板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());
@ -149,8 +156,8 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
private XLayoutContainer selectedBodyLayout(FormDesigner formDesigner) {
XLayoutContainer rootLayout = formDesigner.getRootComponent();
if (rootLayout.getComponentCount() == 1 && rootLayout.getXCreator(0).acceptType(XWAbsoluteBodyLayout.class)){
rootLayout = (XWAbsoluteBodyLayout)rootLayout.getXCreator(0);
if (rootLayout.getComponentCount() == 1 && rootLayout.getXCreator(0).acceptType(XWAbsoluteBodyLayout.class)) {
rootLayout = (XWAbsoluteBodyLayout) rootLayout.getXCreator(0);
}
return rootLayout;
}
@ -162,8 +169,8 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) {
paddingBound.update(layout);
}
LayoutBorderStyle borderStyle = (LayoutBorderStyle) stylePane.getValue();
if(borderStyle != null){
LayoutBorderStyle borderStyle = (LayoutBorderStyle) stylePane.getValue();
if (borderStyle != null) {
layout.setBorderStyle(borderStyle);
}
updateWatermark();
@ -205,7 +212,7 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
}
int intervelValue = (int)componentIntervel.getValue();
int intervelValue = (int) componentIntervel.getValue();
if (xWFitLayout.canAddInterval(intervelValue)) {
// 设置完间隔后,要同步处理界面组件,容器刷新后显示出对应效果
setLayoutGap(intervelValue);
@ -227,7 +234,7 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
}
private void setLayoutGap(int value) {
int interval = wFitLayout.getCompInterval();
int interval = wFitLayout.getCompInterval();
if (value != interval) {
xWFitLayout.moveContainerMargin();
xWFitLayout.moveCompInterval(xWFitLayout.getAcualInterval());

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

@ -14,7 +14,7 @@ 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;
@ -142,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();

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;

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

10
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

@ -17,16 +17,16 @@ import com.fr.third.org.apache.commons.codec.digest.DigestUtils;
/**
* 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();
}
}
}

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

Binary file not shown.

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

@ -9,7 +9,7 @@ import org.junit.Before;
import org.junit.Test;
public class SearchManegerTest {
SimilarSearchManeger similarSearchManeger;
SimilarSearchManager similarSearchManager;
ComplementAdviceManager complementAdviceManager;
DocumentSearchManager documentSearchManager;
PluginSearchManager pluginSearchManager;
@ -23,7 +23,7 @@ public class SearchManegerTest {
public void setUp() {
recentSearchManager = RecentSearchManager.getInstance();
recommendSearchManager = RecommendSearchManager.getInstance();
similarSearchManeger = SimilarSearchManeger.getInstance();
similarSearchManager = SimilarSearchManager.getInstance();
complementAdviceManager = ComplementAdviceManager.getInstance();
documentSearchManager = DocumentSearchManager.getInstance();
pluginSearchManager = PluginSearchManager.getInstance();
@ -43,7 +43,7 @@ public class SearchManegerTest {
lessModelList = recentSearchManager.getLessSearchResult(new String[]{"数据集"});
Assert.assertNotNull(lessModelList);
lessModelList = similarSearchManeger.getLessSearchResult(new String[]{"数据集"});
lessModelList = similarSearchManager.getLessSearchResult(new String[]{"数据集"});
Assert.assertEquals(lessModelList.get(1).getType(), CellType.ROBOT);
lessModelList = complementAdviceManager.getAllSearchResult(new String[]{"数据集"});
@ -51,7 +51,7 @@ public class SearchManegerTest {
//返回MoreSearchResult
SearchResult moreModelList;
moreModelList = similarSearchManeger.getMoreSearchResult("数据集");
moreModelList = similarSearchManager.getMoreSearchResult("数据集");
Assert.assertNotNull(moreModelList);
moreModelList = recommendSearchManager.getMoreSearchResult("数据集");
@ -60,7 +60,7 @@ public class SearchManegerTest {
@Test
public void getModelFromCloudTest() {
Assert.assertNotNull(SimilarSearchManeger.getModelFromCloud(new JSONObject()));
Assert.assertNotNull(SimilarSearchManager.getModelFromCloud(new JSONObject()));
Assert.assertNotNull(DocumentSearchManager.getModelFromCloud(new JSONObject()));
Assert.assertNotNull(PluginSearchManager.getModelFromCloud(new JSONObject()));
}

Loading…
Cancel
Save