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;
}
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();
}
}
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;
}
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();
}
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();
}
}
Aggregations