com.intellij.openapi.module.ModuleType Java Examples

The following examples show how to use com.intellij.openapi.module.ModuleType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RouteModuleRendererFactory.java    From railways with MIT License 6 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    Component component = super.getListCellRendererComponent(list,
            value, index, isSelected, cellHasFocus);

    // Set module name and icon
    Module module = ((Route)value).getModule();
    setText(module.getName());
    setIcon(ModuleType.get(module).getIcon());

    // Set additional rendering properties.
    // To preserve consistent look and feel, the implementation is taken from
    // com.intellij.ide.util.PsiElementModuleRenderer.customizeCellRenderer()
    setBorder(BorderFactory.createEmptyBorder(0, 0, 0, UIUtil.getListCellHPadding()));
    setHorizontalTextPosition(SwingConstants.LEFT);
    setBackground(UIUtil.getListBackground(isSelected, cellHasFocus));
    setForeground(isSelected ? UIUtil.getListForeground(true, cellHasFocus) : UIUtil.getInactiveTextColor());

    return component;
}
 
Example #2
Source File: ModuleEditorImpl.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
public Module createModule(String moduleName, ModuleType moduleType) {
  Module module = moduleModel.findModuleByName(moduleName);
  if (module == null) {
    File imlFile = new File(imlDirectory, moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);
    removeImlFile(imlFile);
    module = moduleModel.newModule(imlFile.getPath(), moduleType.getId());
    module.setOption(EXTERNAL_SYSTEM_ID_KEY, EXTERNAL_SYSTEM_ID_VALUE);
  }
  module.setOption(Module.ELEMENT_TYPE, moduleType.getId());

  ModifiableRootModel modifiableModel =
      ModuleRootManager.getInstance(module).getModifiableModel();
  modules.put(module.getName(), modifiableModel);
  modifiableModel.clear();
  modifiableModel.inheritSdk();
  CompilerModuleExtension compilerSettings =
      modifiableModel.getModuleExtension(CompilerModuleExtension.class);
  if (compilerSettings != null) {
    compilerSettings.inheritCompilerOutputPath(false);
  }

  return module;
}
 
Example #3
Source File: DWCleanAction.java    From intellij-demandware with MIT License 6 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
    Project project = e.getProject();

    if (project != null) {
        for (Module module : ModuleManager.getInstance(project).getModules()) {
            if (ModuleType.get(module) instanceof DWModuleType) {
                ModuleServiceManager.getService(module, DWServerConnection.class);
                ProgressManager.getInstance().run(
                        new DWCleanTask(project, module, "Cleaning cartridges...", true, PerformInBackgroundOption.ALWAYS_BACKGROUND)
                );

            }
        }
    }

}
 
Example #4
Source File: DojoToolkitModuleEditorProvider.java    From needsmoredojo with Apache License 2.0 6 votes vote down vote up
@Override
public ModuleConfigurationEditor[] createEditors(ModuleConfigurationState moduleConfigurationState) {
    final Module module = moduleConfigurationState.getRootModel().getModule();
    if (ModuleType.get(module) != DojoToolkitModuleType.getInstance()) return ModuleConfigurationEditor.EMPTY;

    final DefaultModuleConfigurationEditorFactory editorFactory = DefaultModuleConfigurationEditorFactory.getInstance();
    List<ModuleConfigurationEditor> editors = new ArrayList<ModuleConfigurationEditor>();
    //editors.add(editorFactory.createModuleContentRootsEditor(moduleConfigurationState));

    for(Module theModule : ModuleManager.getInstance(moduleConfigurationState.getProject()).getModules())
    {
        ModuleType theType = ModuleType.get(theModule);

        int i=0;
    }

    return editors.toArray(new ModuleConfigurationEditor[editors.size()]);
}
 
