Search in sources :

Example 1 with ILiferayProjectProvider

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);
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IPath(org.eclipse.core.runtime.IPath) ILiferayProjectProvider(com.liferay.ide.core.ILiferayProjectProvider) IProject(org.eclipse.core.resources.IProject)

Example 2 with ILiferayProjectProvider

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;
}
Also used : IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) ILiferayProjectProvider(com.liferay.ide.core.ILiferayProjectProvider)

Example 3 with ILiferayProjectProvider

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);
}
Also used : ILiferayProjectProvider(com.liferay.ide.core.ILiferayProjectProvider) NewLiferayProjectProvider(com.liferay.ide.project.core.NewLiferayProjectProvider)

Example 4 with ILiferayProjectProvider

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;
}
Also used : IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) ILiferayProjectProvider(com.liferay.ide.core.ILiferayProjectProvider)

Example 5 with ILiferayProjectProvider

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);
}
Also used : ILiferayProjectProvider(com.liferay.ide.core.ILiferayProjectProvider)

Aggregations

ILiferayProjectProvider (com.liferay.ide.core.ILiferayProjectProvider)14 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)5 NewLiferayProjectProvider (com.liferay.ide.project.core.NewLiferayProjectProvider)3 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)2 IProject (org.eclipse.core.resources.IProject)2 IPath (org.eclipse.core.runtime.IPath)2 Path (org.eclipse.sapphire.modeling.Path)2 IPortletFramework (com.liferay.ide.project.core.IPortletFramework)1 SDK (com.liferay.ide.sdk.core.SDK)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1 Status (org.eclipse.sapphire.modeling.Status)1 Version (org.osgi.framework.Version)1