mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-84080 Ability to execute Mac app bundles as external tools
This commit is contained in:
@@ -34,6 +34,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Tool implements SchemeElement {
|
||||
@@ -300,7 +301,15 @@ public class Tool implements SchemeElement {
|
||||
commandLine.setWorkDirectory(MacroManager.getInstance().expandMacrosInString(workingDir, false, dataContext));
|
||||
exePath = MacroManager.getInstance().expandMacrosInString(exePath, false, dataContext);
|
||||
if (exePath == null) return null;
|
||||
commandLine.setExePath(exePath);
|
||||
|
||||
File exeFile = new File(exePath);
|
||||
if (exeFile.isDirectory() && exeFile.getName().endsWith(".app")) {
|
||||
commandLine.setExePath("open");
|
||||
commandLine.getParametersList().prependAll("-a", exePath);
|
||||
}
|
||||
else {
|
||||
commandLine.setExePath(exePath);
|
||||
}
|
||||
}
|
||||
catch (Macro.ExecutionCancelledException e) {
|
||||
return null;
|
||||
|
||||
@@ -196,7 +196,7 @@ public class ToolEditorDialog extends DialogWrapper {
|
||||
browseCommandButton.addActionListener(
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor();
|
||||
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrExecutableAppDescriptor();
|
||||
VirtualFile file = FileChooser.chooseFile(descriptor, myProject, null);
|
||||
if (file != null) {
|
||||
myTfCommand.setText(file.getPresentableUrl());
|
||||
@@ -463,4 +463,4 @@ public class ToolEditorDialog extends DialogWrapper {
|
||||
if (s.length() == 0) return null;
|
||||
return s.replace('/', File.separatorChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -206,7 +206,7 @@ public class FileChooserDescriptor implements Cloneable {
|
||||
|
||||
@Nullable
|
||||
public final VirtualFile getFileToSelect(VirtualFile file) {
|
||||
if (file.isDirectory() && myChooseFolders) {
|
||||
if (file.isDirectory() && (myChooseFolders || isFileSelectable(file))) {
|
||||
return file;
|
||||
}
|
||||
boolean isJar = file.getFileType() == FileTypes.ARCHIVE;
|
||||
|
||||
+16
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.fileChooser;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.UIBundle;
|
||||
|
||||
@@ -39,6 +40,21 @@ public class FileChooserDescriptorFactory {
|
||||
return new FileChooserDescriptor(true, false, false, false, false, false);
|
||||
}
|
||||
|
||||
public static FileChooserDescriptor createSingleFileOrExecutableAppDescriptor() {
|
||||
return new FileChooserDescriptor(true, false, false, false, false, false) {
|
||||
@Override
|
||||
public boolean isFileSelectable(VirtualFile file) {
|
||||
if (super.isFileSelectable(file)) return true;
|
||||
|
||||
if (SystemInfo.isMac && file.isDirectory() && "app".equals(file.getExtension())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static FileChooserDescriptor createSingleLocalFileDescriptor() {
|
||||
return new FileChooserDescriptor(true, true, true, true, false, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user