Search in sources :

Example 1 with ProjectType

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

the class ActionManagerImpl method registerChameleon.

private AnAction registerChameleon(String actionId, AnAction action, PluginId pluginId, String projectType) {
    ProjectType type = projectType == null ? null : new ProjectType(projectType);
    // make sure id+projectType is unique
    AnAction o = myId2Action.get(actionId);
    ChameleonAction chameleonAction;
    if (o == null) {
        chameleonAction = new ChameleonAction(action, type);
        myId2Action.put(actionId, chameleonAction);
        return chameleonAction;
    }
    if (o instanceof ChameleonAction) {
        chameleonAction = (ChameleonAction) o;
    } else {
        chameleonAction = new ChameleonAction(o, type);
        myId2Action.put(actionId, chameleonAction);
    }
    AnAction old = chameleonAction.addAction(action, type);
    if (old != null) {
        reportActionError(pluginId, "action with the ID \"" + actionId + "\" was already registered. Action being registered is " + action + "; Registered action is " + myId2Action.get(actionId) + getPluginInfo(pluginId));
        return null;
    }
    return chameleonAction;
}
Also used : ProjectType(com.intellij.openapi.project.ProjectType)

Example 2 with ProjectType

use of com.intellij.openapi.project.ProjectType in project liferay-ide by liferay.

the class LiferayModuleBuilder method setupRootModel.

@Override
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
    Project project = rootModel.getProject();
    ProjectType liferayProjectType = LiferayProjectTypeService.getProjectType(project);
    VirtualFile moduleDir = _createAndGetContentEntry();
    VirtualFile moduleParentDir = moduleDir.getParent();
    StringBuilder sb = new StringBuilder();
    sb.append("create ");
    sb.append("-d \"");
    sb.append(moduleParentDir.getPath());
    sb.append("\" ");
    String typeId = liferayProjectType.getId();
    if ((liferayProjectType != null) && typeId.equals(LiferayProjectType.LIFERAY_MAVEN_WORKSPACE)) {
        sb.append("-b ");
        sb.append("maven ");
    }
    sb.append("-t ");
    sb.append(_type);
    sb.append(" ");
    if (!CoreUtil.isNullOrEmpty(_className)) {
        sb.append("-c ");
        sb.append(_className);
        sb.append(" ");
    }
    if (!CoreUtil.isNullOrEmpty(_packageName)) {
        sb.append("-p ");
        sb.append(_packageName);
        sb.append(" ");
    }
    if ((_type.equals("service") || _type.equals("service-wrapper")) && !CoreUtil.isNullOrEmpty(_serviceName)) {
        sb.append("-s ");
        sb.append(_serviceName);
        sb.append(" ");
    }
    sb.append("\"");
    sb.append(moduleDir.getName());
    sb.append("\" ");
    BladeCLI.execute(sb.toString());
    rootModel.addContentEntry(moduleDir);
    if (myJdk != null) {
        rootModel.setSdk(myJdk);
    } else {
        rootModel.inheritSdk();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) ProjectType(com.intellij.openapi.project.ProjectType)

Example 3 with ProjectType

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

the class ChameleonAction method getAction.

@Nullable
private AnAction getAction(AnActionEvent e) {
    Project project = e.getProject();
    ProjectType projectType = ProjectTypeService.getProjectType(project);
    AnAction action = myActions.get(projectType);
    if (action == null)
        action = myActions.get(null);
    return action;
}
Also used : Project(com.intellij.openapi.project.Project) ProjectType(com.intellij.openapi.project.ProjectType) AnAction(com.intellij.openapi.actionSystem.AnAction) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with ProjectType

use of com.intellij.openapi.project.ProjectType in project liferay-ide by liferay.

the class LiferayProjectTypeService method getProjectType.

@Nullable
public static ProjectType getProjectType(@Nullable Project project) {
    ProjectType projectType;
    if (project != null) {
        projectType = getInstance(project)._projectType;
        if (projectType != null) {
            return projectType;
        }
    }
    boolean liferayGradleProject = LiferayWorkspaceUtil.isValidGradleWorkspaceLocation(project.getBasePath());
    if (liferayGradleProject == true) {
        return new ProjectType(LiferayProjectType.LIFERAY_GRADLE_WORKSPACE);
    }
    boolean liferayMavenProject = LiferayWorkspaceUtil.isValidMavenWorkspaceLocation(project);
    if (liferayMavenProject == true) {
        return new ProjectType(LiferayProjectType.LIFERAY_MAVEN_WORKSPACE);
    }
    return DefaultProjectTypeEP.getDefaultProjectType();
}
Also used : LiferayProjectType(com.liferay.ide.idea.ui.modules.LiferayProjectType) ProjectType(com.intellij.openapi.project.ProjectType) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with ProjectType

use of com.intellij.openapi.project.ProjectType 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

ProjectType (com.intellij.openapi.project.ProjectType)6 Project (com.intellij.openapi.project.Project)4 Nullable (org.jetbrains.annotations.Nullable)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 GradleSyncListener (com.android.tools.idea.gradle.project.sync.GradleSyncListener)1 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 AnAction (com.intellij.openapi.actionSystem.AnAction)1 Module (com.intellij.openapi.module.Module)1 ModuleType (com.intellij.openapi.module.ModuleType)1 StdModuleTypes (com.intellij.openapi.module.StdModuleTypes)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 ModuleListener (com.intellij.openapi.project.ModuleListener)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 FileUtilRt (com.intellij.openapi.util.io.FileUtilRt)1 LocalFileSystem (com.intellij.openapi.vfs.LocalFileSystem)1 MessageBusConnection (com.intellij.util.messages.MessageBusConnection)1 LiferayProjectTypeService (com.liferay.ide.idea.core.LiferayProjectTypeService)1