Browse Source

Merge branch 'final/10.0' of https://code.fineres.com/scm/~qinghui.liu/design into final/10.0

final/10.0
Qinghui.Liu 4 years ago
parent
commit
9b54229236
  1. 3
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  2. 10
      designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java
  3. 2
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  4. 129
      designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java
  5. 67
      designer-base/src/main/java/com/fr/design/utils/DesignUtils.java
  6. 24
      designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java
  7. 11
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  8. 9
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  9. 15
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  10. 7
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java
  11. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java
  12. 11
      designer-realize/src/test/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRenderTest.java

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

@ -185,7 +185,8 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
box.setMinimumSize(new Dimension(300, 400));
// 防止数据连接名过长时影响 split pane 分割效果
connectionTableProcedurePane.setMinimumSize(new Dimension(250, 400));
// 本界面中给MaxMemRowCountPanel留的空间太小,造成MaxMemRowCountPanel显示异常,这边减小一点最小宽度,拉长MaxMemRowCountPanel
connectionTableProcedurePane.setMinimumSize(new Dimension(230, 400));
connectionTableProcedurePane.setMaximumSize(new Dimension(500, 400));
// 使用SplitPane
JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, connectionTableProcedurePane, sqlSplitPane);

10
designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java

@ -3,11 +3,12 @@ package com.fr.design.gui.iprogressbar;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.ilable.UILabel;
import com.fr.stable.os.support.OSBasedAction;
import com.fr.stable.os.support.OSSupportCenter;
import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont;
import com.fr.stable.os.support.OSBasedAction;
import com.fr.stable.os.support.OSSupportCenter;
import javax.swing.JDialog;
import javax.swing.JLabel;
@ -57,7 +58,10 @@ public class ProgressDialog extends UIDialog {
progressBar.setMaximum(1000);
panel.add(progressBar, BorderLayout.CENTER);
text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Project"), JLabel.CENTER);
FRFont font = FRFont.getInstance().applySize(14).applyForeground(new ColorUIResource(333334));
FRFont font = DesignUtils
.getDefaultGUIFont()
.applySize(14)
.applyForeground(new ColorUIResource(333334));
text.setFont(font);
panel.add(text, BorderLayout.SOUTH);
panel.setVisible(true);

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

@ -578,7 +578,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
});
nameField.selectAll();
nameField.setPreferredSize(new Dimension(180, 20));
nameField.setPreferredSize(new Dimension(170, 20));
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5));
topPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 0, 15));

129
designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java

