forked from fanruan/design
Browse Source
* commit 'a5943c127935fe9ff4a72775dd8230739dde5b99': fix 调整 fix 无用import fix 适配 REPORT-28099feature/big-screen
3 changed files with 58 additions and 0 deletions
@ -0,0 +1,41 @@ |
|||||||
|
package com.fr.design.os.impl; |
||||||
|
|
||||||
|
import com.fr.design.mainframe.DesignerFrame; |
||||||
|
import com.fr.invoke.Reflect; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.stable.os.support.OSBasedAction; |
||||||
|
|
||||||
|
import java.lang.reflect.InvocationHandler; |
||||||
|
import java.lang.reflect.Method; |
||||||
|
import java.lang.reflect.Proxy; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/3/13 |
||||||
|
*/ |
||||||
|
public class MacOsAddListenerAction implements OSBasedAction { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void execute(final Object... objects) { |
||||||
|
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 designerFrame = (DesignerFrame) objects[0]; |
||||||
|
designerFrame.exit(); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
}); |
||||||
|
Reflect.on(Reflect.on(app).call("getApplication").get()).call("setQuitHandler", instance); |
||||||
|
} catch (ClassNotFoundException e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue