Browse Source

Merge pull request #1496 in DESIGN/design from ~MAKSIM/design:release/10.0 to release/10.0

* commit 'b9f3b1b7377a8de303fe865aaa24500820226f3b':
  NPE处理方式
  根据显示的长度来定义间隔符
  处理NPE
  服务检测弹窗出现时间做修改
feature/big-screen
Maksim 5 years ago
parent
commit
75a72305cb
  1. 9
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 12
      designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java
  3. 20
      designer-base/src/main/java/com/fr/env/CheckServiceDialog.java
  4. 3
      designer-base/src/main/java/com/fr/env/EnvListPane.java
  5. 39
      designer-base/src/main/java/com/fr/env/utils/DisplayUtils.java
  6. 2
      designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java
  7. 52
      designer-base/src/test/java/com/fr/env/utils/DisplayUtilsTest.java

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

@ -14,7 +14,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.design.write.submit.CheckServiceDialog; import com.fr.env.CheckServiceDialog;
import com.fr.env.EnvListPane; import com.fr.env.EnvListPane;
import com.fr.exit.DesignerExiter; import com.fr.exit.DesignerExiter;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
@ -246,10 +246,17 @@ public class EnvChangeEntrance {
StringBuilder textBuilder = new StringBuilder(); StringBuilder textBuilder = new StringBuilder();
for (Class clazz : noExistServiceSet) { for (Class clazz : noExistServiceSet) {
WorkspaceAPI workspaceAPI = (WorkspaceAPI) clazz.getAnnotation(WorkspaceAPI.class); WorkspaceAPI workspaceAPI = (WorkspaceAPI) clazz.getAnnotation(WorkspaceAPI.class);
if(workspaceAPI == null){
FineLoggerFactory.getLogger().info("workspace service {} get annotation failed", clazz);
continue;
}
String descriptionOfCN = InterProviderFactory.getProvider().getLocText(workspaceAPI.description()); String descriptionOfCN = InterProviderFactory.getProvider().getLocText(workspaceAPI.description());
textBuilder.append(descriptionOfCN).append("\n"); textBuilder.append(descriptionOfCN).append("\n");
} }
String areaText = textBuilder.toString(); String areaText = textBuilder.toString();
if(StringUtils.isEmpty(areaText)){
return;
}
CheckServiceDialog dialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), areaText, localBranch, remoteBranch); CheckServiceDialog dialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), areaText, localBranch, remoteBranch);
dialog.setVisible(true); dialog.setVisible(true);
} }

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

@ -1,10 +1,13 @@
package com.fr.design.gui.controlpane; package com.fr.design.gui.controlpane;
import com.fr.design.DesignerEnvManager;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.data.tabledata.tabledatapane.GlobalMultiTDTableDataPane; import com.fr.design.data.tabledata.tabledatapane.GlobalMultiTDTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.GlobalTreeTableDataPane; import com.fr.design.data.tabledata.tabledatapane.GlobalTreeTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.MultiTDTableDataPane; import com.fr.design.data.tabledata.tabledatapane.MultiTDTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane; import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
@ -99,6 +102,15 @@ class JControlUpdatePane extends JPanel {
if (pane != null && pane.isVisible()) { if (pane != null && pane.isVisible()) {
Object bean = pane.updateBean(); Object bean = pane.updateBean();
try {
if (bean instanceof RemoteDesignerWorkspaceInfo) {
DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(elEditing.wrapper.getName());
String remindTime = info.getRemindTime();
((RemoteDesignerWorkspaceInfo) bean).setRemindTime(remindTime);
}
}catch (Exception e){
FineLoggerFactory.getLogger().info("remindTime is not exist");
}
if (i < creators.length) { if (i < creators.length) {
creators[i].saveUpdatedBean(elEditing, bean); creators[i].saveUpdatedBean(elEditing, bean);
} }

20
designer-base/src/main/java/com/fr/design/write/submit/CheckServiceDialog.java → designer-base/src/main/java/com/fr/env/CheckServiceDialog.java vendored

@ -1,4 +1,4 @@
package com.fr.design.write.submit; package com.fr.env;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo;
@ -7,6 +7,7 @@ import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.env.utils.DisplayUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
@ -17,6 +18,7 @@ import javax.swing.JDialog;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTextArea; import javax.swing.JTextArea;
import javax.swing.JTextPane;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Frame; import java.awt.Frame;
@ -55,15 +57,23 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
JLabel label = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Inconsistency")); JLabel label = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Inconsistency"));
label.setFont(font); label.setFont(font);
label.setPreferredSize(new Dimension(650,30)); label.setPreferredSize(new Dimension(650,30));
String text = Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Local_Designer") + localBranch
+ Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") + remoteBranch;
String delimiter = DisplayUtils.getDisplayLength(text) > 70? "<br>":"/";
JLabel label2 = new JLabel("<html>"+Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Local_Designer") JLabel label2 = new JLabel("<html>"+Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Local_Designer")
+ localBranch + "/" + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") + remoteBranch+"</html>"); + localBranch + delimiter + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") + remoteBranch+"</html>");
label2.setPreferredSize(new Dimension(600,30)); label2.setPreferredSize(new Dimension(600,30));
JLabel label3 = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Need_Update"));
label3.setPreferredSize(new Dimension(500,30)); JTextPane tipsPane = new JTextPane();
tipsPane.setEditable(false);
tipsPane.setBackground(verticalPanel.getBackground());
tipsPane.setPreferredSize(new Dimension(500,30));
tipsPane.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Need_Update"));
verticalPanel.add(label); verticalPanel.add(label);
verticalPanel.add(label2); verticalPanel.add(label2);
verticalPanel.add(label3); verticalPanel.add(tipsPane);
topPanel.add(imagePanel,BorderLayout.WEST); topPanel.add(imagePanel,BorderLayout.WEST);
topPanel.add(verticalPanel,BorderLayout.CENTER); topPanel.add(verticalPanel,BorderLayout.CENTER);