@ -7,7 +7,7 @@ import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.controlpane.NameableSelfCreator;
import com.fr.design.gui.controlpane.UnrepeatedNameHelper;
import com.fr.design.gui.ilist.ModNameActionListener;
import com.fr.design.i18n.Toolkit;
import com.fr.general.ComparatorUtils;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
@ -18,79 +18,74 @@ import java.util.Arrays;
import java.util.List;
public class ParameterArrayPane extends JListControlPane {
/**
* Constructor.
*/
public ParameterArrayPane() {
super();
this.addModNameActionListener(new ModNameActionListener() {
public void nameModed(int index, String oldName, String newName) {
populateSelectedValue();
}
/**
* Constructor.
*/
public ParameterArrayPane() {
super();
this.addModNameActionListener((index, oldName, newName) -> populateSelectedValue());
this.addEditingListener(new PropertyChangeAdapter() {
public void propertyChange() {
Parameter[] parameters = ParameterConfig.getInstance().getGlobalParameters();
String[] allListNames = nameableList.getAllNames();
allListNames[editingIndex] = StringUtils.EMPTY;
String tempName = getEditingName();
if (StringUtils.isEmpty(tempName)) {
nameableList.stopEditing();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ParameterArrayPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Empty_Parameter_Name"));
setIllegalIndex(editingIndex);
return;
}
if (!ComparatorUtils.equals(tempName, selectedName)
&& isNameRepeated(new List[]{Arrays.asList(parameters), Arrays.asList(allListNames)}, tempName)) {
nameableList.stopEditing();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ParameterArrayPane.this),
Toolkit.i18nText("Fine-Design_Basic_Duplicate_Parameter_Name"));
setIllegalIndex(editingIndex);
}
}
});
}
});
this.addEditingListener(new PropertyChangeAdapter() {
public void propertyChange() {
Parameter[] parameters = ParameterConfig.getInstance().getGlobalParameters();
String[] allListNames = nameableList.getAllNames();
allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY;
String tempName = getEditingName();
if (StringUtils.isEmpty(tempName)) {
nameableList.stopEditing();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ParameterArrayPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Empty_Parameter_Name"));
setIllegalIndex(editingIndex);
return;
}
if (!ComparatorUtils.equals(tempName, selectedName)
&& isNameRepeated(new List[]{Arrays.asList(parameters), Arrays.asList(allListNames)}, tempName)) {
nameableList.stopEditing();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ParameterArrayPane.this),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Duplicate_Parameter_Name"));
setIllegalIndex(editingIndex);
}
}
});
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Engine_Schedule_Template_Parameter");
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Engine_Schedule_Template_Parameter");
}
/**
* 创建模板参数设置组件
*
* @return 模板参数设置组件
*/
public NameableCreator[] createNameableCreators() {
return new NameableCreator[]{
new NameableSelfCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Engine_Parameter_Name"), Parameter.class, ParameterPane.class) {
public Parameter createNameable(UnrepeatedNameHelper helper) {
// 返回参数设置面板.
return new Parameter(helper.createUnrepeatedName("p"));
}
/**
* 创建模板参数设置组件
*
* @return 模板参数设置组件
*/
public NameableCreator[] createNameableCreators() {
return new NameableCreator[]{
new NameableSelfCreator(Toolkit.i18nText("Fine-Design_Basic_Engine_Parameter_Name"), Parameter.class, ParameterPane.class) {
public Parameter createNameable(UnrepeatedNameHelper helper) {
// 返回参数设置面板.
return new Parameter(helper.createUnrepeatedName("p"));
}
@Override
public String createTooltip() {
return null;
}
}
};
}
@Override
public String createTooltip() {
return null;
}
}
};
}
/**
* 更新参数
/**
* 更新参数
*
* @return 更新后的参数
*/
public Parameter[] updateParameters() {
// Nameable[]居然不能强转成Parameter[],一定要这么写...
Nameable[] res = this.update();
Parameter[] res_array = new Parameter[res.length];
java.util.Arrays.asList(res).toArray(res_array);
*/
public Parameter[] updateParameters() {
// Nameable[]居然不能强转成Parameter[],一定要这么写...
Nameable[] res = this.update();
Parameter[] res_array = new Parameter[res.length];
Arrays.asList(res).toArray(res_array);
return res_array;
}
return res_array;
}
}

67
designer-base/src/main/java/com/fr/design/utils/DesignUtils.java

