use of com.liferay.ide.core.ILiferayProjectProvider in project liferay-ide by liferay.
the class ModuleProjectNameListener method updateLocation.
public static void updateLocation(NewLiferayModuleProjectOp op) {
String currentProjectName = op.getProjectName().content(true);
if ((currentProjectName == null) || CoreUtil.isNullOrEmpty(currentProjectName.trim())) {
return;
}
boolean useDefaultLocation = op.getUseDefaultLocation().content(true);
if (useDefaultLocation) {
Path newLocationBase = null;
boolean hasLiferayWorkspace = false;
boolean hasGradleWorkspace = false;
boolean hasMavenWorkspace = false;
try {
hasLiferayWorkspace = LiferayWorkspaceUtil.hasWorkspace();
hasGradleWorkspace = LiferayWorkspaceUtil.hasGradleWorkspace();
hasMavenWorkspace = LiferayWorkspaceUtil.hasMavenWorkspace();
} catch (Exception e) {
ProjectCore.logError("Failed to check LiferayWorkspace project.");
}
if (!hasLiferayWorkspace) {
newLocationBase = PathBridge.create(CoreUtil.getWorkspaceRootLocation());
} else {
boolean gradleModule = false;
boolean mavenModule = false;
ILiferayProjectProvider provider = op.getProjectProvider().content();
if (provider != null) {
String shortName = provider.getShortName();
if (!CoreUtil.empty(shortName) && shortName.startsWith("gradle")) {
gradleModule = true;
} else {
mavenModule = true;
}
}
boolean themeProject = false;
if (op instanceof NewLiferayModuleProjectOp) {
NewLiferayModuleProjectOp moduleProjectOp = (NewLiferayModuleProjectOp) op;
String projectTemplateName = moduleProjectOp.getProjectTemplateName().content();
for (String projectType : _WAR_TYPE_PROJECT) {
if (projectType.equals(projectTemplateName)) {
themeProject = true;
}
}
}
if ((gradleModule && hasGradleWorkspace) || (mavenModule && hasMavenWorkspace)) {
IProject liferayWorkspaceProject = LiferayWorkspaceUtil.getWorkspaceProject();
if (FileUtil.exists(liferayWorkspaceProject)) {
if (themeProject) {
String[] warsNames = LiferayWorkspaceUtil.getWarsDirs(liferayWorkspaceProject);
// use the first configured wars fodle name
newLocationBase = PathBridge.create(liferayWorkspaceProject.getLocation().append(warsNames[0]));
} else {
String folder = LiferayWorkspaceUtil.getModulesDir(liferayWorkspaceProject);
if (folder != null) {
IPath appendPath = liferayWorkspaceProject.getLocation().append(folder);
newLocationBase = PathBridge.create(appendPath);
}
}
}
} else {
newLocationBase = PathBridge.create(CoreUtil.getWorkspaceRoot().getLocation());
}
}
if (newLocationBase != null) {
op.setLocation(newLocationBase);
}
}
}
use of com.liferay.ide.core.ILiferayProjectProvider in project liferay-ide by liferay.
the class ModuleProjectProviderDefaultValueService method compute.
@Override
protected String compute() {
String retval = "gradle-module";
IScopeContext[] prefContexts = { DefaultScope.INSTANCE, InstanceScope.INSTANCE };
String defaultProjectBuildType = Platform.getPreferencesService().getString(ProjectCore.PLUGIN_ID, ProjectCore.PREF_DEFAULT_MODULE_PROJECT_BUILD_TYPE_OPTION, null, prefContexts);
if (defaultProjectBuildType != null) {
ILiferayProjectProvider provider = LiferayCore.getProvider(defaultProjectBuildType);
if (provider != null) {
retval = defaultProjectBuildType;
}
}
return retval;
}
use of com.liferay.ide.core.ILiferayProjectProvider in project liferay-ide by liferay.
the class FragmentProjectProviderPossibleValuesService method initPossibleValuesService.
protected void initPossibleValuesService() {
_possibleValues = new ArrayList<>();
for (final ILiferayProjectProvider provider : LiferayCore.getProviders("module-fragment")) {
if (provider instanceof NewLiferayProjectProvider<?>) {
_possibleValues.add(provider.getShortName());
}
}
Collections.sort(_possibleValues);
}
use of com.liferay.ide.core.ILiferayProjectProvider in project liferay-ide by liferay.
the class WorkspaceProjectProviderDefaultValueService method compute.
@Override
protected String compute() {
String retval = "gradle-liferay-workspace";
IScopeContext[] prefContexts = { DefaultScope.INSTANCE, InstanceScope.INSTANCE };
String defaultProjectBuildType = Platform.getPreferencesService().getString(ProjectCore.PLUGIN_ID, ProjectCore.PREF_DEFAULT_WORKSPACE_PROJECT_BUILD_TYPE_OPTION, null, prefContexts);
if (defaultProjectBuildType != null) {
ILiferayProjectProvider provider = LiferayCore.getProvider(defaultProjectBuildType);
if (provider != null) {
retval = defaultProjectBuildType;
}
}
return retval;
}
use of com.liferay.ide.core.ILiferayProjectProvider in project liferay-ide by liferay.
the class WorkspaceProjectProviderPossibleValuesService method initPossibleValuesService.
protected void initPossibleValuesService() {
_possibleValues = new ArrayList<>();
for (ILiferayProjectProvider provider : LiferayCore.getProviders("workspace")) {
if (provider instanceof NewLiferayWorkspaceProjectProvider<?>) {
_possibleValues.add(provider.getShortName());
}
}
Collections.sort(_possibleValues);
}
Aggregations