Search in sources :

Example 1 with SwitchConsumer

use of com.liferay.ide.idea.util.SwitchConsumer in project liferay-ide by liferay.

the class LiferayModuleFragmentBuilder method setupRootModel.

@Override
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
    VirtualFile projectRoot = _createAndGetContentEntry();
    Project project = rootModel.getProject();
    ProjectType liferayProjectType = LiferayProjectTypeService.getProjectType(project);
    _createProject(projectRoot, liferayProjectType.getId());
    File hostBundle = new File(LiferayIdeaUI.USER_BUNDLES_DIR, _fragmentHost.substring(0, _fragmentHost.lastIndexOf(".jar")));
    SwitchConsumerBuilder<File> switch_ = SwitchConsumer.newBuilder();
    SwitchConsumer<File> switchConsumer = switch_.addCase(f -> f.getName().equals("portlet.properties"), f -> _copyPortletExtProperties(projectRoot, f)).addCase(f -> f.getName().contains("default.xml"), f -> _createDefaultExtXmlFile(projectRoot, f)).setDefault(f -> _copyOtherResource(projectRoot, f)).build();
    Stream<String> stream = Stream.of(_overrideFiles);
    stream.map(overrideFile -> new File(hostBundle, overrideFile)).filter(file -> file.exists()).forEach(switchConsumer);
    rootModel.addContentEntry(projectRoot);
    if (myJdk != null) {
        rootModel.setSdk(myJdk);
    } else {
        rootModel.inheritSdk();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileUtilRt(com.intellij.openapi.util.io.FileUtilRt) ModuleBuilder(com.intellij.ide.util.projectWizard.ModuleBuilder) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) FileUtil(com.liferay.ide.idea.util.FileUtil) Project(com.intellij.openapi.project.Project) ModuleType(com.intellij.openapi.module.ModuleType) LiferayIdeaUI(com.liferay.ide.idea.ui.LiferayIdeaUI) LiferayProjectTypeService(com.liferay.ide.idea.core.LiferayProjectTypeService) Path(java.nio.file.Path) StdModuleTypes(com.intellij.openapi.module.StdModuleTypes) ProjectType(com.intellij.openapi.project.ProjectType) SwitchConsumer(com.liferay.ide.idea.util.SwitchConsumer) Icon(javax.swing.Icon) FileSystem(java.nio.file.FileSystem) Disposable(com.intellij.openapi.Disposable) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) File(java.io.File) WizardContext(com.intellij.ide.util.projectWizard.WizardContext) SwitchConsumerBuilder(com.liferay.ide.idea.util.SwitchConsumer.SwitchConsumerBuilder) Stream(java.util.stream.Stream) BladeCLI(com.liferay.ide.idea.util.BladeCLI) ConfigurationException(com.intellij.openapi.options.ConfigurationException) FileSystems(java.nio.file.FileSystems) Project(com.intellij.openapi.project.Project) ProjectType(com.intellij.openapi.project.ProjectType) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Aggregations

ModuleBuilder (com.intellij.ide.util.projectWizard.ModuleBuilder)1 ModuleWizardStep (com.intellij.ide.util.projectWizard.ModuleWizardStep)1 WizardContext (com.intellij.ide.util.projectWizard.WizardContext)1 Disposable (com.intellij.openapi.Disposable)1 ModuleType (com.intellij.openapi.module.ModuleType)1 StdModuleTypes (com.intellij.openapi.module.StdModuleTypes)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 Project (com.intellij.openapi.project.Project)1 ProjectType (com.intellij.openapi.project.ProjectType)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 FileUtilRt (com.intellij.openapi.util.io.FileUtilRt)1 LocalFileSystem (com.intellij.openapi.vfs.LocalFileSystem)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 LiferayProjectTypeService (com.liferay.ide.idea.core.LiferayProjectTypeService)1 LiferayIdeaUI (com.liferay.ide.idea.ui.LiferayIdeaUI)1 BladeCLI (com.liferay.ide.idea.util.BladeCLI)1 FileUtil (com.liferay.ide.idea.util.FileUtil)1 SwitchConsumer (com.liferay.ide.idea.util.SwitchConsumer)1 SwitchConsumerBuilder (com.liferay.ide.idea.util.SwitchConsumer.SwitchConsumerBuilder)1 File (java.io.File)1