use project open processor if no project exists

#IDEA-129532 fixed
This commit is contained in:
Dennis Ushakov
2016-08-26 18:40:30 +03:00
parent 7b22b0d763
commit 47e4b067c3
@@ -32,7 +32,10 @@ import com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.platform.PlatformProjectOpenProcessor;
import com.intellij.ui.mac.foundation.Foundation;
import com.intellij.ui.mac.foundation.ID;
import com.sun.jna.Callback;
@@ -40,7 +43,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.Component;
import java.awt.*;
import java.awt.color.ColorSpace;
import java.awt.color.ICC_ColorSpace;
import java.awt.color.ICC_Profile;
@@ -143,11 +146,18 @@ public class MacOSApplicationProvider implements ApplicationComponent {
return;
}
}
if (project != null) {
for (File file : list) {
if (file.exists()) {
LOG.debug("MacMenu: open file ", file);
OpenFileAction.openFile(file.getAbsolutePath(), project);
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);
}
}
}
}
@@ -204,10 +214,7 @@ public class MacOSApplicationProvider implements ApplicationComponent {
}
else {
Component component = IdeFocusManager.getGlobalInstance().getFocusOwner();
if (component == null) {
LOG.debug("MacMenu: no focused component");
}
else if (IdeKeyEventDispatcher.isModalContext(component)) {
if (component != null && IdeKeyEventDispatcher.isModalContext(component)) {
LOG.debug("MacMenu: component in modal context");
}
else {