Example #5
Source File: GaugeModuleConfigurationProvider.java    From Intellij-Plugin with Apache License 2.0 6 votes vote down vote up
@Override
public ModuleConfigurationEditor[] createEditors(ModuleConfigurationState state) {
    final Module module = state.getRootModel().getModule();

    final ModuleType moduleType = ModuleType.get(module);

    if (!(moduleType instanceof GaugeModuleType)) {
        return ModuleConfigurationEditor.EMPTY;
    }

    final DefaultModuleConfigurationEditorFactory editorFactory = DefaultModuleConfigurationEditorFactory.getInstance();
    List<ModuleConfigurationEditor> editors = new ArrayList<>();
    editors.add(editorFactory.createModuleContentRootsEditor(state));
    editors.add(editorFactory.createOutputEditor(state));
    editors.add(editorFactory.createClasspathEditor(state));
    return editors.toArray(new ModuleConfigurationEditor[editors.size()]);
}
 
Example #6
Source File: BlazeCLionSyncPlugin.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public ModuleType getWorkspaceModuleType(WorkspaceType workspaceType) {
  if (workspaceType == WorkspaceType.C) {
    return BlazeCppModuleType.getInstance();
  }
  return null;
}
 
Example #7
Source File: CppModuleConfigurationEditorProvider.java    From CppTools with Apache License 2.0 5 votes vote down vote up
public ModuleConfigurationEditor[] createEditors(ModuleConfigurationState state) {
  final Module module = state.getRootModel().getModule();
  if (ModuleType.get(module) != CppModuleType.getInstance()) return new ModuleConfigurationEditor[0];

  ModifiableRootModel rootModel = state.getRootModel();

  DefaultModuleConfigurationEditorFactory defaultModuleConfigurationEditorFactory = DefaultModuleConfigurationEditorFactory.getInstance();
  return new ModuleConfigurationEditor[] {
    defaultModuleConfigurationEditorFactory.createModuleContentRootsEditor(state),
    defaultModuleConfigurationEditorFactory.createClasspathEditor(state),
  };
}
 
Example #8
Source File: CppCompiler.java    From CppTools with Apache License 2.0 5 votes vote down vote up
public boolean validateConfiguration(CompileScope compileScope) {
  EnvironmentFacade facade = EnvironmentFacade.getInstance();

  for(Module module:compileScope.getAffectedModules()) {
    if (ModuleType.get(module) == CppModuleType.getInstance()) {
      Sdk sdk = ModuleRootManager.getInstance(module).getSdk();

      if (!(sdk.getSdkType() == CppSdkType.getInstance())) {
        Messages.showMessageDialog(module.getProject(), "C/Cpp module type is not configured", "C/C++ compiler problem", Messages.getErrorIcon());
        return false;
      }
    }
  }
  return true;
}
 
Example #9
Source File: OCamlDefaultModuleEditorsProvider.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public ModuleConfigurationEditor[] createEditors(@NotNull ModuleConfigurationState state) {
    Module module = state.getRootModel().getModule();
    if (ModuleType.get(module) instanceof OCamlModuleType) {
        return new ModuleConfigurationEditor[]{
                new OCamlContentEntriesEditor(module.getName(), state)
        };
    }

    return ModuleConfigurationEditor.EMPTY;
}
 
Example #10
Source File: CppCompiler.java    From CppTools with Apache License 2.0 5 votes vote down vote up
@NotNull
public ProcessingItem[] getProcessingItems(final CompileContext compileContext) {
  final List<ProcessingItem> processingItems = new ArrayList<ProcessingItem>();
  boolean doneSave = false;

  Module[] affectedModules = ApplicationManager.getApplication().runReadAction(new Computable<Module[]>() {
    public Module[] compute() {
      return compileContext.getCompileScope().getAffectedModules();
    }
  });

  for(Module module: affectedModules) {
    Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
    if (ModuleType.get(module) == CppModuleType.getInstance() ||
       (sdk != null && sdk.getSdkType() == CppSdkType.getInstance())) {
      processingItems.add(new MyProcessingItem(module));

      if (!doneSave) {
        BuildState.saveDocuments();
        doneSave = true;
      }

      VirtualFile moduleFile = module.getModuleFile();
      if (moduleFile == null) {
        BuildState.saveAll();
      }
    }
  }
  return processingItems.toArray(new ProcessingItem[processingItems.size()]);
}
 
