Browse Source

REPORT-28099

feature/big-screen
hades 5 years ago
parent
commit
0ebfd70fc0
  1. 28
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

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

@ -109,6 +109,9 @@ import java.awt.event.WindowListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@ -316,6 +319,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
// window close listener.
this.addWindowListeners(getFrameListeners());
addMacOsListener();
this.addComponentListener(new ComponentAdapter() {
@Override
@ -523,6 +528,29 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
}
private void addMacOsListener() {
if (OperatingSystem.isMacos()) {
try {
Class app = Class.forName("com.apple.eawt.Application");
Class handler = Class.forName("com.apple.eawt.QuitHandler");
Object instance = Proxy.newProxyInstance(handler.getClassLoader(), new Class[]{handler},
new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method,
Object[] args) throws Throwable {
if ("handleQuitRequestWith".equals(method.getName())) {
DesignerFrame.this.exit();
}
return null;
}
});
Reflect.on(Reflect.on(app).call("getApplication").get()).call("setQuitHandler", instance);
} catch (ClassNotFoundException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
protected ArrayList<WindowListener> getFrameListeners() {
ArrayList<WindowListener> arrayList = new ArrayList<>();

Loading…
Cancel
Save