3
designer-base/src/main/java/com/fr/env/EnvListPane.java vendored

@ -96,8 +96,9 @@ public class EnvListPane extends JListControlPane {
*/ */
public String updateEnvManager() { public String updateEnvManager() {
DesignerEnvManager mgr = DesignerEnvManager.getEnvManager(); DesignerEnvManager mgr = DesignerEnvManager.getEnvManager();
mgr.clearAllEnv(); //这里代码时序换一下,因为update中需要借助mgr来获取提醒时间,已确认mgr对res无依赖
Nameable[] res = this.update(); Nameable[] res = this.update();
mgr.clearAllEnv();
for (Nameable re : res) { for (Nameable re : res) {
NameObject nameObject = (NameObject) re; NameObject nameObject = (NameObject) re;
mgr.putEnv(nameObject.getName(), (DesignerWorkspaceInfo) nameObject.getObject()); mgr.putEnv(nameObject.getName(), (DesignerWorkspaceInfo) nameObject.getObject());

39
designer-base/src/main/java/com/fr/env/utils/DisplayUtils.java vendored

@ -0,0 +1,39 @@
package com.fr.env.utils;
/**
* @author: Maksim
* @Date: Created in 2020/3/16
* @Description:
*/
public class DisplayUtils {
/**
* 获取字符串显示时的计算长度
* @param text 被计算的字符串
* @return 计算长度
*/
public static int getDisplayLength(String text){
if (text == null) {
return 0;
}
char[] c = text.toCharArray();
int len = 0;
for (int i = 0; i < c.length; i++) {
len++;
if(!isLetter(c[i])){
len++;
};
}
return len;
}
/**
* 判断字符是否为字母数字英文符号
* @param c 传入的字符
* @return 如果符合上述条件返回true
*/
public static boolean isLetter(char c) {
int k = 0x80;
return c / k == 0;
}
}

2
designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java

@ -2,7 +2,7 @@ package com.fr.design;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.write.submit.CheckServiceDialog; import com.fr.env.CheckServiceDialog;
import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import org.easymock.EasyMock; import org.easymock.EasyMock;

52
designer-base/src/test/java/com/fr/env/utils/DisplayUtilsTest.java vendored

@ -0,0 +1,52 @@
package com.fr.env.utils;
import org.junit.Assert;
import org.junit.Test;
/**
* @author: Maksim
* @Date: Created in 2020/3/16
* @Description:
*/
public class DisplayUtilsTest {
@Test
public void getDisplayLengthTest() {
String s1 = "本地设计器";
String s2 = "リモートサーバ";
String s3 = "Local Designer:";
String s4 = "本地,设,计器: persist-2020.01.15";
String s5 = "ローカルデザイナrelease-2020.03.03 ... Remote Server:persist-2020.01.15";
String s6 = "本地 00:00ロ ーカDE / abc ";
int length1 = DisplayUtils.getDisplayLength(s1);
int length2 = DisplayUtils.getDisplayLength(s2);
int length3 = DisplayUtils.getDisplayLength(s3);
int length4 = DisplayUtils.getDisplayLength(s4);
int length5 = DisplayUtils.getDisplayLength(s5);
int length6 = DisplayUtils.getDisplayLength(s6);
Assert.assertEquals(10,length1);
Assert.assertEquals(14,length2);
Assert.assertEquals(15,length3);
Assert.assertEquals(34,length4);
Assert.assertEquals(72,length5);
Assert.assertEquals(26,length6);
}
@Test
public void isLetterTest(){
char c1 = 'A';
char c2 = '中';
char c3 = ',';
char c4 = ',';
char c5 = 'デ';
char c6 = ' ';
Assert.assertTrue(DisplayUtils.isLetter(c1));
Assert.assertFalse(DisplayUtils.isLetter(c2));
Assert.assertTrue(DisplayUtils.isLetter(c3));
Assert.assertFalse(DisplayUtils.isLetter(c4));
Assert.assertFalse(DisplayUtils.isLetter(c5));
Assert.assertTrue(DisplayUtils.isLetter(c6));
}
}
Loading…
Cancel
Save