use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class CompileQrcAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
VirtualFile[] vFiles = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
assert vFiles != null;
Module module = e.getData(LangDataKeys.MODULE);
String path = QtFileType.findQtTool(module, "pyrcc4");
if (path == null) {
path = QtFileType.findQtTool(module, "pyside-rcc");
}
if (path == null) {
Messages.showErrorDialog(project, "Could not find pyrcc4 or pyside-rcc for selected Python interpreter", "Compile .qrc file");
return;
}
CompileQrcDialog dialog = new CompileQrcDialog(project, vFiles);
dialog.show();
if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
return;
}
GeneralCommandLine cmdLine = new GeneralCommandLine(path, "-o", dialog.getOutputPath());
for (VirtualFile vFile : vFiles) {
cmdLine.addParameter(vFile.getPath());
}
try {
ProcessHandler process = new OSProcessHandler(cmdLine);
ProcessTerminatedListener.attach(process);
new RunContentExecutor(project, process).withTitle("Compile .qrc").run();
} catch (ExecutionException ex) {
Messages.showErrorDialog(project, "Error running " + path + ": " + ex.getMessage(), "Compile .qrc file");
}
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class PyDirectoryIconProvider method isSpecialDirectory.
private static boolean isSpecialDirectory(@NotNull PsiDirectory directory) {
final VirtualFile vFile = directory.getVirtualFile();
if (FileIndexFacade.getInstance(directory.getProject()).isExcludedFile(vFile)) {
return true;
}
final Module module = ModuleUtilCore.findModuleForPsiElement(directory);
return module == null || PyUtil.getSourceRoots(module).contains(vFile);
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class RestLanguageSubstitutor method getLanguage.
@Override
public Language getLanguage(@NotNull final VirtualFile vFile, @NotNull final Project project) {
final Module module = ModuleUtilCore.findModuleForFile(vFile, project);
if (module == null)
return null;
boolean txtIsRst = ReSTService.getInstance(module).txtIsRst();
if (txtIsRst)
return RestLanguage.INSTANCE;
return null;
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class RestPythonUtil method updateSphinxQuickStartRequiredAction.
public static Presentation updateSphinxQuickStartRequiredAction(final AnActionEvent e) {
final Presentation presentation = e.getPresentation();
final Project project = e.getData(CommonDataKeys.PROJECT);
if (project != null) {
Module module = e.getData(LangDataKeys.MODULE);
if (module == null) {
Module[] modules = ModuleManager.getInstance(project).getModules();
module = modules.length == 0 ? null : modules[0];
}
if (module != null) {
final Sdk sdk = PythonSdkType.findPythonSdk(module);
if (sdk != null) {
final List<PyPackage> packages = PyPackageManager.getInstance(sdk).getPackages();
final PyPackage sphinx = packages != null ? PyPackageUtil.findPackage(packages, "Sphinx") : null;
presentation.setEnabled(sphinx != null);
}
}
}
return presentation;
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class SphinxConfigurationProducer method createConfigurationByElement.
protected RunnerAndConfigurationSettings createConfigurationByElement(final Location location, final ConfigurationContext context) {
PsiElement element = location.getPsiElement();
if (!(element instanceof PsiDirectory))
return null;
mySourceFile = (PsiDirectory) element;
boolean hasRstFile = false;
boolean hasConf = false;
for (PsiFile file : mySourceFile.getFiles()) {
if ("conf.py".equals(file.getName()))
hasConf = true;
if (file instanceof RestFile) {
hasRstFile = true;
}
}
if (!hasRstFile || !hasConf)
return null;
final Project project = mySourceFile.getProject();
RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(project, context);
SphinxRunConfiguration configuration = (SphinxRunConfiguration) settings.getConfiguration();
final VirtualFile vFile = mySourceFile.getVirtualFile();
configuration.setInputFile(vFile.getPath());
configuration.setName(((PsiDirectory) element).getName());
if (configuration.getTask().isEmpty())
configuration.setTask("html");
final VirtualFile parent = vFile.getParent();
if (parent != null) {
configuration.setWorkingDirectory(parent.getPath());
}
configuration.setName(configuration.suggestedName());
Module module = ModuleUtil.findModuleForPsiElement(element);
if (module != null) {
configuration.setUseModuleSdk(true);
configuration.setModule(module);
}
return settings;
}
Aggregations