Search in sources :

Example 1 with CustomProtocolHandler

use of com.intellij.ui.CustomProtocolHandler in project intellij-community by JetBrains.

the class MacMainFrameDecorator method createProtocolHandler.

private static void createProtocolHandler() {
    if (ourProtocolHandler == null) {
        // install uri handler
        final ID mainBundle = invoke("NSBundle", "mainBundle");
        final ID urlTypes = invoke(mainBundle, "objectForInfoDictionaryKey:", Foundation.nsString("CFBundleURLTypes"));
        final ApplicationInfoEx info = ApplicationInfoImpl.getShadowInstance();
        final BuildNumber build = info != null ? info.getBuild() : null;
        if (urlTypes.equals(ID.NIL) && build != null && !build.isSnapshot()) {
            LOG.warn("no url bundle present. \n" + "To use platform protocol handler to open external links specify required protocols in the mac app layout section of the build file\n" + "Example: args.urlSchemes = [\"your-protocol\"] will handle following links: your-protocol://open?file=file&line=line");
            return;
        }
        ourProtocolHandler = new CustomProtocolHandler();
        Application.getApplication().setOpenURIHandler(new OpenURIHandler() {

            @Override
            public void openURI(AppEvent.OpenURIEvent event) {
                ourProtocolHandler.openLink(event.getURI());
            }
        });
    }
}
Also used : ApplicationInfoEx(com.intellij.openapi.application.ex.ApplicationInfoEx) BuildNumber(com.intellij.openapi.util.BuildNumber) CustomProtocolHandler(com.intellij.ui.CustomProtocolHandler) ID(com.intellij.ui.mac.foundation.ID)

Aggregations

ApplicationInfoEx (com.intellij.openapi.application.ex.ApplicationInfoEx)1 BuildNumber (com.intellij.openapi.util.BuildNumber)1 CustomProtocolHandler (com.intellij.ui.CustomProtocolHandler)1 ID (com.intellij.ui.mac.foundation.ID)1