diff --git a/platform/platform-impl/src/com/intellij/ide/MacOSApplicationProvider.java b/platform/platform-impl/src/com/intellij/ide/MacOSApplicationProvider.java index dc2af9c91e8e..0516cd6ddf72 100644 --- a/platform/platform-impl/src/com/intellij/ide/MacOSApplicationProvider.java +++ b/platform/platform-impl/src/com/intellij/ide/MacOSApplicationProvider.java @@ -112,28 +112,7 @@ public class MacOSApplicationProvider { List list = event.getFiles(); if (list.isEmpty()) return; submit("OpenFile", () -> { - for (File file : list) { - if (ProjectUtil.openOrImport(file.getAbsolutePath(), project, true) != null) { - LOG.debug("MacMenu: load project from ", file); - IdeaApplication.getInstance().disableProjectLoad(); - return; - } - } - for (File file : list) { - if (file.exists()) { - LOG.debug("MacMenu: open file ", file); - String path = file.getAbsolutePath(); - if (project != null) { - OpenFileAction.openFile(path, project); - } else { - PlatformProjectOpenProcessor processor = PlatformProjectOpenProcessor.getInstanceIfItExists(); - if (processor != null) { - VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(path); - if (virtualFile != null && virtualFile.isValid()) processor.doOpenProject(virtualFile, null, false); - } - } - } - } + tryOpenFileList( project, list, "MacMenu"); }); }); installAutoUpdateMenu(); @@ -208,4 +187,34 @@ public class MacOSApplicationProvider { } } } + + public static boolean tryOpenFileList(Project project, List list, String location) { + for (File file : list) { + if (ProjectUtil.openOrImport(file.getAbsolutePath(), project, true) != null) { + LOG.debug(location + ": load project from ", file); + IdeaApplication.getInstance().disableProjectLoad(); + return true; + } + } + boolean result = false; + for (File file : list) { + if (file.exists()) { + LOG.debug(location + ": open file ", file); + String path = file.getAbsolutePath(); + if (project != null) { + OpenFileAction.openFile(path, project); + result = true; + } else { + PlatformProjectOpenProcessor processor = PlatformProjectOpenProcessor.getInstanceIfItExists(); + if (processor != null) { + VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(path); + if (virtualFile != null && virtualFile.isValid()) { + result |= processor.doOpenProject(virtualFile, null, false) != null; + } + } + } + } + } + return result; + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/FlatWelcomeFrame.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/FlatWelcomeFrame.java index f5e460140078..89cdbe095e7e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/FlatWelcomeFrame.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/FlatWelcomeFrame.java @@ -5,7 +5,9 @@ import com.intellij.diagnostic.IdeMessagePanel; import com.intellij.diagnostic.MessagePool; import com.intellij.icons.AllIcons; import com.intellij.ide.DataManager; +import com.intellij.ide.MacOSApplicationProvider; import com.intellij.ide.RecentProjectsManager; +import com.intellij.ide.dnd.FileCopyPasteUtil; import com.intellij.notification.NotificationType; import com.intellij.notification.impl.IdeNotificationArea; import com.intellij.openapi.Disposable; @@ -259,6 +261,21 @@ public class FlatWelcomeFrame extends JFrame implements IdeFrame, Disposable, Ac } } add(createBody(), BorderLayout.CENTER); + setTransferHandler(new TransferHandler(null) { + @Override + public boolean canImport(TransferSupport support) { + return true; + } + + @Override + public boolean importData(TransferSupport support) { + List list = FileCopyPasteUtil.getFileList(support.getTransferable()); + if (list != null && list.size() > 0) { + return MacOSApplicationProvider.tryOpenFileList(null, list, "WelcomeFrame"); + } + return false; + } + }); TouchbarDataKeys.putActionDescriptor(myTouchbarActions).setShowText(true); }