Browse Source

Pull request #4805: REPORT-54643 回退

Merge in DESIGN/design from ~HADES/design:persist/10.0 to persist/10.0

* commit 'f4138e5c220569d0bdd2e91e9fa2cb2fa6a44799':
  REPORT-54643  回退
persist/10.0
Hades 3 years ago
parent
commit
7dbcad101c
  1. 5
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  2. 84
      designer-base/src/main/java/com/fr/design/mainframe/SafeWindowListener.java

5
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -535,11 +535,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
} }
@Override
public synchronized void addWindowListener(WindowListener l) {
super.addWindowListener(new SafeWindowListener(l));
}
private void addMacOsListener() { private void addMacOsListener() {
OSSupportCenter.buildAction(new MacOsAddListenerAction(), SupportOSImpl.DOCK_QUIT); OSSupportCenter.buildAction(new MacOsAddListenerAction(), SupportOSImpl.DOCK_QUIT);
} }

84
designer-base/src/main/java/com/fr/design/mainframe/SafeWindowListener.java

@ -1,84 +0,0 @@
package com.fr.design.mainframe;
import com.fr.log.FineLoggerFactory;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
/**
* 保证监听运行出错也不影响其他功能正常使用
*
* @author hades
* @version 10.0
* Created by hades on 2021/6/30
*/
public class SafeWindowListener implements WindowListener {
private final WindowListener windowListener;
public SafeWindowListener(WindowListener windowListener) {
this.windowListener = windowListener;
}
@Override
public void windowOpened(WindowEvent e) {
try {
windowListener.windowOpened(e);
} catch (Throwable throwable) {
FineLoggerFactory.getLogger().debug(throwable.getMessage(), throwable);
}
}
@Override
public void windowClosing(WindowEvent e) {
try {
windowListener.windowClosing(e);
} catch (Throwable throwable) {
FineLoggerFactory.getLogger().debug(throwable.getMessage(), throwable);
}
}
@Override
public void windowClosed(WindowEvent e) {
try {
windowListener.windowClosed(e);
} catch (Throwable throwable) {
FineLoggerFactory.getLogger().debug(throwable.getMessage(), throwable);
}
}
@Override
public void windowIconified(WindowEvent e) {
try {
windowListener.windowIconified(e);
} catch (Throwable throwable) {
FineLoggerFactory.getLogger().debug(throwable.getMessage(), throwable);
}
}
@Override
public void windowDeiconified(WindowEvent e) {
try {
windowListener.windowDeiconified(e);
} catch (Throwable throwable) {
FineLoggerFactory.getLogger().debug(throwable.getMessage(), throwable);
}
}
@Override
public void windowActivated(WindowEvent e) {
try {
windowListener.windowActivated(e);
} catch (Throwable throwable) {
FineLoggerFactory.getLogger().debug(throwable.getMessage(), throwable);
}
}
@Override
public void windowDeactivated(WindowEvent e) {
try {
windowListener.windowDeactivated(e);
} catch (Throwable throwable) {
FineLoggerFactory.getLogger().debug(throwable.getMessage(), throwable);
}
}
}
Loading…
Cancel
Save