Search in sources :

Example 71 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class DataBindingWizardAction method actionPerformed.

public void actionPerformed(final AnActionEvent e) {
    final Project project;
    final VirtualFile formFile;
    GuiEditor editor = FormEditingUtil.getActiveEditor(e.getDataContext());
    if (editor == null) {
        return;
    }
    project = editor.getProject();
    formFile = editor.getFile();
    try {
        final WizardData wizardData = new WizardData(project, formFile);
        final Module module = ModuleUtilCore.findModuleForFile(formFile, wizardData.myProject);
        LOG.assertTrue(module != null);
        final LwRootContainer[] rootContainer = new LwRootContainer[1];
        Generator.exposeForm(wizardData.myProject, formFile, rootContainer);
        final String classToBind = rootContainer[0].getClassToBind();
        if (classToBind == null) {
            Messages.showInfoMessage(project, UIDesignerBundle.message("info.form.not.bound"), UIDesignerBundle.message("title.data.binding.wizard"));
            return;
        }
        final PsiClass boundClass = FormEditingUtil.findClassToBind(module, classToBind);
        if (boundClass == null) {
            Messages.showErrorDialog(project, UIDesignerBundle.message("error.bound.to.not.found.class", classToBind), UIDesignerBundle.message("title.data.binding.wizard"));
            return;
        }
        Generator.prepareWizardData(wizardData, boundClass);
        if (!hasBinding(rootContainer[0])) {
            Messages.showInfoMessage(project, UIDesignerBundle.message("info.no.bound.components"), UIDesignerBundle.message("title.data.binding.wizard"));
            return;
        }
        if (!wizardData.myBindToNewBean) {
            final String[] variants = new String[] { UIDesignerBundle.message("action.alter.data.binding"), UIDesignerBundle.message("action.bind.to.another.bean"), CommonBundle.getCancelButtonText() };
            final int result = Messages.showYesNoCancelDialog(project, UIDesignerBundle.message("info.data.binding.regenerate", wizardData.myBeanClass.getQualifiedName()), UIDesignerBundle.message("title.data.binding"), variants[0], variants[1], variants[2], Messages.getQuestionIcon());
            if (result == Messages.YES) {
            // do nothing here
            } else if (result == Messages.NO) {
                wizardData.myBindToNewBean = true;
            } else {
                return;
            }
        }
        final DataBindingWizard wizard = new DataBindingWizard(project, wizardData);
        wizard.show();
    } catch (Generator.MyException exc) {
        Messages.showErrorDialog(project, exc.getMessage(), CommonBundle.getErrorTitle());
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiClass(com.intellij.psi.PsiClass) WizardData(com.intellij.uiDesigner.wizard.WizardData) GuiEditor(com.intellij.uiDesigner.designSurface.GuiEditor) LwRootContainer(com.intellij.uiDesigner.lw.LwRootContainer) Project(com.intellij.openapi.project.Project) DataBindingWizard(com.intellij.uiDesigner.wizard.DataBindingWizard) Module(com.intellij.openapi.module.Module) Generator(com.intellij.uiDesigner.wizard.Generator)

Example 72 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class ResourceBundleFileReference method resolve.

public PsiElement resolve() {
    final Project project = myFile.getProject();
    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
    final VirtualFile formVirtualFile = myFile.getVirtualFile();
    if (formVirtualFile == null) {
        return null;
    }
    final Module module = fileIndex.getModuleForFile(formVirtualFile);
    if (module == null) {
        return null;
    }
    PropertiesFile propertiesFile = PropertiesUtilBase.getPropertiesFile(getRangeText(), module, null);
    return propertiesFile == null ? null : propertiesFile.getContainingFile();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) PropertiesFile(com.intellij.lang.properties.psi.PropertiesFile) Module(com.intellij.openapi.module.Module)

Example 73 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class EduCustomCourseModuleBuilder method createModule.

@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
    Module baseModule = super.createModule(moduleModel);
    if (mySelectedCourse != null) {
        String type = mySelectedCourse.getType();
        String languageName = type.substring("pycharm ".length());
        Language language = Language.findLanguageByID(languageName);
        if (language != null) {
            EduCourseConfigurator configurator = EduCourseConfigurator.INSTANCE.forLanguage(language);
            if (configurator != null) {
                configurator.createCourseFromCourseInfo(moduleModel, baseModule.getProject(), myGenerator, mySelectedCourse, getModuleFileDirectory());
            }
        }
    }
    return baseModule;
}
Also used : Language(com.intellij.lang.Language) EduCourseConfigurator(com.jetbrains.edu.learning.intellij.EduCourseConfigurator) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Example 74 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class CreateSetupPyAction method update.

@Override
public void update(AnActionEvent e) {
    final Module module = e.getData(LangDataKeys.MODULE);
    e.getPresentation().setEnabled(module != null && !PyPackageUtil.hasSetupPy(module));
}
Also used : Module(com.intellij.openapi.module.Module)

Example 75 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class SetupTaskChooserAction method update.

@Override
public void update(AnActionEvent e) {
    final Module module = e.getData(LangDataKeys.MODULE);
    e.getPresentation().setEnabled(module != null && PyPackageUtil.hasSetupPy(module) && PythonSdkType.findPythonSdk(module) != null);
}
Also used : Module(com.intellij.openapi.module.Module)

Aggregations

Module (com.intellij.openapi.module.Module)1893 VirtualFile (com.intellij.openapi.vfs.VirtualFile)585 Project (com.intellij.openapi.project.Project)379 NotNull (org.jetbrains.annotations.NotNull)330 Nullable (org.jetbrains.annotations.Nullable)267 File (java.io.File)185 PsiFile (com.intellij.psi.PsiFile)147 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)134 ArrayList (java.util.ArrayList)118 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)112 Sdk (com.intellij.openapi.projectRoots.Sdk)95 PsiElement (com.intellij.psi.PsiElement)89 PsiDirectory (com.intellij.psi.PsiDirectory)77 ModuleManager (com.intellij.openapi.module.ModuleManager)65 PsiClass (com.intellij.psi.PsiClass)65 IOException (java.io.IOException)61 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)57 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)57 List (java.util.List)57 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)51