@ -8,6 +8,7 @@ import com.fr.design.ExtraDesignClassManager;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.fun.DesignerEnvProcessor;
import com.fr.design.gui.UILookAndFeel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.exit.DesignerExiter;
import com.fr.file.FileFILE;
@ -21,7 +22,9 @@ import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.os.OperatingSystem;
import com.fr.start.ServerStarter;
import com.fr.value.NotNullLazyValue;
import com.fr.workspace.WorkContext;
import org.jetbrains.annotations.NotNull;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
@ -248,6 +251,7 @@ public class DesignUtils {
// 刷新DesignerFrame里面的面板
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (DesignerContext.getDesignerFrame() == null) {
return;
@ -269,7 +273,7 @@ public class DesignUtils {
FineLoggerFactory.getLogger().error("Substance Raven Graphite failed to initialize");
}
//获取当前系统语言下设计器用的默认字体
FRFont guiFRFont = getCurrentLocaleFont();
FRFont guiFRFont = getDefaultGUIFont();
//指定UIManager中字体
Enumeration keys = UIManager.getDefaults().keys();
while (keys.hasMoreElements()) {
@ -286,41 +290,50 @@ public class DesignUtils {
}
/**
* 获取当前系统语言下设计器用的默认字体
* 获取当前系统语言下设计器界面使用的默认字体
*
* @return 默认字体
*/
private static FRFont getCurrentLocaleFont() {
FRFont guiFRFont;
Locale defaultLocale = Locale.getDefault();
// JDK9 之后宋体在计算label中字母的空间上出现问题,暂时先用雅黑兼容,以后再统一字体
if (StableUtils.getMajorJavaVersion() >= 9 && OperatingSystem.isWindows()) {
guiFRFont = getNamedFont("Microsoft YaHei");
} else if (isDisplaySimSun(defaultLocale)) {
guiFRFont = getNamedFont("SimSun");
} else {
guiFRFont = getNamedFont("Dialog");
}
public static FRFont getDefaultGUIFont() {
return CURRENT_LOCALE_FONT.getValue();
}
//先初始化的设计器locale, 后初始化lookandfeel.如果顺序改了, 这边也要调整.
Locale designerLocale = GeneralContext.getLocale();
String file = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_File");
char displayChar = file.charAt(0);
if (!guiFRFont.canDisplay(displayChar)) {
//如果不能用默认的语言显示字体, 比如想在英文系统里用中文设计器
//默认语言(中文:宋体, 英文:Tahoma, 其他:Dialog)
guiFRFont = getNamedFont("SimSun");
if (!guiFRFont.canDisplay(displayChar)) {
//比如想在中文或英文系统里用韩文设计器
/**
* 获取当前系统语言下设计器用的默认字体
*/
private static final NotNullLazyValue<FRFont> CURRENT_LOCALE_FONT = new NotNullLazyValue<FRFont>() {
@NotNull
@Override
protected FRFont compute() {
FRFont guiFRFont;
Locale defaultLocale = Locale.getDefault();
// JDK9 之后宋体在计算label中字母的空间上出现问题,暂时先用雅黑兼容,以后再统一字体
if (StableUtils.getMajorJavaVersion() >= 9 && OperatingSystem.isWindows()) {
guiFRFont = getNamedFont("Microsoft YaHei");
} else if (isDisplaySimSun(defaultLocale)) {
guiFRFont = getNamedFont("SimSun");
} else {
guiFRFont = getNamedFont("Dialog");
}
String file = Toolkit.i18nText("Fine-Design_Basic_File");
char displayChar = file.charAt(0);
if (!guiFRFont.canDisplay(displayChar)) {
//如果不能用默认的语言显示字体, 比如想在英文系统里用中文设计器
//默认语言(中文:宋体, 英文:Tahoma, 其他:Dialog)
guiFRFont = getNamedFont("SimSun");
if (!guiFRFont.canDisplay(displayChar)) {
FineLoggerFactory.getLogger().error(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_SimSun_Not_Found"));
//比如想在中文或英文系统里用韩文设计器
guiFRFont = getNamedFont("Dialog");
if (!guiFRFont.canDisplay(displayChar)) {
FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Base_SimSun_Not_Found"));
}
}
}
}
return guiFRFont;
}
return guiFRFont;
}
};
private static FRFont getNamedFont(String name) {
return FRFont.getInstance(name, Font.PLAIN, 12);

24
designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java

@ -30,6 +30,7 @@ import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormDesignerModeForSpecial;
import com.fr.design.mainframe.FormDesignerUI;
import com.fr.design.mainframe.FormParaPane;
import com.fr.design.mainframe.FormWidgetDetailPane;
import com.fr.design.mainframe.JTemplate;
@ -58,6 +59,7 @@ import java.awt.Graphics;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -467,6 +469,21 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
return ((FormParameterUI) getTarget()).getDesignSize();
}
/**
* 设置其UI类为DesignerUI负责渲染
*/
@Override
public void updateUI() {
setUI(new FormDesignerUI(){
@Override
protected Rectangle getFitPaintBounds(Component component, Component parent) {
return new Rectangle(0, 0, parent.getSize().width, parent.getSize().height);
}
});
}
/**
* 设置高度
*
@ -722,4 +739,11 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
return new JComponent[]{new CutAction(this).createToolBarComponent(), new CopyAction(this).createToolBarComponent(), new PasteAction(this).createToolBarComponent(),
new FormDeleteAction(this).createToolBarComponent()};
}
@Override
public boolean checkIfBeyondValidArea(MouseEvent e){
return false;
}
}

11
designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java

@ -166,7 +166,7 @@ public class EditingMouseListener extends MouseInputAdapter {
// 获取焦点,以便获取热键
designer.requestFocus();
}
if (e.getButton() == MouseEvent.BUTTON1 && !beyondValidArea(e)) {
if (e.getButton() == MouseEvent.BUTTON1 && !designer.checkIfBeyondValidArea(e)) {
Direction dir = selectionModel.getDirectionAt(e);
if (!DesignerMode.isAuthorityEditing()) {
@ -194,15 +194,6 @@ public class EditingMouseListener extends MouseInputAdapter {
e.translatePoint(oldX - e.getX(), oldY - e.getY());
}
private boolean beyondValidArea(MouseEvent e) {
if (e.getX() < 0 || e.getY() < 0 ||
e.getX() > designer.getRootComponent().getWidth() ||
e.getY() > (designer.getRootComponent().getHeight() + designer.getParaHeight())) {
return true;
}
return false;
}
private void offsetEventPoint(MouseEvent e){
int x = designer.getRelativeX(e.getX());
int y = designer.getRelativeY(e.getY());

9
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -1733,4 +1733,13 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return (int) (this.getArea().getVerticalValue() / this.scale);
}
public boolean checkIfBeyondValidArea(MouseEvent e){
if (e.getX() < 0 || e.getY() < 0 ||
e.getX() > this.getRootComponent().getWidth() ||
e.getY() > (this.getRootComponent().getHeight() + this.getParaHeight())) {
return true;
}
return false;
}
}

15
designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java

@ -424,12 +424,8 @@ public class FormDesignerUI extends ComponentUI {
// 禁止双缓冲
ComponentUtils.disableBuffer(component, dbcomponents);
Graphics clipg;
clipg = g.create(
-designer.getHorizontalScaleValue(),
-designer.getVerticalScaleValue() + designer.getParaHeight(),
component.getSize().width + designer.getHorizontalScaleValue(),
component.getSize().height + designer.getVerticalScaleValue());
Rectangle clipgBounds = getFitPaintBounds(component, parent);
clipg = g.create(clipgBounds.x, clipgBounds.y, clipgBounds.width, clipgBounds.height);
designer.paintContent(clipg);
paintWatermark((Graphics2D) clipg);
clipg.dispose();
@ -439,6 +435,13 @@ public class FormDesignerUI extends ComponentUI {
designer.resetEditorComponentBounds();
}
protected Rectangle getFitPaintBounds(Component component, Component parent) {
return new Rectangle(-designer.getHorizontalScaleValue(),
-designer.getVerticalScaleValue() + designer.getParaHeight(),
component.getSize().width + designer.getHorizontalScaleValue(),
component.getSize().height + designer.getVerticalScaleValue());
}
/**
* 画参数面板
*/

7
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java

@ -124,7 +124,10 @@ public class ContentCellRender implements ListCellRenderer<Object> {
private String getReplacedString(String modelName, String string) {
//需要考虑modelName有空格的情况
//比如现在是work boo k 搜索词是workb,应该要替换的部分是work b
//先去掉空格进行匹配
//先去掉已经匹配替换过的部分,因为考虑到分词的情况,可能会进行多次替换
final String regex = "\\|<font.*?</font>\\|";
modelName = modelName.replaceAll(regex, StringUtils.EMPTY);
//再去掉空格进行匹配
String noBlackName = modelName.replaceAll(StringUtils.BLANK, StringUtils.EMPTY).toLowerCase();
int index = noBlackName.indexOf(string.toLowerCase());
if (index == -1) {
@ -139,6 +142,4 @@ public class ContentCellRender implements ListCellRenderer<Object> {
}
return result.toString();
}
}

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

@ -112,7 +112,7 @@ public class FileSearchManager implements AlphaFineSearchProvider {
name = name.replaceAll(StringUtils.BLANK, StringUtils.EMPTY);
if (name.contains(searchText)) {
FileModel model = new FileModel(node.getName(), node.getEnvPath());
if (!AlphaFineHelper.getFilterResult().contains(model)) {
if (!AlphaFineHelper.getFilterResult().contains(model) && !filterModelList.contains(model)) {
AlphaFineHelper.checkCancel();
filterModelList.add(model);
}

11
designer-realize/src/test/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRenderTest.java

@ -1,7 +1,9 @@
package com.fr.design.mainframe.alphafine.cell.render;
import com.fr.stable.StringUtils;
import org.junit.Test;
import static org.junit.Assert.*;
/**
@ -13,11 +15,20 @@ public class ContentCellRenderTest {
@Test
public void highLightModelName() {
final String regex = "<font.*?</font>";
String searchText = "workb";
ContentCellRender contentCellRender = new ContentCellRender(searchText,new String[]{searchText});
String workbook = contentCellRender.highLightModelName("workbook", new String[]{searchText});
assertTrue(workbook.endsWith("workb</font>ook</body></HTML>"));
workbook = contentCellRender.highLightModelName("work book", new String[]{searchText});
assertTrue(workbook.endsWith("work b</font>ook</body></HTML>"));
searchText = "我是空格";
contentCellRender = new ContentCellRender(searchText, new String[]{"我是空格", "我是", "空格"});
workbook = contentCellRender.highLightModelName("我是 空格", new String[]{searchText});
assertEquals(workbook.replaceFirst(regex, StringUtils.EMPTY), workbook.replaceAll(regex, StringUtils.EMPTY));
workbook = contentCellRender.highLightModelName("我是是 空格", new String[]{"我是空格", "我是", "空格"});
assertNotEquals(workbook.replaceFirst(regex, StringUtils.EMPTY), workbook.replaceAll(regex, StringUtils.EMPTY));
}
}
Loading…
Cancel
Save