Example #11
Source File: MavenTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
protected Module createModule(final String name, final ModuleType type) {
  try {
    return WriteCommandAction.writeCommandAction(myProject).compute(() -> {
      VirtualFile f = createProjectSubFile(name + "/" + name + ".iml");
      Module module = ModuleManager.getInstance(myProject).newModule(f.getPath(), type.getId());
      PsiTestUtil.addContentRoot(module, f.getParent());
      return module;
    });
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
Example #12
Source File: ExternalSystemTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
protected Module createModule(final String name, final ModuleType type) {
  try {
    return WriteCommandAction.writeCommandAction(myProject).compute(() -> {
      VirtualFile f = createProjectSubFile(name + "/" + name + ".iml");
      Module module = ModuleManager.getInstance(myProject).newModule(f.getPath(), type.getId());
      PsiTestUtil.addContentRoot(module, f.getParent());
      return module;
    });
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
Example #13
Source File: HaskellModuleConfigurationEditor.java    From intellij-haskforce with Apache License 2.0 5 votes vote down vote up
public ModuleConfigurationEditor[] createEditors(ModuleConfigurationState state) {
    Module module = state.getRootModel().getModule();
    if (!(ModuleType.get(module) instanceof HaskellModuleType)) {
        return ModuleConfigurationEditor.EMPTY;
    }
    return new ModuleConfigurationEditor[]{
            new JavaContentEntriesEditor(module.getName(), state),
            // new CabalFilesEditor(state),
            new ClasspathEditor(state),
    };
}
 
Example #14
Source File: RoutesView.java    From railways with MIT License 5 votes vote down vote up
public void addModulePane(Module module) {
    // Skip if RoutesView is not initialized or if added module is not
    // Rails application.
    RailsApp railsApp = RailsApp.fromModule(module);
    if ((myContentManager == null) || railsApp == null)
        return;

    // Register content, so we'll have a combo-box instead tool window
    // title, and each item will represent a module.
    String contentTitle = module.getName();
    Content content = myContentManager.getFactory().createContent(getComponent(),
            contentTitle, false);
    content.setTabName(contentTitle);
    content.setIcon(ModuleType.get(module).getIcon());

    // Set tool window icon to be the same as selected module icon
    content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE);
    myContentManager.addContent(content);

    // Bind content with pane for further use
    RoutesViewPane pane = new RoutesViewPane(railsApp, myToolWindow, content);
    myPanes.add(pane);

    // Register contributor
    ChooseByRouteRegistry.getInstance(myProject)
            .addContributorFor(pane.getRoutesManager());

    // Subscribe to RoutesManager events.
    pane.getRoutesManager().addListener(new MyRoutesManagerListener());

    // And select pane if it's the first one.
    if (myPanes.size() == 1)
        setCurrentPane(pane);
}
 
Example #15
Source File: BlazeGoSyncPlugin.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public ModuleType getWorkspaceModuleType(WorkspaceType workspaceType) {
  return workspaceType == WorkspaceType.GO
      ? ModuleTypeManager.getInstance().getDefaultModuleType()
      : null;
}
 
Example #16
Source File: BlazeJavascriptSyncPlugin.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public ModuleType getWorkspaceModuleType(WorkspaceType workspaceType) {
  if (workspaceType == WorkspaceType.JAVASCRIPT) {
    return WebModuleType.getInstance();
  }
  return null;
}
 
Example #17
Source File: BlazeAndroidSyncPlugin.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public ModuleType getWorkspaceModuleType(WorkspaceType workspaceType) {
  if (workspaceType == WorkspaceType.ANDROID) {
    return StdModuleTypes.JAVA;
  }
  return null;
}
 
Example #18
Source File: HaxeModuleConfigurationEditorProvider.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
public ModuleConfigurationEditor[] createEditors(final ModuleConfigurationState state) {
  final Module module = state.getRootModel().getModule();
  if (ModuleType.get(module) != HaxeModuleType.getInstance()) {
    return ModuleConfigurationEditor.EMPTY;
  }
  return new ModuleConfigurationEditor[]{
    new CommonContentEntriesEditor(module.getName(), state, JavaSourceRootType.SOURCE, JavaSourceRootType.TEST_SOURCE),
    new ClasspathEditor(state),
    new HaxeModuleConfigurationEditor(state)
  };
}
 
Example #19
Source File: BlazePythonSyncPlugin.java    From intellij with Apache License 2.0 5 votes vote down vote up
private static void updatePythonFacet(
    Project project,
    BlazeContext context,
    BlazeProjectData blazeProjectData,
    Module workspaceModule,
    ModifiableRootModel workspaceModifiableModel) {
  if (!PythonFacetUtil.usePythonFacets()) {
    return;
  }
  if (!blazeProjectData.getWorkspaceLanguageSettings().isLanguageActive(LanguageClass.PYTHON)
      || blazeProjectData.getWorkspaceLanguageSettings().isWorkspaceType(WorkspaceType.PYTHON)) {
    removeFacet(workspaceModule);
    return;
  }
  if (ModuleType.get(workspaceModule) instanceof PythonModuleTypeBase) {
    return;
  }
  LibraryContributingFacet<?> pythonFacet =
      getOrCreatePythonFacet(project, context, workspaceModule, blazeProjectData);
  if (pythonFacet == null) {
    return;
  }
  Library pythonLib = getFacetLibrary(pythonFacet);
  if (pythonLib != null) {
    workspaceModifiableModel.addLibraryEntry(pythonLib);
  }
}
 
Example #20
Source File: ProjectUpdateSyncTask.java    From intellij with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a module that includes the user's data directory.
 *
 * <p>This is useful to be able to edit the project view without IntelliJ complaining it's outside
 * the project.
 */
private void createProjectDataDirectoryModule(
    ModuleEditor moduleEditor, File projectDataDirectory, ModuleType moduleType) {
  Module module = moduleEditor.createModule(".project-data-dir", moduleType);
  ModifiableRootModel modifiableModel = moduleEditor.editModule(module);
  ContentEntry rootContentEntry =
      modifiableModel.addContentEntry(pathToUrl(projectDataDirectory));
  rootContentEntry.addExcludeFolder(pathToUrl(new File(projectDataDirectory, ".idea")));
  rootContentEntry.addExcludeFolder(
      pathToUrl(BlazeDataStorage.getProjectDataDir(importSettings)));
}
 
Example #21
Source File: IntellijPluginSyncPlugin.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public ModuleType getWorkspaceModuleType(WorkspaceType workspaceType) {
  if (workspaceType == WorkspaceType.INTELLIJ_PLUGIN) {
    return StdModuleTypes.JAVA;
  }
  return null;
}
 
Example #22
Source File: BlazeJavaSyncPlugin.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public ModuleType getWorkspaceModuleType(WorkspaceType workspaceType) {
  if (workspaceType == WorkspaceType.JAVA) {
    return StdModuleTypes.JAVA;
  }
  return null;
}
 
Example #23
Source File: HaxeCompiler.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
private static List<Module> getModulesToCompile(final CompileScope scope /*, final Project project */) {
  final List<Module> result = new ArrayList<Module>();
  for (final Module module : scope.getAffectedModules()) {
    if (ModuleType.get(module) != HaxeModuleType.getInstance()) continue;
    result.add(module);
    /*
    boolean skipBuilding = false; // default: always build
    //-- are any changes since last build
    if (changeSetMap.get(module) != null) { // was built at least once, in past ...
      final Set<String> latestChangeSet = new HashSet<String>();
      Collection<VirtualFile> vFileCollection = FileTypeIndex
        .getFiles(HaxeFileType.HAXE_FILE_TYPE, module.getModuleWithDependenciesScope());
      final VirtualFile[] virtualFiles = vFileCollection.toArray(new VirtualFile[0]);
      for (VirtualFile file : virtualFiles) {
        final FileStatus fileStatus = FileStatusManager.getInstance(project).getStatus(file);
        if (fileStatus.equals(FileStatus.NOT_CHANGED) || fileStatus.equals(FileStatus.UNKNOWN)) continue;
        latestChangeSet.add(file.getPath());
      }
      skipBuilding = latestChangeSet.equals(changeSetMap.get(module));
      changeSetMap.put(module, latestChangeSet);
    }
    else {
      changeSetMap.put(module, new HashSet<String>());
    }
    skipBuildMap.put(module, new Boolean(skipBuilding));
    if (! skipBuilding) {
      result.add(module);
    }
    */
  }
  return result;
}
 
Example #24
Source File: BlazePythonSyncPlugin.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public ModuleType getWorkspaceModuleType(WorkspaceType workspaceType) {
  if (workspaceType == WorkspaceType.PYTHON && supportsPythonWorkspaceType()) {
    return PythonModuleTypeBase.getInstance();
  }
  return null;
}
 
Example #25
Source File: DWBulkFileListener.java    From intellij-demandware with MIT License 4 votes vote down vote up
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
    Project[] projects = ProjectManager.getInstance().getOpenProjects();

    for (VFileEvent event : events) {
        VirtualFile eventFile = event.getFile();

        if (eventFile != null && !eventFile.isDirectory()) {
            for (Project project : projects) {
                Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(eventFile);

                if (module != null) {
                    ModuleType CurrentModuleType = ModuleType.get(module);

                    // Bail out if auto uploads are not enabled.
                    if (!DWSettingsProvider.getInstance(module).getAutoUploadEnabled()) {
                        return;
                    }

                    if (CurrentModuleType instanceof DWModuleType) {
                        for (VirtualFile sourceRoot : ModuleRootManager.getInstance(module).getSourceRoots()) {
                            if (eventFile.getPath().contains(sourceRoot.getPath())) {
                                ProgressManager.getInstance().run(
                                    new DWUpdateFileTask(
                                        project,
                                        module,
                                        "Syncing files to: " + DWSettingsProvider.getInstance(module).getHostname(),
                                        true,
                                        PerformInBackgroundOption.ALWAYS_BACKGROUND,
                                        sourceRoot.getPath(),
                                        eventFile.getPath()
                                    )
                                );
                            }
                        }
                    }
                }
            }
        }
    }
}
 
Example #26
Source File: CppModuleBuilder.java    From CppTools with Apache License 2.0 4 votes vote down vote up
public ModuleType getModuleType() {
  return CppModuleType.getInstance();
}
 
Example #27
Source File: DemoModuleWizardStep.java    From intellij-sdk-docs with Apache License 2.0 4 votes vote down vote up
public ModuleType getModuleType() {
  return ModuleType.EMPTY; //or it could be other module type
}
 
Example #28
Source File: GaugeModuleBuilder.java    From Intellij-Plugin with Apache License 2.0 4 votes vote down vote up
@Override
public ModuleType getModuleType() {
    return GaugeModuleType.getInstance();
}
 
Example #29
Source File: DWModuleBuilder.java    From intellij-demandware with MIT License 4 votes vote down vote up
@Override
public ModuleType getModuleType() {
    return DWModuleType.getInstance();
}
 
Example #30
Source File: DemoModuleBuilder.java    From intellij-sdk-docs with Apache License 2.0 4 votes vote down vote up
@Override
public ModuleType getModuleType() {
  return DemoModuleType.getInstance();
}