Search in sources :

Example 11 with ILiferayProjectProvider

use of com.liferay.ide.core.ILiferayProjectProvider in project liferay-ide by liferay.

the class JSFModuleProjectProviderPossibleValuesService method initPossibleValuesService.

protected void initPossibleValuesService() {
    _possibleValues = new ArrayList<>();
    ILiferayProjectProvider[] jsfProviders = LiferayCore.getProviders("jsf-module");
    for (ILiferayProjectProvider provider : jsfProviders) {
        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 12 with ILiferayProjectProvider

use of com.liferay.ide.core.ILiferayProjectProvider in project liferay-ide by liferay.

the class FragmentProjectNameListener method updateLocation.

public static void updateLocation(NewModuleFragmentOp 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.getWorkspaceRoot().getLocation());
        } else {
            boolean gradleModule = false;
            boolean mavenModule = false;
            ILiferayProjectProvider iProvider = op.getProjectProvider().content();
            if (iProvider != null) {
                String shortName = iProvider.getShortName();
                if (!CoreUtil.empty(shortName) && shortName.startsWith("gradle")) {
                    gradleModule = true;
                } else {
                    mavenModule = true;
                }
            }
            if ((gradleModule && hasGradleWorkspace) || (mavenModule && hasMavenWorkspace)) {
                IProject liferayWorkspaceProject = LiferayWorkspaceUtil.getWorkspaceProject();
                if (FileUtil.exists(liferayWorkspaceProject)) {
                    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 13 with ILiferayProjectProvider

use of com.liferay.ide.core.ILiferayProjectProvider in project liferay-ide by liferay.

the class FragmentProjectProviderDefaultValueService method compute.

@Override
protected String compute() {
    String retval = "gradle-module-fragment";
    final IScopeContext[] prefContexts = { DefaultScope.INSTANCE, InstanceScope.INSTANCE };
    final String defaultProjectBuildType = Platform.getPreferencesService().getString(ProjectCore.PLUGIN_ID, ProjectCore.PREF_DEFAULT_MODULE_FRAGMENT_PROJECT_BUILD_TYPE_OPTION, null, prefContexts);
    if (defaultProjectBuildType != null) {
        final 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 14 with ILiferayProjectProvider

use of com.liferay.ide.core.ILiferayProjectProvider in project liferay-ide by liferay.

the class ModuleProjectProviderPossibleValuesService method initPossibleValuesService.

protected void initPossibleValuesService() {
    _possibleValues = new ArrayList<>();
    for (ILiferayProjectProvider provider : LiferayCore.getProviders("module")) {
        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)

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