Browse Source

REPORT-46574 & REPORT-46813 & REPORT-46550

feature/big-screen
lucian 4 years ago
parent
commit
22a581c108
  1. 7
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 44
      designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java
  3. BIN
      designer-base/src/main/resources/com/fr/design/images/warnings/icon_WarningIcon_normal.png
  4. BIN
      designer-base/src/main/resources/com/fr/design/images/warnings/icon_WarningIcon_normal@2x.png
  5. 26
      designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java
  6. 11
      designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java
  7. 50
      designer-realize/src/test/java/com/fr/start/module/DesignerWorkspaceProviderTest.java

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

@ -146,7 +146,7 @@ public class EnvChangeEntrance {
template.refreshToolArea();
}
showServiceDialog(selectedEnv);
pluginErrorRemind(selectedEnv);
pluginErrorRemind();
} catch (WorkspaceAuthException | RegistEditionException e) {
// String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed");
// String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote");
@ -302,10 +302,9 @@ public class EnvChangeEntrance {
/**
* 插件启动错误信息提示
* @param selectedEnv 选择的工作环境
*/
public void pluginErrorRemind(DesignerWorkspaceInfo selectedEnv) {
if (selectedEnv.getType() == DesignerWorkspaceType.Remote) {
public void pluginErrorRemind() {
if (!WorkContext.getCurrent().isLocal()) {
return;
}

44
designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java vendored

@ -6,7 +6,6 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import javax.swing.BorderFactory;
@ -14,52 +13,65 @@ import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextPane;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Locale;
/**
* 插件启动失败提示窗
*/
public class PluginErrorRemindDialog extends JDialog implements ActionListener {
public PluginErrorRemindDialog(Frame parent, String areaText) {
private static final String SIM_HEI = "SimHei";
public PluginErrorRemindDialog(Frame parent, String text) {
super(parent, true);
//上面的标签面板
JPanel topPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
JPanel imagePanel = new JPanel();
Icon icon = IOUtils.readIcon("com/fr/design/images/warnings/warning5.png");
Icon icon = IOUtils.readIcon("com/fr/design/images/warnings/icon_WarningIcon_normal.png");
JLabel imageLabel = new JLabel();
imageLabel.setIcon(icon);
imagePanel.add(imageLabel);
imagePanel.setPreferredSize(new Dimension(130, 100));
imagePanel.setPreferredSize(new Dimension(48, 48));
JPanel verticalPanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true);
JLabel label = new JLabel(Toolkit.i18nText("Fine-Design_Plugin_Error_Remind_Title"));
label.setFont(FRFont.getInstance().applySize(18).applyStyle(1));
label.setPreferredSize(new Dimension(650, 100));
label.setFont(FRFont.getInstance().applySize(16).applyName(SIM_HEI));
label.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20));
verticalPanel.add(label);
topPanel.add(imagePanel, BorderLayout.WEST);
topPanel.add(verticalPanel, BorderLayout.CENTER);
topPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
topPanel.setPreferredSize(new Dimension(600, 73));
topPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 0, 20));
//中间的文本域面板
JPanel centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
centerPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
centerPanel.setPreferredSize(new Dimension(480, 320));
centerPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
centerPanel.setPreferredSize(new Dimension(580, 269));
JTextPane textPane = new JTextPane();
SimpleAttributeSet attributeSet = new SimpleAttributeSet();
StyleConstants.setFontFamily(attributeSet, SIM_HEI);
StyleConstants.setLineSpacing(attributeSet, 0.5f);
textPane.setParagraphAttributes(attributeSet, true);
JTextArea checkArea = new JTextArea(areaText);
checkArea.setEnabled(false);
centerPanel.add(checkArea, BorderLayout.CENTER);
textPane.setEditable(false);
textPane.setMargin(new Insets(10, 10, 10, 10));
textPane.setText(text);
centerPanel.add(textPane, BorderLayout.CENTER);
UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Plugin_Error_Remind_Not_Deal_With"));
UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Plugin_Error_Remind_Deal_With"));
@ -69,7 +81,7 @@ public class PluginErrorRemindDialog extends JDialog implements ActionListener {
// 按钮
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
buttonPanel.add(cancelButton);
buttonPanel.add(okButton);
@ -80,7 +92,7 @@ public class PluginErrorRemindDialog extends JDialog implements ActionListener {
this.add(topPanel, BorderLayout.NORTH);
this.add(centerPanel, BorderLayout.CENTER);
this.add(buttonPanel, BorderLayout.SOUTH);
this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US) ? 750 : 600, 500));
this.setSize(new Dimension(600, 400));
GUICoreUtils.centerWindow(this);
}

BIN
designer-base/src/main/resources/com/fr/design/images/warnings/icon_WarningIcon_normal.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

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

@ -8,6 +8,8 @@ import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.env.CheckServiceDialog;
import com.fr.env.PluginErrorRemindDialog;
import com.fr.invoke.Reflect;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import org.easymock.EasyMock;
@ -30,7 +32,8 @@ import java.awt.Frame;
EnvChangeEntrance.class,
CheckServiceDialog.class,
DesignerEnvManager.class,
PluginErrorRemindHandler.class})
PluginErrorRemindHandler.class,
WorkContext.class})
public class EnvChangeEntranceTest {
@Test
@ -107,12 +110,15 @@ public class EnvChangeEntranceTest {
}
@Test
public void testPluginErrorRemind() throws Exception {
public void testPluginErrorRemind() {
try {
DesignerWorkspaceInfo selectedEnv = EasyMock.mock(DesignerWorkspaceInfo.class);
EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Remote).once();
EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Local).times(2);
Workspace workspace = EasyMock.mock(Workspace.class);
EasyMock.expect(workspace.isLocal()).andReturn(false).once();
EasyMock.expect(workspace.isLocal()).andReturn(true).times(2);
PowerMock.mockStatic(WorkContext.class);
EasyMock.expect(WorkContext.getCurrent()).andReturn(workspace).anyTimes();
PowerMock.mockStatic(PluginErrorRemindHandler.class);
EasyMock.expect(PluginErrorRemindHandler.pluginErrorContent()).andReturn("").once();
@ -124,17 +130,17 @@ public class EnvChangeEntranceTest {
dialog.setVisible(true);
EasyMock.expectLastCall();
EasyMock.replay(selectedEnv, dialog);
EasyMock.replay(workspace, dialog);
PowerMock.replayAll();
EnvChangeEntrance entrance = EnvChangeEntrance.getInstance();
entrance.pluginErrorRemind(selectedEnv);
entrance.pluginErrorRemind(selectedEnv);
entrance.pluginErrorRemind(selectedEnv);
entrance.pluginErrorRemind();
entrance.pluginErrorRemind();
entrance.pluginErrorRemind();
EasyMock.verify(selectedEnv, dialog);
EasyMock.verify(workspace, dialog);
PowerMock.verifyAll();
} catch (Exception e) {
Assert.fail();

11
designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java

@ -71,7 +71,6 @@ public class DesignerWorkspaceProvider extends Activator {
} catch (Exception e) {
FineLoggerFactory.getLogger().warn("Check Service Failed");
}
EnvChangeEntrance.getInstance().pluginErrorRemind(selectEnv);
}
});
}
@ -88,6 +87,16 @@ public class DesignerWorkspaceProvider extends Activator {
EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner();
}
}
pluginErrorRemind();
}
private void pluginErrorRemind() {
EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener<Null>() {
@Override
public void on(Event event, Null aNull) {
EnvChangeEntrance.getInstance().pluginErrorRemind();
}
});
}
@Override

50
designer-realize/src/test/java/com/fr/start/module/DesignerWorkspaceProviderTest.java

@ -0,0 +1,50 @@
package com.fr.start.module;
import com.fr.design.constants.DesignerLaunchStatus;
import com.fr.event.EventDispatcher;
import com.fr.invoke.Reflect;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
/**
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2021/1/7
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({WorkContext.class})
public class DesignerWorkspaceProviderTest {
@Test
public void testPluginErrorRemind() {
try {
Workspace workspace = EasyMock.mock(Workspace.class);
EasyMock.expect(workspace.isLocal()).andReturn(false).once();
PowerMock.mockStatic(WorkContext.class);
EasyMock.expect(WorkContext.getCurrent()).andReturn(workspace).anyTimes();
EasyMock.replay(workspace);
PowerMock.replayAll();
DesignerWorkspaceProvider provider = new DesignerWorkspaceProvider();
Reflect.on(provider).call("pluginErrorRemind");
EventDispatcher.fire(DesignerLaunchStatus.STARTUP_COMPLETE);
EasyMock.verify(workspace);
PowerMock.verifyAll();
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
}
Loading…
Cancel
Save